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
39a6151e2f76b644017079b75709e7481f19dd5d
923
h
C
src/Core/Rigid/rigid_2d.h
Oncle-Ha/peridyno
7952252923d637685bf3a982856aca8095b78c50
[ "Apache-2.0" ]
22
2021-05-26T09:19:07.000Z
2022-03-28T04:06:21.000Z
src/Core/Rigid/rigid_2d.h
Oncle-Ha/peridyno
7952252923d637685bf3a982856aca8095b78c50
[ "Apache-2.0" ]
1
2021-07-27T09:43:42.000Z
2022-02-07T14:47:18.000Z
src/Core/Rigid/rigid_2d.h
Oncle-Ha/peridyno
7952252923d637685bf3a982856aca8095b78c50
[ "Apache-2.0" ]
11
2021-04-24T03:43:33.000Z
2022-03-11T14:09:21.000Z
#pragma once #include <iostream> #include "rigid_base.h" #include "../Vector.h" #include "../Matrix.h" namespace dyno { template <typename T> class Rigid<T, 2> { public: typedef Vector<T, 2> TranslationDOF; typedef T RotationDOF; DYN_FUNC Rigid() : m_p(0) , m_angle(0) {}; DYN_FUNC Rigid(Vector<T, 2> p, T angle) : m_p(p) , m_angle(angle) {}; DYN_FUNC ~Rigid() {}; DYN_FUNC T getOrientation() const { return m_angle; } DYN_FUNC Vector<T, 2> getCenter() const { return m_p; } DYN_FUNC SquareMatrix<T, 2> getRotationMatrix() const { return SquareMatrix<T, 2>(glm::cos(m_angle), -glm::sin(m_angle), glm::sin(m_angle), glm::cos(m_angle)); } private: Vector<T, 2> m_p; T m_angle; }; template class Rigid<float, 2>; template class Rigid<double, 2>; //convenient typedefs typedef Rigid<float, 2> Rigid2f; typedef Rigid<double, 2> Rigid2d; } //end of namespace dyno
20.511111
67
0.657638
[ "vector" ]
39a7ed8a8308179fb90a44412d65fa3752347d58
1,814
h
C
iraf.v2161/noao/nproto/ace/cat.h
ysBach/irafdocgen
b11fcd75cc44b01ae69c9c399e650ec100167a54
[ "MIT" ]
2
2019-12-01T15:19:09.000Z
2019-12-02T16:48:42.000Z
noao/nproto/ace/cat.h
kirxkirx/iraf
fcd7569b4e0ddbea29f7dbe534a25759e0c31883
[ "MIT" ]
1
2019-11-30T13:48:50.000Z
2019-12-02T19:40:25.000Z
noao/nproto/ace/cat.h
kirxkirx/iraf
fcd7569b4e0ddbea29f7dbe534a25759e0c31883
[ "MIT" ]
null
null
null
# Catalog structure. define CAT_SZSTR 99 # Length of catalog string define CAT_LEN 160 # Length of catalog structure define CAT_OBJS Memi[$1] # Array of objects (ptr) define CAT_APFLUX Memi[$1+1] # Array of aperture fluxes (ptr) define CAT_NOBJS Memi[$1+2] # Number of objects define CAT_NUMMAX Memi[$1+3] # Maximum object number define CAT_FLAGS Memi[$1+4] # Catalog flags define CAT_HDR Memi[$1+5] # Header structure define CAT_INTBL Memi[$1+6] # Input table structure define CAT_OUTTBL Memi[$1+7] # Output table structure define CAT_MAGZERO Memr[P2R($1+8)] # Magnitude zero define CAT_CATALOG Memc[P2C($1+10)] # Catalog name define CAT_OBJID Memc[P2C($1+60)] # Default ID define CAT_STRPTR P2C($1+110) # Working string buffer define CAT_STR Memc[CAT_STRPTR($1)] # Working string buffer # Table structure. define TBL_LEN 2 define TBL_TP Memi[$1] # Table pointer define TBL_STP Memi[$1+1] # Symbol table of entries # Entry structure. define ENTRY_ULEN 19 # Length of units string define ENTRY_FLEN 19 # Length of format string define ENTRY_DLEN 99 # Length of description string define ENTRY_LEN 95 # Length of entry structure define ENTRY_CDEF Memi[$1] # Column descriptor define ENTRY_ID Memi[$1+1] # Entry id define ENTRY_TYPE Memi[$1+2] # Datatype in object record define ENTRY_CTYPE Memi[$1+3] # Datatype in catalog define ENTRY_FUNC Memi[$1+4] # Entry function define ENTRY_RAP Memr[P2R($1+5)] # Entry aperture radius define ENTRY_UNITS Memc[P2C($1+6)] # Entry units (19) define ENTRY_FORMAT Memc[P2C($1+26)] # Entry format (19) define ENTRY_DESC Memc[P2C($1+46)] # Entry description (99) define FUNCS "|MAG|" define FUNC_MAG 1 # Magnitude # Catalog extensions. define CATEXTNS "|fits|tab|" # Catalog Parameters. define CATPARAMS "|image|mask|objid|catalog|nobjects|magzero|"
39.434783
62
0.750827
[ "object" ]
39ae5fee8e9794a5972d14a8b4c21afeed391e2b
8,057
h
C
src/estimators/ransac_similarity.h
Yzhbuaa/DAGSfM
321f9bf24456f2e68aa4ea3d7a59c39040fe1f1f
[ "BSD-3-Clause" ]
255
2018-12-14T05:59:29.000Z
2020-11-04T12:15:32.000Z
src/estimators/ransac_similarity.h
Yzhbuaa/DAGSfM
321f9bf24456f2e68aa4ea3d7a59c39040fe1f1f
[ "BSD-3-Clause" ]
35
2018-12-25T03:02:48.000Z
2020-11-19T03:33:25.000Z
src/estimators/ransac_similarity.h
Yzhbuaa/DAGSfM
321f9bf24456f2e68aa4ea3d7a59c39040fe1f1f
[ "BSD-3-Clause" ]
54
2018-12-14T06:09:21.000Z
2020-11-21T08:29:31.000Z
// BSD 3-Clause License // Copyright (c) 2020, Chenyu // All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // 1. Redistributions of source code must retain the above copyright notice, // this // list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // 3. Neither the name of the copyright holder nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. #ifndef ESTIMATORS_RANSAC_SIMILARITY_H_ #define ESTIMATORS_RANSAC_SIMILARITY_H_ #include <Eigen/Core> #include <Eigen/Dense> #include <algorithm> #include <ctime> #include <random> #include <vector> #include "estimators/rigid_transformation3D_srt.h" #include "estimators/sim3.h" #include "ransac/estimator.h" #include "ransac/prosac.h" #include "solver/l1_solver.h" using namespace std; using namespace Eigen; namespace DAGSfM { inline double ReprojectionErr(const Vector3d& point1, const Vector3d& point2, const Matrix3d& R, const Vector3d& t, const double& scale) { Vector3d transformed_point = scale * R * point1 + t; return (transformed_point - point2).norm(); } struct Euclidean3D { Eigen::Matrix3d R; Eigen::Vector3d t; Euclidean3D() { R = Eigen::Matrix3d::Identity(); t = Eigen::Vector3d::Zero(); } Euclidean3D(const Eigen::Matrix3d& rotation, const Eigen::Vector3d& translation) { R = rotation; t = translation; } Euclidean3D(const Euclidean3D& eu) { R = eu.R; t = eu.t; } }; struct Correspondence3D { Eigen::Vector3d p1; Eigen::Vector3d p2; Correspondence3D() { p1 = Eigen::Vector3d::Zero(); p2 = Eigen::Vector3d::Zero(); } Correspondence3D(const Eigen::Vector3d& point1, const Eigen::Vector3d& point2) { p1 = point1; p2 = point2; } }; class SimilarityEstimator : public Estimator<Correspondence3D, Sim3> { public: SimilarityEstimator() {} ~SimilarityEstimator() {} double SampleSize() const { return 4; } bool EstimateModel(const std::vector<Correspondence3D>& data, std::vector<Sim3>* models) const { Sim3 model; int sample_size = (int)SampleSize(); Eigen::MatrixXd x1 = MatrixXd::Zero(3, sample_size); Eigen::MatrixXd x2 = MatrixXd::Zero(3, sample_size); for (int i = 0; i < sample_size; i++) { x1.col(i) = data[i].p1; x2.col(i) = data[i].p2; } DAGSfM::FindRTS(x1, x2, &model.s, &model.t, &model.R); // DAGSfM::Refine_RTS(x1, x2, &model.s, &model.t, &model.R); models->push_back(model); return true; } double Error(const Correspondence3D& corre, const Sim3& sim3) const { return ReprojectionErr(corre.p1, corre.p2, sim3.R, sim3.t, sim3.s); } }; typedef std::pair<Euclidean3D, Euclidean3D> CorrespondenceEuc; class EuclideanEstimator : public Estimator<CorrespondenceEuc, Euclidean3D> { private: double _s; // fixed scale std::vector<Correspondence3D> _correspondences; public: EuclideanEstimator() {} EuclideanEstimator(const double& scale, const std::vector<Correspondence3D>& correspondences) : Estimator<CorrespondenceEuc, Euclidean3D>() { _s = scale; _correspondences.assign(correspondences.begin(), correspondences.end()); } ~EuclideanEstimator() {} double SampleSize() const { return 1; } bool EstimateModel(const std::vector<CorrespondenceEuc>& data, std::vector<Euclidean3D>* models) const { Euclidean3D model; int sample_size = (int)SampleSize(); // double angle_axis[3] = {0, 0, 0}; for (int i = 0; i < sample_size; i++) { Eigen::Matrix3d R_a = data[i].first.R, R_b = data[i].second.R; Eigen::Matrix3d R_ab = R_b.transpose() * R_a; model.R = R_ab; } std::vector<Eigen::Vector3d> translations; // construct a l1-solver to solve: argmin |T - t_{ab}|_1 Eigen::MatrixXd A(3 * sample_size, 3); Eigen::VectorXd b(3 * sample_size); Eigen::VectorXd solution = Eigen::Vector3d::Zero(); for (int i = 0; i < sample_size; i++) { A(3 * i + 0, 0) = A(3 * i + 1, 1) = A(3 * i + 2, 2) = 1.0; } for (int i = 0; i < sample_size; i++) { Eigen::Matrix3d R_b = data[i].second.R; Eigen::Vector3d t_a = data[i].first.t, t_b = data[i].second.t; Eigen::Vector3d t_ab = _s * R_b.transpose() * t_a - R_b.transpose() * t_b; b[3 * i + 0] = t_ab[0]; b[3 * i + 1] = t_ab[1]; b[3 * i + 2] = t_ab[2]; translations.push_back(t_ab); } // L1Solver<Eigen::MatrixXd>::Options options; // options.max_num_iterations = 500; // L1Solver<Eigen::MatrixXd> l1_solver(options, A); // l1_solver.Solve(b, &solution); // model.t = solution; model.t = translations[0]; models->push_back(model); return true; } double Error(const CorrespondenceEuc& ceuc, const Euclidean3D& euc) const { // double reproj_err = 0.0; // for (int i = 0; i < _correspondences.size(); i++) { // reproj_err += ReprojectionErr(_correspondences[i].p1, // _correspondences[i].p2, // euc.R, euc.t, _s); // } // reproj_err /= (double)_correspondences.size(); // return reproj_err; const Eigen::Vector3d c1 = -ceuc.first.R.transpose() * ceuc.first.t; const Eigen::Vector3d c2 = -ceuc.second.R.transpose() * ceuc.second.t; return ReprojectionErr(c1, c2, euc.R, euc.t, _s); } }; inline void RansacSimilarity(const vector<Vector3d>& points1, const vector<Vector3d>& points2, vector<Vector3d>& inliers1, vector<Vector3d>& inliers2, Matrix3d& R, Vector3d& t, double& scale, const double threshold = 0.001, const double p = 0.99) { int size = points1.size(); // prepare input data std::vector<Correspondence3D> input_points; for (int i = 0; i < size; i++) { input_points.push_back(Correspondence3D(points1[i], points2[i])); } SimilarityEstimator sim3_estimator; Sim3 sim3; RansacParameters params; params.rng = std::make_shared<RandomNumberGenerator>((unsigned int)time(NULL)); params.error_thresh = threshold; params.max_iterations = 5000; params.use_mle = true; Prosac<SimilarityEstimator> prosac_sim3(params, sim3_estimator); prosac_sim3.Initialize(); RansacSummary summary; // LOG(INFO) << "Estimating..."; prosac_sim3.Estimate(input_points, &sim3, &summary); // LOG(INFO) << "Estimate ends"; std::vector<int> inlier_indeces = summary.inliers; for (auto index : inlier_indeces) { inliers1.push_back(input_points[index].p1); inliers2.push_back(input_points[index].p2); } R = sim3.R; t = sim3.t; scale = sim3.s; } } // namespace DAGSfM #endif
32.487903
80
0.650863
[ "vector", "model" ]
39b458aaf7e852fb9d70b815c60aa078042d1063
3,269
h
C
src/classifier/nearest_neighbor.h
amadavan/OCR
05c323593302c9183005b067cdf1d48864727f29
[ "MIT" ]
null
null
null
src/classifier/nearest_neighbor.h
amadavan/OCR
05c323593302c9183005b067cdf1d48864727f29
[ "MIT" ]
null
null
null
src/classifier/nearest_neighbor.h
amadavan/OCR
05c323593302c9183005b067cdf1d48864727f29
[ "MIT" ]
null
null
null
#ifndef OCR_CLASSIFIER_NEAREST_NEIGHBOR_H_ #define OCR_CLASSIFIER_NEAREST_NEIGHBOR_H_ #include "classifier/classifier.h" #include <float.h> #include <string.h> #include "metric/metric.h" #include "metric/pnorm_metric.h" #include "util/ocrtypes.h" namespace ocr { /** * A simple Nearest-Neighbor algorithm implementation. * * Defines the methodology for implementing a Nearest-Neighbor algorithm. */ class NearestNeighbor : public ClassifierInterface { public: friend class NearestNeighborTests; /** * Constructor for nearest neighbor from metric * * Defines the Nearest Neighbor classifier with a given distance metric used * to determine the closest neighbors. Defaults to empty p-norm. * * @param[in] metric A metric specified by the Metric class */ NearestNeighbor( Metric *metric = new PNorm() ); ~NearestNeighbor() {} /** * Trains the classifier given a dataset and known labels for the set * * Uses the known dataset and labels to generate the algorithm that will * later be used to predict the values of unknown data. This method should * be run prior to any testing methods (including test, test_batch...) * * @param[in] data_set nxm matrix with each entry in a column * @param[in] label_set mx1 vector of data_set labels */ void train(const arma::mat &data_set, const arma::Col<label_t> &label_set); /** * Predict the label of a single vector. * * Uses the trained algorithm to determine the label of a specified nx1 * vector where n is the number of elements in each dataset entry. This * method assumes that the training method has already been completed. * * @param[in] predict_vector nx1 vector, whose label is desired * * @return classification label (defined by type label_t) of the input * vector */ label_t predict( const arma::vec &predict_vector ); /** * Predict the labels of several vectors. * * Uses the trained algorithm to determine the label of each n-dimensional * column vector in a nxm matrix of entries where each entry is stored in * a column. This method assumes that the training method has already been * completed. * * @param[in] test_mat nxm matrix with each entry in a column * * @return column vector of classification labels (defined by type label_t) * where each i-th entry corresponds to the i-th column of the input */ label_t* test( const arma::mat &test_mat ); /** * Determine the error rate for a given test set * * Computes the labels for a given dataset and compares to given known * labels. The resulting comparison is used to determine the overall * error rate of the algorithm for that dataset. This method assumes that * the training method has already been completed. * * @param[in] test_mat nxm matrix with each entry in a column * @param[in] true_labels mx1 column vector of true labels * @param[out] predicted_labels mx1 column vector of predicted labels * * @return fractional error rate */ double validate( const arma::mat &test_mat, const arma::Col<label_t> &true_labels, arma::Col<label_t> *predicted_labels = nullptr ); private: arma::mat training_set_; arma::Col<label_t> training_labels_; Metric *metric_; }; } #endif // OCR_CLASSIFIER_NEAREST_NEIGHBOR_H_
32.04902
77
0.733558
[ "vector" ]
39b89b5ab71c1e9b3e76b4bb043e78646e900946
197
h
C
Homeworks/1_MiniDraw/project/src/App/Ellipse.h
Chaphlagical/USTC_CG
9f8b0321e09e5a05afb1c93303e3c736f78503fa
[ "MIT" ]
13
2020-05-21T03:12:48.000Z
2022-01-20T01:25:02.000Z
Homeworks/1_MiniDraw/project/src/App/Ellipse.h
lyf7115/USTC_CG
9f8b0321e09e5a05afb1c93303e3c736f78503fa
[ "MIT" ]
null
null
null
Homeworks/1_MiniDraw/project/src/App/Ellipse.h
lyf7115/USTC_CG
9f8b0321e09e5a05afb1c93303e3c736f78503fa
[ "MIT" ]
4
2020-06-13T13:14:14.000Z
2021-12-15T07:36:05.000Z
#ifndef ELLIPSE_H #define ELLIPSE_H #include"shape.h" namespace minidraw { class Ellipse :public Shape { public: Ellipse(); ~Ellipse(); void Draw(QPainter& painter); }; } #endif
10.368421
32
0.664975
[ "shape" ]
39bb81a1d6183d43e3e91de95cdba278daf749ad
48,072
h
C
src_main/deps/amd3dx/include/amd3dx.h
ArcadiusGFN/SourceEngine2007
51cd6d4f0f9ed901cb9b61456eb621a50ce44f55
[ "bzip2-1.0.6" ]
25
2018-02-28T15:04:42.000Z
2021-08-16T03:49:00.000Z
src_main/deps/amd3dx/include/amd3dx.h
ArcadiusGFN/SourceEngine2007
51cd6d4f0f9ed901cb9b61456eb621a50ce44f55
[ "bzip2-1.0.6" ]
1
2019-09-20T11:06:03.000Z
2019-09-20T11:06:03.000Z
src_main/deps/amd3dx/include/amd3dx.h
ArcadiusGFN/SourceEngine2007
51cd6d4f0f9ed901cb9b61456eb621a50ce44f55
[ "bzip2-1.0.6" ]
9
2019-07-31T11:58:20.000Z
2021-08-31T11:18:15.000Z
/****************************************************************************** Copyright (c) 1999 Advanced Micro Devices, Inc. LIMITATION OF LIABILITY: THE MATERIALS ARE PROVIDED *AS IS* WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT OF THIRD-PARTY INTELLECTUAL PROPERTY, OR FITNESS FOR ANY PARTICULAR PURPOSE. IN NO EVENT SHALL AMD OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, LOSS OF INFORMATION) ARISING OUT OF THE USE OF OR INABILITY TO USE THE MATERIALS, EVEN IF AMD HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME JURISDICTIONS PROHIBIT THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU. AMD does not assume any responsibility for any errors which may appear in the Materials nor any responsibility to support or update the Materials. AMD retains the right to make changes to its test specifications at any time, without notice. NO SUPPORT OBLIGATION: AMD is not obligated to furnish, support, or make any further information, software, technical information, know-how, or show-how available to you. So that all may benefit from your experience, please report any problems or suggestions about this software to 3dsdk.support@amd.com AMD Developer Technologies, M/S 585 Advanced Micro Devices, Inc. 5900 E. Ben White Blvd. Austin, TX 78741 3dsdk.support@amd.com ******************************************************************************* AMD3DX.H MACRO FORMAT ============ This file contains inline assembly macros that generate AMD-3D instructions in binary format. Therefore, C or C++ programmer can use AMD-3D instructions without any penalty in their C or C++ source code. The macro's name and format conventions are as follow: 1. First argument of macro is a destination and second argument is a source operand. ex) _asm PFCMPEQ (mm3, mm4) | | dst src 2. The destination operand can be m0 to m7 only. The source operand can be any one of the register m0 to m7 or _eax, _ecx, _edx, _ebx, _esi, or _edi that contains effective address. ex) _asm PFRCP (MM7, MM6) ex) _asm PFRCPIT2 (mm0, mm4) ex) _asm PFMUL (mm3, _edi) 3. The prefetch(w) takes one src operand _eax, ecx, _edx, _ebx, _esi, or _edi that contains effective address. ex) _asm PREFETCH (_edi) For WATCOM C/C++ users, when using #pragma aux instead if _asm, all macro names should be prefixed by a p_ or P_. Macros should not be enclosed in quotes. ex) p_pfrcp (MM7,MM6) NOTE: Not all instruction macros, nor all possible combinations of operands have been explicitely tested. If any errors are found, please report them. EXAMPLE ======= Following program doesn't do anything but it shows you how to use inline assembly AMD-3D instructions in C. Note that this will only work in flat memory model which segment registers cs, ds, ss and es point to the same linear address space total less than 4GB. Used Microsoft VC++ 5.0 #include <stdio.h> #include "amd3d.h" void main () { float x = (float)1.25; float y = (float)1.25; float z, zz; _asm { movd mm1, x movd mm2, y pfmul (mm1, mm2) movd z, mm1 femms } printf ("value of z = %f\n", z); // // Demonstration of using the memory instead of // multimedia register // _asm { movd mm3, x lea esi, y // load effective address of y pfmul (mm3, _esi) movd zz, mm3 femms } printf ("value of zz = %f\n", zz); } #pragma aux EXAMPLE with WATCOM C/C++ v11.x =========================================== extern void Add(float *__Dest, float *__A, float *__B); #pragma aux Add = \ p_femms \ "movd mm6,[esi]" \ p_pfadd(mm6,_edi) \ "movd [ebx],mm6" \ p_femms \ parm [ebx] [esi] [edi]; *******************************************************************************/ #ifndef _K3DMACROSINCLUDED_ #define _K3DMACROSINCLUDED_ #if defined(__WATCOMC__) // The WATCOM C/C++ version of the 3DNow! macros. // // The older, compbined register style for WATCOM C/C++ macros is not // supported. /* Operand defines for instructions two operands */ #define _k3d_mm0_mm0 0xc0 #define _k3d_mm0_mm1 0xc1 #define _k3d_mm0_mm2 0xc2 #define _k3d_mm0_mm3 0xc3 #define _k3d_mm0_mm4 0xc4 #define _k3d_mm0_mm5 0xc5 #define _k3d_mm0_mm6 0xc6 #define _k3d_mm0_mm7 0xc7 #define _k3d_mm0_eax 0x00 #define _k3d_mm0_ecx 0x01 #define _k3d_mm0_edx 0x02 #define _k3d_mm0_ebx 0x03 #define _k3d_mm0_esi 0x06 #define _k3d_mm0_edi 0x07 #define _k3d_mm1_mm0 0xc8 #define _k3d_mm1_mm1 0xc9 #define _k3d_mm1_mm2 0xca #define _k3d_mm1_mm3 0xcb #define _k3d_mm1_mm4 0xcc #define _k3d_mm1_mm5 0xcd #define _k3d_mm1_mm6 0xce #define _k3d_mm1_mm7 0xcf #define _k3d_mm1_eax 0x08 #define _k3d_mm1_ecx 0x09 #define _k3d_mm1_edx 0x0a #define _k3d_mm1_ebx 0x0b #define _k3d_mm1_esi 0x0e #define _k3d_mm1_edi 0x0f #define _k3d_mm2_mm0 0xd0 #define _k3d_mm2_mm1 0xd1 #define _k3d_mm2_mm2 0xd2 #define _k3d_mm2_mm3 0xd3 #define _k3d_mm2_mm4 0xd4 #define _k3d_mm2_mm5 0xd5 #define _k3d_mm2_mm6 0xd6 #define _k3d_mm2_mm7 0xd7 #define _k3d_mm2_eax 0x10 #define _k3d_mm2_ecx 0x11 #define _k3d_mm2_edx 0x12 #define _k3d_mm2_ebx 0x13 #define _k3d_mm2_esi 0x16 #define _k3d_mm2_edi 0x17 #define _k3d_mm3_mm0 0xd8 #define _k3d_mm3_mm1 0xd9 #define _k3d_mm3_mm2 0xda #define _k3d_mm3_mm3 0xdb #define _k3d_mm3_mm4 0xdc #define _k3d_mm3_mm5 0xdd #define _k3d_mm3_mm6 0xde #define _k3d_mm3_mm7 0xdf #define _k3d_mm3_eax 0x18 #define _k3d_mm3_ecx 0x19 #define _k3d_mm3_edx 0x1a #define _k3d_mm3_ebx 0x1b #define _k3d_mm3_esi 0x1e #define _k3d_mm3_edi 0x1f #define _k3d_mm4_mm0 0xe0 #define _k3d_mm4_mm1 0xe1 #define _k3d_mm4_mm2 0xe2 #define _k3d_mm4_mm3 0xe3 #define _k3d_mm4_mm4 0xe4 #define _k3d_mm4_mm5 0xe5 #define _k3d_mm4_mm6 0xe6 #define _k3d_mm4_mm7 0xe7 #define _k3d_mm4_eax 0x20 #define _k3d_mm4_ecx 0x21 #define _k3d_mm4_edx 0x22 #define _k3d_mm4_ebx 0x23 #define _k3d_mm4_esi 0x26 #define _k3d_mm4_edi 0x27 #define _k3d_mm5_mm0 0xe8 #define _k3d_mm5_mm1 0xe9 #define _k3d_mm5_mm2 0xea #define _k3d_mm5_mm3 0xeb #define _k3d_mm5_mm4 0xec #define _k3d_mm5_mm5 0xed #define _k3d_mm5_mm6 0xee #define _k3d_mm5_mm7 0xef #define _k3d_mm5_eax 0x28 #define _k3d_mm5_ecx 0x29 #define _k3d_mm5_edx 0x2a #define _k3d_mm5_ebx 0x2b #define _k3d_mm5_esi 0x2e #define _k3d_mm5_edi 0x2f #define _k3d_mm6_mm0 0xf0 #define _k3d_mm6_mm1 0xf1 #define _k3d_mm6_mm2 0xf2 #define _k3d_mm6_mm3 0xf3 #define _k3d_mm6_mm4 0xf4 #define _k3d_mm6_mm5 0xf5 #define _k3d_mm6_mm6 0xf6 #define _k3d_mm6_mm7 0xf7 #define _k3d_mm6_eax 0x30 #define _k3d_mm6_ecx 0x31 #define _k3d_mm6_edx 0x32 #define _k3d_mm6_ebx 0x33 #define _k3d_mm6_esi 0x36 #define _k3d_mm6_edi 0x37 #define _k3d_mm7_mm0 0xf8 #define _k3d_mm7_mm1 0xf9 #define _k3d_mm7_mm2 0xfa #define _k3d_mm7_mm3 0xfb #define _k3d_mm7_mm4 0xfc #define _k3d_mm7_mm5 0xfd #define _k3d_mm7_mm6 0xfe #define _k3d_mm7_mm7 0xff #define _k3d_mm7_eax 0x38 #define _k3d_mm7_ecx 0x39 #define _k3d_mm7_edx 0x3a #define _k3d_mm7_ebx 0x3b #define _k3d_mm7_esi 0x3e #define _k3d_mm7_edi 0x3f #define _k3d_name_xlat_m0 _mm0 #define _k3d_name_xlat_m1 _mm1 #define _k3d_name_xlat_m2 _mm2 #define _k3d_name_xlat_m3 _mm3 #define _k3d_name_xlat_m4 _mm4 #define _k3d_name_xlat_m5 _mm5 #define _k3d_name_xlat_m6 _mm6 #define _k3d_name_xlat_m7 _mm7 #define _k3d_name_xlat_M0 _mm0 #define _k3d_name_xlat_M1 _mm1 #define _k3d_name_xlat_M2 _mm2 #define _k3d_name_xlat_M3 _mm3 #define _k3d_name_xlat_M4 _mm4 #define _k3d_name_xlat_M5 _mm5 #define _k3d_name_xlat_M6 _mm6 #define _k3d_name_xlat_M7 _mm7 #define _k3d_name_xlat_mm0 _mm0 #define _k3d_name_xlat_mm1 _mm1 #define _k3d_name_xlat_mm2 _mm2 #define _k3d_name_xlat_mm3 _mm3 #define _k3d_name_xlat_mm4 _mm4 #define _k3d_name_xlat_mm5 _mm5 #define _k3d_name_xlat_mm6 _mm6 #define _k3d_name_xlat_mm7 _mm7 #define _k3d_name_xlat_MM0 _mm0 #define _k3d_name_xlat_MM1 _mm1 #define _k3d_name_xlat_MM2 _mm2 #define _k3d_name_xlat_MM3 _mm3 #define _k3d_name_xlat_MM4 _mm4 #define _k3d_name_xlat_MM5 _mm5 #define _k3d_name_xlat_MM6 _mm6 #define _k3d_name_xlat_MM7 _mm7 #define _k3d_name_xlat_eax _eax #define _k3d_name_xlat_ebx _ebx #define _k3d_name_xlat_ecx _ecx #define _k3d_name_xlat_edx _edx #define _k3d_name_xlat_esi _esi #define _k3d_name_xlat_edi _edi #define _k3d_name_xlat_ebp _ebp #define _k3d_name_xlat_EAX _eax #define _k3d_name_xlat_EBX _ebx #define _k3d_name_xlat_ECX _ecx #define _k3d_name_xlat_EDX _edx #define _k3d_name_xlat_ESI _esi #define _k3d_name_xlat_EDI _edi #define _k3d_name_xlat_EBP _ebp #define _k3d_name_xlat__eax _eax #define _k3d_name_xlat__ebx _ebx #define _k3d_name_xlat__ecx _ecx #define _k3d_name_xlat__edx _edx #define _k3d_name_xlat__esi _esi #define _k3d_name_xlat__edi _edi #define _k3d_name_xlat__ebp _ebp #define _k3d_name_xlat__EAX _eax #define _k3d_name_xlat__EBX _ebx #define _k3d_name_xlat__ECX _ecx #define _k3d_name_xlat__EDX _edx #define _k3d_name_xlat__ESI _esi #define _k3d_name_xlat__EDI _edi #define _k3d_name_xlat__EBP _ebp #define _k3d_xglue3(a, b, c) a##b##c #define _k3d_glue3(a, b, c) _k3d_xglue3(a, b, c) #define _k3d_MODRM(dst, src) _k3d_glue3(_k3d, _k3d_name_xlat_##dst, _k3d_name_xlat_##src) /* Operand defines for prefetch and prefetchw */ #define _k3d_pref_eax 0x00 #define _k3d_pref_ecx 0x01 #define _k3d_pref_edx 0x02 #define _k3d_pref_ebx 0x03 #define _k3d_pref_esi 0x06 #define _k3d_pref_edi 0x07 #define _k3d_pref_EAX 0x00 #define _k3d_pref_ECX 0x01 #define _k3d_pref_EDX 0x02 #define _k3d_pref_EBX 0x03 #define _k3d_pref_ESI 0x06 #define _k3d_pref_EDI 0x07 #define _k3d_prefw_eax 0x08 #define _k3d_prefw_ecx 0x09 #define _k3d_prefw_edx 0x0A #define _k3d_prefw_ebx 0x0B #define _k3d_prefw_esi 0x0E #define _k3d_prefw_edi 0x0F #define _k3d_prefw_EAX 0x08 #define _k3d_prefw_ECX 0x09 #define _k3d_prefw_EDX 0x0A #define _k3d_prefw_EBX 0x0B #define _k3d_prefw_ESI 0x0E #define _k3d_prefw_EDI 0x0F /* Defines for 3DNow! instructions */ #define PF2ID(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0x1d #define PFACC(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0xae #define PFADD(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0x9e #define PFCMPEQ(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0xb0 #define PFCMPGE(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0x90 #define PFCMPGT(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0xa0 #define PFMAX(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0xa4 #define PFMIN(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0x94 #define PFMUL(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0xb4 #define PFRCP(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0x96 #define PFRCPIT1(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0xa6 #define PFRCPIT2(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0xb6 #define PFRSQRT(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0x97 #define PFRSQIT1(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0xa7 #define PFSUB(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0x9a #define PFSUBR(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0xaa #define PI2FD(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0x0d #define FEMMS db 0x0f, 0x0e #define PAVGUSB(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0xbf #define PMULHRW(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0xb7 #define PREFETCH(src) db 0x0f, 0x0d, _k3d_pref_##src #define PREFETCHW(src) db 0x0f, 0x0d, _k3d_prefw_##src #define CPUID db 0x0f, 0xa2 /* Defines for new, K7 opcodes */ #define PFNACC(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0x8a #define FPPNACC(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0x8e #define PSWAPD(dst, src) db 0x0f, 0x0f, _k3d_MODRM(dst, src), 0xbb #define PMINUB(dst, src) db 0x0f, 0xda, _k3d_MODRM(dst, src) #define PMAXUB(dst, src) db 0x0f, 0xde, _k3d_MODRM(dst, src) #define PMINSW(dst, src) db 0x0f, 0xea, _k3d_MODRM(dst, src) #define PMAXSW(dst, src) db 0x0f, 0xee, _k3d_MODRM(dst, src) #define PMULHUW(dst, src) db 0x0f, 0xe4, _k3d_MODRM(dst, src) #define PAVGB(dst, src) db 0x0f, 0xe0, _k3d_MODRM(dst, src) #define PAVGW(dst, src) db 0x0f, 0xe3, _k3d_MODRM(dst, src) #define PSADBW(dst, src) db 0x0f, 0xf6, _k3d_MODRM(dst, src) #define PMOVMSKB(dst, src) db 0x0f, 0xd7, _k3d_MODRM(dst, src) #define PMASKMOVQ(dst, src) db 0x0f, 0xf7, _k3d_MODRM(dst, src) #define PINSRW(dst, src, msk) db 0x0f, 0xc4, _k3d_MODRM(dst, src), msk #define PEXTRW(dst, src, msk) db 0x0f, 0xc5, _k3d_MODRM(dst, src), msk #define PSHUFW(dst, src, msk) db 0x0f, 0x70, _k3d_MODRM(dst, src), msk #define MOVNTQ(dst, src) db 0x0f, 0xe7, _k3d_MODRM(src, dst) #define SFENCE db 0x0f, 0xae, 0xf8 /* Memory/offset versions of the opcodes */ #define PF2IDM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0x1d #define PFACCM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0xae #define PFADDM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0x9e #define PFCMPEQM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0xb0 #define PFCMPGEM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0x90 #define PFCMPGTM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0xa0 #define PFMAXM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0xa4 #define PFMINM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0x94 #define PFMULM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0xb4 #define PFRCPM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0x96 #define PFRCPIT1M(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0xa6 #define PFRCPIT2M(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0xb6 #define PFRSQRTM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0x97 #define PFRSQIT1M(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0xa7 #define PFSUBM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0x9a #define PFSUBRM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0xaa #define PI2FDM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0x0d #define PAVGUSBM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0xbf #define PMULHRWM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0xb7 /* Memory/offset versions of the new, K7 opcodes */ #define PFNACCM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0x8a #define FPPNACCM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0x8e #define PSWAPDM(dst, src, off) db 0x0f, 0x0f, _k3d_MODRM(dst, src) | 0x40, off, 0xbb #define PMINUBM(dst, src, off) db 0x0f, 0xda, _k3d_MODRM(dst, src) | 0x40, off #define PMAXUBM(dst, src, off) db 0x0f, 0xde, _k3d_MODRM(dst, src) | 0x40, off #define PMINSWM(dst, src, off) db 0x0f, 0xea, _k3d_MODRM(dst, src) | 0x40, off #define PMAXSWM(dst, src, off) db 0x0f, 0xee, _k3d_MODRM(dst, src) | 0x40, off #define PMULHUWM(dst, src, off) db 0x0f, 0xe4, _k3d_MODRM(dst, src) | 0x40, off #define PAVGBM(dst, src, off) db 0x0f, 0xe0, _k3d_MODRM(dst, src) | 0x40, off #define PAVGWM(dst, src, off) db 0x0f, 0xe3, _k3d_MODRM(dst, src) | 0x40, off #define PSADBWM(dst, src, off) db 0x0f, 0xf6, _k3d_MODRM(dst, src) | 0x40, off #define PMOVMSKBM(dst, src, off) db 0x0f, 0xd7, _k3d_MODRM(dst, src) | 0x40, off #define PMASKMOVQM(dst, src, off) db 0x0f, 0xf7, _k3d_MODRM(dst, src) | 0x40, off #define MOVNTQM(dst, src, off) db 0x0f, 0xe7, _k3d_MODRM(src, dst) | 0x40, off #define PINSRWM(dst, src, off, msk) db 0x0f, 0xc4, _k3d_MODRM(dst, src) | 0x40, off, msk #define PSHUFWM(dst, src, off, msk) db 0x0f, 0x70, _k3d_MODRM(dst, src) | 0x40, off, msk /* Defines for 3DNow! instructions for use in pragmas */ #define p_pf2id(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0x1d #define p_pfacc(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0xae #define p_pfadd(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0x9e #define p_pfcmpeq(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0xb0 #define p_pfcmpge(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0x90 #define p_pfcmpgt(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0xa0 #define p_pfmax(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0xa4 #define p_pfmin(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0x94 #define p_pfmul(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0xb4 #define p_pfrcp(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0x96 #define p_pfrcpit1(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0xa6 #define p_pfrcpit2(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0xb6 #define p_pfrsqrt(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0x97 #define p_pfrsqit1(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0xa7 #define p_pfsub(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0x9a #define p_pfsubr(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0xaa #define p_pi2fd(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0x0d #define p_femms 0x0f 0x0e #define p_pavgusb(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0xbf #define p_pmulhrw(dst, src) 0x0f 0x0f _k3d_MODRM(dst, src) 0xb7 #define p_prefetch(src) 0x0f 0x0d _k3d_pref_##src #define p_prefetchw(src) 0x0f 0x0d _k3d_prefw_##src #define P_PFNACC(dst, src) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0x8a #define P_FPPNACC(dst, src) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0x8e #define P_PSWAPD(dst, src) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0xbb #define P_PMINUB(dst, src) 0x0f 0xda(_k3d_MODRM(dst, src) | 0x40) off #define P_PMAXUB(dst, src) 0x0f 0xde(_k3d_MODRM(dst, src) | 0x40) off #define P_PMINSW(dst, src) 0x0f 0xea(_k3d_MODRM(dst, src) | 0x40) off #define P_PMAXSW(dst, src) 0x0f 0xee(_k3d_MODRM(dst, src) | 0x40) off #define P_PMULHUW(dst, src) 0x0f 0xe4(_k3d_MODRM(dst, src) | 0x40) off #define P_PAVGB(dst, src) 0x0f 0xe0(_k3d_MODRM(dst, src) | 0x40) off #define P_PAVGW(dst, src) 0x0f 0xe3(_k3d_MODRM(dst, src) | 0x40) off #define P_PSADBW(dst, src) 0x0f 0xf6(_k3d_MODRM(dst, src) | 0x40) off #define P_PMOVMSKB(dst, src) 0x0f 0xd7(_k3d_MODRM(dst, src) | 0x40) off #define P_PMASKMOVQ(dst, src) 0x0f 0xf7(_k3d_MODRM(dst, src) | 0x40) off #define P_PINSRW(dst, src, msk) 0x0f 0xc4(_k3d_MODRM(dst, src) | 0x40) off msk #define P_PEXTRW(dst, src, msk) 0x0f 0xc5(_k3d_MODRM(dst, src) | 0x40) off msk #define P_PSHUFW(dst, src, msk) 0x0f 0x70(_k3d_MODRM(dst, src) | 0x40) off msk #define P_MOVNTQ(dst, src) 0x0f 0xe7(_k3d_MODRM(src, dst) | 0x40) off #define P_PF2IDM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0x1d #define P_PFACCM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0xae #define P_PFADDM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0x9e #define P_PFCMPEQM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0xb0 #define P_PFCMPGEM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0x90 #define P_PFCMPGTM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0xa0 #define P_PFMAXM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0xa4 #define P_PFMINM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0x94 #define P_PFMULM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0xb4 #define P_PFRCPM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0x96 #define P_PFRCPIT1M(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0xa6 #define P_PFRCPIT2M(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0xb6 #define P_PFRSQRTM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0x97 #define P_PFRSQIT1M(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0xa7 #define P_PFSUBM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0x9a #define P_PFSUBRM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0xaa #define P_PI2FDM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0x0d #define P_PAVGUSBM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0xbf #define P_PMULHRWM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0xb7 #define P_PFNACCM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0x8a #define P_FPPNACCM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0x8e #define P_PSWAPDM(dst, src, off) 0x0f 0x0f(_k3d_MODRM(dst, src) | 0x40) off 0xbb #define P_PMINUBM(dst, src, off) 0x0f 0xda(_k3d_MODRM(dst, src) | 0x40) off #define P_PMAXUBM(dst, src, off) 0x0f 0xde(_k3d_MODRM(dst, src) | 0x40) off #define P_PMINSWM(dst, src, off) 0x0f 0xea(_k3d_MODRM(dst, src) | 0x40) off #define P_PMAXSWM(dst, src, off) 0x0f 0xee(_k3d_MODRM(dst, src) | 0x40) off #define P_PMULHUWM(dst, src, off) 0x0f 0xe4(_k3d_MODRM(dst, src) | 0x40) off #define P_PAVGBM(dst, src, off) 0x0f 0xe0(_k3d_MODRM(dst, src) | 0x40) off #define P_PAVGWM(dst, src, off) 0x0f 0xe3(_k3d_MODRM(dst, src) | 0x40) off #define P_PSADBWM(dst, src, off) 0x0f 0xf6(_k3d_MODRM(dst, src) | 0x40) off #define P_PMOVMSKBM(dst, src, off) 0x0f 0xd7(_k3d_MODRM(dst, src) | 0x40) off #define P_MOVNTQM(dst, src, off) 0x0f 0xe7(_k3d_MODRM(src, dst) | 0x40) off #define P_PMASKMOVQM(dst, src, off) 0x0f 0xf7(_k3d_MODRM(dst, src) | 0x40) off #define P_PINSRWM(dst, src, off, msk) 0x0f 0xc4(_k3d_MODRM(dst, src) | 0x40) off msk #define P_PSHUFWM(dst, src, off, msk) 0x0f 0x70(_k3d_MODRM(dst, src) | 0x40) off msk #define P_PF2ID(dst, src) p_pf2id(dst, src) #define P_PFACC(dst, src) p_pfacc(dst, src) #define P_PFADD(dst, src) p_pfadd(dst, src) #define P_PFCMPEQ(dst, src) p_pfcmpeq(dst, src) #define P_PFCMPGE(dst, src) p_pfcmpge(dst, src) #define P_PFCMPGT(dst, src) p_pfcmpgt(dst, src) #define P_PFMAX(dst, src) p_pfmax(dst, src) #define P_PFMIN(dst, src) p_pfmin(dst, src) #define P_PFMUL(dst, src) p_pfmul(dst, src) #define P_PFRCP(dst, src) p_pfrcp(dst, src) #define P_PFRCPIT1(dst, src) p_pfrcpit1(dst, src) #define P_PFRCPIT2(dst, src) p_pfrcpit2(dst, src) #define P_PFRSQRT(dst, src) p_pfrsqrt(dst, src) #define P_PFRSQIT1(dst, src) p_pfrsqit1(dst, src) #define P_PFSUB(dst, src) p_pfsub(dst, src) #define P_PFSUBR(dst, src) p_pfsubr(dst, src) #define P_PI2FD(dst, src) p_pi2fd(dst, src) #define P_FEMMS p_femms #define P_PAVGUSB(dst, src) p_pavgusb(dst, src) #define P_PMULHRW(dst, src) p_pmulhrw(dst, src) #define P_PREFETCH(src) p_prefetch(src) #define P_PREFETCHW(src) p_prefetchw(src) #define p_CPUID 0x0f 0xa2 #define p_pf2idm(dst, src, off) P_PF2IDM(dst, src, off) #define p_pfaccm(dst, src, off) P_PFACCM(dst, src, off) #define p_pfaddm(dst, src, off) P_PFADDM(dst, src, off) #define p_pfcmpeqm(dst, src, off) P_PFCMPEQM(dst, src, off) #define p_pfcmpgem(dst, src, off) P_PFCMPGEM(dst, src, off) #define p_pfcmpgtm(dst, src, off) P_PFCMPGTM(dst, src, off) #define p_pfmaxm(dst, src, off) P_PFMAXM(dst, src, off) #define p_pfminm(dst, src, off) P_PFMINM(dst, src, off) #define p_pfmulm(dst, src, off) P_PFMULM(dst, src, off) #define p_pfrcpm(dst, src, off) P_PFRCPM(dst, src, off) #define p_pfrcpit1m(dst, src, off) P_PFRCPIT1M(dst, src, off) #define p_pfrcpit2m(dst, src, off) P_PFRCPIT2M(dst, src, off) #define p_pfrsqrtm(dst, src, off) P_PFRSQRTM(dst, src, off) #define p_pfrsqit1m(dst, src, off) P_PFRSQIT1M(dst, src, off) #define p_pfsubm(dst, src, off) P_PFSUBM(dst, src, off) #define p_pfsubrm(dst, src, off) P_PFSUBRM(dst, src, off) #define p_pi2fdm(dst, src, off) P_PI2FDM(dst, src, off) #define p_pavgusbm(dst, src, off) P_PAVGUSBM(dst, src, off) #define p_pmulhrwm(dst, src, off) P_PMULHRWM(dst, src, off) #define P_PFNACC(dst, src) p_pfnacc(dst, src) #define P_FPPNACC(dst, src) p_pfpnacc(dst, src) #define P_PSWAPD(dst, src) p_pswapd(dst, src) #define P_PMINUB(dst, src) p_pminub(dst, src) #define P_PMAXUB(dst, src) p_pmaxub(dst, src) #define P_PMINSW(dst, src) p_pminsw(dst, src) #define P_PMAXSW(dst, src) p_pmaxsw(dst, src) #define P_PMULHUW(dst, src) p_pmulhuw(dst, src) #define P_PAVGB(dst, src) p_pavgb(dst, src) #define P_PAVGW(dst, src) p_avgw(dst, src) #define P_PSADBW(dst, src) p_psadbw(dst, src) #define P_PMOVMSKB(dst, src) p_pmovmskb(dst, src) #define P_PMASKMOVQ(dst, src) p_pmaskmovq(dst, src) #define P_PINSRW(dst, src, msk) p_pinsrw(dst, src) #define P_PEXTRW(dst, src, msk) p_pextrw(dst, src) #define P_PSHUFW(dst, src, msk) p_pshufw(dst, src) #define P_MOVNTQ(dst, src) p_movntq(dst, src) #define P_PFNACCM(dst, src, off) p_pfnaccm(dst, src, off) #define P_FPPNACCM(dst, src, off) p_pfpnaccm(dst, src, off) #define P_PSWAPDM(dst, src, off) p_pswapdm(dst, src, off) #define P_PMINUBM(dst, src, off) p_pminubm(dst, src, off) #define P_PMAXUBM(dst, src, off) p_pmaxubm(dst, src, off) #define P_PMINSWM(dst, src, off) p_pminswm(dst, src, off) #define P_PMAXSWM(dst, src, off) p_pmaxswm(dst, src, off) #define P_PMULHUWM(dst, src, off) p_pmulhuwm(dst, src, off) #define P_PAVGBM(dst, src, off) p_pavgbm(dst, src, off) #define P_PAVGWM(dst, src, off) p_avgwm(dst, src, off) #define P_PSADBWM(dst, src, off) p_psadbwm(dst, src, off) #define P_PMOVMSKBM(dst, src, off) p_pmovmskbm(dst, src, off) #define P_PMASKMOVQM(dst, src, off) p_pmaskmovqm(dst, src, off) #define P_PINSRWM(dst, src, off, msk) p_pinsrwm(dst, src, off, msk) #define P_PSHUFWM(dst, src, off, msk) p_pshufwm(dst, src, off, msk) #define P_MOVNTQM(dst, src, off) p_movntqm(dst, src, off) #elif defined(_MSC_VER) && !defined(__MWERKS__) // The Microsoft Visual C++ version of the 3DNow! macros. // Stop the "no EMMS" warning, since it doesn't detect FEMMS properly #pragma warning(disable : 4799) // Defines for operands. #define _K3D_MM0 0xc0 #define _K3D_MM1 0xc1 #define _K3D_MM2 0xc2 #define _K3D_MM3 0xc3 #define _K3D_MM4 0xc4 #define _K3D_MM5 0xc5 #define _K3D_MM6 0xc6 #define _K3D_MM7 0xc7 #define _K3D_mm0 0xc0 #define _K3D_mm1 0xc1 #define _K3D_mm2 0xc2 #define _K3D_mm3 0xc3 #define _K3D_mm4 0xc4 #define _K3D_mm5 0xc5 #define _K3D_mm6 0xc6 #define _K3D_mm7 0xc7 #define _K3D_EAX 0x00 #define _K3D_ECX 0x01 #define _K3D_EDX 0x02 #define _K3D_EBX 0x03 #define _K3D_ESI 0x06 #define _K3D_EDI 0x07 #define _K3D_eax 0x00 #define _K3D_ecx 0x01 #define _K3D_edx 0x02 #define _K3D_ebx 0x03 #define _K3D_esi 0x06 #define _K3D_edi 0x07 // These defines are for compatibility with the previous version of the header file. #define _K3D_M0 0xc0 #define _K3D_M1 0xc1 #define _K3D_M2 0xc2 #define _K3D_M3 0xc3 #define _K3D_M4 0xc4 #define _K3D_M5 0xc5 #define _K3D_M6 0xc6 #define _K3D_M7 0xc7 #define _K3D_m0 0xc0 #define _K3D_m1 0xc1 #define _K3D_m2 0xc2 #define _K3D_m3 0xc3 #define _K3D_m4 0xc4 #define _K3D_m5 0xc5 #define _K3D_m6 0xc6 #define _K3D_m7 0xc7 #define _K3D__EAX 0x00 #define _K3D__ECX 0x01 #define _K3D__EDX 0x02 #define _K3D__EBX 0x03 #define _K3D__ESI 0x06 #define _K3D__EDI 0x07 #define _K3D__eax 0x00 #define _K3D__ecx 0x01 #define _K3D__edx 0x02 #define _K3D__ebx 0x03 #define _K3D__esi 0x06 #define _K3D__edi 0x07 // General 3DNow! instruction format that is supported by // these macros. Note that only the most basic form of memory // operands are supported by these macros. #define InjK3DOps(dst, src, inst) \ { \ _asm _emit 0x0f _asm _emit 0x0f _asm _emit((_K3D_##dst & 0x3f) << 3) | \ _K3D_##src _asm _emit _3DNowOpcode##inst \ } #define InjK3DMOps(dst, src, off, inst) \ { \ _asm _emit 0x0f _asm _emit 0x0f _asm _emit(((_K3D_##dst & 0x3f) << 3) | _K3D_##src | \ 0x40) _asm _emit off _asm _emit _3DNowOpcode##inst \ } #define InjMMXOps(dst, src, inst) \ { \ _asm _emit 0x0f _asm _emit _3DNowOpcode##inst _asm _emit((_K3D_##dst & 0x3f) << 3) | \ _K3D_##src \ } #define InjMMXMOps(dst, src, off, inst) \ { \ _asm _emit 0x0f _asm _emit _3DNowOpcode##inst _asm _emit(((_K3D_##dst & 0x3f) << 3) | \ _K3D_##src | 0x40) _asm _emit off \ } #define _3DNowOpcodePF2ID 0x1d #define _3DNowOpcodePFACC 0xae #define _3DNowOpcodePFADD 0x9e #define _3DNowOpcodePFCMPEQ 0xb0 #define _3DNowOpcodePFCMPGE 0x90 #define _3DNowOpcodePFCMPGT 0xa0 #define _3DNowOpcodePFMAX 0xa4 #define _3DNowOpcodePFMIN 0x94 #define _3DNowOpcodePFMUL 0xb4 #define _3DNowOpcodePFRCP 0x96 #define _3DNowOpcodePFRCPIT1 0xa6 #define _3DNowOpcodePFRCPIT2 0xb6 #define _3DNowOpcodePFRSQRT 0x97 #define _3DNowOpcodePFRSQIT1 0xa7 #define _3DNowOpcodePFSUB 0x9a #define _3DNowOpcodePFSUBR 0xaa #define _3DNowOpcodePI2FD 0x0d #define _3DNowOpcodePAVGUSB 0xbf #define _3DNowOpcodePMULHRW 0xb7 #define _3DNowOpcodePFNACC 0x8a #define _3DNowOpcodeFPPNACC 0x8e #define _3DNowOpcodePSWAPD 0xbb #define _3DNowOpcodePMINUB 0xda #define _3DNowOpcodePMAXUB 0xde #define _3DNowOpcodePMINSW 0xea #define _3DNowOpcodePMAXSW 0xee #define _3DNowOpcodePMULHUW 0xe4 #define _3DNowOpcodePAVGB 0xe0 #define _3DNowOpcodePAVGW 0xe3 #define _3DNowOpcodePSADBW 0xf6 #define _3DNowOpcodePMOVMSKB 0xd7 #define _3DNowOpcodePMASKMOVQ 0xf7 #define _3DNowOpcodePINSRW 0xc4 #define _3DNowOpcodePEXTRW 0xc5 #define _3DNowOpcodePSHUFW 0x70 #define _3DNowOpcodeMOVNTQ 0xe7 #define _3DNowOpcodePREFETCHT 0x18 #define PF2ID(dst, src) InjK3DOps(dst, src, PF2ID) #define PFACC(dst, src) InjK3DOps(dst, src, PFACC) #define PFADD(dst, src) InjK3DOps(dst, src, PFADD) #define PFCMPEQ(dst, src) InjK3DOps(dst, src, PFCMPEQ) #define PFCMPGE(dst, src) InjK3DOps(dst, src, PFCMPGE) #define PFCMPGT(dst, src) InjK3DOps(dst, src, PFCMPGT) #define PFMAX(dst, src) InjK3DOps(dst, src, PFMAX) #define PFMIN(dst, src) InjK3DOps(dst, src, PFMIN) #define PFMUL(dst, src) InjK3DOps(dst, src, PFMUL) #define PFRCP(dst, src) InjK3DOps(dst, src, PFRCP) #define PFRCPIT1(dst, src) InjK3DOps(dst, src, PFRCPIT1) #define PFRCPIT2(dst, src) InjK3DOps(dst, src, PFRCPIT2) #define PFRSQRT(dst, src) InjK3DOps(dst, src, PFRSQRT) #define PFRSQIT1(dst, src) InjK3DOps(dst, src, PFRSQIT1) #define PFSUB(dst, src) InjK3DOps(dst, src, PFSUB) #define PFSUBR(dst, src) InjK3DOps(dst, src, PFSUBR) #define PI2FD(dst, src) InjK3DOps(dst, src, PI2FD) #define PAVGUSB(dst, src) InjK3DOps(dst, src, PAVGUSB) #define PMULHRW(dst, src) InjK3DOps(dst, src, PMULHRW) #define FEMMS \ { _asm _emit 0x0f _asm _emit 0x0e } #define PREFETCH(src) \ { _asm _emit 0x0f _asm _emit 0x0d _asm _emit(_K3D_##src & 0x07) } /* Prefetch with a short offset, < 127 or > -127 Carefull! Doesn't check for your offset being in range. */ #define PREFETCHM(src, off) \ { _asm _emit 0x0f _asm _emit 0x0d _asm _emit(0x40 | (_K3D_##src & 0x07)) _asm _emit off } /* Prefetch with a long offset */ #define PREFETCHMLONG(src, off) \ { \ _asm _emit 0x0f _asm _emit 0x0d _asm _emit(0x80 | (_K3D_##src & 0x07)) _asm _emit( \ off & 0x000000ff) _asm _emit(off & 0x0000ff00) >> \ 8 _asm _emit(off & 0x00ff0000) >> 16 _asm _emit(off & 0xff000000) >> 24 \ } #define PREFETCHW(src) \ { _asm _emit 0x0f _asm _emit 0x0d _asm _emit(0x08 | (_K3D_##src & 0x07)) } #define PREFETCHWM(src, off) \ { _asm _emit 0x0f _asm _emit 0x0d _asm _emit 0x48 | (_K3D_##src & 0x07) _asm _emit off } #define PREFETCHWMLONG(src, off) \ { \ _asm _emit 0x0f _asm _emit 0x0d _asm _emit 0x88 | \ (_K3D_##src & 0x07) _asm _emit(off & 0x000000ff) _asm _emit(off & 0x0000ff00) >> \ 8 _asm _emit(off & 0x00ff0000) >> 16 _asm _emit(off & 0xff000000) >> 24 \ } #define CPUID \ { _asm _emit 0x0f _asm _emit 0xa2 } /* Defines for new, K7 opcodes */ #define SFENCE \ { _asm _emit 0x0f _asm _emit 0xae _asm _emit 0xf8 } #define PFNACC(dst, src) InjK3DOps(dst, src, PFNACC) #define PFPNACC(dst, src) InjK3DOps(dst, src, PFPNACC) #define PSWAPD(dst, src) InjK3DOps(dst, src, PSWAPD) #define PMINUB(dst, src) InjMMXOps(dst, src, PMINUB) #define PMAXUB(dst, src) InjMMXOps(dst, src, PMAXUB) #define PMINSW(dst, src) InjMMXOps(dst, src, PMINSW) #define PMAXSW(dst, src) InjMMXOps(dst, src, PMAXSW) #define PMULHUW(dst, src) InjMMXOps(dst, src, PMULHUW) #define PAVGB(dst, src) InjMMXOps(dst, src, PAVGB) #define PAVGW(dst, src) InjMMXOps(dst, src, PAVGW) #define PSADBW(dst, src) InjMMXOps(dst, src, PSADBW) #define PMOVMSKB(dst, src) InjMMXOps(dst, src, PMOVMSKB) #define PMASKMOVQ(dst, src) InjMMXOps(dst, src, PMASKMOVQ) #define PINSRW(dst, src, msk) InjMMXOps(dst, src, PINSRW) _asm _emit msk #define PEXTRW(dst, src, msk) InjMMXOps(dst, src, PEXTRW) _asm _emit msk #define PSHUFW(dst, src, msk) InjMMXOps(dst, src, PSHUFW) _asm _emit msk #define MOVNTQ(dst, src) InjMMXOps(src, dst, MOVNTQ) #define PREFETCHNTA(mem) InjMMXOps(mm0, mem, PREFETCHT) #define PREFETCHT0(mem) InjMMXOps(mm1, mem, PREFETCHT) #define PREFETCHT1(mem) InjMMXOps(mm2, mem, PREFETCHT) #define PREFETCHT2(mem) InjMMXOps(mm3, mem, PREFETCHT) /* Memory/offset versions of the opcodes */ #define PAVGUSBM(dst, src, off) InjK3DMOps(dst, src, off, PAVGUSB) #define PF2IDM(dst, src, off) InjK3DMOps(dst, src, off, PF2ID) #define PFACCM(dst, src, off) InjK3DMOps(dst, src, off, PFACC) #define PFADDM(dst, src, off) InjK3DMOps(dst, src, off, PFADD) #define PFCMPEQM(dst, src, off) InjK3DMOps(dst, src, off, PFCMPEQ) #define PFCMPGEM(dst, src, off) InjK3DMOps(dst, src, off, PFCMPGE) #define PFCMPGTM(dst, src, off) InjK3DMOps(dst, src, off, PFCMPGT) #define PFMAXM(dst, src, off) InjK3DMOps(dst, src, off, PFMAX) #define PFMINM(dst, src, off) InjK3DMOps(dst, src, off, PFMIN) #define PFMULM(dst, src, off) InjK3DMOps(dst, src, off, PFMUL) #define PFRCPM(dst, src, off) InjK3DMOps(dst, src, off, PFRCP) #define PFRCPIT1M(dst, src, off) InjK3DMOps(dst, src, off, PFRCPIT1) #define PFRCPIT2M(dst, src, off) InjK3DMOps(dst, src, off, PFRCPIT2) #define PFRSQRTM(dst, src, off) InjK3DMOps(dst, src, off, PFRSQRT) #define PFRSQIT1M(dst, src, off) InjK3DMOps(dst, src, off, PFRSQIT1) #define PFSUBM(dst, src, off) InjK3DMOps(dst, src, off, PFSUB) #define PFSUBRM(dst, src, off) InjK3DMOps(dst, src, off, PFSUBR) #define PI2FDM(dst, src, off) InjK3DMOps(dst, src, off, PI2FD) #define PMULHRWM(dst, src, off) InjK3DMOps(dst, src, off, PMULHRW) /* Memory/offset versions of the K7 opcodes */ #define PFNACCM(dst, src, off) InjK3DMOps(dst, src, off, PFNACC) #define PFPNACCM(dst, src, off) InjK3DMOps(dst, src, off, PFPNACC) #define PSWAPDM(dst, src, off) InjK3DMOps(dst, src, off, PSWAPD) #define PMINUBM(dst, src, off) InjMMXMOps(dst, src, off, PMINUB) #define PMAXUBM(dst, src, off) InjMMXMOps(dst, src, off, PMAXUB) #define PMINSWM(dst, src, off) InjMMXMOps(dst, src, off, PMINSW) #define PMAXSWM(dst, src, off) InjMMXMOps(dst, src, off, PMAXSW) #define PMULHUWM(dst, src, off) InjMMXMOps(dst, src, off, PMULHUW) #define PAVGBM(dst, src, off) InjMMXMOps(dst, src, off, PAVGB) #define PAVGWM(dst, src, off) InjMMXMOps(dst, src, off, PAVGW) #define PSADBWM(dst, src, off) InjMMXMOps(dst, src, off, PSADBW) #define PMOVMSKBM(dst, src, off) InjMMXMOps(dst, src, off, PMOVMSKB) #define PMASKMOVQM(dst, src, off) InjMMXMOps(dst, src, off, PMASKMOVQ) #define PINSRWM(dst, src, off, msk) InjMMXMOps(dst, src, off, PINSRW) _asm _emit msk #define PSHUFWM(dst, src, off, msk) InjMMXMOps(dst, src, off, PSHUFW) _asm _emit msk #define MOVNTQM(dst, src, off) InjMMXMOps(src, dst, off, MOVNTQ) #define PREFETCHNTAM(mem, off) InjMMXMOps(mm0, mem, off, PREFETCHT) #define PREFETCHT0M(mem, off) InjMMXMOps(mm1, mem, off, PREFETCHT) #define PREFETCHT1M(mem, off) InjMMXMOps(mm2, mem, off, PREFETCHT) #define PREFETCHT2M(mem, off) InjMMXMOps(mm3, mem, off, PREFETCHT) #else /* Assume built-in support for 3DNow! opcodes, replace macros with opcodes */ #define PAVGUSB(dst, src) pavgusb dst, src #define PF2ID(dst, src) pf2id dst, src #define PFACC(dst, src) pfacc dst, src #define PFADD(dst, src) pfadd dst, src #define PFCMPEQ(dst, src) pfcmpeq dst, src #define PFCMPGE(dst, src) pfcmpge dst, src #define PFCMPGT(dst, src) pfcmpgt dst, src #define PFMAX(dst, src) pfmax dst, src #define PFMIN(dst, src) pfmin dst, src #define PFMUL(dst, src) pfmul dst, src #define PFRCP(dst, src) pfrcp dst, src #define PFRCPIT1(dst, src) pfrcpit1 dst, src #define PFRCPIT2(dst, src) pfrcpit2 dst, src #define PFRSQRT(dst, src) pfrsqrt dst, src #define PFRSQIT1(dst, src) pfrsqit1 dst, src #define PFSUB(dst, src) pfsub dst, src #define PFSUBR(dst, src) pfsubr dst, src #define PI2FD(dst, src) pi2fd dst, src #define PMULHRW(dst, src) pmulhrw dst, src #define PREFETCH(src) prefetch src #define PREFETCHW(src) prefetchw src #define PAVGUSBM(dst, src, off) pavgusb dst, [src + off] #define PF2IDM(dst, src, off) PF2ID dst, [src + off] #define PFACCM(dst, src, off) PFACC dst, [src + off] #define PFADDM(dst, src, off) PFADD dst, [src + off] #define PFCMPEQM(dst, src, off) PFCMPEQ dst, [src + off] #define PFCMPGEM(dst, src, off) PFCMPGE dst, [src + off] #define PFCMPGTM(dst, src, off) PFCMPGT dst, [src + off] #define PFMAXM(dst, src, off) PFMAX dst, [src + off] #define PFMINM(dst, src, off) PFMIN dst, [src + off] #define PFMULM(dst, src, off) PFMUL dst, [src + off] #define PFRCPM(dst, src, off) PFRCP dst, [src + off] #define PFRCPIT1M(dst, src, off) PFRCPIT1 dst, [src + off] #define PFRCPIT2M(dst, src, off) PFRCPIT2 dst, [src + off] #define PFRSQRTM(dst, src, off) PFRSQRT dst, [src + off] #define PFRSQIT1M(dst, src, off) PFRSQIT1 dst, [src + off] #define PFSUBM(dst, src, off) PFSUB dst, [src + off] #define PFSUBRM(dst, src, off) PFSUBR dst, [src + off] #define PI2FDM(dst, src, off) PI2FD dst, [src + off] #define PMULHRWM(dst, src, off) PMULHRW dst, [src + off] #if defined(__MWERKS__) // At the moment, CodeWarrior does not support these opcodes, so hand-assemble them // Defines for operands. #define _K3D_MM0 0xc0 #define _K3D_MM1 0xc1 #define _K3D_MM2 0xc2 #define _K3D_MM3 0xc3 #define _K3D_MM4 0xc4 #define _K3D_MM5 0xc5 #define _K3D_MM6 0xc6 #define _K3D_MM7 0xc7 #define _K3D_mm0 0xc0 #define _K3D_mm1 0xc1 #define _K3D_mm2 0xc2 #define _K3D_mm3 0xc3 #define _K3D_mm4 0xc4 #define _K3D_mm5 0xc5 #define _K3D_mm6 0xc6 #define _K3D_mm7 0xc7 #define _K3D_EAX 0x00 #define _K3D_ECX 0x01 #define _K3D_EDX 0x02 #define _K3D_EBX 0x03 #define _K3D_ESI 0x06 #define _K3D_EDI 0x07 #define _K3D_eax 0x00 #define _K3D_ecx 0x01 #define _K3D_edx 0x02 #define _K3D_ebx 0x03 #define _K3D_esi 0x06 #define _K3D_edi 0x07 #define _K3D_EAX 0x00 #define _K3D_ECX 0x01 #define _K3D_EDX 0x02 #define _K3D_EBX 0x03 #define _K3D_ESI 0x06 #define _K3D_EDI 0x07 #define _K3D_eax 0x00 #define _K3D_ecx 0x01 #define _K3D_edx 0x02 #define _K3D_ebx 0x03 #define _K3D_esi 0x06 #define _K3D_edi 0x07 #define InjK3DOps(dst, src, inst) \ db 0x0f, 0x0f, (((_K3D_##dst & 0x3f) << 3) | _K3D_##src), _3DNowOpcode##inst #define InjK3DMOps(dst, src, off, inst) \ db 0x0f, 0x0f, (((_K3D_##dst & 0x3f) << 3) | _K3D_##src | 0x40), off, _3DNowOpcode##inst #define InjMMXOps(dst, src, inst) \ db 0x0f, _3DNowOpcode##inst, (((_K3D_##dst & 0x3f) << 3) | _K3D_##src) #define InjMMXMOps(dst, src, off, inst) \ db 0x0f, _3DNowOpcode##inst, (((_K3D_##dst & 0x3f) << 3) | _K3D_##src | 0x40), off #define PFNACC(dst, src) InjK3DOps(dst, src, PFNACC) #define PFPNACC(dst, src) InjK3DOps(dst, src, PFPNACC) #define PSWAPD(dst, src) InjK3DOps(dst, src, PSWAPD) #define PMINUB(dst, src) InjMMXOps(dst, src, PMINUB) #define PMAXUB(dst, src) InjMMXOps(dst, src, PMAXUB) #define PMINSW(dst, src) InjMMXOps(dst, src, PMINSW) #define PMAXSW(dst, src) InjMMXOps(dst, src, PMAXSW) #define PMULHUW(dst, src) InjMMXOps(dst, src, PMULHUW) #define PAVGB(dst, src) InjMMXOps(dst, src, PAVGB) #define PAVGW(dst, src) InjMMXOps(dst, src, PAVGW) #define PSADBW(dst, src) InjMMXOps(dst, src, PSADBW) #define PMOVMSKB(dst, src) InjMMXOps(dst, src, PMOVMSKB) #define PMASKMOVQ(dst, src) InjMMXOps(dst, src, PMASKMOVQ) #define PINSRW(dst, src, msk) InjMMXOps(dst, src, PINSRW) db msk #define PEXTRW(dst, src, msk) InjMMXOps(dst, src, PEXTRW) db msk #define PSHUFW(dst, src, msk) InjMMXOps(dst, src, PSHUFW) db msk #define MOVNTQ(dst, src) InjMMXOps(src, dst, MOVNTQ) #define PREFETCHNTA(mem) InjMMXOps(mm0, mem, PREFETCHT) #define PREFETCHT0(mem) InjMMXOps(mm1, mem, PREFETCHT) #define PREFETCHT1(mem) InjMMXOps(mm2, mem, PREFETCHT) #define PREFETCHT2(mem) InjMMXOps(mm3, mem, PREFETCHT) /* Memory/offset versions of the K7 opcodes */ #define PFNACCM(dst, src, off) InjK3DMOps(dst, src, off, PFNACC) #define PFPNACCM(dst, src, off) InjK3DMOps(dst, src, off, PFPNACC) #define PSWAPDM(dst, src, off) InjK3DMOps(dst, src, off, PSWAPD) #define PMINUBM(dst, src, off) InjMMXMOps(dst, src, off, PMINUB) #define PMAXUBM(dst, src, off) InjMMXMOps(dst, src, off, PMAXUB) #define PMINSWM(dst, src, off) InjMMXMOps(dst, src, off, PMINSW) #define PMAXSWM(dst, src, off) InjMMXMOps(dst, src, off, PMAXSW) #define PMULHUWM(dst, src, off) InjMMXMOps(dst, src, off, PMULHUW) #define PAVGBM(dst, src, off) InjMMXMOps(dst, src, off, PAVGB) #define PAVGWM(dst, src, off) InjMMXMOps(dst, src, off, PAVGW) #define PSADBWM(dst, src, off) InjMMXMOps(dst, src, off, PSADBW) #define PMOVMSKBM(dst, src, off) InjMMXMOps(dst, src, off, PMOVMSKB) #define PMASKMOVQM(dst, src, off) InjMMXMOps(dst, src, off, PMASKMOVQ) #define PINSRWM(dst, src, off, msk) InjMMXMOps(dst, src, off, PINSRW), msk #define PEXTRWM(dst, src, off, msk) InjMMXMOps(dst, src, off, PEXTRW), msk #define PSHUFWM(dst, src, off, msk) InjMMXMOps(dst, src, off, PSHUFW), msk #define MOVNTQM(dst, src, off) InjMMXMOps(src, dst, off, MOVNTQ) #define PREFETCHNTAM(mem, off) InjMMXMOps(mm0, mem, off, PREFETCHT) #define PREFETCHT0M(mem, off) InjMMXMOps(mm1, mem, off, PREFETCHT) #define PREFETCHT1M(mem, off) InjMMXMOps(mm2, mem, off, PREFETCHT) #define PREFETCHT2M(mem, off) InjMMXMOps(mm3, mem, off, PREFETCHT) #else #define PFNACC(dst, src) PFNACC dst, src #define PFPNACC(dst, src) PFPNACC dst, src #define PSWAPD(dst, src) PSWAPD dst, src #define PMINUB(dst, src) PMINUB dst, src #define PMAXUB(dst, src) PMAXUB dst, src #define PMINSW(dst, src) PMINSW dst, src #define PMAXSW(dst, src) PMAXSW dst, src #define PMULHUW(dst, src) PMULHUW dst, src #define PAVGB(dst, src) PAVGB dst, src #define PAVGW(dst, src) PAVGW dst, src #define PSADBW(dst, src) PSADBW dst, src #define PMOVMSKB(dst, src) PMOVMSKB dst, src #define PMASKMOVQ(dst, src) PMASKMOVQ dst, src #define PINSRW(dst, src, msk) PINSRW dst, src, msk #define PEXTRW(dst, src, msk) PEXTRW dst, src, msk #define PSHUFW(dst, src, msk) PSHUFW dst, src, msk #define MOVNTQ(dst, src) MOVNTQ dst, src #define PFNACCM(dst, src, off) PFNACC dst, [src + off] #define PFPNACCM(dst, src, off) PFPNACC dst, [src + off] #define PSWAPDM(dst, src, off) PSWAPD dst, [src + off] #define PMINUBM(dst, src, off) PMINUB dst, [src + off] #define PMAXUBM(dst, src, off) PMAXUB dst, [src + off] #define PMINSWM(dst, src, off) PMINSW dst, [src + off] #define PMAXSWM(dst, src, off) PMAXSW dst, [src + off] #define PMULHUWM(dst, src, off) PMULHUW dst, [src + off] #define PAVGBM(dst, src, off) PAVGB dst, [src + off] #define PAVGWM(dst, src, off) PAVGW dst, [src + off] #define PSADBWM(dst, src, off) PSADBW dst, [src + off] #define PMOVMSKBM(dst, src, off) PMOVMSKB dst, [src + off] #define PMASKMOVQM(dst, src, off) PMASKMOVQ dst, [src + off] #define PINSRWM(dst, src, off, msk) PINSRW dst, [src + off], msk #define PEXTRWM(dst, src, off, msk) PEXTRW dst, [src + off], msk #define PSHUFWM(dst, src, off, msk) PSHUFW dst, [src + off], msk #define MOVNTQM(dst, src, off) MOVNTQ dst, [src + off] #endif #endif /* Just to deal with lower case. */ #define pf2id(dst, src) PF2ID(dst, src) #define pfacc(dst, src) PFACC(dst, src) #define pfadd(dst, src) PFADD(dst, src) #define pfcmpeq(dst, src) PFCMPEQ(dst, src) #define pfcmpge(dst, src) PFCMPGE(dst, src) #define pfcmpgt(dst, src) PFCMPGT(dst, src) #define pfmax(dst, src) PFMAX(dst, src) #define pfmin(dst, src) PFMIN(dst, src) #define pfmul(dst, src) PFMUL(dst, src) #define pfrcp(dst, src) PFRCP(dst, src) #define pfrcpit1(dst, src) PFRCPIT1(dst, src) #define pfrcpit2(dst, src) PFRCPIT2(dst, src) #define pfrsqrt(dst, src) PFRSQRT(dst, src) #define pfrsqit1(dst, src) PFRSQIT1(dst, src) #define pfsub(dst, src) PFSUB(dst, src) #define pfsubr(dst, src) PFSUBR(dst, src) #define pi2fd(dst, src) PI2FD(dst, src) #define femms FEMMS #define pavgusb(dst, src) PAVGUSB(dst, src) #define pmulhrw(dst, src) PMULHRW(dst, src) #define prefetch(src) PREFETCH(src) #define prefetchw(src) PREFETCHW(src) #define prefetchm(src, off) PREFETCHM(src, off) #define prefetchmlong(src, off) PREFETCHMLONG(src, off) #define prefetchwm(src, off) PREFETCHWM(src, off) #define prefetchwmlong(src, off) PREFETCHWMLONG(src, off) #define pfnacc(dst, src) PFNACC(dst, src) #define pfpnacc(dst, src) PFPNACC(dst, src) #define pswapd(dst, src) PSWAPD(dst, src) #define pminub(dst, src) PMINUB(dst, src) #define pmaxub(dst, src) PMAXUB(dst, src) #define pminsw(dst, src) PMINSW(dst, src) #define pmaxsw(dst, src) PMAXSW(dst, src) #define pmulhuw(dst, src) PMULHUW(dst, src) #define pavgb(dst, src) PAVGB(dst, src) #define pavgw(dst, src) PAVGW(dst, src) #define psadbw(dst, src) PSADBW(dst, src) #define pmovmskb(dst, src) PMOVMSKB(dst, src) #define pmaskmovq(dst, src) PMASKMOVQ(dst, src) #define pinsrw(dst, src, msk) PINSRW(dst, src, msk) #define pextrw(dst, src, msk) PEXTRW(dst, src, msk) #define pshufw(dst, src, msk) PSHUFW(dst, src, msk) #define movntq(dst, src) MOVNTQ(dst, src) #define prefetchnta(mem) PREFETCHNTA(mem) #define prefetcht0(mem) PREFETCHT0(mem) #define prefetcht1(mem) PREFETCHT1(mem) #define prefetcht2(mem) PREFETCHT2(mem) #define pavgusbm(dst, src, off) PAVGUSBM(dst, src, off) #define pf2idm(dst, src, off) PF2IDM(dst, src, off) #define pfaccm(dst, src, off) PFACCM(dst, src, off) #define pfaddm(dst, src, off) PFADDM(dst, src, off) #define pfcmpeqm(dst, src, off) PFCMPEQM(dst, src, off) #define pfcmpgem(dst, src, off) PFCMPGEM(dst, src, off) #define pfcmpgtm(dst, src, off) PFCMPGTM(dst, src, off) #define pfmaxm(dst, src, off) PFMAXM(dst, src, off) #define pfminm(dst, src, off) PFMINM(dst, src, off) #define pfmulm(dst, src, off) PFMULM(dst, src, off) #define pfrcpm(dst, src, off) PFRCPM(dst, src, off) #define pfrcpit1m(dst, src, off) PFRCPIT1M(dst, src, off) #define pfrcpit2m(dst, src, off) PFRCPIT2M(dst, src, off) #define pfrsqrtm(dst, src, off) PFRSQRTM(dst, src, off) #define pfrsqit1m(dst, src, off) PFRSQIT1M(dst, src, off) #define pfsubm(dst, src, off) PFSUBM(dst, src, off) #define pfsubrm(dst, src, off) PFSUBRM(dst, src, off) #define pi2fdm(dst, src, off) PI2FDM(dst, src, off) #define pmulhrwm(dst, src, off) PMULHRWM(dst, src, off) #define cpuid CPUID #define sfence SFENCE #define pfnaccm(dst, src, off) PFNACCM(dst, src, off) #define pfpnaccm(dst, src, off) PFPNACCM(dst, src, off) #define pswapdm(dst, src, off) PSWAPDM(dst, src, off) #define pminubm(dst, src, off) PMINUBM(dst, src, off) #define pmaxubm(dst, src, off) PMAXUBM(dst, src, off) #define pminswm(dst, src, off) PMINSWM(dst, src, off) #define pmaxswm(dst, src, off) PMAXSWM(dst, src, off) #define pmulhuwm(dst, src, off) PMULHUWM(dst, src, off) #define pavgbm(dst, src, off) PAVGBM(dst, src, off) #define pavgwm(dst, src, off) PAVGWM(dst, src, off) #define psadbwm(dst, src, off) PSADBWM(dst, src, off) #define pmovmskbm(dst, src, off) PMOVMSKBM(dst, src, off) #define pmaskmovqm(dst, src, off) PMASKMOVQM(dst, src, off) #define pinsrwm(dst, src, off, msk) PINSRWM(dst, src, off, msk) #define pextrwm(dst, src, off, msk) PEXTRWM(dst, src, off, msk) #define pshufwm(dst, src, off, msk) PSHUFWM(dst, src, off, msk) #define movntqm(dst, src, off) MOVNTQM(dst, src, off) #define prefetchntam(mem, off) PREFETCHNTA(mem, off) #define prefetcht0m(mem, off) PREFETCHT0(mem, off) #define prefetcht1m(mem, off) PREFETCHT1(mem, off) #define prefetcht2m(mem, off) PREFETCHT2(mem, off) #endif
42.466431
99
0.722604
[ "model", "3d" ]
39c0851713cb79a47288b910226a3934dc8b53cf
1,151
h
C
klic-3.01/include/klic/g_vector.h
GunterMueller/KLIC
75e541269b4ad0bb6e23b73e7310f626b59830d2
[ "Xnet", "X11" ]
5
2020-02-02T04:51:16.000Z
2022-01-16T01:32:13.000Z
klic-3.01/include/OME/local/roquefort/include/klic/g_vector.h
GunterMueller/KLIC
75e541269b4ad0bb6e23b73e7310f626b59830d2
[ "Xnet", "X11" ]
1
2021-08-04T13:33:53.000Z
2021-08-04T13:33:53.000Z
klic-3.011/include/OME/local/roquefort/include/klic/g_vector.h
GunterMueller/KLIC
75e541269b4ad0bb6e23b73e7310f626b59830d2
[ "Xnet", "X11" ]
3
2020-10-18T23:08:38.000Z
2021-02-21T05:13:33.000Z
/* ---------------------------------------------------------- % (C)1994,1995 Institute for New Generation Computer Technology % (Read COPYRIGHT for detailed information.) % (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center % (Read COPYRIGHT-JIPDEC for detailed information.) ----------------------------------------------------------- */ struct vector_object { struct data_object_method_table *method_table; q next; int index:(8*sizeof(int)-1); /* size or index */ int iscnst:1; /* The following field "body" is actually used as a union: when shallowed, as actually the body of the vector; when deep, i.e., for difference records, the element that differs. */ q *body; }; #define VECTOR_SHALLOW_MARK (makeint(0)) #define IS_SHALLOW_VECTOR(v) ((v)->next == VECTOR_SHALLOW_MARK) #define vector_structure_type struct vector_object #define declare_vector_constant(body, length) \ { \ &vector_g_data_method_table, \ VECTOR_SHALLOW_MARK, /* next */ \ length, /* index */ \ 1, /* iscnst */ \ (q *) body /* body */ \ } extern q create_vector();
31.972222
77
0.604692
[ "vector" ]
39c18f71afc142070c15db86210fb838aa7b5ec7
4,269
h
C
neon/Helium/HeliumForWindows/Implementation/Plugins/PB_DeviceApplication_PLG/HourglassModule.h
mensfeld/rhodes
2962610a314ed563a0b7c83fcae6136913a1b033
[ "MIT" ]
173
2015-01-02T11:14:08.000Z
2022-03-05T09:54:54.000Z
neon/Helium/HeliumForWindows/Implementation/Plugins/PB_DeviceApplication_PLG/HourglassModule.h
mensfeld/rhodes
2962610a314ed563a0b7c83fcae6136913a1b033
[ "MIT" ]
263
2015-01-05T04:35:22.000Z
2021-09-07T06:00:02.000Z
neon/Helium/HeliumForWindows/Implementation/Plugins/PB_DeviceApplication_PLG/HourglassModule.h
watusi/rhodes
07161cca58ff6a960bbd1b79b36447b819bfa0eb
[ "MIT" ]
77
2015-01-12T20:57:18.000Z
2022-02-17T15:15:14.000Z
/** * \file HourglassModule.h * \brief Hourglass Plug-in module interface. * File to house the CHourglassModule class and all related includes / defines * to interface between Browser core and the Hourglass functionality. * The Hourglass will be shown automatically during page navigates and also * when told to. The Hourglass will not be shown if the request originates from * a module which does not have focus. */ #pragma once #include "../../common/Public/PBPlugin.h" #include "HourglassAnimation.h" /** * Class to define the interface between the core and the CHourglassAnimation * functionality. * Inherits from PBModule to align with the Plug-in design. Actions meta tags * to perform the appropriate Hourglass behaviour. */ class CHourglassModule: public PBModule { public: /** * This Function is inherited from PBModule::onInit. * Please see that function for further definition. * Copies the Module name into the Module and registers for OnAppFocus * events. */ BOOL onInit(PPBSTRUCT pPBStructure); /** * This Function is inherited from PBModule::onDeInit. * Please see that function for further definition. * Deregisters for OnAppFocus events. */ void onDeInit(PPBSTRUCT pPBStructure); /** * This Function is inherited from PBModule::onAttachInstance. * Please see that function for further definition. * Creates instance data for the new Object. Stores a reference to * the instance data in the pInstStruct, associating it with the newly * created instance. */ BOOL onAttachInstance(PPBSTRUCT pPBStructure, PPBINSTSTRUCT pInstStruct); /** * This Function is inherited from PBModule::onReleaseInstance. * Please see that function for further definition. * Deletes the instance data associated with the instance being * released. */ BOOL onReleaseInstance(PPBSTRUCT pPBStructure, PPBINSTSTRUCT pInstStruct); /** * This Function is inherited from PBModule::onAppFocus. * Please see that function for further definition. * Receive change of application focus notifications, inform the old and * new IDs whether they have lost / gained focus */ BOOL onAppFocus(int iOldID, int iNewID); /** * This Function is inherited from PBModule::onBeforeNavigate. * Please see that function for further definition. * Displays the Hourglass if this application is in the foreground. */ BOOL onBeforeNavigate (int iInstID); /** * This Function is inherited from PBModule::onDocumentComplete. * Please see that function for further definition. * Hides the Hourglass once navigation has completed. */ BOOL onDocumentComplete (int iInstID); /** * This Function is inherited from PBModule::MetaProc. * Please see that function for further definition. * Accepts 'Meta tags' associated with the Hourglass module and actions * them appropriately. */ BOOL MetaProc(PBMetaStruct *pbMetaStructure, PPBSTRUCT pPBStructure, void *pParam); /** * Function to retrieve the 'WaitCursorEnabled' configuration setting. * \param iInstance Application instance to retrieve the setting for * \param value [out] Value of the configuration setting * \return Whether or not the value was successfully read from the * configuration. */ bool RetrieveNoWaitConfigValue(int iInstance, BOOL* input); /** * Function to retrieve the 'WaitCursorLeft' configuration setting. * \param iInstance Application instance to retrieve the setting for * \param value [out] Value of the configuration setting * \return Whether or not the value was successfully read from the * configuration. */ bool RetrieveHourglassDefaultLeft(int iInstance, DWORD* value); /** * Function to retrieve the 'WaitCursorTop' configuration setting. * \param iInstance Application instance to retrieve the setting for * \param value [out] Value of the configuration setting * \return Whether or not the value was successfully read from the * configuration. */ bool RetrieveHourglassDefaultTop(int iInstance, DWORD* value); /** * This function is inherited from PBModule::onRhoAppFocus. * Please see that function for further definition. */ BOOL onRhoAppFocus(bool bActivate, int iInstID); private: HANDLE m_hWindowInitialisedEvent; };
34.991803
84
0.750059
[ "object" ]
39c4a8dcff6c6d8d52704493fa80bbab663d7998
1,332
h
C
core-src/WholeMove.h
Quuxplusone/Homeworlds
8e193a60a0cc59901df1980f3866731d5c1ee15a
[ "BSD-2-Clause" ]
11
2016-07-01T10:51:58.000Z
2021-03-18T07:59:32.000Z
core-src/WholeMove.h
Quuxplusone/Homeworlds
8e193a60a0cc59901df1980f3866731d5c1ee15a
[ "BSD-2-Clause" ]
1
2017-06-11T04:30:09.000Z
2017-06-11T04:30:09.000Z
core-src/WholeMove.h
Quuxplusone/Homeworlds
8e193a60a0cc59901df1980f3866731d5c1ee15a
[ "BSD-2-Clause" ]
3
2016-02-27T16:53:28.000Z
2017-06-10T19:21:24.000Z
#pragma once #include "global.h" #include <assert.h> #include <stdio.h> #include <string> #include <vector> #include "SingleAction.h" class WholeMove { public: bool isPass() const { return actions.empty(); } /* We use this operation to build up whole moves piece by piece. * Note that any prefix of a legal move is itself a legal move, * so it's safe to sanity-check both the input and the output of * this operation. */ WholeMove &operator += (SingleAction a) { assert(this->sanitycheck()); assert(a.sanitycheck()); actions.push_back(std::move(a)); assert(this->sanitycheck()); return *this; } bool isMissingPieces() const; int unusedSacrificeActions() const; std::string toString() const; std::string toSDGString() const; bool scan(const char *text); explicit WholeMove() { assert(this->isPass()); } explicit WholeMove(const char *text) { const bool UNUSED(rc) = scan(text); assert(rc); } explicit WholeMove(const std::string &text) : WholeMove(text.c_str()) {} explicit WholeMove(const WholeMove &m, const SingleAction &a): actions(m.actions) { *this += a; } bool sanitycheck() const; public: /* These fields should be treated as read-only. */ std::vector<SingleAction> actions; };
28.340426
92
0.647147
[ "vector" ]
39c65fae491c2bcf50d1b9a985c8ca43cf9cd466
309
h
C
habitus/crystal.h
olegabr/tomo3d
36ffca69aba8556170ec7330271eb58ebaf7459b
[ "MIT" ]
5
2016-01-07T12:27:58.000Z
2021-11-03T06:58:42.000Z
habitus/crystal.h
olegabr/tomo3d
36ffca69aba8556170ec7330271eb58ebaf7459b
[ "MIT" ]
null
null
null
habitus/crystal.h
olegabr/tomo3d
36ffca69aba8556170ec7330271eb58ebaf7459b
[ "MIT" ]
1
2020-12-10T10:22:13.000Z
2020-12-10T10:22:13.000Z
//crystal.h /* * the crystal abstraction * it is simulated by a collection of faces * (C) 2005 olegabr. All rights reserved. */ #ifndef TOMO3D_CRYSTAL_H #define TOMO3D_CRYSTAL_H #include <vector> class crystal { public : crystal() {} private : std::vector<face> m_vecFaces; }; #endif //TOMO3D_CRYSTAL_H
14.045455
42
0.724919
[ "vector" ]
39cf5ef9fd24bbf91d84cf9889248b6f42d9694f
15,806
c
C
Cuda/Source/Libs/CuDnnMemory.c
EmilPi/PuzzleLib
31aa0fab3b5e9472b9b9871ca52e4d94ea683fa9
[ "Apache-2.0" ]
52
2020-02-28T20:40:15.000Z
2021-08-25T05:35:17.000Z
Cuda/Source/Libs/CuDnnMemory.c
EmilPi/PuzzleLib
31aa0fab3b5e9472b9b9871ca52e4d94ea683fa9
[ "Apache-2.0" ]
2
2021-02-14T15:57:03.000Z
2021-10-05T12:21:34.000Z
Cuda/Source/Libs/CuDnnMemory.c
EmilPi/PuzzleLib
31aa0fab3b5e9472b9b9871ca52e4d94ea683fa9
[ "Apache-2.0" ]
8
2020-02-28T20:40:11.000Z
2020-07-09T13:27:23.000Z
#include "Libs.h" typedef struct CuDnn_TransformParams { size_t shape[GPUTENSOR_DIM_MAX], instrides[GPUTENSOR_DIM_MAX], outstrides[GPUTENSOR_DIM_MAX]; size_t ndim; } CuDnn_TransformParams; static bool CuDnn_Context_transform(CuDnn_Context *self, const void *dataPtr, void *outPtr, CuDnn_TransformParams params, size_t ndim, Cuda_DataType dtype) { if (ndim < 3) { if (ndim == 2) { params.shape[2] = params.shape[1], params.shape[1] = params.shape[0], params.shape[0] = 1; params.instrides[2] = params.instrides[1], params.instrides[1] = params.instrides[0]; params.outstrides[2] = params.outstrides[1], params.outstrides[1] = params.outstrides[0]; } else { params.shape[2] = params.shape[0], params.shape[0] = 1, params.shape[1] = 1; params.instrides[2] = params.instrides[0], params.instrides[1] = params.instrides[0]; params.outstrides[2] = params.outstrides[0], params.outstrides[1] = params.outstrides[0]; } params.ndim = 3; } bool status = false; float alpha = 1.0f, beta = 0.0f; cudnnTensorDescriptor_t dataDesc, outDesc; if (!CuDnn_describeTensorFromShape(&dataDesc, params.shape, params.instrides, params.ndim, dtype)) goto error_1; if (!CuDnn_describeTensorFromShape(&outDesc, params.shape, params.outstrides, params.ndim, dtype)) goto error_2; CUDNN_CHECK(cudnnTransformTensor(self->handle, &alpha, dataDesc, dataPtr, &beta, outDesc, outPtr), goto error_3); status = true; error_3: CUDNN_ASSERT(cudnnDestroyTensorDescriptor(outDesc)); error_2: CUDNN_ASSERT(cudnnDestroyTensorDescriptor(dataDesc)); error_1: return status; } inline static Cuda_GPUArray *CuDnn_Context_transpose(CuDnn_Context *self, const size_t *axes, const Cuda_GPUArray *data, Cuda_GPUArray *out, Cuda_MemoryPool *allocator) { CuDnn_TransformParams params; params.ndim = data->ndim; const size_t *shape = CUDA_GPUARRAY_SHAPE(data); size_t outshape[GPUTENSOR_DIM_MAX]; for (size_t i = 0; i < data->ndim; i += 1) { params.instrides[i] = CUDA_GPUARRAY_STRIDES(data)[i]; params.shape[i] = shape[i], outshape[i] = shape[axes[i]]; } out = CuDnn_enforceAllocated(out, allocator, outshape, params.ndim, data->dtype, false); if (out == NULL) return NULL; for (size_t i = 0; i < data->ndim; i += 1) params.outstrides[axes[i]] = CUDA_GPUARRAY_STRIDES(out)[i]; if (!CuDnn_Context_transform(self, data->gpudata->ptr, out->gpudata->ptr, params, data->ndim, data->dtype)) { Py_DECREF(out); out = NULL; } return out; } const char CuDnn_Context_pyTranspose_doc[] = PyDoc_STR( "transpose(self, data, axes=None, out=None, allocator=None) -> " CUDA_GPUARRAY_FULLNAME ); PyObject *CuDnn_Context_pyTranspose(PyObject *self, PyObject *args, PyObject *kwds) { const char *kwlist[] = {"data", "axes", "out", "allocator", NULL}; Cuda_GPUArray *data; PyObject *pyaxes = NULL, *pyout = NULL, *pyalloc = NULL; if (!PyArg_ParseTupleAndKeywords( args, kwds, "O!|OOO", (char **)kwlist, Cuda_GPUArray_Type, &data, &pyaxes, &pyout, &pyalloc )) return NULL; if (!unpackPyOptional(&pyaxes, &PyTuple_Type, "axes")) return NULL; if (!unpackPyOptional(&pyout, Cuda_GPUArray_Type, "out")) return NULL; if (!unpackPyOptional(&pyalloc, Cuda_MemoryPool_Type, "allocator")) return NULL; Cuda_GPUArray *out = (Cuda_GPUArray *)pyout; Cuda_MemoryPool *allocator = (Cuda_MemoryPool *)pyalloc; if (!CuDnn_isValidExtDim(data->ndim)) { PyErr_SetString(PyExc_ValueError, "invalid input gpuarray dims"); return NULL; } if (!CuDnn_isValidDtype(data->dtype)) { PyErr_SetString(PyExc_ValueError, "invalid input gpuarray data layout"); return NULL; } size_t axes[GPUTENSOR_DIM_MAX]; if (pyaxes == NULL) { for (size_t i = 0; i < data->ndim; i += 1) axes[i] = data->ndim - 1 - i; } else { if (!PyTuple_CheckExact(pyaxes)) { PyErr_Format(PyExc_TypeError, "axes must be %s, not %s", PyTuple_Type.tp_name, Py_TYPE(pyaxes)->tp_name); return NULL; } size_t pylength = PyTuple_GET_SIZE(pyaxes); if (data->ndim != pylength) { PyErr_Format(PyExc_ValueError, "axes must be %d-tuple, not %d", (int)data->ndim, (int)pylength); return NULL; } bool axisSet[GPUTENSOR_DIM_MAX]; for (size_t i = 0; i < data->ndim; i += 1) axisSet[i] = false; for (size_t i = 0; i < data->ndim; i += 1) { PyObject *pyaxis = PyTuple_GET_ITEM(pyaxes, i); size_t axis = PyLong_AsSize_t(pyaxis); if (axis == (size_t)-1 && PyErr_Occurred()) return NULL; if (axisSet[axis] || axis >= data->ndim) { PyErr_SetString(PyExc_ValueError, "invalid axis in transpose"); return NULL; } axes[i] = axis, axisSet[axis] = true; } } return (PyObject *)CuDnn_Context_transpose((CuDnn_Context *)self, axes, data, out, allocator); } const char CuDnn_Context_moveaxis_doc[] = PyDoc_STR( "moveaxis(self, data, src, dst, out=None, allocator=None) -> " CUDA_GPUARRAY_FULLNAME ); PyObject *CuDnn_Context_moveaxis(PyObject *self, PyObject *args, PyObject *kwds) { const char *kwlist[] = {"data", "src", "dst", "out", "allocator", NULL}; Cuda_GPUArray *data; Py_ssize_t pysrc, pydst; PyObject *pyout = NULL, *pyalloc = NULL; if (!PyArg_ParseTupleAndKeywords( args, kwds, "O!nn|OO", (char **)kwlist, Cuda_GPUArray_Type, &data, &pysrc, &pydst, &pyout, &pyalloc )) return NULL; if (!unpackPyOptional(&pyout, Cuda_GPUArray_Type, "out")) return NULL; if (!unpackPyOptional(&pyalloc, Cuda_MemoryPool_Type, "allocator")) return NULL; Cuda_GPUArray *out = (Cuda_GPUArray *)pyout; Cuda_MemoryPool *allocator = (Cuda_MemoryPool *)pyalloc; if (!CuDnn_isValidExtDim(data->ndim)) { PyErr_SetString(PyExc_ValueError, "invalid input gpuarray dims"); return NULL; } if (!CuDnn_isValidDtype(data->dtype)) { PyErr_SetString(PyExc_ValueError, "invalid input gpuarray data layout"); return NULL; } size_t src = pysrc, dst = pydst; if (src >= data->ndim || dst >= data->ndim) { PyErr_SetString(PyExc_ValueError, "invalid moving axis"); return NULL; } size_t axes[GPUTENSOR_DIM_MAX], offset = 0; if (src < dst) { for (size_t i = 0; i < src; i += 1) axes[offset++] = i; for (size_t i = src + 1; i < dst + 1; i += 1) axes[offset++] = i; axes[offset++] = src; for (size_t i = dst + 1; i < data->ndim; i += 1) axes[offset++] = i; } else { for (size_t i = 0; i < dst; i += 1) axes[offset++] = i; axes[offset++] = src; for (size_t i = dst; i < src; i += 1) axes[offset++] = i; for (size_t i = src + 1; i < data->ndim; i += 1) axes[offset++] = i; } return (PyObject *)CuDnn_Context_transpose((CuDnn_Context *)self, axes, data, out, allocator); } const char CuDnn_Context_swapaxes_doc[] = PyDoc_STR( "swapaxes(self, data, axis1, axis2, out=None, allocator=None) -> " CUDA_GPUARRAY_FULLNAME ); PyObject *CuDnn_Context_swapaxes(PyObject *self, PyObject *args, PyObject *kwds) { const char *kwlist[] = {"data", "axis1", "axis2", "out", "allocator", NULL}; Cuda_GPUArray *data; Py_ssize_t pyaxis1, pyaxis2; PyObject *pyout = NULL, *pyalloc = NULL; if (!PyArg_ParseTupleAndKeywords( args, kwds, "O!nn|OO", (char **)kwlist, Cuda_GPUArray_Type, &data, &pyaxis1, &pyaxis2, &pyout, &pyalloc )) return NULL; if (!unpackPyOptional(&pyout, Cuda_GPUArray_Type, "out")) return NULL; if (!unpackPyOptional(&pyalloc, Cuda_MemoryPool_Type, "allocator")) return NULL; Cuda_GPUArray *out = (Cuda_GPUArray *)pyout; Cuda_MemoryPool *allocator = (Cuda_MemoryPool *)pyalloc; if (!CuDnn_isValidExtDim(data->ndim)) { PyErr_SetString(PyExc_ValueError, "invalid input gpuarray dims"); return NULL; } if (!CuDnn_isValidDtype(data->dtype)) { PyErr_SetString(PyExc_ValueError, "invalid input gpuarray data layout"); return NULL; } size_t axis1 = pyaxis1, axis2 = pyaxis2; if (axis1 >= data->ndim || axis2 >= data->ndim) { PyErr_SetString(PyExc_ValueError, "invalid moving axis"); return NULL; } if (axis1 > axis2) { size_t temp = axis1; axis1 = axis2; axis2 = temp; } size_t axes[GPUTENSOR_DIM_MAX]; for (size_t i = 0; i < data->ndim; i += 1) axes[i] = (i == axis1) ? axis2 : ((i == axis2) ? axis1 : i); return (PyObject *)CuDnn_Context_transpose((CuDnn_Context *)self, axes, data, out, allocator); } static bool CuDnn_depthConcat_outshape(PyListObject *tensors, size_t *outshape, size_t *outdim, Cuda_DataType *outtype) { size_t ndim = 0, length = PyList_GET_SIZE(tensors); Cuda_DataType dtype = DTYPE_FLOAT32; if (length == 0) { PyErr_SetString(PyExc_ValueError, "tensor list is empty"); return false; } for (size_t i = 0; i < length; i += 1) { PyObject *item = PyList_GET_ITEM(tensors, i); if (Py_TYPE(item) != Cuda_GPUArray_Type) { PyErr_SetString(PyExc_TypeError, "invalid tensor object in list"); return false; } Cuda_GPUArray *tensor = (Cuda_GPUArray *)item; if (!CuDnn_isValidDim(tensor->ndim)) { PyErr_SetString(PyExc_ValueError, "invalid input gpuarray dims"); return false; } if (!CuDnn_isValidDtype(tensor->dtype)) { PyErr_SetString(PyExc_ValueError, "invalid input gpuarray data layout"); return false; } const size_t *shape = CUDA_GPUARRAY_SHAPE(tensor); if (i == 0) { ndim = tensor->ndim, dtype = tensor->dtype; for (size_t j = 0; j < ndim; j += 1) outshape[j] = shape[j]; } else { if (tensor->ndim != ndim || shape[0] != outshape[0]) { PyErr_SetString(PyExc_ValueError, "invalid input gpuarray dims"); return false; } if (tensor->dtype != dtype) { PyErr_SetString(PyExc_ValueError, "invalid input gpuarray data layout"); return false; } outshape[1] += shape[1]; for (size_t j = 2; j < ndim; j += 1) outshape[j] = (outshape[j] > shape[j]) ? outshape[j] : shape[j]; } } *outdim = ndim, *outtype = dtype; return true; } const char CuDnn_Context_depthConcat_doc[] = PyDoc_STR( "depthConcat(self, tensors, out=None, allocator=None) -> " CUDA_GPUARRAY_FULLNAME ); PyObject *CuDnn_Context_depthConcat(PyObject *self, PyObject *args, PyObject *kwds) { const char *kwlist[] = {"tensors", "out", "allocator", NULL}; PyListObject *tensors; PyObject *pyout = NULL, *pyalloc = NULL; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|OO", (char **)kwlist, &PyList_Type, &tensors, &pyout, &pyalloc)) return NULL; if (!unpackPyOptional(&pyout, Cuda_GPUArray_Type, "out")) return NULL; if (!unpackPyOptional(&pyalloc, Cuda_MemoryPool_Type, "allocator")) return NULL; Cuda_GPUArray *out = (Cuda_GPUArray *)pyout; Cuda_MemoryPool *allocator = (Cuda_MemoryPool *)pyalloc; size_t ndim, outshape[GPUTENSOR_DIM_MAX]; Cuda_DataType dtype; if (!CuDnn_depthConcat_outshape(tensors, outshape, &ndim, &dtype)) return NULL; out = CuDnn_enforceAllocated(out, allocator, outshape, ndim, dtype, true); size_t length = PyList_GET_SIZE(tensors), stride = 0; for (size_t i = 0; i < length; i += 1) { Cuda_GPUArray *tensor = (Cuda_GPUArray *)PyList_GET_ITEM(tensors, i); const size_t *shape = CUDA_GPUARRAY_SHAPE(tensor), *outstrides = CUDA_GPUARRAY_STRIDES(out); CuDnn_TransformParams params; params.ndim = ndim; for (size_t j = 0; j < ndim; j += 1) { params.shape[j] = shape[j]; params.instrides[j] = CUDA_GPUARRAY_STRIDES(tensor)[j], params.outstrides[j] = outstrides[j]; } size_t center = 0; for (size_t j = 2; j < ndim; j += 1) center += (outshape[j] - shape[j]) / 2 * outstrides[j]; if (!CuDnn_Context_transform( (CuDnn_Context *)self, tensor->gpudata->ptr, (char *)out->gpudata->ptr + stride + center, params, ndim, dtype )) goto error; stride += outstrides[1] * shape[1]; } return (PyObject *)out; error: Py_DECREF(out); return NULL; } static PyObject *CuDnn_depthSplit_prepareInGradList(PyListObject *tensors, PyObject *ingradList, const Cuda_GPUArray *grad, Cuda_MemoryPool *allocator) { size_t length = PyList_GET_SIZE(tensors); if (ingradList != NULL && length != (size_t)PyList_GET_SIZE(ingradList)) { PyErr_SetString(PyExc_ValueError, "invalid number of output gpuarrays"); return NULL; } size_t inshape[GPUTENSOR_DIM_MAX]; PyObject *out = PyList_New(length); for (size_t i = 0; i < length; i += 1) { PyObject *item = PyList_GET_ITEM(tensors, i); if (Py_TYPE(item) != Cuda_GPUArray_Type) { PyErr_SetString(PyExc_TypeError, "invalid item type in input gpuarray list"); goto error; } Cuda_GPUArray *tensor = (Cuda_GPUArray *)item; if (tensor->ndim != grad->ndim) { PyErr_SetString(PyExc_ValueError, "invalid item gpuarray dims"); goto error; } const size_t *shape = CUDA_GPUARRAY_SHAPE(tensor); if (i == 0) for (size_t j = 0; j < tensor->ndim; j += 1) inshape[j] = shape[j]; else { if (shape[0] != inshape[0]) { PyErr_SetString(PyExc_ValueError, "invalid item gpuarray dims"); goto error; } inshape[1] += shape[1]; for (size_t j = 2; j < tensor->ndim; j += 1) inshape[j] = (inshape[j] > shape[j]) ? inshape[j] : shape[j]; } Cuda_GPUArray *ingrad = NULL; if (ingradList != NULL) { PyObject *outItem = PyList_GET_ITEM(ingradList, i); if (Py_TYPE(outItem) != Cuda_GPUArray_Type) { PyErr_SetString(PyExc_TypeError, "invalid item type in output gpuarray list"); goto error; } ingrad = (Cuda_GPUArray *)outItem; } ingrad = CuDnn_enforceAllocated(ingrad, allocator, shape, tensor->ndim, tensor->dtype, false); if (ingrad == NULL) goto error; PyList_SET_ITEM(out, i, (PyObject *)ingrad); } for (size_t i = 0; i < grad->ndim; i += 1) { if (inshape[i] != CUDA_GPUARRAY_SHAPE(grad)[i]) { PyErr_SetString(PyExc_ValueError, "invalid total input gpuarray dims"); goto error; } } return out; error: Py_DECREF(out); return NULL; } const char CuDnn_Context_depthSplit_doc[] = PyDoc_STR( "depthSplit(self, grad, tensors, out=None, allocator=None) -> List[" CUDA_GPUARRAY_FULLNAME "]" ); PyObject *CuDnn_Context_depthSplit(PyObject *self, PyObject *args, PyObject *kwds) { const char *kwlist[] = {"grad", "tensors", "out", "allocator", NULL}; Cuda_GPUArray *grad; PyListObject *tensors; PyObject *ingradList = NULL, *pyalloc = NULL; if (!PyArg_ParseTupleAndKeywords( args, kwds, "O!O!|OO", (char **)kwlist, Cuda_GPUArray_Type, &grad, &PyList_Type, &tensors, &ingradList, &pyalloc )) return NULL; if (!unpackPyOptional(&ingradList, &PyList_Type, "out")) return NULL; if (!unpackPyOptional(&pyalloc, Cuda_MemoryPool_Type, "allocator")) return NULL; Cuda_MemoryPool *allocator = (Cuda_MemoryPool *)pyalloc; if (!CuDnn_isValidDim(grad->ndim)) { PyErr_SetString(PyExc_ValueError, "invalid input gpuarray dims"); return NULL; } if (!CuDnn_isValidDtype(grad->dtype)) { PyErr_SetString(PyExc_ValueError, "invalid input gpuarray data layout"); return NULL; } PyObject *out = CuDnn_depthSplit_prepareInGradList(tensors, ingradList, grad, allocator); if (out == NULL) return NULL; size_t length = PyList_GET_SIZE(out), stride = 0; for (size_t i = 0; i < length; i += 1) { Cuda_GPUArray *ingrad = (Cuda_GPUArray *)PyList_GET_ITEM(out, i); const size_t *shape = CUDA_GPUARRAY_SHAPE(ingrad), *strides = CUDA_GPUARRAY_STRIDES(grad); CuDnn_TransformParams params; params.ndim = grad->ndim; for (size_t j = 0; j < grad->ndim; j += 1) { params.shape[j] = shape[j]; params.instrides[j] = strides[j], params.outstrides[j] = CUDA_GPUARRAY_STRIDES(ingrad)[j]; } size_t center = 0; for (size_t j = 2; j < grad->ndim; j += 1) center += (CUDA_GPUARRAY_SHAPE(grad)[j] - shape[j]) / 2 * strides[j]; if (!CuDnn_Context_transform( (CuDnn_Context *)self, (char *)grad->gpudata->ptr + stride + center, ingrad->gpudata->ptr, params, grad->ndim, grad->dtype )) goto error; stride += strides[1] * shape[1]; } return out; error: Py_DECREF(out); return NULL; }
27.729825
120
0.683411
[ "object", "shape" ]
39cf8a2fe3358338914ef3999c63bb0abfbf1549
1,400
h
C
model/v1_scale_io_volume_source.h
ityuhui/client-c
1d30380d7ba0fe9b5e97626e0f7507be4ce8f96d
[ "curl", "Apache-2.0" ]
null
null
null
model/v1_scale_io_volume_source.h
ityuhui/client-c
1d30380d7ba0fe9b5e97626e0f7507be4ce8f96d
[ "curl", "Apache-2.0" ]
null
null
null
model/v1_scale_io_volume_source.h
ityuhui/client-c
1d30380d7ba0fe9b5e97626e0f7507be4ce8f96d
[ "curl", "Apache-2.0" ]
null
null
null
/* * v1_scale_io_volume_source.h * * ScaleIOVolumeSource represents a persistent ScaleIO volume */ #ifndef _v1_scale_io_volume_source_H_ #define _v1_scale_io_volume_source_H_ #include <string.h> #include "../external/cJSON.h" #include "../include/list.h" #include "../include/keyValuePair.h" #include "v1_local_object_reference.h" typedef struct v1_scale_io_volume_source_t { char *fsType; // string char *gateway; // string char *protectionDomain; // string int readOnly; //boolean v1_local_object_reference_t *secretRef; //model int sslEnabled; //boolean char *storageMode; // string char *storagePool; // string char *system; // string char *volumeName; // string } v1_scale_io_volume_source_t; v1_scale_io_volume_source_t *v1_scale_io_volume_source_create( char *fsType, char *gateway, char *protectionDomain, int readOnly, v1_local_object_reference_t *secretRef, int sslEnabled, char *storageMode, char *storagePool, char *system, char *volumeName ); void v1_scale_io_volume_source_free(v1_scale_io_volume_source_t *v1_scale_io_volume_source); v1_scale_io_volume_source_t *v1_scale_io_volume_source_parseFromJSON(cJSON *v1_scale_io_volume_sourceJSON); cJSON *v1_scale_io_volume_source_convertToJSON(v1_scale_io_volume_source_t *v1_scale_io_volume_source); #endif /* _v1_scale_io_volume_source_H_ */
26.415094
107
0.768571
[ "model" ]
39d0a98ca07480dde8390f71d3d6046454598132
1,465
h
C
Plugin/sources/DirectSoundInputStream.h
mitsukuro/mrayGStreamerUnity
8afc11a67f005fe5464a08f88811cec8f5f96bb2
[ "MIT" ]
78
2015-10-19T23:23:06.000Z
2022-03-08T13:36:32.000Z
Plugin/sources/DirectSoundInputStream.h
mitsukuro/mrayGStreamerUnity
8afc11a67f005fe5464a08f88811cec8f5f96bb2
[ "MIT" ]
29
2015-10-22T14:40:01.000Z
2022-03-25T17:13:22.000Z
Plugin/sources/DirectSoundInputStream.h
mitsukuro/mrayGStreamerUnity
8afc11a67f005fe5464a08f88811cec8f5f96bb2
[ "MIT" ]
27
2015-12-02T14:38:17.000Z
2022-02-04T11:17:05.000Z
/******************************************************************** created: 2011/01/15 created: 15:1:2011 20:41 filename: i:\Programing\GameEngine\mrayEngine\mraySound\DirectSoundInputStream.h file path: i:\Programing\GameEngine\mrayEngine\mraySound file base: DirectSoundInputStream file ext: h author: Mohamad Yamen Saraiji purpose: *********************************************************************/ #ifndef DirectSoundInputStream_h__ #define DirectSoundInputStream_h__ #include "mTypes.h" #include <string> #include <vector> namespace mray { namespace sound { struct InputStreamDeviceInfo { int ID; std::string name; std::string deviceGUID; std::string description; }; class DirectSoundData; class DirectSoundInputStream { private: protected: DirectSoundData* m_dsData; uchar m_numChannels; uint m_samplesPerSec; uint m_avgBytesPerSec; uchar m_bitsPerSample; bool m_recording; uint m_lastReadOffset; void* m_captureBuffer; public: DirectSoundInputStream(); virtual ~DirectSoundInputStream(); virtual void ListDevices(std::vector<InputStreamDeviceInfo> &lst); virtual bool CreateInputStream(int device,uchar numChannels,uint samplesPerSec,uint avgBytesPerSec,uchar bitsPerSample); virtual bool StartInputStream(); virtual void CaptureSamples(std::vector<uchar>& buffer); virtual void StopInputStream(); virtual bool CanStream(); virtual bool IsStreaming(); }; } } #endif // DirectSoundInputStream_h__
22.19697
121
0.711945
[ "vector" ]
39d2034a700238cbb7d6910258492fbf694ee05d
13,198
c
C
Automaton_pickle.c
timgates42/pyahocorasick
3eab1ed66cea1dd30a48eff03927326a166502e5
[ "BSD-3-Clause" ]
707
2015-03-26T02:43:06.000Z
2022-03-28T07:54:06.000Z
Automaton_pickle.c
timgates42/pyahocorasick
3eab1ed66cea1dd30a48eff03927326a166502e5
[ "BSD-3-Clause" ]
140
2015-04-18T04:47:19.000Z
2022-03-09T11:24:50.000Z
Automaton_pickle.c
timgates42/pyahocorasick
3eab1ed66cea1dd30a48eff03927326a166502e5
[ "BSD-3-Clause" ]
112
2015-06-17T03:51:32.000Z
2022-03-09T01:58:58.000Z
/* This is part of pyahocorasick Python module. Implementation of pickling/unpickling routines for Automaton class Author : Wojciech Muła, wojciech_mula@poczta.onet.pl WWW : http://0x80.pl License : BSD-3-Clause (see LICENSE) */ /* Pickling (automaton___reduce__): 1. assign sequential numbers to nodes in order to replace address with these numbers (pickle_dump_replace_fail_with_id) 2. save in array all nodes data in the same order as numbers, also replace fail and next links with numbers; collect on a list all values (python objects) stored in a trie (pickle_dump_save); Before we start, all nodes of trie are visited and total size of pickled data is calculated. If it is small enough (less than given threshold), all data is saved in a single byte array. Otherwise, data is saved in several byte arrays. In either case, the format of byte array is the same: * 8 first bytes is number of nodes stored in this chunk of memory * the number if followed by some raw data. When there is just one byte array, it's size is fit to needs. If data is split, then each array has exactly the same size of bytes, but not all might be used (only the last array is fit). 3. clean up (pickle_dump_undo_replace or pickle_dump_revert_replace) Unpickling (automaton_unpickle, called in Automaton constructor) 1. load all nodes from array 2. make number->node lookup table 3. replace numbers stored in fail and next pointers with real pointers, reassign python objects as values */ #include <string.h> #include "src/pickle/pickle_data.c" typedef struct NodeID { TrieNode* fail; ///< original fail value Py_uintptr_t id; ///< id } NodeID; typedef struct DumpState { Py_uintptr_t id; ///< next id size_t total_size; ///< number of nodes TrieNode* failed_on; ///< if fail while numerating, save node in order /// to revert changes made in trie } DumpState; static size_t get_pickled_size(TrieNode* node) { ASSERT(node != NULL); return PICKLE_TRIENODE_SIZE + node->n * sizeof(Pair); } // replace fail with pairs (fail, id) static int pickle_dump_replace_fail_with_id(TrieNode* node, const int depth, void* extra) { NodeID* repl; ASSERT(sizeof(NodeID*) <= sizeof(TrieNode*)); #define state ((DumpState*)extra) repl = (NodeID*)memory_alloc(sizeof(NodeID)); if (LIKELY(repl != NULL)) { state->id += 1; state->total_size += get_pickled_size(node); repl->id = state->id; repl->fail = node->fail; node->fail = (TrieNode*)repl; return 1; } else { // error, revert is needed! state->failed_on = node; return 0; } #undef state } // revert changes in trie (in case of error) static int pickle_dump_revert_replace(TrieNode* node, const int depth, void* extra) { #define state ((DumpState*)extra) if (state->failed_on != node) { NodeID* repl = (NodeID*)(node->fail); node->fail = repl->fail; memory_free(repl); return 1; } else return 0; #undef state } // revert changes in trie static int pickle_dump_undo_replace(TrieNode* node, const int depth, void* extra) { #define state ((DumpState*)extra) NodeID* repl = (NodeID*)(node->fail); node->fail = repl->fail; memory_free(repl); return 1; #undef state } static int pickle_dump_save(TrieNode* node, const int depth, void* extra) { #define self ((PickleData*)extra) #define NODEID(object) ((NodeID*)((TrieNode*)object)->fail) TrieNode* dump; TrieNode* tmp; Pair* arr; unsigned i; size_t size; size = get_pickled_size(node); if (UNLIKELY(self->top + size > self->size)) { if (UNLIKELY(!pickle_data__add_next_buffer(self))) { self->error = true; return 0; } } dump = (TrieNode*)(self->data + self->top); // we do not save the last pointer in array arr = (Pair*)(self->data + self->top + PICKLE_TRIENODE_SIZE); // append the python object to the list if (node->eow and self->values) { if (PyList_Append(self->values, node->output.object) == -1) { self->error = true; return 0; } } // save node data if (self->values) dump->output.integer = 0; else dump->output.integer = node->output.integer; dump->n = node->n; dump->eow = node->eow; tmp = NODEID(node)->fail; if (tmp) dump->fail = (TrieNode*)(NODEID(tmp)->id); else dump->fail = NULL; // save array of pointers for (i=0; i < node->n; i++) { TrieNode* child = trienode_get_ith_unsafe(node, i); ASSERT(child); arr[i].child = (TrieNode*)(NODEID(child)->id); // save the id of child node arr[i].letter = trieletter_get_ith_unsafe(node, i); } self->top += size; (*self->count) += 1; return 1; #undef NODEID #undef self } static PyObject* automaton___reduce__(PyObject* self, PyObject* args) { #define automaton ((Automaton*)self) #define MB ((size_t)(1024*1024)) const size_t array_size = 16*MB; DumpState state; PickleData data; PyObject* tuple; // 0. for an empty automaton do nothing if (automaton->count == 0) { // the class constructor feed with an empty argument build an empty automaton return F(Py_BuildValue)("O()", Py_TYPE(self)); } // 1. numerate nodes state.id = 0; state.failed_on = NULL; state.total_size = 0; trie_traverse(automaton->root, pickle_dump_replace_fail_with_id, &state); if (state.failed_on) { // revert changes (partial) trie_traverse(automaton->root, pickle_dump_revert_replace, &state); // and set error PyErr_NoMemory(); return NULL; } // 2. gather data if (!pickle_data__init(&data, automaton->store, state.total_size, array_size)) goto exception; trie_traverse(automaton->root, pickle_dump_save, &data); if (UNLIKELY(data.error)) { goto exception; } if (UNLIKELY(!pickle_data__shrink_last_buffer(&data))) { goto exception; } if (automaton->store != STORE_ANY) { // always pickle a Python object data.values = Py_None; Py_INCREF(data.values); } /* 3: save tuple: * binary data * automaton->kind * automaton->store * automaton->key_type * automaton->count * automaton->longest_word * list of values */ tuple = F(Py_BuildValue)( "O(OiiiiiO)", Py_TYPE(self), data.bytes_list, automaton->kind, automaton->store, automaton->key_type, automaton->count, automaton->longest_word, data.values ); if (data.values == Py_None) { data.values = NULL; } if (UNLIKELY(tuple == NULL)) { goto exception; } // revert all changes trie_traverse(automaton->root, pickle_dump_undo_replace, NULL); return tuple; exception: // revert all changes trie_traverse(automaton->root, pickle_dump_undo_replace, NULL); // and free memory pickle_data__cleanup(&data); return NULL; #undef automaton } static bool automaton_unpickle__validate_bytes_list(PyObject* bytes_list, size_t* result) { PyObject* bytes; Py_ssize_t k; Py_ssize_t nodes_count; const uint8_t* data; size_t count = 0; // calculate the total number of nodes (and do validate data at the same time) for (k=0; k < PyList_GET_SIZE(bytes_list); k++) { bytes = PyList_GET_ITEM(bytes_list, k); if (UNLIKELY(!F(PyBytes_CheckExact)(bytes))) { PyErr_Format(PyExc_ValueError, "Item #%d on the bytes list is not a bytes object", k); return false; } data = (const uint8_t*)PyBytes_AS_STRING(bytes); nodes_count = *((Py_ssize_t*)data); if (UNLIKELY(nodes_count <= 0)) { PyErr_Format(PyExc_ValueError, "Nodes count for item #%d on the bytes list is not positive (%d)", k, nodes_count); return false; } count += nodes_count; } *result = count; return true; } static bool automaton_unpickle( Automaton* automaton, PyObject* bytes_list, PyObject* values ) { TrieNode** id2node = NULL; TrieNode* node; TrieNode* dump; Pair* next; PyObject* bytes; PyObject* value; Py_ssize_t nodes_count; Py_ssize_t i; size_t id; const uint8_t* data; const uint8_t* ptr; const uint8_t* end; size_t k; size_t j; size_t object_idx = 0; size_t index; size_t count; if (!automaton_unpickle__validate_bytes_list(bytes_list, &count)) { goto exception; } id2node = (TrieNode**)memory_alloc((count+1) * sizeof(TrieNode*)); if (UNLIKELY(id2node == NULL)) { goto no_mem; } // 1. make nodes id = 1; for (k=0; k < PyList_GET_SIZE(bytes_list); k++) { bytes = PyList_GET_ITEM(bytes_list, k); data = (const uint8_t*)PyBytes_AS_STRING(bytes); nodes_count = *((Py_ssize_t*)data); ptr = data + PICKLE_CHUNK_COUNTER_SIZE; end = ptr + PyBytes_GET_SIZE(bytes) - PICKLE_CHUNK_COUNTER_SIZE; for (i=0; i < nodes_count; i++) { if (UNLIKELY(ptr + PICKLE_TRIENODE_SIZE > end)) { PyErr_Format(PyExc_ValueError, "Data truncated [parsing header of node #%d]: " "chunk #%d @ offset %lu, expected at least %lu bytes", i, k, ptr - data, PICKLE_TRIENODE_SIZE); goto exception; } dump = (TrieNode*)(ptr); node = (TrieNode*)memory_alloc(sizeof(TrieNode)); if (LIKELY(node != NULL)) { node->output = dump->output; node->fail = dump->fail; node->n = dump->n; node->eow = dump->eow; node->next = NULL; } else goto no_mem; ptr += PICKLE_TRIENODE_SIZE; id2node[id++] = node; if (node->n > 0) { if (UNLIKELY(ptr + node->n * sizeof(Pair) > end)) { PyErr_Format(PyExc_ValueError, "Data truncated [parsing children of node #%d]: " "chunk #%d @ offset %lu, expected at least %ld bytes", i, k, ptr - data + i, node->n * sizeof(Pair)); goto exception; } node->next = (Pair*)memory_alloc(node->n * sizeof(Pair)); if (UNLIKELY(node->next == NULL)) { goto no_mem; } next = (Pair*)(ptr); for (j=0; j < node->n; j++) { node->next[j] = next[j]; } ptr += node->n * sizeof(Pair); } } } // 2. restore pointers and references to pyobjects for (i=1; i < id; i++) { node = id2node[i]; // references if (values and node->eow) { value = F(PyList_GetItem)(values, object_idx); if (value) { Py_INCREF(value); node->output.object = value; object_idx += 1; } else goto exception; } // pointers if (node->fail) { index = (size_t)(node->fail); if (LIKELY(index < count + 1)) { node->fail = id2node[index]; } else { PyErr_Format(PyExc_ValueError, "Node #%lu malformed: the fail link points to node #%lu, while there are %lu nodes", i - 1, index, count); goto exception; } } for (j=0; j < node->n; j++) { index = (size_t)(node->next[j].child); if (LIKELY(index < count + 1)) { node->next[j].child = id2node[index]; } else { PyErr_Format(PyExc_ValueError, "Node #%lu malformed: next link #%lu points to node #%lu, while there are %lu nodes", i - 1, j, index, count); goto exception; } } } automaton->root = id2node[1]; memory_free(id2node); return 1; no_mem: PyErr_NoMemory(); exception: // free memory if (id2node) { for (i=1; i < id; i++) { trienode_free(id2node[i]); } memory_free(id2node); } // If there is value list and some of its items were already // referenced, release them if (values) { for (i=0; i < object_idx; i++) { Py_XDECREF(F(PyList_GetItem)(values, i)); } } return 0; }
26.879837
114
0.562813
[ "object" ]
39dbe31fddb8515640eb39e906dbc529705801e0
197
h
C
cycle/ts/_ts.h
zhanghuanqian/CFDWARP
9340a8526bb263d910f79d79e84dcac7aec211b6
[ "BSD-2-Clause" ]
29
2018-09-13T13:58:18.000Z
2022-03-08T21:44:13.000Z
cycle/ts/_ts.h
zhanghuanqian/CFDWARP
9340a8526bb263d910f79d79e84dcac7aec211b6
[ "BSD-2-Clause" ]
3
2020-11-10T11:28:30.000Z
2021-11-23T09:21:28.000Z
cycle/ts/_ts.h
zhanghuanqian/CFDWARP
9340a8526bb263d910f79d79e84dcac7aec211b6
[ "BSD-2-Clause" ]
20
2018-07-26T08:17:37.000Z
2022-03-04T08:41:55.000Z
#ifndef _TS_H #define _TS_H #include <src/common.h> #include <model/_model.h> void update_U(np_t *np, gl_t *gl, zone_t zone); void find_dU(np_t *np, gl_t *gl, zone_t zone); #endif /* _TS_H */
16.416667
47
0.685279
[ "model" ]
5eac3f485b8b264209178402a377ea2afbe8cc7e
2,958
h
C
demos/common/cpp/models/include/models/detection_model_retinaface.h
kblaszczak-intel/open_model_zoo
e313674d35050d2a4721bbccd9bd4c404f1ba7f8
[ "Apache-2.0" ]
2,201
2018-10-15T14:37:19.000Z
2020-07-16T02:05:51.000Z
demos/common/cpp/models/include/models/detection_model_retinaface.h
kblaszczak-intel/open_model_zoo
e313674d35050d2a4721bbccd9bd4c404f1ba7f8
[ "Apache-2.0" ]
759
2018-10-18T07:43:55.000Z
2020-07-16T01:23:12.000Z
demos/common/cpp/models/include/models/detection_model_retinaface.h
kblaszczak-intel/open_model_zoo
e313674d35050d2a4721bbccd9bd4c404f1ba7f8
[ "Apache-2.0" ]
808
2018-10-16T14:03:49.000Z
2020-07-15T11:41:45.000Z
/* // Copyright (C) 2020-2022 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. */ #pragma once #include <map> #include <memory> #include <string> #include <vector> #include "models/detection_model.h" namespace ov { class Model; } // namespace ov struct InferenceResult; struct ResultBase; class ModelRetinaFace : public DetectionModel { public: struct Anchor { float left; float top; float right; float bottom; float getWidth() const { return (right - left) + 1.0f; } float getHeight() const { return (bottom - top) + 1.0f; } float getXCenter() const { return left + (getWidth() - 1.0f) / 2.0f; } float getYCenter() const { return top + (getHeight() - 1.0f) / 2.0f; } }; static const int LANDMARKS_NUM = 5; static const int INIT_VECTOR_SIZE = 200; /// Loads model and performs required initialization /// @param model_name name of model to load /// @param confidenceThreshold - threshold to eliminate low-confidence detections. /// Any detected object with confidence lower than this threshold will be ignored. /// @param useAutoResize - if true, image will be resized by openvino. /// @param boxIOUThreshold - threshold for NMS boxes filtering, varies in [0.0, 1.0] range. /// @param layout - model input layout ModelRetinaFace(const std::string& model_name, float confidenceThreshold, bool useAutoResize, float boxIOUThreshold, const std::string& layout = ""); std::unique_ptr<ResultBase> postprocess(InferenceResult& infResult) override; protected: struct AnchorCfgLine { int stride; std::vector<int> scales; int baseSize; std::vector<int> ratios; }; bool shouldDetectMasks; bool shouldDetectLandmarks; const float boxIOUThreshold; const float maskThreshold; float landmarkStd; enum OutputType { OUT_BOXES, OUT_SCORES, OUT_LANDMARKS, OUT_MASKSCORES, OUT_MAX }; std::vector<std::string> separateOutputsNames[OUT_MAX]; const std::vector<AnchorCfgLine> anchorCfg; std::map<int, std::vector<Anchor>> anchorsFpn; std::vector<std::vector<Anchor>> anchors; void generateAnchorsFpn(); void prepareInputsOutputs(std::shared_ptr<ov::Model>& model) override; };
31.806452
95
0.659229
[ "object", "vector", "model" ]
5eae00ecfc07599e002a41c32f195cdec350c90c
2,623
h
C
WLCollectionView/Class/Delegate/WLCollectionViewDelegate.h
DaLiangWang/WLCollectionView
178a5d3691c6e131e43c8997cf2e819ab29d4250
[ "MIT" ]
null
null
null
WLCollectionView/Class/Delegate/WLCollectionViewDelegate.h
DaLiangWang/WLCollectionView
178a5d3691c6e131e43c8997cf2e819ab29d4250
[ "MIT" ]
null
null
null
WLCollectionView/Class/Delegate/WLCollectionViewDelegate.h
DaLiangWang/WLCollectionView
178a5d3691c6e131e43c8997cf2e819ab29d4250
[ "MIT" ]
null
null
null
// // WLCollectionView.h // 链式语法 // // Created by shushui on 2018/8/16. // Copyright © 2018年 shushui. All rights reserved. // #import <UIKit/UIKit.h> #import "WLBaseCollectionViewLayerModel.h" #import "UIScrollView+WLEmptyDataSet.h" @protocol WLCollectionDelegate <NSObject> @required @optional //cell创建 -(UICollectionViewCell *)wl_collectionView:(UICollectionView *)collectionView layerModel:(WLBaseCollectionViewLayerModel *)model cellIndexPath:(NSIndexPath *)indexPath; //头脚视图创建 - (UICollectionReusableView *)wl_collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind layersectionModel:(id)section atIndexPath:(NSIndexPath *)indexPath; //点击cell的响应 - (void)wl_collectionView:(UICollectionView *)collectionView layerModel:(WLBaseCollectionViewLayerModel *)layerModel didIndexPath:(NSIndexPath *)indexPath; - (void)wl_collectionView:(UICollectionView *)collectionView layerModel:(WLBaseCollectionViewLayerModel *)layerModel layerRowData:(id)rowData didIndexPath:(NSIndexPath *)indexPath; // 结束拖拽时触发 - (void)wl_scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate; // 换页 - (void)wl_changeDragging:(UIScrollView *)scrollView pageNumber:(NSInteger)pageNumber; // 滚动就会触发 - (void)wl_scrollViewDidScroll:(UIScrollView *)scrollView; #pragma mark --缺省页 /** 自定义显示视图 */ - (UIView *)wl_customViewForWLEmptyDataSet; /** 强制显示空数据集:当项目数量大于0时,请求代理是否仍应显示空数据集。(默认值为NO) */ - (BOOL)wl_emptyDataSetShouldBeForcedToDisplay; /** 点击刷新按钮 */ - (void )wl_clickReloadButton; @end @interface WLCollectionViewDelegate : NSObject <UICollectionViewDelegate,UICollectionViewDataSource,WLEmptyDataSetSource, WLEmptyDataSetDelegate> /** cell需要绑定代理的对象 */ @property(nonatomic,strong) id delegateTie; /** 资深代理对象 */ @property(nonatomic,weak) id<WLCollectionDelegate> delegate; /** collection 对象 */ @property(nonatomic,strong) UICollectionView *collection; /** 判断是否为初次初始化,用于判断空白页样式 */ @property(nonatomic,assign) BOOL isNotReload; /** 滚动方向,根据滚动方向进行滑动换页计算 */ @property (nonatomic) UICollectionViewScrollDirection scrollDirection; // default is UICollectionViewScrollDirectionVertical /** 初始化对象 待废弃 */ - (instancetype)initWithDelegate:(id)delegate collection:(UICollectionView *)collection; /** 初始化对象 新 */ - (instancetype)initWithCollection:(UICollectionView *)collection; /** 视图展示模型 */ @property(nonatomic,strong) WLBaseCollectionViewLayerModel *viewModel; @end
35.445946
145
0.737324
[ "model" ]
5eb2b5a5d8259a587970de69c563db15d7137f38
1,294
h
C
common/include/logger/Logger.h
Vladec/matching-engine
090a7e7414f478f1424a50668e3f5c2417646ba7
[ "MIT" ]
9
2015-02-17T14:00:52.000Z
2018-07-03T12:10:08.000Z
common/include/logger/Logger.h
faulaire/matching-engine
090a7e7414f478f1424a50668e3f5c2417646ba7
[ "MIT" ]
1
2015-05-14T13:35:59.000Z
2015-05-14T13:35:59.000Z
common/include/logger/Logger.h
Vladec/matching-engine
090a7e7414f478f1424a50668e3f5c2417646ba7
[ "MIT" ]
7
2015-05-02T16:33:32.000Z
2018-08-10T10:02:48.000Z
/* * Copyright (C) 2016, Fabien Aulaire * All rights reserved. */ #pragma once #include <LoggerHolder.h> #include <LoggerConsole.h> #include <LoggerFile.h> namespace exch_logger = exchange::common::logger; typedef boost::fusion::vector<exch_logger::LoggerConsole, exch_logger::LoggerFile> ExchangeLoggers; typedef exch_logger::LoggerHolder<ExchangeLoggers> LoggerHolder; #define EXINFO(MSG) do { LoggerHolder::GetInstance() << exch_logger::header_info << MSG << exch_logger::eos; } while (0) #define EXWARN(MSG) do { LoggerHolder::GetInstance() << exch_logger::header_warn << MSG << exch_logger::eos; } while (0) #define EXERR(MSG) do { LoggerHolder::GetInstance() << exch_logger::header_err << MSG << exch_logger::eos; } while (0) #define EXPANIC(MSG) do { LoggerHolder::GetInstance() << exch_logger::header_panic << MSG << exch_logger::eos; } while (0) #define EXLOG(Category, Verbosity, MSG) \ do { if ( LoggerHolder::GetInstance().IsReporting( Category, Verbosity ) ) \ { \ LoggerHolder::GetInstance() << exch_logger::header_info << MSG << exch_logger::eos;\ } } while (0)
43.133333
122
0.608964
[ "vector" ]
5ebdb0f8bb088520ae294b9090773f66fde1fcca
6,693
h
C
Modules/Platform/App/Include/Methane/Platform/AppBase.h
navono/MethaneKit
5cf55dcbbc23392f5c06b178570c7c32b6368ca7
[ "Apache-2.0" ]
null
null
null
Modules/Platform/App/Include/Methane/Platform/AppBase.h
navono/MethaneKit
5cf55dcbbc23392f5c06b178570c7c32b6368ca7
[ "Apache-2.0" ]
null
null
null
Modules/Platform/App/Include/Methane/Platform/AppBase.h
navono/MethaneKit
5cf55dcbbc23392f5c06b178570c7c32b6368ca7
[ "Apache-2.0" ]
null
null
null
/****************************************************************************** Copyright 2019-2020 Evgeny Gorodetskiy 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: Methane/Platform/AppBase.h Base application interface and platform-independent implementation. ******************************************************************************/ #pragma once #include <Methane/Platform/AppView.h> #include <Methane/Platform/Input/State.h> #include <Methane/Data/Types.h> #include <Methane/Memory.hpp> #include <Methane/Instrumentation.h> #include <CLI/App.hpp> #include <fmt/format.h> #include <string> #include <vector> #include <memory> namespace tf // NOSONAR { // TaskFlow Executor class forward declaration: // #include <taskflow/core/executor.hpp> class Executor; } namespace Methane::Platform { struct AppEnvironment; class AppBase : public CLI::App { public: struct Settings { std::string name; double width = 0.8; // if width < 1.0 use as ratio of desktop size; else use as exact size in pixels/dots double height = 0.8; // same rule applies for height bool is_full_screen = false; uint32_t min_width = 640; uint32_t min_height = 480; }; struct RunArgs { int cmd_arg_count; const char** cmd_arg_values; }; struct Message { enum class Type : uint32_t { Information = 0, Warning, Error }; Type type; std::string title; std::string information; }; explicit AppBase(const Settings& settings); ~AppBase() override; // AppBase interface virtual int Run(const RunArgs& args); virtual void InitContext(const Platform::AppEnvironment& env, const Data::FrameSize& frame_size) = 0; virtual void Init(); virtual void ChangeWindowBounds(const Data::FrameRect& window_bounds); virtual void StartResizing(); virtual void EndResizing(); virtual bool Resize(const Data::FrameSize& frame_size, bool is_minimized); virtual bool Update() = 0; virtual bool Render() = 0; virtual void Alert(const Message& msg, bool deferred = false); virtual void SetWindowTitle(const std::string& title_text) = 0; virtual bool SetFullScreen(bool is_full_screen); virtual bool SetKeyboardFocus(bool has_keyboard_focus); virtual void ShowControlsHelp(); virtual void ShowCommandLineHelp(); virtual void ShowParameters() { /* no parameters are displayed by default, but can be overridden */ } virtual void Close() = 0; bool InitContextWithErrorHandling(const Platform::AppEnvironment& env, const Data::FrameSize& frame_size) { return ExecuteWithErrorHandling("Render Context Initialization", *this, &AppBase::InitContext, env, frame_size); } bool InitWithErrorHandling() { return ExecuteWithErrorHandling("Application Initialization", *this, &AppBase::Init); } bool UpdateAndRenderWithErrorHandling() { return ExecuteWithErrorHandling("Application Rendering", *this, &AppBase::UpdateAndRender); } template<typename FuncType, typename... ArgTypes> void ProcessInputWithErrorHandling(FuncType&& func_ptr, ArgTypes&&... args) { ExecuteWithErrorHandling("Application Input", m_input_state, std::forward<FuncType>(func_ptr), std::forward<ArgTypes>(args)...); } tf::Executor& GetParallelExecutor() const; const Settings& GetPlatformAppSettings() const noexcept { return m_settings; } const Input::State& GetInputState() const noexcept { return m_input_state; } const Data::FrameSize& GetFrameSize() const noexcept { return m_frame_size; } bool IsMinimized() const noexcept { return m_is_minimized; } bool IsResizing() const noexcept { return m_is_resizing; } bool HasKeyboardFocus() const noexcept { return m_has_keyboard_focus; } bool HasError() const noexcept; protected: // AppBase interface virtual AppView GetView() const = 0; virtual void ShowAlert(const Message& msg); std::string GetControlsHelp() const; std::string GetCommandLineHelp() const { return CLI::App::help(); } void AddInputControllers(const Ptrs<Input::Controller>& controllers) { m_input_state.AddControllers(controllers); } void Deinitialize() { m_initialized = false; } bool HasDeferredMessage() const noexcept { return !!m_deferred_message_ptr; } const Message& GetDeferredMessage() const; void ResetDeferredMessage() noexcept { m_deferred_message_ptr.reset(); } private: bool UpdateAndRender(); template<typename ObjectType, typename FuncType, typename... ArgTypes> bool ExecuteWithErrorHandling(const char* stage_name, ObjectType& obj, FuncType&& func_ptr, ArgTypes&&... args) #ifdef _DEBUG const #endif { // We do not catch exceptions in Debug build to let them be handled by the Debugger #ifndef _DEBUG try { #else META_UNUSED(stage_name); #endif (obj.*std::forward<FuncType>(func_ptr))(std::forward<ArgTypes>(args)...); #ifndef _DEBUG } catch (std::exception& e) { Alert({ Message::Type::Error, fmt::format("{} Error", stage_name), e.what() }); return false; } catch (...) { Alert({ Message::Type::Error, fmt::format("{} Error", stage_name), "Unknown exception occurred." }); return false; } #endif return true; } Settings m_settings; Data::FrameRect m_window_bounds; Data::FrameSize m_frame_size; Ptr<Message> m_deferred_message_ptr; bool m_is_minimized = false; bool m_initialized = false; bool m_is_resizing = false; bool m_has_keyboard_focus = false; Input::State m_input_state; mutable UniquePtr<tf::Executor> m_parallel_executor_ptr; }; } // namespace Methane::Platform
35.791444
139
0.642761
[ "render", "vector" ]
5ec71ac8cb7dc5588ce6beba8e519a6e131f5d27
15,806
h
C
EnumInfo.h
bugrazoid/EnumReflection
32db5a1c0e0afaff6da14039c9dbf7010653b741
[ "MIT" ]
null
null
null
EnumInfo.h
bugrazoid/EnumReflection
32db5a1c0e0afaff6da14039c9dbf7010653b741
[ "MIT" ]
null
null
null
EnumInfo.h
bugrazoid/EnumReflection
32db5a1c0e0afaff6da14039c9dbf7010653b741
[ "MIT" ]
null
null
null
/** * @author Trubnikov Sergey <bugrazoid@gmail.com> */ #pragma once #include <string> #include <array> #include <map> #include <unordered_map> #include <type_traits> #include <optional> #include <stdexcept> #include <assert.h> template<typename Enum, typename String> class EnumInfo; namespace _enum_info_private { template<typename Enum> struct Adaptor { Enum val; constexpr operator Enum() const {return val;} constexpr Adaptor() : val(static_cast<Enum>([] { _val = _val.has_value() ? *_val + 1 : 0; return *_val; }())) {} template<typename U> constexpr Adaptor(U i) : val(static_cast<Enum>(i)) {_val = i;} template<typename U> constexpr const Adaptor operator=(const U) const {return *this;} private: static std::optional<std::underlying_type_t<Enum>> _val; }; template<typename Enum> std::optional<std::underlying_type_t<Enum>> Adaptor<Enum>::_val = std::nullopt; /** * @author Yakov Litvitskiy <thedsi100@gmail.com> (c) 2016 * <a href="https://github.com/thedsi/EnumReflection/blob/master/LICENSE.txt">LICENSE.txt</a> */ constexpr bool isIdentChar(char c) { return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c == '_'); } template<typename Enum> struct RawData { constexpr RawData(const char* enumName, size_t enumNameSize, const Enum* vals, size_t valsCount, const char* rawNames, size_t rawNamesSize) : _enumName(enumName), _enumNameSize(enumNameSize) , _rawNames(rawNames), _rawNamesSize(rawNamesSize) , _vals(vals) , _valsCount(valsCount) {} const char* _enumName; const size_t _enumNameSize; const char* _rawNames; const size_t _rawNamesSize; const Enum* _vals; const size_t _valsCount; }; template<typename Enum, typename String> struct ParsedData { constexpr ParsedData(const char* enumName, size_t enumNameSize, const Enum* vals, size_t valsCount, const char* rawNames, size_t rawNamesSize) : enumName(enumName, enumNameSize) , values(vals) , size(valsCount) { names.reserve(size); parseNames(vals, valsCount, rawNames, rawNamesSize); } constexpr ParsedData(RawData<Enum> rawData) : ParsedData(rawData._enumName, rawData._enumNameSize, rawData._vals, rawData._valsCount, rawData._rawNames, rawData._rawNamesSize) {} friend EnumInfo<Enum, String>; private: String enumName; std::vector<String> names; std::multimap<Enum, String> nameByVal; std::unordered_map<String, Enum> valByName; const Enum* values; const size_t size; /** * @author Yakov Litvitskiy <thedsi100@gmail.com> (c) 2016 * <a href="https://github.com/thedsi/EnumReflection/blob/master/LICENSE.txt">LICENSE.txt</a> */ constexpr void parseNames(const Enum* vals, size_t valsCount, const char* rawNames, size_t rawNamesSize) { enum states { state_start, // Before identifier state_ident, // In identifier state_skip, // Looking for separator comma } state = state_start; const char* begin = nullptr; const char* end = rawNames; size_t value_index = 0; int level = 0; while (end != rawNames + rawNamesSize) { assert(*end); switch (state) { case state_start: if (isIdentChar(*end)) { state = state_ident; begin = end; } ++end; break; case state_ident: if (!isIdentChar(*end)) { state = state_skip; assert(value_index < valsCount); const auto value = vals[value_index]; const String string(begin, size_t(end - begin)); names.push_back(string); nameByVal.emplace(value, string); valByName.emplace(string, value); ++value_index; } else { ++end; } break; case state_skip: if (*end == '(') { ++level; } else if (*end == ')') { if (level == 0) { assert(value_index == valsCount); return; } --level; } else if (level == 0 && *end == ',') { state = state_start; } ++end; } } } }; } // namespace _enum_info_private /** * @brief Declare an enumeration inside a class * @author Yakov Litvitskiy <thedsi100@gmail.com> (c) 2016 * <a href="https://github.com/thedsi/EnumReflection/blob/master/LICENSE.txt">LICENSE.txt</a> */ #define ENUM_DECLARE( enumName, enumType, ... )\ ENUM_INFO_DETAIL_MAKE( class, enumName, enumType, __VA_ARGS__ ) /** * @brief Declare an enumeration inside a namespace * @author Yakov Litvitskiy <thedsi100@gmail.com> (c) 2016 * <a href="https://github.com/thedsi/EnumReflection/blob/master/LICENSE.txt">LICENSE.txt</a> */ #define ENUM_DECLARE_NS( enumName, enumType, ... )\ ENUM_INFO_DETAIL_MAKE( namespace, enumName, enumType, __VA_ARGS__ ) /** * @author Yakov Litvitskiy <thedsi100@gmail.com> (c) 2016 * <a href="https://github.com/thedsi/EnumReflection/blob/master/LICENSE.txt">LICENSE.txt</a> */ #define ENUM_INFO_DETAIL_SPEC_namespace \ extern "C"{/* Protection from being used inside a class body */} \ inline /** * @author Yakov Litvitskiy <thedsi100@gmail.com> (c) 2016 * <a href="https://github.com/thedsi/EnumReflection/blob/master/LICENSE.txt">LICENSE.txt</a> */ #define ENUM_INFO_DETAIL_SPEC_class friend /** * @author Yakov Litvitskiy <thedsi100@gmail.com> (c) 2016 * <a href="https://github.com/thedsi/EnumReflection/blob/master/LICENSE.txt">LICENSE.txt</a> */ #define ENUM_INFO_DETAIL_STR(x) #x /** * @author Yakov Litvitskiy <thedsi100@gmail.com> (c) 2016 * <a href="https://github.com/thedsi/EnumReflection/blob/master/LICENSE.txt">LICENSE.txt</a> */ #define ENUM_INFO_DETAIL_MAKE(spec, enumName, enumType, ...) \ enum enumName:enumType \ { \ __VA_ARGS__ \ }; \ ENUM_INFO_DETAIL_SPEC_##spec \ const _enum_info_private::RawData<enumName>& getRawData(enumName = enumName()) \ { \ constexpr const char* const enumNameStr = ENUM_INFO_DETAIL_STR(enumName); \ constexpr const size_t enumNameStrSize = sizeof(ENUM_INFO_DETAIL_STR(enumName)) - 1; \ static const _enum_info_private::Adaptor<enumName> __VA_ARGS__; \ static const enumName vals[] = { __VA_ARGS__ }; \ constexpr size_t valsCount = sizeof(vals)/sizeof(enumName); \ constexpr const char* const rawNames = ENUM_INFO_DETAIL_STR((__VA_ARGS__)); \ constexpr const size_t rawNamesSize = sizeof (ENUM_INFO_DETAIL_STR((__VA_ARGS__))) - 1; \ static const _enum_info_private::RawData<enumName> rawData( \ enumNameStr, enumNameStrSize, vals, valsCount, rawNames, rawNamesSize); \ return rawData; \ } template<typename Enum, typename String = std::string_view> class EnumInfo { public: using EnumType = std::underlying_type_t<Enum>; static String name(); static size_t size(); static std::optional<String> valueName(Enum value); static std::optional<String> valueName(size_t index); // TODO: valueNames & aliases static std::optional<Enum> value(String name); static std::optional<Enum> value(size_t index); static std::optional<size_t> index(Enum value); static std::optional<size_t> index(String name); struct iterator { using iterator_category = std::bidirectional_iterator_tag; using value_type = iterator; iterator() = delete; size_t index(); Enum value(); String name() const; value_type operator*(); iterator& operator++(); iterator operator++(int); iterator& operator--(); iterator operator--(int); bool operator==(iterator) const; bool operator!=(iterator) const; private: friend EnumInfo; explicit iterator(const _enum_info_private::ParsedData<Enum, String>* const parsedData, size_t index); const _enum_info_private::ParsedData<Enum, String>* const _parsedData; size_t _index; }; using reverse_iterator = std::reverse_iterator<iterator>; static iterator begin(); static iterator end(); static reverse_iterator rbegin(); static reverse_iterator rend(); private: const static _enum_info_private::ParsedData<Enum, String> _parsedData; template<typename Ret, typename Key, typename Cont> static std::optional<Ret> find(Key key, Cont cont); static iterator fromIndex(size_t index); }; template<typename Enum, typename String> const _enum_info_private::ParsedData<Enum, String> EnumInfo<Enum, String>::_parsedData = _enum_info_private::ParsedData<Enum, String>(getRawData(Enum())); // ---- EnumInfo implementation ---- template<typename Enum, typename String> String EnumInfo<Enum, String>::name() { return _parsedData.enumName; } template<typename Enum, typename String> std::optional<String> EnumInfo<Enum, String>::valueName(Enum value) { return EnumInfo::find<String>(value, _parsedData.nameByVal); } template<typename Enum, typename String> std::optional<String> EnumInfo<Enum, String>::valueName(size_t index) { if (index >= _parsedData.names.size()) return std::nullopt; return _parsedData.names[index]; } template<typename Enum, typename String> std::optional<Enum> EnumInfo<Enum, String>::value(String name) { return EnumInfo::find<Enum>(name, _parsedData.valByName); } template<typename Enum, typename String> std::optional<Enum> EnumInfo<Enum, String>::value(size_t index) { if (index >= _parsedData.size) return std::nullopt; return _parsedData.values[index]; } template<typename Enum, typename String> std::optional<size_t> EnumInfo<Enum, String>::index(Enum value) { for (size_t i = 0; i < _parsedData.size; ++i) { if (_parsedData.values[i] == value) return i; } return std::nullopt; } template<typename Enum, typename String> std::optional<size_t> EnumInfo<Enum, String>::index(String name) { const auto it = std::find(_parsedData.names.begin(), _parsedData.names.end(), name); if (it == _parsedData.names.end()) return std::nullopt; return std::distance(_parsedData.names.begin(), it); } template<typename Enum, typename String> size_t EnumInfo<Enum, String>::size() { return _parsedData.size; } template<typename Enum, typename String> typename EnumInfo<Enum, String>::iterator EnumInfo<Enum, String>::begin() { return iterator(&_parsedData, 0); } template<typename Enum, typename String> typename EnumInfo<Enum, String>::iterator EnumInfo<Enum, String>::end() { return iterator(&_parsedData, size()); } template<typename Enum, typename String> typename EnumInfo<Enum, String>::reverse_iterator EnumInfo<Enum, String>::rbegin() { return iterator(_parsedData.nameByVal.begin()); } template<typename Enum, typename String> typename EnumInfo<Enum, String>::reverse_iterator EnumInfo<Enum, String>::rend() { return iterator(_parsedData.nameByVal.end()); } template<typename Enum, typename String> typename EnumInfo<Enum, String>::iterator EnumInfo<Enum, String>::fromIndex(size_t index) { iterator it(_parsedData.nameByVal.begin()); for (size_t i = 0; i != index; ++i) { ++it; } return it; } template<typename Enum, typename String> template<typename Ret, typename Key, typename Cont> std::optional<Ret> EnumInfo<Enum, String>::find(Key key, Cont cont) { const auto it = cont.find(key); if (it != cont.end()) { return it->second; } return std::nullopt; } // ---- EnumInfo::iterator implementation ---- template<typename Enum, typename String> EnumInfo<Enum, String>::iterator::iterator(const _enum_info_private::ParsedData<Enum, String>* const parsedData, size_t index) : _parsedData(parsedData) , _index(index) { assert(_parsedData != nullptr); assert(_index <= _parsedData->size); } template<typename Enum, typename String> size_t EnumInfo<Enum, String>::iterator::index() { return _index; } template<typename Enum, typename String> Enum EnumInfo<Enum, String>::iterator::value() { return _parsedData->values[_index]; } template<typename Enum, typename String> String EnumInfo<Enum, String>::iterator::name() const { return _parsedData->names[_index]; } template<typename Enum, typename String> typename EnumInfo<Enum, String>::iterator::value_type EnumInfo<Enum, String>::iterator::operator*() { return *this; } /// Prefix operator++ template<typename Enum, typename String> typename EnumInfo<Enum, String>::iterator& EnumInfo<Enum, String>::iterator::operator++() { ++_index; return *this; } /// Postfix operator++ template<typename Enum, typename String> typename EnumInfo<Enum, String>::iterator EnumInfo<Enum, String>::iterator::operator++(int) { EnumInfo<Enum, String>::iterator tmp(*this); operator++(); return tmp; } /// Prefix operator-- template<typename Enum, typename String> typename EnumInfo<Enum, String>::iterator& EnumInfo<Enum, String>::iterator::operator--() { --_index; return *this; } /// Postfix operator-- template<typename Enum, typename String> typename EnumInfo<Enum, String>::iterator EnumInfo<Enum, String>::iterator::operator--(int) { EnumInfo<Enum, String>::iterator tmp(*this); operator--(); return tmp; } template<typename Enum, typename String> bool EnumInfo<Enum, String>::iterator::operator==(EnumInfo::iterator other) const { return _parsedData == other._parsedData && _index == other._index; } template<typename Enum, typename String> bool EnumInfo<Enum, String>::iterator::operator!=(EnumInfo::iterator other) const { return !(*this == other); }
32.060852
147
0.58617
[ "vector" ]
5ec78217eb4cabd142e1cc22d25517c385254c98
2,007
h
C
Aplicacion Movil/generated/bundles/login-transition/build/Android/Preview/app/src/main/include/Fuse.Android.Controls-3a7bea61.h
marferfer/SpinOff-LoL
a9dba8ac9dd476ec1ef94712d9a8e76d3b45aca8
[ "Apache-2.0" ]
null
null
null
Aplicacion Movil/generated/bundles/login-transition/build/Android/Preview/app/src/main/include/Fuse.Android.Controls-3a7bea61.h
marferfer/SpinOff-LoL
a9dba8ac9dd476ec1ef94712d9a8e76d3b45aca8
[ "Apache-2.0" ]
null
null
null
Aplicacion Movil/generated/bundles/login-transition/build/Android/Preview/app/src/main/include/Fuse.Android.Controls-3a7bea61.h
marferfer/SpinOff-LoL
a9dba8ac9dd476ec1ef94712d9a8e76d3b45aca8
[ "Apache-2.0" ]
null
null
null
// This file was generated based on C:/Users/JuanJose/AppData/Local/Fusetools/Packages/Fuse.Controls.WebView/1.9.0/Android/WebView.Eval.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Uno.Object.h> namespace g{namespace Fuse{namespace Android{namespace Controls{namespace WebViewUtils{struct EvaluateJsCommand;}}}}} namespace g{namespace Fuse{namespace Android{namespace Controls{namespace WebViewUtils{struct JSEvalRequestManager;}}}}} namespace g{namespace Java{struct Object;}} namespace g{namespace Uno{namespace Collections{struct List;}}} namespace g{ namespace Fuse{ namespace Android{ namespace Controls{ namespace WebViewUtils{ // public sealed extern class JSEvalRequestManager :34 // { uType* JSEvalRequestManager_typeof(); void JSEvalRequestManager__ctor__fn(JSEvalRequestManager* __this, ::g::Java::Object* webViewHandle); void JSEvalRequestManager__CreateExpression_fn(JSEvalRequestManager* __this, uString* original, uString** __retval); void JSEvalRequestManager__EvaluateJs_fn(JSEvalRequestManager* __this, uString* js, uDelegate* handler); void JSEvalRequestManager__New1_fn(::g::Java::Object* webViewHandle, JSEvalRequestManager** __retval); void JSEvalRequestManager__NextRequest_fn(JSEvalRequestManager* __this); void JSEvalRequestManager__OnJsResult_fn(JSEvalRequestManager* __this, uString* result); struct JSEvalRequestManager : uObject { uStrong< ::g::Uno::Collections::List*> _evaluateRequests; uStrong< ::g::Fuse::Android::Controls::WebViewUtils::EvaluateJsCommand*> _currentRequest; uStrong< ::g::Java::Object*> _webViewHandle; uStrong<uString*> _interfaceName; void ctor_(::g::Java::Object* webViewHandle); uString* CreateExpression(uString* original); void EvaluateJs(uString* js, uDelegate* handler); void NextRequest(); void OnJsResult(uString* result); static JSEvalRequestManager* New1(::g::Java::Object* webViewHandle); }; // } }}}}} // ::g::Fuse::Android::Controls::WebViewUtils
45.613636
140
0.788739
[ "object" ]
5ece844b56a65fa42305babf2779f6e97a826575
558
h
C
Stripe3DS2/Stripe3DS2/STDSChallengeResponseMessageExtensionObject.h
oshima819/stripe-ios
f3581b36e3fc12ee5ecbc3d68926c488d7789e86
[ "MIT" ]
1,427
2015-01-12T14:39:45.000Z
2022-03-31T07:35:26.000Z
Stripe3DS2/Stripe3DS2/STDSChallengeResponseMessageExtensionObject.h
oshima819/stripe-ios
f3581b36e3fc12ee5ecbc3d68926c488d7789e86
[ "MIT" ]
1,303
2015-01-05T22:25:31.000Z
2022-03-29T11:59:30.000Z
Stripe3DS2/Stripe3DS2/STDSChallengeResponseMessageExtensionObject.h
oshima819/stripe-ios
f3581b36e3fc12ee5ecbc3d68926c488d7789e86
[ "MIT" ]
821
2015-01-07T21:20:00.000Z
2022-03-31T07:53:01.000Z
// // STDSChallengeResponseMessageExtensionObject.h // Stripe3DS2 // // Created by Andrew Harrison on 2/25/19. // Copyright © 2019 Stripe. All rights reserved. // #import <Foundation/Foundation.h> #import "STDSChallengeResponseMessageExtension.h" #import "STDSJSONDecodable.h" NS_ASSUME_NONNULL_BEGIN /// An object used to represent an individual message extension inside of a challenge response. @interface STDSChallengeResponseMessageExtensionObject: NSObject <STDSChallengeResponseMessageExtension, STDSJSONDecodable> @end NS_ASSUME_NONNULL_END
25.363636
123
0.811828
[ "object" ]
5edad75cd346c715c8bd22751b596ae87e8caf04
7,430
h
C
WSEExternal/include/Common/GeometryUtilities/Mesh/Utils/VertexBufferUtil/hkMeshVertexBufferUtil.h
Swyter/wse
3ad901f1a463139b320c30ea08bdc343358ea6b6
[ "WTFPL" ]
null
null
null
WSEExternal/include/Common/GeometryUtilities/Mesh/Utils/VertexBufferUtil/hkMeshVertexBufferUtil.h
Swyter/wse
3ad901f1a463139b320c30ea08bdc343358ea6b6
[ "WTFPL" ]
null
null
null
WSEExternal/include/Common/GeometryUtilities/Mesh/Utils/VertexBufferUtil/hkMeshVertexBufferUtil.h
Swyter/wse
3ad901f1a463139b320c30ea08bdc343358ea6b6
[ "WTFPL" ]
null
null
null
/* * * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's * prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok. * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement. * */ #ifndef HK_VERTEX_BUFFER_UTIL_H #define HK_VERTEX_BUFFER_UTIL_H #include <Common/GeometryUtilities/Mesh/hkMeshVertexBuffer.h> class hkMeshSystem; /// A utility to help in the processing of vertices and vertex buffers class hkMeshVertexBufferUtil { public: struct Thresholds { Thresholds(): m_positionThreshold(1e-5f), m_normalThreshold(1e-3f), m_colorThreshold(1.0f / 255.0f), m_otherThreshold(1e-5f), m_texCoordThreshold(1e-6f) { } hkReal m_positionThreshold; hkReal m_normalThreshold; hkReal m_colorThreshold; hkReal m_otherThreshold; hkReal m_texCoordThreshold; }; enum TransformFlag { TRANSFORM_NORMALIZE = 0x1, /// TRANSFORM_PRE_NEGATE = 0x2, /// TRANSFORM_POST_NEGATE = 0x4, /// }; typedef hkMeshVertexBuffer::LockedVertices LockedVertices; typedef LockedVertices::Buffer Buffer; typedef hkVertexFormat::Element Element; /// Extract the buffer as vector4s static hkResult HK_CALL getElementVectorArray(const Buffer& buffer, hkVector4* out, int numVertices); /// Get components and store in a hkVector4 array (helper function - calls getElementVectorArray with the appropriate buffer) static hkResult HK_CALL getElementVectorArray(const LockedVertices& lockedVertices, int bufferIndex, hkVector4* dst); /// Set components held in buffer from an array of hkVector4s static hkResult HK_CALL setElementVectorArray(const LockedVertices::Buffer& buffer, const hkVector4* src, int numVertices); /// Set components from a hkVector4 array (helper fucntion - calls setElementVectorArray with the appropritate buffer) static hkResult HK_CALL setElementVectorArray(const LockedVertices& lockedVertices, int bufferIndex, const hkVector4* src); /// The elements being extracted must have been previously been locked with lock/partialLock. static hkResult HK_CALL getElementIntArray(const LockedVertices& lockedVertices, int elementIndex, int* dst); /// Sets the elements of an array doing conversions from ints as needed. Converts only integral types. /// The elements being set must have previously have been locked with lock/partialLock. static hkResult HK_CALL setElementIntArray(const LockedVertices& lockedVertices, int elementIndex, const int* src); /// Copy the elements of src to dst of elementSize with the appropriate striding static void HK_CALL stridedCopy(const void* srcIn, int srcStride, void* dstIn, int dstStride, int elementSize, int numVertices); /// Zero the strided destination data static void HK_CALL stridedZero(void* dstIn, int dstStride, int elementSize, int numVertices); /// Copy vertex data from srcVertices to dstVertices static void HK_CALL copy(const LockedVertices& srcVertices, const LockedVertices& dstVertices); /// Copy the data from one buffer to the other - they must be the same type (m_type + m_numValues the same) static void HK_CALL copy(const Buffer& srcBuffer, const Buffer& dstBuffer, int numVertices); /// Copy/convert all of the src buffers into the destination buffers. static void HK_CALL convert(const LockedVertices& srcVertices, const LockedVertices& dstVertices); /// Copys/converts all members of src into dst static void HK_CALL convert(hkMeshVertexBuffer* src, hkMeshVertexBuffer* dst); /// Copy and convert as necessary static void HK_CALL convert(const Buffer& srcBuffer, const Buffer& dstBuffer, int numVertices); /// Finds out if the locked vertex data is contiguous static hkBool HK_CALL isContiguous(const LockedVertices& srcVertices, void** start, int& dataSize); /// Partition the format into shared and non shared (instanced) elements static void HK_CALL partitionVertexFormat(const hkVertexFormat& format, hkVertexFormat& sharedFormat, hkVertexFormat& instanceFormat); /// Get array component static hkResult HK_CALL getElementVectorArray(hkMeshVertexBuffer* vertexBuffer, hkVertexFormat::DataUsage usage, int subUsage, hkArray<hkVector4>& vectorsOut); /// Transform the content of the buffer static void HK_CALL transform(const Buffer& srcBuffer, const hkMatrix4& transform, int transformFlags, int numVertices); /// Transform the content of the vertex buffer static hkResult HK_CALL transform(hkMeshVertexBuffer* buffer, const hkMatrix4& transform, int transformFlags); /// Produces a new vertex buffer which is a concatenation of the input buffers. If only 1 buffer is input the original buffer is returned with an extra ref count. static hkMeshVertexBuffer* HK_CALL concatVertexBuffers(hkMeshSystem* system, hkMeshVertexBuffer** buffers, int numBuffers); /// Compares two buffers - all values must be equal within the threshold to return true. static hkBool HK_CALL isBufferDataEqual(const Buffer& bufferA, const Buffer& bufferB, hkReal threshold); /// Compare - handle data as a normal (use dot products difference from 1 as measure of error) static hkBool HK_CALL isBufferNormalDataEqual(const Buffer& bufferA, const Buffer& bufferB, hkReal threshold); /// Compares an array of buffer data. Uses the thresholds strucuture to determine what is equal based on type static hkBool HK_CALL isBufferDataEqual(const Buffer* a, const Buffer* b, int numBuffers, const Thresholds& thresholds); /// Performs a linear interpolation of components. Will normalize 'normal' type components /// If interp is 0, a is output, 1 then b is output. Ie its a * (1-interp) + b * interp static void HK_CALL interpolate(const hkVertexFormat::Element& element, const void* a, const void* b, hkReal interp, void* dst); }; #endif // HK_VERTEX_BUFFER_UTIL_H /* * Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20090704) * * Confidential Information of Havok. (C) Copyright 1999-2009 * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok * Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership * rights, and intellectual property rights in the Havok software remain in * Havok and/or its suppliers. * * Use of this software for evaluation purposes is subject to and indicates * acceptance of the End User licence Agreement for this product. A copy of * the license is included with this software and is also available at www.havok.com/tryhavok. * */
53.84058
247
0.705518
[ "mesh", "transform" ]
5ee08b6b196df26542f24f5aa682bc7338f274aa
9,066
h
C
zpp/sqlite3.h
ZRiemann/ZppAdapter
6320e382a8a4f4d1df91faac2ffd3adeee4939e9
[ "MIT" ]
null
null
null
zpp/sqlite3.h
ZRiemann/ZppAdapter
6320e382a8a4f4d1df91faac2ffd3adeee4939e9
[ "MIT" ]
null
null
null
zpp/sqlite3.h
ZRiemann/ZppAdapter
6320e382a8a4f4d1df91faac2ffd3adeee4939e9
[ "MIT" ]
null
null
null
/** * MIT License * * Copyright (c) 2018 Z.Riemann * https://github.com/ZRiemann/ * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the Software), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM * , OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #ifndef _ZPP_SQLITE3_H_ #define _ZPP_SQLITE3_H_ /** * @file sqlite3.h * @brief <A brief description of what this file is.> * @author Z.Riemann https://github.com/ZRiemann/ * @date 2018-07-26 Z.Riemann found */ #ifndef NSB_Z #define NSB_Z namespace z{ #define NSE_Z } #endif #include <string> #include <sqlite3.h> #include <zsi/base/error.h> #include <zsi/base/trace.h> NSB_Z /** * @brief sqlite3 wrapper */ class Sqlite{ public: sqlite3 *db; public: Sqlite() :db(NULL){} ~Sqlite(){Close();} zerr_t Open(const char *filename, int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, const char *vfs = NULL){ if(db){ zerr("sqlite already open"); return ZE_EXIST; } int err; if(SQLITE_OK != (err = sqlite3_open_v2(filename, &db, flags, vfs))){ zerr("%s", sqlite3_errstr(err)); return ZEFAIL; } return ZEOK; } zerr_t Close(){ if(db){ sqlite3_close_v2(db); db = NULL; } } /* * Configuring SQLite */ /* * Extending SQLite */ /* * Other Interfaces */ }; class SqliteStmt{ public: sqlite3 *db; sqlite3_stmt *stmt; const char *tail; public: SqliteStmt() :stmt(NULL) ,tail(NULL){} ~SqliteStmt(){ if(stmt){ sqlite3_finalize(stmt); } } /** * @brief Complied sql statement into byte-code program. * @pre sqlte3_open() */ zerr_t Prepare(Sqlite &sqldb, std::string &sql, unsigned int flags = 0){ db = sqldb.db; if(!db){ zerr("database not connected! call db.Open() first."); return ZEPARAM_INVALID; } if(sql.empty()){ zerr("query is empty"); return ZEPARAM_INVALID; } int err = sqlite3_prepare_v3(db, sql.data(), sql.length(), flags, &stmt, &tail); if(SQLITE_OK != err){ zerr("%s", sqlite3_errstr(err)); return ZEFAIL; }else{ zinf("prepare: %s", sql.c_str()); } return ZEOK; } /** * @brief Called one or more times to evaluate the statement. * @pre sqlite3_prepare() */ int Step(){ return sqlite3_step(stmt); #if 0 switch(ret){ case SQLITE_BUSY: return ZEAGAIN; case SQLITE_DONE: return ZEOK; case SQLITE_ROW: return ZE_EXIST; case SQLITE_ERROR: zerr("%s", sqlite3_errmsg(db)); return ZEFAIL; case SQLITE_MISUSE: return ZESTATUS_INVALID; default: return ZEFAIL; } return ZEFAIL; #endif } const void *GetBlob(int column, int *len){ const void *ret = sqlite3_column_blob(stmt, column); *len = sqlite3_column_bytes(stmt, column); return ret; } double GetDouble(int column){return sqlite3_column_double(stmt, column);} sqlite3_int64 GetInt64(int column){return sqlite3_column_int64(stmt, column);} const unsigned char *GetText(int column, int *len){ const unsigned char* text = sqlite3_column_text(stmt, column); *len = sqlite3_column_bytes(stmt, column); return text; } const void *GetText16(int column, int *len){ const void *text = sqlite3_column_text16(stmt, column); *len = sqlite3_column_bytes16(stmt, column); return text; } sqlite3_value *GetValue(int column){return sqlite3_column_value(stmt, column);} /* * Binding Parameters and Reusing Prepared Statements * Parameter forms: * ? * ?<int> * :<identifier> * $<identifier> * @<identifier> */ /** * @brief Reset statement object back to its initial state. * * @par Does not change the values of any bindings on the prepared statment */ zerr_t Reset(){ return SQLITE_OK == sqlite3_reset(stmt) ? ZEOK : ZEFAIL; } /** * @brief Binding values to prepared statements. * @param idx [in] index of parameter, the leftmost has index of 1. * @param data [in] value to bind to the parameter * @param fn [in] dispose of data; SQLITE_STATIC/SQLITE_TRANSIENT * @par sqlite3_clear_bindings() to reset the binding * */ zerr_t Bind(int idx, double data){ zerr_t ret = SQLITE_OK == sqlite3_bind_double(stmt, idx, data) ? ZEOK : ZEFAIL; if(ZEFAIL == ret){ zerr("%s", sqlite3_errmsg(db)); } return ret; } zerr_t Bind(int idx, int data){ zerr_t ret = SQLITE_OK == sqlite3_bind_int(stmt, idx, data) ? ZEOK : ZEFAIL; if(ZEFAIL == ret){ zerr("%s", sqlite3_errmsg(db)); } return ret; } zerr_t Bind(int idx, sqlite3_int64 data){ zerr_t ret = SQLITE_OK == sqlite3_bind_int64(stmt, idx, data) ? ZEOK : ZEFAIL; if(ZEFAIL == ret){ zerr("%s", sqlite3_errmsg(db)); } return ret; } zerr_t Bind(int idx){ zerr_t ret = SQLITE_OK == sqlite3_bind_null(stmt, idx) ? ZEOK : ZEFAIL; if(ZEFAIL == ret){ zerr("%s", sqlite3_errmsg(db)); } return ret; } zerr_t Bind(int idx, const sqlite3_value *data){ zerr_t ret = SQLITE_OK == sqlite3_bind_value(stmt, idx, data) ? ZEOK : ZEFAIL; if(ZEFAIL == ret){ zerr("%s", sqlite3_errmsg(db)); } return ret; } zerr_t BindBlob(int idx, const void *data, int n, void(*fn)(void*)){ zerr_t ret = SQLITE_OK == sqlite3_bind_blob(stmt, idx, data, n, fn) ? ZEOK : ZEFAIL; if(ZEFAIL == ret){ zerr("%s", sqlite3_errmsg(db)); } return ret; } zerr_t BindBlob64(int idx, const void *data, sqlite3_uint64 n, void(*fn)(void*)){ zerr_t ret = SQLITE_OK == sqlite3_bind_blob64(stmt, idx, data, n, fn) ? ZEOK : ZEFAIL; if(ZEFAIL == ret){ zerr("%s", sqlite3_errmsg(db)); } return ret; } zerr_t BindText(int idx, const char *data, int len, void(*fn)(void*)){ zerr_t ret = SQLITE_OK == sqlite3_bind_text(stmt, idx, data, len, fn) ? ZEOK : ZEFAIL; if(ZEFAIL == ret){ zerr("%s", sqlite3_errmsg(db)); } return ret; } zerr_t BindText16(int idx, const char *data, int len, void(*fn)(void*)){ zerr_t ret = SQLITE_OK == sqlite3_bind_text16(stmt, idx, data, len, fn) ? ZEOK : ZEFAIL; if(ZEFAIL == ret){ zerr("%s", sqlite3_errmsg(db)); } return ret; } zerr_t BindText64(int idx, const char *data, sqlite3_uint64 len, void(*fn)(void*), unsigned char encoding = SQLITE_UTF8){ zerr_t ret = SQLITE_OK == sqlite3_bind_text64(stmt, idx, data, len, fn, encoding)\ ? ZEOK : ZEFAIL; if(ZEFAIL == ret){ zerr("%s", sqlite3_errmsg(db)); } return ret; } zerr_t BindPointer(int idx, void *data, const char *pc, void(*fn)(void*)){ zerr_t ret = SQLITE_OK == sqlite3_bind_pointer(stmt, idx, data, pc, fn) ? ZEOK : ZEFAIL; if(ZEFAIL == ret){ zerr("%s", sqlite3_errmsg(db)); } return ret; } zerr_t BindZeroBlob(int idx, int data){ zerr_t ret = SQLITE_OK == sqlite3_bind_zeroblob(stmt, idx, data) ? ZEOK : ZEFAIL; if(ZEFAIL == ret){ zerr("%s", sqlite3_errmsg(db)); } return ret; } zerr_t BindZeroBlob64(int idx, sqlite3_uint64 data){ zerr_t ret = SQLITE_OK == sqlite3_bind_zeroblob64(stmt, idx, data) ? ZEOK : ZEFAIL; if(ZEFAIL == ret){ zerr("%s", sqlite3_errmsg(db)); } return ret; } }; NSE_Z #endif /*_ZPP_SQLITE3_H_*/
30.836735
96
0.58383
[ "object" ]
5ee0e9ac845794795f2316f728d6c3a052433f08
2,524
h
C
include/GameSettings.h
abelidze/roguelite-game
2b4385b54d237c12f068a5287bea61b8b1379f1b
[ "MIT" ]
null
null
null
include/GameSettings.h
abelidze/roguelite-game
2b4385b54d237c12f068a5287bea61b8b1379f1b
[ "MIT" ]
null
null
null
include/GameSettings.h
abelidze/roguelite-game
2b4385b54d237c12f068a5287bea61b8b1379f1b
[ "MIT" ]
null
null
null
#pragma once #include <ctime> #include <thread> #include <chrono> #include <memory> #include <string> #include <vector> #include <cstdint> #include <fstream> #include <iostream> #include <typeinfo> #include <type_traits> #include <unordered_map> #include <stdexcept> #include "curses.h" /** * Ultra-magic creation of Gods#1 */ #define EXTENDED_INHERITANCE_DECLARE() \ public: \ static const std::size_t TypeHash; \ virtual bool IsClassType(const std::size_t) const; \ /** * Ultra-magic creation of Gods#2 */ #define EXTENDED_INHERITANCE_DEFINITION(ChildClass, ParentClass) \ const std::size_t ChildClass::TypeHash = typeid(ChildClass).hash_code(); \ bool ChildClass::IsClassType(const std::size_t classType) const \ { \ if (classType == ChildClass::TypeHash) \ return true; \ if (std::is_same<ChildClass, ParentClass>::value) \ return false; \ return ParentClass::IsClassType(classType); \ } \ /** * Compilation time constants */ namespace engine { const int DEFAULT_ROOM_SEED = 2147483648; const int ROOM_SHIFT_X = 1; const int ROOM_SHIFT_Y = 65536; const char WALL_SYMBOL = '#'; const char FLOOR_SYMBOL = '.'; const char KNIGHT_SYMBOL = 'K'; const char ZOMBIE_SYMBOL = 'Z'; const char DRAGON_SYMBOL = 'D'; const char CASTER_SYMBOL = 'X'; const char PRINCESS_SYMBOL = 'P'; const char PROJECTILE_SYMBOL = '*'; const char HEALING_SYMBOL = '+'; } // namespace engine namespace game { const int UPDATE_TIME = 350; const int WINDOW_W = 120; const int WINDOW_H = 50; } // namespace game /** * Typedef and co. */ typedef uint32_t seed_t; template<class T> using TWContainer = std::vector< std::weak_ptr<T> >; template<class T> using TSContainer = std::vector< std::shared_ptr<T> >; template<class T> using TUContainer = std::vector< std::unique_ptr<T> >; template<class T> using TContainer = std::vector<T>; template<typename Key, class T> using TSMap = std::unordered_map< Key, std::shared_ptr<T> >; template<typename Key, class T> using TMap = std::unordered_map< Key, T >;
26.291667
74
0.571712
[ "vector" ]
5ee7621fb9c97d40a7a1df00900f73b70cc30a32
677
h
C
model/blockchains/CBHash.h
nwtechguy/toolbox
a981ee6b371e92f1b18f11170e1c089b7c7f1364
[ "MIT" ]
30
2019-12-20T06:02:21.000Z
2021-09-13T20:25:41.000Z
model/blockchains/CBHash.h
nwtechguy/toolbox
a981ee6b371e92f1b18f11170e1c089b7c7f1364
[ "MIT" ]
5
2020-02-20T21:12:56.000Z
2021-09-19T07:43:39.000Z
model/blockchains/CBHash.h
nwtechguy/toolbox
a981ee6b371e92f1b18f11170e1c089b7c7f1364
[ "MIT" ]
11
2019-12-20T06:02:25.000Z
2022-03-26T07:53:34.000Z
/* * * Crypto.BI Toolbox * https://Crypto.BI/ * * Author: José Fonseca (https://zefonseca.com/) * * Distributed under the MIT software license, see the accompanying * file COPYING or http://www.opensource.org/licenses/mit-license.php. * */ #ifndef MODEL_CBHASH_H_ #define MODEL_CBHASH_H_ #include <uint256.h> #include <memory> namespace model::blockchains { class CBHash { uint256 *_hash; public: CBHash(); CBHash(uint256 * h): _hash(h){ } virtual ~CBHash(); const uint256 * getHash() const { return _hash; } void setHash(uint256 * hash) { _hash = hash; } void setHash(uint256 hash) { *_hash = hash; } }; } #endif /* MODEL_CBHASH_H_ */
13.54
70
0.666174
[ "model" ]
5ef26166cdd0a0a43e00f3f3dee0d6a038eaf05a
5,729
c
C
vic/drivers/image/src/vic_image.c
lingyunan0510/VIC
dbc00a813b5df5a88027d1dc57a7805e9a464436
[ "MIT" ]
1
2022-01-18T01:23:47.000Z
2022-01-18T01:23:47.000Z
vic/drivers/image/src/vic_image.c
yusheng-wang/VIC
8f6cc0661bdc67c4f6caabdd4dcd0b8782517435
[ "MIT" ]
null
null
null
vic/drivers/image/src/vic_image.c
yusheng-wang/VIC
8f6cc0661bdc67c4f6caabdd4dcd0b8782517435
[ "MIT" ]
null
null
null
/****************************************************************************** * @section DESCRIPTION * * Stand-alone image mode driver of the VIC model *****************************************************************************/ #include <vic_driver_image.h> #include <rout.h> // Routing routine (extension) size_t NF, NR; size_t current; size_t *filter_active_cells = NULL; size_t *mpi_map_mapping_array = NULL; all_vars_struct *all_vars = NULL; force_data_struct *force = NULL; dmy_struct *dmy = NULL; dmy_struct dmy_state; filenames_struct filenames; filep_struct filep; domain_struct global_domain; global_param_struct global_param; lake_con_struct *lake_con = NULL; domain_struct local_domain; MPI_Comm MPI_COMM_VIC = MPI_COMM_WORLD; MPI_Datatype mpi_global_struct_type; MPI_Datatype mpi_filenames_struct_type; MPI_Datatype mpi_location_struct_type; MPI_Datatype mpi_alarm_struct_type; MPI_Datatype mpi_option_struct_type; MPI_Datatype mpi_param_struct_type; int *mpi_map_local_array_sizes = NULL; int *mpi_map_global_array_offsets = NULL; int mpi_rank; int mpi_size; option_struct options; parameters_struct param; param_set_struct param_set; soil_con_struct *soil_con = NULL; veg_con_map_struct *veg_con_map = NULL; veg_con_struct **veg_con = NULL; veg_hist_struct **veg_hist = NULL; veg_lib_struct **veg_lib = NULL; metadata_struct state_metadata[N_STATE_VARS + N_STATE_VARS_EXT]; metadata_struct out_metadata[N_OUTVAR_TYPES]; save_data_struct *save_data; // [ncells] double ***out_data = NULL; // [ncells, nvars, nelem] stream_struct *output_streams = NULL; // [nstreams] nc_file_struct *nc_hist_files = NULL; // [nstreams] // Extensions rout_struct rout; // Routing routine (extension) /****************************************************************************** * @brief Stand-alone image mode driver of the VIC model * @details The image mode driver runs VIC for a single timestep for all grid * cells before moving on to the next timestep. * * @param argc Argument count * @param argv Argument vector *****************************************************************************/ int main(int argc, char **argv) { int status; timer_struct global_timers[N_TIMERS]; char state_filename[MAXSTRING]; // start vic all timer timer_start(&(global_timers[TIMER_VIC_ALL])); // start vic init timer timer_start(&(global_timers[TIMER_VIC_INIT])); // Initialize MPI - note: logging not yet initialized status = MPI_Init(&argc, &argv); if (status != MPI_SUCCESS) { fprintf(stderr, "MPI error in main(): %d\n", status); exit(EXIT_FAILURE); } // Initialize Log Destination initialize_log(); // initialize mpi initialize_mpi(); // process command line arguments if (mpi_rank == VIC_MPI_ROOT) { cmd_proc(argc, argv, filenames.global); } // read global parameters vic_image_start(); // allocate memory vic_alloc(); // allocate memory for routing rout_alloc(); // Routing routine (extension) // initialize model parameters from parameter files vic_image_init(); // initialize routing parameters from parameter files rout_init(); // Routing routine (extension) // populate model state, either using a cold start or from a restart file vic_populate_model_state(&(dmy[0])); // initialize output structures vic_init_output(&(dmy[0])); // Initialization is complete, print settings log_info( "Initialization is complete, print global param, parameters and options structures"); print_global_param(&global_param); print_option(&options); print_parameters(&param); // stop init timer timer_stop(&(global_timers[TIMER_VIC_INIT])); // start vic run timer timer_start(&(global_timers[TIMER_VIC_RUN])); // loop over all timesteps for (current = 0; current < global_param.nrecs; current++) { // read forcing data timer_continue(&(global_timers[TIMER_VIC_FORCE])); vic_force(); timer_stop(&(global_timers[TIMER_VIC_FORCE])); // run vic over the domain vic_image_run(&(dmy[current])); // Write history files timer_continue(&(global_timers[TIMER_VIC_WRITE])); vic_write_output(&(dmy[current])); timer_stop(&(global_timers[TIMER_VIC_WRITE])); // Write state file if (check_save_state_flag(current, &dmy_state)) { debug("writing state file for timestep %zu", current); vic_store(&dmy_state, state_filename); debug("finished storing state file: %s", state_filename) } } // stop vic run timer timer_stop(&(global_timers[TIMER_VIC_RUN])); // start vic final timer timer_start(&(global_timers[TIMER_VIC_FINAL])); // clean up vic_image_finalize(); // clean up routing rout_finalize(); // Routing routine (extension) // finalize MPI status = MPI_Finalize(); if (status != MPI_SUCCESS) { log_err("MPI error: %d", status); } log_info("Completed running VIC %s", VIC_DRIVER); // stop vic final timer timer_stop(&(global_timers[TIMER_VIC_FINAL])); // stop vic all timer timer_stop(&(global_timers[TIMER_VIC_ALL])); if (mpi_rank == VIC_MPI_ROOT) { // write timing info write_vic_timing_table(global_timers, VIC_DRIVER); } return EXIT_SUCCESS; }
32.367232
93
0.626113
[ "vector", "model" ]
5ef9bcb94581653c2e9a4392eb32b55700ea5402
1,507
h
C
SDL/gui.h
gameblabla/SameBoy
50304a8d95bc062700963d0a8812a6d5da4a1618
[ "MIT" ]
null
null
null
SDL/gui.h
gameblabla/SameBoy
50304a8d95bc062700963d0a8812a6d5da4a1618
[ "MIT" ]
null
null
null
SDL/gui.h
gameblabla/SameBoy
50304a8d95bc062700963d0a8812a6d5da4a1618
[ "MIT" ]
null
null
null
#ifndef gui_h #define gui_h #include <SDL/SDL.h> #include <Core/gb.h> #include <stdbool.h> #define JOYSTICK_HIGH 0x4000 #define JOYSTICK_LOW 0x3800 extern GB_gameboy_t gb; /* extern SDL_Window *window; extern SDL_Renderer *renderer; extern SDL_Texture *texture; extern SDL_PixelFormat *pixel_format; */ extern SDL_Surface* screen; enum scaling_mode { GB_SDL_SCALING_ENTIRE_WINDOW, GB_SDL_SCALING_KEEP_RATIO, GB_SDL_SCALING_INTEGER_FACTOR, GB_SDL_SCALING_MAX, }; enum pending_command { GB_SDL_NO_COMMAND, GB_SDL_SAVE_STATE_COMMAND, GB_SDL_LOAD_STATE_COMMAND, GB_SDL_RESET_COMMAND, GB_SDL_NEW_FILE_COMMAND, GB_SDL_QUIT_COMMAND, }; extern enum pending_command pending_command; extern unsigned command_parameter; typedef struct { int keys[9]; GB_color_correction_mode_t color_correction_mode; enum scaling_mode scaling_mode; bool blend_frames; GB_highpass_mode_t highpass_mode; bool _deprecated_div_joystick; bool _deprecated_flip_joystick_bit_1; bool _deprecated_swap_joysticks_bits_1_and_2; char filter[32]; enum { MODEL_DMG, MODEL_CGB, MODEL_AGB, MODEL_MAX, } model; /* v0.11 */ uint32_t rewind_length; int keys_2[32]; /* Rewind and underclock, + padding for the future */ } configuration_t; extern configuration_t configuration; void update_viewport(void); void run_gui(bool is_running); void render_texture(void *pixels, void *previous); #endif
20.643836
73
0.742535
[ "model" ]
5efa797ce47b97c7ecbe69f7cf719ba395205cfa
1,884
h
C
src/antler.h
cbpark/MAT
4f63e50269a6a557bf35a2de16e858b6fef76efc
[ "BSD-3-Clause" ]
1
2020-06-01T15:39:11.000Z
2020-06-01T15:39:11.000Z
src/antler.h
cbpark/MAT
4f63e50269a6a557bf35a2de16e858b6fef76efc
[ "BSD-3-Clause" ]
null
null
null
src/antler.h
cbpark/MAT
4f63e50269a6a557bf35a2de16e858b6fef76efc
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 2020 Chan Beom Park <cbpark@gmail.com> */ #ifndef MAT_SRC_ANTLER_H_ #define MAT_SRC_ANTLER_H_ #include <vector> #include "momentum.h" namespace mat { /** * @param q the four-momentum of the resonance. * @param p1 the four-momentum of the first visible particle. * @param p2 the four-momentum of the second visible particle. * @param mA the mass of the intermediate particle. * @param mB the mass of the invisible particle in the final state. */ double deltaAT(const FourMomentum &q, const FourMomentum &p1, const FourMomentum &p2, const Mass &mA, const Mass &mB); /** * @param p1 the four-momentum of the first visible particle. * @param p2 the four-momentum of the second visible particle. * @param metx the x component of the missing transverse energy. * @param mety the y component of the missing transverse energy. * @param qz a guess value for the longitudinal momentum of the resonance. * @param mA the mass of the intermediate particle. * @param mB the mass of the invisible particle in the final state. */ std::vector<double> mAT(const FourMomentum &p1, const FourMomentum &p2, double metx, double mety, double qz, const Mass &mA, const Mass &mB); /** * @param p1 the four-momentum of the first visible particle. * @param p2 the four-momentum of the second visible particle. * @param metx the x component of the missing transverse energy. * @param mety the y component of the missing transverse energy. * @param mA the mass of the intermediate particle. * @param mB the mass of the invisible particle in the final state. */ std::vector<double> mATmaos(const FourMomentum &p1, const FourMomentum &p2, double metx, double mety, const Mass &mA, const Mass &mB); } // namespace mat #endif // MAT_SRC_ANTLER_H_
38.44898
76
0.694268
[ "vector" ]
5efaf5f45cdb94fc47bd10afdaef5f7f2cdf2ff7
2,427
h
C
Tile.h
Boyko03/snow
8218d57fa8f01854d2c8aec9d98eb222846db5f7
[ "MIT" ]
null
null
null
Tile.h
Boyko03/snow
8218d57fa8f01854d2c8aec9d98eb222846db5f7
[ "MIT" ]
null
null
null
Tile.h
Boyko03/snow
8218d57fa8f01854d2c8aec9d98eb222846db5f7
[ "MIT" ]
null
null
null
#pragma once #include <utility> #include <map> #include "surface.h" #include "BoxCollider.h" constexpr int TILE = 32; class Tile { public: /// <summary> /// Terrain types /// </summary> enum class Terrains_t { Snow, FinishLine, Ice, Gravel, CobbleStone }; /// <summary> /// Object types /// </summary> enum class Objects_t { None, Tree, Rock, Log, Bush, Sign, // Not used yet // Not Randomly Generated TopOfTree, TwoTrees, // (Powerup) Offroad map only Heart, Shield, // Normal map only BlueFlag, RedFlag, // Border trees Pine1, Pine2, WinterTree }; /// <summary> /// Use tile factory. (Uses terrain and object) /// </summary> /// <param name="ox">- Object X from tilemap</param> /// <param name="oy">- Object Y from tilemap</param> /// <param name="cx">- Collision center X</param> /// <param name="cy">- Collision bottom Y</param> /// <param name="dx">- Collision delta X</param> /// <param name="dy">- Collision delta Y</param> /// <param name="object">- Object</param> /// <param name="terrain">- Terrain</param> /// <param name="tile_width">- tile width, default: TILE</param> /// <param name="tile_height">- tile height, default: TILE</param> Tile(int ox, int oy, BoxCollider collider, Objects_t object, Terrains_t terrain, int tile_width=TILE, int tile_height=TILE); int ox, oy; // x, y in tileset BoxCollider collider; static std::map<Terrains_t, std::pair<int, int>> terrains; Terrains_t terrain; Objects_t object; private: static Tmpl8::Surface tiles; // tilemap static int t_width; // tilemap width int tile_width, tile_height; // Can be different from TILE public: // Draw background only void DrawBackground(int x, int y, Tmpl8::Surface& screen); // Draw foreground only void DrawForegound(int x, int y, Tmpl8::Surface& screen); // Draw object only void DrawObjectOnly(int x, int y, Tmpl8::Surface& screen); private: /// <summary> /// Draw tile on screen /// </summary> /// <param name="tx">- tilemap X</param> /// <param name="ty">- tilemap Y</param> /// <param name="screen">- surface to draw tile on to</param> /// <param name="x">- screen X</param> /// <param name="y">- screen Y</param> /// <param name="is_object">- if tile is object uses tile_width and tile_height else default TILE size</param> void DrawTile(int tx, int ty, Tmpl8::Surface& screen, int x, int y, bool is_object=false); };
23.794118
125
0.65925
[ "object" ]
6f0535aefeeddfd7cf883f5e0d8ea9a71b93967d
1,172
h
C
ui/base/ime/grammar_fragment.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
14,668
2015-01-01T01:57:10.000Z
2022-03-31T23:33:32.000Z
ui/base/ime/grammar_fragment.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
86
2015-10-21T13:02:42.000Z
2022-03-14T07:50:50.000Z
ui/base/ime/grammar_fragment.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
5,941
2015-01-02T11:32:21.000Z
2022-03-31T16:35:46.000Z
// Copyright (c) 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_BASE_IME_GRAMMAR_FRAGMENT_H_ #define UI_BASE_IME_GRAMMAR_FRAGMENT_H_ #include <string> #include "base/component_export.h" #include "ui/gfx/range/range.h" namespace ui { // A struct represents a fragment of grammar edit suggestion. struct COMPONENT_EXPORT(UI_BASE_IME_TYPES) GrammarFragment { GrammarFragment(const gfx::Range& range, const std::string& suggestion, const std::string& original_text = std::string()); GrammarFragment(const GrammarFragment& other); ~GrammarFragment(); bool operator==(const GrammarFragment& other) const; bool operator!=(const GrammarFragment& other) const; // The range of the marker, visual indications such as underlining are // expected to show in this range. gfx::Range range; // The replacement text suggested by the grammar model. std::string suggestion; // The original text to be replaced. std::string original_text; }; } // namespace ui #endif // UI_BASE_IME_GRAMMAR_FRAGMENT_H_
29.3
73
0.736348
[ "model" ]
6f065d6c0a1f1e03ab8a15d32614b3dab367ac11
1,128
h
C
shared_include/image/segmentation/LandmarkSegmentation.h
ahewer/mri-shape-tools
4268499948f1330b983ffcdb43df62e38ca45079
[ "MIT" ]
null
null
null
shared_include/image/segmentation/LandmarkSegmentation.h
ahewer/mri-shape-tools
4268499948f1330b983ffcdb43df62e38ca45079
[ "MIT" ]
2
2017-05-29T09:43:01.000Z
2017-05-29T09:50:05.000Z
shared_include/image/segmentation/LandmarkSegmentation.h
ahewer/mri-shape-tools
4268499948f1330b983ffcdb43df62e38ca45079
[ "MIT" ]
4
2017-05-17T11:56:02.000Z
2022-03-05T09:12:24.000Z
#ifndef __LANDMARK_SEGMENTATION_H__ #define __LANDMARK_SEGMENTATION_H__ #include <armadillo> #include "image/ImageAccess.h" #include "image/ImageData.h" #include "image/ImageBoundary.h" #include "image/segmentation/Threshold.h" class LandmarkSegmentation{ private: ImageData& imageData; const std::vector<arma::vec> landmarks; public: LandmarkSegmentation( ImageData& imageData, const std::vector<arma::vec>& landmarks ) : imageData(imageData), landmarks(landmarks) { ImageValues imageValues(this->imageData); imageValues.scale(0, 255); imageValues.round(); } void apply() { const double bestThreshold = find_threshold(); Threshold(this->imageData, bestThreshold).apply(); } double find_threshold() { ImageAccess access(this->imageData); double threshold = 255; for(const arma::vec& landmark: this->landmarks) { const double& currentColor = access.at_grid(landmark(0), landmark(1), landmark(2)); threshold = (currentColor < threshold )? currentColor: threshold; } return threshold; } }; #endif
18.8
89
0.68617
[ "vector" ]
6f06784fe12673f8b4983be151ab7e9c9392a53d
426
h
C
2M3/Include/Common/Systems/BulletSystem.h
simatic/MultiplayerLab
f483a80882f32249923c4fbcc876cfdca2b7da10
[ "MIT" ]
null
null
null
2M3/Include/Common/Systems/BulletSystem.h
simatic/MultiplayerLab
f483a80882f32249923c4fbcc876cfdca2b7da10
[ "MIT" ]
45
2020-10-08T13:32:36.000Z
2020-12-17T14:41:40.000Z
2M3/Include/Common/Systems/BulletSystem.h
simatic/MultiplayerLab
f483a80882f32249923c4fbcc876cfdca2b7da10
[ "MIT" ]
3
2020-10-02T09:02:20.000Z
2020-11-07T00:14:13.000Z
#pragma once #include "Common/Systems/System.h" #include "Common/Components/Transform.h" #include "Common/Components/Kinematics.h" #include "Common/Components/Bullet.h" /** * @class BulletSystem * Handles bullets movement and lifetime. */ class BulletSystem : public LogicSystem<Transform, Kinematics, Bullet> { public: explicit BulletSystem(GameManager* const gameManager); void update(const sf::Time& dt) override; };
25.058824
70
0.767606
[ "transform" ]
1cfae66c38dab9b045259eed27b4a4437beb39cd
1,046
h
C
Source/Dibella/Inc/Samplers/Sampler.h
vasumahesh1/azura
80aa23e2fb498e6288484bc49b0d5b8889db6ebb
[ "MIT" ]
12
2019-01-08T23:10:37.000Z
2021-06-04T09:48:42.000Z
Source/Dibella/Inc/Samplers/Sampler.h
vasumahesh1/azura
80aa23e2fb498e6288484bc49b0d5b8889db6ebb
[ "MIT" ]
38
2017-04-05T00:27:24.000Z
2018-12-25T08:34:04.000Z
Source/Dibella/Inc/Samplers/Sampler.h
vasumahesh1/azura
80aa23e2fb498e6288484bc49b0d5b8889db6ebb
[ "MIT" ]
4
2019-03-27T10:07:32.000Z
2021-07-15T03:22:27.000Z
#pragma once #include <cinttypes> #include "../Core/Types.h" namespace Dibella { class Sampler { public: // Sampler Interface virtual ~Sampler(); explicit Sampler(U64 samplesPerPixel); virtual Float Get1D() = 0; virtual Point2f Get2D() = 0; virtual std::unique_ptr<Sampler> Clone(int seed) = 0; virtual bool SetSampleNumber(U64 sampleNum); std::string StateString() const { return StringPrintf("(%d,%d), sample %" PRId64, currentPixel.x, currentPixel.y, currentPixelSampleIndex); } U64 CurrentSampleNumber() const { return currentPixelSampleIndex; } // Sampler Public Data const U64 samplesPerPixel; protected: // Sampler Protected Data Point2i currentPixel; U64 currentPixelSampleIndex; std::vector<int> samples1DArraySizes, samples2DArraySizes; std::vector<std::vector<Float>> sampleArray1D; std::vector<std::vector<Point2f>> sampleArray2D; private: // Sampler Private Data size_t array1DOffset, array2DOffset; }; } // namespace Dibella
24.325581
110
0.696941
[ "vector" ]
1cfcf4fe77bcbbf7e8eade83cc6679032ede0ccc
2,771
h
C
shaka/src/js/mse/text_track.h
jgongo/shaka-player-embedded
e04f97b971c684ef18a370697584d5239fb711bd
[ "Apache-2.0", "BSD-3-Clause" ]
185
2018-11-06T06:04:44.000Z
2022-03-02T22:20:39.000Z
shaka/src/js/mse/text_track.h
jgongo/shaka-player-embedded
e04f97b971c684ef18a370697584d5239fb711bd
[ "Apache-2.0", "BSD-3-Clause" ]
211
2018-11-15T22:52:49.000Z
2022-03-02T18:46:20.000Z
shaka/src/js/mse/text_track.h
jgongo/shaka-player-embedded
e04f97b971c684ef18a370697584d5239fb711bd
[ "Apache-2.0", "BSD-3-Clause" ]
52
2018-12-12T11:00:46.000Z
2022-02-23T17:35:02.000Z
// Copyright 2016 Google LLC // // 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 // // https://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 SHAKA_EMBEDDED_JS_MSE_TEXT_TRACK_H_ #define SHAKA_EMBEDDED_JS_MSE_TEXT_TRACK_H_ #include <memory> #include <string> #include <unordered_map> #include <vector> #include "shaka/media/text_track.h" #include "shaka/media/vtt_cue.h" #include "src/core/member.h" #include "src/core/ref_ptr.h" #include "src/js/events/event_target.h" #include "src/js/vtt_cue.h" #include "src/mapping/backing_object.h" #include "src/mapping/backing_object_factory.h" namespace shaka { namespace js { namespace mse { class HTMLMediaElement; class TextTrack : public events::EventTarget, shaka::media::TextTrack::Client { DECLARE_TYPE_INFO(TextTrack); public: explicit TextTrack(std::shared_ptr<shaka::media::TextTrack> track); void Trace(memory::HeapTracer* tracer) const override; const media::TextTrackKind kind; const std::string label; const std::string language; const std::string id; std::vector<RefPtr<VTTCue>> cues() const; media::TextTrackMode mode() const; void SetMode(media::TextTrackMode mode); // Technically this should accept a TextTrackCue, but we don't distinguish // between the types. void AddCue(RefPtr<VTTCue> cue); void RemoveCue(RefPtr<VTTCue> cue); private: void OnCueAdded(std::shared_ptr<shaka::media::VTTCue> cue) override; void OnCueRemoved(std::shared_ptr<shaka::media::VTTCue> cue) override; mutable Mutex mutex_; std::unordered_map<shaka::media::VTTCue*, Member<VTTCue>> cues_; std::shared_ptr<shaka::media::TextTrack> track_; }; class TextTrackFactory : public BackingObjectFactory<TextTrack, events::EventTarget> { public: TextTrackFactory(); }; } // namespace mse } // namespace js } // namespace shaka DEFINE_ENUM_MAPPING(shaka::media, TextTrackKind) { AddMapping(Enum::Subtitles, "subtitles"); AddMapping(Enum::Captions, "captions"); AddMapping(Enum::Descriptions, "descriptions"); AddMapping(Enum::Chapters, "chapters"); AddMapping(Enum::Metadata, "metadata"); } DEFINE_ENUM_MAPPING(shaka::media, TextTrackMode) { AddMapping(Enum::Disabled, "disabled"); AddMapping(Enum::Hidden, "hidden"); AddMapping(Enum::Showing, "showing"); } #endif // SHAKA_EMBEDDED_JS_MSE_TEXT_TRACK_H_
29.168421
79
0.748105
[ "vector" ]
e82032b05472e76dc7ab4ed8bcad632b890043bc
4,984
h
C
xdl/xdl/core/framework/op_kernel.h
Ru-Xiang/x-deeplearning
04cc0497150920c64b06bb8c314ef89977a3427a
[ "Apache-2.0" ]
4,071
2018-12-13T04:17:38.000Z
2022-03-30T03:29:35.000Z
xdl/xdl/core/framework/op_kernel.h
laozhuang727/x-deeplearning
781545783a4e2bbbda48fc64318fb2c6d8bbb3cc
[ "Apache-2.0" ]
359
2018-12-21T01:14:57.000Z
2022-02-15T07:18:02.000Z
xdl/xdl/core/framework/op_kernel.h
laozhuang727/x-deeplearning
781545783a4e2bbbda48fc64318fb2c6d8bbb3cc
[ "Apache-2.0" ]
1,054
2018-12-20T09:57:42.000Z
2022-03-29T07:16:53.000Z
/* Copyright (C) 2016-2018 Alibaba Group Holding Limited Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #ifndef XDL_CORE_FRAMEWORK_OP_KERNEL_H_ #define XDL_CORE_FRAMEWORK_OP_KERNEL_H_ #include <functional> #include <string> #include <vector> #include <unordered_map> #include "xdl/core/lib/status.h" #include "xdl/core/framework/device.h" #include "xdl/core/framework/tensor.h" #include "xdl/core/framework/graph_def.h" #include "xdl/core/framework/run_option.h" namespace xdl { struct OpKernelConstruction; struct OpKernelContext; class SimpleExecutor; class OpKernelBase { public: using Callback = std::function<void(Status)>; virtual ~OpKernelBase() {} virtual Status Init(OpKernelConstruction* ctx); virtual void Launch(OpKernelContext* ctx) = 0; }; class OpKernel : public OpKernelBase { public: void Launch(OpKernelContext* ctx) override; virtual Status Compute(OpKernelContext* ctx) = 0; }; class OpKernelAsync : public OpKernelBase { public: void Launch(OpKernelContext* ctx) override; virtual void Compute(OpKernelContext* ctx, Callback done) = 0; }; class OpKernelConstruction { public: explicit OpKernelConstruction( const std::unordered_map<std::string, AttrValue>& attr, Device* device) : attr_(attr), device_(device) {} Status GetAttr(const std::string& name, int64_t* i); Status GetAttr(const std::string& name, float* f); Status GetAttr(const std::string& name, bool* b); Status GetAttr(const std::string& name, std::string* s); Status GetAttr(const std::string& name, DataType* type); Status GetAttr(const std::string& name, TensorShape* shape); Status GetAttr(const std::string& name, std::vector<DataType>* type_list); Device* GetDevice(); private: std::unordered_map<std::string, AttrValue> attr_; Device* device_; }; struct OpKernelContextArg { Device* device; std::vector<Device*> input_devices; std::vector<std::string> input_name; std::vector<DataType> input_type; std::unordered_map<std::string, int> input_id; std::unordered_map<std::string, std::vector<int>> input_list_id; std::vector<std::string> output_name; std::vector<DataType> output_type; std::unordered_map<std::string, int> output_id; std::unordered_map<std::string, std::vector<int>> output_list_id; }; class OpKernelContext : public RefCounted { public: OpKernelContext(OpKernelContextArg* arg, SimpleExecutor* executor, const std::vector<Tensor>& input); OpKernelContext(OpKernelContextArg* arg, SimpleExecutor* executor, std::vector<Tensor>&& input); Status GetInput(size_t id, Tensor* tensor); Status GetInput(const std::string& name, Tensor* tensor); Status GetInputList(const std::string& name, std::vector<Tensor>* tensor_list); Status Allocate(const TensorShape& shape, DataType type, Tensor* tensor); Status AllocateOutput(size_t id, const TensorShape& shape, Tensor* tensor); Status AllocateOutput(const std::string& name, const TensorShape& shape, Tensor* tensor); Status SetOutput(size_t id, const Tensor& tensor); Status SetOutput(const std::string& name, const Tensor& tensor); Status SetOutputList(const std::string& name, const std::vector<Tensor>& tensor_list); void AddDoneHandler(std::function<void(Status)> handler); Device* GetDevice(); void LaunchDone(Status st); void RunDone(Status st); const RunOption& GetRunOption(); void SetLaunchDone(OpKernelBase::Callback launch_done); void SetRunDone(OpKernelBase::Callback run_done); const std::vector<Tensor>& GetOutputs() const { return output_; } private: OpKernelContextArg* arg_; SimpleExecutor* executor_; OpKernelBase::Callback launch_done_; OpKernelBase::Callback run_done_; std::vector<Tensor> allocated_; std::vector<Tensor> input_; std::vector<Tensor> output_; }; #define OP_REQUIRES_OK_ASYNC(CTX, STATUS, CALLBACK) \ do { \ xdl::Status _s_(STATUS); \ if (!_s_.IsOk()) { \ CALLBACK(_s_); \ return; \ } \ } while (0) \ } // namespace xdl #endif // XDL_CORE_FRAMEWORK_OP_KERNEL_H_
33.904762
80
0.673957
[ "shape", "vector" ]
e839a98d2bb43ff311734a9d05169bca5fffea98
3,402
h
C
src/AGC/AGCOrientation.h
FreeAllegiance/AllegianceDX7
3955756dffea8e7e31d3a55fcf6184232b792195
[ "MIT" ]
76
2015-08-18T19:18:40.000Z
2022-01-08T12:47:22.000Z
src/AGC/AGCOrientation.h
StudentAlleg/Allegiance
e91660a471eb4e57e9cea4c743ad43a82f8c7b18
[ "MIT" ]
37
2015-08-14T22:44:12.000Z
2020-01-21T01:03:06.000Z
src/AGC/AGCOrientation.h
FreeAllegiance/Allegiance-AZ
1d8678ddff9e2efc79ed449de6d47544989bc091
[ "MIT" ]
42
2015-08-13T23:31:35.000Z
2022-03-17T02:20:26.000Z
///////////////////////////////////////////////////////////////////////////// // AGCOrientation.h : Declaration of the CAGCOrientation // #ifndef __AGCOrientation_H_ #define __AGCOrientation_H_ #include <AGC.h> #include <..\TCLib\ObjectLock.h> #include "resource.h" ///////////////////////////////////////////////////////////////////////////// // CAGCOrientation class ATL_NO_VTABLE CAGCOrientation : public IDispatchImpl<IAGCOrientation, &IID_IAGCOrientation, &LIBID_AGCLib>, public IAGCOrientationPrivate, public ISupportErrorInfo, public IPersistStreamInit, public AGCObjectSafetyImpl<CAGCOrientation>, public CComObjectRootEx<CComMultiThreadModel>, public CComCoClass<CAGCOrientation, &CLSID_AGCOrientation> { // Declarations public: DECLARE_REGISTRY_RESOURCEID(IDR_AGCOrientation) DECLARE_PROTECT_FINAL_CONSTRUCT() DECLARE_GET_CONTROLLING_UNKNOWN() // Interface Map public: BEGIN_COM_MAP(CAGCOrientation) COM_INTERFACE_ENTRY(IAGCOrientation) COM_INTERFACE_ENTRY(IAGCOrientationPrivate) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(ISupportErrorInfo) COM_INTERFACE_ENTRY(IPersistStreamInit) COM_INTERFACE_ENTRY2(IPersistStream, IPersistStreamInit) COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit) COM_INTERFACE_ENTRY_AUTOAGGREGATE(IID_IMarshal, m_punkMBV.p, CLSID_TCMarshalByValue) COM_INTERFACE_ENTRY(IObjectSafety) END_COM_MAP() // Category Map public: BEGIN_CATEGORY_MAP(CAGCOrientation) IMPLEMENTED_CATEGORY(CATID_AGC) IMPLEMENTED_CATEGORY(CATID_SafeForScripting) IMPLEMENTED_CATEGORY(CATID_SafeForInitializing) END_CATEGORY_MAP() // Construction public: CAGCOrientation() : m_bDirty(false) { } // Implemenatation protected: static HRESULT GetRawOrientation(IAGCOrientation* pOrientation, Orientation* pOrientationRaw); static HRESULT CreateResultVector(const Vector* pVectorRaw, IAGCVector** ppResult); // ISupportsErrorInfo Interface Methods public: STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); // IAGCOrientation Interface Methods public: STDMETHODIMP InitCopy(IAGCOrientation* pOrientation); STDMETHODIMP get_Forward(IAGCVector** ppVector); STDMETHODIMP get_Backward(IAGCVector** ppVector); STDMETHODIMP get_Up(IAGCVector** ppVector); STDMETHODIMP get_Right(IAGCVector** ppVector); STDMETHODIMP get_IsEqual(IAGCOrientation* pOrientation, VARIANT_BOOL* pbIsEqual); STDMETHODIMP get_IsRoughlyEqual(IAGCOrientation* pOrientation, VARIANT_BOOL* pbIsEqual); // IAGCOrientationPrivate Interface Methods public: STDMETHODIMP InitFromOrientation(const void* pvOrientation); STDMETHODIMP CopyOrientationTo(void* pvOrientation); // IPersist Interface Methods public: STDMETHODIMP GetClassID(CLSID* pClassID); // IPersistStreamInit Interface Methods public: STDMETHODIMP IsDirty(); STDMETHODIMP Load(LPSTREAM pStm); STDMETHODIMP Save(LPSTREAM pStm, BOOL fClearDirty); STDMETHODIMP GetSizeMax(ULARGE_INTEGER* pCbSize); STDMETHODIMP InitNew(void); // Enumerations protected: enum {DIMENSIONS = 9}; // Types protected: typedef TCObjectLock<CAGCOrientation> XLock; // Data Members private: Orientation m_orientation; // the actual orientation data goes here! bool m_bDirty; public: CComPtr<IUnknown> m_punkMBV; }; ///////////////////////////////////////////////////////////////////////////// #endif //__AGCOrientation_H_
28.35
77
0.748677
[ "vector" ]
e83e93516d99717da1c1d0ca4c8773efb9f1f5e0
3,694
c
C
csrc/exec_aggregate.c
witheve/lueve
8633742d491dc8e5aa97153d3365515bd9b64543
[ "Apache-2.0" ]
14
2016-05-19T02:11:47.000Z
2016-07-15T18:11:08.000Z
csrc/exec_aggregate.c
witheve/lueve
8633742d491dc8e5aa97153d3365515bd9b64543
[ "Apache-2.0" ]
10
2016-06-08T17:20:59.000Z
2016-07-19T18:53:35.000Z
csrc/exec_aggregate.c
ibdknox/lueve
8633742d491dc8e5aa97153d3365515bd9b64543
[ "Apache-2.0" ]
3
2016-06-08T12:11:51.000Z
2016-07-19T18:55:01.000Z
#include <runtime.h> #include <exec.h> // we're suposed to have multiple keys and multiple sort orders, ideally // just generate a comparator over r static CONTINUATION_7_4(do_sort, execf, perf, table *, value, value, vector,vector, heap, perf, operator, value *); static void do_sort(execf n, perf p, table *targets, value key, value out, vector proj, vector pk, heap h, perf pp, operator op, value *r) { start_perf(p); if (op == op_insert) { extract(pk, proj, r); pqueue x; if (!(x = table_find(*targets, pk))) { x = allocate_pqueue(h, order_values); // make a new key idiot table_set(*targets,pk, x); } pqueue_insert(x, lookup(r, key)); } if (op == op_flush) { table_foreach(*targets, pk, x) { pqueue q = x; int count; copyout(r, proj, x); vector_foreach(q->v, i) { // if we dont do the denorm trick, these should at least be findable and resuable store(out, out, box_float(count++)); apply(n, h, p, op_insert, r); } } apply(n, h, p, op_flush, r); *targets = allocate_table((*targets)->h, key_from_pointer, compare_pointer); } if (op == op_close) { apply(n, h, p, op_close, r); } stop_perf(p, pp); } static execf build_sort(block bk, node n, execf *arms) { return cont(bk->h, do_sort, resolve_cfg(bk, n, 0), register_perf(bk->ev, n), 0, 0, 0, 0, 0); } static CONTINUATION_7_4(do_sum, execf, perf, table*, vector, value, value, vector, heap, perf, operator, value *); static void do_sum(execf n, perf p, table *targets, vector grouping, value src, value dst, vector pk, heap h, perf pp, operator op, value *r) { start_perf(p); if (op == op_insert) { extract(pk, grouping, r); double *x; if (!(x = table_find(*targets, pk))) { x = allocate((*targets)->h, sizeof(double *)); *x = 0.0; vector key = allocate_vector((*targets)->h, vector_length(grouping)); extract(key, grouping, r); table_set(*targets, key, x); } *x = *x + *(double *)lookup(r, src); } if (op == op_flush) { table_foreach(*targets, pk, x) { copyout(r, grouping, pk); store(r, dst, box_float(*(double *)x)); apply(n, h, p, op_insert, r); } *targets = create_value_vector_table((*targets)->h); apply(n, h, p, op_flush, r); } if (op == op_close) { apply(n, h, p, op_close, r); } stop_perf(p, pp); } static execf build_sum(block bk, node n, execf *arms) { // vector targets, grouping, value src, value dst, vector pk vector args = vector_get(n->arguments, 0); vector groupings = vector_get(n->arguments, 1); vector pk = allocate_vector(bk->h, vector_length(groupings)); table *targets = allocate(bk->h, sizeof(table)); *targets = create_value_vector_table(bk->h); return cont(bk->h, do_sum, resolve_cfg(bk, n, 0), register_perf(bk->ev, n), targets, groupings, vector_get(args, 1), vector_get(args, 0), pk); } void register_aggregate_builders(table builders) { table_set(builders, intern_cstring("sum"), build_sum); table_set(builders, intern_cstring("sort"), build_sort); }
31.305085
114
0.529778
[ "vector" ]
e840a36c10914db0eeda71bff5c589a464242963
32,394
c
C
src/libnfc-nci/gki/common/gki_time.c
EVerestProject/linux_libnfc-nci
7de6de2eaa66889d57dd31e3c91da00a9622f8db
[ "Apache-2.0" ]
123
2015-09-09T08:14:43.000Z
2022-03-12T11:51:30.000Z
src/libnfc-nci/gki/common/gki_time.c
EVerestProject/linux_libnfc-nci
7de6de2eaa66889d57dd31e3c91da00a9622f8db
[ "Apache-2.0" ]
133
2015-10-20T17:34:17.000Z
2022-03-31T15:25:31.000Z
src/libnfc-nci/gki/common/gki_time.c
EVerestProject/linux_libnfc-nci
7de6de2eaa66889d57dd31e3c91da00a9622f8db
[ "Apache-2.0" ]
93
2015-06-11T04:09:44.000Z
2022-03-14T11:18:15.000Z
/****************************************************************************** * * Copyright (C) 1999-2012 Broadcom Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ******************************************************************************/ #include "gki_int.h" #ifndef BT_ERROR_TRACE_0 #define BT_ERROR_TRACE_0(l,m) #endif /* Make sure that this has been defined in target.h */ #ifndef GKI_NUM_TIMERS #error NO TIMERS: Must define at least 1 timer in the system! #endif #define GKI_NO_NEW_TMRS_STARTED (0x7fffffffL) /* Largest signed positive timer count */ #define GKI_UNUSED_LIST_ENTRY (0x80000000L) /* Marks an unused timer list entry (initial value) */ #define GKI_MAX_INT32 (0x7fffffffL) /******************************************************************************* ** ** Function gki_timers_init ** ** Description This internal function is called once at startup to initialize ** all the timer structures. ** ** Returns void ** *******************************************************************************/ void gki_timers_init(void) { UINT8 tt; gki_cb.com.OSTicksTilExp = 0; /* Remaining time (of OSTimeCurTimeout) before next timer expires */ gki_cb.com.OSNumOrigTicks = 0; #if (defined(GKI_DELAY_STOP_SYS_TICK) && (GKI_DELAY_STOP_SYS_TICK > 0)) gki_cb.com.OSTicksTilStop = 0; /* clear inactivity delay timer */ #endif for (tt = 0; tt < GKI_MAX_TASKS; tt++) { gki_cb.com.OSWaitTmr [tt] = 0; #if (GKI_NUM_TIMERS > 0) gki_cb.com.OSTaskTmr0 [tt] = 0; gki_cb.com.OSTaskTmr0R [tt] = 0; #endif #if (GKI_NUM_TIMERS > 1) gki_cb.com.OSTaskTmr1 [tt] = 0; gki_cb.com.OSTaskTmr1R [tt] = 0; #endif #if (GKI_NUM_TIMERS > 2) gki_cb.com.OSTaskTmr2 [tt] = 0; gki_cb.com.OSTaskTmr2R [tt] = 0; #endif #if (GKI_NUM_TIMERS > 3) gki_cb.com.OSTaskTmr3 [tt] = 0; gki_cb.com.OSTaskTmr3R [tt] = 0; #endif } for (tt = 0; tt < GKI_MAX_TIMER_QUEUES; tt++) { gki_cb.com.timer_queues[tt] = NULL; } gki_cb.com.p_tick_cb = NULL; gki_cb.com.system_tick_running = FALSE; return; } /******************************************************************************* ** ** Function gki_timers_is_timer_running ** ** Description This internal function is called to test if any gki timer are running ** ** ** Returns TRUE if at least one time is running in the system, FALSE else. ** *******************************************************************************/ BOOLEAN gki_timers_is_timer_running(void) { UINT8 tt; for (tt = 0; tt < GKI_MAX_TASKS; tt++) { #if (GKI_NUM_TIMERS > 0) if(gki_cb.com.OSTaskTmr0 [tt]) { return TRUE; } #endif #if (GKI_NUM_TIMERS > 1) if(gki_cb.com.OSTaskTmr1 [tt] ) { return TRUE; } #endif #if (GKI_NUM_TIMERS > 2) if(gki_cb.com.OSTaskTmr2 [tt] ) { return TRUE; } #endif #if (GKI_NUM_TIMERS > 3) if(gki_cb.com.OSTaskTmr3 [tt] ) { return TRUE; } #endif } return FALSE; } /******************************************************************************* ** ** Function GKI_get_tick_count ** ** Description This function returns the current system ticks ** ** Returns The current number of system ticks ** *******************************************************************************/ UINT32 GKI_get_tick_count(void) { return gki_cb.com.OSTicks; } /******************************************************************************* ** ** Function GKI_ready_to_sleep ** ** Description This function returns the number of system ticks until the ** next timer will expire. It is typically called by a power ** savings manager to find out how long it can have the system ** sleep before it needs to service the next entry. ** ** Parameters: None ** ** Returns Number of ticks til the next timer expires ** Note: the value is a signed value. This value should be ** compared to x > 0, to avoid misinterpreting negative tick ** values. ** *******************************************************************************/ INT32 GKI_ready_to_sleep (void) { return (gki_cb.com.OSTicksTilExp); } /******************************************************************************* ** ** Function GKI_start_timer ** ** Description An application can call this function to start one of ** it's four general purpose timers. Any of the four timers ** can be 1-shot or continuous. If a timer is already running, ** it will be reset to the new parameters. ** ** Parameters tnum - (input) timer number to be started (TIMER_0, ** TIMER_1, TIMER_2, or TIMER_3) ** ticks - (input) the number of system ticks til the ** timer expires. ** is_continuous - (input) TRUE if timer restarts automatically, ** else FALSE if it is a 'one-shot'. ** ** Returns void ** *******************************************************************************/ void GKI_start_timer (UINT8 tnum, INT32 ticks, BOOLEAN is_continuous) { INT32 reload; INT32 orig_ticks; UINT8 task_id = GKI_get_taskid(); BOOLEAN bad_timer = FALSE; if (ticks <= 0) ticks = 1; orig_ticks = ticks; /* save the ticks in case adjustment is necessary */ /* If continuous timer, set reload, else set it to 0 */ if (is_continuous) reload = ticks; else reload = 0; GKI_disable(); if(gki_timers_is_timer_running() == FALSE) { #if (defined(GKI_DELAY_STOP_SYS_TICK) && (GKI_DELAY_STOP_SYS_TICK > 0)) /* if inactivity delay timer is not running, start system tick */ if(gki_cb.com.OSTicksTilStop == 0) { #endif if(gki_cb.com.p_tick_cb) { /* start system tick */ gki_cb.com.system_tick_running = TRUE; (gki_cb.com.p_tick_cb) (TRUE); } #if (defined(GKI_DELAY_STOP_SYS_TICK) && (GKI_DELAY_STOP_SYS_TICK > 0)) } else { /* clear inactivity delay timer */ gki_cb.com.OSTicksTilStop = 0; } #endif } /* Add the time since the last task timer update. ** Note that this works when no timers are active since ** both OSNumOrigTicks and OSTicksTilExp are 0. */ if (GKI_MAX_INT32 - (gki_cb.com.OSNumOrigTicks - gki_cb.com.OSTicksTilExp) > ticks) { ticks += gki_cb.com.OSNumOrigTicks - gki_cb.com.OSTicksTilExp; } else ticks = GKI_MAX_INT32; switch (tnum) { #if (GKI_NUM_TIMERS > 0) case TIMER_0: gki_cb.com.OSTaskTmr0R[task_id] = reload; gki_cb.com.OSTaskTmr0 [task_id] = ticks; break; #endif #if (GKI_NUM_TIMERS > 1) case TIMER_1: gki_cb.com.OSTaskTmr1R[task_id] = reload; gki_cb.com.OSTaskTmr1 [task_id] = ticks; break; #endif #if (GKI_NUM_TIMERS > 2) case TIMER_2: gki_cb.com.OSTaskTmr2R[task_id] = reload; gki_cb.com.OSTaskTmr2 [task_id] = ticks; break; #endif #if (GKI_NUM_TIMERS > 3) case TIMER_3: gki_cb.com.OSTaskTmr3R[task_id] = reload; gki_cb.com.OSTaskTmr3 [task_id] = ticks; break; #endif default: bad_timer = TRUE; /* Timer number is bad, so do not use */ } /* Update the expiration timeout if a legitimate timer */ if (!bad_timer) { /* Only update the timeout value if it is less than any other newly started timers */ gki_adjust_timer_count (orig_ticks); } GKI_enable(); } /******************************************************************************* ** ** Function GKI_stop_timer ** ** Description An application can call this function to stop one of ** it's four general purpose timers. There is no harm in ** stopping a timer that is already stopped. ** ** Parameters tnum - (input) timer number to be started (TIMER_0, ** TIMER_1, TIMER_2, or TIMER_3) ** Returns void ** *******************************************************************************/ void GKI_stop_timer (UINT8 tnum) { UINT8 task_id = GKI_get_taskid(); GKI_disable(); switch (tnum) { #if (GKI_NUM_TIMERS > 0) case TIMER_0: gki_cb.com.OSTaskTmr0R[task_id] = 0; gki_cb.com.OSTaskTmr0 [task_id] = 0; break; #endif #if (GKI_NUM_TIMERS > 1) case TIMER_1: gki_cb.com.OSTaskTmr1R[task_id] = 0; gki_cb.com.OSTaskTmr1 [task_id] = 0; break; #endif #if (GKI_NUM_TIMERS > 2) case TIMER_2: gki_cb.com.OSTaskTmr2R[task_id] = 0; gki_cb.com.OSTaskTmr2 [task_id] = 0; break; #endif #if (GKI_NUM_TIMERS > 3) case TIMER_3: gki_cb.com.OSTaskTmr3R[task_id] = 0; gki_cb.com.OSTaskTmr3 [task_id] = 0; break; #endif } if (gki_timers_is_timer_running() == FALSE) { if (gki_cb.com.p_tick_cb) { #if (defined(GKI_DELAY_STOP_SYS_TICK) && (GKI_DELAY_STOP_SYS_TICK > 0)) /* if inactivity delay timer is not running */ if ((gki_cb.com.system_tick_running)&&(gki_cb.com.OSTicksTilStop == 0)) { /* set inactivity delay timer */ /* when timer expires, system tick will be stopped */ gki_cb.com.OSTicksTilStop = GKI_DELAY_STOP_SYS_TICK; } #else gki_cb.com.system_tick_running = FALSE; gki_cb.com.p_tick_cb(FALSE); /* stop system tick */ #endif } } GKI_enable(); } /******************************************************************************* ** ** Function GKI_timer_update ** ** Description This function is called by an OS to drive the GKI's timers. ** It is typically called at every system tick to ** update the timers for all tasks, and check for timeouts. ** ** Note: It has been designed to also allow for variable tick updates ** so that systems with strict power savings requirements can ** have the update occur at variable intervals. ** ** Parameters: ticks_since_last_update - (input) This is the number of TICKS that have ** occurred since the last time GKI_timer_update was called. ** ** Returns void ** *******************************************************************************/ void GKI_timer_update (INT32 ticks_since_last_update) { UINT8 task_id; long next_expiration; /* Holds the next soonest expiration time after this update */ /* Increment the number of ticks used for time stamps */ gki_cb.com.OSTicks += ticks_since_last_update; /* If any timers are running in any tasks, decrement the remaining time til * the timer updates need to take place (next expiration occurs) */ gki_cb.com.OSTicksTilExp -= ticks_since_last_update; /* Don't allow timer interrupt nesting */ if (gki_cb.com.timer_nesting) return; gki_cb.com.timer_nesting = 1; #if (defined(GKI_DELAY_STOP_SYS_TICK) && (GKI_DELAY_STOP_SYS_TICK > 0)) /* if inactivity delay timer is set and expired */ if (gki_cb.com.OSTicksTilStop) { if( gki_cb.com.OSTicksTilStop <= (UINT32)ticks_since_last_update ) { if(gki_cb.com.p_tick_cb) { gki_cb.com.system_tick_running = FALSE; (gki_cb.com.p_tick_cb) (FALSE); /* stop system tick */ } gki_cb.com.OSTicksTilStop = 0; /* clear inactivity delay timer */ gki_cb.com.timer_nesting = 0; return; } else gki_cb.com.OSTicksTilStop -= ticks_since_last_update; } #endif /* No need to update the ticks if no timeout has occurred */ if (gki_cb.com.OSTicksTilExp > 0) { gki_cb.com.timer_nesting = 0; return; } GKI_disable(); next_expiration = GKI_NO_NEW_TMRS_STARTED; /* If here then gki_cb.com.OSTicksTilExp <= 0. If negative, then increase gki_cb.com.OSNumOrigTicks to account for the difference so timer updates below are decremented by the full number of ticks. gki_cb.com.OSNumOrigTicks is reset at the bottom of this function so changing this value only affects the timer updates below */ gki_cb.com.OSNumOrigTicks -= gki_cb.com.OSTicksTilExp; /* Check for OS Task Timers */ for (task_id = 0; task_id < GKI_MAX_TASKS; task_id++) { if (gki_cb.com.OSRdyTbl[task_id] == TASK_DEAD) { // task is shutdown do not try to service timers continue; } if (gki_cb.com.OSWaitTmr[task_id] > 0) /* If timer is running */ { gki_cb.com.OSWaitTmr[task_id] -= gki_cb.com.OSNumOrigTicks; if (gki_cb.com.OSWaitTmr[task_id] <= 0) { /* Timer Expired */ gki_cb.com.OSRdyTbl[task_id] = TASK_READY; } } #if (GKI_NUM_TIMERS > 0) /* If any timer is running, decrement */ if (gki_cb.com.OSTaskTmr0[task_id] > 0) { gki_cb.com.OSTaskTmr0[task_id] -= gki_cb.com.OSNumOrigTicks; if (gki_cb.com.OSTaskTmr0[task_id] <= 0) { /* Set Timer 0 Expired event mask and reload timer */ #if (defined(GKI_TIMER_UPDATES_FROM_ISR) && GKI_TIMER_UPDATES_FROM_ISR == TRUE) GKI_isend_event (task_id, TIMER_0_EVT_MASK); #else GKI_send_event (task_id, TIMER_0_EVT_MASK); #endif gki_cb.com.OSTaskTmr0[task_id] = gki_cb.com.OSTaskTmr0R[task_id]; } } /* Check to see if this timer is the next one to expire */ if (gki_cb.com.OSTaskTmr0[task_id] > 0 && gki_cb.com.OSTaskTmr0[task_id] < next_expiration) next_expiration = gki_cb.com.OSTaskTmr0[task_id]; #endif #if (GKI_NUM_TIMERS > 1) /* If any timer is running, decrement */ if (gki_cb.com.OSTaskTmr1[task_id] > 0) { gki_cb.com.OSTaskTmr1[task_id] -= gki_cb.com.OSNumOrigTicks; if (gki_cb.com.OSTaskTmr1[task_id] <= 0) { /* Set Timer 1 Expired event mask and reload timer */ #if (defined(GKI_TIMER_UPDATES_FROM_ISR) && GKI_TIMER_UPDATES_FROM_ISR == TRUE) GKI_isend_event (task_id, TIMER_1_EVT_MASK); #else GKI_send_event (task_id, TIMER_1_EVT_MASK); #endif gki_cb.com.OSTaskTmr1[task_id] = gki_cb.com.OSTaskTmr1R[task_id]; } } /* Check to see if this timer is the next one to expire */ if (gki_cb.com.OSTaskTmr1[task_id] > 0 && gki_cb.com.OSTaskTmr1[task_id] < next_expiration) next_expiration = gki_cb.com.OSTaskTmr1[task_id]; #endif #if (GKI_NUM_TIMERS > 2) /* If any timer is running, decrement */ if (gki_cb.com.OSTaskTmr2[task_id] > 0) { gki_cb.com.OSTaskTmr2[task_id] -= gki_cb.com.OSNumOrigTicks; if (gki_cb.com.OSTaskTmr2[task_id] <= 0) { /* Set Timer 2 Expired event mask and reload timer */ #if (defined(GKI_TIMER_UPDATES_FROM_ISR) && GKI_TIMER_UPDATES_FROM_ISR == TRUE) GKI_isend_event (task_id, TIMER_2_EVT_MASK); #else GKI_send_event (task_id, TIMER_2_EVT_MASK); #endif gki_cb.com.OSTaskTmr2[task_id] = gki_cb.com.OSTaskTmr2R[task_id]; } } /* Check to see if this timer is the next one to expire */ if (gki_cb.com.OSTaskTmr2[task_id] > 0 && gki_cb.com.OSTaskTmr2[task_id] < next_expiration) next_expiration = gki_cb.com.OSTaskTmr2[task_id]; #endif #if (GKI_NUM_TIMERS > 3) /* If any timer is running, decrement */ if (gki_cb.com.OSTaskTmr3[task_id] > 0) { gki_cb.com.OSTaskTmr3[task_id] -= gki_cb.com.OSNumOrigTicks; if (gki_cb.com.OSTaskTmr3[task_id] <= 0) { /* Set Timer 3 Expired event mask and reload timer */ #if (defined(GKI_TIMER_UPDATES_FROM_ISR) && GKI_TIMER_UPDATES_FROM_ISR == TRUE) GKI_isend_event (task_id, TIMER_3_EVT_MASK); #else GKI_send_event (task_id, TIMER_3_EVT_MASK); #endif gki_cb.com.OSTaskTmr3[task_id] = gki_cb.com.OSTaskTmr3R[task_id]; } } /* Check to see if this timer is the next one to expire */ if (gki_cb.com.OSTaskTmr3[task_id] > 0 && gki_cb.com.OSTaskTmr3[task_id] < next_expiration) next_expiration = gki_cb.com.OSTaskTmr3[task_id]; #endif } /* Set the next timer experation value if there is one to start */ if (next_expiration < GKI_NO_NEW_TMRS_STARTED) { gki_cb.com.OSTicksTilExp = gki_cb.com.OSNumOrigTicks = next_expiration; } else { gki_cb.com.OSTicksTilExp = gki_cb.com.OSNumOrigTicks = 0; } gki_cb.com.timer_nesting = 0; GKI_enable(); return; } /******************************************************************************* ** ** Function GKI_timer_queue_empty ** ** Description This function is called by applications to see whether the timer ** queue is empty ** ** Parameters ** ** Returns BOOLEAN ** *******************************************************************************/ BOOLEAN GKI_timer_queue_empty (void) { UINT8 tt; for (tt = 0; tt < GKI_MAX_TIMER_QUEUES; tt++) { if (gki_cb.com.timer_queues[tt]) return FALSE; } return TRUE; } /******************************************************************************* ** ** Function GKI_timer_queue_register_callback ** ** Description This function is called by applications to register system tick ** start/stop callback for time queues ** ** ** Parameters p_callback - (input) pointer to the system tick callback ** ** Returns BOOLEAN ** *******************************************************************************/ void GKI_timer_queue_register_callback (SYSTEM_TICK_CBACK *p_callback) { gki_cb.com.p_tick_cb = p_callback; return; } /******************************************************************************* ** ** Function GKI_init_timer_list ** ** Description This function is called by applications when they ** want to initialize a timer list. ** ** Parameters p_timer_listq - (input) pointer to the timer list queue object ** ** Returns void ** *******************************************************************************/ void GKI_init_timer_list (TIMER_LIST_Q *p_timer_listq) { p_timer_listq->p_first = NULL; p_timer_listq->p_last = NULL; p_timer_listq->last_ticks = 0; return; } /******************************************************************************* ** ** Function GKI_init_timer_list_entry ** ** Description This function is called by the applications when they ** want to initialize a timer list entry. This must be ** done prior to first use of the entry. ** ** Parameters p_tle - (input) pointer to a timer list queue entry ** ** Returns void ** *******************************************************************************/ void GKI_init_timer_list_entry (TIMER_LIST_ENT *p_tle) { p_tle->p_next = NULL; p_tle->p_prev = NULL; p_tle->ticks = GKI_UNUSED_LIST_ENTRY; p_tle->in_use = FALSE; } /******************************************************************************* ** ** Function GKI_update_timer_list ** ** Description This function is called by the applications when they ** want to update a timer list. This should be at every ** timer list unit tick, e.g. once per sec, once per minute etc. ** ** Parameters p_timer_listq - (input) pointer to the timer list queue object ** num_units_since_last_update - (input) number of units since the last update ** (allows for variable unit update) ** ** NOTE: The following timer list update routines should not be used for exact time ** critical purposes. The timer tasks should be used when exact timing is needed. ** ** Returns the number of timers that have expired ** *******************************************************************************/ UINT16 GKI_update_timer_list (TIMER_LIST_Q *p_timer_listq, INT32 num_units_since_last_update) { TIMER_LIST_ENT *p_tle; UINT16 num_time_out = 0; INT32 rem_ticks; INT32 temp_ticks; p_tle = p_timer_listq->p_first; /* First, get the guys who have previously timed out */ /* Note that the tick value of the timers should always be '0' */ while ((p_tle) && (p_tle->ticks <= 0)) { num_time_out++; p_tle = p_tle->p_next; } /* Timer entriy tick values are relative to the preceeding entry */ rem_ticks = num_units_since_last_update; /* Now, adjust remaining timer entries */ while ((p_tle != NULL) && (rem_ticks > 0)) { temp_ticks = p_tle->ticks; p_tle->ticks -= rem_ticks; /* See if this timer has just timed out */ if (p_tle->ticks <= 0) { /* We set the number of ticks to '0' so that the legacy code * that assumes a '0' or nonzero value will still work as coded. */ p_tle->ticks = 0; num_time_out++; } rem_ticks -= temp_ticks; /* Decrement the remaining ticks to process */ p_tle = p_tle->p_next; } if (p_timer_listq->last_ticks > 0) { p_timer_listq->last_ticks -= num_units_since_last_update; /* If the last timer has expired set last_ticks to 0 so that other list update * functions will calculate correctly */ if (p_timer_listq->last_ticks < 0) p_timer_listq->last_ticks = 0; } return (num_time_out); } /******************************************************************************* ** ** Function GKI_get_remaining_ticks ** ** Description This function is called by an application to get remaining ** ticks to expire ** ** Parameters p_timer_listq - (input) pointer to the timer list queue object ** p_target_tle - (input) pointer to a timer list queue entry ** ** Returns 0 if timer is not used or timer is not in the list ** remaining ticks if success ** *******************************************************************************/ UINT32 GKI_get_remaining_ticks (TIMER_LIST_Q *p_timer_listq, TIMER_LIST_ENT *p_target_tle) { TIMER_LIST_ENT *p_tle; UINT32 rem_ticks = 0; if (p_target_tle->in_use) { p_tle = p_timer_listq->p_first; /* adding up all of ticks in previous entries */ while ((p_tle)&&(p_tle != p_target_tle)) { rem_ticks += p_tle->ticks; p_tle = p_tle->p_next; } /* if found target entry */ if (p_tle == p_target_tle) { rem_ticks += p_tle->ticks; } else { BT_ERROR_TRACE_0(TRACE_LAYER_GKI, "GKI_get_remaining_ticks: No timer entry in the list"); return(0); } } else { BT_ERROR_TRACE_0(TRACE_LAYER_GKI, "GKI_get_remaining_ticks: timer entry is not active"); } return (rem_ticks); } /******************************************************************************* ** ** Function GKI_add_to_timer_list ** ** Description This function is called by an application to add a timer ** entry to a timer list. ** ** Note: A timer value of '0' will effectively insert an already ** expired event. Negative tick values will be ignored. ** ** Parameters p_timer_listq - (input) pointer to the timer list queue object ** p_tle - (input) pointer to a timer list queue entry ** ** Returns void ** *******************************************************************************/ void GKI_add_to_timer_list (TIMER_LIST_Q *p_timer_listq, TIMER_LIST_ENT *p_tle) { UINT32 nr_ticks_total; UINT8 tt; TIMER_LIST_ENT *p_temp; if (p_tle == NULL || p_timer_listq == NULL) { GKI_TRACE_3("%s: invalid argument %x, %x****************************<<", __func__, p_timer_listq, p_tle); return; } /* Only process valid tick values */ if (p_tle->ticks >= 0) { /* If this entry is the last in the list */ if (p_tle->ticks >= p_timer_listq->last_ticks) { /* If this entry is the only entry in the list */ if (p_timer_listq->p_first == NULL) p_timer_listq->p_first = p_tle; else { /* Insert the entry onto the end of the list */ if (p_timer_listq->p_last != NULL) p_timer_listq->p_last->p_next = p_tle; p_tle->p_prev = p_timer_listq->p_last; } p_tle->p_next = NULL; p_timer_listq->p_last = p_tle; nr_ticks_total = p_tle->ticks; p_tle->ticks -= p_timer_listq->last_ticks; p_timer_listq->last_ticks = nr_ticks_total; } else /* This entry needs to be inserted before the last entry */ { /* Find the entry that the new one needs to be inserted in front of */ p_temp = p_timer_listq->p_first; while (p_tle->ticks > p_temp->ticks) { /* Update the tick value if looking at an unexpired entry */ if (p_temp->ticks > 0) p_tle->ticks -= p_temp->ticks; p_temp = p_temp->p_next; } /* The new entry is the first in the list */ if (p_temp == p_timer_listq->p_first) { p_tle->p_next = p_timer_listq->p_first; p_timer_listq->p_first->p_prev = p_tle; p_timer_listq->p_first = p_tle; } else { p_temp->p_prev->p_next = p_tle; p_tle->p_prev = p_temp->p_prev; p_temp->p_prev = p_tle; p_tle->p_next = p_temp; } p_temp->ticks -= p_tle->ticks; } p_tle->in_use = TRUE; /* if we already add this timer queue to the array */ for (tt = 0; tt < GKI_MAX_TIMER_QUEUES; tt++) { if (gki_cb.com.timer_queues[tt] == p_timer_listq) return; } /* add this timer queue to the array */ for (tt = 0; tt < GKI_MAX_TIMER_QUEUES; tt++) { if (gki_cb.com.timer_queues[tt] == NULL) break; } if (tt < GKI_MAX_TIMER_QUEUES) { gki_cb.com.timer_queues[tt] = p_timer_listq; } } return; } /******************************************************************************* ** ** Function GKI_remove_from_timer_list ** ** Description This function is called by an application to remove a timer ** entry from a timer list. ** ** Parameters p_timer_listq - (input) pointer to the timer list queue object ** p_tle - (input) pointer to a timer list queue entry ** ** Returns void ** *******************************************************************************/ void GKI_remove_from_timer_list (TIMER_LIST_Q *p_timer_listq, TIMER_LIST_ENT *p_tle) { UINT8 tt; /* Verify that the entry is valid */ if (p_tle == NULL || p_tle->in_use == FALSE || p_timer_listq->p_first == NULL) { return; } /* Add the ticks remaining in this timer (if any) to the next guy in the list. ** Note: Expired timers have a tick value of '0'. */ if (p_tle->p_next != NULL) { p_tle->p_next->ticks += p_tle->ticks; } else { p_timer_listq->last_ticks -= p_tle->ticks; } /* Unlink timer from the list. */ if (p_timer_listq->p_first == p_tle) { p_timer_listq->p_first = p_tle->p_next; if (p_timer_listq->p_first != NULL) p_timer_listq->p_first->p_prev = NULL; if (p_timer_listq->p_last == p_tle) p_timer_listq->p_last = NULL; } else { if (p_timer_listq->p_last == p_tle) { p_timer_listq->p_last = p_tle->p_prev; if (p_timer_listq->p_last != NULL) p_timer_listq->p_last->p_next = NULL; } else { if (p_tle->p_next != NULL && p_tle->p_next->p_prev == p_tle) p_tle->p_next->p_prev = p_tle->p_prev; else { /* Error case - chain messed up ?? */ return; } if (p_tle->p_prev != NULL && p_tle->p_prev->p_next == p_tle) p_tle->p_prev->p_next = p_tle->p_next; else { /* Error case - chain messed up ?? */ return; } } } p_tle->p_next = p_tle->p_prev = NULL; p_tle->ticks = GKI_UNUSED_LIST_ENTRY; p_tle->in_use = FALSE; /* if timer queue is empty */ if (p_timer_listq->p_first == NULL && p_timer_listq->p_last == NULL) { for (tt = 0; tt < GKI_MAX_TIMER_QUEUES; tt++) { if (gki_cb.com.timer_queues[tt] == p_timer_listq) { gki_cb.com.timer_queues[tt] = NULL; break; } } } return; } /******************************************************************************* ** ** Function gki_adjust_timer_count ** ** Description This function is called whenever a new timer or GKI_wait occurs ** to adjust (if necessary) the current time til the first expiration. ** This only needs to make an adjustment if the new timer (in ticks) is ** less than the number of ticks remaining on the current timer. ** ** Parameters: ticks - (input) number of system ticks of the new timer entry ** ** NOTE: This routine MUST be called while interrupts are disabled to ** avoid updates while adjusting the timer variables. ** ** Returns void ** *******************************************************************************/ void gki_adjust_timer_count (INT32 ticks) { if (ticks > 0) { /* See if the new timer expires before the current first expiration */ if (gki_cb.com.OSNumOrigTicks == 0 || (ticks < gki_cb.com.OSTicksTilExp && gki_cb.com.OSTicksTilExp > 0)) { gki_cb.com.OSNumOrigTicks = (gki_cb.com.OSNumOrigTicks - gki_cb.com.OSTicksTilExp) + ticks; gki_cb.com.OSTicksTilExp = ticks; } } return; }
31.821218
113
0.53334
[ "object" ]
e843126b85e9aecc0adbc20243b76b57b5146d9c
15,123
c
C
manuscript/python_generators/local_imports/stride/sheet.c
Seanny123/backmap
c216ab1fb9c21114c3d7414e514f5283a0a45f60
[ "MIT" ]
3
2019-10-07T13:07:13.000Z
2021-09-26T08:58:38.000Z
manuscript/python_generators/local_imports/stride/sheet.c
Seanny123/backmap
c216ab1fb9c21114c3d7414e514f5283a0a45f60
[ "MIT" ]
null
null
null
manuscript/python_generators/local_imports/stride/sheet.c
Seanny123/backmap
c216ab1fb9c21114c3d7414e514f5283a0a45f60
[ "MIT" ]
2
2019-03-29T14:51:58.000Z
2020-02-21T14:53:08.000Z
#include "stride.h" void Sheet(CHAIN **Chain, int Cn1, int Cn2, HBOND **HBond, COMMAND *Cmd, float **PhiPsiMap) { PATTERN **PatN, **PatP; RESIDUE *Res1, *Res3, *Res2, *Res4, *ResA, *ResB, *Res1m1, *Res3p1; int R1, R3, R2, R4, RA, RB, PatCntN = 0, PatCntP = 0, Beg; char *AntiPar1, *Par1, *AntiPar2, *Par2; register int i; PatN = (PATTERN **)ckalloc(MAXHYDRBOND*sizeof(PATTERN *)); PatP = (PATTERN **)ckalloc(MAXHYDRBOND*sizeof(PATTERN *)); AntiPar1 = (char *)ckalloc(Chain[Cn1]->NRes*sizeof(char)); /* Antiparallel strands */ Par1 = (char *)ckalloc(Chain[Cn1]->NRes*sizeof(char)); /* Parallel strands */ AntiPar2 = (char *)ckalloc(Chain[Cn2]->NRes*sizeof(char)); /* Antiparallel strands */ Par2 = (char *)ckalloc(Chain[Cn2]->NRes*sizeof(char)); /* Parallel strands */ for( i=0; i<Chain[Cn1]->NRes; i++ ) { AntiPar1[i] = 'C'; Par1[i] = 'C'; } for( i=0; i<Chain[Cn2]->NRes; i++ ) { AntiPar2[i] = 'C'; Par2[i] = 'C'; } for( R1=0; R1<Chain[Cn1]->NRes; R1++ ) { Res1 = Chain[Cn1]->Rsd[R1]; if( (!Res1->Inv->NBondDnr && !Res1->Inv->NBondAcc) || ((Cn1 != Cn2) && !Res1->Inv->InterchainHBonds) ) continue; RA = R1+1; R2 = R1+2; Res1m1 = Chain[Cn1]->Rsd[R1-1]; ResA = Chain[Cn1]->Rsd[RA]; Res2 = Chain[Cn1]->Rsd[R2]; if( R2 >= Chain[Cn1]->NRes || Res1->Prop->PhiZn == ERR || Res1->Prop->PsiZn == ERR || Res2->Prop->PhiZn == ERR || Res2->Prop->PsiZn == ERR || ResA->Prop->PhiZn == ERR || ResA->Prop->PsiZn == ERR ) continue; if( Cn1 != Cn2 ) Beg = 0; else Beg = R1+1; for( R3=Beg; R3<Chain[Cn2]->NRes; R3++ ) { /* Process anti-parallel strands */ Res3 = Chain[Cn2]->Rsd[R3]; if( (!Res3->Inv->NBondAcc && !Res3->Inv->NBondDnr ) || ((Cn1 != Cn2) && !Res3->Inv->InterchainHBonds) ) continue; RB = R3-1; R4 = R3-2; Res3p1 = Chain[Cn2]->Rsd[R3+1]; ResB = Chain[Cn2]->Rsd[RB]; Res4 = Chain[Cn2]->Rsd[R4]; if( Cn1 != Cn2 || R3 - R1 >= 3 ) Link(HBond,Chain,Cn1,Cn2,Res1,Res3,Res3,Res1,Res1,Res3, PhiPsiMap,PatN,&PatCntN,"1331",Cmd->Treshold_E1,Cmd,0); if( R2 < Chain[Cn1]->NRes && ((Cn1 != Cn2 && R4 >= 0) || R4-R2 >=2 ) ) Link(HBond,Chain,Cn2,Cn1,Res3,Res1,Res2,Res4,ResB,ResA, PhiPsiMap,PatN,&PatCntN,"3124",Cmd->Treshold_E1,Cmd,0); if( ((Cn1 != Cn2 && RB >= 0 ) || RB-R1 > 4) && ( RA >= Chain[Cn1]->NRes || (Cn1 == Cn2 && R3-RA <= 4 ) || !Link(HBond,Chain,Cn1,Cn2,Res1,Res3,Res3,ResA,NULL,Res3, PhiPsiMap,PatN,&PatCntN,"133A",Cmd->Treshold_E1,Cmd,1)) && ( R1-1 < 0 || !Link(HBond,Chain,Cn1,Cn2,Res1m1,ResB,ResB,Res1,NULL,ResB, PhiPsiMap,PatN,&PatCntN,"1-BB1",Cmd->Treshold_E1,Cmd,1))) Link(HBond,Chain,Cn1,Cn2,Res1,Res3,ResB,Res1,Res1,NULL, PhiPsiMap,PatN,&PatCntN,"13B1",Cmd->Treshold_E1,Cmd,0); if( (RA < Chain[Cn1]->NRes && (Cn1 != Cn2 || R3-RA > 4)) && ( (Cn1 == Cn2 && RB-R1 <= 4 ) || (Cn1 != Cn2 && RB < 0 ) || !Link(HBond,Chain,Cn1,Cn2,Res1,Res3,ResB,Res1,Res1,NULL, PhiPsiMap,PatN,&PatCntN,"13B1",Cmd->Treshold_E1,Cmd,1)) && ( R3+1 >= Chain[Cn2]->NRes || !Link(HBond,Chain,Cn1,Cn2,ResA,Res3p1,Res3,ResA,ResA,NULL, PhiPsiMap,PatN,&PatCntN,"A3+3A",Cmd->Treshold_E1,Cmd,1))) Link(HBond,Chain,Cn1,Cn2,Res1,Res3,Res3,ResA,NULL,Res3, PhiPsiMap,PatN,&PatCntN,"133A",Cmd->Treshold_E1,Cmd,0); /* Process parallel strands */ R4 = R3+2; RB = R3+1; ResB = Chain[Cn2]->Rsd[RB]; Res4 = Chain[Cn2]->Rsd[R4]; if( (Cn1 == Cn2 && abs(R3-R1) <= 3) || R4 >= Chain[Cn2]->NRes ) continue; if( R2 < Chain[Cn1]->NRes && (Cn1 != Cn2 || abs(R2-R3) > 3) ) Link(HBond,Chain,Cn2,Cn1,Res3,Res1,Res2,Res3,Res3,ResA, PhiPsiMap,PatP,&PatCntP,"3123",Cmd->Treshold_E2,Cmd,0); if( R4 < Chain[Cn2]->NRes && (Cn1 != Cn2 || abs(R4-R1) > 3) ) Link(HBond,Chain,Cn1,Cn2,Res1,Res3,Res4,Res1,Res1,ResB, PhiPsiMap,PatP,&PatCntP,"1341",Cmd->Treshold_E2,Cmd,0); } } FilterAntiPar(PatN,PatCntN); FilterPar(PatP,PatCntP); MergePatternsAntiPar(PatN,PatCntN); MergePatternsPar(PatP,PatCntP); if( Cmd->Info ) { PrintPatterns(PatN,PatCntN,Chain,Cn1,Cn2); PrintPatterns(PatP,PatCntP,Chain,Cn1,Cn2); } FillAsnAntiPar(AntiPar1,AntiPar2,Chain,Cn1,Cn2,PatN,PatCntN,Cmd); FillAsnPar(Par1,Par2,Chain,Cn1,Cn2,PatP,PatCntP,Cmd); Bridge(AntiPar1,AntiPar2,Chain,Cn1,Cn2,PatN,PatCntN); Bridge(Par1,Par2,Chain,Cn1,Cn2,PatP,PatCntP); for( i=0; i<Chain[Cn1]->NRes; i++ ) if( AntiPar1[i] == 'N' || Par1[i] == 'P' ) Chain[Cn1]->Rsd[i]->Prop->Asn = 'E'; else if( AntiPar1[i] == 'B' || Par1[i] == 'B' ) Chain[Cn1]->Rsd[i]->Prop->Asn = 'B'; else if( AntiPar1[i] == 'b' || Par1[i] == 'b' ) Chain[Cn1]->Rsd[i]->Prop->Asn = 'b'; for( i=0; i<Chain[Cn2]->NRes; i++ ) if( Chain[Cn2]->Rsd[i]->Prop->Asn == 'E' ) continue; else if( AntiPar2[i] == 'N' || Par2[i] == 'P' ) Chain[Cn2]->Rsd[i]->Prop->Asn = 'E'; else if( AntiPar2[i] == 'B' || Par2[i] == 'B' ) Chain[Cn2]->Rsd[i]->Prop->Asn = 'B'; else if( AntiPar2[i] == 'b' || Par2[i] == 'b' ) Chain[Cn2]->Rsd[i]->Prop->Asn = 'b'; /* for( i=0; i<PatCntN; i++ ) free(PatN[i]); for( i=0; i<PatCntP; i++ ) free(PatP[i]); */ free(PatN); free(PatP); free(AntiPar1); free(Par1); free(AntiPar2); free(Par2); } int Link(HBOND **HBond, CHAIN **Chain, int Cn1, int Cn2, RESIDUE *Res1_1, RESIDUE *Res1_2, RESIDUE *Res2_2, RESIDUE *Res2_1, RESIDUE *CRes1, RESIDUE *CRes2, float **PhiPsiMap, PATTERN **Pattern, int *NumPat, char *Text, float Treshold, COMMAND *Cmd, int Test) { int BondNumber1, BondNumber2, Flag = 0; static char *Result[2] = {" NO \n"," YES \n"}; float Prob1, Prob2, Conf, Coeff; if( (BondNumber1 = FindPolInt(HBond,Res1_1,Res1_2)) == ERR ) return(FAILURE); if( (BondNumber2 = FindPolInt(HBond,Res2_2,Res2_1)) == ERR ) return(FAILURE); if( CRes1 == NULL ) { if( CRes2->Prop->PhiZn == ERR || CRes2->Prop->PsiZn == ERR ) return(FAILURE); Conf = PhiPsiMap[CRes2->Prop->PhiZn][CRes2->Prop->PsiZn]; } else if( CRes2 == NULL ) { if( CRes1->Prop->PhiZn == ERR || CRes1->Prop->PsiZn == ERR ) return(FAILURE); Conf = PhiPsiMap[CRes1->Prop->PhiZn][CRes1->Prop->PsiZn]; } else { if( CRes2->Prop->PhiZn == ERR || CRes2->Prop->PsiZn == ERR || CRes1->Prop->PhiZn == ERR || CRes1->Prop->PsiZn == ERR ) return(FAILURE); Conf = 0.5*(PhiPsiMap[CRes1->Prop->PhiZn][CRes1->Prop->PsiZn]+ PhiPsiMap[CRes2->Prop->PhiZn][CRes2->Prop->PsiZn]); } Coeff = 1+Cmd->C1_E+Cmd->C2_E*Conf; Prob1 = HBond[BondNumber1]->Energy*Coeff; Prob2 = HBond[BondNumber2]->Energy*Coeff; if( Prob1 < Treshold && Prob2 < Treshold ) { if( !Test ) { Pattern[*NumPat] = (PATTERN *)ckalloc(sizeof(PATTERN)); Pattern[*NumPat]->ExistPattern = YES; Pattern[*NumPat]->Hb1 = HBond[BondNumber1]; Pattern[*NumPat]->Hb2 = HBond[BondNumber2]; Pattern[*NumPat]->Nei1 = NULL; Pattern[*NumPat]->Nei2 = NULL; strcpy(Pattern[*NumPat]->Type,Text); (*NumPat)++; } Flag = 1; } if( Cmd->Info && Flag ) { fprintf(stdout,"%s %c: %3s %c: %3s | %c: %3s %c: %3s | ", Text, Chain[Cn1]->Id,Res1_1->PDB_ResNumb, Chain[Cn2]->Id,Res1_2->PDB_ResNumb, Chain[Cn2]->Id,Res2_2->PDB_ResNumb, Chain[Cn1]->Id,Res2_1->PDB_ResNumb); fprintf(stdout,"%8.6f %6.4f | ", Prob1,HBond[BondNumber1]->Energy); fprintf(stdout,"%8.6f %6.4f | ", Prob2,HBond[BondNumber2]->Energy); if( CRes1 != NULL && CRes1->Prop->PhiZn != ERR && CRes1->Prop->PsiZn != ERR ) fprintf(stdout,"%6.4f %2d %2d | ", PhiPsiMap[CRes1->Prop->PhiZn][CRes1->Prop->PsiZn], CRes1->Prop->PhiZn,CRes1->Prop->PsiZn); else fprintf(stdout,"000000 00 00 | "); if( CRes2 != NULL && CRes2->Prop->PhiZn != ERR && CRes2->Prop->PsiZn != ERR ) fprintf(stdout,"%6.4f %2d %2d | ", PhiPsiMap[CRes2->Prop->PhiZn][CRes2->Prop->PsiZn], CRes2->Prop->PhiZn,CRes2->Prop->PsiZn); else fprintf(stdout,"000000 00 00 | "); fprintf(stdout,"%s",Result[Flag]); } return(Flag); } void PrintPatterns(PATTERN **Pat, int NPat, CHAIN **Chain, int Cn1, int Cn2) { register int i; int D1, A1, D2, A2; for( i=0; i<NPat; i++ ) { if( !Pat[i]->ExistPattern ) continue; D1 = Pat[i]->Hb1->Dnr->D_Res; A1 = Pat[i]->Hb1->Acc->A_Res; D2 = Pat[i]->Hb2->Dnr->D_Res; A2 = Pat[i]->Hb2->Acc->A_Res; fprintf(stdout,"%3d %c %c ", i,Pat[i]->Hb1->Dnr->Chain->Id,Pat[i]->Hb2->Dnr->Chain->Id); if( Pat[i]->Hb1->Dnr->Chain->Id == Chain[Cn1]->Id ) fprintf(stdout,"%3s(%3d) %3s(%3d) %3s(%3d) %3s(%3d)", Chain[Cn1]->Rsd[D1]->PDB_ResNumb,D1, Chain[Cn2]->Rsd[A1]->PDB_ResNumb,A1, Chain[Cn2]->Rsd[D2]->PDB_ResNumb,D2, Chain[Cn1]->Rsd[A2]->PDB_ResNumb,A2); else fprintf(stdout,"%3s(%3d) %3s(%3d) %3s(%3d) %3s(%3d)", Chain[Cn2]->Rsd[D1]->PDB_ResNumb,D1, Chain[Cn1]->Rsd[A1]->PDB_ResNumb,A1, Chain[Cn1]->Rsd[D2]->PDB_ResNumb,D2, Chain[Cn2]->Rsd[A2]->PDB_ResNumb,A2); if( Pat[i]->Nei1 != NULL ) { D1 = Pat[i]->Nei1->Hb1->Dnr->D_Res; A1 = Pat[i]->Nei1->Hb1->Acc->A_Res; D2 = Pat[i]->Nei1->Hb2->Dnr->D_Res; A2 = Pat[i]->Nei1->Hb2->Acc->A_Res; fprintf(stdout," N1 %c %c ", Pat[i]->Nei1->Hb1->Dnr->Chain->Id,Pat[i]->Nei1->Hb2->Dnr->Chain->Id); if( Pat[i]->Nei1->Hb1->Dnr->Chain->Id == Chain[Cn1]->Id ) fprintf(stdout,"%3s(%3d) %3s(%3d) %3s(%3d) %3s(%3d) ", Chain[Cn1]->Rsd[D1]->PDB_ResNumb,D1, Chain[Cn2]->Rsd[A1]->PDB_ResNumb,A1, Chain[Cn2]->Rsd[D2]->PDB_ResNumb,D2, Chain[Cn1]->Rsd[A2]->PDB_ResNumb,A2); else fprintf(stdout,"%3s(%3d) %3s(%3d) %3s(%3d) %3s(%3d) ", Chain[Cn2]->Rsd[D1]->PDB_ResNumb,D1, Chain[Cn1]->Rsd[A1]->PDB_ResNumb,A1, Chain[Cn1]->Rsd[D2]->PDB_ResNumb,D2, Chain[Cn2]->Rsd[A2]->PDB_ResNumb,A2); } if( Pat[i]->Nei2 != NULL ) { D1 = Pat[i]->Nei2->Hb1->Dnr->D_Res; A1 = Pat[i]->Nei2->Hb1->Acc->A_Res; D2 = Pat[i]->Nei2->Hb2->Dnr->D_Res; A2 = Pat[i]->Nei2->Hb2->Acc->A_Res; fprintf(stdout," N2 %c %c ", Pat[i]->Nei2->Hb1->Dnr->Chain->Id,Pat[i]->Nei2->Hb2->Dnr->Chain->Id); if( Pat[i]->Nei2->Hb1->Dnr->Chain->Id == Chain[Cn1]->Id ) fprintf(stdout,"%3s(%3d) %3s(%3d) %3s(%3d) %3s(%3d) ", Chain[Cn1]->Rsd[D1]->PDB_ResNumb,D1, Chain[Cn2]->Rsd[A1]->PDB_ResNumb,A1, Chain[Cn2]->Rsd[D2]->PDB_ResNumb,D2, Chain[Cn1]->Rsd[A2]->PDB_ResNumb,A2); else fprintf(stdout,"%3s(%3d) %3s(%3d) %3s(%3d) %3s(%3d) ", Chain[Cn2]->Rsd[D1]->PDB_ResNumb,D1, Chain[Cn1]->Rsd[A1]->PDB_ResNumb,A1, Chain[Cn1]->Rsd[D2]->PDB_ResNumb,D2, Chain[Cn2]->Rsd[A2]->PDB_ResNumb,A2); } fprintf(stdout,"\n"); } } void Bridge(char *Asn1, char *Asn2, CHAIN **Chain, int Cn1, int Cn2, PATTERN **Pat, int NPat) { register int i; int B_Res; for( i=0; i<NPat; i++ ) { if( Pat[i]->Nei1 != NULL || Pat[i]->Nei2 != NULL ) continue; if( !strcmp(Pat[i]->Type,"1331") && ( Cn1 != Cn2 || abs(Pat[i]->Hb1->Dnr->D_Res-Pat[i]->Hb1->Acc->A_Res) >= 3 ) ) { if( Pat[i]->Hb1->Dnr->Chain->Id == Chain[Cn1]->Id ) { if( Asn1[Pat[i]->Hb1->Dnr->D_Res] == 'C' ) Asn1[Pat[i]->Hb1->Dnr->D_Res] = 'B'; if( Asn2[Pat[i]->Hb1->Acc->A_Res] == 'C' ) Asn2[Pat[i]->Hb1->Acc->A_Res] = 'B'; } else { if( Asn2[Pat[i]->Hb1->Dnr->D_Res] == 'C' ) Asn2[Pat[i]->Hb1->Dnr->D_Res] = 'B'; if( Asn1[Pat[i]->Hb1->Acc->A_Res] == 'C' ) Asn1[Pat[i]->Hb1->Acc->A_Res] = 'B'; } } else if( !strcmp(Pat[i]->Type,"3124") && ( Cn1 != Cn2 || (abs(Pat[i]->Hb1->Dnr->D_Res-Pat[i]->Hb1->Acc->A_Res) >= 2 && abs(Pat[i]->Hb2->Dnr->D_Res-Pat[i]->Hb2->Acc->A_Res) >= 2 ) ) ) { if( Pat[i]->Hb1->Dnr->Chain->Id == Chain[Cn1]->Id ) { if( Pat[i]->Hb1->Dnr->D_Res > Pat[i]->Hb2->Acc->A_Res ) B_Res = Pat[i]->Hb1->Dnr->D_Res-1; else B_Res = Pat[i]->Hb1->Dnr->D_Res+1; if( Asn1[B_Res] == 'C' ) Asn1[B_Res] = 'B'; if( Pat[i]->Hb2->Dnr->D_Res > Pat[i]->Hb1->Acc->A_Res ) B_Res = Pat[i]->Hb2->Dnr->D_Res-1; else B_Res = Pat[i]->Hb2->Dnr->D_Res+1; if( Asn2[B_Res] == 'C' ) Asn2[B_Res] = 'B'; } else { if( Pat[i]->Hb1->Dnr->D_Res > Pat[i]->Hb2->Acc->A_Res ) B_Res = Pat[i]->Hb1->Dnr->D_Res-1; else B_Res = Pat[i]->Hb1->Dnr->D_Res+1; if( Asn2[B_Res] == 'C' ) Asn2[B_Res] = 'B'; if( Pat[i]->Hb2->Dnr->D_Res > Pat[i]->Hb1->Acc->A_Res ) B_Res = Pat[i]->Hb2->Dnr->D_Res-1; else B_Res = Pat[i]->Hb2->Dnr->D_Res+1; if( Asn1[B_Res] == 'C' ) Asn1[B_Res] = 'B'; } } else if( ( ( !strcmp(Pat[i]->Type,"3123") || !strcmp(Pat[i]->Type,"1341") ) && ( Cn1 != Cn2 || (abs(Pat[i]->Hb1->Dnr->D_Res-Pat[i]->Hb1->Acc->A_Res) > 3 && abs(Pat[i]->Hb2->Dnr->D_Res-Pat[i]->Hb2->Acc->A_Res) > 3 ) ) ) ) { if( Pat[i]->Hb1->Dnr->Chain->Id == Chain[Cn1]->Id ) { if( Pat[i]->Hb1->Dnr->D_Res == Pat[i]->Hb2->Acc->A_Res ) { if( Asn1[Pat[i]->Hb1->Dnr->D_Res] == 'C' ) Asn1[Pat[i]->Hb1->Dnr->D_Res] = 'B'; if( Pat[i]->Hb2->Dnr->D_Res > Pat[i]->Hb1->Acc->A_Res ) B_Res = Pat[i]->Hb2->Dnr->D_Res-1; else B_Res = Pat[i]->Hb2->Dnr->D_Res+1; if( Asn2[B_Res] == 'C' ) Asn2[B_Res] = 'B'; } else { if( Pat[i]->Hb2->Dnr->D_Res == Pat[i]->Hb1->Acc->A_Res ) if( Asn2[Pat[i]->Hb2->Dnr->D_Res] == 'C' ) Asn2[Pat[i]->Hb2->Dnr->D_Res] = 'B'; if( Pat[i]->Hb1->Dnr->D_Res > Pat[i]->Hb2->Acc->A_Res ) B_Res = Pat[i]->Hb1->Dnr->D_Res-1; else B_Res = Pat[i]->Hb1->Dnr->D_Res+1; if( Asn1[B_Res] == 'C' ) Asn1[B_Res] = 'B'; } } } else if( ( !strcmp(Pat[i]->Type,"13B1") || !strcmp(Pat[i]->Type,"133A") ) && ( Cn1 != Cn2 || (abs(Pat[i]->Hb1->Dnr->D_Res-Pat[i]->Hb1->Acc->A_Res) > 4 && abs(Pat[i]->Hb2->Dnr->D_Res-Pat[i]->Hb2->Acc->A_Res) > 4 ) ) ) { if( Pat[i]->Hb1->Dnr->Chain->Id == Chain[Cn1]->Id ) { if( Pat[i]->Hb1->Dnr->D_Res == Pat[i]->Hb2->Acc->A_Res ) { if( Asn1[Pat[i]->Hb1->Dnr->D_Res] == 'C' ) Asn1[Pat[i]->Hb1->Dnr->D_Res] = 'B'; if( Pat[i]->Hb2->Dnr->D_Res > Pat[i]->Hb1->Acc->A_Res ) B_Res = Pat[i]->Hb2->Dnr->D_Res-1; else B_Res = Pat[i]->Hb2->Dnr->D_Res+1; if( Asn2[B_Res] == 'C' ) Asn2[B_Res] = 'B'; } else { if( Pat[i]->Hb2->Dnr->D_Res == Pat[i]->Hb1->Acc->A_Res ) if( Asn2[Pat[i]->Hb2->Dnr->D_Res] == 'C' ) Asn2[Pat[i]->Hb2->Dnr->D_Res] = 'b'; if( Pat[i]->Hb1->Dnr->D_Res > Pat[i]->Hb2->Acc->A_Res ) B_Res = Pat[i]->Hb1->Dnr->D_Res-1; else B_Res = Pat[i]->Hb1->Dnr->D_Res+1; if( Asn1[B_Res] == 'C' ) Asn1[B_Res] = 'b'; } } } } }
30.246
93
0.536997
[ "3d" ]
e8477f592413aa9d784fac97f940c62b27b74202
2,398
h
C
dsp++/include/dsp++/zeropole.h
andrzejc/dsp-
fd39d2395a37ade36e3b551d261de0177b78296b
[ "MIT" ]
null
null
null
dsp++/include/dsp++/zeropole.h
andrzejc/dsp-
fd39d2395a37ade36e3b551d261de0177b78296b
[ "MIT" ]
null
null
null
dsp++/include/dsp++/zeropole.h
andrzejc/dsp-
fd39d2395a37ade36e3b551d261de0177b78296b
[ "MIT" ]
null
null
null
/*! * @file dsp++/zeropole.h * @brief Tools for converting between DF II, SOS & zero-pole model * @author Andrzej Ciarkowski <mailto:andrzej.ciarkowski@gmail.com> */ #ifndef DSP_ZEROPOLE_H_INCLUDED #define DSP_ZEROPOLE_H_INCLUDED #pragma once #include <dsp++/export.h> #include <complex> #include <functional> namespace dsp { //! @brief Convert filter transfer function to zero-pole representation. //! Conjugate pair elements will always be adjacent to each other in the returned vectors. //! @return system gain k DSPXX_API double tf2zp( unsigned bn, //!< [in] number of numerator coefficients const double b[], //!< [in] numerator coefficients [bn] unsigned an, //!< [in] number of denominator coefficients, may be set to 0 with @p a set to NULL. const double a[], //!< [in] denominator coefficients [an], may be NULL in which case single cefficient 1 will be used. unsigned& zn, //!< [out] length of @p z vector std::complex<double> z[], //!< [out] transfer function zeros, should have space for @p bn - 1 elements [bn - 1] unsigned& pn, //!< [out] length of @p p vector std::complex<double> p[] //!< [out] transfer function poles, should have space for @p an - 1 elements [an - 1], may be NULL if @p a is NULL. ); //! @brief Convert zero-pole filter representation to second-order-sections. //! @return number of second-order-section written, or going to be written to @p num, @p den (ceil(max(zn, pn) / 2)); needs to be multiplied by @p sos_length to get @p num/@p den length //! @throw std::invalid_argument if @p z or @p p are NULL with non-null @p num or @p den DSPXX_API unsigned zp2sos( unsigned zn, //!< [in] length of @p z (zeros) vector const std::complex<double> z[], //!< [in] zeros vector (zn), may be NULL if @p num and @p den set to NULL unsigned pn, //!< [in] length of @p p (poles) vector const std::complex<double> p[], //!< [in] poles vector (pn), may be NULL if @p num and @p den set to NULL double k, //!< [in] system gain double num[], //!< [out] second-order-sections numerators (3 * ceil(max(zn, pn) / 2)), if NULL, this function will only return the number of sections double den[] //!< [out] second-order-sections denominators (3 * ceil(max(zn, pn) / 2)), if NULL, this function will only return the number of sections ); } #endif /* DSP_ZEROPOLE_H_INCLUDED */
52.130435
186
0.670559
[ "vector", "model" ]
e855253ab6b8d193b569d21c1d8f1f939a8cf867
9,095
h
C
Dependencies/OpenTissue/include/OpenTissue/dynamics/mbd/mbd_material_library.h
marizoldi/Hapty
ed9ef1175d755dbca1609dbb27601440220fd98c
[ "MIT" ]
3
2016-01-06T13:43:21.000Z
2016-03-24T08:57:57.000Z
Dependencies/OpenTissue/include/OpenTissue/dynamics/mbd/mbd_material_library.h
marizoldi/Hapty
ed9ef1175d755dbca1609dbb27601440220fd98c
[ "MIT" ]
2
2016-01-06T12:15:43.000Z
2016-01-16T19:57:09.000Z
Dependencies/OpenTissue/include/OpenTissue/dynamics/mbd/mbd_material_library.h
marizoldi/Hapty
ed9ef1175d755dbca1609dbb27601440220fd98c
[ "MIT" ]
null
null
null
#ifndef OPENTISSUE_DYNAMICS_MBD_MBD_MATERIAL_LIBRARY_H #define OPENTISSUE_DYNAMICS_MBD_MBD_MATERIAL_LIBRARY_H // // OpenTissue Template Library // - A generic toolbox for physics-based modeling and simulation. // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. // // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php // #include <OpenTissue/configuration.h> #include <OpenTissue/core/containers/containers_hash_map.h> #include <OpenTissue/utility/utility_map_data_iterator.h> #include <boost/iterator/indirect_iterator.hpp> namespace OpenTissue { namespace mbd { /** * Modelling Material Properties. First one should create some unique positive material indices, <pre> size_t ground_material_idx = 1; size_t wheel_material_idx = 2; </pre> The material index value of zero has special meaning since it is hardwired to the default material properties. The default material properties is used between two objects having both material index zero. Notice that iIf no materials exist with material indices matching those of the rigid bodies then the engine works like the material indices of the rigid bodies were both set to zero. After having defined some material indices one can now assign the materials to the rigid bodies that one like. In our little example we will setup an interesting material between the wheels of vechicle and a ground surface. The material indices should be assigned in a maner similar to this <pre> m_ground.set_material_idx(ground_material_idx); ... m_configuration.add(&m_ground); for(size_t i ....) { m_wheels[i].set_material_idx(wheel_material_idx); ... m_configuration.add(&m_wheels[i]); } </pre> Notice that the material indices are simply assigned using the method set_material_idx. Material indices should be assigned prior to the first run of a simulator. Perferably before adding a rigid body to a configuration. Next one should create the material properties and assign their values. First we need a container for the material properties, <pre> material_type wheel_ground_material; wheel_ground_material.set_material_indices(wheel_material_idx, ground_material_idx); </pre> Following this one can assign how many friction directions that should be used <pre> wheel_ground_material.set_number_of_friction_directions(2); </pre> Next one should decide whether an isotropic or an anisotrpic friction cone should be used. If one choice an isotropic model then the friction coefficient can be set for all friction directions by a single invokation of the method set_friction_coefficient, <pre> real_type my_friction_value = ...; wheel_ground_material.set_friction_coefficient( my_friction_value ); </pre> However, for a wheel like object one would most likely choose an anisotropic model, and the friction coefficients for each friction direction must be specified individually like this, <pre> wheel_ground_material.set_friction_coefficient(0,2.0); wheel_ground_material.set_friction_coefficient(1,5.0); </pre> By default the friction directions of the friction cone is determined by the relative slinding direction of two rigid bodies at a single contact point. This behavior can be turned off and another scheme can be used for determining the friction directions. <pre> wheel_ground_material.set_use_sliding_direction(false); </pre> The technique of using the relative slidning directin takes precedence over any other settings, thus default behavior can be established simply by turning this setting on again. For a tire-ground contact it makes sense to use a prefixed friction direction determined by the forward/backward moving direction of the wheels. First we will tell the material properties to use a prefixed direction, <pre> wheel_ground_material.set_use_prefixed_direction(true); </pre> Following this we have to specify how the prefixed direction should be determined. In our case we want to have the direction prefixed wrt. the local frame of the wheel body. This is done by specifying the material index of the rigid body wrt. which the prefixed direction should be set. <pre> wheel_ground_material.set_prefixed_material_index( wheel_material_idx ); </pre> If one uses values not equal to any of the two rigid bodies (wheel and gound in the case) then the prefixed direction is given wrt. the world coordinate system. Now we can specify the prefixed direction as a local vector in the wheel model frame. <pre> wheel_ground_material.set_prefixed_direction( vector3_type( 0.0, 0.0, 1.0 ) ); </pre> This is advantages because we want the friction coefficient along the rolling direction to be smaller than the friction direction across the rolling direction of the wheel. This will prevent a car model from skiding when making sharp turns. Next one could specify how bouncy a wheel object should be on the ground surface <pre> wheel_ground_material.normal_restitution() = 0.1; </pre> Hereafter one could make the wheel-ground contacts a little soft by adding a sligt amount of regularization, it has the effect of adding a certain amount of damping. <pre> wheel_ground_material.set_normal_regularization(0.1); </pre> In the same go one would most likely also specify the value of the error reduction paramter, <pre> wheel_ground_material.wheel_ground_material.set_error_reduction_parameter(0.1); </pre> This effect will correspond to adding a small spring to prevent penetrations at wheel ground contacts. Overall the error-reduction-parameter and the regularization add some elasticity to the wheel-ground contacts. As a finally step we can add the new material properties to our material library, like this <pre> m_library.add( wheel_ground_material ); </pre> In general one should also setup the default material properties, these properties are used whenever the material liberay can not find a pre-set material properties for a pair of rigid bodies. First we need to obtain access to the defualt material properties, <pre> material_type * default_material = data.m_library.default_material(); </pre> If one has already used the material properties in a previously configuration then one can clear all previously settings by invoking the clear method. <pre> default_material->clear(); </pre> Next one simply set the values as one please, here we simply choice a low friction bouncy type of material. <pre> default_material->set_friction_coefficient(0.25); default_material->normal_restitution() = (0.15); </pre> */ template<typename mbd_types> class MaterialLibrary { public: typedef typename mbd_types::math_policy::real_type real_type; typedef typename mbd_types::math_policy::index_type index_type; typedef typename mbd_types::math_policy::index_type size_type; typedef typename mbd_types::material_type material_type; protected: typedef typename stdext::hash_map<index_type, material_type*> material_ptr_lut_type; typedef OpenTissue::utility::map_data_iterator<typename material_ptr_lut_type::iterator> material_ptr_lut_iterator; public: typedef boost::indirect_iterator<material_ptr_lut_iterator> material_iterator; protected: material_ptr_lut_type m_storage; ///< Storage of material properties. material_type m_default; ///< Default material property public: MaterialLibrary() { add(m_default); } virtual ~MaterialLibrary() { clear(); } public: void add(material_type const & m) { assert(m_storage.find(m.hash_key())==m_storage.end() || !"MaterialLibrary::add(): Material already exist"); m_storage.insert( std::pair<index_type, material_type*>(m.hash_key(), const_cast<material_type*>(&m) ) ); } material_type * get(index_type A, index_type B) { typename material_ptr_lut_type::iterator mit = m_storage.find(material_type::hash_key(A,B)); if(mit==m_storage.end()) return 0; return mit->second; } void clear() { m_storage.clear(); m_default.clear(); add(m_default); } material_type * default_material() { return &m_default; } size_type size_materials() const { return m_storage.size(); } material_iterator material_begin() { return material_iterator( material_ptr_lut_iterator( m_storage.begin() ) );} material_iterator material_end() { return material_iterator( material_ptr_lut_iterator( m_storage.end() ) );} }; } // namespace mbd } // namespace OpenTissue // OPENTISSUE_DYNAMICS_MBD_MBD_MATERIAL_LIBRARY_H #endif
32.482143
124
0.73326
[ "object", "vector", "model" ]
e866e672978fc382505e50da410fef53d7ae6e07
7,295
h
C
GRIT/GLUE/include/glue_compute_neighbors.h
H2020-MSCA-ITN-rainbow/GRIT
1bdfb0735515e9d462214f66b88a71aabf836d76
[ "MIT" ]
4
2018-05-28T19:59:05.000Z
2021-04-23T19:57:26.000Z
GRIT/GLUE/include/glue_compute_neighbors.h
H2020-MSCA-ITN-rainbow/GRIT
1bdfb0735515e9d462214f66b88a71aabf836d76
[ "MIT" ]
18
2018-05-06T21:08:19.000Z
2018-06-11T17:59:00.000Z
GRIT/GLUE/include/glue_compute_neighbors.h
misztal/GRIT
6850fec967c9de7c6c501f5067d021ef5288b88e
[ "MIT" ]
null
null
null
#ifndef GLUE_COMPUTE_NEIGHBORS_H #define GLUE_COMPUTE_NEIGHBORS_H #include <glue_tuple.h> #include <glue_triplet.h> #include <glue_neighbors.h> #include <util_log.h> #include <vector> #include <algorithm> namespace glue { namespace details { inline void print_V2T(Neighbors const & info) { util::Log log; log << "print V2T" << util::Log::newline(); for ( size_t idx = 0u; idx < info.m_V2T.size(); ++idx) { log << "V2T[" << idx << "] = (" << info.m_V2T[ idx ].first << "," << info.m_V2T[ idx ].second << ")" << util::Log::newline(); } } inline void print_offset(Neighbors const & info) { util::Log log; log << "print offset" << util::Log::newline(); for ( size_t idx = 0u; idx < info.m_offset.size(); ++idx) { log << "offset[" << idx << "] = (" << info.m_offset[ idx ] << ")" << util::Log::newline(); } } inline void scan_for_start_offset( unsigned int const & V , Neighbors & info ) { unsigned int const UNASSIGNED = 0xFFFFFFFFu; unsigned int const N = info.m_V2T.size(); info.m_offset.resize( V + 1u); std::fill(info.m_offset.begin(), info.m_offset.end(), UNASSIGNED); info.m_offset[ info.m_V2T[ 0 ].first ] = 0; info.m_offset[ V ] = N; for(unsigned int n = 1u; n < N; ++n) { unsigned int const cur = info.m_V2T[ n ].first; unsigned int const prev = info.m_V2T[ n - 1u ].first; if (prev != cur) { info.m_offset[cur] = n; } } } inline void skip_isolated_nodes( unsigned int const & V , Neighbors & info ) { unsigned int const UNASSIGNED = 0xFFFFFFFFu; for(unsigned int v = 1u; v < V+1u; ++v) { unsigned int const cur = info.m_offset[v]; if (cur == UNASSIGNED ) continue; unsigned int scan = v-1u; unsigned int left = info.m_offset[scan]; while(left == UNASSIGNED ) { info.m_offset[scan] = cur; if(scan==0) // nothing more left to scan break; --scan; left = info.m_offset[scan]; } } } }// end namespace details /** * Compute Neighbors. * This function computes neighborhood lookup information. This is * perhaps better illustrated by a small example. Say one has the * triangle mesh with 6 vertices labeled V = [ 1 2 3 4 5 6]; * * T = [ 1 2 3; 1 3 4; 4 3 5; 3 2 5; 2 6 5 ]; * * For completeness (but not important for finding neighbors) we assume the coordinates * * x = [ 0 2 1 0 2 4]; * y = [ 0 0 1 2 2 1]; * * One may inspect our little example using Matlab and writing triplot(T,x,y). * * The neighborhood information of the vertices are given as arrays of triagnle indexes (into the T-array). * * N1 = [ 1 2 ]; % Triangle neighbors of vertex 1 * N2 = [ 1 4 5 ]; % Triangle neighbors of vertex 2 * N3 = [ 1 2 3 4]; % Triangle neighbors of vertex 3 * N4 = [ 2 3 ]; % Triangle neighbors of vertex 4 * N5 = [ 3 4 5 ]; % Triangle neighbors of vertex 5 * N6 = [ 5 ]; % Triangle neighbors of vertex 6 * * This function essentially computes the Ni's above and stored this information * compactly into the info argument. * * @param triangles An array of all triangles in the mesh * @param V The number of vertices in the mesh (assumed labelled from 0 to V-1) * @param info Upon return this argument holds the computed information. @See glue::Neighbors for details. */ inline void compute_neighbors( std::vector<Triplet> const & triangles , unsigned int const & V , Neighbors & info ) { unsigned int const T = triangles.size(); unsigned int const N = T*3u; info.m_V2T.resize( N ); for ( size_t idx = 0u; idx < T; ++idx) { unsigned int const i = triangles[idx].i; unsigned int const j = triangles[idx].j; unsigned int const k = triangles[idx].k; info.m_V2T[ idx*3 ].first = i; info.m_V2T[ idx*3 + 1 ].first = j; info.m_V2T[ idx*3 + 2 ].first = k; info.m_V2T[ idx*3 ].second = idx; info.m_V2T[ idx*3 + 1 ].second = idx; info.m_V2T[ idx*3 + 2 ].second = idx; } std::sort( info.m_V2T.begin(), info.m_V2T.end() ); details::scan_for_start_offset(V,info); details::skip_isolated_nodes(V,info); } /** * Compute Neighbors. * This function computes neighborhood lookup information. This is * perhaps better illustrated by a small example. Say one has the * triangle mesh with 6 vertices labeled V = [ 1 2 3 4 5 6]; * * T = [ 1 2 3; 1 3 4; 4 3 5; 3 2 5; 2 6 5 ]; * And wish to find neighbors of the edges given by * * E = [ 1 3; 3 5] * * For completeness (but not important for finding neighbors) we assume the coordinates * * x = [ 0 2 1 0 2 4]; * y = [ 0 0 1 2 2 1]; * * One may inspect our little example using Matlab and writing triplot(T,x,y). * * The neighborhood information of the vertices are given as arrays of edge indexes (into the E-array). * * N1 = [ 1 ]; % Edge neighbors of vertex 1 * N2 = [ ]; % Edge neighbors of vertex 2 * N3 = [ 1 2 ]; % Edge neighbors of vertex 3 * N4 = [ ]; % Edge neighbors of vertex 4 * N5 = [ 2 ]; % Edge neighbors of vertex 5 * N6 = [ ]; % Edge neighbors of vertex 6 * * This function essentially computes the Ni's above and stored this information * compactly into the info argument. * * @param edges An array of the set of edges in the mesh one wish to work with (need not be all edges in the mesh but could be a subset) * @param V The number of vertices in the mesh (assumed labelled from 0 to V-1) * @param info Upon return this argument holds the computed information. @See glue::Neighbors for details. */ inline void compute_neighbors( std::vector<Tuple> const & edges , unsigned int const & V , Neighbors & info ) { unsigned int const T = edges.size(); unsigned int const N = T*2u; info.m_V2T.resize( N ); for ( size_t idx = 0u; idx < T; ++idx) { unsigned int const i = edges[idx].i; unsigned int const j = edges[idx].j; info.m_V2T[ idx*2 ].first = i; info.m_V2T[ idx*2 + 1 ].first = j; info.m_V2T[ idx*2 ].second = idx; info.m_V2T[ idx*2 + 1 ].second = idx; } std::sort( info.m_V2T.begin(), info.m_V2T.end() ); details::scan_for_start_offset(V,info); details::skip_isolated_nodes(V,info); } }// namespace glue // GLUE_COMPUTE_NEIGHBORS_H #endif
31.175214
146
0.539136
[ "mesh", "vector" ]
e86fce45ce3a25364415d4fff1d2196fd1fa09b6
2,042
c
C
usr.bin/pascal/pdx/runtime/entry.c
weiss/original-bsd
b44636d7febc9dcf553118bd320571864188351d
[ "Unlicense" ]
114
2015-01-18T22:55:52.000Z
2022-02-17T10:45:02.000Z
usr.bin/pascal/pdx/runtime/entry.c
JamesLinus/original-bsd
b44636d7febc9dcf553118bd320571864188351d
[ "Unlicense" ]
null
null
null
usr.bin/pascal/pdx/runtime/entry.c
JamesLinus/original-bsd
b44636d7febc9dcf553118bd320571864188351d
[ "Unlicense" ]
29
2015-11-03T22:05:22.000Z
2022-02-08T15:36:37.000Z
/*- * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * %sccs.include.redist.c% */ #ifndef lint static char sccsid[] = "@(#)entry.c 8.1 (Berkeley) 06/06/93"; #endif /* not lint */ /* * routines to deal with the entry addresses of blocks */ #include "defs.h" #include "runtime.h" #include "frame.rep" #include "machine.h" #include "process.h" #include "sym.h" #include "source.h" #include "object.h" #include "process/pxinfo.h" #include "process/process.rep" /* * Return the address of the beginning of the procedure/function * associated with the given frame. */ ADDRESS entry(frp) register FRAME *frp; { return(frp->blockp - 2 - ENDOFF); } /* * Find the entry address of the caller of the current block. * This is only called in connection with breakpoints. * * This routine assumes it is at the very beginning of the block. */ ADDRESS caller_addr() { FRAME *frp; if ((frp = curframe()) == NIL) { panic("caller_addr(main program)"); } frp = nextframe(frp); if (frp == NIL) { return(codeloc(program)); } else { return(entry(frp)); } } /* * Find the return address of the current procedure/function. * * There are two special cases: * * we're right at the beginning of the main program * we're right at the beginning of some procedure or function * * The first one is handled by returning the last instruction in * the object code. In the second case, we get the return address * directly from the process' stack. */ ADDRESS return_addr() { ADDRESS addr; FRAME *frp, frame; if (pc == codeloc(program)) { addr = lastaddr(); } else { frp = curframe(); if (frp == NIL) { dread(&frame, (ADDRESS) process->sp, sizeof(FRAME)); addr = frame.save_pc - ENDOFF; } else { addr = frp->save_pc; } } return addr; } /* * Calculate the entry address for a procedure or function parameter, * given the address of the descriptor. */ ADDRESS fparamaddr(a) ADDRESS a; { ADDRESS r; dread(&r, a, sizeof(r)); return (r - ENDOFF); }
19.447619
69
0.668952
[ "object" ]
e8711e6cbf42a46cb549e72f1bff6abcd7c76d75
2,619
h
C
src/data/Cluster.h
kaszarek/drivenowandthen
9632ae308544f2833a2de9b7d1a5bdb7649c2930
[ "MIT" ]
null
null
null
src/data/Cluster.h
kaszarek/drivenowandthen
9632ae308544f2833a2de9b7d1a5bdb7649c2930
[ "MIT" ]
null
null
null
src/data/Cluster.h
kaszarek/drivenowandthen
9632ae308544f2833a2de9b7d1a5bdb7649c2930
[ "MIT" ]
null
null
null
/* * Cluster.h * * Created on: 30 lis 2015 * Author: Kamil */ #ifndef CLUSTER_H_ #define CLUSTER_H_ #include <QObject> #include "src/interfaces/IPointOnMap.h" /*! * Container for a points on a map. It generated clusters with provided algorithm */ class Cluster: public IPointOnMap { Q_OBJECT public: Cluster(QObject* parent = 0); virtual ~Cluster(); /*! * Adds cluster as a child to this * * \param child Cluster object to be added */ void addChild(Cluster * child); /*! * Sets children clusters on this * * \param children List of clusters to be added */ void setChildren(QList<Cluster*> &children); /*! * Gets content from a specified depth, NOT clusters * * \param depth Depth that content will be returned from * \return List of objects a the given depths */ QList<IPointOnMap*> getContentAtDepth(int depth); /*! * Gets amount of content under this cluster * * \return Amount of content. */ int getContentCountBelowCluster(); /*! * Adds content to this cluster * * \param content QObject to be added */ void addContent(IPointOnMap* content); /*! * Gets clusters at a given depth * * \param depth Depth clusters will be returned from. Starts from 0 - top/root cluster * \return List of clusters */ QList<Cluster*> getClustersAtDepth(int depth); /*! * Gets lists of clusters without children which fall in the coordinates limits. * * \param east The most eastern coordinate to consider. * \param west The most western coordinate to consider. * \param south The most southern coordinate to consider. * \param north The most northern coordinate to consider. * * \return List of clusters */ QList<Cluster*> getAllContentFromBoundriesBox(double westBorder, double eastBorder, double southBorder, double northBorder); /*! * Gets amount of clusters at a given level. * * \param depth Depth to consider. * \return Amount of clusters. */ int getClustersCountAtLevel(int depth); /*! * Gets number of children. * * \return Number of children. */ int getChildrenCount(){ return m_clustersBelow.length(); } /*! * Gets maximum available depth */ int getMaxAvailableDepth(); private: double m_minLat; double m_maxLat; double m_minLon; double m_maxLon; QList<Cluster*> m_clustersBelow; QList<IPointOnMap*> m_pointsInCluster; }; #endif /* CLUSTER_H_ */
24.707547
128
0.63803
[ "object" ]
e87477a8bb0fbe6d9449ff330491ddbdbc250359
1,339
h
C
RStein.AsyncCpp/Schedulers/SimpleThreadPool.h
renestein/Rstein.AsyncCpp
8f020ad271250479f600d7e2e862f701472c3a48
[ "MIT" ]
41
2020-05-04T05:58:24.000Z
2022-03-25T07:21:45.000Z
RStein.AsyncCpp/Schedulers/SimpleThreadPool.h
renestein/Rstein.AsyncCpp
8f020ad271250479f600d7e2e862f701472c3a48
[ "MIT" ]
15
2021-02-03T16:05:19.000Z
2021-08-17T17:09:28.000Z
RStein.AsyncCpp/Schedulers/SimpleThreadPool.h
renestein/Rstein.AsyncCpp
8f020ad271250479f600d7e2e862f701472c3a48
[ "MIT" ]
4
2020-05-04T15:41:37.000Z
2021-08-24T00:59:18.000Z
#pragma once #include <functional> #include <queue> #include <mutex> #include <condition_variable> #include <vector> #include <thread> #include <atomic> namespace RStein::AsyncCpp::Schedulers { //TODO: Better Lock free + work stealing ThreadPool //TODO: Start/Stop is not thread safe. class SimpleThreadPool { public: enum class ThreadPoolState { Created, Started, Stopped }; using WorkItem = std::function<void()>; SimpleThreadPool(); SimpleThreadPool(unsigned int numberOfThreads); virtual ~SimpleThreadPool(); SimpleThreadPool(const SimpleThreadPool& other) = delete; SimpleThreadPool(SimpleThreadPool&& other) = delete; SimpleThreadPool& operator=(const SimpleThreadPool& other) = delete; SimpleThreadPool& operator=(SimpleThreadPool&& other) = delete; void Start(); void Stop(); void EnqueueItem(WorkItem originalFunction); unsigned GetNumberOfThreads() const; ThreadPoolState GetThreadPoolState() const; private: std::queue<WorkItem> _innerQueue; std::mutex _lockRoot; std::condition_variable _queueConditionVariable; ThreadPoolState _threadPoolState; unsigned int _numberOfThreads; std::vector<std::thread> _threads; std::atomic<bool> _quitRequest; void throwInvalidThreadPoolState(); }; }
24.345455
72
0.713219
[ "vector" ]
e875613f6b371ef774ed7b4ca52e96e805156b79
2,255
h
C
main/lucid/rm/GA.h
irumsey/ijrumsey.com
3dcf909eada5a09d39e6bf89a1f0bf1fa7328789
[ "MIT" ]
null
null
null
main/lucid/rm/GA.h
irumsey/ijrumsey.com
3dcf909eada5a09d39e6bf89a1f0bf1fa7328789
[ "MIT" ]
null
null
null
main/lucid/rm/GA.h
irumsey/ijrumsey.com
3dcf909eada5a09d39e6bf89a1f0bf1fa7328789
[ "MIT" ]
null
null
null
#pragma once #include <vector> #include <lucid/core/Types.h> #include <lucid/core/Error.h> #include <lucid/core/Bits.h> namespace lucid { namespace rm { /// Genome /// /// template<class Gene, class Measure = float32_t, class Chromosome = std::vector<Gene> > struct Genome { typedef Gene gene_t; typedef Measure measure_t; typedef Chromosome chromosome_t; typedef Genome<Gene, Measure, Chromosome> self_t; Chromosome chromosome; Measure fitness = Measure(); }; /// distance /// /// computes the hamming distance between two chromosomes template<class Iter1, class Iter2> inline size_t distance(Iter1 src1, Iter1 const &&end1, Iter2 src2) { LUCID_VALIDATE(src1 <= end1, "invalid source range for distance"); size_t dist = 0; for (; src1 != end1; ++src1, ++src2) dist += core::bits::hamming_distance(*src1, *src2); return dist; } /// crossover_copy /// /// generic crossover operation in the "stl style" template<class InIt1, class InIt2, class OutIt1, class OutIt2, class Pred> inline void crossover_copy ( InIt1 src1, InIt1 const &&end1, InIt2 src2, OutIt1 dst1, OutIt2 dst2, Pred pred ) { LUCID_VALIDATE(src1 <= end1, "invalid source range for crossover_copy"); for (; src1 != end1; ++src1, ++src2, ++dst1, ++dst2) { if (pred(src1, src2)) { *dst1 = *src2; *dst2 = *src1; } else { *dst1 = *src1; *dst2 = *src2; } } } /// crossover /// /// helper for chromosome specific crossover template<class Gene, class Measure, class Chromosome, class Pred> inline void crossover( Genome<Gene, Measure, Chromosome> const &src1, Genome<Gene, Measure, Chromosome> const &src2, Genome<Gene, Measure, Chromosome> &dst1, Genome<Gene, Measure, Chromosome> &dst2, Pred pred ) { LUCID_VALIDATE(src1.chromosome.size() == src2.chromosome.size(), "chromosome size mismatch"); LUCID_VALIDATE(src1.chromosome.size() == dst1.chromosome.size(), "chromosome size mismatch"); LUCID_VALIDATE(src1.chromosome.size() == dst2.chromosome.size(), "chromosome size mismatch"); crossover_copy( src1.chromosome.begin(), src1.chromosome.end(), src2.chromosome.begin(), dst1.chromosome.begin(), dst2.chromosome.begin(), pred ); } } // rm } // lucid
24.51087
102
0.678936
[ "vector" ]
e876882f9a5fec07491fe05ae20e9a7c18735e74
162
h
C
faux/vec/private.h
npobaum/faux
4c2c1e3fc7c5d3206a1d9582579e99cea4147917
[ "BSD-3-Clause" ]
1
2021-01-01T02:54:30.000Z
2021-01-01T02:54:30.000Z
faux/vec/private.h
npobaum/faux
4c2c1e3fc7c5d3206a1d9582579e99cea4147917
[ "BSD-3-Clause" ]
null
null
null
faux/vec/private.h
npobaum/faux
4c2c1e3fc7c5d3206a1d9582579e99cea4147917
[ "BSD-3-Clause" ]
null
null
null
#include "faux/vec.h" struct faux_vec_s { void *data; size_t len; size_t item_size; faux_vec_kcmp_fn kcmpFn; // Function to compare key and vector's item };
18
70
0.734568
[ "vector" ]
e877c8250275c78c03862c75f57d9a0dc592139f
4,257
h
C
call/adaptation/resource_adaptation_processor.h
hjybdrs/webrtcRepo
9427b51d6ff50af73c217cb725b1c59b9d701796
[ "BSD-3-Clause" ]
null
null
null
call/adaptation/resource_adaptation_processor.h
hjybdrs/webrtcRepo
9427b51d6ff50af73c217cb725b1c59b9d701796
[ "BSD-3-Clause" ]
null
null
null
call/adaptation/resource_adaptation_processor.h
hjybdrs/webrtcRepo
9427b51d6ff50af73c217cb725b1c59b9d701796
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright 2020 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef CALL_ADAPTATION_RESOURCE_ADAPTATION_PROCESSOR_H_ #define CALL_ADAPTATION_RESOURCE_ADAPTATION_PROCESSOR_H_ #include <memory> #include <vector> #include "absl/types/optional.h" #include "api/rtp_parameters.h" #include "api/video/video_frame.h" #include "api/video/video_stream_encoder_observer.h" #include "call/adaptation/resource.h" #include "call/adaptation/resource_adaptation_processor_interface.h" #include "call/adaptation/video_source_restrictions.h" #include "call/adaptation/video_stream_adapter.h" #include "call/adaptation/video_stream_input_state.h" #include "call/adaptation/video_stream_input_state_provider.h" namespace webrtc { class ResourceAdaptationProcessor : public ResourceAdaptationProcessorInterface, public ResourceListener { public: ResourceAdaptationProcessor( VideoStreamInputStateProvider* input_state_provider, VideoStreamEncoderObserver* encoder_stats_observer); ~ResourceAdaptationProcessor() override; // ResourceAdaptationProcessorInterface implementation. DegradationPreference degradation_preference() const override; DegradationPreference effective_degradation_preference() const override; void StartResourceAdaptation() override; void StopResourceAdaptation() override; void AddAdaptationListener( ResourceAdaptationProcessorListener* adaptation_listener) override; void AddResource(Resource* resource) override; void SetDegradationPreference( DegradationPreference degradation_preference) override; void SetIsScreenshare(bool is_screenshare) override; void ResetVideoSourceRestrictions() override; // ResourceListener implementation. // Triggers OnResourceUnderuse() or OnResourceOveruse(). ResourceListenerResponse OnResourceUsageStateMeasured( const Resource& resource) override; // May trigger 1-2 adaptations. It is meant to reduce resolution - useful if a // frame was dropped due to its size - but if you look at the implementation // you'll find that this is not guaranteed. It could adapt frame rate, which // does not address the issue. // TODO(hbos): Can we replace this by something which actually satisfies the // resolution constraints, or get rid of it altogether? void TriggerAdaptationDueToFrameDroppedDueToSize( const Resource& reason_resource); private: bool HasSufficientInputForAdaptation( const VideoStreamInputState& input_state) const; // Performs the adaptation by getting the next target, applying it and // informing listeners of the new VideoSourceRestriction and adaptation // counters. void OnResourceUnderuse(const Resource& reason_resource); ResourceListenerResponse OnResourceOveruse(const Resource& reason_resource); // Needs to be invoked any time |degradation_preference_| or |is_screenshare_| // changes to ensure |effective_degradation_preference_| is up-to-date. void MaybeUpdateEffectiveDegradationPreference(); // If the filtered source restrictions are different than // |last_reported_source_restrictions_|, inform the listeners. void MaybeUpdateVideoSourceRestrictions(const Resource* reason); // Input and output. VideoStreamInputStateProvider* const input_state_provider_; VideoStreamEncoderObserver* const encoder_stats_observer_; std::vector<ResourceAdaptationProcessorListener*> adaptation_listeners_; std::vector<Resource*> resources_; // Adaptation strategy settings. DegradationPreference degradation_preference_; DegradationPreference effective_degradation_preference_; bool is_screenshare_; // Responsible for generating and applying possible adaptations. const std::unique_ptr<VideoStreamAdapter> stream_adapter_; VideoSourceRestrictions last_reported_source_restrictions_; }; } // namespace webrtc #endif // CALL_ADAPTATION_RESOURCE_ADAPTATION_PROCESSOR_H_
42.148515
80
0.802443
[ "vector" ]
e8848e7ac0a6fc0497f05d7c64a73f319606af27
7,915
h
C
old/shaders/Lighting/include/Defines.h
clayne/Skyrim-SE-Shader-Tools
b54d184a5c3acc25c60e6666a46c68b09a3759ed
[ "MIT" ]
null
null
null
old/shaders/Lighting/include/Defines.h
clayne/Skyrim-SE-Shader-Tools
b54d184a5c3acc25c60e6666a46c68b09a3759ed
[ "MIT" ]
null
null
null
old/shaders/Lighting/include/Defines.h
clayne/Skyrim-SE-Shader-Tools
b54d184a5c3acc25c60e6666a46c68b09a3759ed
[ "MIT" ]
1
2021-03-12T20:54:21.000Z
2021-03-12T20:54:21.000Z
// Skyrim Special Edition - BSLightingShader Defines // All the groundwork for this can be found in Nukem's project here: https://github.com/Nukem9/SkyrimSETest/tree/master/skyrim64_test/src/patches/TES/BSShader/Shaders // techniques // 0 None // 1 Envmap - #define ENVMAP // 2 Glowmap - #define GLOWMAP // 3 Parallax - #define PARALLAX // 4 Facegen - #define FACEGEN (Face Tint) // 5 FacegenRGBTint - #define FACEGEN_RGB_TINT (Skin Tint) // 6 Hair - #define HAIR (Hair Tint) // 7 ParallaxOcc - #define PARALLAX_OCC // 8 MTLand - #define MULTI_TEXTURE, #define LANDSCAPE // 9 LODLand - #define LODLANDSCAPE // 10 Unknown - Unused (SNOW) // 11 MultiLayerParallax - #define MULTI_LAYER_PARALLAX, #define ENVMAP // 12 Tree - #define TREE_ANIM // 13 LODObj - #define LODOBJECTS // 14 MultiIndexTriShapeSnow - #define MULTI_INDEX, #define SPARKLE // 15 LODObjHD - #define LODOBJECTSHD // 16 Eye - #define EYE // 17 Unknown - Unused (#define CLOUD, #define INSTANCED) // 18 LODLandNoise - #define LODLANDSCAPE, #define LODLANDNOISE // 19 MTLandLODBlend - #define MULTI_TEXTURE, #define LANDSCAPE, #define LOD_LAND_BLEND // flags // 1<<0 Vc - #define VC // 1<<1 Sk - #define SKINNED // 1<<2 Msn - #define MODELSPACENORMALS // 1<<9 Spc - #define SPECULAR // 1<<10 Sss - #define SOFT_LIGHTING // 1<<11 Rim - #define RIM_LIGHTING // 1<<12 Bk - #define BACK_LIGHTING // 1<<13 Sh - #define SHADOW_DIR // 1<<14 DfSh - #define DEFSHADOW // 1<<15 Projuv - #define PROJECTED_UV // 1<<15 DwDecals - #define DEPTH_WRITE_DECALS (HAIR technique only) // 1<<16 (None) - #define ANISO_LIGHTING // 1<<17 Aspc - #define AMBIENT_SPECULAR // 1<<18 Wmap - #define WORLD_MAP // 1<<19 BaseSnow - #define BASE_OBJECT_IS_SNOW // 1<<20 Atest - #define DO_ALPHA_TEST // 1<<21 Snow - #define SNOW // 1<<22 (None) - #define CHARACTER_LIGHT // 1<<23 (Aam) - #define ADDITIONAL_ALPHA_MASK // check for repeated techniques #undef HAS_TECHNIQUE #undef TECHNIQUE_IS_ENVMAP #undef TECHNIQUE_IS_MTLAND #undef TECHNIQUE_IS_LODLANDSCAPE #if defined(ENVMAP) #define HAS_TECHNIQUE #define TECHNIQUE_IS_ENVMAP #endif #if defined(GLOWMAP) #if defined(HAS_TECHNIQUE) #error multiple techniques defined #endif #define HAS_TECHNIQUE #endif #if defined(PARALLAX) #if defined(HAS_TECHNIQUE) #error multiple techniques defined #endif #define HAS_TECHNIQUE #endif #if defined(FACEGEN) #if defined(HAS_TECHNIQUE) #error multiple techniques defined #endif #define HAS_TECHNIQUE #endif #if defined(FACEGEN_RGB_TINT) #if defined(HAS_TECHNIQUE) #error multiple techniques defined #endif #define HAS_TECHNIQUE #endif #if defined(HAIR) #if defined(HAS_TECHNIQUE) #error multiple techniques defined #endif #define HAS_TECHNIQUE #endif #if defined(PARALLAX_OCC) #if defined(HAS_TECHNIQUE) #error multiple techniques defined #endif #define HAS_TECHNIQUE #endif #if defined(MULTI_TEXTURE) && defined(LANDSCAPE) #if defined(HAS_TECHNIQUE) #error multiple techniques defined #endif #define HAS_TECHNIQUE #define TECHNIQUE_IS_MTLAND #endif #if (defined(MULTI_TEXTURE) && !defined(LANDSCAPE)) || (!defined(MULTI_TEXTURE) && defined(LANDSCAPE)) #error MULTI_TEXTURE and LANDSCAPE must be used together #endif #if defined(LODLANDSCAPE) #if defined(HAS_TECHNIQUE) #error multiple techniques defined #endif #define HAS_TECHNIQUE #define TECHNIQUE_IS_LODLANDSCAPE #endif #if defined(MULTI_LAYER_PARALLAX) #if defined(HAS_TECHNIQUE) && !defined(TECHNIQUE_IS_ENVMAP) #error multiple techniques defined #endif #if !defined(TECHNIQUE_IS_ENVMAP) #error MULTI_LAYER_PARALLAX requires ENVMAP to also be defined #endif #define HAS_TECHNIQUE #endif #if defined(TREE_ANIM) #if defined(HAS_TECHNIQUE) #error multiple techniques defined #endif #define HAS_TECHNIQUE #endif #if defined(LODOBJECTS) #if defined(HAS_TECHNIQUE) #error multiple techniques defined #endif #define HAS_TECHNIQUE #endif #if defined(MULTI_INDEX) && defined(SPARKLE) #if defined(HAS_TECHNIQUE) #error multiple techniques defined #endif #define HAS_TECHNIQUE #endif #if (defined(MULTI_INDEX) && !defined(SPARKLE)) || (!defined(MULTI_INDEX) && defined(SPARKLE)) #error MULTI_INDEX and SPARKLE must be used together #endif #if defined(LODOBJECTSHD) #if defined(HAS_TECHNIQUE) #error multiple techniques defined #endif #define HAS_TECHNIQUE #endif #if defined(EYE) #if defined(HAS_TECHNIQUE) #error multiple techniques defined #endif #define HAS_TECHNIQUE #endif #if defined(LODLANDNOISE) #if defined(HAS_TECHNIQUE) && !defined(TECHNIQUE_IS_LODLANDSCAPE) #error multiple techniques defined #endif #if !defined(TECHNIQUE_IS_LODLANDSCAPE) #error LODLANDNOISE requires LODLANDSCAPE to also be defined #endif #define HAS_TECHNIQUE #endif #if defined(LOD_LAND_BLEND) #if defined(HAS_TECHNIQUE) && !defined(TECHNIQUE_IS_MTLAND) #error multiple techniques defined #endif #if !defined(TECHNIQUE_IS_MTLAND) #error LOD_LAND_BLEND requires MULTI_TEXTURE and LANDSCAPE to also be defined #endif #define HAS_TECHNIQUE #endif // guard against incompatible flags #if defined(MODELSPACENORMALS) #if defined(PARALLAX) || defined(PARALLAX_OCC) || defined(MULTI_LAYER_PARALLAX) #error PARALLAX techniques are incompatible with MODELSPACENORMALS because the vertex shader does not provide a tangent space conversion matrix #endif #if defined(MULTI_TEXTURE) #error MULTI_TEXTURE techniques are incompatible with MODELSPACENORMALS due to re-use of texture slot 2 #endif #if defined(ANISO_LIGHTING) #error ANISO_LIGHTING flag is incompatible with MODELSPACENORMALS because it requires access to the vertex normal #endif #endif #if defined(MULTI_TEXTURE) && (defined(SOFT_LIGHTING) || defined(RIM_LIGHTING)) #error MULTI_TEXTURE technique incompatible with SOFT_LIGHTING and RIM_LIGHTING flags due to re-use of texture slot 12 #endif #if defined(MULTI_TEXTURE) && defined(BACK_LIGHTING) #error MULTI_TEXTURE technique incompatible with BACK_LIGHTING flag due to re-use of texture slot 9 #endif #if defined(PROJECTED_UV) #if defined(PARALLAX) #error PARALLAX technique is incompatible with PROJETED_UV flag due to re-use of texture slot 3 #endif #if defined(MULTI_LAYER_PARALLAX) #error MULTI_LAYER_PARALLAX technique is incompatible with PROJECTED_UV flag due to re-use of texture slot 8 #endif #if defined(FACEGEN) #error FACEGEN technique is incompatible with PROJECTED_UV flag due to re-use of texture slot 3 #endif #if defined(MULTI_TEXTURE) #error MULTI_TEXTURE technique is incompatible with PROJECTED_UV flag due to re-use of multiple texture slots #endif #endif #if defined(DEPTH_WRITE_DECALS) #if !defined(HAIR) #error DEPTH_WRITE_DECALS flag is only compatible with the HAIR technique #endif #if defined(PIXELSHADER) && !defined(DO_ALPHA_TEST) #error DEPTH_WRITE_DECALS requires the DO_ALPHA_TEST flag when compiling the pixel shader #endif #endif // set some extra defines to avoid large if statements in the main shader // note: in the game's renderer PARALLAX, PARALLAXOCC, FACEGEN, and FACEGEN_RGB_TINT do not update the eye (view) position so this output will be wrong unless specular is also enabled // in vertex shader RIM_LIGHTING and AMBIENT_SPECULAR force SPECULAR flag, creating the view direction vector, even though those flags aren't used to generate vertex shader combinations #if defined(SPECULAR) || defined(RIM_LIGHTING) || defined(AMBIENT_SPECULAR) || defined(ENVMAP) || defined(PARALLAX) || defined(PARALLAX_OCC) || defined(FACEGEN) || defined(FACEGEN_RGB_TINT) || defined(MULTI_LAYER_PARALLAX) || defined(EYE) #define HAS_VIEW_DIRECTION_VECTOR_OUTPUT #endif #if defined(SKINNED) || defined(ENVMAP) || defined(EYE) || defined(MULTI_LAYER_PARALLAX) #define DRAW_IN_WORLDSPACE #endif // this transform is primarly used to take normals into common space // since common space is model space by default, its not present if there are model space normals and the shader is not drawing in world space #if defined(DRAW_IN_WORLDSPACE) || !defined(MODELSPACENORMALS) #define HAS_COMMON_TRANSFORM #endif
31.40873
238
0.787997
[ "vector", "model", "transform" ]
95487853d33ebba931634baf693a8c8b3c7a0127
1,549
h
C
include/pr/collision/todo/shapetriangle.h
psryland/rylogic_code
f79e471fe0d6714c5e0cf8385ddc2a88ab2e082b
[ "CNRI-Python" ]
2
2020-11-11T16:19:04.000Z
2021-01-19T01:53:29.000Z
include/pr/collision/todo/shapetriangle.h
psryland/rylogic_code
f79e471fe0d6714c5e0cf8385ddc2a88ab2e082b
[ "CNRI-Python" ]
1
2020-07-27T09:00:21.000Z
2020-07-27T10:58:10.000Z
include/pr/physics/shape/shapetriangle.h
psryland/rylogic_code
f79e471fe0d6714c5e0cf8385ddc2a88ab2e082b
[ "CNRI-Python" ]
1
2021-04-04T01:39:55.000Z
2021-04-04T01:39:55.000Z
//********************************************* // Physics engine // Copyright (c) Rylogic Ltd 2006 //********************************************* #pragma once #ifndef PR_PHYSICS_SHAPE_TRIANGLE_H #define PR_PHYSICS_SHAPE_TRIANGLE_H #include "pr/physics/shape/shape.h" namespace pr { namespace ph { struct ShapeTriangle { Shape m_base; m4x4 m_v; // <x,y,z> = verts of the triangle, w = normal. Cross3(w, y-x) should point toward the interior of the triangle enum { EShapeType = EShape_Triangle }; static ShapeTriangle make(v4 const& a, v4 const& b, v4 const& c, const m4x4& shape_to_model, MaterialId material_id, uint flags) { ShapeTriangle s; s.set(a, b, c, shape_to_model, material_id, flags); return s; } ShapeTriangle& set (v4 const& a, v4 const& b, v4 const& c, const m4x4& shape_to_model, MaterialId material_id, uint flags); operator Shape const&() const { return m_base; } operator Shape& () { return m_base; } }; // Shape functions BBox& CalcBBox (ShapeTriangle const& shape, BBox& bbox); MassProperties& CalcMassProperties (ShapeTriangle const& shape, float density, MassProperties& mp); m3x4 CalcInertiaTensor (ShapeTriangle const& shape); void ShiftCentre (ShapeTriangle& shape, v4& shift); v4 SupportVertex (ShapeTriangle const& shape, v4 const& direction, std::size_t hint_vert_id, std::size_t& sup_vert_id); void ClosestPoint (ShapeTriangle const& shape, v4 const& point, float& distance, v4& closest); } } #endif
39.717949
215
0.654616
[ "shape" ]
954c8c428609c5c0b4b12e65340cdde59f770f76
528
h
C
ShapeDisplay.h
sergrt/Gen61850Sv
ac4461ee0c755553e82be2513f635a6f92fb6f5d
[ "Apache-2.0" ]
6
2017-08-29T08:35:32.000Z
2021-07-10T07:56:56.000Z
ShapeDisplay.h
sergrt/Gen61850Sv
ac4461ee0c755553e82be2513f635a6f92fb6f5d
[ "Apache-2.0" ]
null
null
null
ShapeDisplay.h
sergrt/Gen61850Sv
ac4461ee0c755553e82be2513f635a6f92fb6f5d
[ "Apache-2.0" ]
4
2016-04-11T05:14:54.000Z
2022-01-20T16:16:30.000Z
#ifndef SHAPEDISPLAY_H #define SHAPEDISPLAY_H #include <QWidget> #include "ui_ShapeDisplay.h" class ShapeDisplay : public QWidget { Q_OBJECT public: ShapeDisplay(QWidget *parent = 0); ~ShapeDisplay(); enum DISPLAY_SHAPE { DISPLAY_SHAPE_NONE = 0, DISPLAY_SHAPE_SIN, DISPLAY_SHAPE_TRIANGLE, DISPLAY_SHAPE_SAW, DISPLAY_SHAPE_MEANDER }; void setShape(DISPLAY_SHAPE shape); private: Ui::ShapeDisplay ui; }; #endif // SHAPEDISPLAY_H
18.857143
40
0.651515
[ "shape" ]
954e5ef4c9bda84b01d0498e0da7280079dc7bd4
2,225
c
C
src/maze.c
adamples/maze_generator
5d3ad60238027fc935c2aa0ed699de47ab9ae339
[ "MIT" ]
2
2022-03-12T02:41:17.000Z
2022-03-12T04:31:16.000Z
src/maze.c
adamples/maze_generator
5d3ad60238027fc935c2aa0ed699de47ab9ae339
[ "MIT" ]
null
null
null
src/maze.c
adamples/maze_generator
5d3ad60238027fc935c2aa0ed699de47ab9ae339
[ "MIT" ]
null
null
null
/* Copyright (c) 2018 Adam Ples * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <stdlib.h> #include <stdio.h> #include <inttypes.h> #include <errno.h> #include <time.h> #include "model.h" #include "renderer.h" #include "prims_maze.h" int error(const char *message) { fprintf(stderr, "maze: %s\n", message); fprintf(stderr, "usage: maze width height [ random_seed ]\n"); return -1; } int main(int argc, char *argv[]) { maze_t *maze; int random_seed; if (argc < 3 || argc > 4) { return error("Wrong number of arguments"); } int width = strtoimax(argv[1], NULL, 10); if (errno != 0 || width < 2) { return error("Invalid width value"); } int height = strtoimax(argv[2], NULL, 10); if (errno != 0 || height < 2) { return error("Invalid height value"); } if (argc == 4) { random_seed = strtoimax(argv[3], NULL, 10); if (errno != 0) { return error("Invalid random seed value"); } } else { random_seed = time(NULL); } printf("Random seed is %d\n\n", random_seed); srand(random_seed); maze = maze_create(width, height); prims_maze_generate(maze); render_maze(maze); maze_free(&maze); return 0; }
26.176471
80
0.688989
[ "model" ]
95500b7f67cce72d5d39753c45240eb3097ae2e7
16,930
c
C
mex/include/sisl-4.5.0/src/s1992.c
sangyoonHan/extern
a3c874538a7262b895b60d3c4d493e5b34cf81f8
[ "BSD-2-Clause" ]
null
null
null
mex/include/sisl-4.5.0/src/s1992.c
sangyoonHan/extern
a3c874538a7262b895b60d3c4d493e5b34cf81f8
[ "BSD-2-Clause" ]
null
null
null
mex/include/sisl-4.5.0/src/s1992.c
sangyoonHan/extern
a3c874538a7262b895b60d3c4d493e5b34cf81f8
[ "BSD-2-Clause" ]
null
null
null
//=========================================================================== // SISL - SINTEF Spline Library, version 4.5.0. // Definition and interrogation of NURBS curves and surfaces. // // Copyright (C) 2000-2005, 2010 SINTEF ICT, Applied Mathematics, Norway. // // 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 version 2 of the License. // // 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., // 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // Contact information: E-mail: tor.dokken@sintef.no // SINTEF ICT, Department of Applied Mathematics, // P.O. Box 124 Blindern, // 0314 Oslo, Norway. // // Other licenses are also available for this software, notably licenses // for: // - Building commercial software. // - Building software whose source code you wish to keep private. //=========================================================================== #include "sisl-copyright.h" /* * * $Id: s1992.c,v 1.2 2001-03-19 15:58:59 afr Exp $ * */ #define S1992 #include "sislP.h" /* * Forward declarations. * --------------------- */ #if defined(SISLNEEDPROTOTYPES) static void s1992_s9mbox3(double [],int,double [],double []); static void s1992_s9mbox2(double [],int,double [],double []); static void s1992_s9mbox(double [],int,int idim,double[],double []); #else static void s1992_s9mbox3(); static void s1992_s9mbox2(); static void s1992_s9mbox(); #endif #if defined(SISLNEEDPROTOTYPES) void s1992(SISLObject *po,int *jstat) #else void s1992(po,jstat) SISLObject *po; int *jstat; #endif /* ********************************************************************* * ********************************************************************* * * PURPOSE : Make a SISLbox on the control-polygons given by * ecoef to the object. If dimension is 2 then one * SISLbox rotated 45 degree is also made. If dimension * is 3 then one SISLbox roteted 45 degree around each * main axes, in all 4 boxes is made. * * * * INPUT : po - SISLObject to treat. * * OUTPUT : jstat - status messages * > 0 : warning * = 0 : ok * < 0 : error * * * * METHOD : * * * REFERENCES : * *- * CALLS : * * WRITTEN BY : Arne Laksaa, SI, 89-02. * ********************************************************************* */ { int kpos = 0; /* Position of error. */ if (po -> iobj == SISLPOINT) { if (po->p1->pbox == SISL_NULL) { if ((po->p1->pbox = newbox(po->p1->idim))==SISL_NULL) goto err101; if (po->p1->idim == 3) s1992_s9mbox3(po->p1->ecoef,1,po->p1->pbox->emax, po->p1->pbox->emin); else if (po->p1->idim == 2) s1992_s9mbox2(po->p1->ecoef,1,po->p1->pbox->emax, po->p1->pbox->emin); else s1992_s9mbox(po->p1->ecoef,1,po->p1->idim, po->p1->pbox->emax,po->p1->pbox->emin); } } else if (po -> iobj == SISLCURVE) { if (po->c1->pbox == SISL_NULL) { if ((po->c1->pbox = newbox(po->c1->idim))==SISL_NULL) goto err101; if (po->c1->idim == 3) s1992_s9mbox3(po->c1->ecoef,po->c1->in,po->c1->pbox->emax, po->c1->pbox->emin); else if (po->c1->idim == 2) s1992_s9mbox2(po->c1->ecoef,po->c1->in,po->c1->pbox->emax, po->c1->pbox->emin); else s1992_s9mbox(po->c1->ecoef,po->c1->in,po->c1->idim, po->c1->pbox->emax,po->c1->pbox->emin); } } else if (po -> iobj == SISLSURFACE) { if (po->s1->pbox == SISL_NULL) { if ((po->s1->pbox = newbox(po->s1->idim))==SISL_NULL) goto err101; if (po->s1->idim == 3) s1992_s9mbox3(po->s1->ecoef,po->s1->in1 * po->s1->in2, po->s1->pbox->emax,po->s1->pbox->emin); else if (po->s1->idim == 2) s1992_s9mbox2(po->s1->ecoef,po->s1->in1 * po->s1->in2, po->s1->pbox->emax,po->s1->pbox->emin); else s1992_s9mbox(po->s1->ecoef,po->s1->in1 * po->s1->in2, po->s1->idim,po->s1->pbox->emax,po->s1->pbox->emin); } } *jstat = 0; goto out; /* Error in space allocation. */ err101: *jstat = -101; s6err("s1992",*jstat,kpos); goto out; out: ; } #if defined(SISLNEEDPROTOTYPES) void s1992cu(SISLCurve *pc,int *jstat) #else void s1992cu(pc,jstat) SISLCurve *pc; int *jstat; #endif /* ********************************************************************* * ********************************************************************* * * PURPOSE : Make a SISLbox on the control-polygons given by * ecoef to the object. If dimension is 2 then one * SISLbox rotated 45 degree is also made. If dimension * is 3 then one SISLbox roteted 45 degree around each * main axes, in all 4 boxes is made. * * * * INPUT : pc - SISLObject to treat. * * OUTPUT : jstat - status messages * > 0 : warning * = 0 : ok * < 0 : error * * * * METHOD : * * * REFERENCES : * *- * CALLS : * * WRITTEN BY : Arne Laksaa, SI, 89-02. * ********************************************************************* */ { int kpos = 0; /* Position of error. */ if (pc->pbox == SISL_NULL) { if ((pc->pbox = newbox(pc->idim))==SISL_NULL) goto err101; if (pc->idim == 3) s1992_s9mbox3(pc->ecoef,pc->in,pc->pbox->emax,pc->pbox->emin); else if (pc->idim == 2) s1992_s9mbox2(pc->ecoef,pc->in,pc->pbox->emax,pc->pbox->emin); else s1992_s9mbox(pc->ecoef,pc->in,pc->idim, pc->pbox->emax,pc->pbox->emin); } *jstat = 0; goto out; /* Error in space allocation. */ err101: *jstat = -101; s6err("s1992cu",*jstat,kpos); goto out; out: ; } #if defined(SISLNEEDPROTOTYPES) void s1992su(SISLSurf *ps,int *jstat) #else void s1992su(ps,jstat) SISLSurf *ps; int *jstat; #endif /* ********************************************************************* * ********************************************************************* * * PURPOSE : Make a SISLbox on the control-polygons given by * ecoef to the object. If dimension is 2 then one * SISLbox rotated 45 degree is also made. If dimension * is 3 then one SISLbox roteted 45 degree around each * main axes, in all 4 boxes is made. * * * * INPUT : ps - SISLObject to treat. * * OUTPUT : jstat - status messages * > 0 : warning * = 0 : ok * < 0 : error * * * * METHOD : * * * REFERENCES : * *- * CALLS : * * WRITTEN BY : Arne Laksaa, SI, 89-02. * ********************************************************************* */ { int kpos = 0; /* Position of error. */ if (ps->pbox == SISL_NULL) { if ((ps->pbox = newbox(ps->idim))==SISL_NULL) goto err101; if (ps->idim == 3) s1992_s9mbox3(ps->ecoef,ps->in1 * ps->in2, ps->pbox->emax,ps->pbox->emin); else if (ps->idim == 2) s1992_s9mbox2(ps->ecoef,ps->in1 * ps->in2, ps->pbox->emax,ps->pbox->emin); else s1992_s9mbox(ps->ecoef,ps->in1 * ps->in2, ps->idim,ps->pbox->emax,ps->pbox->emin); } *jstat = 0; goto out; /* Error in space allocation. */ err101: *jstat = -101; s6err("s1992su",*jstat,kpos); goto out; out: ; } #if defined(SISLNEEDPROTOTYPES) static void s1992_s9mbox3(double ecoef[],int icoef,double gmax[],double gmin[]) #else static void s1992_s9mbox3(ecoef,icoef,gmax,gmin) double ecoef[]; int icoef; double gmax[]; double gmin[]; #endif /* ********************************************************************* * ********************************************************************* * * PURPOSE : Make 4 boxes on the control-polygons given by * ecoef to the object. * * * INPUT : ecoef - Control-polygon. * icoef - Number of vertices in control-polygon. * * * * OUTPUT : gmax - Array to contain maximum values of the box. * gmin - Array to contain minimum values of the box. * * * METHOD : Make 4 boxes. One ordinary and tree boxes rotated * 45 degree around the main axes. * * * REFERENCES : * *- * CALLS : * * WRITTEN BY : Arne Laksaa, SI, 89-02. * ********************************************************************* */ { int ki,ki1,ki2,ki3; /* Counters. */ double t1,t2,t3,t4; /* To store elements of the rotation matrix. */ double *tmin,*tmax; /* Pointers used to traverse gmin and gmax. */ /* Fetch value of first vertex. */ t1= ROTM * ecoef[0]; t2= ROTM * ecoef[1]; t3= ROTM * ecoef[2]; tmin = gmin; tmax = gmax; *tmin = *tmax = ecoef[0]; tmin++; tmax++; *tmin = *tmax = ecoef[1]; tmin++; tmax++; *tmin = *tmax = ecoef[2]; tmin++; tmax++; *tmin = *tmax = ecoef[0]; tmin++; tmax++; *tmin = *tmax = t2-t3; tmin++; tmax++; *tmin = *tmax = t2+t3; tmin++; tmax++; *tmin = *tmax = t1-t3; tmin++; tmax++; *tmin = *tmax = ecoef[1]; tmin++; tmax++; *tmin = *tmax = t1+t3; tmin++; tmax++; *tmin = *tmax = t1-t2; tmin++; tmax++; *tmin = *tmax = t1+t2; tmin++; tmax++; *tmin = *tmax = ecoef[2]; /* For each vertice check and corrigate the box. */ for (ki=1,ki1=3,ki2=4,ki3=5; ki<icoef; ki++,ki1+=3,ki2+=3,ki3+=3) { t1= ROTM * ecoef[ki1]; t2= ROTM * ecoef[ki2]; t3= ROTM * ecoef[ki3]; tmin = gmin; tmax = gmax; if(ecoef[ki1] < *tmin) *tmin = ecoef[ki1]; if(ecoef[ki1] > *tmax) *tmax = ecoef[ki1]; tmin++; tmax++; if(ecoef[ki2] < *tmin) *tmin = ecoef[ki2]; if(ecoef[ki2] > *tmax) *tmax = ecoef[ki2]; tmin++; tmax++; if(ecoef[ki3] < *tmin) *tmin = ecoef[ki3]; if(ecoef[ki3] > *tmax) *tmax = ecoef[ki3]; tmin++; tmax++; if(ecoef[ki1] < *tmin) *tmin = ecoef[ki1]; if(ecoef[ki1] > *tmax) *tmax = ecoef[ki1]; tmin++; tmax++; t4= t2 - t3; if(t4 < *tmin) *tmin = t4; if(t4 > *tmax) *tmax = t4; tmin++; tmax++; t4= t2 + t3; if(t4 < *tmin) *tmin = t4; if(t4 > *tmax) *tmax = t4; tmin++; tmax++; t4= t1 - t3; if(t4 < *tmin) *tmin = t4; if(t4 > *tmax) *tmax = t4; tmin++; tmax++; if(ecoef[ki2] < *tmin) *tmin = ecoef[ki2]; if(ecoef[ki2] > *tmax) *tmax = ecoef[ki2]; tmin++; tmax++; t4= t1 + t3; if(t4 < *tmin) *tmin = t4; if(t4 > *tmax) *tmax = t4; tmin++; tmax++; t4= t1 - t2; if(t4 < *tmin) *tmin = t4; if(t4 > *tmax) *tmax = t4; tmin++; tmax++; t4= t1 + t2; if(t4 < *tmin) *tmin = t4; if(t4 > *tmax) *tmax = t4; tmin++; tmax++; if(ecoef[ki3] < *tmin) *tmin = ecoef[ki3]; if(ecoef[ki3] > *tmax) *tmax = ecoef[ki3]; } } #if defined(SISLNEEDPROTOTYPES) static void s1992_s9mbox2(double ecoef[],int icoef,double gmax[],double gmin[]) #else static void s1992_s9mbox2(ecoef,icoef,gmax,gmin) double ecoef[]; int icoef; double gmax[]; double gmin[]; #endif /* ********************************************************************* * ********************************************************************* * * PURPOSE : Make 2 boxes on the control-polygons given by * ecoef to the object. * * * INPUT : ecoef - Control-polygon. * icoef - Number of vertices in control-polygon. * * * * OUTPUT : gmax - Array to contain maximum values of the box. * gmin - Array to contain minimum values of the box. * * * METHOD : Make two boxes. One ordinary and one rotated 45 degree. * * * REFERENCES : * *- * CALLS : * * WRITTEN BY : Arne Laksaa, SI, 89-02. * ********************************************************************* */ { int ki,ki1,ki2; /* Counters. */ double t1,t2,t3; /* To store elements of the rotation matrix. */ double *tmin,*tmax; /* Pointers used to traverse gmin and gmax. */ /* Fetch value of first vertex. */ t1= ROTM * ecoef[0]; t2= ROTM * ecoef[1]; tmin = gmin; tmax = gmax; *tmin = *tmax = ecoef[0]; tmin++; tmax++; *tmin = *tmax = ecoef[1]; tmin++; tmax++; *tmin = *tmax = t1-t2; tmin++; tmax++; *tmin = *tmax = t1+t2; /* For each vertice check and corrigate the box. */ for (ki=1,ki1=2,ki2=3; ki<icoef; ki++,ki1+=2,ki2+=2) { t1= ROTM * ecoef[ki1]; t2= ROTM * ecoef[ki2]; tmin = gmin; tmax = gmax; if(ecoef[ki1] < *tmin) *tmin = ecoef[ki1]; if(ecoef[ki1] > *tmax) *tmax = ecoef[ki1]; tmin++; tmax++; if(ecoef[ki2] < *tmin) *tmin = ecoef[ki2]; if(ecoef[ki2] > *tmax) *tmax = ecoef[ki2]; tmin++; tmax++; t3= t1 - t2; if(t3 < *tmin) *tmin = t3; if(t3 > *tmax) *tmax = t3; tmin++; tmax++; t3= t1 + t2; if(t3 < *tmin) *tmin = t3; if(t3 > *tmax) *tmax = t3; } } #if defined(SISLNEEDPROTOTYPES) static void s1992_s9mbox(double ecoef[],int icoef,int idim,double gmax[],double gmin[]) #else static void s1992_s9mbox(ecoef,icoef,idim,gmax,gmin) double ecoef[]; int icoef; int idim; double gmax[]; double gmin[]; #endif /* ********************************************************************* * ********************************************************************* * * PURPOSE : Make a SISLbox on the control-polygons given by * ecoef to the object. * * * INPUT : ecoef - Control-polygon. * icoef - Number of vertices in control-polygon. * * * * OUTPUT : gmax - Array to contain maximum values of the box. * gmin - Array to contain minimum values of the box. * * * METHOD : * * * REFERENCES : * *- * CALLS : * * WRITTEN BY : Arne Laksaa, SI, 89-02. * ********************************************************************* */ { int ki,ki1,kj; /* Counters. */ double noice = (double)100.0 * REL_COMP_RES; /* Noice killer */ /* Fetch value of first vertex. */ for (ki = 0; ki < idim; ki++) gmin[ki] = gmax[ki] = ecoef[ki]; /* For each vertice check and corrigate the box. */ for (kj=1; kj<icoef; kj++) for (ki1 = 0; ki1 < idim; ki1++,ki++) { if(ecoef[ki] < gmin[ki1]) gmin[ki1] = ecoef[ki]; if(ecoef[ki] > gmax[ki1]) gmax[ki1] = ecoef[ki]; } /* ALA and UJK 30.10.90, remove noice near by zero */ if (idim == 1) { if (fabs(gmax[0]) < noice) gmax[0] = DZERO; if (fabs(gmin[0]) < noice) gmin[0] = DZERO; } }
27.350565
77
0.445068
[ "object" ]
95601d3a948ccf2892c55ee94f7b5202385bb757
10,055
c
C
external/SCOTCH/src/libscotchmetis/parmetis_dgraph_part.c
ElectronicStructureLibrary/elsi-interface
95d2b02ca627e08eea52eea8358fdb44ab0e67e3
[ "BSD-3-Clause" ]
5
2020-12-10T09:52:01.000Z
2022-01-28T13:38:45.000Z
external/SCOTCH/src/libscotchmetis/parmetis_dgraph_part.c
ElectronicStructureLibrary/elsi-interface
95d2b02ca627e08eea52eea8358fdb44ab0e67e3
[ "BSD-3-Clause" ]
null
null
null
external/SCOTCH/src/libscotchmetis/parmetis_dgraph_part.c
ElectronicStructureLibrary/elsi-interface
95d2b02ca627e08eea52eea8358fdb44ab0e67e3
[ "BSD-3-Clause" ]
3
2021-04-07T00:30:08.000Z
2021-12-12T07:02:50.000Z
/* Copyright 2008-2010,2012,2018,2019 IPB, Universite de Bordeaux, INRIA & CNRS ** ** This file is part of the Scotch software package for static mapping, ** graph partitioning and sparse matrix ordering. ** ** This software is governed by the CeCILL-C license under French law ** and abiding by the rules of distribution of free software. You can ** use, modify and/or redistribute the software under the terms of the ** CeCILL-C license as circulated by CEA, CNRS and INRIA at the following ** URL: "http://www.cecill.info". ** ** As a counterpart to the access to the source code and rights to copy, ** modify and redistribute granted by the license, users are provided ** only with a limited warranty and the software's author, the holder of ** the economic rights, and the successive licensors have only limited ** liability. ** ** In this respect, the user's attention is drawn to the risks associated ** with loading, using, modifying and/or developing or reproducing the ** software by the user in light of its specific status of free software, ** that may mean that it is complicated to manipulate, and that also ** therefore means that it is reserved for developers and experienced ** professionals having in-depth computer knowledge. Users are therefore ** encouraged to load and test the software's suitability as regards ** their requirements in conditions enabling the security of their ** systems and/or data to be ensured and, more generally, to use and ** operate it in the same conditions as regards security. ** ** The fact that you are presently reading this means that you have had ** knowledge of the CeCILL-C license and that you accept its terms. */ /************************************************************/ /** **/ /** NAME : parmetis_dgraph_part.c **/ /** **/ /** AUTHOR : Francois PELLEGRINI **/ /** **/ /** FUNCTION : This module is the compatibility **/ /** library for the ParMeTiS ordering **/ /** routines. **/ /** **/ /** DATES : # Version 5.1 : from : 19 jun 2008 **/ /** to : 30 jun 2010 **/ /** # Version 6.0 : from : 13 sep 2012 **/ /** to : 18 may 2019 **/ /** **/ /************************************************************/ /* ** The defines and includes. */ #define LIBRARY #include "module.h" #include "common.h" #include "ptscotch.h" #include "parmetis.h" /* Our "parmetis.h" file */ /************************************/ /* */ /* These routines are the C API for */ /* the ParMeTiS graph ordering */ /* routine. */ /* */ /************************************/ int SCOTCH_ParMETIS_V3_PartKway ( const SCOTCH_Num * const vtxdist, SCOTCH_Num * const xadj, SCOTCH_Num * const adjncy, SCOTCH_Num * const vwgt, SCOTCH_Num * const adjwgt, const SCOTCH_Num * const wgtflag, const SCOTCH_Num * const numflag, const SCOTCH_Num * const ncon, /* Not used */ const SCOTCH_Num * const nparts, const float * const tpwgts, const float * const ubvec, /* Not used */ const SCOTCH_Num * const options, /* Not used */ SCOTCH_Num * const edgecut, SCOTCH_Num * const part, MPI_Comm * commptr) { MPI_Comm proccomm; int procglbnbr; int proclocnum; SCOTCH_Num baseval; SCOTCH_Arch archdat; SCOTCH_Dgraph grafdat; /* Scotch distributed graph object to interface with libScotch */ SCOTCH_Dmapping mappdat; /* Scotch distributed mapping object to interface with libScotch */ SCOTCH_Strat stradat; SCOTCH_Num vertlocnbr; SCOTCH_Num * veloloctab; SCOTCH_Num edgelocnbr; SCOTCH_Num * edloloctab; SCOTCH_Num * velotab; double * vwgttab; SCOTCH_Num i; if ((vwgttab = malloc (*nparts * sizeof (double))) == NULL) return (METIS_ERROR_MEMORY); if ((velotab = malloc (*nparts * sizeof (SCOTCH_Num))) == NULL) { free (vwgttab); return (METIS_ERROR_MEMORY); } for (i = 0; i < *nparts; i ++) vwgttab[i] = (double) tpwgts[i] * (double) (*nparts); for (i = 0; i < *nparts; i ++) { double deltval; deltval = fabs (vwgttab[i] - floor (vwgttab[i] + 0.5)); if (deltval > 0.01) { SCOTCH_Num j; deltval = 1.0 / deltval; for (j = 0; j < *nparts; j ++) vwgttab[j] *= deltval; } } for (i = 0; i < *nparts; i ++) velotab[i] = (SCOTCH_Num) (vwgttab[i] + 0.5); proccomm = *commptr; if (SCOTCH_dgraphInit (&grafdat, proccomm) != 0) { free (velotab); free (vwgttab); return (METIS_ERROR); } MPI_Comm_size (proccomm, &procglbnbr); MPI_Comm_rank (proccomm, &proclocnum); baseval = *numflag; vertlocnbr = vtxdist[proclocnum + 1] - vtxdist[proclocnum]; edgelocnbr = xadj[vertlocnbr] - baseval; veloloctab = ((vwgt != NULL) && ((*wgtflag & 2) != 0)) ? vwgt : NULL; edloloctab = ((adjwgt != NULL) && ((*wgtflag & 1) != 0)) ? adjwgt : NULL; if (SCOTCH_dgraphBuild (&grafdat, baseval, vertlocnbr, vertlocnbr, xadj, xadj + 1, veloloctab, NULL, edgelocnbr, edgelocnbr, adjncy, NULL, edloloctab) == 0) { SCOTCH_stratInit (&stradat); #ifdef SCOTCH_DEBUG_ALL if (SCOTCH_dgraphCheck (&grafdat) == 0) /* TRICK: next instruction called only if graph is consistent */ #endif /* SCOTCH_DEBUG_ALL */ { SCOTCH_archInit (&archdat); if ((SCOTCH_archCmpltw (&archdat, *nparts, velotab) == 0) && (SCOTCH_dgraphMapInit (&grafdat, &mappdat, &archdat, part) == 0)) { SCOTCH_dgraphMapCompute (&grafdat, &mappdat, &stradat); SCOTCH_dgraphMapExit (&grafdat, &mappdat); } SCOTCH_archExit (&archdat); } SCOTCH_stratExit (&stradat); } SCOTCH_dgraphExit (&grafdat); *edgecut = 0; /* TODO : compute real edge cut for people who might want it */ free (velotab); free (vwgttab); if (baseval != 0) { /* MeTiS part array is based, Scotch is not */ SCOTCH_Num vertlocnum; for (vertlocnum = 0; vertlocnum < vertlocnbr; vertlocnum ++) part[vertlocnum] += baseval; } return (METIS_OK); } /* ** */ int SCOTCH_ParMETIS_V3_PartGeomKway ( const SCOTCH_Num * const vtxdist, SCOTCH_Num * const xadj, SCOTCH_Num * const adjncy, SCOTCH_Num * const vwgt, SCOTCH_Num * const adjwgt, const SCOTCH_Num * const wgtflag, const SCOTCH_Num * const numflag, const SCOTCH_Num * const ndims, /* Not used */ const float * const xyz, /* Not used */ const SCOTCH_Num * const ncon, /* Not used */ const SCOTCH_Num * const nparts, const float * const tpwgts, const float * const ubvec, const SCOTCH_Num * const options, /* Not used */ SCOTCH_Num * const edgecut, SCOTCH_Num * const part, MPI_Comm * commptr) { return (SCOTCH_ParMETIS_V3_PartKway (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, ncon, nparts, tpwgts, ubvec, options, edgecut, part, commptr)); } /**********************/ /* */ /* ParMeTiS v3 stubs. */ /* */ /**********************/ #if (SCOTCH_PARMETIS_VERSION == 3) #ifndef SCOTCH_METIS_PREFIX /* With "SCOTCH_" prefix, names already defined */ int METISNAMEU (ParMETIS_V3_PartKway) ( const SCOTCH_Num * const vtxdist, SCOTCH_Num * const xadj, SCOTCH_Num * const adjncy, SCOTCH_Num * const vwgt, SCOTCH_Num * const adjwgt, const SCOTCH_Num * const wgtflag, const SCOTCH_Num * const numflag, const SCOTCH_Num * const ncon, /* Not used */ const SCOTCH_Num * const nparts, const float * const tpwgts, const float * const ubvec, /* Not used */ const SCOTCH_Num * const options, /* Not used */ SCOTCH_Num * const edgecut, SCOTCH_Num * const part, MPI_Comm * commptr) { return (SCOTCH_ParMETIS_V3_PartKway (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, ncon, nparts, tpwgts, ubvec, options, edgecut, part, commptr)); } /* ** */ int METISNAMEU (ParMETIS_V3_PartGeomKway) ( const SCOTCH_Num * const vtxdist, SCOTCH_Num * const xadj, SCOTCH_Num * const adjncy, SCOTCH_Num * const vwgt, SCOTCH_Num * const adjwgt, const SCOTCH_Num * const wgtflag, const SCOTCH_Num * const numflag, const SCOTCH_Num * const ndims, /* Not used */ const float * const xyz, /* Not used */ const SCOTCH_Num * const ncon, /* Not used */ const SCOTCH_Num * const nparts, const float * const tpwgts, const float * const ubvec, const SCOTCH_Num * const options, /* Not used */ SCOTCH_Num * const edgecut, SCOTCH_Num * const part, MPI_Comm * commptr) { return (SCOTCH_ParMETIS_V3_PartGeomKway (vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, ndims, xyz, ncon, nparts, tpwgts, ubvec, options, edgecut, part, commptr)); } #endif /* SCOTCH_METIS_PREFIX */ #endif /* (SCOTCH_PARMETIS_VERSION == 3) */
38.087121
157
0.556141
[ "object" ]
95635cc1df6af739ddd200dca5381fbee5cfba68
6,293
h
C
include/liveplusplus/liveplusplus.h
simongeilfus/liveplusplus
cdf239ad20181368263ff6f92ddb4a48f073eea7
[ "MIT" ]
null
null
null
include/liveplusplus/liveplusplus.h
simongeilfus/liveplusplus
cdf239ad20181368263ff6f92ddb4a48f073eea7
[ "MIT" ]
null
null
null
include/liveplusplus/liveplusplus.h
simongeilfus/liveplusplus
cdf239ad20181368263ff6f92ddb4a48f073eea7
[ "MIT" ]
null
null
null
/* Copyright 2020 Simon Geilfus 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 <filesystem> #include <functional> #include <optional> #if ! defined( LPP_PATH ) #define LPP_PATH "D:\\LivePP" #endif class LivePlusPlus { public: enum class WindowMode { Normal, Minimized, Maximized }; enum class FocusMode { OnError, OnSuccess, OnShortcut, Never }; class Settings { public: //! Sets whether the exception handler / error recovery system should be installed Settings& installExceptionHandler( bool exceptionHandler = true ) { mInstallExceptionHandler = exceptionHandler; return *this; } //! Sets whether Live++ starts minimized, maximized, or normal. Settings& initialWindowMode( WindowMode mode ) { mInitialWindowMode = mode; return *this; } //! Sets if and under what circumstances Live++ should get focus upon re-compiling. Settings& receiveFocusOnRecompile( FocusMode mode ) { mReceiveFocusOnRecompile = mode; return *this; } //! When continuous compilation is turned on, Live++ waits for change notifications in the given directory (and its sub-directories) and automatically compiles any changes once the timeout has expired. Settings& enableContinuousCompilation( bool enabled = true ) { mEnableContinuousCompilation = enabled; return *this; } //! Directory to watch Lets you set the directory that is being watched for changes when using continuous compilation. Settings& continuousCompilationPath( const std::filesystem::path &path ) { mContinuousCompilationPath = path; return *this; } //! When listening for change notifications, Live++ will wait for subsequent changes until the timeout is reached. Settings& continuousCompilationTimeout( int32_t ms ) { mContinuousCompilationTimeout = ms; return *this; } //! Enables restart from the Lpp App Settings& enableRestart( bool enabled = true ) { mEnableRestart = enabled; if( enabled ) return enableMultiProcessEditing(); else return *this; } //! By default, you can launch several executables and register them at the same process group, but only if no patches have been applied yet. When this setting is enabled, registered modules will automatically load all available patches when registering with a process group. Settings& enableMultiProcessEditing( bool enabled = true ) { mEnableMultiProcessEditing = enabled; return *this; } // Specifies additional options passed to the compiler when creating a patch Settings& additionalCompilerOptions( const std::wstring &options ) { mAdditionalCompilerOptions = options; return *this; } Settings(); protected: void apply( void* lppModule ) const; bool mInstallExceptionHandler; bool mEnableRestart; std::optional<bool> mEnableMultiProcessEditing; std::optional<WindowMode> mInitialWindowMode; std::optional<FocusMode> mReceiveFocusOnRecompile; std::optional<bool> mEnableContinuousCompilation; std::filesystem::path mContinuousCompilationPath; int32_t mContinuousCompilationTimeout; std::wstring mAdditionalCompilerOptions; friend LivePlusPlus; }; //! Returns the global instance static LivePlusPlus& instance(); //! Initialize the global instance static void initialize( const Settings &settings = Settings(), const std::filesystem::path &lppPath = LPP_PATH ); //! Specifies when the the syncing point should happen static void syncPoint(); //! Used to keep track of the lifetime of callbacks class Connection { public: Connection() = default; Connection( uint32_t id, class LivePlusPlus* parent ); Connection( const Connection &other ) = delete; Connection& operator=( const Connection &other ) = delete; //! Removes this callback from Lpp void disconnect(); //! Returns the unique id associated with this callback uint32_t getId() const; //! Returns the FileWatcher that issued this Connection class LivePlusPlus* getParent() const; protected: uint32_t mId; class LivePlusPlus* mParent; friend class LivePlusPlus; }; //! Raii version of Connection class ScopedConnection : public Connection { public: ScopedConnection() : Connection() {} ScopedConnection( const Connection &other ); ScopedConnection& operator=( const Connection &other ); ~ScopedConnection(); }; //! Adds a function to be called before a live++ patch is applied Connection addPrePatchFn( const std::function<void()> &fn ); //! Adds a function to be called after a live++ patch is applied Connection addPostPatchFn( const std::function<void()> &fn ); //! Removes any target matching the Connection void removeFn( uint32_t connectionId ); //! Removes any target matching the Connection void removePrePatchFn( const Connection &connection ); //! Removes any target matching the Connection void removePostPatchFn( const Connection &connection ); LivePlusPlus(); LivePlusPlus( const Settings &settings, const std::filesystem::path &lppPath = LPP_PATH ); void emitPostPatch(); void emitPrePatch(); private: void initializeLpp( const Settings &settings, const std::filesystem::path &lppPath ); void* mModule; using Callback = std::pair<uint32_t,std::function<void()>>; std::vector<Callback> mPostPatchFunctions; std::vector<Callback> mPrePatchFunctions; uint32_t mFunctionsIds; }; #if ! defined( LIVEPLUSPLUS_DISABLE_ALIAS ) using lxx = LivePlusPlus; #endif
47.674242
278
0.767361
[ "vector" ]
9565c8440a8956798a7089736a50249058e864bd
2,188
h
C
Utilities.h
NinhPham/Outlier
cbd8875b8185901f2b5d7d70b0294184d7004939
[ "MIT" ]
11
2018-08-28T11:55:54.000Z
2021-08-21T10:51:32.000Z
Utilities.h
NinhPham/Outlier
cbd8875b8185901f2b5d7d70b0294184d7004939
[ "MIT" ]
null
null
null
Utilities.h
NinhPham/Outlier
cbd8875b8185901f2b5d7d70b0294184d7004939
[ "MIT" ]
1
2021-04-29T09:34:15.000Z
2021-04-29T09:34:15.000Z
#ifndef UTILITIES_H_INCLUDED #define UTILITIES_H_INCLUDED #include "Header.h" #include "prng.h" //#include <string> #include <sstream> // already included string #include <utility> // for pair<int, int> #include "time.h" // clock() #include <algorithm> // sort() #include <cstdio> // printf() #include <math.h> // log() #include <iostream> // cout //const double Gamma = ceil(4 * LAMBDA * log(2 / DELTA) / pow(EPSILON, 2)); /** Manipulate 2D vector by 1D vector **/ size_t get1DIndex(size_t, size_t); // Get index from (pointIdx, dimIDx) vector<double> getPoint(size_t); // Get vector of point /** KNN operations **/ void kNearestNeighbors(vector<IDPair> &, const size_t, const size_t); // get kNN list of (pointIdx, distance) double kNN_Dist(const size_t, const size_t); // Get kNN distance /** Generate random uniform variables **/ void generateRndPair(const size_t, size_t &, size_t &); // generate of random pair (B, C) where A != B != C vector<size_t> samplingSubset(vector<size_t>, size_t ); // subsampling a subset from [N] void generateNormal(vector<double> &); // generate Normal distribution variables void generate4Wises(vector<int> &, vector<int> &); // generate 2 4-wise independent vectors long long hash31(long long, long long, long long); // generate 2-wise independent h(x) = ax + b mod 2^31 /** Linear Algebra operations **/ double dotProduct(const vector<double> &, const vector<double> &); double l2Dist(const vector<double> &, const vector<double> &); void computeAB_AC(const size_t, const size_t, const size_t , double &, double &, double &); /** Print vector in command line **/ void printVector(const vector<double> &); void printVector(const vector<int> &); void printVector(const vector<size_t> &); /** Type conversion **/ string int2str(int); /** Save outputs **/ void saveRanking(const vector<IDPair> &, string); void saveVOAInfo(const vector<double> &, const vector<double> &, const vector<double> &, string); void saveVector(const vector<int> &, string ); /** Arithmetic operations **/ double truncateCosine(double); double hackAcos(double); #endif // UTILITIES_H_INCLUDED
29.972603
110
0.691956
[ "vector" ]
95724c13c1e8e57da3dd6c82acd5e91b7a8c4de4
1,028
h
C
frame_loader.h
jmmelis/DipteraTrack
1d267ccd4248635233147f2035b900a433dc4536
[ "MIT" ]
1
2019-06-14T10:19:19.000Z
2019-06-14T10:19:19.000Z
frame_loader.h
jmmelis/DipteraTrack
1d267ccd4248635233147f2035b900a433dc4536
[ "MIT" ]
null
null
null
frame_loader.h
jmmelis/DipteraTrack
1d267ccd4248635233147f2035b900a433dc4536
[ "MIT" ]
null
null
null
#ifndef FRAME_LOADER_CLASS_H #define FRAME_LOADER_CLASS_H #include "session_data.h" #include "frame_data.h" #include <boost/python.hpp> #include <boost/python/numpy.hpp> #include <string> #include <stdint.h> #include <iostream> #include <vector> #include <opencv2/opencv.hpp> #include <opencv2/highgui.hpp> #include <armadillo> using namespace std; namespace p = boost::python; namespace np = boost::python::numpy; class FrameLoader { public: vector<tuple<int,int>> image_size; vector<arma::Col<int>> bckg_images; FrameLoader(); bool LoadBackground(session_data &session); void SetFrame(session_data &session, frame_data &frame); bool LoadFrame(session_data &session, frame_data &frame, int MovNR, int FrameNR); arma::Col<int> BackgroundSubtract(arma::Col<int> &img_vec, arma::Col<int> &bckg_vec); np::ndarray ReturnFrame(session_data &session, frame_data &frame, int CamNR); arma::Col<int> CVMat2Vector(cv::Mat &img); cv::Mat Vector2CVMat(arma::Col<int> &img_vec, int N_row, int N_col); }; #endif
25.7
87
0.744163
[ "vector" ]
9584d068c40b0bec43bd123c545f16040f9516a1
2,257
h
C
cSound.h
llop/R-Type
9d41cb7de85496cefa67d4c14b3ba793926aba8f
[ "MIT" ]
2
2016-04-12T10:24:27.000Z
2020-12-29T16:53:51.000Z
cSound.h
llop/R-Type
9d41cb7de85496cefa67d4c14b3ba793926aba8f
[ "MIT" ]
null
null
null
cSound.h
llop/R-Type
9d41cb7de85496cefa67d4c14b3ba793926aba8f
[ "MIT" ]
2
2017-10-07T17:36:03.000Z
2021-12-11T14:11:25.000Z
#pragma once #include "Globals.h" class cSound { public: cSound(); ~cSound(); bool loadWAV(const char* fileName, bool continuousLoop, float gain); bool play(); bool pause(); bool resume(); bool stop(); bool rewind(); bool loaded() const; void gain(float gainLevel); float gain(); private: bool _loaded; ALuint _audioBuffer; ALuint _audioSource; }; #define SOUND_PANTALLA_INICIAL 0 #define SOUND_NIVEL1_INTRO 1 #define SOUND_NIVEL1 2 #define SOUND_NIVEL2 3 #define SOUND_NIVEL3 4 #define SOUND_NIVEL4 5 #define SOUND_JEFE_INTRO 6 #define SOUND_JEFE 7 #define SOUND_SCORE 8 #define SOUND_JUEGO_COMPLETO 9 #define SOUND_SET_HI_SCORE 10 #define SOUND_GAME_OVER 11 #define SOUND_OPCION_MENU 12 #define SOUND_START_GAME 13 #define SOUND_EXPLO1 14 #define SOUND_EXPLO2 15 #define SOUND_EXPLO_NAVE 16 #define SOUND_DISPARO_ENEMIGO 17 #define SOUND_DISPARO_JEFE1 18 #define SOUND_DISPARO_GUSANO 19 #define SOUND_DISPARO_NAVE 20 #define SOUND_DISPARO_RB_NAVE 21 #define SOUND_CARGA_DISPARO 22 #define SOUND_DISPARO_CARGADO 23 #define SOUND_DISPARO_ESCUDO1 24 #define SOUND_DISPARO_ESCUDO2 25 #define SOUND_ITEM_VIDA 26 #define SOUND_ITEM 27 #define SOUND_DISPARO_NAVE_EXPLO1 28 #define SOUND_DISPARO_NAVE_EXPLO2 29 #define SOUND_DISPARO_ENEMIGO_EXPLO1 30 #define SOUND_DISPARO_ENEMIGO_EXPLO2 31 #define SOUND_MAGIA 32 #define SOUND_CLIT 33 #define SOUND_CUC 34 #define SOUND_ENEMIGO_HIT 35 #define NUM_SOUNDS 36 struct cSoundWrapper { vector<cSound> _sources; int _numSources; long long _lastPlayed; long long _delay; int _queued; int _playIndex; bool _loaded; cSoundWrapper(); void init(const char* ficheroSonido, bool loop, int numSources, long long delay, float gain); }; #define SONIDO_MAX_QUEUED 6 #define SONIDO_DELAY 1 class cSoundManager { private: long long _tiempo; long long _ultimoSonido; list<pair<long long, int> > _que; cSoundWrapper _sounds[NUM_SOUNDS]; bool _paused; public: cSoundManager(); void suena(); void cargaSonido(int id, const char* ficheroSonido, bool loop, int num, long long delay, float gain); void playSonido(int id); void stopSonido(int id); void stopSonidos(); void pauseSonido(int id); void resumeSonido(int id); void pauseSonidos(); void resumeSonidos(); };
18.056
102
0.782898
[ "vector" ]
95a04de066f1e31b15592e8f6fcff49101afc0bb
23,869
h
C
deps/mozjs/src/jit/CodeGenerator.h
ktrzeciaknubisa/jxcore-binary-packaging
5759df084be10a259a4a4f1b38c214c6084a7c0f
[ "Apache-2.0" ]
2,494
2015-02-11T04:34:13.000Z
2022-03-31T14:21:47.000Z
deps/mozjs/src/jit/CodeGenerator.h
ktrzeciaknubisa/jxcore-binary-packaging
5759df084be10a259a4a4f1b38c214c6084a7c0f
[ "Apache-2.0" ]
685
2015-02-11T17:14:26.000Z
2021-04-13T09:58:39.000Z
deps/mozjs/src/jit/CodeGenerator.h
ktrzeciaknubisa/jxcore-binary-packaging
5759df084be10a259a4a4f1b38c214c6084a7c0f
[ "Apache-2.0" ]
442
2015-02-12T13:45:46.000Z
2022-03-21T05:28:05.000Z
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 tw=99: * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef jit_CodeGenerator_h #define jit_CodeGenerator_h #include "jit/IonCaches.h" #if defined(JS_ION_PERF) # include "jit/PerfSpewer.h" #endif #if defined(JS_CODEGEN_X86) # include "jit/x86/CodeGenerator-x86.h" #elif defined(JS_CODEGEN_X64) # include "jit/x64/CodeGenerator-x64.h" #elif defined(JS_CODEGEN_ARM) # include "jit/arm/CodeGenerator-arm.h" #elif defined(JS_CODEGEN_MIPS) # include "jit/mips/CodeGenerator-mips.h" #elif defined(JS_CODEGEN_NONE) # include "jit/none/CodeGenerator-none.h" #else #error "Unknown architecture!" #endif namespace js { namespace jit { class OutOfLineTestObject; class OutOfLineNewArray; class OutOfLineNewObject; class CheckOverRecursedFailure; class CheckOverRecursedFailurePar; class OutOfLineInterruptCheckPar; class OutOfLineInterruptCheckImplicit; class OutOfLineUnboxFloatingPoint; class OutOfLineStoreElementHole; class OutOfLineTypeOfV; class OutOfLineLoadTypedArray; class OutOfLineNewGCThingPar; class OutOfLineUpdateCache; class OutOfLineCallPostWriteBarrier; class CodeGenerator : public CodeGeneratorSpecific { bool generateArgumentsChecks(bool bailout = true); bool generateBody(); public: CodeGenerator(MIRGenerator *gen, LIRGraph *graph, MacroAssembler *masm = nullptr); ~CodeGenerator(); public: bool generate(); bool generateAsmJS(AsmJSFunctionLabels *labels); bool link(JSContext *cx, types::CompilerConstraintList *constraints); bool visitLabel(LLabel *lir); bool visitNop(LNop *lir); bool visitOsiPoint(LOsiPoint *lir); bool visitGoto(LGoto *lir); bool visitTableSwitch(LTableSwitch *ins); bool visitTableSwitchV(LTableSwitchV *ins); bool visitCloneLiteral(LCloneLiteral *lir); bool visitParameter(LParameter *lir); bool visitCallee(LCallee *lir); bool visitStart(LStart *lir); bool visitReturn(LReturn *ret); bool visitDefVar(LDefVar *lir); bool visitDefFun(LDefFun *lir); bool visitOsrEntry(LOsrEntry *lir); bool visitOsrScopeChain(LOsrScopeChain *lir); bool visitOsrValue(LOsrValue *lir); bool visitOsrReturnValue(LOsrReturnValue *lir); bool visitOsrArgumentsObject(LOsrArgumentsObject *lir); bool visitStackArgT(LStackArgT *lir); bool visitStackArgV(LStackArgV *lir); bool visitMoveGroup(LMoveGroup *group); bool visitValueToInt32(LValueToInt32 *lir); bool visitValueToDouble(LValueToDouble *lir); bool visitValueToFloat32(LValueToFloat32 *lir); bool visitFloat32ToDouble(LFloat32ToDouble *lir); bool visitDoubleToFloat32(LDoubleToFloat32 *lir); bool visitInt32ToFloat32(LInt32ToFloat32 *lir); bool visitInt32ToDouble(LInt32ToDouble *lir); void emitOOLTestObject(Register objreg, Label *ifTruthy, Label *ifFalsy, Register scratch); bool visitTestOAndBranch(LTestOAndBranch *lir); bool visitTestVAndBranch(LTestVAndBranch *lir); bool visitFunctionDispatch(LFunctionDispatch *lir); bool visitTypeObjectDispatch(LTypeObjectDispatch *lir); bool visitBooleanToString(LBooleanToString *lir); void emitIntToString(Register input, Register output, Label *ool); bool visitIntToString(LIntToString *lir); bool visitDoubleToString(LDoubleToString *lir); bool visitValueToString(LValueToString *lir); bool visitInteger(LInteger *lir); bool visitRegExp(LRegExp *lir); bool visitRegExpExec(LRegExpExec *lir); bool visitRegExpTest(LRegExpTest *lir); bool visitRegExpReplace(LRegExpReplace *lir); bool visitStringReplace(LStringReplace *lir); bool visitLambda(LLambda *lir); bool visitLambdaArrow(LLambdaArrow *lir); bool visitLambdaForSingleton(LLambdaForSingleton *lir); bool visitLambdaPar(LLambdaPar *lir); bool visitPointer(LPointer *lir); bool visitSlots(LSlots *lir); bool visitLoadSlotT(LLoadSlotT *lir); bool visitLoadSlotV(LLoadSlotV *lir); bool visitStoreSlotT(LStoreSlotT *lir); bool visitStoreSlotV(LStoreSlotV *lir); bool visitElements(LElements *lir); bool visitConvertElementsToDoubles(LConvertElementsToDoubles *lir); bool visitMaybeToDoubleElement(LMaybeToDoubleElement *lir); bool visitMaybeCopyElementsForWrite(LMaybeCopyElementsForWrite *lir); bool visitGuardObjectIdentity(LGuardObjectIdentity *guard); bool visitGuardShapePolymorphic(LGuardShapePolymorphic *lir); bool visitTypeBarrierV(LTypeBarrierV *lir); bool visitTypeBarrierO(LTypeBarrierO *lir); bool visitMonitorTypes(LMonitorTypes *lir); bool visitPostWriteBarrierO(LPostWriteBarrierO *lir); bool visitPostWriteBarrierV(LPostWriteBarrierV *lir); bool visitOutOfLineCallPostWriteBarrier(OutOfLineCallPostWriteBarrier *ool); bool visitCallNative(LCallNative *call); bool emitCallInvokeFunction(LInstruction *call, Register callereg, uint32_t argc, uint32_t unusedStack); bool visitCallGeneric(LCallGeneric *call); bool visitCallKnown(LCallKnown *call); bool emitCallInvokeFunction(LApplyArgsGeneric *apply, Register extraStackSize); void emitPushArguments(LApplyArgsGeneric *apply, Register extraStackSpace); void emitPopArguments(LApplyArgsGeneric *apply, Register extraStackSize); bool visitApplyArgsGeneric(LApplyArgsGeneric *apply); bool visitBail(LBail *lir); bool visitUnreachable(LUnreachable *unreachable); bool visitGetDynamicName(LGetDynamicName *lir); bool visitFilterArgumentsOrEvalS(LFilterArgumentsOrEvalS *lir); bool visitFilterArgumentsOrEvalV(LFilterArgumentsOrEvalV *lir); bool visitCallDirectEvalS(LCallDirectEvalS *lir); bool visitCallDirectEvalV(LCallDirectEvalV *lir); bool visitDoubleToInt32(LDoubleToInt32 *lir); bool visitFloat32ToInt32(LFloat32ToInt32 *lir); bool visitNewArrayCallVM(LNewArray *lir); bool visitNewArray(LNewArray *lir); bool visitOutOfLineNewArray(OutOfLineNewArray *ool); bool visitNewArrayCopyOnWrite(LNewArrayCopyOnWrite *lir); bool visitNewObjectVMCall(LNewObject *lir); bool visitNewObject(LNewObject *lir); bool visitOutOfLineNewObject(OutOfLineNewObject *ool); bool visitNewDeclEnvObject(LNewDeclEnvObject *lir); bool visitNewCallObject(LNewCallObject *lir); bool visitNewSingletonCallObject(LNewSingletonCallObject *lir); bool visitNewCallObjectPar(LNewCallObjectPar *lir); bool visitNewStringObject(LNewStringObject *lir); bool visitNewPar(LNewPar *lir); bool visitNewDenseArrayPar(LNewDenseArrayPar *lir); bool visitNewDerivedTypedObject(LNewDerivedTypedObject *lir); bool visitInitElem(LInitElem *lir); bool visitInitElemGetterSetter(LInitElemGetterSetter *lir); bool visitMutateProto(LMutateProto *lir); bool visitInitProp(LInitProp *lir); bool visitInitPropGetterSetter(LInitPropGetterSetter *lir); bool visitCreateThis(LCreateThis *lir); bool visitCreateThisWithProto(LCreateThisWithProto *lir); bool visitCreateThisWithTemplate(LCreateThisWithTemplate *lir); bool visitCreateArgumentsObject(LCreateArgumentsObject *lir); bool visitGetArgumentsObjectArg(LGetArgumentsObjectArg *lir); bool visitSetArgumentsObjectArg(LSetArgumentsObjectArg *lir); bool visitReturnFromCtor(LReturnFromCtor *lir); bool visitComputeThis(LComputeThis *lir); bool visitLoadArrowThis(LLoadArrowThis *lir); bool visitArrayLength(LArrayLength *lir); bool visitSetArrayLength(LSetArrayLength *lir); bool visitTypedArrayLength(LTypedArrayLength *lir); bool visitTypedArrayElements(LTypedArrayElements *lir); bool visitNeuterCheck(LNeuterCheck *lir); bool visitTypedObjectElements(LTypedObjectElements *lir); bool visitSetTypedObjectOffset(LSetTypedObjectOffset *lir); bool visitTypedObjectProto(LTypedObjectProto *ins); bool visitStringLength(LStringLength *lir); bool visitInitializedLength(LInitializedLength *lir); bool visitSetInitializedLength(LSetInitializedLength *lir); bool visitNotO(LNotO *ins); bool visitNotV(LNotV *ins); bool visitBoundsCheck(LBoundsCheck *lir); bool visitBoundsCheckRange(LBoundsCheckRange *lir); bool visitBoundsCheckLower(LBoundsCheckLower *lir); bool visitLoadFixedSlotV(LLoadFixedSlotV *ins); bool visitLoadFixedSlotT(LLoadFixedSlotT *ins); bool visitStoreFixedSlotV(LStoreFixedSlotV *ins); bool visitStoreFixedSlotT(LStoreFixedSlotT *ins); bool emitGetPropertyPolymorphic(LInstruction *lir, Register obj, Register scratch, const TypedOrValueRegister &output); bool visitGetPropertyPolymorphicV(LGetPropertyPolymorphicV *ins); bool visitGetPropertyPolymorphicT(LGetPropertyPolymorphicT *ins); bool emitSetPropertyPolymorphic(LInstruction *lir, Register obj, Register scratch, const ConstantOrRegister &value); bool visitSetPropertyPolymorphicV(LSetPropertyPolymorphicV *ins); bool visitArraySplice(LArraySplice *splice); bool visitSetPropertyPolymorphicT(LSetPropertyPolymorphicT *ins); bool visitAbsI(LAbsI *lir); bool visitAtan2D(LAtan2D *lir); bool visitHypot(LHypot *lir); bool visitPowI(LPowI *lir); bool visitPowD(LPowD *lir); bool visitRandom(LRandom *lir); bool visitMathFunctionD(LMathFunctionD *ins); bool visitMathFunctionF(LMathFunctionF *ins); bool visitModD(LModD *ins); bool visitMinMaxI(LMinMaxI *lir); bool visitBinaryV(LBinaryV *lir); bool emitCompareS(LInstruction *lir, JSOp op, Register left, Register right, Register output); bool visitCompareS(LCompareS *lir); bool visitCompareStrictS(LCompareStrictS *lir); bool visitCompareVM(LCompareVM *lir); bool visitIsNullOrLikeUndefined(LIsNullOrLikeUndefined *lir); bool visitIsNullOrLikeUndefinedAndBranch(LIsNullOrLikeUndefinedAndBranch *lir); bool visitEmulatesUndefined(LEmulatesUndefined *lir); bool visitEmulatesUndefinedAndBranch(LEmulatesUndefinedAndBranch *lir); bool emitConcat(LInstruction *lir, Register lhs, Register rhs, Register output); bool visitConcat(LConcat *lir); bool visitConcatPar(LConcatPar *lir); bool visitCharCodeAt(LCharCodeAt *lir); bool visitFromCharCode(LFromCharCode *lir); bool visitStringSplit(LStringSplit *lir); bool visitFunctionEnvironment(LFunctionEnvironment *lir); bool visitForkJoinContext(LForkJoinContext *lir); bool visitGuardThreadExclusive(LGuardThreadExclusive *lir); bool visitCallGetProperty(LCallGetProperty *lir); bool visitCallGetElement(LCallGetElement *lir); bool visitCallSetElement(LCallSetElement *lir); bool visitCallInitElementArray(LCallInitElementArray *lir); bool visitThrow(LThrow *lir); bool visitTypeOfV(LTypeOfV *lir); bool visitOutOfLineTypeOfV(OutOfLineTypeOfV *ool); bool visitToIdV(LToIdV *lir); template<typename T> bool emitLoadElementT(LLoadElementT *lir, const T &source); bool visitLoadElementT(LLoadElementT *lir); bool visitLoadElementV(LLoadElementV *load); bool visitLoadElementHole(LLoadElementHole *lir); bool visitStoreElementT(LStoreElementT *lir); bool visitStoreElementV(LStoreElementV *lir); bool visitStoreElementHoleT(LStoreElementHoleT *lir); bool visitStoreElementHoleV(LStoreElementHoleV *lir); bool emitArrayPopShift(LInstruction *lir, const MArrayPopShift *mir, Register obj, Register elementsTemp, Register lengthTemp, TypedOrValueRegister out); bool visitArrayPopShiftV(LArrayPopShiftV *lir); bool visitArrayPopShiftT(LArrayPopShiftT *lir); bool emitArrayPush(LInstruction *lir, const MArrayPush *mir, Register obj, ConstantOrRegister value, Register elementsTemp, Register length); bool visitArrayPushV(LArrayPushV *lir); bool visitArrayPushT(LArrayPushT *lir); bool visitArrayConcat(LArrayConcat *lir); bool visitArrayJoin(LArrayJoin *lir); bool visitLoadTypedArrayElement(LLoadTypedArrayElement *lir); bool visitLoadTypedArrayElementHole(LLoadTypedArrayElementHole *lir); bool visitStoreTypedArrayElement(LStoreTypedArrayElement *lir); bool visitStoreTypedArrayElementHole(LStoreTypedArrayElementHole *lir); bool visitClampIToUint8(LClampIToUint8 *lir); bool visitClampDToUint8(LClampDToUint8 *lir); bool visitClampVToUint8(LClampVToUint8 *lir); bool visitCallIteratorStart(LCallIteratorStart *lir); bool visitIteratorStart(LIteratorStart *lir); bool visitIteratorNext(LIteratorNext *lir); bool visitIteratorMore(LIteratorMore *lir); bool visitIteratorEnd(LIteratorEnd *lir); bool visitArgumentsLength(LArgumentsLength *lir); bool visitGetFrameArgument(LGetFrameArgument *lir); bool visitSetFrameArgumentT(LSetFrameArgumentT *lir); bool visitSetFrameArgumentC(LSetFrameArgumentC *lir); bool visitSetFrameArgumentV(LSetFrameArgumentV *lir); bool visitRunOncePrologue(LRunOncePrologue *lir); bool emitRest(LInstruction *lir, Register array, Register numActuals, Register temp0, Register temp1, unsigned numFormals, JSObject *templateObject, bool saveAndRestore, Register resultreg); bool visitRest(LRest *lir); bool visitRestPar(LRestPar *lir); bool visitCallSetProperty(LCallSetProperty *ins); bool visitCallDeleteProperty(LCallDeleteProperty *lir); bool visitCallDeleteElement(LCallDeleteElement *lir); bool visitBitNotV(LBitNotV *lir); bool visitBitOpV(LBitOpV *lir); bool emitInstanceOf(LInstruction *ins, JSObject *prototypeObject); bool visitIn(LIn *ins); bool visitInArray(LInArray *ins); bool visitInstanceOfO(LInstanceOfO *ins); bool visitInstanceOfV(LInstanceOfV *ins); bool visitCallInstanceOf(LCallInstanceOf *ins); bool visitProfilerStackOp(LProfilerStackOp *lir); bool visitGetDOMProperty(LGetDOMProperty *lir); bool visitGetDOMMember(LGetDOMMember *lir); bool visitSetDOMProperty(LSetDOMProperty *lir); bool visitCallDOMNative(LCallDOMNative *lir); bool visitCallGetIntrinsicValue(LCallGetIntrinsicValue *lir); bool visitIsCallable(LIsCallable *lir); bool visitIsObject(LIsObject *lir); bool visitHaveSameClass(LHaveSameClass *lir); bool visitHasClass(LHasClass *lir); bool visitAsmJSCall(LAsmJSCall *lir); bool visitAsmJSParameter(LAsmJSParameter *lir); bool visitAsmJSReturn(LAsmJSReturn *ret); bool visitAsmJSVoidReturn(LAsmJSVoidReturn *ret); bool visitCheckOverRecursed(LCheckOverRecursed *lir); bool visitCheckOverRecursedFailure(CheckOverRecursedFailure *ool); bool visitCheckOverRecursedPar(LCheckOverRecursedPar *lir); bool visitInterruptCheckPar(LInterruptCheckPar *lir); bool visitOutOfLineInterruptCheckPar(OutOfLineInterruptCheckPar *ool); bool visitInterruptCheckImplicit(LInterruptCheckImplicit *ins); bool visitOutOfLineInterruptCheckImplicit(OutOfLineInterruptCheckImplicit *ins); bool visitUnboxFloatingPoint(LUnboxFloatingPoint *lir); bool visitOutOfLineUnboxFloatingPoint(OutOfLineUnboxFloatingPoint *ool); bool visitOutOfLineStoreElementHole(OutOfLineStoreElementHole *ool); bool visitOutOfLineNewGCThingPar(OutOfLineNewGCThingPar *ool); void loadJSScriptForBlock(MBasicBlock *block, Register reg); void loadOutermostJSScript(Register reg); // Inline caches visitors. bool visitOutOfLineCache(OutOfLineUpdateCache *ool); bool visitGetPropertyCacheV(LGetPropertyCacheV *ins); bool visitGetPropertyCacheT(LGetPropertyCacheT *ins); bool visitGetElementCacheV(LGetElementCacheV *ins); bool visitGetElementCacheT(LGetElementCacheT *ins); bool visitSetElementCacheV(LSetElementCacheV *ins); bool visitSetElementCacheT(LSetElementCacheT *ins); bool visitBindNameCache(LBindNameCache *ins); bool visitCallSetProperty(LInstruction *ins); bool visitSetPropertyCacheV(LSetPropertyCacheV *ins); bool visitSetPropertyCacheT(LSetPropertyCacheT *ins); bool visitGetNameCache(LGetNameCache *ins); bool visitCallsiteCloneCache(LCallsiteCloneCache *ins); bool visitGetPropertyIC(OutOfLineUpdateCache *ool, DataPtr<GetPropertyIC> &ic); bool visitGetPropertyParIC(OutOfLineUpdateCache *ool, DataPtr<GetPropertyParIC> &ic); bool visitSetPropertyIC(OutOfLineUpdateCache *ool, DataPtr<SetPropertyIC> &ic); bool visitSetPropertyParIC(OutOfLineUpdateCache *ool, DataPtr<SetPropertyParIC> &ic); bool visitGetElementIC(OutOfLineUpdateCache *ool, DataPtr<GetElementIC> &ic); bool visitGetElementParIC(OutOfLineUpdateCache *ool, DataPtr<GetElementParIC> &ic); bool visitSetElementIC(OutOfLineUpdateCache *ool, DataPtr<SetElementIC> &ic); bool visitSetElementParIC(OutOfLineUpdateCache *ool, DataPtr<SetElementParIC> &ic); bool visitBindNameIC(OutOfLineUpdateCache *ool, DataPtr<BindNameIC> &ic); bool visitNameIC(OutOfLineUpdateCache *ool, DataPtr<NameIC> &ic); bool visitCallsiteCloneIC(OutOfLineUpdateCache *ool, DataPtr<CallsiteCloneIC> &ic); bool visitAssertRangeI(LAssertRangeI *ins); bool visitAssertRangeD(LAssertRangeD *ins); bool visitAssertRangeF(LAssertRangeF *ins); bool visitAssertRangeV(LAssertRangeV *ins); bool visitInterruptCheck(LInterruptCheck *lir); bool visitAsmJSInterruptCheck(LAsmJSInterruptCheck *lir); bool visitRecompileCheck(LRecompileCheck *ins); IonScriptCounts *extractScriptCounts() { IonScriptCounts *counts = scriptCounts_; scriptCounts_ = nullptr; // prevent delete in dtor return counts; } private: bool addGetPropertyCache(LInstruction *ins, RegisterSet liveRegs, Register objReg, PropertyName *name, TypedOrValueRegister output, bool monitoredResult, jsbytecode *profilerLeavePc); bool addGetElementCache(LInstruction *ins, Register obj, ConstantOrRegister index, TypedOrValueRegister output, bool monitoredResult, bool allowDoubleResult, jsbytecode *profilerLeavePc); bool addSetPropertyCache(LInstruction *ins, RegisterSet liveRegs, Register objReg, PropertyName *name, ConstantOrRegister value, bool strict, bool needsTypeBarrier, jsbytecode *profilerLeavePc); bool addSetElementCache(LInstruction *ins, Register obj, Register unboxIndex, Register temp, FloatRegister tempDouble, FloatRegister tempFloat32, ValueOperand index, ConstantOrRegister value, bool strict, bool guardHoles, jsbytecode *profilerLeavePc); bool generateBranchV(const ValueOperand &value, Label *ifTrue, Label *ifFalse, FloatRegister fr); bool emitAllocateGCThingPar(LInstruction *lir, Register objReg, Register cxReg, Register tempReg1, Register tempReg2, JSObject *templateObj); bool emitCallToUncompiledScriptPar(LInstruction *lir, Register calleeReg); void emitLambdaInit(Register resultReg, Register scopeChainReg, const LambdaFunctionInfo &info); bool emitFilterArgumentsOrEval(LInstruction *lir, Register string, Register temp1, Register temp2); IonScriptCounts *maybeCreateScriptCounts(); // This function behaves like testValueTruthy with the exception that it can // choose to let control flow fall through when the object is truthy, as // an optimization. Use testValueTruthy when it's required to branch to one // of the two labels. void testValueTruthyKernel(const ValueOperand &value, const LDefinition *scratch1, const LDefinition *scratch2, FloatRegister fr, Label *ifTruthy, Label *ifFalsy, OutOfLineTestObject *ool, MDefinition *valueMIR); // Test whether value is truthy or not and jump to the corresponding label. // If the value can be an object that emulates |undefined|, |ool| must be // non-null; otherwise it may be null (and the scratch definitions should // be bogus), in which case an object encountered here will always be // truthy. void testValueTruthy(const ValueOperand &value, const LDefinition *scratch1, const LDefinition *scratch2, FloatRegister fr, Label *ifTruthy, Label *ifFalsy, OutOfLineTestObject *ool, MDefinition *valueMIR); // This function behaves like testObjectEmulatesUndefined with the exception // that it can choose to let control flow fall through when the object // doesn't emulate undefined, as an optimization. Use the regular // testObjectEmulatesUndefined when it's required to branch to one of the // two labels. void testObjectEmulatesUndefinedKernel(Register objreg, Label *ifEmulatesUndefined, Label *ifDoesntEmulateUndefined, Register scratch, OutOfLineTestObject *ool); // Test whether an object emulates |undefined|. If it does, jump to // |ifEmulatesUndefined|; the caller is responsible for binding this label. // If it doesn't, fall through; the label |ifDoesntEmulateUndefined| (which // must be initially unbound) will be bound at this point. void branchTestObjectEmulatesUndefined(Register objreg, Label *ifEmulatesUndefined, Label *ifDoesntEmulateUndefined, Register scratch, OutOfLineTestObject *ool); // Test whether an object emulates |undefined|, and jump to the // corresponding label. // // This method should be used when subsequent code can't be laid out in a // straight line; if it can, branchTest* should be used instead. void testObjectEmulatesUndefined(Register objreg, Label *ifEmulatesUndefined, Label *ifDoesntEmulateUndefined, Register scratch, OutOfLineTestObject *ool); // Get a label for the start of block which can be used for jumping, in // place of jumpToBlock. Label *getJumpLabelForBranch(MBasicBlock *block); void emitStoreElementTyped(const LAllocation *value, MIRType valueType, MIRType elementType, Register elements, const LAllocation *index); // Bailout if an element about to be written to is a hole. bool emitStoreHoleCheck(Register elements, const LAllocation *index, LSnapshot *snapshot); bool emitAssertRangeI(const Range *r, Register input); bool emitAssertRangeD(const Range *r, FloatRegister input, FloatRegister temp); Vector<CodeOffsetLabel, 0, IonAllocPolicy> ionScriptLabels_; #ifdef DEBUG bool branchIfInvalidated(Register temp, Label *invalidated); bool emitDebugResultChecks(LInstruction *ins); bool emitObjectOrStringResultChecks(LInstruction *lir, MDefinition *mir); bool emitValueResultChecks(LInstruction *lir, MDefinition *mir); #endif // Script counts created during code generation. IonScriptCounts *scriptCounts_; #if defined(JS_ION_PERF) PerfSpewer perfSpewer_; #endif }; } // namespace jit } // namespace js #endif /* jit_CodeGenerator_h */
49.214433
101
0.742092
[ "object", "vector" ]
9f310d2853030117968b360e74e6dc2b729faec5
3,035
h
C
libraries/model/include/NodeMap.h
awf/ELL
25c94a1422efc41d5560db11b136f9d8f957ad41
[ "MIT" ]
2,094
2016-09-28T05:55:24.000Z
2019-05-04T19:06:36.000Z
libraries/model/include/NodeMap.h
awesomemachinelearning/ELL
cb897e3aec148a1e9bd648012b5f53ab9d0dd20c
[ "MIT" ]
213
2017-06-30T12:53:40.000Z
2019-05-03T06:35:38.000Z
libraries/model/include/NodeMap.h
awesomemachinelearning/ELL
cb897e3aec148a1e9bd648012b5f53ab9d0dd20c
[ "MIT" ]
301
2017-03-24T08:40:00.000Z
2019-05-02T21:22:28.000Z
//////////////////////////////////////////////////////////////////////////////////////////////////// // // Project: Embedded Learning Library (ELL) // File: NodeMap.h (model) // Authors: Umesh Madan // //////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once #include "Node.h" #include <unordered_map> namespace ell { namespace model { /// <summary> Used by the compiler to maintain tables for data associated with each node. </summary> template <typename ValueType, ValueType defaultValue = ValueType(0)> class NodeMap { public: /// <summary> Get the mapped value for this node, or the default. </summary> /// /// <param name="node"> The node to look up. </param> /// <returns> The value associated with the node, if it has one, otherwise the default. </returns> ValueType Get(const model::Node& node) const; /// <summary> Set the mapped value for this node. </summary> /// /// <param name="node"> The node to set a value for. </param> /// <param name="value"> The value to set for the node. </param> void Set(const model::Node& node, ValueType value); /// <summary> True if the given node is mapped. </summary> /// /// <param name="node"> The node to look up. </param> /// <returns> `true` if the node is in the map. </returns> bool Contains(const model::Node& node) const; /// <summary> Remove the mapped value for this node. </summary> /// /// <param name="node"> The node to remove. </param> void Remove(const model::Node& node); /// <summary> Clear the map </summary> void Clear(); private: std::unordered_map<model::Node::NodeId, ValueType> _map; }; } // namespace model } // namespace ell #pragma region implementation namespace ell { namespace model { template <typename T, T defaultValue> T NodeMap<T, defaultValue>::Get(const model::Node& node) const { T value = defaultValue; auto search = _map.find(node.GetId()); if (search != _map.end()) { value = search->second; } return value; } template <typename T, T defaultValue> void NodeMap<T, defaultValue>::Set(const model::Node& node, T value) { _map[node.GetId()] = value; } template <typename T, T defaultValue> bool NodeMap<T, defaultValue>::Contains(const model::Node& node) const { return (Get(node) != nullptr); } template <typename T, T defaultValue> void NodeMap<T, defaultValue>::Remove(const model::Node& node) { auto search = _map.find(node.GetId()); if (search != _map.end()) { _map.erase(search); } } template <typename T, T defaultValue> void NodeMap<T, defaultValue>::Clear() { _map.clear(); } } // namespace model } // namespace ell #pragma endregion implementation
29.182692
106
0.554201
[ "model" ]
9f3292b71a1101ba52c92c59e3f1931b20be2482
871
h
C
external/adaqs/include/qs_model/qs_model_block.h
qf6101/algorithm-components
f7307e4bd9697ee473d5763e0a61df7891b699f6
[ "Apache-2.0" ]
2
2019-11-27T11:43:45.000Z
2020-11-09T09:21:23.000Z
external/adaqs/include/qs_model/qs_model_block.h
qf6101/algorithm-components
f7307e4bd9697ee473d5763e0a61df7891b699f6
[ "Apache-2.0" ]
null
null
null
external/adaqs/include/qs_model/qs_model_block.h
qf6101/algorithm-components
f7307e4bd9697ee473d5763e0a61df7891b699f6
[ "Apache-2.0" ]
2
2019-12-16T18:54:17.000Z
2020-02-24T07:52:24.000Z
// // Created by qfeng on 17-10-13. // #ifndef QUICKSCORER_QS_MODEL_BLOCK_H #define QUICKSCORER_QS_MODEL_BLOCK_H #include "conf/config.h" #include <Eigen/Sparse> #include <vector> using namespace std; namespace quickscorer { class QSModelBlock { public: shared_ptr<spdlog::logger> _logger; QSModelBlock(); // calculate the score wrt logistic loss float predict(const Eigen::SparseVector<float> &features); // calculate the batch scores wrt logistic loss vector<float> raw_predict(const vector<Eigen::SparseVector<float>> &instances); // calculate the margin virtual float raw_predict(const Eigen::SparseVector<float> &features) = 0; // calculate the index of highest one bit uint32_t highest_one_bit_index(BANDWITH_TYPE n); }; } #endif //QUICKSCORER_QS_MODEL_BLOCK_H
22.921053
87
0.695752
[ "vector" ]
9f46de3276d61ab944eda709c37624abc21a4bde
6,495
h
C
labbot/devel/include/labbot/msgFromLabbot.h
RafalStaszak/autonomous-real
e45214ed323d9627de2c5f1f4188e330d65dd202
[ "MIT" ]
null
null
null
labbot/devel/include/labbot/msgFromLabbot.h
RafalStaszak/autonomous-real
e45214ed323d9627de2c5f1f4188e330d65dd202
[ "MIT" ]
null
null
null
labbot/devel/include/labbot/msgFromLabbot.h
RafalStaszak/autonomous-real
e45214ed323d9627de2c5f1f4188e330d65dd202
[ "MIT" ]
null
null
null
// Generated by gencpp from file labbot/msgFromLabbot.msg // DO NOT EDIT! #ifndef LABBOT_MESSAGE_MSGFROMLABBOT_H #define LABBOT_MESSAGE_MSGFROMLABBOT_H #include <string> #include <vector> #include <map> #include <ros/types.h> #include <ros/serialization.h> #include <ros/builtin_message_traits.h> #include <ros/message_operations.h> namespace labbot { template <class ContainerAllocator> struct msgFromLabbot_ { typedef msgFromLabbot_<ContainerAllocator> Type; msgFromLabbot_() : motorRightInput(0.0) , motorRightSetpoint(0.0) , motorRightOutput(0.0) , motorLeftInput(0.0) , motorLeftSetpoint(0.0) , motorLefttOutput(0.0) { } msgFromLabbot_(const ContainerAllocator& _alloc) : motorRightInput(0.0) , motorRightSetpoint(0.0) , motorRightOutput(0.0) , motorLeftInput(0.0) , motorLeftSetpoint(0.0) , motorLefttOutput(0.0) { (void)_alloc; } typedef float _motorRightInput_type; _motorRightInput_type motorRightInput; typedef float _motorRightSetpoint_type; _motorRightSetpoint_type motorRightSetpoint; typedef float _motorRightOutput_type; _motorRightOutput_type motorRightOutput; typedef float _motorLeftInput_type; _motorLeftInput_type motorLeftInput; typedef float _motorLeftSetpoint_type; _motorLeftSetpoint_type motorLeftSetpoint; typedef float _motorLefttOutput_type; _motorLefttOutput_type motorLefttOutput; typedef boost::shared_ptr< ::labbot::msgFromLabbot_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::labbot::msgFromLabbot_<ContainerAllocator> const> ConstPtr; }; // struct msgFromLabbot_ typedef ::labbot::msgFromLabbot_<std::allocator<void> > msgFromLabbot; typedef boost::shared_ptr< ::labbot::msgFromLabbot > msgFromLabbotPtr; typedef boost::shared_ptr< ::labbot::msgFromLabbot const> msgFromLabbotConstPtr; // constants requiring out of line definition template<typename ContainerAllocator> std::ostream& operator<<(std::ostream& s, const ::labbot::msgFromLabbot_<ContainerAllocator> & v) { ros::message_operations::Printer< ::labbot::msgFromLabbot_<ContainerAllocator> >::stream(s, "", v); return s; } } // namespace labbot namespace ros { namespace message_traits { // BOOLTRAITS {'IsFixedSize': True, 'IsMessage': True, 'HasHeader': False} // {'labbot': ['/home/labbot/ROS-labbot/labbot_ws/src/labbot/msg'], 'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg']} // !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types'] template <class ContainerAllocator> struct IsFixedSize< ::labbot::msgFromLabbot_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsFixedSize< ::labbot::msgFromLabbot_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::labbot::msgFromLabbot_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::labbot::msgFromLabbot_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::labbot::msgFromLabbot_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct HasHeader< ::labbot::msgFromLabbot_<ContainerAllocator> const> : FalseType { }; template<class ContainerAllocator> struct MD5Sum< ::labbot::msgFromLabbot_<ContainerAllocator> > { static const char* value() { return "4bf0f6e2fd2b507f5c1d51ceec5b93b5"; } static const char* value(const ::labbot::msgFromLabbot_<ContainerAllocator>&) { return value(); } static const uint64_t static_value1 = 0x4bf0f6e2fd2b507fULL; static const uint64_t static_value2 = 0x5c1d51ceec5b93b5ULL; }; template<class ContainerAllocator> struct DataType< ::labbot::msgFromLabbot_<ContainerAllocator> > { static const char* value() { return "labbot/msgFromLabbot"; } static const char* value(const ::labbot::msgFromLabbot_<ContainerAllocator>&) { return value(); } }; template<class ContainerAllocator> struct Definition< ::labbot::msgFromLabbot_<ContainerAllocator> > { static const char* value() { return "# right motor parameters\n\ float32 motorRightInput\n\ float32 motorRightSetpoint\n\ float32 motorRightOutput\n\ # left motor parameters\n\ float32 motorLeftInput\n\ float32 motorLeftSetpoint\n\ float32 motorLefttOutput\n\ "; } static const char* value(const ::labbot::msgFromLabbot_<ContainerAllocator>&) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::labbot::msgFromLabbot_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.motorRightInput); stream.next(m.motorRightSetpoint); stream.next(m.motorRightOutput); stream.next(m.motorLeftInput); stream.next(m.motorLeftSetpoint); stream.next(m.motorLefttOutput); } ROS_DECLARE_ALLINONE_SERIALIZER }; // struct msgFromLabbot_ } // namespace serialization } // namespace ros namespace ros { namespace message_operations { template<class ContainerAllocator> struct Printer< ::labbot::msgFromLabbot_<ContainerAllocator> > { template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::labbot::msgFromLabbot_<ContainerAllocator>& v) { s << indent << "motorRightInput: "; Printer<float>::stream(s, indent + " ", v.motorRightInput); s << indent << "motorRightSetpoint: "; Printer<float>::stream(s, indent + " ", v.motorRightSetpoint); s << indent << "motorRightOutput: "; Printer<float>::stream(s, indent + " ", v.motorRightOutput); s << indent << "motorLeftInput: "; Printer<float>::stream(s, indent + " ", v.motorLeftInput); s << indent << "motorLeftSetpoint: "; Printer<float>::stream(s, indent + " ", v.motorLeftSetpoint); s << indent << "motorLefttOutput: "; Printer<float>::stream(s, indent + " ", v.motorLefttOutput); } }; } // namespace message_operations } // namespace ros #endif // LABBOT_MESSAGE_MSGFROMLABBOT_H
27.75641
441
0.733949
[ "vector" ]
9f5d9a3c3d0a57114b8471f80fb3d4aca8a07745
525
h
C
BWT/Classes/Controller/common/User/BWTUserTool.h
Miridescen/BWT
160f1b6aa11c052afe42f157759d7f931ecea184
[ "Apache-2.0" ]
null
null
null
BWT/Classes/Controller/common/User/BWTUserTool.h
Miridescen/BWT
160f1b6aa11c052afe42f157759d7f931ecea184
[ "Apache-2.0" ]
null
null
null
BWT/Classes/Controller/common/User/BWTUserTool.h
Miridescen/BWT
160f1b6aa11c052afe42f157759d7f931ecea184
[ "Apache-2.0" ]
null
null
null
// // BWTUserTool.h // BWT // // Created by Miridescent on 2019/10/24. // Copyright © 2019 Miridescent. All rights reserved. // #import <Foundation/Foundation.h> NS_ASSUME_NONNULL_BEGIN @class BWTUserModel; @interface BWTUserTool : NSObject + (void)loginWithUserModel:(BWTUserModel *)model; + (BWTUserModel *)userModel; + (BOOL)isLogin; + (void)changeUserPhone:(NSString *)phone; + (NSString *)userToken; + (NSInteger)userId; + (void)logout; + (void)presentLoginVC; // 执行一系列是否要login判断 @end NS_ASSUME_NONNULL_END
16.935484
54
0.729524
[ "model" ]
9f764a152d08a4b1f227ec4c3afea586b3f96e83
3,488
h
C
trunk/WCSiOS/Utility/WCSLogging.h
Superalvin1123/wcs-ios-sdk
5721003c1a10bf4799ded5fa42602e5acd396b15
[ "MIT" ]
17
2017-06-12T10:40:19.000Z
2019-07-01T03:18:13.000Z
trunk/WCSiOS/Utility/WCSLogging.h
Superalvin1123/wcs-ios-sdk
5721003c1a10bf4799ded5fa42602e5acd396b15
[ "MIT" ]
2
2017-09-28T09:05:20.000Z
2020-12-22T10:16:14.000Z
trunk/WCSiOS/Utility/WCSLogging.h
Superalvin1123/wcs-ios-sdk
5721003c1a10bf4799ded5fa42602e5acd396b15
[ "MIT" ]
2
2017-07-10T03:40:28.000Z
2018-06-04T08:38:54.000Z
// // Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"). // You may not use this file except in compliance with the License. // A copy of the License is located at // // http://aws.amazon.com/apache2.0 // // or in the "license" file accompanying this file. This file 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. // #import <Foundation/Foundation.h> #define WCSLogFormat @"%@ line:%d | %s | " #define WCSLogError(fmt, ...) [[WCSLogger defaultLogger] log:WCSLogLevelError format:(WCSLogFormat fmt), [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__] #define WCSLogWarn(fmt, ...) [[WCSLogger defaultLogger] log:WCSLogLevelWarn format:(WCSLogFormat fmt), [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__] #define WCSLogInfo(fmt, ...) [[WCSLogger defaultLogger] log:WCSLogLevelInfo format:(WCSLogFormat fmt), [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__] #define WCSLogDebug(fmt, ...) [[WCSLogger defaultLogger] log:WCSLogLevelDebug format:(WCSLogFormat fmt), [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__] #define WCSLogVerbose(fmt, ...) [[WCSLogger defaultLogger] log:WCSLogLevelVerbose format:(WCSLogFormat fmt), [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__] typedef NS_ENUM(NSInteger, WCSLogLevel) { WCSLogLevelUnknown = -1, WCSLogLevelNone = 0, WCSLogLevelError = 1, WCSLogLevelWarn = 2, WCSLogLevelInfo = 3, WCSLogLevelDebug = 4, WCSLogLevelVerbose = 5 }; /** WCSLogger is an utility class that handles logging to the console. Changing log levels during development may make debugging easier. You can change the log level by importing `WCSCore.h` and calling: *Swift* WCSLogger.defaultLogger().logLevel = .Verbose The following logging level options are available: .None .Error (This is the default. Only error logs are printed to the console.) .Warn .Info .Debug .Verbose *Objective-C* [WCSLogger defaultLogger].logLevel = WCSLogLevelVerbose; The following logging level options are available: WCSLogLevelNone WCSLogLevelError (This is the default. Only error logs are printed to the console.) WCSLogLevelWarn WCSLogLevelInfo WCSLogLevelDebug WCSLogLevelVerbose */ @interface WCSLogger : NSObject /** The log level setting. The default is WCSLogLevelError. */ @property (atomic, assign) WCSLogLevel logLevel; /** Returns the shared logger object. @return The shared logger object. */ + (instancetype _Nonnull)defaultLogger; /** Prints out the formatted logs to the console. You can use the following predefined shorthand methods instead: WCSLogError(fmt, ...) WCSLogWarn(fmt, ...) WCSLogInfo(fmt, ...) WCSLogDebug(fmt, ...) WCSLogVerbose(fmt, ...) @param logLevel The level of this log. @param fmt The formatted string to log. */ - (void)log:(WCSLogLevel)logLevel format:(NSString * _Nonnull)fmt, ... NS_FORMAT_FUNCTION(2, 3); @end
35.591837
219
0.736525
[ "object" ]
9f7e58aba3d2d2e52aa4c147bd9913e7080efb60
31,486
c
C
DIR819_v1.06/src/opensource/dlna/dlna_usb/upnp/src/controlpoint.c
Sirherobrine23/Dir819gpl_code
8af92d65416198755974e3247b7bbe7f1151d525
[ "BSD-2-Clause" ]
1
2022-03-19T06:38:01.000Z
2022-03-19T06:38:01.000Z
DIR819_v1.06/src/opensource/dlna/dlna_usb/upnp/src/controlpoint.c
Sirherobrine23/Dir819gpl_code
8af92d65416198755974e3247b7bbe7f1151d525
[ "BSD-2-Clause" ]
null
null
null
DIR819_v1.06/src/opensource/dlna/dlna_usb/upnp/src/controlpoint.c
Sirherobrine23/Dir819gpl_code
8af92d65416198755974e3247b7bbe7f1151d525
[ "BSD-2-Clause" ]
1
2022-03-19T06:38:03.000Z
2022-03-19T06:38:03.000Z
/*************************************************************************** * (c)2008-2009 Broadcom Corporation * * This program is the proprietary software of Broadcom Corporation and/or its licensors, * and may only be used, duplicated, modified or distributed pursuant to the terms and * conditions of a separate, written license agreement executed between you and Broadcom * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants * no license (express or implied), right to use, or waiver of any kind with respect to the * Software, and Broadcom expressly reserves all rights in and to the Software and all * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. * * Except as expressly set forth in the Authorized License, * * 1. This program, including its structure, sequence and organization, constitutes the valuable trade * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, * and to use this information only in connection with your use of Broadcom integrated circuit products. * * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF * USE OR PERFORMANCE OF THE SOFTWARE. * * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF * ANY LIMITED REMEDY. * * $brcm_Workfile: controlpoint.c $ * $brcm_Revision: 11 $ * $brcm_Date: 9/30/09 4:19p $ * * Module Description: * * Revision History: * * $brcm_Log: /AppLibs/upnp/src/controlpoint.c $ * * 11 9/30/09 4:19p dliu * SW7405-2482: Add implemention for DMC * * 10 9/16/09 10:21a dliu * SW7405-2482: Add support for DMC * * 9 7/2/09 10:07a dliu * PR55615: Add support for maxAge = 'infinite' * ***************************************************************************/ #include "upnp_priv.h" #include "device.h" #include "bsocket.h" #include "list.h" #include "subscription.h" #include "controlpoint.h" #include "url.h" #include "gena.h" #include "soap.h" #include "ssdp.h" #include "debug.h" #include "service.h" typedef struct InvokeAysncParam { BUPnPDeviceHandle hDevice; BUPnPServiceHandle hService; BUPnPActionHandle hAction; } InvokeAsyncParam; struct ControlPoint* g_ctrlPoint; static BUPnPError BUPnPControlPoint_DownloadDescription(BUPnPDeviceHandle hDevice); static void BUPnPControlPoint_VerifyDeviceAlive(TimerHandle handle, void* param); static void BUPnPControlPoint_GetDescription(void* data); static void BUPnPControlPoint_InvokeFunc(void* data); static void BUPnPControlPoint_DestroyDevicePriv(BUPnPDeviceHandle hDevice); static void BUPnPControlPoint_DestroyServicePriv(BUPnPDeviceHandle hDevice, BUPnPServiceHandle hService); static BUPnPError BUPnPControlPoint_DownloadServiceDescription(BUPnPDeviceHandle hDevice, HttpContext* pContext); static void BUPnPControlPoint_TriggerCallback(BUPnPDeviceHandle hDevice); #define MX_TIME 5 BUPnPError BUPnPControlPoint_Initialize(BUPnPControlPointOpenSettings* pOpenSettings) { /* Create the object */ g_ctrlPoint = (ControlPointHandle)BUPnPCalloc(1, sizeof(*g_ctrlPoint)); if (!g_ctrlPoint) { UPNP_DEBUG_ERROR(BUPnPDebugCategory_Discovery, ("Out of memory")); return UPNP_E_OUT_OF_MEMORY; } g_ctrlPoint->SsdpAddr.sin_family = AF_INET; g_ctrlPoint->SsdpAddr.sin_addr.s_addr = inet_addr(SSDP_ADDRESS); g_ctrlPoint->SsdpAddr.sin_port = htons(SSDP_PORT); /* Initialize device lists */ BLST_INIT(&g_ctrlPoint->deviceList); BLST_INIT(&g_ctrlPoint->subscriptionList); g_ctrlPoint->deviceListMutex = bthread_mutex_create(); g_ctrlPoint->subscriptionListMutex = bthread_mutex_create(); g_ctrlPoint->deviceAdded = pOpenSettings->deviceAdded; g_ctrlPoint->deviceRemoved = pOpenSettings->deviceRemoved; g_ctrlPoint->propertyChanged = pOpenSettings->propertyChanged; g_ctrlPoint->searchOption = pOpenSettings->searchOption; if (pOpenSettings->searchOption == eSpecificDevice) g_ctrlPoint->searchType = BUPnPStrdup(pOpenSettings->searchType); g_ctrlPoint->userAgent = BUPnPStrdup(pOpenSettings->userAgent); g_ctrlPoint->context = pOpenSettings->context; return UPNP_E_SUCCESS; } void BUPnPControlPoint_Destroy() { BUPnPDeviceHandle hDevice; if (g_ctrlPoint) { bthread_mutex_lock(g_ctrlPoint->deviceListMutex); /* We have to manually loop the list because the pointer could be gone */ while((hDevice=BLST_FIRST(&g_ctrlPoint->deviceList)) != NULL) { BLST_REMOVE(&g_ctrlPoint->deviceList, hDevice, BUPnPDevice, link); BUPnPControlPoint_DestroyDevicePriv(hDevice); BUPnPDevice_Destroy(hDevice); } bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); bthread_mutex_destroy(g_ctrlPoint->deviceListMutex); BUPnPFree(g_ctrlPoint->searchType); BUPnPFree(g_ctrlPoint->userAgent); BUPnPFree(g_ctrlPoint); } } struct sockaddr_in BUPnPControlPoint_GetSsdpAddr() { return g_ctrlPoint->SsdpAddr; } BUPnPError BUPnPControlPoint_UnsubscribeDevice(BUPnPRemoteDeviceHandle hDevice) { struct BUPnPService* pService; for(pService=BLST_FIRST(&hDevice->device->serviceList); pService; pService=BLST_NEXT(pService, link)) { /* it is okay unsubscribe fails */ Gena_Unsubscribe(pService->subscriptionId); } return UPNP_E_SUCCESS; } BUPnPError BUPnPControlPoint_SubscribeDevice(BUPnPRemoteDeviceHandle hDevice) { struct BUPnPService *pService; BUPnPError result; if (BUPnPControlPoint_CheckDeviceAlive(hDevice->device) == false) return UPNP_E_NO_DEVICE; for(pService=BLST_FIRST(&hDevice->device->serviceList); pService; pService=BLST_NEXT(pService, link)) { /* Only subscribe if we got a sub url */ /* TODO: Change this to only subscribe to services we care about because * some device have additional service that we don't know about */ if (pService->serviceInfo->eventSubUrl != NULL) { UPNP_DEBUG_TRACE(BUPnPDebugCategory_Eventing, ("found service sub url %s\n", pService->serviceInfo->eventSubUrl)); result = Gena_Subscribe(hDevice->device, pService); if (result != UPNP_E_SUCCESS) return result; } } return UPNP_E_SUCCESS; } void BUPnPControlPoint_SearchDevices() { /* Always send search twice per the spec */ if (g_ctrlPoint->searchOption == eSpecificDevice) { UPNP_DEBUG_TRACE( BUPnPDebugCategory_Discovery, ("Send M-SEARCH request for %s\n", g_ctrlPoint->searchType)); Ssdp_SendSearchRequest( MX_TIME, g_ctrlPoint->searchType); Ssdp_SendSearchRequest( MX_TIME, g_ctrlPoint->searchType); } else { UPNP_DEBUG_TRACE( BUPnPDebugCategory_Discovery, ("Send M-SEARCH request for %s\n", SSDP_ALL)); Ssdp_SendSearchRequest( MX_TIME, SSDP_ALL); Ssdp_SendSearchRequest( MX_TIME, SSDP_ALL); } } BUPnPError BUPnPControlPoint_GetIconCount(BUPnPRemoteDeviceHandle hDevice, size_t* count) { BUPnPIconHandle hIcon; *count = 0; if (BUPnPControlPoint_CheckDeviceAlive(hDevice->device)) { if ( !BLST_EMPTY(&hDevice->device->iconList) ) { for(hIcon = BLST_FIRST(&hDevice->device->iconList); hIcon; hIcon = BLST_NEXT(hIcon, link)) *count++; } } else return UPNP_E_NO_DEVICE; return UPNP_E_SUCCESS; } BUPnPError BUPnPControlPoint_GetDeviceIconInfo(BUPnPRemoteDeviceHandle hDevice, int index, struct BUPnPIconInfo* pIconInfo) { struct BUPnPIcon* pIcon; if (BUPnPControlPoint_CheckDeviceAlive(hDevice->device)) { pIcon = BLST_FIRST(&hDevice->device->iconList); for(;pIcon; pIcon = BLST_NEXT(pIcon, link)) { if (index-- == 0) { memcpy(pIconInfo, &pIcon->iconInfo, sizeof(struct BUPnPIconInfo)); return UPNP_E_SUCCESS; } } return UPNP_E_NO_ICON; } else { return UPNP_E_NO_DEVICE; } } void BUPnPControlPoint_DestroyIcons(void) { } BUPnPError BUPnPControlPoint_GetDeviceInfo(BUPnPRemoteDeviceHandle hDevice, BUPnPDeviceInfo* pDeviceInfo) { if (BUPnPControlPoint_CheckDeviceAlive(hDevice->device) == false) return UPNP_E_NO_DEVICE; memcpy(pDeviceInfo, hDevice->device->deviceInfo, sizeof(*pDeviceInfo)); return UPNP_E_SUCCESS; } BUPnPError BUPnPControlPoint_DownloadServiceDescription(BUPnPDeviceHandle hDevice, HttpContext* pContext) { int result = 0; BUPnPServiceHandle hService; HttpStatusCode statusCode; char headers[UPNP_MAX_PACKET_SIZE]; UPNP_DEBUG_TRACE( BUPnPDebugCategory_Description, ("Downloading Description from %s\n", BUPnPDevice_GetLocation(hDevice))); hService = BLST_FIRST(&hDevice->serviceList); while(hService!=NULL) { if (!Http_IsPersistent(pContext)) { closesocket(pContext->s); pContext->s = BSocket_CreateTcpClient(hDevice->url.host, hDevice->url.port); if ( pContext->s <= 0 ) return UPNP_E_SOCKET; } Http_ClearContext(pContext); snprintf(headers, sizeof(headers)-1, "HOST: %s:%d\r\n" "CONTENT-LENGTH: 0\r\n" "\r\n", hDevice->url.host, hDevice->url.port); UPNP_DEBUG_TRACE(BUPnPDebugCategory_Description, ("Request = %s", headers)); /* send it off */ if ((result = Http_Invoke(pContext, "GET", hService->serviceInfo->scpdUrl, headers, NULL)) != UPNP_E_SUCCESS) { if ( result == UPNP_E_SOCKET_CLOSED) { /* server might have closed the socket without telling us about it */ closesocket(pContext->s); pContext->s = BSocket_CreateTcpClient(hDevice->url.host, hDevice->url.port); if ( pContext->s <= 0 ) { Http_DestroyContext(pContext); return UPNP_E_SOCKET; } if ((result = Http_Invoke(pContext, "GET", hService->serviceInfo->scpdUrl, headers, NULL)) != UPNP_E_SUCCESS) { UPNP_DEBUG_ERROR(BUPnPDebugCategory_Description, ("Unable to download service description %s", hService->serviceInfo->scpdUrl)); BUPnPControlPoint_DestroyServicePriv(hDevice, hService); closesocket(pContext->s); return UPNP_E_SERVICE_NOT_FOUND; } } else { UPNP_DEBUG_ERROR(BUPnPDebugCategory_Description, ("Unable to download service description %s", hService->serviceInfo->scpdUrl)); BUPnPControlPoint_DestroyServicePriv(hDevice, hService); closesocket(pContext->s); return UPNP_E_SERVICE_NOT_FOUND; } } UPNP_DEBUG_TRACE(BUPnPDebugCategory_Description, ("Content = %s", Http_GetBody(pContext))); if (Http_GetBody(pContext)) { statusCode = Http_GetStatusCode(pContext); if (statusCode != HTTP_OK) { UPNP_DEBUG_ERROR( BUPnPDebugCategory_Description, ("Unable to retrieve service description")); result = UPNP_E_INVALID_CONTROL_URL; } else result = BUPnPService_ParseDescriptipn(hService, Http_GetBody(pContext)); } else { UPNP_DEBUG_ERROR( BUPnPDebugCategory_Description, ("Unable to retrieve device description")); result = UPNP_E_INVALID_CONTROL_URL; } hService = BLST_NEXT(hService, link); } Http_DestroyContext(pContext); UPNP_DEBUG_TRACE(BUPnPDebugCategory_Description, ("Get description from %s complete", BUPnPDevice_GetLocation(hDevice))); return result; } BUPnPError BUPnPControlPoint_DownloadDescription(BUPnPDeviceHandle hDevice) { int urlBaseLen; char* pUrlBase; BUPnPError result; HttpContext context; BUPnPDeviceHandle hSubDevice; char uri[UPNP_MAX_URI_SIZE], headers[UPNP_MAX_PACKET_SIZE]; UPNP_DEBUG_TRACE( BUPnPDebugCategory_Description, ("Downloading Description from %s\n", BUPnPDevice_GetLocation(hDevice))); result = Http_CreateContext(&context); if ( result != UPNP_E_SUCCESS ) return result; context.s = BSocket_CreateTcpClient(hDevice->url.host, hDevice->url.port); if ( context.s <= 0 ) return UPNP_E_SOCKET; if (hDevice->url.query != NULL) sprintf(uri, "%s?%s", hDevice->url.path, hDevice->url.query); else cmsUtl_strcpy(uri, hDevice->url.path); snprintf(headers, sizeof(headers)-1, "HOST: %s:%d\r\n" "CONTENT-LENGTH: 0\r\n" "\r\n", hDevice->url.host, hDevice->url.port); UPNP_DEBUG_TRACE(BUPnPDebugCategory_Description, ("Request = %s", headers)); /* send it off */ if ((result = Http_Invoke(&context, "GET", uri, headers, NULL)) != UPNP_E_SUCCESS) { Http_DestroyContext(&context); return result; } UPNP_DEBUG_TRACE(BUPnPDebugCategory_Description, ("Content = %s", Http_GetBody(&context))); if (Http_GetBody(&context)) { urlBaseLen = cmsUtl_strlen(hDevice->url.path); if (hDevice->url.path[urlBaseLen-1] != '/') { pUrlBase = strrchr(hDevice->url.path, '/'); pUrlBase[1] = '\0'; } hDevice->urlBase = BUPnPStrdup(hDevice->url.path); result = BUPnPDevice_ParseDescription(hDevice, Http_GetBody(&context)); if (result == UPNP_E_SUCCESS) result = BUPnPControlPoint_DownloadServiceDescription(hDevice, &context); } else { UPNP_DEBUG_ERROR( BUPnPDebugCategory_Description, ("Unable to retrieve device description")); result = UPNP_E_INVALID_CONTROL_URL; } for(hSubDevice=BLST_FIRST(&g_ctrlPoint->deviceList); hSubDevice; hSubDevice=BLST_NEXT(hSubDevice, link)) { if (hSubDevice->parent != NULL) { if(hSubDevice->parent == hDevice) result = BUPnPControlPoint_DownloadServiceDescription(hSubDevice, &context); } } closesocket(context.s); Http_DestroyContext(&context); UPNP_DEBUG_TRACE(BUPnPDebugCategory_Description, ("Get description from %s complete", BUPnPDevice_GetLocation(hDevice))); return result; } BUPnPError BUPnPControlPoint_GetService(BUPnPRemoteDeviceHandle hDevice, const char* serviceName, struct BUPnPService** ppService) { BUPnPServiceHandle hService; if (hDevice == NULL) return UPNP_E_NO_DEVICE; if (BUPnPControlPoint_CheckDeviceAlive(hDevice->device) == false) return UPNP_E_NO_DEVICE; hService = BLST_FIRST(&hDevice->device->serviceList); while(hService) { if (MATCH(hService->serviceInfo->serviceId, serviceName)) { *ppService = hService; return UPNP_E_SUCCESS; } hService = BLST_NEXT(hService, link); } return UPNP_E_SUCCESS; } static void BUPnPControlPoint_DestroyServicePriv(BUPnPDeviceHandle hDevice, BUPnPServiceHandle hService) { BUPnPFree((void*)(hService->serviceInfo->serviceId)); BUPnPFree((void*)(hService->serviceInfo->scpdUrl)); BUPnPFree((void*)(hService->serviceInfo->controlUrl)); BUPnPFree((void*)(hService->serviceInfo->eventSubUrl)); BUPnPFree((void*)(hService->serviceInfo)); BLST_REMOVE_HEAD(&hDevice->serviceList, link); BUPnPService_Destroy(hService); } static void BUPnPControlPoint_DestroyDevicePriv(BUPnPDeviceHandle hDevice) { BUPnPServiceHandle hService; BUPnPIconHandle hIcon; BUPnPActionHandle hAction; BUPnPStateVariableHandle hStateVariable; size_t i; /* we don't close the socket here because it will cause the select to fail */ hService = BLST_FIRST(&hDevice->serviceList); while(hService) { if ( hService->subscriptionId != NULL) Gena_RemoveSubscriptionByService(hService); BUPnPFree((void*)(hService->serviceInfo->serviceId)); BUPnPFree((void*)(hService->serviceInfo->scpdUrl)); BUPnPFree((void*)(hService->serviceInfo->controlUrl)); BUPnPFree((void*)(hService->serviceInfo->eventSubUrl)); BUPnPFree((void*)(hService->serviceInfo)); while( (hAction = BLST_FIRST(&hService->actions)) != NULL ) { BLST_REMOVE_HEAD(&hService->actions, link); for ( i=0; i<hAction->argumentCount; i++ ) { BUPnPFree((void*)hAction->arguments[i].argumentInfo->name); BUPnPFree(hAction->arguments[i].argumentInfo); } BUPnPFree((void*)hAction->actionInfo->name); BUPnPFree(hAction->actionInfo); BUPnPAction_Destroy(hAction); } while( (hStateVariable = BLST_FIRST(&hService->stateVariables)) != NULL ) { BUPnPFree((void*)hStateVariable->variableInfo->name); BUPnPFree(hStateVariable->variableInfo); BLST_REMOVE_HEAD(&hService->stateVariables, link); BUPnPStateVariable_Destroy(hStateVariable); } hService = BLST_NEXT(hService, link); } while( (hIcon = BLST_FIRST(&hDevice->iconList)) != NULL ) { BLST_REMOVE_HEAD(&hDevice->iconList, link); BUPnPFree((void*)(hIcon->iconInfo->mimeType)); BUPnPFree((void*)(hIcon->iconInfo->url)); BUPnPFree(hIcon->iconInfo); BUPnPFree(hIcon); } BUPnPFree((void*)(hDevice->deviceInfo->udn)); BUPnPFree((void*)(hDevice->deviceInfo->friendlyName)); BUPnPFree((void*)(hDevice->deviceInfo->manufacturer)); BUPnPFree((void*)(hDevice->deviceInfo->manufacturerUrl)); BUPnPFree((void*)(hDevice->deviceInfo->modelDescription)); BUPnPFree((void*)(hDevice->deviceInfo->modelName)); BUPnPFree((void*)(hDevice->deviceInfo->modelNumber)); BUPnPFree((void*)(hDevice->deviceInfo->modelUrl)); BUPnPFree((void*)(hDevice->deviceInfo->serialNumber)); BUPnPFree((void*)(hDevice->deviceInfo->upc)); BUPnPFree((void*)(hDevice->deviceInfo->presentationUrl)); BUPnPFree((void*)(hDevice->urlBase)); BUPnPFree(hDevice->deviceInfo); } static void BUPnPControlPoint_GetDescription(void* data) { int result; BUPnPDeviceHandle hDevice = (BUPnPDeviceHandle)data; BUPnPDeviceHandle hSubDevice; /* device might be removed before we have a chance to get it */ if (BUPnPControlPoint_CheckDeviceAlive(hDevice) == false) return; /* cannot lock here because DownloadDescription could take up to 30 seconds */ if ((result = BUPnPControlPoint_DownloadDescription(hDevice)) != UPNP_E_SUCCESS) { /* At this point, either the devie is incorrect or download failed so just remove it */ bthread_mutex_lock(g_ctrlPoint->deviceListMutex); assert(hDevice != NULL); BLST_REMOVE(&g_ctrlPoint->deviceList, hDevice, BUPnPDevice, link); bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); UPNP_DEBUG_ERROR(BUPnPDebugCategory_Description, ("Unabled to download description from %s, error=%d", hDevice->url.path, result)); /* remove timer */ if (hDevice->expirationTimer != NULL) Timer_Destroy(hDevice->expirationTimer); if ( hDevice) { /* This frees all resources in the device info structure */ BUPnPControlPoint_DestroyDevicePriv(hDevice); BUPnPDevice_Destroy(hDevice); } } else { BUPnPControlPoint_TriggerCallback(hDevice); for(hSubDevice=BLST_FIRST(&g_ctrlPoint->deviceList); hSubDevice; hSubDevice=BLST_NEXT(hSubDevice, link)) { if (hSubDevice->parent != NULL) { if(hSubDevice->parent == hDevice) BUPnPControlPoint_TriggerCallback(hSubDevice); } } } } void BUPnPControlPoint_AddSubDevice(BUPnPDeviceHandle hDevice) { bthread_mutex_lock(g_ctrlPoint->deviceListMutex); /* it is okay if this fails. Just means it was already added during discovery to prevent duplicated downloads */ BLST_DICT_ADD(&g_ctrlPoint->deviceList, hDevice, BUPnPDevice, deviceInfo->udn, link, ignore); ignore: bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); } void BUPnPControlPoint_TriggerCallback(BUPnPDeviceHandle hDevice) { /* last check to make sure it is the proper device before we inform the application */ if (g_ctrlPoint->searchType == NULL) { if (g_ctrlPoint->deviceAdded != NULL) g_ctrlPoint->deviceAdded(g_ctrlPoint->context, hDevice->deviceInfo->udn, hDevice->deviceType); } else { if (IMATCH_PREFIX(g_ctrlPoint->searchType, hDevice->deviceType)) { if (g_ctrlPoint->deviceAdded != NULL) { g_ctrlPoint->deviceAdded(g_ctrlPoint->context, hDevice->deviceInfo->udn, hDevice->deviceType); } } } } void BUPnPControlPoint_AddDevice(const char* uuid, int maxAge, const char* location) { BUPnPDeviceHandle hDevice; BUPnPDeviceInfo *hDeviceInfo; TimerSettings timerSettings; void* prevUuid; bthread_mutex_lock(g_ctrlPoint->deviceListMutex); UPNP_DEBUG_TRACE(BUPnPDebugCategory_Discovery, ("Adding Device at %s (%s)", location, uuid)); /* Make sure it doesn't exist already, and make sure we don't already have the root device */ for(hDevice=BLST_FIRST(&g_ctrlPoint->deviceList); hDevice; hDevice=BLST_NEXT(hDevice, link)) { if (IMATCH(hDevice->deviceInfo->udn, uuid)) break; /* Make sure it not a sub device. If it is, we'll add it when we get description */ if (MATCH(BUPnPDevice_GetLocation(hDevice), location)) { bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); return; } } if (NULL != hDevice) { bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); /* already exists so just renew it */ if (hDevice->expirationTimer != NULL) { prevUuid = Timer_GetParam(hDevice->expirationTimer); Timer_Destroy(hDevice->expirationTimer); if (maxAge != 0) /* maxAge of 0 indicates that it is infinite or not known */ { timerSettings.period = 1000*maxAge; timerSettings.callback = BUPnPControlPoint_VerifyDeviceAlive; timerSettings.param = prevUuid; timerSettings.executeOnce = true; hDevice->expirationTimer = Timer_Create(&timerSettings); } } return; } /* Create a new device */ hDeviceInfo = (BUPnPDeviceInfo*)BUPnPCalloc(1, sizeof(*hDeviceInfo)); if ( hDeviceInfo == NULL ) { bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); UPNP_DEBUG_ERROR(BUPnPDebugCategory_Description, ("Out of memory:Create device info")); return; } hDevice = BUPnPDevice_Create(hDeviceInfo); hDevice->deviceInfo->udn = BUPnPStrdup(uuid); Url_Create(&(hDevice->url), location); /* Keep track of cache-control time */ if (maxAge != 0) /* maxAge is not infinite */ { timerSettings.period = 1000*maxAge; timerSettings.callback = BUPnPControlPoint_VerifyDeviceAlive; timerSettings.param = (void*)BUPnPStrdup(uuid); timerSettings.executeOnce = true; hDevice->expirationTimer = Timer_Create(&timerSettings); } /* Add it first so we don't call get description twice */ BLST_DICT_ADD(&g_ctrlPoint->deviceList, hDevice, BUPnPDevice, deviceInfo->udn, link, error); bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); /* launch worker thread */ UPNP_DEBUG_TRACE(BUPnPDebugCategory_Discovery, ("Device %s added", location, uuid)); bthread_create(BUPnPControlPoint_GetDescription, (void*)hDevice); error: assert(true); } void BUPnPControlPoint_RemoveDevice(const char* uuid) { BUPnPDeviceHandle hDevice; if (g_ctrlPoint == NULL) return; UPNP_DEBUG_TRACE(BUPnPDebugCategory_Description, ("Removing %s", uuid)); /* callback before we actually delete */ BLST_DICT_FIND_BY_STR(&g_ctrlPoint->deviceList, hDevice, uuid, deviceInfo->udn, link); if (hDevice) { if (g_ctrlPoint->deviceRemoved != NULL) g_ctrlPoint->deviceRemoved(g_ctrlPoint->context, uuid); bthread_mutex_lock(g_ctrlPoint->deviceListMutex); BLST_REMOVE(&g_ctrlPoint->deviceList, hDevice, BUPnPDevice, link); bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); /* This frees all resources in the device info structure */ BUPnPControlPoint_DestroyDevicePriv(hDevice); BUPnPDevice_Destroy(hDevice); } } void BUPnPControlPoint_InvokeCallback(const char* serviceName, const char* variable) { if (g_ctrlPoint->propertyChanged != NULL) g_ctrlPoint->propertyChanged(g_ctrlPoint->context, serviceName, variable); } BUPnPError BUPnPControlPoint_Invoke(BUPnPRemoteDeviceHandle hDevice, BUPnPServiceHandle pService, BUPnPActionHandle hAction) { //return Soap_Invoke(hDevice->device->url, pService, hAction); return Soap_Invoke(hDevice->device, pService, hAction); } static void BUPnPControlPoint_InvokeFunc(void* data) { UNUSED_ARGUMENT(data); //InvokeAsyncParam* param = (InvokeAsyncParam*)data; //Soap_Invoke(param->hDevice->url, param->hService, param->hAction); /*g_ctrlPoint->callback(g_ctrlPoint->context, BUPnPControlPointEvent_eActionComplete, (void*)param->hAction); */ } void BUPnPControlPoint_InvokeAsync(BUPnPDeviceHandle hDevice, BUPnPServiceHandle hService, BUPnPActionHandle hAction) { InvokeAsyncParam* param = (InvokeAsyncParam*)BUPnPCalloc(1, sizeof(InvokeAsyncParam)); param->hDevice = hDevice; param->hService = hService; param->hAction = hAction; bthread_create(BUPnPControlPoint_InvokeFunc, (void*)param); } bthread_mutex_t* BUPnPControlPoint_GetSubscriptionsMutex(void) { return g_ctrlPoint->subscriptionListMutex; } struct BUPnPSubscriptionList* BUPnPControlPoint_GetSubscriptionList() { return &g_ctrlPoint->subscriptionList; } static void BUPnPControlPoint_VerifyDeviceAlive(TimerHandle handle, void* param) { UNUSED_ARGUMENT(handle); BUPnPControlPoint_RemoveDevice((const char*)param); BUPnPFree(param); } void BUPnPControlPoint_GetDefaultOpenSettings(BUPnPControlPointOpenSettings* pOpenSettings) { memset(pOpenSettings, 0, sizeof(*pOpenSettings)); /* Default to search for all devices */ pOpenSettings->searchOption = eAllDevices; } const char* BUPnPControlPoint_GetUserAgent(void) { return g_ctrlPoint->userAgent; } bool BUPnPControlPoint_CheckDeviceAlive(BUPnPDeviceHandle selectedDevice) { BUPnPDeviceHandle hDevice; if (selectedDevice == NULL) return false; bthread_mutex_lock(g_ctrlPoint->deviceListMutex); /* We have to manually loop the list because the pointer could be gone */ for(hDevice=BLST_FIRST(&g_ctrlPoint->deviceList); hDevice; hDevice=BLST_NEXT(hDevice, link)) { if (selectedDevice == hDevice) { bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); return true; } } bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); return false; } bool BUPnPControlPoint_IsEnabled(void) { if (g_ctrlPoint != NULL) return true; else return false; } void BUPnPControlPoint_DestroyDevice(BUPnPRemoteDeviceHandle pDevice) { BUPnPFree(pDevice); pDevice = NULL; } BUPnPRemoteDeviceHandle BUPnPControlPoint_CreateDevice(const char* uuid) { BUPnPDeviceHandle hDevice; BUPnPRemoteDevice* hNewDevice = (BUPnPRemoteDevice*)BUPnPCalloc(1, sizeof(BUPnPRemoteDevice)); bthread_mutex_lock(g_ctrlPoint->deviceListMutex); /* We have to manually loop the list because the pointer could be gone */ for(hDevice=BLST_FIRST(&g_ctrlPoint->deviceList); hDevice; hDevice=BLST_NEXT(hDevice, link)) { if (MATCH(hDevice->deviceInfo->udn, uuid)) { hNewDevice->device = hDevice; bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); return hNewDevice; } } /* cannot find out, maybe it went away already */ bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); return NULL; } bool BUPnPControlPoint_CheckActionExists(const char* uuid, const char* serviceName, const char* actionName) { BUPnPDeviceHandle hDevice; BUPnPServiceHandle hService; BUPnPActionHandle hAction; bthread_mutex_lock(g_ctrlPoint->deviceListMutex); /* it is okay if this fails. Just means it was already added during discovery to prevent duplicated downloads */ BLST_DICT_FIND_BY_STR(&g_ctrlPoint->deviceList, hDevice, uuid, deviceInfo->udn, link); bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); if (hDevice != NULL) { hService = BLST_FIRST(&hDevice->serviceList); while (hService!=NULL) { if (IMATCH(hService->serviceInfo->serviceId, serviceName)) { hAction = BUPnPService_GetAction(hService, actionName); if (hAction != NULL) return true; } hService = BLST_NEXT(hService, link); } } return false; } bool BUPnPControlPoint_CheckServiceExists(const char* uuid, const char* serviceName) { BUPnPDeviceHandle hDevice; BUPnPServiceHandle hService; bthread_mutex_lock(g_ctrlPoint->deviceListMutex); /* it is okay if this fails. Just means it was already added during discovery to prevent duplicated downloads */ BLST_DICT_FIND_BY_STR(&g_ctrlPoint->deviceList, hDevice, uuid, deviceInfo->udn, link); bthread_mutex_unlock(g_ctrlPoint->deviceListMutex); if (hDevice != NULL) { hService = BLST_FIRST(&hDevice->serviceList); while (hService!=NULL) { if (IMATCH(hService->serviceInfo->serviceId, serviceName)) return true; hService = BLST_NEXT(hService, link); } } return false; }
35.258679
139
0.678429
[ "object" ]
9f8546a1d9d081683904e7b7f51c60ea73601d1c
35,946
c
C
QCA4020_SDK/target/quartz/demo/QCLI_demo/src/net/iperf.c
r8d8/lastlock
78c02e5fbb129b1bc4147bd55eec2882267d7e87
[ "Apache-2.0" ]
null
null
null
QCA4020_SDK/target/quartz/demo/QCLI_demo/src/net/iperf.c
r8d8/lastlock
78c02e5fbb129b1bc4147bd55eec2882267d7e87
[ "Apache-2.0" ]
null
null
null
QCA4020_SDK/target/quartz/demo/QCLI_demo/src/net/iperf.c
r8d8/lastlock
78c02e5fbb129b1bc4147bd55eec2882267d7e87
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2016-2018 Qualcomm Technologies, Inc. * All Rights Reserved. */ // Copyright (c) 2018 Qualcomm Technologies, Inc. // All rights reserved. // Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) // 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 Qualcomm Technologies, Inc. nor the names of its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "stdio.h" #include "stdlib.h" #include "string.h" #include "qapi_status.h" #include "iperf.h" #include "bench.h" #ifdef CONFIG_NET_TXRX_DEMO extern QCLI_Group_Handle_t qcli_net_handle; /* Handle for Net Command Group. */ extern uint8_t benchtx_quit; extern uint8_t benchrx_quit; #define IPERF_PRINTF(...) QCLI_Printf(qcli_net_handle, __VA_ARGS__) static void iperf3_make_cookie(char *str, int len); static void iperf3_tx_reverse(THROUGHPUT_CXT *p_tCxt); /*************************************************************************************** * * iperf function * **************************************************************************************/ QCLI_Command_Status_t iperf(uint32_t Parameter_Count, QCLI_Parameter_t *Parameter_List) { unsigned int protocol = TCP; unsigned int port = IPERF_DEFAULT_PORT; unsigned int port_tag = 0; unsigned int seconds = IPERF_DEFAULT_RUNTIME; unsigned int pktSize = 0; int operation_mode = -1; int reverse_mode = 0; unsigned int udpRate = IPERF_DEFAULT_UDP_RATE; unsigned short mcastEnabled = 0; unsigned int ipAddress = 0; unsigned int numOfPkts = 0; unsigned int interval = 0; unsigned int index = 0; THROUGHPUT_CXT tCxt; THROUGHPUT_CXT rCxt; uint32_t v6 = 0; char *receiver_ip; memset(&tCxt, 0, sizeof(THROUGHPUT_CXT)); memset(&rCxt, 0, sizeof(THROUGHPUT_CXT)); index = 0; if(Parameter_Count < 1) { IPERF_PRINTF("\nUsage: iperf [-s|-c host] [options]\n"); IPERF_PRINTF(" -p = The server port for the server to listen on and the client to connect to. This should be the same in both client and server. Default is 5001.\n"); IPERF_PRINTF(" -i = Sets the interval time in seconds between periodic bandwidth, jitter, and loss reports\n"); IPERF_PRINTF(" -u = Use UDP rather than TCP\n"); IPERF_PRINTF(" -l = The length of buffers to read or write\n"); IPERF_PRINTF(" -t = The time in seconds to transmit for\n"); IPERF_PRINTF(" -n = The number of buffers to transmit\n"); IPERF_PRINTF(" -b = Set target bandwidth to n bits/sec\n"); IPERF_PRINTF(" -r = Client Reserve Mode\n"); IPERF_PRINTF(" -V = IPV6\n"); return QCLI_STATUS_ERROR_E; } while (index < Parameter_Count) { if (0 == strcmp(Parameter_List[index].String_Value, "-u")) { index++; protocol = UDP; } else if (0 == strcmp(Parameter_List[index].String_Value, "-s")) { index++; operation_mode = IPERF_SERVER; } else if (0 == strcmp(Parameter_List[index].String_Value, "-c")) { index++; operation_mode = IPERF_CLIENT; if(inet_pton(AF_INET, Parameter_List[index].String_Value, &ipAddress) != 0) { /* check if it's IPV6 */ receiver_ip = Parameter_List[index].String_Value; if (inet_pton(AF_INET6, receiver_ip, tCxt.params.tx_params.v6addr) != 0) { IPERF_PRINTF("Incorrect IP address %s\n", receiver_ip); return QCLI_STATUS_ERROR_E; } else { /* is valid IPV6*/ if (QAPI_IS_IPV6_LINK_LOCAL(tCxt.params.tx_params.v6addr) || QAPI_IS_IPV6_MULTICAST(tCxt.params.tx_params.v6addr)) { /* if this is a link local address, then the interface must be specified after % */ char * interface_name = (char*) bench_common_GetInterfaceNameFromStr(receiver_ip); if (!interface_name) { IPERF_PRINTF("this is a link local address, then the interface must be specified after %\n", receiver_ip); return QCLI_STATUS_ERROR_E; } if (qapi_Net_IPv6_Get_Scope_ID(interface_name, &tCxt.params.tx_params.scope_id) != 0) { IPERF_PRINTF("Failed to get scope id for the interface %s\n", interface_name); return QCLI_STATUS_ERROR_E; } } } } else { /* is valid IPV4 */ if ((ipAddress & 0xf0000000) == 0xE0000000) //224.xxx.xxx.xxx - 239.xxx.xxx.xxx { mcastEnabled =1; } } index++; } else if (0 == strcmp(Parameter_List[index].String_Value, "-p")) { index++; port = Parameter_List[index].Integer_Value; port_tag = 1; index++; if(port > 64*1024) { IPERF_PRINTF("error: invalid port\n"); return QCLI_STATUS_ERROR_E; } } else if (0 == strcmp(Parameter_List[index].String_Value, "-i")) { index++; interval = Parameter_List[index].Integer_Value; index++; } else if (0 == strcmp(Parameter_List[index].String_Value, "-l")) { index++; pktSize = Parameter_List[index].Integer_Value; index++; } else if (0 == strcmp(Parameter_List[index].String_Value, "-t")) { index++; seconds = Parameter_List[index].Integer_Value; index++; } else if (0 == strcmp(Parameter_List[index].String_Value, "-n")) { index++; numOfPkts = Parameter_List[index].Integer_Value; index++; } else if (0 == strcmp(Parameter_List[index].String_Value, "-b")) { index++; udpRate = Parameter_List[index].Integer_Value; index++; } else if (0 == strcmp(Parameter_List[index].String_Value, "-V")) { index++; v6 = 1; } else if (0 == strcmp(Parameter_List[index].String_Value, "-r")) { index++; reverse_mode = 1; } else if (0 == strcmp(Parameter_List[index].String_Value, "-h")) { index++; IPERF_PRINTF("Usage: iperf [-s|-c host] [options]\n"); IPERF_PRINTF(" iperf [-h]\n"); } else { /*silent ignore*/ index++; } } tCxt.is_iperf = 1; tCxt.pktStats.iperf_display_interval = interval; tCxt.pktStats.iperf_udp_rate = udpRate; rCxt.is_iperf = 1; rCxt.pktStats.iperf_display_interval = interval; rCxt.pktStats.iperf_udp_rate = udpRate; if (operation_mode == IPERF_CLIENT) { benchtx_quit = 0; tCxt.params.tx_params.v6 = v6; tCxt.params.tx_params.ip_address = ipAddress; if (pktSize > 0) { if (v6) { if (protocol == TCP) { pktSize = min(pktSize, IPERF_MAX_PACKET_SIZE_TCPV6); } else { pktSize = min(pktSize, IPERF_MAX_PACKET_SIZE_UDPV6); } } else { if (protocol == TCP) { pktSize = min(pktSize, IPERF_MAX_PACKET_SIZE_TCP); } else { pktSize = min(pktSize, IPERF_MAX_PACKET_SIZE_UDP); } } } else { if (v6) { if (protocol == TCP) { pktSize = IPERF_MAX_PACKET_SIZE_TCPV6; } else { pktSize = IPERF_MAX_PACKET_SIZE_UDPV6; } } else { if (protocol == TCP) { pktSize = IPERF_MAX_PACKET_SIZE_TCP; } else { pktSize = IPERF_MAX_PACKET_SIZE_UDP; } } } tCxt.params.tx_params.packet_size = pktSize; tCxt.params.tx_params.test_mode = TIME_TEST; tCxt.params.tx_params.tx_time = seconds; if (numOfPkts > 0) { tCxt.params.tx_params.test_mode = PACKET_TEST; tCxt.params.tx_params.packet_number = numOfPkts; } /* set default iperf3 port if reverse_mode */ if( (reverse_mode != 0) && (port_tag == 0) ) { port = IPERF3_DEFAULT_PORT; } if ((protocol == UDP) && mcastEnabled) { IPERF_PRINTF("Multicast transmit not yet implemented\n"); } else if (protocol == UDP) { bench_common_SetParams(&tCxt, tCxt.params.tx_params.v6, "udp", port, TX); if( reverse_mode == 0 ) { bench_udp_tx(&tCxt); } else /* iperf3 udp reverse mode */ { iperf3_tx_reverse(&tCxt); } } else if (protocol == TCP) { bench_common_SetParams(&tCxt, tCxt.params.tx_params.v6, "tcp", port, TX); if( reverse_mode == 0 ) { bench_tcp_tx(&tCxt); } else /* iperf3 tcp reverse mode */ { iperf3_tx_reverse(&tCxt); } } } else if (operation_mode == IPERF_SERVER) { benchrx_quit = 0; rCxt.params.rx_params.v6 = v6; if ((protocol == UDP) && mcastEnabled) { IPERF_PRINTF("Multicast receive not yet implemented\n"); } else if (protocol == UDP) { bench_common_SetParams(&rCxt, rCxt.params.rx_params.v6, "udp", port, RX); bench_udp_rx(&rCxt); } else if (protocol == TCP) { bench_common_SetParams(&rCxt, rCxt.params.rx_params.v6, "tcp", port, RX); bench_tcp_rx(&rCxt); } } else { IPERF_PRINTF("Usage: iperf [-s|-c host] [options]\n"); IPERF_PRINTF("Try `iperf -h` for more information.\n"); return QCLI_STATUS_ERROR_E; } return QCLI_STATUS_SUCCESS_E; } void iperf_result_print(STATS * pCxtPara, uint32_t prev, uint32_t cur) { uint32_t throughput_Kbps = 0; uint32_t msInterval; uint32_t bytes, rem_bytes = 0; char *transfer_unit = " "; char *bandwidth_unit = " "; uint32_t sec_val1, sec_val2; msInterval = (cur - prev) * 1000; pCxtPara->kbytes += pCxtPara->bytes / BYTES_PER_KILO_BYTE; if (msInterval > 0) { throughput_Kbps = (pCxtPara->bytes / msInterval) * 8; bytes = pCxtPara->bytes; sec_val1 = pCxtPara->iperf_time_sec; sec_val2 = pCxtPara->iperf_time_sec + pCxtPara->iperf_display_interval; if (bytes > BYTES_PER_KILO_BYTE*BYTES_PER_KILO_BYTE) { transfer_unit = "M"; rem_bytes = ((bytes % (BYTES_PER_KILO_BYTE*BYTES_PER_KILO_BYTE)) * 100) / (BYTES_PER_KILO_BYTE*BYTES_PER_KILO_BYTE); bytes /= BYTES_PER_KILO_BYTE*BYTES_PER_KILO_BYTE; } else if (bytes > BYTES_PER_KILO_BYTE) { transfer_unit = "K"; rem_bytes = ((bytes % (BYTES_PER_KILO_BYTE)) * 100) / BYTES_PER_KILO_BYTE; bytes /= BYTES_PER_KILO_BYTE; } } else { msInterval = (pCxtPara->last_time.seconds - pCxtPara->first_time.seconds) * 1000; if (msInterval == 0) { return; /* error */ } pCxtPara->iperf_time_sec -= pCxtPara->iperf_display_interval; /* Final stats */ throughput_Kbps = (pCxtPara->kbytes / (msInterval/1000)) * 8; sec_val1 = 0; sec_val2 = msInterval/1000; bytes = pCxtPara->kbytes; /* Note: working with KB */ if (bytes > BYTES_PER_KILO_BYTE*BYTES_PER_KILO_BYTE) { transfer_unit = "G"; rem_bytes = ((bytes % (BYTES_PER_KILO_BYTE*BYTES_PER_KILO_BYTE)) * 100) / (BYTES_PER_KILO_BYTE*BYTES_PER_KILO_BYTE); bytes /= BYTES_PER_KILO_BYTE*BYTES_PER_KILO_BYTE; } else if (bytes > BYTES_PER_KILO_BYTE) { transfer_unit = "M"; rem_bytes = ((bytes % (BYTES_PER_KILO_BYTE)) * 100) / BYTES_PER_KILO_BYTE; bytes /= BYTES_PER_KILO_BYTE; } else if (bytes) { transfer_unit = "K"; } } if (throughput_Kbps > BYTES_PER_KILO_BYTE) { bandwidth_unit = "M"; } else if (pCxtPara->bytes > 0) { bandwidth_unit = "K"; } if (throughput_Kbps > BYTES_PER_KILO_BYTE) { IPERF_PRINTF("[%3d] %2d.0-%2d.0 sec %3d.%02d %sBytes %d.%02d %sbits/sec\n", pCxtPara->iperf_stream_id, sec_val1, sec_val2, bytes, rem_bytes, transfer_unit, throughput_Kbps/BYTES_PER_KILO_BYTE, (throughput_Kbps%BYTES_PER_KILO_BYTE)/10, bandwidth_unit); } else if (pCxtPara->bytes > 0) { IPERF_PRINTF("[%3d] %2d.0-%2d.0 sec %3d.%02d %sBytes %d.%02d %sbits/sec\n", pCxtPara->iperf_stream_id, sec_val1, sec_val2, bytes, rem_bytes, transfer_unit, throughput_Kbps, 0, bandwidth_unit); } /* Clear for next time */ pCxtPara->bytes = 0; pCxtPara->iperf_time_sec += pCxtPara->iperf_display_interval; } static void iperf3_make_cookie(char *str, int len) { memset(str, 0, len); strncpy((char *)str, COOKIE_CLIENT_NAME, len); return; } /************************************************************************ * NAME: iperf3_tx_reverse * * DESCRIPTION: Start TCP/UDP Transmit reverse test. ************************************************************************/ void iperf3_tx_reverse(THROUGHPUT_CXT *p_tCxt) { struct sockaddr_in foreign_addr; struct sockaddr_in6 foreign_addr6; struct sockaddr *to; uint32_t tolen; char ip_str[48]; char state = PARAM_EXCHANGE; char sub_state = 0; uint32_t cur_packet_number = 0; int32_t netbuf_id = QAPI_NETBUF_APP; int32_t received; int32_t exchange_result_len = 0; int family; fd_set rd_set; int32_t conn_sock; uint32_t iperf_display_interval=0; uint32_t iperf_display_last=0; uint32_t iperf_display_next=0; int opt = 1; int test_running = 1; p_tCxt->sock_control = A_ERROR; p_tCxt->sock_peer = A_ERROR; p_tCxt->pktStats.iperf_time_sec = 0; memset(ip_str, 0, sizeof(ip_str)); /*Allocate buffer*/ if ((p_tCxt->buffer = qapi_Net_Buf_Alloc(CFG_PACKET_SIZE_MAX_RX, netbuf_id)) == NULL) { QCLI_Printf(qcli_net_handle, "Out of memory error\n"); goto ERROR_2; } if (p_tCxt->params.tx_params.v6) /* IPV6 */ { family = AF_INET6; inet_ntop(family, &p_tCxt->params.tx_params.v6addr[0], ip_str, sizeof(ip_str)); memset(&foreign_addr6, 0, sizeof(foreign_addr6)); memcpy(&foreign_addr6.sin_addr, p_tCxt->params.tx_params.v6addr, sizeof(foreign_addr6.sin_addr)); foreign_addr6.sin_port = htons(p_tCxt->params.tx_params.port); foreign_addr6.sin_family = family; foreign_addr6.sin_scope_id = p_tCxt->params.tx_params.scope_id; to = (struct sockaddr *)&foreign_addr6; tolen = sizeof(foreign_addr6); } else { /* IPv4 */ family = AF_INET; inet_ntop(family, &p_tCxt->params.tx_params.ip_address, ip_str, sizeof(ip_str)); memset(&foreign_addr, 0, sizeof(foreign_addr)); foreign_addr.sin_addr.s_addr = p_tCxt->params.tx_params.ip_address; foreign_addr.sin_port = htons(p_tCxt->params.tx_params.port); foreign_addr.sin_family = family; to = (struct sockaddr *)&foreign_addr; tolen = sizeof(foreign_addr); } /* create control socket */ if ((p_tCxt->sock_control = qapi_socket(family, SOCK_STREAM, 0)) == A_ERROR) { QCLI_Printf(qcli_net_handle, "ERROR: Unable to create control socket\n"); goto ERROR_2; } /* enable TCP keepalive */ qapi_setsockopt(p_tCxt->sock_control, SOL_SOCKET, SO_KEEPALIVE, &opt, sizeof(opt)); /* set to non-blocking mode */ qapi_setsockopt(p_tCxt->sock_control, SOL_SOCKET, SO_NBIO, NULL, 0); /* Connect to the server.*/ if (qapi_connect( p_tCxt->sock_control, to, tolen) == A_ERROR) { QCLI_Printf(qcli_net_handle, "Control Socket Connection Failed.\n"); goto ERROR_2; } /* send cookie */ iperf3_make_cookie(p_tCxt->buffer, COOKIE_SIZE); if( qapi_send( p_tCxt->sock_control, (char *)p_tCxt->buffer, COOKIE_SIZE, 0) <=0 ) { QCLI_Printf(qcli_net_handle, "ERROR: Failed to send cookie\n"); goto ERROR_2; } qapi_fd_zero(&rd_set); qapi_fd_set(p_tCxt->sock_control, &rd_set); while(1) { fd_set rset; qapi_fd_zero(&rset); rset = rd_set; if (benchtx_quit) { app_get_time(&p_tCxt->pktStats.last_time); break; } /* Socket select to check if data is available */ conn_sock = qapi_select(&rset, NULL, NULL, 10); if (conn_sock == 0) { /* No activity. Continue with the next round */ continue; } else { /* control socket */ if ( qapi_fd_isset(p_tCxt->sock_control, &rset)) { if( state == EXCHANGE_RESULTS) { int32_t l; /* when state is EXCHANGE_RESULTS */ /* receive remote results length, then receive results */ if( sub_state == 0 ) { /* receive server result length */ if( qapi_recv( p_tCxt->sock_control, (char*) &l, sizeof(l), 0) < 0 ) { QCLI_Printf(qcli_net_handle, "Control Socket Receive Results Length Error\n"); goto ERROR_2; } exchange_result_len = ntohl(l); sub_state = 1; } else { /* receive server result */ l = exchange_result_len < CFG_PACKET_SIZE_MAX_RX?exchange_result_len:CFG_PACKET_SIZE_MAX_RX; received = qapi_recv( p_tCxt->sock_control, (char*) p_tCxt->buffer, l, 0); if( received < 0 ) { QCLI_Printf(qcli_net_handle, "Control Socket Receive Results Error\n"); goto ERROR_2; } else { exchange_result_len = exchange_result_len - received; if( exchange_result_len == 0) state = DISPLAY_RESULTS; } } } else { /* receive state */ received = qapi_recv( p_tCxt->sock_control, (char*)(&state), sizeof(unsigned char), 0); if (received == 0) { QCLI_Printf(qcli_net_handle, "Control Socket Error to receive\n"); goto ERROR_2; } switch ((int)state) { case PARAM_EXCHANGE: /* send parameters */ { int32_t len, l; #define BUF_LEN 512 /* generate parameters */ snprintf(p_tCxt->buffer, BUF_LEN, "{\"%s\":true,\"omit\":0,\"%s\":%d,\"parallel\":1,\"reverse\":true,\"len\":%d,\"client_version\":\"3.1.2\" }", p_tCxt->protocol == TCP?"tcp":"udp", p_tCxt->params.tx_params.test_mode == TIME_TEST?"time":"blockcount", p_tCxt->params.tx_params.test_mode == TIME_TEST?p_tCxt->params.tx_params.tx_time:p_tCxt->params.tx_params.packet_number, p_tCxt->params.tx_params.packet_size); /* send parameters length */ len = strlen(p_tCxt->buffer); l = htonl(len); qapi_send( p_tCxt->sock_control, (char *) &l, sizeof(l), 0); app_msec_delay(1); /* send parameters */ qapi_send( p_tCxt->sock_control, (char *) p_tCxt->buffer, len, 0); app_msec_delay(1); } break; case CREATE_STREAMS: p_tCxt->iperf_stream_id = 1; p_tCxt->pktStats.iperf_stream_id = p_tCxt->iperf_stream_id; if( p_tCxt->protocol == TCP ) { int32_t window_size = 0; /* Create TCP data socket */ if ((p_tCxt->sock_peer = qapi_socket(family, SOCK_STREAM, 0)) == A_ERROR) { QCLI_Printf(qcli_net_handle, "ERROR: Unable to create socket\n"); goto ERROR_2; } /* Configure queue sizes */ bench_config_queue_size(p_tCxt->sock_peer); qapi_getsockopt(p_tCxt->sock_peer,SOL_SOCKET, SO_SNDBUF, &window_size, (int32_t *)sizeof(window_size)); QCLI_Printf(qcli_net_handle, "------------------------------------------------------------\n"); QCLI_Printf(qcli_net_handle, "Client connecting to %s, TCP port %d\n", ip_str, p_tCxt->params.tx_params.port); QCLI_Printf(qcli_net_handle, "TCP window size: %d bytes\n",window_size); QCLI_Printf(qcli_net_handle, "------------------------------------------------------------\n"); /* enable TCP keepalive */ qapi_setsockopt(p_tCxt->sock_peer, SOL_SOCKET, SO_KEEPALIVE, &opt, sizeof(opt)); /* set to non-blocking mode */ qapi_setsockopt(p_tCxt->sock_peer, SOL_SOCKET, SO_NBIO, NULL, 0); /* display connecting */ QCLI_Printf(qcli_net_handle, "Connecting\n"); } else { /*UDP */ int32_t buffer_size = 0; /* Create UDP data socket */ if ((p_tCxt->sock_peer = qapi_socket(family, SOCK_DGRAM, 0)) == A_ERROR) { QCLI_Printf(qcli_net_handle, "ERROR: Unable to create socket\n"); goto ERROR_2; } /* Configure queue sizes */ bench_config_queue_size(p_tCxt->sock_peer); qapi_getsockopt(p_tCxt->sock_peer,SOL_SOCKET, SO_RCVBUF, &buffer_size, (int32_t *)sizeof(buffer_size)); QCLI_Printf(qcli_net_handle, "------------------------------------------------------------\n"); QCLI_Printf(qcli_net_handle, "Client connecting to %s, UDP port %d\n", ip_str, p_tCxt->params.tx_params.port); QCLI_Printf(qcli_net_handle, "UDP buffer size: %d bytes\n",buffer_size); QCLI_Printf(qcli_net_handle, "------------------------------------------------------------\n"); /* set to non-blocking mode */ qapi_setsockopt(p_tCxt->sock_peer, SOL_SOCKET, SO_NBIO, NULL, 0); } /* Connect to the server */ if (qapi_connect( p_tCxt->sock_peer, to, tolen) == A_ERROR) { QCLI_Printf(qcli_net_handle, "Connection failed.\n"); goto ERROR_2; } qapi_fd_set(p_tCxt->sock_peer, &rd_set); if( p_tCxt->protocol == TCP ) { /* send cookie */ iperf3_make_cookie(p_tCxt->buffer, COOKIE_SIZE); if( qapi_send( p_tCxt->sock_peer, (char *)p_tCxt->buffer, COOKIE_SIZE, 0) <=0 ) { QCLI_Printf(qcli_net_handle, "ERROR: Failed to send cookie\n"); goto ERROR_2; } } else { /* UDP */ /* send anything with 4 bytes length */ if( qapi_send( p_tCxt->sock_peer, (char *)p_tCxt->buffer, 4, 0) <=0 ) { QCLI_Printf(qcli_net_handle, "ERROR: Failed to send UDP\n"); goto ERROR_2; } } /*Reset all counters*/ cur_packet_number = 0; p_tCxt->pktStats.bytes = 0; p_tCxt->pktStats.iperf_time_sec = 0; app_get_time(&p_tCxt->pktStats.first_time); iperf_display_interval = p_tCxt->pktStats.iperf_display_interval; iperf_display_last = p_tCxt->pktStats.first_time.seconds; iperf_display_next = iperf_display_last + iperf_display_interval; QCLI_Printf(qcli_net_handle, "Receiving\n"); break; case TEST_START: break; case TEST_RUNNING: break; case EXCHANGE_RESULTS: { int32_t len, l; #define BUF_LEN 512 /* generate result */ snprintf(p_tCxt->buffer, BUF_LEN, "{\"cpu_util_total\":0.011,\"cpu_util_user\":0.001,\"cpu_util_system\":0.01,\"sender_has_retransmits\":0,\"streams\":[{\"id\":1,\"bytes\":%lld,\"retransmits\":-1,\"jitter\":0,\"errors\":0,\"packets\":0,\"start_time\":0,\"end_time\":%ld}]}", p_tCxt->pktStats.bytes, p_tCxt->pktStats.last_time.seconds - p_tCxt->pktStats.first_time.seconds); len = strlen(p_tCxt->buffer); l = htonl(len); /* send result length */ qapi_send( p_tCxt->sock_control, (char *) &l, sizeof(l), 0); /* send result */ qapi_send( p_tCxt->sock_control, (char *) p_tCxt->buffer, len, 0); } break; case DISPLAY_RESULTS: /* send IPERF DONE */ { unsigned char ch = IPERF_DONE; qapi_send( p_tCxt->sock_control, (char *) &ch, sizeof(ch), 0); /* finish here */ benchtx_quit = 1; } break; case IPERF_DONE: break; case SERVER_TERMINATE: /* * Temporarily be in DISPLAY_RESULTS phase so we can get * ending summary statistics. */ /*quit */ QCLI_Printf(qcli_net_handle, "server terminate\n"); benchtx_quit = 1; break; case ACCESS_DENIED: QCLI_Printf(qcli_net_handle, "Access denied\n"); goto ERROR_2; break; case SERVER_ERROR: { int32_t err, i_errno, errno; app_msec_delay(50); if( qapi_recv( p_tCxt->sock_control, (char*) &err, sizeof(err), 0) < 0 ) { QCLI_Printf(qcli_net_handle, "Control Socket Receive Error\n"); goto ERROR_2; } i_errno = ntohl(err); app_msec_delay(50); if( qapi_recv( p_tCxt->sock_control, (char*) &err, sizeof(err), 0) < 0 ) { QCLI_Printf(qcli_net_handle, "Control Socket Receive Error\n"); goto ERROR_2; } errno = ntohl(err); QCLI_Printf(qcli_net_handle, "Server Error: i_errno: %d, errno:%d\n", i_errno, errno); goto ERROR_2; } default: QCLI_Printf(qcli_net_handle, "Unknown control code:%d\n", state); goto ERROR_2; } /* switch */ } } /* end of control socket process */ /* receive data from peer */ if( (p_tCxt->sock_peer != A_ERROR) && (qapi_fd_isset(p_tCxt->sock_peer, &rset)) ) { if( p_tCxt->protocol == TCP ) { received = qapi_recv( p_tCxt->sock_peer, (char*)(&p_tCxt->buffer[0]), CFG_PACKET_SIZE_MAX_RX, 0); } else { received = qapi_recvfrom( p_tCxt->sock_peer, (char*)(&p_tCxt->buffer[0]), CFG_PACKET_SIZE_MAX_RX, 0, to, (int32_t *)&tolen); if( received == 0 ) continue; } /*Valid packet received*/ if (received > 0) { cur_packet_number++; p_tCxt->pktStats.bytes += received; } else {/* received <= 0 */ QCLI_Printf(qcli_net_handle, "\nReceived %llu bytes \n", p_tCxt->pktStats.bytes); /* remote may close the socket */ benchtx_quit = 1; continue; } if(p_tCxt->pktStats.iperf_display_interval > 0) { time_struct_t iperf_curr_time; app_get_time(&iperf_curr_time); uint32_t cur_time = iperf_curr_time.seconds; if(cur_time >= iperf_display_next) { iperf_result_print(&p_tCxt->pktStats, iperf_display_last, cur_time); iperf_display_last = cur_time; iperf_display_next = cur_time + iperf_display_interval; } } // check the test completion condition based on number of packets sent if ( (p_tCxt->params.tx_params.test_mode == PACKET_TEST) && (test_running != 0) ) { if ((cur_packet_number >= p_tCxt->params.tx_params.packet_number)) { char ch = TEST_END; /* Test completed */ app_get_time(&p_tCxt->pktStats.last_time); /* send TEST_END */ if( qapi_send( p_tCxt->sock_control, (char *) &ch, sizeof(ch), 0) <=0 ) { QCLI_Printf(qcli_net_handle, "Error to send Test END\n"); goto ERROR_2; } test_running = 0; } } // check the test completion condition based on time if ( (p_tCxt->params.tx_params.test_mode == TIME_TEST) && (test_running != 0) ) { app_get_time(&p_tCxt->pktStats.last_time); if (bench_common_check_test_time(p_tCxt)) { char ch = TEST_END; /* Test completed */ /* send TEST_END */ if( qapi_send( p_tCxt->sock_control, (char *) &ch, sizeof(ch), 0) <=0 ) { QCLI_Printf(qcli_net_handle, "Error to send Test END\n"); goto ERROR_2; } test_running = 0; } } } /* end receive data */ } } /* while(1) */ iperf_result_print(&p_tCxt->pktStats, 0, 0); ERROR_2: if( p_tCxt->sock_peer != A_ERROR ) qapi_socketclose( p_tCxt->sock_peer); if( p_tCxt->sock_control != A_ERROR ) qapi_socketclose( p_tCxt->sock_control); if( p_tCxt->buffer != NULL ) qapi_Net_Buf_Free(p_tCxt->buffer, netbuf_id); return; } #endif
40.388764
397
0.487509
[ "3d" ]
9f9bee431c6f35b1fc4ce63a4265c4b5773f3d48
27,371
h
C
Source/Services/AdExchangeBuyer/Generated/GTLQueryAdExchangeBuyer.h
mpapp/google-api-objectivec-client
7c4e4a86d94c10f2fd2dbea46ec9f1a631109bd3
[ "Apache-2.0" ]
null
null
null
Source/Services/AdExchangeBuyer/Generated/GTLQueryAdExchangeBuyer.h
mpapp/google-api-objectivec-client
7c4e4a86d94c10f2fd2dbea46ec9f1a631109bd3
[ "Apache-2.0" ]
null
null
null
Source/Services/AdExchangeBuyer/Generated/GTLQueryAdExchangeBuyer.h
mpapp/google-api-objectivec-client
7c4e4a86d94c10f2fd2dbea46ec9f1a631109bd3
[ "Apache-2.0" ]
null
null
null
/* Copyright (c) 2016 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // // GTLQueryAdExchangeBuyer.h // // ---------------------------------------------------------------------------- // NOTE: This file is generated from Google APIs Discovery Service. // Service: // Ad Exchange Buyer API (adexchangebuyer/v1.4) // Description: // Accesses your bidding-account information, submits creatives for // validation, finds available direct deals, and retrieves performance // reports. // Documentation: // https://developers.google.com/ad-exchange/buyer-rest // Classes: // GTLQueryAdExchangeBuyer (37 custom class methods, 29 custom properties) #if GTL_BUILT_AS_FRAMEWORK #import "GTL/GTLQuery.h" #else #import "GTLQuery.h" #endif @class GTLAdExchangeBuyerAccount; @class GTLAdExchangeBuyerBudget; @class GTLAdExchangeBuyerCreative; @class GTLAdExchangeBuyerMarketplaceDeal; @class GTLAdExchangeBuyerMarketplaceNote; @class GTLAdExchangeBuyerPretargetingConfig; @class GTLAdExchangeBuyerProposal; @interface GTLQueryAdExchangeBuyer : GTLQuery // // Parameters valid on all methods. // // Selector specifying which fields to include in a partial response. @property (nonatomic, copy) NSString *fields; // // Method-specific parameters; see the comments below for more information. // // "accountId" has different types for some query methods; see the documentation // for the right type for each query method. @property (nonatomic, retain) id accountId; @property (nonatomic, assign) long long billingId; // "buyerCreativeId" has different types for some query methods; see the // documentation for the right type for each query method. @property (nonatomic, retain) id buyerCreativeId; @property (nonatomic, assign) long long configId; @property (nonatomic, assign) long long dealId; @property (nonatomic, retain) NSArray *dealIds; // of NSString @property (nonatomic, retain) NSArray *deals; // of GTLAdExchangeBuyerMarketplaceDeal @property (nonatomic, copy) NSString *dealsStatusFilter; @property (nonatomic, copy) NSString *endDateTime; @property (nonatomic, copy) NSString *externalDealId; // identifier property maps to 'id' in JSON (to avoid Objective C's 'id'). @property (nonatomic, assign) NSInteger identifier; @property (nonatomic, assign) NSUInteger maxResults; @property (nonatomic, retain) GTLAdExchangeBuyerMarketplaceNote *note; @property (nonatomic, retain) NSArray *notes; // of GTLAdExchangeBuyerMarketplaceNote @property (nonatomic, copy) NSString *openAuctionStatusFilter; @property (nonatomic, retain) GTLAdExchangeBuyerProposal *order; @property (nonatomic, copy) NSString *pageToken; @property (nonatomic, copy) NSString *pqlQuery; @property (nonatomic, copy) NSString *privateAuctionId; @property (nonatomic, copy) NSString *productId; @property (nonatomic, retain) GTLAdExchangeBuyerProposal *proposal; @property (nonatomic, copy) NSString *proposalId; @property (nonatomic, assign) long long proposalRevisionNumber; @property (nonatomic, retain) NSArray *proposals; // of GTLAdExchangeBuyerProposal @property (nonatomic, assign) long long revisionNumber; @property (nonatomic, copy) NSString *startDateTime; @property (nonatomic, copy) NSString *updateAction; @property (nonatomic, copy) NSString *webPropertyCode; #pragma mark - "accounts" methods // These create a GTLQueryAdExchangeBuyer object. // Method: adexchangebuyer.accounts.get // Gets one account by ID. // Required: // identifier: The account id // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerAccount. + (instancetype)queryForAccountsGetWithIdentifier:(NSInteger)identifier; // Method: adexchangebuyer.accounts.list // Retrieves the authenticated user's list of accounts. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerAccountsList. + (instancetype)queryForAccountsList; // Method: adexchangebuyer.accounts.patch // Updates an existing account. This method supports patch semantics. // Required: // identifier: The account id // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerAccount. + (instancetype)queryForAccountsPatchWithObject:(GTLAdExchangeBuyerAccount *)object identifier:(NSInteger)identifier; // Method: adexchangebuyer.accounts.update // Updates an existing account. // Required: // identifier: The account id // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerAccount. + (instancetype)queryForAccountsUpdateWithObject:(GTLAdExchangeBuyerAccount *)object identifier:(NSInteger)identifier; #pragma mark - "billingInfo" methods // These create a GTLQueryAdExchangeBuyer object. // Method: adexchangebuyer.billingInfo.get // Returns the billing information for one account specified by account ID. // Required: // accountId: The account id. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerBillingInfo. + (instancetype)queryForBillingInfoGetWithAccountId:(NSInteger)accountId; // Method: adexchangebuyer.billingInfo.list // Retrieves a list of billing information for all accounts of the authenticated // user. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerBillingInfoList. + (instancetype)queryForBillingInfoList; #pragma mark - "budget" methods // These create a GTLQueryAdExchangeBuyer object. // Method: adexchangebuyer.budget.get // Returns the budget information for the adgroup specified by the accountId and // billingId. // Required: // accountId: The account id to get the budget information for. // billingId: The billing id to get the budget information for. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerBudget. + (instancetype)queryForBudgetGetWithAccountId:(long long)accountId billingId:(long long)billingId; // Method: adexchangebuyer.budget.patch // Updates the budget amount for the budget of the adgroup specified by the // accountId and billingId, with the budget amount in the request. This method // supports patch semantics. // Required: // accountId: The account id associated with the budget being updated. // billingId: The billing id associated with the budget being updated. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerBudget. + (instancetype)queryForBudgetPatchWithObject:(GTLAdExchangeBuyerBudget *)object accountId:(long long)accountId billingId:(long long)billingId; // Method: adexchangebuyer.budget.update // Updates the budget amount for the budget of the adgroup specified by the // accountId and billingId, with the budget amount in the request. // Required: // accountId: The account id associated with the budget being updated. // billingId: The billing id associated with the budget being updated. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerBudget. + (instancetype)queryForBudgetUpdateWithObject:(GTLAdExchangeBuyerBudget *)object accountId:(long long)accountId billingId:(long long)billingId; #pragma mark - "creatives" methods // These create a GTLQueryAdExchangeBuyer object. // Method: adexchangebuyer.creatives.addDeal // Add a deal id association for the creative. // Required: // accountId: The id for the account that will serve this creative. // buyerCreativeId: The buyer-specific id for this creative. // dealId: The id of the deal id to associate with this creative. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer + (instancetype)queryForCreativesAddDealWithAccountId:(NSInteger)accountId buyerCreativeId:(NSString *)buyerCreativeId dealId:(long long)dealId; // Method: adexchangebuyer.creatives.get // Gets the status for a single creative. A creative will be available 30-40 // minutes after submission. // Required: // accountId: The id for the account that will serve this creative. // buyerCreativeId: The buyer-specific id for this creative. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerCreative. + (instancetype)queryForCreativesGetWithAccountId:(NSInteger)accountId buyerCreativeId:(NSString *)buyerCreativeId; // Method: adexchangebuyer.creatives.insert // Submit a new creative. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerCreative. + (instancetype)queryForCreativesInsertWithObject:(GTLAdExchangeBuyerCreative *)object; // Method: adexchangebuyer.creatives.list // Retrieves a list of the authenticated user's active creatives. A creative // will be available 30-40 minutes after submission. // Optional: // accountId: When specified, only creatives for the given account ids are // returned. // Note: For this method, "accountId" should be of type NSArray<NSNumber>. // buyerCreativeId: When specified, only creatives for the given buyer // creative ids are returned. // Note: For this method, "buyerCreativeId" should be of type // NSArray<NSString>. // dealsStatusFilter: When specified, only creatives having the given deals // status are returned. // kGTLAdExchangeBuyerDealsStatusFilterApproved: Creatives which have been // approved for serving on deals. // kGTLAdExchangeBuyerDealsStatusFilterConditionallyApproved: Creatives // which have been conditionally approved for serving on deals. // kGTLAdExchangeBuyerDealsStatusFilterDisapproved: Creatives which have // been disapproved for serving on deals. // kGTLAdExchangeBuyerDealsStatusFilterNotChecked: Creatives whose deals // status is not yet checked. // maxResults: Maximum number of entries returned on one result page. If not // set, the default is 100. Optional. (1..1000) // openAuctionStatusFilter: When specified, only creatives having the given // open auction status are returned. // kGTLAdExchangeBuyerOpenAuctionStatusFilterApproved: Creatives which have // been approved for serving on the open auction. // kGTLAdExchangeBuyerOpenAuctionStatusFilterConditionallyApproved: Creatives // which have been conditionally approved for serving on the open // auction. // kGTLAdExchangeBuyerOpenAuctionStatusFilterDisapproved: Creatives which // have been disapproved for serving on the open auction. // kGTLAdExchangeBuyerOpenAuctionStatusFilterNotChecked: Creatives whose // open auction status is not yet checked. // pageToken: A continuation token, used to page through ad clients. To // retrieve the next page, set this parameter to the value of // "nextPageToken" from the previous response. Optional. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerCreativesList. + (instancetype)queryForCreativesList; // Method: adexchangebuyer.creatives.removeDeal // Remove a deal id associated with the creative. // Required: // accountId: The id for the account that will serve this creative. // buyerCreativeId: The buyer-specific id for this creative. // dealId: The id of the deal id to disassociate with this creative. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer + (instancetype)queryForCreativesRemoveDealWithAccountId:(NSInteger)accountId buyerCreativeId:(NSString *)buyerCreativeId dealId:(long long)dealId; #pragma mark - "marketplacedeals" methods // These create a GTLQueryAdExchangeBuyer object. // Method: adexchangebuyer.marketplacedeals.delete // Delete the specified deals from the proposal // Required: // proposalId: The proposalId to delete deals from. // Optional: // dealIds: List of deals to delete for a given proposal // proposalRevisionNumber: The last known proposal revision number. // updateAction: Indicates an optional action to take on the proposal // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerDeleteOrderDealsResponse. + (instancetype)queryForMarketplacedealsDeleteWithProposalId:(NSString *)proposalId; // Method: adexchangebuyer.marketplacedeals.insert // Add new deals for the specified proposal // Required: // proposalId: proposalId for which deals need to be added. // Optional: // deals: The list of deals to add // proposalRevisionNumber: The last known proposal revision number. // updateAction: Indicates an optional action to take on the proposal // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerAddOrderDealsResponse. + (instancetype)queryForMarketplacedealsInsertWithProposalId:(NSString *)proposalId; // Method: adexchangebuyer.marketplacedeals.list // List all the deals for a given proposal // Required: // proposalId: The proposalId to get deals for. To search across proposals // specify order_id = '-' as part of the URL. // Optional: // pqlQuery: Query string to retrieve specific deals. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerGetOrderDealsResponse. + (instancetype)queryForMarketplacedealsListWithProposalId:(NSString *)proposalId; // Method: adexchangebuyer.marketplacedeals.update // Replaces all the deals in the proposal with the passed in deals // Required: // proposalId: The proposalId to edit deals on. // Optional: // deals: List of deals to edit. Service may perform 3 different operations // based on comparison of deals in this list vs deals already persisted in // database: 1. Add new deal to proposal If a deal in this list does not // exist in the proposal, the service will create a new deal and add it to // the proposal. Validation will follow AddOrderDealsRequest. 2. Update // existing deal in the proposal If a deal in this list already exist in the // proposal, the service will update that existing deal to this new deal in // the request. Validation will follow UpdateOrderDealsRequest. 3. Delete // deals from the proposal (just need the id) If a existing deal in the // proposal is not present in this list, the service will delete that deal // from the proposal. Validation will follow DeleteOrderDealsRequest. // proposal: If specified, also updates the proposal in the batch transaction. // This is useful when the proposal and the deals need to be updated in one // transaction. // proposalRevisionNumber: The last known revision number for the proposal. // updateAction: Indicates an optional action to take on the proposal // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerEditAllOrderDealsResponse. + (instancetype)queryForMarketplacedealsUpdateWithProposalId:(NSString *)proposalId; #pragma mark - "marketplacenotes" methods // These create a GTLQueryAdExchangeBuyer object. // Method: adexchangebuyer.marketplacenotes.insert // Add notes to the proposal // Required: // proposalId: The proposalId to add notes for. // Optional: // notes: The list of notes to add. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerAddOrderNotesResponse. + (instancetype)queryForMarketplacenotesInsertWithProposalId:(NSString *)proposalId; // Method: adexchangebuyer.marketplacenotes.list // Get all the notes associated with a proposal // Required: // proposalId: The proposalId to get notes for. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerGetOrderNotesResponse. + (instancetype)queryForMarketplacenotesListWithProposalId:(NSString *)proposalId; #pragma mark - "marketplaceprivateauction" methods // These create a GTLQueryAdExchangeBuyer object. // Method: adexchangebuyer.marketplaceprivateauction.updateproposal // Update a given private auction proposal // Required: // privateAuctionId: The private auction id to be updated. // Optional: // externalDealId: The externalDealId of the deal to be updated. // note: Optional note to be added. // proposalRevisionNumber: The current revision number of the proposal to be // updated. // updateAction: The proposed action on the private auction proposal. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer + (instancetype)queryForMarketplaceprivateauctionUpdateproposalWithPrivateAuctionId:(NSString *)privateAuctionId; #pragma mark - "performanceReport" methods // These create a GTLQueryAdExchangeBuyer object. // Method: adexchangebuyer.performanceReport.list // Retrieves the authenticated user's list of performance metrics. // Required: // accountId: The account id to get the reports. // endDateTime: The end time of the report in ISO 8601 timestamp format using // UTC. // startDateTime: The start time of the report in ISO 8601 timestamp format // using UTC. // Optional: // maxResults: Maximum number of entries returned on one result page. If not // set, the default is 100. Optional. (1..1000) // pageToken: A continuation token, used to page through performance reports. // To retrieve the next page, set this parameter to the value of // "nextPageToken" from the previous response. Optional. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerPerformanceReportList. + (instancetype)queryForPerformanceReportListWithAccountId:(long long)accountId endDateTime:(NSString *)endDateTime startDateTime:(NSString *)startDateTime; #pragma mark - "pretargetingConfig" methods // These create a GTLQueryAdExchangeBuyer object. // Method: adexchangebuyer.pretargetingConfig.delete // Deletes an existing pretargeting config. // Required: // accountId: The account id to delete the pretargeting config for. // configId: The specific id of the configuration to delete. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer + (instancetype)queryForPretargetingConfigDeleteWithAccountId:(long long)accountId configId:(long long)configId; // Method: adexchangebuyer.pretargetingConfig.get // Gets a specific pretargeting configuration // Required: // accountId: The account id to get the pretargeting config for. // configId: The specific id of the configuration to retrieve. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerPretargetingConfig. + (instancetype)queryForPretargetingConfigGetWithAccountId:(long long)accountId configId:(long long)configId; // Method: adexchangebuyer.pretargetingConfig.insert // Inserts a new pretargeting configuration. // Required: // accountId: The account id to insert the pretargeting config for. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerPretargetingConfig. + (instancetype)queryForPretargetingConfigInsertWithObject:(GTLAdExchangeBuyerPretargetingConfig *)object accountId:(long long)accountId; // Method: adexchangebuyer.pretargetingConfig.list // Retrieves a list of the authenticated user's pretargeting configurations. // Required: // accountId: The account id to get the pretargeting configs for. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerPretargetingConfigList. + (instancetype)queryForPretargetingConfigListWithAccountId:(long long)accountId; // Method: adexchangebuyer.pretargetingConfig.patch // Updates an existing pretargeting config. This method supports patch // semantics. // Required: // accountId: The account id to update the pretargeting config for. // configId: The specific id of the configuration to update. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerPretargetingConfig. + (instancetype)queryForPretargetingConfigPatchWithObject:(GTLAdExchangeBuyerPretargetingConfig *)object accountId:(long long)accountId configId:(long long)configId; // Method: adexchangebuyer.pretargetingConfig.update // Updates an existing pretargeting config. // Required: // accountId: The account id to update the pretargeting config for. // configId: The specific id of the configuration to update. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerPretargetingConfig. + (instancetype)queryForPretargetingConfigUpdateWithObject:(GTLAdExchangeBuyerPretargetingConfig *)object accountId:(long long)accountId configId:(long long)configId; #pragma mark - "products" methods // These create a GTLQueryAdExchangeBuyer object. // Method: adexchangebuyer.products.get // Gets the requested product by id. // Required: // productId: The id for the product to get the head revision for. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerProduct. + (instancetype)queryForProductsGetWithProductId:(NSString *)productId; // Method: adexchangebuyer.products.search // Gets the requested product. // Optional: // pqlQuery: The pql query used to query for products. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerGetOffersResponse. + (instancetype)queryForProductsSearch; #pragma mark - "proposals" methods // These create a GTLQueryAdExchangeBuyer object. // Method: adexchangebuyer.proposals.get // Get a proposal given its id // Required: // proposalId: Id of the proposal to retrieve. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerProposal. + (instancetype)queryForProposalsGetWithProposalId:(NSString *)proposalId; // Method: adexchangebuyer.proposals.insert // Create the given list of proposals // Optional: // proposals: The list of proposals to create. // webPropertyCode: Web property id of the seller creating these orders // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerCreateOrdersResponse. + (instancetype)queryForProposalsInsert; // Method: adexchangebuyer.proposals.patch // Update the given proposal. This method supports patch semantics. // Required: // proposalId: The proposal id to update. // revisionNumber: The last known revision number to update. If the head // revision in the marketplace database has since changed, an error will be // thrown. The caller should then fetch the latest proposal at head revision // and retry the update at that revision. // updateAction: The proposed action to take on the proposal. // kGTLAdExchangeBuyerUpdateActionAccept: "accept" // kGTLAdExchangeBuyerUpdateActionCancel: "cancel" // kGTLAdExchangeBuyerUpdateActionPropose: "propose" // kGTLAdExchangeBuyerUpdateActionUnknownAction: "unknownAction" // kGTLAdExchangeBuyerUpdateActionUpdateFinalized: "updateFinalized" // Optional: // order: GTLAdExchangeBuyerProposal // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerProposal. + (instancetype)queryForProposalsPatchWithProposalId:(NSString *)proposalId revisionNumber:(long long)revisionNumber updateAction:(NSString *)updateAction; // Method: adexchangebuyer.proposals.search // Search for proposals using pql query // Optional: // pqlQuery: Query string to retrieve specific proposals. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerGetOrdersResponse. + (instancetype)queryForProposalsSearch; // Method: adexchangebuyer.proposals.setupcomplete // Update the given proposal to indicate that setup has been completed. // Required: // proposalId: The proposal id for which the setup is complete // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer + (instancetype)queryForProposalsSetupcompleteWithProposalId:(NSString *)proposalId; // Method: adexchangebuyer.proposals.update // Update the given proposal // Required: // proposalId: The proposal id to update. // revisionNumber: The last known revision number to update. If the head // revision in the marketplace database has since changed, an error will be // thrown. The caller should then fetch the latest proposal at head revision // and retry the update at that revision. // updateAction: The proposed action to take on the proposal. // kGTLAdExchangeBuyerUpdateActionAccept: "accept" // kGTLAdExchangeBuyerUpdateActionCancel: "cancel" // kGTLAdExchangeBuyerUpdateActionPropose: "propose" // kGTLAdExchangeBuyerUpdateActionUnknownAction: "unknownAction" // kGTLAdExchangeBuyerUpdateActionUpdateFinalized: "updateFinalized" // Optional: // order: GTLAdExchangeBuyerProposal // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerProposal. + (instancetype)queryForProposalsUpdateWithProposalId:(NSString *)proposalId revisionNumber:(long long)revisionNumber updateAction:(NSString *)updateAction; #pragma mark - "pubprofiles" methods // These create a GTLQueryAdExchangeBuyer object. // Method: adexchangebuyer.pubprofiles.list // Gets the requested publisher profile(s) by publisher accountId. // Required: // accountId: The accountId of the publisher to get profiles for. // Authorization scope(s): // kGTLAuthScopeAdExchangeBuyerAdexchangeBuyer // Fetches a GTLAdExchangeBuyerGetPublisherProfilesByAccountIdResponse. + (instancetype)queryForPubprofilesListWithAccountId:(NSInteger)accountId; @end
45.618333
113
0.752073
[ "object" ]
9fb6dc84b51574159d3adf5c9225d22d993de88f
2,958
h
C
include/tl/bare.h
mattiabrandon/MBProto
54ce2d4c3103c83cab559aff206f4cdd095bdef3
[ "MIT" ]
12
2020-09-01T20:32:54.000Z
2021-09-10T21:07:19.000Z
include/tl/bare.h
mattiabrandon/MBProto
54ce2d4c3103c83cab559aff206f4cdd095bdef3
[ "MIT" ]
null
null
null
include/tl/bare.h
mattiabrandon/MBProto
54ce2d4c3103c83cab559aff206f4cdd095bdef3
[ "MIT" ]
2
2021-07-09T19:23:22.000Z
2022-02-05T16:09:15.000Z
/* Copyright (c) 2021 Mattia Lorenzo Chiabrando * * 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 <cstring> #include <string> #include "tl/TLObject.h" #include "utils/streams.h" #include "utils/packing.h" class Int : public TLObject { public: static int read(Reader reader); static void write(Writer writer, const int value); }; class Int128 : public TLObject { public: static int128_t read(Reader reader); static void write(Writer writer, const int128_t value); }; class Int256 : public TLObject { public: static int256_t read(Reader reader); static void write(Writer writer, const int256_t value); }; class Long : public TLObject { public: static long read(Reader reader); static void write(Writer writer, const long value); }; class Double : public TLObject { public: static double read(Reader reader); static void write(Writer writer, const double value); }; class Bytes : public TLObject { public: static std::vector<unsigned char> read(Reader reader); static void write(Writer writer, std::vector<unsigned char> value); }; class String : public Bytes { public: static std::string read(Reader reader); static void write(Writer writer, std::string value); }; class Bool : public TLObject { private: static const int __bool_false_id = 0xbc799737; static const int __bool_true_id = 0x997275b5; public: static bool read(Reader reader); static void write(Writer writer, const bool value); }; template <class T, typename U> class Vector : public TLObject { static_assert(std::is_base_of_v<TLObject, T>); public: static const int tl_id = 0x1cb5c415; static std::vector<U> read(Reader reader); static void write(Writer writer, std::vector<T> values); template <class Q = void, typename = typename std::enable_if_t<!std::is_same_v<U, T>, Q>> static void write(Writer writer, std::vector<U> values); };
29
93
0.732928
[ "vector" ]
9fbb2c4b99172d97ff8686c65607c3cd83368d20
1,871
h
C
ParallaxOcclusionMapping/object.h
Shantanu-Chauhan/ParallaxOcclusionMapping
403b4c208cb743bb16d13815cd635defd4619db7
[ "Apache-2.0" ]
1
2020-03-08T05:36:19.000Z
2020-03-08T05:36:19.000Z
ParallaxOcclusionMapping/object.h
Shantanu-Chauhan/ParallaxOcclusionMapping
403b4c208cb743bb16d13815cd635defd4619db7
[ "Apache-2.0" ]
null
null
null
ParallaxOcclusionMapping/object.h
Shantanu-Chauhan/ParallaxOcclusionMapping
403b4c208cb743bb16d13815cd635defd4619db7
[ "Apache-2.0" ]
null
null
null
//////////////////////////////////////////////////////////////////////// // A lightweight class representing an instance of an object that can // be drawn onscreen. An Object consists of a shape (batch of // triangles), and various transformation, color and texture // parameters. It also contains a list of child objects to be drawn // in a hierarchical fashion under the control of parent's // transformations. // // Methods consist of a constructor, and a Draw procedure, and an // append for building hierarchies of objects. #ifndef _OBJECT #define _OBJECT #include "shapes.h" #include "texture.h" #include <utility> // for pair<Object*,MAT4> class Shader; class Object; // Object:: A shape, and its transformations, colors, and textures and sub-objects. class Object { public: Shape* shape; // Polygons MAT4 animTr; // This model's animation transformation int objectId; // Object id to be sent to the shader vec3 diffuseColor; // Diffuse color of object vec3 specularColor; // Specular color of object float shininess; // Surface roughness value std::vector<std::pair<Object*,MAT4>> instances; // Pairs of sub-objects and transformations Object(Shape* _shape, const int objectId, const vec3 _d=vec3(), const vec3 _s=vec3(), const float _n=1); // If this object is to be drawn with a texture, this is a good // place to store the texture id (a small positive integer). The // texture id should be set in Scene::InitializeScene and used in // Object::Draw. unsigned int TextureId; unsigned int NormalId; unsigned int HeightId; void Object::Draw(ShaderProgram* program, MAT4& objectTr, bool dontdraw=false); void add(Object* m, MAT4 tr=MAT4()) { instances.push_back(std::make_pair(m,tr)); } }; #endif
35.980769
96
0.657402
[ "object", "shape", "vector", "model" ]
9fc111a79890e2932aaa77f2cd79384c0a9b15c5
1,996
h
C
models/math/include/math_utility_c.h
cihuang123/Next-simulation
e8552a5804184b30022d103d47c8728fb242b5bc
[ "BSD-3-Clause" ]
null
null
null
models/math/include/math_utility_c.h
cihuang123/Next-simulation
e8552a5804184b30022d103d47c8728fb242b5bc
[ "BSD-3-Clause" ]
null
null
null
models/math/include/math_utility_c.h
cihuang123/Next-simulation
e8552a5804184b30022d103d47c8728fb242b5bc
[ "BSD-3-Clause" ]
2
2021-05-05T14:59:37.000Z
2021-06-17T03:19:45.000Z
#ifndef math_utility_c__H #define math_utility_c__H /********************************* TRICK HEADER ******************************* PURPOSE: (Math functions C Version) LIBRARY DEPENDENCY: ((../src/math_utility_c.c) (../../cad/src/global_constants.c)) *******************************************************************************/ #include <gsl/gsl_matrix.h> #include <gsl/gsl_blas.h> #include <gsl/gsl_vector.h> #include <math.h> #ifdef __cplusplus extern "C" { #endif extern const double ___PI; extern const double __RAD; extern const double __EPS; int pol_from_cart_C(const gsl_vector *cart, gsl_vector *pol); int build_psivg_thtvg_TM_C(const double psivg, const double thtvg, gsl_matrix *AMAT); int build_psi_tht_phi_TM_C(const double psi, const double tht, const double phi, gsl_matrix *TM); int Matrix2Quaternion_C(gsl_matrix *Matrix_in, gsl_vector *Quaternion_out); int Quaternion2Matrix_C(const gsl_vector *Quaternion_in, gsl_matrix *Matrix_out); int Quaternion_cross_C(const gsl_vector *Quaternion_in1, const gsl_vector *Quaternion_in2, gsl_vector *Quaternion_out); int Quaternion2Euler_C(const gsl_vector *Quaternion_in, double *Roll, double *Pitch, double *Yaw); int Euler2Quaternion_C(const double Roll, const double Pitch, const double Yaw, gsl_vector *Quaternion_out); int QuaternionMultiply_C(const gsl_vector *Quaternion_in1, const gsl_vector *Quaternion_in2, gsl_vector *Quaternion_out); int Quaternion_rotation_C(const gsl_vector *Vector_in, const gsl_vector *Quaternion_in, gsl_vector *Vector_out); int build_321_rotation_matrix(const gsl_vector *angle, gsl_matrix *mat_out); int sign(const double variable); int euler_angle(gsl_matrix *TBD, gsl_vector *euler_ang); gsl_matrix* moore_penrose_pinv(gsl_matrix *A, const double rcond); gsl_matrix *skew_sym_C(const gsl_vector *vec); gsl_vector *Quaternion_conjugate_C(const gsl_vector *Quaternion_in); gsl_vector *QuaternionInverse_C(const gsl_vector *Quaternion_in); #ifdef __cplusplus } #endif #endif
42.468085
121
0.746994
[ "cad" ]
1952a153eea26da5bf0639a00babfcada446c94e
715
h
C
CWin/CWin/grid/grid_object.h
benbraide/CWin
0441b48a71fef0dbddabf61033d7286669772c1e
[ "MIT" ]
null
null
null
CWin/CWin/grid/grid_object.h
benbraide/CWin
0441b48a71fef0dbddabf61033d7286669772c1e
[ "MIT" ]
null
null
null
CWin/CWin/grid/grid_object.h
benbraide/CWin
0441b48a71fef0dbddabf61033d7286669772c1e
[ "MIT" ]
null
null
null
#pragma once #include "grid_row.h" namespace cwin::grid{ class object : public ui::visible_surface{ public: struct row_info{ row *target; bool is_fixed; int fixed_height; }; object(); explicit object(tree &parent); object(tree &parent, std::size_t index); virtual ~object(); virtual void refresh(); protected: virtual bool inserting_child_(ui::object &child) override; virtual void size_update_(const SIZE &old_value, const SIZE &current_value) override; virtual void refresh_(); }; class fixed_object : public object{ public: fixed_object(); explicit fixed_object(tree &parent); fixed_object(tree &parent, std::size_t index); virtual ~fixed_object(); }; }
16.627907
87
0.703497
[ "object" ]
195bcff7165f1eab1fe98624e3a948ddd4eab145
616
h
C
dali/array/expression/optimization.h
bzcheeseman/Dali
a77c7ce60b20ce150a5927747e128688657907eb
[ "MIT" ]
null
null
null
dali/array/expression/optimization.h
bzcheeseman/Dali
a77c7ce60b20ce150a5927747e128688657907eb
[ "MIT" ]
null
null
null
dali/array/expression/optimization.h
bzcheeseman/Dali
a77c7ce60b20ce150a5927747e128688657907eb
[ "MIT" ]
null
null
null
#ifndef DALI_ARRAY_EXPRESSION_OPTIMIZATION_H #define DALI_ARRAY_EXPRESSION_OPTIMIZATION_H #include <functional> #include "dali/array/array.h" // gets the right-hand side arguments from an assignment node. const std::vector<Array>& right_args(Array node); int register_optimization(std::function<bool(const Array&)> condition, std::function<Array(const Array&)> transformation, const std::string& name); // simplify internal expression graph to return to a more common view. Array canonical(const Array& array); #endif // DALI_ARRAY_EXPRESSION_OPTIMIZATION_H
34.222222
76
0.733766
[ "vector" ]
195ceabfd1eade27a30b85e49ff1740faa5b8f64
590
h
C
include/Engine/Renderer/Mesh/StaticMesh.h
sfulham/GameProject-1
83c065ac7abc4c0a098dfcb0d1cc13f9d8bf7a03
[ "MIT" ]
null
null
null
include/Engine/Renderer/Mesh/StaticMesh.h
sfulham/GameProject-1
83c065ac7abc4c0a098dfcb0d1cc13f9d8bf7a03
[ "MIT" ]
null
null
null
include/Engine/Renderer/Mesh/StaticMesh.h
sfulham/GameProject-1
83c065ac7abc4c0a098dfcb0d1cc13f9d8bf7a03
[ "MIT" ]
null
null
null
// // Created by MarcasRealAccount on 30. Oct. 2020 // #include "Engine/Renderer/Mesh/Mesh.h" #include <glm.hpp> namespace gp1::renderer::mesh { struct StaticMeshVertex { public: glm::fvec3 position { 0.0f, 0.0f, 0.0f }; // The position of this vertex. glm::fvec3 normal { 0.0f, 0.0f, 0.0f }; // The normal of this vertex. glm::fvec2 uv { 0.0f, 0.0f }; // The uv of this vertex. }; struct StaticMesh : public Mesh { public: StaticMesh(); public: std::vector<StaticMeshVertex> m_Vertices; // This mesh's vertices. }; } // namespace gp1::renderer::mesh
20.344828
75
0.645763
[ "mesh", "vector" ]
1965d7bf139bd3cac38aea06efe3a2c8897684a1
4,076
h
C
src/function/NSDebug.h
mulle-objc/MulleObjC
ce1d3e2b9427b293044aea735363e7707a2721d9
[ "BSD-3-Clause" ]
54
2016-11-21T12:26:25.000Z
2021-10-13T16:51:52.000Z
src/function/NSDebug.h
mulle-objc/MulleObjC
ce1d3e2b9427b293044aea735363e7707a2721d9
[ "BSD-3-Clause" ]
13
2016-12-14T13:38:17.000Z
2022-01-26T13:39:20.000Z
src/function/NSDebug.h
mulle-objc/MulleObjC
ce1d3e2b9427b293044aea735363e7707a2721d9
[ "BSD-3-Clause" ]
9
2016-11-10T19:01:29.000Z
2021-04-03T11:40:45.000Z
// // NSDebug.h // MulleObjC // // Copyright (c) 2011 Nat! - Mulle kybernetiK. // Copyright (c) 2011 Codeon GmbH. // 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 Mulle kybernetiK nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // #import "NSObject.h" @interface NSObject ( NSDebug) - (id) debugDescription; @end char *_NSPrintForDebugger( id a); MULLE_C_CONST_RETURN BOOL MulleObjCIsDebugEnabled( void); #define NSDebugEnabled MulleObjCIsDebugEnabled() void MulleObjCHTMLDumpUniverseToDirectory( char *directory); void MulleObjCHTMLDumpUniverseToTmp( void); void MulleObjCHTMLDumpUniverse( void); void MulleObjCHTMLDumpClassToDirectory( char *classname, char *directory); void MulleObjCHTMLDumpClass( char *classname); void MulleObjCHTMLDumpClassToTmp( char *classname); void MulleObjCDotdumpClassToDirectory( char *classname, char *directory); void MulleObjCDotdumpClassToTmp( char *classname); void MulleObjCDotdumpClass( char *classname); void MulleObjCDotdumpUniverseFrameToTmp( void); void MulleObjCDotdumpUniverseToTmp( void); void MulleObjCDotdumpUniverse( void); // dump all relevant classes and instance methods, starting from classname void MulleObjCDotdumpMetaHierarchyToDirectory( char *classname, char *directory); void MulleObjCDotdumpInfraHierarchyToTmp( char *classname); void MulleObjCDotdumpInfraHierarchy( char *classname); // dump all relevant classes and class methods, starting from classname void MulleObjCDotdumpMetaHierarchyToDirectory( char *classname, char *directory); void MulleObjCDotdumpMetaHierarchyToTmp( char *classname); void MulleObjCDotdumpMetaHierarchy( char *classname); // interfaces with mulle-stacktrace value enhancer char *MulleObjCStacktraceSymbolize( void *addresse, size_t max, char *buf, size_t len, void **userinfo); void MulleObjCCSVDumpMethodsToTmp( void); void _MulleObjCZombifyObject( id obj, int shred); static inline void MulleObjCZombifyObject( id obj, int shred) { if( ! obj) return; _MulleObjCZombifyObject( obj, shred); } // // now coming up: some unused old junk // that sticks around for compatibility enum { NSObjectAutoreleasedEvent = 3, NSObjectExtraRefDecrementedEvent = 5, NSObjectExtraRefIncrementedEvent = 4, NSObjectInternalRefDecrementedEvent =7, NSObjectInternalRefIncrementedEvent = 8 }; extern BOOL NSKeepAllocationStatistics; static inline void NSRecordAllocationEvent( int eventType, id object) { }
34.252101
83
0.742885
[ "object" ]
19664794aff79ad9c2e4c41796d9ebe0d6f6ff20
86,884
h
C
mmwave_sdk/packages/ti/drivers/hwa/test/common/1dFFT_in.h
astroa-git/fmcw-RADAR
e120c8c9c84a1473749c632dcf602741a9ab67ef
[ "MIT" ]
14
2021-05-11T21:20:01.000Z
2022-01-05T03:53:29.000Z
mmwave_sdk/packages/ti/drivers/hwa/test/common/1dFFT_in.h
astroa-git/fmcw-RADAR
e120c8c9c84a1473749c632dcf602741a9ab67ef
[ "MIT" ]
null
null
null
mmwave_sdk/packages/ti/drivers/hwa/test/common/1dFFT_in.h
astroa-git/fmcw-RADAR
e120c8c9c84a1473749c632dcf602741a9ab67ef
[ "MIT" ]
4
2021-11-16T02:36:31.000Z
2021-11-30T00:37:55.000Z
/* * Copyright (c) 2015, Texas Instruments Incorporated * 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 Texas Instruments Incorporated 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. */ /** ============================================================================ * @file 1dFFT_in.h * * @brief 1D FFT input test vector */ uint16_t gHWATest_1DFFT_input[] = { 64693, 65300, 305, 65522, 67, 279, 65455, 65246, 64984, 65384, 168, 210, 65370, 65447, 347, 65433, 65012, 65513, 25, 75, 227, 65506, 65506, 65445, 64644, 97, 261, 65501, 66, 65496, 93, 65467, 64841, 65193, 296, 69, 184, 190, 65491, 65141, 64916, 65373, 279, 205, 65361, 65470, 246, 65410, 65025, 65425, 65392, 50, 229, 65427, 65524, 65517, 64716, 38, 308, 65289, 65528, 223, 65401, 65296, 64818, 65334, 281, 257, 65525, 27, 131, 65235, 64826, 65472, 195, 179, 65511, 41, 239, 65413, 64960, 65439, 65519, 142, 231, 65398, 23, 65526, 64727, 65472, 353, 65399, 213, 272, 65498, 65271, 65021, 65222, 316, 230, 65438, 47, 200, 65259, 64993, 65520, 176, 164, 58, 65376, 150, 65415, 64772, 2, 87, 27, 203, 65491, 65528, 65300, 64671, 65278, 179, 65530, 87, 123, 39, 65235, 65020, 65249, 192, 67, 65526, 104, 158, 65287, 64879, 65498, 141, 108, 65486, 65518, 239, 11, 64960, 65371, 126, 65528, 223, 40, 65356, 65442, 64807, 69, 421, 100, 65517, 81, 132, 65158, 64937, 65269, 136, 235, 114, 65529, 278, 65324, 64914, 20, 197, 50, 72, 65293, 30, 37, 64956, 65390, 233, 65379, 315, 183, 65483, 65035, 64679, 65442, 348, 228, 65471, 65421, 179, 65275, 64937, 65243, 45, 55, 89, 133, 169, 65273, 64887, 65411, 167, 193, 7, 65350, 33, 65484, 64880, 65414, 108, 65440, 313, 113, 65449, 65237, 64838, 65399, 353, 103, 65447, 93, 336, 65142, 64985, 65385, 104, 136, 219, 65427, 187, 32, 64909, 65380, 275, 13, 145, 54, 65479, 65330, 65036, 65517, 184, 65517, 233, 69, 100, 65022, 64614, 65313, 430, 125, 65356, 65509, 329, 65314, 65091, 65269, 65494, 63, 123, 65299, 151, 65424, 64912, 65450, 251, 65509, 206, 65488, 65382, 65379, 64835, 65423, 218, 15, 72, 239, 138, 65076, 64887, 65250, 214, 195, 65461, 65349, 143, 65402, 65052, 65472, 71, 90, 260, 65403, 56, 65368, 64768, 65488, 259, 65519, 225, 76, 65502, 65197, 64988, 65367, 240, 65465, 85, 129, 304, 65124, 64747, 65336, 431, 150, 65518, 65299, 199, 65391, 65062, 65324, 8, 97, 189, 65423, 3, 65282, 64772, 65331, 178, 65520, 154, 65472, 65410, 65131, 64960, 65343, 262, 65509, 65492, 129, 348, 65032, 64941, 65274, 49, 235, 28, 65206, 160, 97, 64852, 32, 147, 65340, 298, 59, 65338, 65314, 64832, 65242, 196, 182, 117, 118, 134, 65028, 64923, 65350, 227, 65433, 65520, 23, 313, 65339, 65147, 65293, 219, 126, 64, 65271, 51, 65381, 64784, 37, 211, 65433, 232, 65412, 65392, 65215, 64820, 65190, 333, 79, 65475, 65509, 155, 64948, 64954, 65291, 107, 110, 115, 65319, 205, 65388, 64866, 65375, 129, 95, 108, 65476, 65477, 65389, 64933, 65346, 65487, 65394, 217, 97, 65405, 65070, 64740, 65330, 443, 117, 65358, 65515, 256, 65170, 65026, 65377, 14, 47, 148, 65426, 230, 65468, 64799, 65329, 299, 131, 108, 65384, 65274, 65231, 64830, 0, 90, 65394, 106, 25, 306, 65173, 64804, 64810, 242, 294, 48, 65360, 65397, 65095, 65237, 138, 65523, 65346, 65528, 65389, 353, 65405, 64577, 65206, 135, 49, 235, 65521, 65272, 65108, 64877, 65350, 244, 65424, 65297, 35, 210, 65302, 65038, 65201, 69, 138, 37, 65334, 12, 65363, 64797, 87, 210, 65509, 125, 65430, 65407, 65365, 64781, 65303, 164, 41, 120, 71, 73, 65131, 64837, 65237, 361, 176, 65461, 65396, 26, 65142, 64979, 65408, 65470, 179, 159, 65299, 216, 65299, 64656, 65337, 27, 65407, 185, 11, 65425, 65230, 64799, 65153, 240, 65450, 65405, 49, 133, 65130, 64932, 65210, 199, 183, 65401, 65414, 97, 65394, 65139, 65401, 65393, 52, 104, 65329, 65331, 65353, 64647, 185, 280, 65346, 85, 123, 1, 65150, 64630, 65029, 224, 352, 65477, 65388, 109, 65294, 64969, 65433, 48, 65485, 75, 65531, 111, 65345, 64909, 65305, 54, 243, 102, 65428, 65410, 65194, 64683, 64, 180, 65152, 65483, 194, 237, 65291, 64830, 64833, 319, 443, 65406, 65290, 65404, 65164, 64979, 135, 65431, 65446, 65503, 65340, 225, 27, 64781, 65199, 89, 32, 161, 66, 65154, 65042, 64722, 65529, 299, 65512, 65320, 65382, 227, 65476, 64875, 65243, 113, 287, 176, 23, 65382, 65103, 64675, 65503, 65490, 155, 90, 65425, 11, 65371, 64771, 65324, 160, 65467, 21, 230, 147, 65065, 64718, 65134, 204, 234, 65472, 65440, 167, 65376, 65198, 65263, 3, 18, 65430, 65460, 110, 65427, 64769, 83, 65, 65511, 141, 65393, 65365, 65217, 64659, 65387, 262, 9, 65368, 106, 98, 65397, 64909, 65137, 51, 308, 65506, 65353, 65353, 65254, 64877, 134, 55, 65475, 86, 40, 68, 65290, 64640, 65316, 80, 161, 8, 43, 48, 65179, 64650, 65400, 295, 65485, 65493, 65514, 67, 13, 65089, 65191, 83, 368, 64, 65531, 65500, 65222, 64718, 56, 21, 9, 77, 6, 65508, 65332, 64812, 65301, 277, 65432, 65359, 78, 119, 65107, 64789, 65301, 193, 442, 48, 65264, 65523, 65386, 64828, 0, 65523, 65508, 63, 130, 16, 65400, 64795, 65276, 128, 188, 1, 13, 65452, 65145, 64615, 65457, 161, 50, 65485, 65510, 223, 65401, 64984, 65187, 27, 242, 12, 53, 65492, 65351, 64799, 65535, 9, 67, 123, 65504, 65510, 65350, 64937, 65481, 244, 65464, 65422, 253, 211, 65198, 64624, 65217, 245, 253, 65523, 65207, 65484, 65532, 65155, 18, 165, 65526, 70, 174, 65519, 65133, 64459, 65484, 137, 308, 15, 65421, 65535, 65368, 64915, 65250, 96, 23, 65508, 195, 112, 65251, 64801, 65396, 161, 220, 65507, 65333, 65524, 65471, 64828, 65365, 117, 66, 86, 92, 65418, 65249, 64873, 40, 142, 58, 65466, 65500, 142, 65228, 64588, 65322, 376, 189, 141, 57, 5, 65371, 65127, 65294, 65505, 295, 22, 65518, 97, 65288, 64717, 37, 160, 65504, 155, 51, 65508, 65187, 64797, 65372, 173, 226, 65401, 41, 312, 65236, 64700, 65312, 116, 105, 115, 65514, 12, 58, 65042, 65282, 138, 124, 1, 47, 65400, 65223, 64817, 88, 139, 65497, 30, 88, 179, 65327, 64727, 65209, 254, 194, 65448, 65476, 65514, 65339, 65138, 70, 167, 42, 74, 65501, 37, 65421, 64535, 65465, 239, 359, 139, 65474, 65458, 65157, 64933, 65420, 71, 65476, 40, 198, 205, 65317, 64653, 65242, 243, 202, 65476, 65403, 65535, 65396, 65130, 65407, 88, 60, 113, 10, 65437, 65326, 64762, 79, 235, 120, 68, 24, 65524, 65079, 64712, 65350, 234, 157, 65513, 13, 293, 65281, 64746, 65389, 147, 58, 97, 65476, 65501, 65433, 64920, 65233, 206, 234, 66, 55, 65522, 65241, 64887, 65531, 74, 87, 70, 64, 112, 65296, 64794, 65319, 245, 137, 65428, 34, 117, 65425, 65004, 65427, 25, 67, 164, 65409, 65499, 65294, 64736, 65434, 392, 76, 90, 111, 65483, 65184, 65048, 65355, 65493, 177, 65517, 65525, 266, 65293, 64677, 17, 384, 65456, 3, 65462, 65414, 28, 65003, 65316, 115, 242, 144, 20, 65487, 65086, 64686, 73, 330, 16, 65474, 62, 132, 65325, 64830, 65307, 27, 291, 67, 65416, 65532, 65292, 64782, 65478, 247, 65461, 47, 57, 17, 65401, 64840, 65210, 264, 290, 129, 65432, 65443, 65147, 64995, 65501, 177, 95, 62, 122, 250, 65281, 64749, 65347, 68, 249, 48, 65408, 65500, 65424, 64919, 65494, 99, 65341, 177, 201, 65495, 65170, 64737, 65333, 381, 279, 65346, 65494, 213, 65196, 64943, 65354, 65526, 107, 137, 65450, 112, 39, 64919, 65397, 178, 65475, 37, 25, 65383, 65313, 64840, 9, 346, 11, 65508, 6, 22, 65308, 64794, 65381, 251, 216, 65519, 73, 42, 65184, 64950, 65379, 105, 240, 20, 65241, 106, 65508, 64843, 2, 96, 65482, 419, 98, 65329, 65211, 64673, 65358, 429, 138, 65401, 112, 133, 65235, 65017, 65226, 16, 296, 54, 65454, 51, 65285, 64880, 119, 183, 65490, 32, 65521, 90, 65472, 64765, 65264, 122, 49, 205, 11, 65324, 65184, 64808, 65450, 434, 27, 65361, 54, 249, 65240, 65013, 65349, 22, 408, 114, 65293, 0, 65342, 64845, 33, 149, 65454, 232, 59, 23, 65411, 64672, 65431, 271, 117, 99, 161, 55, 65161, 64880, 64923, 180, 193, 65363, 69, 220, 65440, 65304, 136, 65533, 17, 65523, 65239, 65453, 37, 64670, 53, 310, 65403, 409, 147, 65226, 65139, 64712, 65389, 398, 225, 65247, 53, 271, 65208, 64989, 65175, 147, 193, 120, 65287, 65526, 65407, 65055, 203, 79, 142, 143, 65459, 51, 65340, 64396, 65490, 261, 65479, 132, 245, 65427, 65272, 64986, 64936, 308, 274, 65338, 33, 258, 65149, 65080, 32, 74, 161, 106, 65126, 83, 166, 64921, 65490, 65494, 65512, 342, 129, 65328, 65199, 64601, 65458, 433, 65488, 65492, 47, 4, 65314, 64991, 65070, 286, 239, 65472, 71, 181, 65175, 65067, 41, 63, 177, 89, 65192, 14, 38, 64711, 12, 116, 65517, 315, 236, 65392, 65099, 64771, 65266, 309, 65473, 65370, 156, 239, 65308, 65033, 65234, 366, 298, 65421, 65298, 78, 65389, 65060, 97, 65515, 50, 175, 65438, 137, 4, 64613, 65377, 236, 22, 93, 60, 65217, 65322, 65017, 65205, 351, 31, 65389, 19, 239, 65134, 64974, 57, 254, 296, 95, 65151, 65523, 37, 64770, 65438, 2, 36, 383, 52, 65429, 65218, 64674, 65447, 306, 65469, 21, 185, 74, 65213, 64847, 65047, 266, 248, 65414, 31, 218, 65287, 65178, 65445, 8, 152, 65520, 65298, 72, 10, 64711, 24, 224, 65363, 283, 84, 65341, 65333, 64872, 65191, 322, 162, 65411, 155, 221, 65051, 64920, 65313, 296, 146, 65447, 65291, 97, 100, 65227, 65514, 65462, 129, 228, 65442, 22, 65280, 64420, 89, 371, 65375, 81, 56, 65408, 65459, 64963, 65017, 243, 205, 65418, 73, 163, 65070, 64991, 65449, 178, 178, 50, 65269, 95, 65530, 64884, 22, 54, 65509, 135, 39, 7, 65416, 64690, 65325, 295, 65391, 102, 54, 65314, 65256, 64912, 65286, 476, 240, 65321, 30, 297, 65093, 65015, 65427, 65458, 240, 237, 65231, 55, 68, 64720, 65480, 273, 65409, 63, 206, 65514, 65200, 64749, 65201, 203, 134, 65485, 65455, 132, 65380, 65025, 65257, 213, 109, 65501, 65519, 42, 65303, 64978, 65510, 68, 107, 117, 65324, 111, 65459, 64665, 65428, 226, 65461, 145, 180, 65402, 65334, 64958, 65174, 219, 43, 65367, 65527, 171, 65186, 64987, 65502, 275, 123, 81, 65376, 131, 65381, 64825, 32, 66, 62, 142, 11, 94, 65440, 64729, 65195, 250, 65528, 26, 83, 65390, 65303, 64957, 65382, 331, 78, 65394, 65496, 206, 65260, 64930, 65324, 30, 185, 55, 65433, 108, 65467, 64779, 24, 217, 65396, 61, 65528, 65438, 65351, 64812, 65343, 338, 98, 65501, 11, 111, 65175, 64804, 65254, 158, 244, 96, 65394, 79, 65331, 64997, 65522, 82, 19, 65521, 65487, 125, 65440, 64732, 65257, 145, 9, 234, 7, 65412, 65269, 64875, 65428, 346, 48, 65359, 135, 256, 65282, 64955, 65227, 4, 126, 97, 65480, 87, 65297, 64830, 47, 268, 13, 65408, 65494, 53, 65489, 64817, 65248, 107, 65461, 202, 65530, 65437, 65266, 64905, 65349, 468, 155, 65340, 16, 136, 65269, 64900, 65486, 65449, 132, 170, 65433, 202, 65351, 64779, 65299, 188, 65506, 65519, 96, 65507, 65435, 64956, 65480, 236, 65515, 0, 65448, 65504, 65261, 64869, 65310, 322, 107, 37, 62, 112, 65159, 64869, 39, 194, 76, 65460, 65320, 180, 53, 64821, 65261, 71, 67, 315, 118, 65367, 65117, 64756, 9, 246, 21, 65386, 54, 176, 65349, 64880, 65204, 179, 144, 65533, 26, 157, 65169, 64764, 65458, 116, 166, 62, 65361, 171, 33, 64813, 65187, 108, 65459, 102, 200, 65421, 65317, 65056, 65334, 172, 65518, 65480, 23, 104, 65154, 64882, 18, 331, 48, 65430, 65468, 179, 65496, 64935, 65235, 65510, 179, 164, 65457, 45, 65254, 64900, 59, 280, 65427, 65534, 65534, 65478, 65380, 64824, 65291, 158, 143, 78, 118, 205, 65057, 64805, 65441, 271, 23, 65376, 65385, 61, 175, 4747, 4835, 4901, 4764, 4182, 4906, 5309, 7893, 8549, 7959, 6195, 5263, 4701, 4676, 4795, 4983, 4588, 4489, 4777, 4225, 3554, 4715, 5527, 7959, 8776, 8197, 5573, 4690, 4025, 4640, 4484, 5102, 4960, 4632, 4599, 4693, 4709, 5129, 5796, 8186, 8570, 7996, 5332, 5068, 4105, 4077, 5020, 4522, 4987, 4861, 4781, 5062, 4907, 4983, 5579, 7985, 8245, 7678, 5303, 4312, 4831, 4866, 4932, 4974, 5113, 4943, 4966, 5023, 4940, 4355, 5325, 7654, 7823, 7272, 5270, 4949, 4344, 4854, 4987, 5039, 5098, 4899, 4747, 4791, 4296, 4970, 4959, 7238, 7516, 6921, 5448, 4946, 4671, 4895, 5152, 5037, 4789, 4098, 4876, 4824, 4196, 4405, 4871, 6922, 7705, 7130, 5310, 4461, 4886, 4841, 4327, 4936, 4719, 4757, 4782, 4944, 4811, 4291, 4977, 7113, 7488, 6894, 5211, 4905, 4751, 4175, 4813, 4944, 4885, 4842, 4754, 4945, 4795, 4784, 4804, 6903, 7440, 6849, 4978, 4165, 4164, 4171, 4752, 4904, 4779, 4023, 4549, 4271, 4732, 5038, 4125, 6885, 7637, 7041, 4412, 4087, 4752, 4723, 4890, 4933, 4911, 4555, 3991, 4745, 4676, 4989, 4716, 7072, 7481, 6899, 4882, 4619, 4973, 4887, 4273, 4970, 4870, 4579, 4860, 4161, 4928, 4835, 4731, 6919, 7217, 6663, 4994, 4140, 5000, 4878, 4208, 4264, 4708, 4204, 5021, 4850, 4838, 4235, 4828, 6596, 8424, 7844, 5297, 4890, 4706, 4879, 4993, 4779, 4351, 4848, 4933, 4935, 4667, 4362, 5582, 7833, 8822, 8240, 5724, 5241, 4764, 4836, 5075, 4624, 4675, 4905, 4889, 4863, 4705, 4994, 5890, 8232, 8678, 8105, 5465, 5293, 4714, 4549, 4953, 4793, 5014, 5023, 4972, 4727, 4428, 4863, 5695, 8095, 8211, 7634, 5429, 5094, 4610, 4144, 5061, 5110, 5208, 4906, 4868, 4173, 4783, 4630, 5412, 7612, 8422, 7836, 5493, 5064, 4166, 4873, 5007, 5125, 5094, 4144, 4769, 4870, 4898, 4733, 5524, 7833, 8226, 7655, 5306, 5073, 4800, 4847, 4837, 5057, 4910, 5007, 4753, 4961, 4878, 4795, 5407, 7644, 7620, 7033, 4475, 4858, 4861, 3520, 4150, 5022, 4989, 5023, 4793, 5013, 4693, 4366, 5079, 7042, 7268, 6675, 4237, 4928, 4988, 4810, 4654, 4928, 4969, 4921, 4773, 4828, 4700, 4841, 4216, 6696, 7642, 7096, 4802, 5052, 4956, 4738, 4200, 4950, 4942, 4681, 4727, 5030, 4940, 4770, 4724, 7040, 7722, 7162, 4921, 4868, 4794, 4350, 4379, 4933, 4899, 3989, 4890, 5088, 5029, 4378, 4811, 7142, 7728, 7167, 5032, 4743, 4810, 4957, 4814, 4952, 4944, 4452, 4875, 5021, 4373, 4932, 4859, 7130, 7473, 6899, 5072, 4902, 4867, 4769, 4786, 4977, 3814, 4717, 4825, 3741, 4932, 4892, 4331, 6880, 8106, 7539, 5345, 5041, 4835, 4736, 4779, 5023, 4952, 4991, 4859, 4656, 4999, 4764, 5265, 7513, 8849, 8273, 5855, 5092, 5072, 3696, 4004, 4829, 4324, 3596, 4614, 4100, 4965, 5192, 5861, 8270, 8941, 8360, 5983, 4630, 5183, 4757, 4021, 4081, 4216, 4147, 4700, 4661, 5176, 5213, 5969, 8355, 8543, 7963, 5793, 5084, 4958, 4969, 4995, 4821, 4979, 4184, 4184, 4877, 4933, 4976, 4914, 7959, 8430, 7839, 5672, 5093, 5049, 4808, 4953, 4881, 5019, 4807, 4846, 4892, 4860, 4934, 5477, 7847, 8671, 8077, 5834, 5065, 4991, 5006, 4919, 5020, 4453, 4325, 4942, 4806, 4702, 4853, 5716, 8083, 8899, 8310, 5967, 5188, 4749, 4925, 5048, 5018, 4740, 4843, 5031, 4853, 4799, 4943, 5936, 8311, 8800, 8217, 5828, 5134, 4053, 4167, 4998, 4766, 4220, 4631, 4992, 4834, 4790, 5059, 5798, 8211, 8383, 7805, 5322, 4428, 3943, 4666, 4745, 4566, 4747, 4833, 4765, 4895, 4867, 4765, 5441, 7791, 7738, 7155, 5218, 4971, 4792, 4190, 3916, 4226, 4275, 4947, 4677, 4960, 4838, 4808, 5139, 7149, 7332, 6769, 5329, 4818, 4841, 4914, 4151, 4903, 4317, 4880, 4174, 5069, 4381, 4841, 4911, 6733, 7377, 6827, 5241, 4833, 4768, 4782, 4557, 4720, 4761, 4404, 4822, 4901, 4795, 4872, 4737, 6805, 8125, 7539, 5460, 5098, 4995, 4541, 4595, 4630, 4111, 4710, 5069, 3643, 4668, 4883, 4515, 7536, 8266, 7671, 5492, 4981, 4996, 4994, 4914, 4149, 4777, 4914, 5112, 4720, 4209, 4978, 5165, 7677, 7872, 7275, 5497, 4361, 4782, 4853, 4811, 4569, 4806, 4830, 4903, 4661, 4308, 4937, 4897, 7285, 7366, 6772, 5362, 4891, 5003, 4779, 4644, 4667, 4608, 3871, 4974, 4240, 4117, 4882, 4663, 6802, 8189, 7601, 5223, 4372, 5112, 4826, 3663, 4692, 4762, 4697, 5033, 4883, 4247, 4930, 5143, 7605, 8492, 7910, 5561, 4775, 5037, 5011, 4889, 4649, 3681, 4939, 4913, 4934, 4938, 5078, 5478, 7916, 8277, 7676, 5602, 4655, 4712, 5033, 4969, 4730, 4762, 4975, 4868, 4831, 4872, 4874, 5352, 7693, 7533, 6964, 4944, 4845, 4798, 4906, 5120, 4227, 4684, 4310, 4290, 4577, 4820, 4769, 4850, 6957, 7413, 6826, 4984, 4927, 4890, 4823, 4937, 4852, 3570, 4783, 4652, 4352, 4623, 4632, 4722, 6835, 7524, 6953, 5137, 4944, 4919, 4934, 4511, 4826, 4821, 4891, 4098, 4754, 4863, 4827, 4676, 6947, 7687, 7099, 5344, 4861, 4797, 4898, 4595, 4640, 4976, 4999, 4689, 4357, 4983, 4688, 4787, 7106, 7700, 7135, 5308, 4874, 4572, 4219, 4135, 4745, 5048, 4478, 4813, 4871, 4895, 4808, 4957, 7120, 7789, 7240, 5266, 4743, 4634, 4741, 4619, 5002, 4974, 4836, 5044, 4816, 4774, 4934, 5075, 7194, 7664, 7107, 5369, 4656, 4823, 4904, 4313, 4961, 5080, 4260, 4965, 4798, 4770, 4846, 5113, 7064, 7254, 6668, 5094, 4072, 4861, 5025, 4851, 4864, 5053, 4854, 5007, 4913, 4726, 4661, 4454, 6639, 7136, 6641, 4990, 4918, 4992, 4839, 4383, 4906, 4984, 4941, 4241, 4334, 4891, 4710, 5093, 6624, 7772, 7194, 5035, 4401, 4998, 4450, 4771, 5007, 4961, 4766, 4749, 4294, 5149, 5037, 5045, 7203, 7709, 7137, 4943, 4792, 4903, 4691, 4176, 5030, 4748, 4819, 4329, 4785, 5144, 4995, 5078, 7136, 6902, 6351, 4850, 4249, 5057, 4878, 4644, 4832, 3911, 4753, 4961, 4929, 4338, 4935, 4619, 6287, 7048, 6455, 4926, 4822, 4236, 4600, 4866, 4831, 4693, 4764, 4980, 4362, 4257, 4837, 4686, 6472, 6924, 6292, 4848, 4397, 4766, 4003, 4259, 4976, 4320, 4887, 4494, 4937, 4776, 4840, 4734, 6378, 6684, 6138, 4634, 4881, 4377, 4732, 4918, 4878, 4973, 5009, 4917, 4983, 4771, 4838, 4903, 6221, 7012, 6404, 4632, 4923, 4983, 4911, 4961, 4644, 4783, 4812, 4855, 4853, 4840, 4503, 4978, 6417, 7384, 6798, 4868, 4906, 5033, 5006, 4782, 3548, 4810, 4874, 4932, 4896, 4879, 4404, 5015, 6815, 7231, 6635, 4905, 4978, 4325, 4978, 4850, 4761, 4874, 4916, 4804, 4897, 4751, 4855, 4390, 6657, 7024, 6358, 4883, 4783, 4273, 4710, 4880, 4060, 4731, 4792, 4716, 4863, 4865, 4312, 4404, 6492, 7565, 6875, 5028, 4385, 4919, 4252, 4724, 4818, 4969, 4353, 4220, 4944, 4804, 4872, 4533, 7026, 7903, 7314, 5350, 4105, 5011, 4814, 4745, 4840, 4912, 4969, 4797, 4923, 3698, 5017, 5091, 7323, 7787, 7206, 5728, 4902, 5024, 4116, 4678, 4136, 4925, 5032, 4783, 4790, 4697, 4907, 5025, 7186, 7362, 6771, 5658, 4870, 4973, 4573, 4513, 4711, 4925, 4961, 4678, 4793, 4834, 4858, 4926, 6775, 7582, 7009, 5423, 4908, 4793, 4073, 4004, 4813, 4886, 4766, 4838, 4417, 4879, 4901, 4964, 6981, 7725, 7112, 5136, 4872, 4682, 4138, 4103, 4813, 4247, 4804, 4871, 4331, 4137, 4699, 4818, 7137, 7325, 6712, 5050, 4854, 4010, 3557, 4108, 4644, 4224, 4855, 4747, 4645, 4549, 4833, 4262, 6726, 7789, 7206, 5037, 4808, 4658, 4671, 4580, 4488, 4955, 4946, 4674, 4352, 4729, 4897, 5142, 7203, 8866, 8289, 5677, 5292, 4751, 4790, 4044, 4226, 4889, 4898, 3573, 4595, 4443, 5236, 5917, 8282, 9255, 8671, 6131, 5694, 4980, 4914, 4783, 4624, 4662, 4904, 3998, 4356, 5076, 5497, 6276, 8661, 9108, 8524, 6008, 5590, 4835, 4830, 4864, 4193, 4747, 4685, 3660, 5112, 5026, 5514, 6102, 8519, 8939, 8355, 5873, 5365, 4214, 5035, 4712, 4132, 4135, 4701, 4903, 5127, 5136, 5517, 5795, 8355, 9146, 8560, 6125, 5433, 4344, 4910, 4288, 4769, 4948, 4939, 4809, 4939, 5214, 5479, 6066, 8562, 8665, 8078, 5760, 4450, 4769, 4863, 4852, 4884, 4944, 4226, 4887, 4894, 4842, 4604, 5496, 8082, 8343, 7765, 5426, 4890, 4744, 3694, 4650, 4754, 4828, 4324, 4672, 4633, 4779, 4549, 4729, 7758, 7953, 7377, 5030, 4288, 4744, 3962, 4037, 4755, 4893, 4980, 4931, 3958, 4838, 4119, 4993, 7365, 7629, 7036, 4971, 4773, 4609, 4165, 4697, 4222, 4887, 4850, 4929, 4723, 4713, 4898, 4851, 7046, 7041, 6532, 5004, 5008, 4890, 4893, 4118, 3902, 4265, 4636, 4740, 4190, 4667, 5001, 4430, 6435, 7267, 6685, 5073, 4915, 5009, 4716, 3348, 4502, 4737, 4569, 4633, 4034, 4635, 4817, 5032, 6681, 7660, 7058, 5176, 4983, 5055, 4088, 4048, 4714, 4780, 4663, 4131, 4112, 4825, 4821, 4374, 7085, 7782, 7198, 5033, 4866, 4929, 4821, 4684, 4666, 4115, 4680, 4629, 4681, 4644, 4299, 4857, 7211, 7781, 7207, 4436, 4932, 4916, 4984, 4341, 4631, 4168, 4918, 4775, 4732, 4735, 4900, 5152, 7200, 7440, 6867, 4457, 4412, 4978, 4727, 4673, 4769, 5011, 4859, 4758, 4728, 4764, 4800, 5066, 6848, 7679, 7074, 5271, 4828, 4149, 4645, 4687, 4930, 4831, 4771, 4286, 4702, 4671, 4742, 5065, 7115, 7918, 7322, 5340, 4782, 4660, 4479, 4305, 4906, 4660, 4709, 4727, 4639, 4587, 3665, 5035, 7336, 7811, 7238, 5145, 4593, 4742, 5010, 4881, 4784, 4556, 4952, 4198, 3584, 4138, 4907, 5039, 7239, 7491, 6900, 4917, 4651, 4899, 4688, 4799, 4539, 4785, 4897, 4287, 4184, 4869, 4669, 4949, 6952, 7401, 6800, 5090, 3993, 4880, 4655, 4607, 4616, 4442, 4738, 4765, 4800, 4907, 4305, 4993, 6818, 7390, 6810, 4565, 4721, 4869, 4082, 4520, 4798, 4891, 4866, 4781, 4974, 4733, 4772, 5055, 6821, 7357, 6778, 5200, 4872, 4944, 4783, 4804, 4839, 4862, 4767, 5088, 5173, 4703, 4804, 4475, 6772, 7423, 6872, 4920, 4697, 4755, 4838, 4185, 4672, 4798, 4788, 5163, 5159, 4820, 4872, 5058, 6823, 7757, 7172, 4355, 4899, 4044, 4837, 4689, 4785, 4654, 4515, 4860, 4335, 4948, 5060, 5262, 7178, 7451, 6865, 4900, 4860, 4150, 3943, 4867, 4838, 4567, 4695, 4546, 4748, 4965, 5052, 5237, 6901, 7560, 7006, 5104, 5168, 4853, 4774, 4211, 4786, 4850, 4743, 3922, 4702, 5094, 4517, 5190, 6966, 7564, 6998, 5150, 5160, 5089, 4905, 4793, 4814, 4926, 4835, 4617, 4943, 5163, 5188, 5122, 6967, 7932, 7351, 5194, 5089, 5092, 4912, 4901, 4896, 4923, 4264, 4522, 4816, 4873, 4995, 4944, 7342, 7941, 7356, 5253, 4976, 4934, 4777, 4730, 4369, 4439, 4829, 4706, 4895, 4837, 5057, 4366, 7355, 7518, 6931, 4620, 4914, 4651, 4299, 4838, 5044, 4804, 4922, 4821, 4223, 4756, 5071, 4848, 6938, 7333, 6819, 5364, 5020, 4869, 4716, 5003, 4463, 5061, 4892, 4883, 4109, 4908, 4377, 3622, 6724, 7190, 6699, 5237, 4850, 4739, 4712, 4783, 4440, 5044, 4804, 4925, 4214, 4718, 4820, 4707, 6571, 6983, 6446, 5212, 4125, 4087, 4113, 4918, 4945, 4826, 4934, 4531, 4186, 4679, 4933, 4183, 6393, 7118, 6413, 5062, 4794, 4660, 3085, 5039, 5110, 4662, 4741, 5105, 4848, 4820, 4427, 4587, 6576, 7343, 6769, 5086, 4848, 4876, 4769, 4824, 4981, 4692, 4598, 4852, 4854, 4938, 5065, 4844, 6771, 7507, 6912, 5206, 4875, 4227, 4754, 4870, 4709, 4175, 4652, 3979, 4890, 5108, 5023, 4887, 6913, 7898, 7294, 5229, 4614, 4625, 3629, 4295, 4666, 4115, 4758, 4560, 4908, 5087, 4858, 4947, 7320, 8335, 7753, 5355, 4655, 4837, 4247, 4997, 4827, 4699, 4666, 4601, 4553, 4687, 4555, 5351, 7746, 8217, 7632, 5073, 4799, 3776, 4153, 5033, 4886, 4958, 4595, 3955, 4424, 4464, 4857, 5335, 7628, 7518, 6943, 4265, 4755, 4771, 3658, 4271, 4840, 4714, 4121, 4682, 4671, 4712, 4685, 5115, 6914, 7907, 7312, 5191, 4654, 4229, 4696, 3619, 4584, 4799, 4083, 4740, 4691, 4854, 4518, 4324, 7319, 7784, 7200, 5085, 4746, 4703, 4679, 3655, 4123, 4593, 4097, 4856, 4697, 4793, 4275, 4874, 7200, 7449, 6884, 4743, 4786, 4317, 4760, 4753, 4065, 4156, 4581, 4812, 4839, 4661, 4034, 4929, 6854, 7536, 6959, 4793, 4927, 4968, 4835, 4831, 4570, 4100, 4671, 4238, 4864, 4749, 4861, 4983, 6914, 7414, 6851, 5075, 4921, 4460, 4894, 4959, 4743, 4773, 3694, 4765, 4825, 4927, 4826, 4856, 6833, 7312, 6731, 5034, 4863, 4943, 4877, 4752, 4591, 4694, 3578, 4829, 4357, 4791, 4928, 4830, 6737, 7534, 6948, 5228, 3004, 4520, 4188, 4604, 4555, 4903, 4870, 4319, 4861, 4836, 4779, 5020, 6944, 7363, 6736, 5009, 4089, 4747, 4375, 4913, 3986, 4862, 5009, 4853, 4662, 4900, 4708, 5021, 6791, 7255, 6645, 4948, 4831, 3746, 4823, 4980, 4750, 4174, 4667, 3739, 4079, 4701, 4474, 4838, 6669, 7136, 6555, 4988, 4786, 4780, 4586, 4238, 4667, 4553, 4081, 4521, 4791, 4667, 4567, 4738, 6549, 7046, 6517, 4817, 4676, 4686, 4543, 4493, 4295, 4687, 4647, 4584, 4891, 4256, 4262, 3954, 6445, 6959, 6416, 3583, 4513, 4030, 4071, 4594, 4652, 4793, 4930, 4847, 4858, 4851, 4291, 3926, 6359, 7107, 6535, 4631, 4446, 4660, 4678, 3998, 4019, 4957, 5014, 4644, 4688, 4836, 4696, 4631, 6515, 7863, 7273, 5033, 4511, 4487, 4199, 4474, 4556, 4917, 4678, 4328, 4137, 4740, 4581, 5013, 7270, 8130, 7559, 5174, 4494, 4058, 4764, 4547, 4745, 4665, 3872, 3975, 3518, 4632, 4048, 5212, 7549, 7897, 7325, 4936, 4623, 3916, 4719, 4494, 4516, 4392, 4307, 3962, 3861, 4513, 4375, 4982, 7315, 7134, 6560, 4493, 4592, 4483, 4617, 3904, 4345, 4248, 3816, 4437, 3851, 4432, 3853, 3998, 6542, 6255, 5686, 3829, 3850, 4403, 4374, 3210, 2593, 4293, 2369, 3405, 4451, 3775, 2841, 4439, 5098, 6054, 5401, 4385, 4288, 4224, 4368, 3170, 1538, 3135, 3180, 3797, 4421, 3757, 3757, 3786, 5523, 6114, 5507, 3941, 3664, 2080, 3832, 2715, 3647, 3164, 2622, 3861, 3786, 2657, 3647, 3170, 5531, 6131, 5562, 4328, 2668, 3589, 2651, 3164, 3180, 3770, 4248, 4310, 4160, 3618, 2628, 2668, 5617, 5991, 5382, 3890, 3618, 3677, 1538, 2051, 3647, 3106, 1538, 2139, 3647, 3677, 3647, 3850, 5348, 5469, 5011, 3741, 4317, 2697, 2139, 4195, 3135, 2628, 2139, 3135, 3135, 3706, 3239, 3706, 4324, 5418, 5026, 3813, 3810, 2651, 3170, 3677, 2622, 2622, 2692, 3199, 2080, 3164, 3164, 4131, 4934, 5347, 4986, 4189, 4281, 2638, 3711, 3711, 3618, 3199, 3677, 3589, 3135, 3618, 2593, 2622, 4353, 5435, 4817, 3618, 4235, 3170, 3301, 2697, 4189, 3135, 3653, 3647, 2726, 3135, 2622, 3076, 4882, 5318, 4650, 2622, 3647, 3199, 2651, 3228, 3803, 3135, 3135, 3151, 2702, 3164, 3215, 2686, 4823, 4912, 3378, 2564, 3204, 3786, 3164, 3677, 4248, 3589, 3180, 3255, 3274, 2777, 3832, 3746, 4736, 5384, 4806, 1602, 3832, 4445, 3647, 2593, 3106, 3164, 3257, 4224, 4288, 3170, 3746, 4454, 4875, 5704, 5120, 3618, 3228, 4307, 2593, 3722, 3735, 3589, 3199, 3786, 4469, 4392, 2283, 4299, 5206, 6475, 5896, 3741, 3757, 3815, 3746, 2622, 4299, 3319, 3821, 3936, 4493, 4543, 4493, 2860, 5927, 8570, 7977, 5004, 5051, 4647, 4345, 3180, 3706, 3135, 3751, 4432, 4508, 4945, 4917, 5602, 7984, 9543, 8964, 6434, 5781, 5425, 4859, 4127, 2900, 4283, 4580, 4329, 4947, 5511, 5803, 6508, 8958, 20745, 44553, 48615, 26295, 9630, 41822, 44730, 45288, 61775, 53124, 20942, 47520, 50368, 4689, 22887, 20117, 7506, 12820, 29430, 37253, 34091, 40785, 52827, 4213, 12656, 42370, 54708, 39062, 34942, 26128, 25893, 44648, 37984, 47679, 10873, 39042, 7598, 12334, 54877, 19157, 63968, 51905, 51194, 25380, 4506, 59386, 15964, 62310, 16311, 24508, 33700, 28452, 54707, 40304, 43417, 60377, 13592, 20322, 6326, 57118, 11346, 13167, 65064, 59858, 7572, 24964, 22535, 45773, 8524, 20694, 41882, 28113, 57490, 54012, 7423, 51140, 10814, 1382, 57337, 27530, 53798, 28546, 32628, 41805, 31305, 29485, 24006, 58396, 12336, 13041, 36278, 25682, 57296, 8969, 9474, 14960, 2942, 17279, 28910, 26199, 1177, 33691, 45200, 22598, 49207, 18299, 37228, 26513, 60126, 39918, 24431, 51325, 62266, 28763, 36680, 64289, 11929, 43927, 44737, 47079, 22485, 45053, 9611, 37445, 32335, 36840, 7087, 16007, 41107, 14750, 62261, 60112, 20210, 26756, 34903, 57760, 59026, 31953, 54263, 36605, 56185, 18626, 20965, 28167, 60922, 19094, 18200, 52683, 19713, 59072, 35696, 61892, 47966, 29129, 34890, 40307, 41755, 40683, 5267, 21131, 28725, 18767, 58309, 59341, 11883, 41544, 64543, 44693, 27822, 42334, 12421, 10396, 29944, 7118, 23667, 43155, 29441, 64911, 2996, 60815, 27799, 58280, 32610, 35233, 37358, 51520, 53512, 735, 14308, 56754, 12658, 55373, 40873, 45582, 20962, 19746, 32788, 47152, 26290, 26813, 62699, 5840, 6281, 27039, 28950, 976, 51268, 28, 49285, 13769, 55830, 1060, 15596, 46211, 14000, 49017, 33508, 10288, 10182, 8570, 30764, 11561, 57354, 62679, 19396, 51696, 60983, 11399, 5032, 27282, 5463, 60256, 6295, 60777, 14861, 62989, 35329, 24237, 58507, 39775, 41290, 64302, 4073, 22087, 9601, 32330, 32997, 45933, 4388, 26404, 63526, 10327, 52578, 442, 53366, 64052, 38288, 4913, 64787, 2793, 32796, 43353, 26338, 1810, 3716, 7294, 59713, 33381, 56125, 58403, 38266, 6251, 32110, 3021, 51596, 56975, 33563, 20132, 16608, 39344, 12833, 14330, 25994, 34211, 10449, 41090, 39172, 34940, 407, 40527, 37412, 30812, 12285, 10982, 49126, 54777, 649, 31455, 36260, 62356, 46495, 6421, 15150, 49310, 22684, 35808, 17514, 58489, 42868, 46097, 60959, 35613, 51898, 54203, 53503, 53955, 60082, 39343, 37555, 34911, 908, 21108, 61068, 38710, 44663, 501, 6118, 21992, 61398, 47516, 26804, 31713, 55174, 54460, 24770, 11812, 21659, 14387, 35275, 55132, 58614, 56843, 3483, 61166, 31352, 54143, 65221, 35039, 51774, 60302, 26018, 38831, 19382, 2963, 24408, 33195, 21589, 11375, 58867, 29502, 42234, 14410, 12043, 16050, 7506, 58155, 32285, 17417, 64677, 19832, 55195, 49662, 59360, 35657, 18753, 44738, 48898, 51474, 59840, 37082, 63451, 3092, 22509, 29882, 15745, 52072, 42212, 15919, 47049, 31055, 23139, 48610, 35879, 35397, 11236, 2191, 13682, 63102, 64186, 6666, 55864, 40079, 38478, 17885, 16336, 55713, 8129, 25595, 58690, 10322, 25760, 31786, 19977, 32894, 32911, 59052, 62671, 45860, 20462, 52732, 25002, 52968, 7701, 26026, 47716, 60974, 14071, 21477, 35597, 65415, 65095, 59023, 30146, 11251, 9558, 62400, 54231, 30170, 15218, 30888, 59393, 44967, 6090, 19067, 44710, 18777, 47421, 62516, 21761, 27298, 39211, 51896, 1194, 62592, 35915, 55464, 61449, 25432, 18963, 32480, 11854, 12413, 22726, 25721, 24140, 29460, 46366, 11952, 4576, 29400, 9185, 41429, 53651, 57513, 47086, 47234, 63651, 23258, 30344, 26181, 31053, 32271, 12927, 47662, 352, 12752, 62719, 47583, 52008, 14834, 40462, 37186, 60794, 54771, 64053, 51226, 28312, 26493, 47532, 9406, 42712, 14122, 51413, 65420, 47164, 48962, 12386, 59777, 63155, 39758, 43650, 41277, 5466, 13747, 38254, 65277, 2641, 56417, 26843, 41199, 50275, 7148, 58340, 58272, 28971, 16634, 8723, 7102, 2178, 24379, 13358, 31346, 65530, 22308, 61202, 21235, 2626, 41067, 8928, 3240, 44626, 43174, 3095, 55345, 18984, 4436, 52623, 12804, 32825, 43898, 56512, 46709, 23726, 12742, 11949, 60009, 65179, 51114, 63920, 57877, 42298, 41314, 56831, 416, 7956, 47286, 40498, 13906, 5046, 60049, 38291, 4075, 10739, 8484, 264, 14266, 46378, 858, 53575, 17554, 51921, 49963, 19537, 42483, 54315, 20614, 33322, 592, 44387, 29913, 21512, 19724, 478, 55050, 1651, 44912, 8963, 21177, 43550, 8230, 29228, 2082, 55079, 1222, 15626, 11971, 26965, 48637, 21244, 13972, 4639, 58615, 1240, 54683, 2951, 38900, 57693, 11647, 45132, 21580, 53869, 24567, 19712, 12602, 32404, 36569, 33442, 17075, 14029, 22702, 24397, 20363, 2687, 46152, 21422, 59901, 36761, 43658, 11796, 39600, 21303, 28944, 32958, 42355, 7489, 17257, 277, 24092, 52855, 45146, 64427, 63327, 24744, 3172, 4624, 27721, 24456, 25712, 29861, 33611, 41797, 30635, 53869, 58656, 12237, 2113, 59856, 2958, 26239, 10708, 34846, 17171, 33172, 62501, 52974, 40912, 51105, 37607, 48718, 9550, 27938, 15391, 16078, 15379, 13985, 274, 17164, 2801, 39443, 48868, 25117, 8254, 49388, 3963, 42296, 25949, 17543, 4390, 18927, 59247, 38834, 30198, 35616, 10428, 49473, 39681, 54646, 48993, 53805, 38278, 30729, 26648, 46091, 34586, 38044, 11011, 34963, 24917, 4058, 52138, 19329, 41547, 56979, 8277, 20441, 16264, 19367, 63038, 12417, 56531, 15563, 31054, 13624, 30807, 467, 59895, 25414, 23137, 65037, 13821, 32359, 60938, 20491, 7049, 4790, 42690, 18428, 62786, 55037, 39647, 44306, 30630, 18115, 471, 26878, 64195, 58857, 4878, 61849, 27539, 6866, 65006, 1749, 2142, 19050, 49471, 58790, 12704, 39714, 19934, 1535, 42594, 35589, 22972, 52755, 46299, 13848, 608, 28933, 26267, 8630, 54137, 55878, 44594, 1535, 19047, 28402, 29844, 51325, 37394, 52248, 59598, 25051, 63094, 18675, 27324, 25048, 961, 4486, 8850, 61201, 64438, 43577, 31588, 33009, 47866, 31695, 11244, 17649, 32899, 24703, 51175, 9354, 12979, 49525, 32018, 10563, 44176, 33362, 41994, 49006, 5915, 45806, 45156, 44250, 48990, 62794, 64316, 2206, 11773, 41775, 6432, 21311, 50331, 27650, 28083, 60547, 36752, 46608, 28140, 48517, 550, 27707, 58528, 40887, 15048, 30835, 26676, 16339, 49552, 10466, 34530, 20405, 46651, 47390, 7001, 32390, 40964, 1337, 40814, 6975, 19001, 53606, 15445, 27838, 44661, 55533, 4393, 7378, 39238, 64808, 38591, 18970, 17651, 20551, 11015, 41184, 53194, 45290, 39058, 43751, 3704, 60012, 46992, 61381, 63162, 28599, 55648, 1921, 37223, 60975, 34799, 27879, 8299, 53677, 3733, 59786, 63863, 8592, 29587, 14682, 39598, 61694, 34574, 9745, 37713, 24660, 57987, 9052, 26620, 29721, 22066, 64072, 28142, 32873, 37061, 41512, 14748, 42692, 20017, 8969, 60492, 43022, 102, 10498, 20327, 18671, 41458, 55227, 59274, 9336, 35877, 61947, 63431, 43217, 5592, 23544, 62301, 35306, 59678, 53877, 46212, 17156, 50190, 2330, 51102, 37120, 13599, 29660, 43882, 4752, 18056, 35484, 19474, 4627, 64735, 19367, 52567, 13485, 13528, 4703, 64150, 11831, 39721, 31818, 53098, 25581, 13094, 16943, 9336, 35645, 11397, 3215, 18353, 45345, 46283, 36280, 36904, 5353, 41285, 18752, 56038, 42283, 37280, 38391, 30918, 58408, 29462, 39606, 60738, 4675, 57281, 23931, 9959, 39292, 11790, 35373, 46242, 19440, 7996, 22210, 35889, 53470, 52287, 18546, 16746, 38158, 22736, 47117, 56888, 13976, 29902, 7150, 11818, 3502, 31103, 45462, 19734, 61886, 3791, 47025, 4450, 46837, 21925, 37306, 10128, 44589, 9130, 39822, 44681, 31788, 56716, 31109, 20712, 25711, 63252, 11686, 47452, 15092, 36646, 11811, 28885, 65292, 52458, 1117, 43959, 28831, 45871, 62230, 41645, 4395, 11061, 55393, 38340, 8097, 8696, 39005, 35135, 34304, 39522, 64751, 10781, 28924, 37271, 41819, 9268, 8969, 13912, 48133, 33317, 36119, 27815, 29798, 39214, 24988, 9478, 24176, 32295, 14437, 63753, 54796, 39471, 57741, 23665, 37633, 6207, 47673, 1200, 43252, 55589, 3580, 48071, 6489, 26941, 10670, 36402, 11933, 29018, 2516, 13004, 45788, 41739, 36192, 45910, 40901, 13390, 46005, 50671, 20957, 14718, 63193, 28121, 34199, 50924, 55996, 26363, 42892, 61799, 50952, 3730, 47903, 13956, 36331, 53247, 55880, 35054, 17042, 26080, 58928, 4172, 45005, 37959, 42747, 1407, 63881, 28956, 23268, 17314, 11206, 8658, 26674, 38529, 11322, 24351, 41364, 34244, 23891, 64290, 9504, 59233, 59647, 41118, 988, 23368, 12583, 11147, 55893, 40340, 60480, 7197, 5462, 40408, 17214, 2035, 32041, 1534, 59563, 1467, 13231, 5027, 41056, 54179, 57953, 48209, 11657, 15954, 39252, 54097, 58088, 46886, 32115, 50201, 29257, 38034, 61504, 29796, 4976, 1686, 51278, 14803, 25220, 40181, 32626, 34555, 34975, 25632, 12678, 41430, 60473, 30356, 8768, 51094, 40925, 31156, 44821, 21658, 25613, 40931, 20361, 48072, 15364, 30962, 45865, 15603, 26773, 29766, 38443, 43148, 12259, 43207, 11477, 43652, 18132, 6489, 24755, 41280, 24563, 6681, 15127, 52016, 47916, 59952, 50278, 30994, 28197, 1746, 54237, 17210, 51352, 40455, 9682, 38542, 56482, 57743, 40675, 15670, 14473, 45237, 40935, 15189, 24729, 41235, 48660, 61619, 1921, 17879, 59044, 42606, 4188, 27853, 37115, 50699, 8756, 10476, 58973, 41008, 38422, 9305, 53853, 17105, 24415, 23122, 51151, 36190, 41277, 61877, 26045, 50129, 51411, 15523, 63098, 8992, 9649, 31602, 18195, 58426, 55888, 41168, 18614, 23739, 35790, 22546, 64374, 57599, 24040, 36908, 12720, 63089, 18381, 10126, 18462, 44235, 53479, 6065, 55099, 56723, 22973, 48049, 4234, 19072, 64199, 49139, 24693, 2285, 40243, 45360, 6060, 4647, 8759, 3231, 54607, 64222, 64185, 63704, 12088, 45547, 31278, 22708, 11894, 43025, 44660, 18752, 64624, 60946, 6602, 3218, 21041, 40016, 32899, 35765, 32921, 26898, 56277, 13579, 35033, 59689, 61862, 21010, 19761, 59843, 27570, 58096, 29035, 64034, 51950, 25968, 11522, 30830, 47275, 9178, 16214, 23385, 40323, 16791, 40181, 16295, 24572, 17375, 55818, 24870, 39060, 47094, 51727, 34050, 42413, 46431, 21509, 5281, 7356, 25051, 39389, 41292, 60183, 10450, 25899, 16892, 35740, 26457, 12970, 64704, 15601, 34988, 12883, 454, 43506, 6251, 25077, 54409, 40353, 14746, 23710, 8738, 21708, 4340, 34375, 6713, 32970, 36598, 48811, 31183, 52960, 53614, 47721, 19538, 36263, 59196, 30649, 9133, 43226, 13420, 3718, 22305, 54851, 19270, 53694, 15282, 39486, 64819, 57719, 6558, 7066, 40251, 65507, 40679, 47909, 9828, 58542, 35394, 8966, 41006, 33316, 4988, 57606, 35178, 23200, 3665, 54019, 13460, 2383, 16976, 36090, 61677, 9570, 34099, 4683, 36005, 24626, 34312, 25651, 36383, 37577, 38855, 14250, 50075, 12767, 26336, 538, 24966, 37930, 62609, 524, 58832, 53406, 25154, 8877, 3994, 49048, 60759, 61480, 11052, 20702, 16703, 42022, 40769, 37064, 12525, 64423, 55226, 64073, 59355, 27000, 58162, 4483, 11507, 18560, 31003, 49114, 9539, 8345, 53052, 36921, 45212, 61386, 40108, 6768, 43338, 20053, 56077, 27475, 968, 27290, 32431, 22282, 49581, 45260, 45590, 55003, 7503, 24102, 55924, 47175, 11322, 23182, 35757, 23290, 24205, 46645, 36176, 47930, 25099, 10869, 48501, 35924, 1237, 61647, 13555, 9404, 20175, 16027, 52815, 40124, 24984, 55066, 5646, 3878, 18015, 60471, 24800, 53202, 63759, 46142, 31585, 14539, 18278, 62297, 43114, 63217, 43002, 58295, 6269, 13898, 36384, 39839, 50404, 30122, 9453, 64430, 24581, 4688, 37070, 11258, 41427, 7972, 59499, 59296, 25736, 4037, 63786, 33349, 55558, 4276, 60764, 25475, 35236, 1444, 49355, 52944, 11014, 19966, 2941, 41263, 15893, 58685, 39730, 41133, 33740, 38465, 22635, 12924, 9053, 43631, 34519, 13162, 9939, 50113, 41744, 15056, 32831, 29527, 65502, 15704, 50370, 49474, 36766, 49894, 59702, 41275, 37368, 5033, 14990, 57735, 4257, 20226, 46063, 12255, 53092, 54922, 1151, 28522, 39815, 65021, 23878, 37241, 45618, 32246, 58505, 63878, 48955, 52490, 42369, 52650, 154, 23602, 31045, 35666, 60045, 6761, 58381, 60425, 34857, 37581, 55332, 1316, 55440, 25873, 17705, 479, 9333, 64304, 43502, 29688, 54050, 39851, 57797, 5093, 45363, 36903, 19835, 1417, 12922, 33821, 35775, 1845, 40146, 57320, 24448, 24981, 9817, 55847, 3215, 43304, 46701, 12433, 39352, 25153, 8293, 13606, 63526, 39754, 61450, 35818, 5785, 9736, 7849, 56763, 48373, 41045, 12951, 40, 51204, 37168, 55177, 57894, 33226, 43204, 8257, 44938, 2934, 3008, 41994, 29001, 13447, 45810, 351, 51443, 30009, 29364, 816, 17878, 20604, 12436, 50358, 28252, 21266, 4294, 6491, 44444, 41639, 30021, 59127, 61820, 65191, 21947, 45678, 29205, 3804, 60998, 9269, 14234, 19889, 30379, 4593, 25376, 27417, 3697, 49294, 40152, 13736, 44219, 904, 44897, 26493, 11072, 31306, 16341, 35726, 51236, 19012, 1688, 61487, 30346, 61000, 41229, 3344, 5744, 19, 16899, 35381, 50127, 21496, 21052, 39544, 16938, 4900, 11494, 60503, 32810, 26659, 38474, 58879, 28827, 36683, 53482, 13089, 42601, 43820, 15392, 39045, 25917, 19153, 18322, 20708, 5264, 19642, 54760, 13332, 61072, 50227, 28037, 3794, 10646, 363, 65358, 13875, 49387, 17878, 63112, 64683, 48678, 17833, 28197, 41176, 1768, 34289, 18105, 61851, 34650, 27609, 54440, 63992, 58318, 49722, 11339, 62274, 13236, 10868, 9578, 48592, 17409, 51823, 3707, 19719, 317, 52838, 9165, 27817, 29788, 53368, 9856, 8868, 28040, 22609, 2786, 20237, 20912, 40202, 29190, 10367, 59715, 44036, 28751, 63498, 19500, 33235, 33707, 947, 64572, 17673, 44358, 9564, 21147, 476, 38810, 54279, 11578, 21803, 35581, 35870, 28560, 12462, 3735, 36128, 1146, 13915, 17133, 11414, 65232, 2944, 32567, 22420, 44825, 32323, 14347, 34751, 19975, 42293, 49318, 17901, 14833, 11339, 13677, 52675, 52024, 40575, 32135, 63173, 13316, 43635, 14613, 13840, 25909, 45924, 64175, 59688, 26635, 4129, 62995, 26143, 59389, 29007, 6650, 8454, 58339, 51270, 22661, 18485, 28194, 20305, 11416, 52761, 13325, 14957, 54936, 41373, 4718, 29772, 62442, 58931, 43677, 32845, 17447, 64577, 13163, 4144, 5462, 52541, 37346, 38811, 10762, 507, 21127, 35592, 51704, 54282, 30399, 58280, 26885, 58292, 54861, 62409, 63472, 47013, 56395, 41759, 9704, 56977, 4968, 25579, 57988, 55381, 27659, 52606, 40627, 2828, 5701, 53957, 3850, 9842, 38018, 35366, 22676, 11521, 25073, 58248, 30914, 49963, 30452, 41238, 2829, 46126, 42525, 27351, 35602, 36942, 38253, 31413, 10409, 34360, 11786, 30988, 17455, 30387, 58329, 28752, 54747, 56047, 39946, 25087, 41382, 11794, 34370, 33019, 45285, 48352, 41092, 39567, 17361, 3811, 24944, 9926, 43292, 25528, 42487, 60341, 48257, 17306, 25128, 19820, 60934, 37744, 3703, 38364, 15192, 18840, 5215, 49720, 38297, 46564, 64103, 25801, 65396, 45619, 55818, 10278, 27761, 58052, 47608, 39022, 50804, 41876, 2443, 12196, 13922, 50624, 49242, 38349, 1353, 36129, 18723, 15253, 14538, 65515, 56272, 17658, 32196, 45980, 15783, 45268, 49474, 55775, 5183, 62758, 33179, 62710, 23354, 23728, 60462, 1466, 32421, 18580, 29585, 6010, 56478, 62019, 15407, 39602, 41538, 9088, 33322, 59580, 37434, 42446, 6339, 54558, 6597, 186, 32459, 24061, 56800, 63996, 3463, 62277, 22380, 10309, 6264, 48128, 14471, 51906, 65195, 30652, 51013, 8856, 52957, 6881, 33454, 10481, 6082, 54858, 20794, 48918, 63159, 43291, 13681, 16985, 3604, 61420, 2150, 6080, 32789, 21263, 63064, 44139, 63498, 12681, 51534, 25920, 16142, 44998, 2193, 14858, 62441, 44185, 46345, 25191, 48630, 11942, 22294, 24436, 722, 60204, 329, 29694, 50053, 29116, 11083, 63225, 59048, 31143, 60910, 28224, 23892, 60218, 27024, 27312, 57210, 27455, 61245, 60859, 38737, 14036, 9509, 5509, 55025, 59329, 58969, 52709, 15923, 24233, 57052, 22430, 56021, 48469, 44640, 455, 12056, 12577, 38831, 18135, 38316, 41526, 10829, 24482, 62074, 11528, 3556, 20039, 24921, 13494, 8770, 16801, 64600, 52539, 52273, 43613, 29764, 5292, 3657, 58596, 27290, 40414, 34570, 20247, 47061, 44853, 43111, 46627, 26826, 2166, 22972, 17810, 8518, 53080, 11944, 5072, 63211, 23302, 4356, 20271, 59790, 19437, 50658, 33172, 10457, 19344, 31658, 62291, 2243, 22700, 31120, 50134, 45477, 18511, 46505, 214, 22701, 40033, 62139, 1570, 21843, 47671, 3537, 49432, 29843, 61001, 36810, 63507, 55335, 820, 27540, 24582, 19690, 16474, 62360, 38665, 40, 9983, 6551, 47708, 25221, 45876, 27891, 25385, 59882, 52820, 13016, 3202, 61776, 59703, 28950, 28017, 63276, 21407, 2337, 39527, 48187, 2159, 48980, 58103, 4254, 27726, 60971, 20706, 42756, 51272, 16430, 54601, 4305, 25750, 62908, 50245, 33834, 21924, 2722, 12546, 24017, 51408, 56249, 1077, 22562, 32391, 57880, 649, 61406, 7372, 1085, 47638, 49788, 61121, 35134, 43821, 3, 41277, 52109, 33569, 15802, 19337, 33792, 50972, 9666, 33319, 19410, 39750, 7429, 7781, 45782, 8362, 35346, 8106, 33123, 42180, 45139, 19971, 30664, 53259, 47205, 1341, 32189, 50141, 29515, 8955, 38169, 37610, 46947, 27133, 64983, 28901, 1725, 328, 23172, 44017, 27862, 44551, 17488, 10713, 32161, 2466, 33451, 50635, 9075, 19550, 14609, 64333, 48877, 44996, 52748, 51383, 4794, 58369, 52662, 37652, 31584, 57568, 27736, 4903, 56440, 6008, 34988, 59842, 28693, 29028, 12082, 36191, 9087, 8918, 42153, 35042, 53770, 25012, 1704, 37240, 2271, 21454, 57974, 57484, 18860, 29647, 61356, 64799, 44476, 11342, 7715, 50246, 41740, 35587, 42322, 44003, 36633, 7582, 10202, 29766, 24401, 58396, 45937, 2291, 51585, 28086, 48345, 41896, 23364, 41577, 51549, 38417, 52218, 32217, 57982, 26745, 9043, 27233, 34692, 11732, 35432, 1543, 40595, 19338, 23861, 59042, 58883, 44684, 9290, 17769, 37188, 37106, 38285, 19358, 32826, 39130, 12927, 16650, 44379, 13197, 39210, 35868, 12329, 15186, 45459, 48046, 23299, 19339, 55690, 61968, 53650, 42349, 33424, 8117, 22061, 45080, 12646, 65273, 15532, 40894, 8467, 30846, 12172, 50259, 43049, 25738, 61246, 57244, 22776, 15151, 55940, 26466, 31028, 43409, 6446, 9563, 35439, 58252, 13166, 23853, 37291, 50280, 37238, 59190, 42494, 22103, 44113, 38703, 33998, 47728, 49343, 46110, 14159, 7231, 55445, 17122, 61399, 20366, 63751, 62003, 43972, 16123, 15544, 50186, 58222, 41242, 14532, 28764, 55443, 27091, 10285, 44468, 14427, 19193, 20928, 17175, 17651, 46101, 10811, 43953, 19083, 54065, 8749, 24890, 49992, 57115, 52851, 36007, 1627, 7609, 5034, 58560, 20068, 25363, 58946, 49634, 24184, 8712, 50277, 18655, 13557, 12984, 39313, 28655, 17464, 8778, 14721, 40761, 61611, 23141, 60949, 31444, 50609, 56131, 5106, 25871, 54517, 57461, 26539, 53559, 38622, 36894, 27137, 23461, 53071, 26388, 42564, 25493, 25110, 48651, 17630, 59916, 21462, 18716, 6398, 27048, 35142, 1689, 36036, 9663, 32128, 43213, 48986, 33030, 25268, 29565, 22969, 12307, 40751, 38833, 49761, 26738, 42404, 15243, 10320, 64825, 23912, 48552, 8340, 43067, 27043, 53104, 62082, 20176, 45694, 25024, 24440, 26505, 21384, 65496, 54170, 13197, 43682, 63647, 39473, 29023, 23774, 39274, 6912, 39127, 45843, 62801, 22747, 33219, 13777, 2475, 7303, 23730, 55940, 16350, 19309, 58594, 26180, 52995, 24586, 59955, 28338, 5846, 6587, 9222, 53930, 37234, 29190, 61920, 49182, 4539, 59191, 21921, 39843, 16055, 22700, 40667, 50816, 53198, 63266, 36390, 25724, 9948, 58615, 22213, 62592, 63977, 38667, 50871, 59090, 10757, 61070, 29103, 60539, 31487, 32293, 17394, 64026, 22097, 20442, 56243, 36176, 47850, 24314, 24581, 10801, 46938, 36404, 23127, 9250, 56886, 34730, 56052, 37658, 26531, 56834, 11378, 10059, 43707, 6357, 9892, 50012, 28857, 9682, 46345, 23314, 3182, 9239, 33928, 49170, 58176, 24726, 54046, 37474, 53217, 6994, 59423, 24068, 5701, 35869, 30405, 14074, 25923, 31609, 29297, 45044, 8101, 26330, 47638, 4025, 27964, 45299, 2865, 34906, 11358, 16610, 15552, 29021, 19761, 47258, 64650, 18267, 51043, 16493, 1937, 11199, 55035, 16010, 31098, 9775, 2273, 9168, 53308, 34024, 27477, 375, 44879, 17523, 16447, 14099, 43215, 16990, 17366, 55473, 25764, 38875, 24850, 48745, 20, 59756, 36000, 7502, 64614, 50333, 44068, 45574, 10128, 40064, 22976, 7546, 22656, 44224, 22866, 30079, 25591, 43183, 46295, 28187, 55149, 24400, 58946, 16192, 60527, 59467, 19730, 1898, 47950, 11312, 40397, 25589, 31528, 33268, 52999, 52800, 51529, 25492, 33729, 47941, 63320, 21147, 35182, 41177, 9519, 47550, 454, 34674, 10499, 7674, 59235, 43008, 19545, 30677, 62466, 56726, 61029, 19743, 1183, 24153, 60905, 17152, 54712, 54541, 39947, 25413, 617, 40763, 23544, 53197, 56163, 39807, 1944, 12904, 171, 42957, 12898, 27075, 8244, 7774, 4655, 15947, 24716, 41866, 39239, 26041, 63411, 45823, 44347, 54762, 60318, 23166, 52893, 58522, 56450, 45655, 43631, 22695, 7482, 28502, 25174, 10186, 27583, 9291, 14496, 64519, 25269, 34208, 53384, 11254, 3877, 55992, 52186, 52233, 4104, 25190, 54417, 10647, 726, 15667, 53783, 18848, 40282, 27511, 26127, 16495, 51773, 16740, 34400, 21902, 19031, 62115, 27764, 37492, 175, 24586, 24524, 28931, 1267, 61497, 35610, 3491, 11413, 2460, 64949, 28277, 53412, 5433, 5951, 27798, 21984, 43860, 37379, 36395, 16802, 21941, 62736, 7931, 61181, 21662, 54102, 54368, 2273, 15355, 32331, 16489, 35550, 12229, 8157, 63751, 33200, 3586, 14912, 53292, 2917, 63367, 43491, 60566, 50020, 38761, 16753, 29849, 50819, 21397, 14873, 27670, 17666, 21619, 53702, 35148, 30176, 3586, 38469, 13932, 3026, 13625, 10986, 52292, 26250, 45905, 36575, 10992, 43402, 28050, 22225, 12324, 20497, 35795, 60643, 28179, 42140, 44159, 54928, 35028, 11006, 27306, 8562, 14996, 15496, 32024, 63194, 37232, 35450, 47851, 4242, 41878, 327, 26887, 8323, 23391, 64220, 42776, 52103, 49537, 12759, 43976, 39126, 1132, 30381, 39048, 31854, 23117, 29025, 22157, 39476, 12013, 11022, 8308, 46402, 15764, 9382, 13126, 34385, 1477, 43902, 40443, 24947, 38546, 54376, 42566, 33448, 24072, 26521, 50739, 34268, 56498, 31973, 40954, 4587, 26267, 59410, 46666, 3277, 33547, 8624, 12959, 17679, 10123, 26080, 63524, 55475, 23302, 18263, 33389, 35496, 42073, 7194, 64665, 39168, 51896, 4399, 26601, 25366, 27272, 33120, 26441, 58274, 42995, 1195, 60943, 58273, 9548, 6617, 7170, 42441, 60691, 46487, 18738, 54416, 43970, 25075, 26560, 58401, 59123, 26361, 46731, 15024, 55702, 44407, 5228, 6414, 50047, 41864, 10803, 56591, 52537, 36994, 26076, 46216, 31808, 16137, 27110, 60194, 41742, 9754, 1134, 31686, 49685, 38338, 21326, 50914, 46494, 17331, 14622, 5815, 47916, 4197, 41184, 61103, 20303, 36372, 33753, 18622, 2832, 51089, 53648, 35853, 2341, 36609, 30524, 51820, 11867, 32786, 20262, 21257, 36707, 24942, 400, 54975, 65249, 60371, 12796, 12512, 62928, 24160, 44518, 29264, 33740, 14466, 56186, 51627, 2855, 56841, 2559, 21189, 27044, 49091, 63388, 64202, 59105, 5643, 12691, 40997, 5896, 39614, 56974, 46542, 33902, 37079, 21066, 6356, 47785, 4276, 54491, 64957, 24838, 35449, 54290, 62882, 2636, 4267, 30044, 30732, 36417, 11008, 11638, 8927, 42403, 28026, 25858, 8863, 28124, 34170, 20771, 1983, 32174, 33549, 24025, 9876, 1277, 65201, 34398, 1504, 32425, 5213, 25942, 62878, 54770, 42584, 195, 2791, 64547, 20236, 35888, 63579, 10786, 33981, 61163, 29647, 55993, 37559, 28421, 47060, 27719, 25475, 30989, 58776, 62394, 52690, 1129, 37679, 19548, 64815, 36620, 32394, 44833, 7991, 4463, 2242, 53269, 49465, 48860, 27604, 5633, 17129, 59187, 24019, 52300, 43524, 23346, 60576, 23193, 2104, 5053, 10421, 62870, 868, 60376, 36918, 4780, 2556, 15776, 21903, 59524, 25691, 5313, 13256, 21563, 54809, 44232, 31314, 59827, 64568, 62703, 43523, 25438, 1055, 55133, 13557, 48592, 34562, 26300, 33531, 17706, 13068, 4843, 35020, 37366, 19128, 64732, 26115, 20754, 65001, 33521, 25237, 46103, 60665, 2584, 32282, 35472, 3666, 40240, 23814, 3379, 2608, 18729, 6149, 33964, 52894, 27653, 2062, 50245, 12718, 1508, 5062, 14917, 65445, 18493, 44420, 39880, 47027, 25830, 21510, 50672, 212, 62709, 40569, 24958, 61434, 37481, 55487, 60033, 36932, 47318, 6027, 27544, 57386, 44542, 5754, 8857, 31708, 23002, 62694, 22501, 21688, 11634, 63302, 2769, 22809, 14830, 63142, 48207, 12827, 36964, 5795, 37253, 16431, 9939, 61443, 37044, 39256, 916, 17971, 50049, 2150, 50957, 18656, 28653, 30434, 37948, 27274, 44184, 63065, 41433, 38198, 21035, 63088, 29714, 36888, 27156, 51706, 34396, 23078, 45189, 9252, 21592, 59008, 46371, 33165, 38630, 24931, 19140, 24158, 19490, 6178, 41520, 44564, 63237, 64839, 30020, 7797, 41826, 53884, 31448, 6520, 8496, 50145, 8247, 24680, 44417, 44298, 37100, 4131, 5362, 14974, 18651, 34662, 42116, 40744, 55559, 17955, 47863, 2416, 12499, 20713, 22011, 29724, 17664, 28400, 60445, 15444, 58777, 26692, 59756, 43840, 29026, 12643, 37025, 57992, 63230, 34096, 49788, 40053, 42910, 12931, 1311, 46132, 52989, 34428, 1158, 53595, 54165, 27366, 13663, 20689, 31378, 1531, 35414, 21045, 26812, 51370, 47477, 4524, 47548, 27492, 55798, 55328, 28155, 21296, 7484, 64240, 4374, 52147, 1632, 18109, 30188, 23244, 26528, 42021, 29939, 62936, 17315, 11145, 64460, 5810, 56263, 55489, 6546, 55009, 35966, 2191, 18742, 32821, 1661, 65224, 26431, 21604, 32128, 64592, 44191, 6786, 1088, 14738, 29371, 45921, 24179, 26232, 60579, 19156, 46367, 8264, 58191, 12520, 46274, 33344, 40085, 39677, 31170, 65199, 1982, 24643, 32760, 44471, 39814, 40446, 21775, 51726, 61996, 47950, 23462, 17732, 42671, 48476, 7510, 61227, 44364, 57910, 64819, 3628, 45750, 266, 43363, 12469, 29774, 25494, 59729, 51401, 50345, 63170, 2626, 22578, 64944, 24697, 33908, 47394, 4315, 33128, 6985, 41289, 29168, 96, 53813, 48317, 60869, 17495, 59657, 37533, 31262, 35144, 44504, 27174, 37446, 6426, 39048, 57698, 8647, 58416, 18262, 22733, 11827, 898, 33132, 42547, 42693, 54467, 19644, 60035, 15521, 59772, 12835, 33505, 16944, 47231, 14537, 56307, 16217, 21023, 17850, 53949, 8399, 41045, 20692, 38944, 55836, 25593, 31646, 55118, 49561, 43201, 30530, 28213, 65099, 1380, 54664, 41494, 20178, 31775, 11681, 64018, 39457, 62468, 17586, 46600, 1933, 64847, 33685, 37933, 43549, 50678, 29945, 59096, 59557, 34905, 10316, 40036, 32689, 36436, 21464, 21672, 53598, 31832, 247, 57100, 61423, 28373, 6976, 17337, 59306, 46043, 31142, 28039, 28358, 24049, 15510, 17634, 23405, 482, 23256, 47833, 30200, 24700, 18534, 700, 59027, 49579, 5119, 27900, 3311, 9261, 29241, 24754, 37825, 11109, 36746, 45810, 17313, 14315, 22, 22998, 36633, 22723, 20238, 12433, 34114, 34814, 55353, 5156, 14027, 61774, 49628, 44005, 53656, 45812, 32533, 35460, 20262, 42209, 31120, 525, 12778, 15074, 62699, 20008, 62233, 5735, 26418, 23417, 8944, 48545, 49244, 21499, 56951, 6968, 6418, 26973, 59851, 12368, 13759, 1035, 53738, 41798, 13140, 35177, 20505, 60538, 44095, 22356, 54308, 48672, 27687, 32965, 57138, 64365, 11645, 33285, 57098, 2523, 20103, 16348, 4001, 55750, 28868, 3102, 33740, 22009, 57806, 11586, 35705, 57868, 10658, 14980, 45759, 33164, 341, 22767, 13378, 34552, 30758, 8365, 62018, 39313, 23684, 47470, 14318, 19229, 38190, 55654, 53547, 50706, 49451, 17671, 16562, 25157, 61291, 55184, 53692, 63148, 1622, 1098, 38767, 25306, 14839, 60653, 46989, 12650, 65099, 51978, 880, 43545, 51121, 64676, 50540, 37441, 44769, 6849, 13660, 46958, 55360, 41778, 44472, 11880, 59186, 57273, 17668, 58121, 43120, 29956, 62341, 33267, 23951, 9175, 1165, 24689, 51260, 61816, 31289, 25235, 25975, 29626, 36658, 52060, 16755, 19104, 58444, 8075, 1465, 29495, 34956, 41327, 64786, 5058, 36921, 57522, 10313, 22464, 50678, 41871, 54299, 36445, 59131, 35101, 32515, 44926, 61905, 60358, 63394, 50431, 33586, 1676, 41410, 22053, 33500, 5359, 38127, 2641, 2469, 11612, 36858, 24681, 14212, 59538, 11081, 45034, 53578, 25039, 10683, 36583, 62928, 39224, 54479, 20224, 44500, 45512, 43544, 42437, 10463, 12526, 42824, 47214, 5885, 61146, 49962, 63613, 25037, 10846, 12066, 37256, 12102, 25744, 20331, 40400, 41272, 15793, 6721, 12730, 15879, 17475, 15017, 26461, 37445, 50440, 8829, 57308, 48587, 56692, 15668, 47440, 2704, 53082, 13006, 3295, 11179, 5792, 40660, 51832, 24100, 35658, 19389, 18326, 27128, 60141, 41693, 25789, 41625, 50971, 33205, 43138, 22578, 22049, 20989, 23826, 50272, 34278, 37501, 36682, 51312, 6768, 49567, 48849, 52895, 26885, 13514, 57301, 29642, 26693, 63670, 46874, 33837, 50738, 17060, 20788, 12820, 57623, 15449, 755, 24604, 41755, 17186, 455, 39072, 41919, 14901, 18760, 55665, 53350, 30933, 62849, 38671, 6680, 31311, 53247, 24763, 15342, 58170, 48985, 51062, 50168, 434, 48948, 9157, 30311, 18762, 9440, 46436, 40489, 56986, 34361, 17864, 61830, 61559, 2453, 45456, 4172, 17024, 13664, 47763, 36679, 29951, 40069, 974, 1440, 3505, 23938, 4294, 47445, 50745, 51233, 10335, 18807, 43603, 4185, 51317, 61666, 37280, 15705, 281, 51121, 45602, 12208, 60520, 41093, 57770, 58172, 25539, 28870, 32649, 3050, 59685, 51725, 39993, 52577, 21147, 21231, 49347, 12067, 32241, 35312, 53388, 26762, 8376, 44821, 59188, 374, 10737, 22260, 31763, 35405, 10870, 59967, 62901, 47549, 49974, 17279, 33102, 12080, 13495, 62151, 53962, 49104, 16542, 22529, 17417, 5910, 18961, 48184, 18571, 53714, 1089, 34595, 7780, 34700, 46111, 1264, 23304, 35516, 32977, 31708, 24677, 25228, 17064, 15684, 26324, 24724, 42062, 30083, 18853, 35658, 4395, 32903, 17039, 21788, 51132, 36086 };
10.554422
81
0.428422
[ "vector" ]
1970cbc2027e4eb6e186658fddcca402c7fe18fd
26,888
h
C
synth1/Source/FilterExtern/pluginconstants.h
mathias-dietrich/flipotronics
6ebdba70448df09ab7a29a4a75ab1fc01138a85f
[ "Apache-2.0" ]
null
null
null
synth1/Source/FilterExtern/pluginconstants.h
mathias-dietrich/flipotronics
6ebdba70448df09ab7a29a4a75ab1fc01138a85f
[ "Apache-2.0" ]
null
null
null
synth1/Source/FilterExtern/pluginconstants.h
mathias-dietrich/flipotronics
6ebdba70448df09ab7a29a4a75ab1fc01138a85f
[ "Apache-2.0" ]
null
null
null
#pragma once // turn off non-critical warnings #pragma warning(disable : 4244)//double to float #pragma warning(disable : 4996)//strncpy #pragma warning(disable : 4305)//double float truncation #pragma warning(disable : 4018)//signed/unsigned mismatch #pragma warning(disable : 4800)//signed/unsigned mismatch // includes for the project #include <stdio.h> #include <stdlib.h> #include <string.h> // this #define enables the following constants form math.h #define _MATH_DEFINES_DEFINED /* #define M_E 2.71828182845904523536 #define M_LOG2E 1.44269504088896340736 #define M_LOG10E 0.434294481903251827651 #define M_LN2 0.693147180559945309417 #define M_LN10 2.30258509299404568402 #define M_PI 3.14159265358979323846 #define M_PI_2 1.57079632679489661923 #define M_PI_4 0.785398163397448309616 #define M_1_PI 0.318309886183790671538 #define M_2_PI 0.636619772367581343076 #define M_2_SQRTPI 1.12837916709551257390 #define M_SQRT2 1.41421356237309504880 #define M_SQRT1_2 0.707106781186547524401 */ #include <math.h> // For WIN vs MacOS // XCode requires these be defined for compatibility #if defined _WINDOWS || defined _WINDLL #include <windows.h> #else // MacOS typedef unsigned int UINT; typedef unsigned long DWORD; typedef unsigned char UCHAR; typedef unsigned char BYTE; #endif // More #defines for MacOS/XCode /* #ifndef max #define max(a,b) (((a) > (b)) ? (a) : (b)) #endif #ifndef min #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif */ #if defined _WINDOWS || defined _WINDLL #if (_MSC_VER <= 1700) // vs2012 and earlier #ifndef fmax #define fmax(a,b) (((a) > (b)) ? (a) : (b)) #endif #ifndef fmin #define fmin(a,b) (((a) < (b)) ? (a) : (b)) #endif #endif #else #ifndef fmax #define fmax(a,b) (((a) > (b)) ? (a) : (b)) #endif #ifndef fmin #define fmin(a,b) (((a) < (b)) ? (a) : (b)) #endif #endif #ifndef itoa #define itoa(value,string,radix) sprintf(string, "%d", value) #endif #ifndef ltoa #define ltoa(value,string,radix) sprintf(string, "%u", value) #endif // a few more constants from student suggestions #define pi 3.1415926535897932384626433832795 #define sqrt2over2 0.707106781186547524401 // same as M_SQRT1_2 // constants for dealing with overflow or underflow #define FLT_EPSILON_PLUS 1.192092896e-07 /* smallest such that 1.0+FLT_EPSILON != 1.0 */ #define FLT_EPSILON_MINUS -1.192092896e-07 /* smallest such that 1.0-FLT_EPSILON != 1.0 */ #define FLT_MIN_PLUS 1.175494351e-38 /* min positive value */ #define FLT_MIN_MINUS -1.175494351e-38 /* min negative value */ const UINT CURRENT_PLUGIN_API = 61; const UINT CONTROL_THEME_SIZE = 32; const UINT PLUGIN_CONTROL_THEME_SIZE = 64; const UINT CONTROL_THEME = 0; const UINT PRESET_COUNT = 16; // more than 16 in VST gets sluggish depending on the client // custom messages #define SEND_STATUS_WND_MESSAGE WM_USER + 3000 #define UPDATE_SLIDER_CONTROL WM_USER + 3001 #define SEND_EDIT_CTRL_STRING WM_USER + 3002 #define SEND_SLIDER_CTRL_VALUE WM_USER + 3004 #define SEND_RADIO_CHECK WM_USER + 3005 #define SEND_ASGN_BUTTON_CLICK WM_USER + 3006 #define SEND_UPDATE_GUI WM_USER + 3007 #define SEND_JSPROG_BUTTON_CLICK WM_USER + 3008 const UINT MAX_JS_PROGRAM_STEPS = 16; const UINT MAX_JS_PROGRAM_STEP_VARS = 7; const UINT JS_PROGRAM_CHANGE = 0xFFFFFFFF; // helper for the 2-Dimensional Joystick Program array #define JS_PROG_INDEX(x,y) ((x)+(MAX_JS_PROGRAM_STEPS*(y))) // basic enums enum {intData, floatData, doubleData, UINTData, nonData}; enum {JS_ONESHOT, JS_LOOP, JS_SUSTAIN, JS_LOOP_BACKANDFORTH}; // SHARED with Client App - do not remove! #ifndef CLIENT_APP const UINT FILTER_CONTROL_CONTINUOUSLY_VARIABLE = 100; const UINT FILTER_CONTROL_DIRECT_DATA_ENTRY = 101; const UINT FILTER_CONTROL_RADIO_SWITCH_VARIABLE = 102; const UINT FILTER_CONTROL_LED_METER = 103; // RackAFX custom LED meters 5/23/11 const UINT FILTER_CONTROL_COMBO_VARIABLE = 104; // my own Joystick 7/30/11 const UINT DETECT_MODE_PEAK = 0; const UINT DETECT_MODE_MS = 1; const UINT DETECT_MODE_RMS = 2; const UINT DETECT_MODE_NONE = 3; /* Function: lagrpol() implements n-order Lagrange Interpolation Inputs: double* x Pointer to an array containing the x-coordinates of the input values double* y Pointer to an array containing the y-coordinates of the input values int n The order of the interpolator, this is also the length of the x,y input arrays double xbar The x-coorinates whose y-value we want to interpolate Returns The interpolated value y at xbar. xbar ideally is between the middle two values in the input array, but can be anywhere within the limits, which is needed for interpolating the first few or last few samples in a table with a fixed size. */ inline double lagrpol(double* x, double* y, int n, double xbar) { int i,j; double fx=0.0; double l=1.0; for (i=0; i<n; i++) { l=1.0; for (j=0; j<n; j++) { if (j != i) l *= (xbar-x[j])/(x[i]-x[j]); } fx += l*y[i]; } return (fx); } inline float dLinTerp(float x1, float x2, float y1, float y2, float x) { float denom = x2 - x1; if(denom == 0) return y1; // should not ever happen // calculate decimal position of x float dx = (x - x1)/(x2 - x1); // use weighted sum method of interpolating float result = dx*y2 + (1-dx)*y1; return result; } inline bool normalizeBuffer(double* pInputBuffer, UINT uBufferSize) { double fMax = 0; for(UINT j=0; j<uBufferSize; j++) { if((fabs(pInputBuffer[j])) > fMax) fMax = fabs(pInputBuffer[j]); } if(fMax > 0) { for(UINT j=0; j<uBufferSize; j++) pInputBuffer[j] = pInputBuffer[j]/fMax; } return true; } #endif // Helper Functions ------------------------------------------------------------- // // calcLogControl: accepts a float variable from 0.0 to 1.0 // returns a log version from 0.0 to 1.0 /* y = 0.5*log10(x) + 1.0 | 1.0 | * | * | * | * |* |* 0.0 ------------------------ 0.0 1.0 */ inline float calcLogControl(float fVar) { return fVar == 0.0 ? 0.0 : 0.5*log10(fVar) + 1.0; } // ----------------------------------------------------------------------------- // // calcAntiLogControl: accepts a float variable from 0.0 to 1.0 // returns an anti-log version from 0.0 to 1.0 /* y = e^(2x-2) | 1.0 | * | * | * | * | * |* 0.0 ------------------------ 0.0 1.0 */ inline float calcAntiLogControl(float fVar) { return pow(10.0, 2.0*fVar - 2); } // ----------------------------------------------------------------------------- // // calcInverseLogControl:accepts a float variable from 0.0 t0 1.0 // returns an anti-log version from 1.0 to 0.0 /* y = 0.5(1-x) + 1 | 1.0 |* | * | * | * | * | * 0.0 ------------------------ 0.0 1.0 */ inline float calcInverseLogControl(float fVar) { return fVar == 1.0 ? 0.0 : 0.5*log10(1.0 - fVar) + 1.0; } // ----------------------------------------------------------------------------- // // calcInverseAntiLogControl: accepts a float variable from 0.0 t0 1.0 // returns an anti-log version from 1.0 to 0.0 /* y = 10^(-2x) -- this is similar to e^(-5x) but clamps value to 0 at 1 | 1.0 |* |* | * | * | * | * 0.0 ------------------------ 0.0 1.0 */ inline float calcInverseAntiLogControl(float fVar) { return pow((float)10.0, (float)-2.0*fVar); } // ----------------------------------------------------------------------------- // // Helpers for advanced users who make their own GUI inline float calcDisplayVariable(float fMin, float fMax, float fVar) { return (fMax - fMin)*fVar + fMin; } // 0->1 inline float calcSliderVariable(float fMin, float fMax, float fVar) { float fDiff = fMax - fMin; float fCookedData = (fVar - fMin)/fDiff; return fCookedData; } // // String Helpers: these convert to and from strings // // user must delete char array when done! inline char* uintToString(long value) { char* text = new char[33]; ltoa (value, text, 10); return text; } inline UINT stringToUINT(char* p) { return atol (p); } // user must delete char array when done! inline char* intToString(long value) { char* text = new char[33]; itoa (value, text, 10); return text; } inline double stringToDouble(char* p) { return atof (p); } inline double stringToFloat(char* p) { return atof (p); } inline int stringToInt(char* p) { return atol (p); } // user must delete char array when done! inline char* floatToString(float value, int nSigDigits) { char* text = new char[64]; if(nSigDigits > 32) nSigDigits = 32; // gcvt (value, nSigDigits, text); sprintf(text,"%.*f", nSigDigits, value); return text; } // user must delete char array when done! inline char* doubleToString(double value, int nSigDigits) { char* text = new char[64]; if(nSigDigits > 32) nSigDigits = 32; // gcvt (value, nSigDigits, text); sprintf(text,"%.*f", nSigDigits, value); return text; } // user must delete the return char* after use // // This function returns the contatenation of String1 and String2 as a newly created // correctly sized string. // // example: // char* p = addStrings("this", " and that"): // // results in p = "this and that" // // example, when called from your DLL you can use your getMyDLLDirectory() method: // char* p = addStrings(getMyDLLDirectory(),"\\test\\this.wav"); <-- note the double \\ // // this returns a char* that is the Path to the file: this.wav // located in the folder: test // which is located: inside the Directory containing your PlugIn inline char* addStrings(char* pString1, char* pString2) { int n = strlen(pString1); int m = strlen(pString2); char* p = new char[n+m+1]; strcpy(p, pString1); return strncat(p, pString2, m); } // Helpers for separating control and data information // advanced use only, see website for details inline int extractControlID(char* p) { // find : char * pColon; pColon = strchr(p,':'); if(!pColon) return -1; // no more DWORD dEndIndex = strlen(p) - strlen(pColon); char* pID = new char[dEndIndex+1]; memset(pID,0,dEndIndex); strncpy(pID, p, dEndIndex); pID[dEndIndex] = '\0'; int n = stringToInt(pID); delete [] pID; return n; } inline double extractControlValue(char* p) { // find : char * pColon; pColon = strchr(p,':'); if(!pColon) return -1; // no more DWORD dEndIndex = strlen(pColon); char* pVal = new char[dEndIndex+1]; memset(pVal,0,dEndIndex); strncpy(pVal, pColon+1, dEndIndex); pVal[dEndIndex] = '\0'; //delete [] pVal; //return 0; double d = stringToDouble(pVal); delete [] pVal; return d; } // END Helper Functions --------------------------------------------------------- // // RackAFX Built-In Objects for use in Plug-Ins; see book for details // // // Note about Helper Objects: DO NOT MODIFY THESE OBJECTS. If you need to do so, // create a derived class and modify it. These objects may be updated from time to // time so they need to be left alone. // // The Object Implementations are found in PluginObjects.cpp // // --- CEnvelopeDetector --- // // http://www.musicdsp.org/archive.php?classid=0#205 // const float DIGITAL_TC = -2.0; // log(1%) const float ANALOG_TC = -0.43533393574791066201247090699309; // (log(36.7%) const float METER_UPDATE_INTERVAL_MSEC = 15.0; const float METER_MIN_DB = -60.0; class CEnvelopeDetector { public: CEnvelopeDetector(void); ~CEnvelopeDetector(void); public: // Call the Init Function to initialize and setup all at once; this can be called as many times // as you want void init(float samplerate, float attack_in_ms, float release_in_ms, bool bAnalogTC, UINT uDetect, bool bLogDetector); // these functions allow you to change modes and attack/release one at a time during // realtime operation void setTCModeAnalog(bool bAnalogTC); // {m_bAnalogTC = bAnalogTC;} // THEN do these after init void setAttackTime(float attack_in_ms); void setReleaseTime(float release_in_ms); // Use these "codes" // DETECT PEAK = 0 // DETECT MS = 1 // DETECT RMS = 2 // void setDetectMode(UINT uDetect) {m_uDetectMode = uDetect;} void setSampleRate(float f) {m_fSampleRate = f;} void setLogDetect(bool b) {m_bLogDetector = b;} // call this to detect; it returns the peak ms or rms value at that instant float detect(float fInput); // call this from your prepareForPlay() function each time to reset the detector void prepareForPlay(); protected: int m_nSample; float m_fAttackTime; float m_fReleaseTime; float m_fAttackTime_mSec; float m_fReleaseTime_mSec; float m_fSampleRate; float m_fEnvelope; UINT m_uDetectMode; bool m_bAnalogTC; bool m_bLogDetector; }; // --- BiQuad --- // This class can be used alone or as the base class for a derived object // Note the virtual destructor, required for proper clean-up of derived // classes // // Implements a single Bi-Quad Structure class CBiQuad { public: CBiQuad(void); virtual ~CBiQuad(void); protected: float m_f_Xz_1; // x z-1 delay element float m_f_Xz_2; // x z-2 delay element float m_f_Yz_1; // y z-1 delay element float m_f_Yz_2; // y z-2 delay element // allow other objects to set these directly since we have no cooking // function or intelligence public: float m_f_a0; float m_f_a1; float m_f_a2; float m_f_b1; float m_f_b2; // flush Delays void flushDelays() { m_f_Xz_1 = 0; m_f_Xz_2 = 0; m_f_Yz_1 = 0; m_f_Yz_2 = 0; } // Do the filter: given input xn, calculate output yn and return it float doBiQuad(float f_xn) { // just do the difference equation: y(n) = a0x(n) + a1x(n-1) + a2x(n-2) - b1y(n-1) - b2y(n-2) float yn = m_f_a0*f_xn + m_f_a1*m_f_Xz_1 + m_f_a2*m_f_Xz_2 - m_f_b1*m_f_Yz_1 - m_f_b2*m_f_Yz_2; // underflow check if(yn > 0.0 && yn < FLT_MIN_PLUS) yn = 0; if(yn < 0.0 && yn > FLT_MIN_MINUS) yn = 0; // shuffle delays // Y delays m_f_Yz_2 = m_f_Yz_1; m_f_Yz_1 = yn; // X delays m_f_Xz_2 = m_f_Xz_1; m_f_Xz_1 = f_xn; return yn; } }; // --- CJoystickProgram --- class CJoystickProgram { public: // Functions // // (1) Initialize here: CJoystickProgram(float* pJSProgramTable, UINT uMode); // One Time Destruction ~CJoystickProgram(void); void startProgram(); void pauseProgram(){m_bRunning = false;} void resumeProgram(){m_bRunning = true;} void reset(){m_uSampleCount = 0; m_bRunning = false; m_bDirInc = true; m_fTimerDurationMSec = 0; m_nCurrentProgramStep = 0;} void setJSMode(UINT uMode); int getCurrentStep(){return m_nCurrentProgramStep;} // (2) Set the sample rate in prepareForPlay() void setSampleRate(int nSampleRate); // (3) call this once per sample period void incTimer(); // (4) get the current vector mix ratios void getVectorMixValues(float& fA, float& fB, float& fC, float& fD){fA = m_fA_Mix; fB = m_fB_Mix, fC = m_fC_Mix, fD = m_fD_Mix;} void getVectorACBDMixes(float& fAB, float& fBD){fAB = m_fAC_Mix; fBD = m_fBD_Mix;} protected: UINT m_uSampleCount; UINT m_uJSMode; bool m_bRunning; bool m_bDirInc; float m_fTimerDurationMSec; float m_fSampleRate; int m_nTimerDurationSamples; int m_nCurrentProgramStep; int m_nNumSteps; public: float m_fStartA_Mix; float m_fStartB_Mix; float m_fStartC_Mix; float m_fStartD_Mix; float m_fStartAC_Mix; float m_fStartBD_Mix; float m_fEndA_Mix; float m_fEndB_Mix; float m_fEndC_Mix; float m_fEndD_Mix; float m_fEndAC_Mix; float m_fEndBD_Mix; float m_fA_Mix; float m_fB_Mix; float m_fC_Mix; float m_fD_Mix; float m_fAC_Mix; float m_fBD_Mix; void calculateCurrentVectorMix(); float* m_pJSProgramTable; }; // --- CWaveTable --- // generic WT Oscillator for you to use class CWaveTable { public: // Functions // // One Time Initialization CWaveTable(); // One Time Destruction ~CWaveTable(void); // The Prepare For Play Function is called just before audio streams bool prepareForPlay(); // --- MEMBER FUNCTIONS // function to do render one sample of the Oscillator // call this once per sample period // // pYn is the normal output // pYqn is the quad phase output void doOscillate(float* pYn, float* pYqn); // reset the read index void reset() { m_fReadIndex = 0.0; m_fQuadPhaseReadIndex = 256.0; // 1/4 of our 1024 point buffer } // set the sample rate: NEEDED to calcualte the increment value from frequency void setSampleRate(int nSampleRate) { m_nSampleRate = nSampleRate; } // our cooking function void cookFrequency() { // inc = L*fd/fs m_f_inc = 1024.0*m_fFrequency_Hz/(float)m_nSampleRate; } // --- MEMBER OBJECTS // Array for the Table float m_SinArray[1024]; // 1024 Point Sinusoid float m_SawtoothArray[1024]; // saw float m_TriangleArray[1024]; // tri float m_SquareArray[1024]; // sqr // band limited to 5 partials float m_SawtoothArray_BL5[1024]; // saw, BL = 5 float m_TriangleArray_BL5[1024]; // tri, BL = 5 float m_SquareArray_BL5[1024]; // sqr, BL = 5 // current read location float m_fReadIndex; // NOTE its a FLOAT! float m_fQuadPhaseReadIndex; // NOTE its a FLOAT! // our inc value float m_f_inc; // fs value int m_nSampleRate; // user-controlled variables: // Frequency float m_fFrequency_Hz; // Inverted Output bool m_bInvert; // Type UINT m_uOscType; enum{sine,saw,tri,square}; // Mode UINT m_uTableMode; enum{normal,bandlimit}; // Polarity UINT m_uPolarity; enum{bipolar,unipolar}; }; // // This is a helper object for reading Wave files into floating point buffers. // It is NOT optimized for speed (yet) #if defined _WINDOWS || defined _WINDLL #include <mmsystem.h> // wave file parser class CWaveData { public: // Functions // // One Time Initialization // pFilePath is the FULLY qualified file name + additional path info // VALID Examples: audio.wav // //samples//audio.wav CWaveData(char* pFilePath = NULL); // prompts with file open dialog, returns TRUE if successfuly // opened and parsed the file into the member m_pWaveBuffer bool initWithUserWAVFile(char* pInitDir = NULL); // One Time Destruction ~CWaveData(void); UINT m_uNumChannels; UINT m_uSampleRate; UINT m_uSampleCount; UINT m_uLoopCount; UINT m_uLoopStartIndex; UINT m_uLoopEndIndex; UINT m_uLoopType; UINT m_uMIDINote; UINT m_uMIDIPitchFraction; UINT m_uSMPTEFormat; UINT m_uSMPTEOffset; bool m_bWaveLoaded; // the WAV file converted to floats on range of -1.0 --> +1.0 float* m_pWaveBuffer; protected: bool readWaveFile(char* pFilePath); HANDLE m_hFile; }; #else // MacOS Version here! // wave file parser class CWaveData { public: // Functions // // One Time Initialization // pFilePath is the FULLY qualified file name + additional path info // VALID Examples: audio.wav // //samples//audio.wav CWaveData(char* pFilePath = NULL); // prompts with file open dialog, returns TRUE if successfuly // opened and parsed the file into the member m_pWaveBuffer bool initWithUserWAVFile(char* pInitDir = NULL); // One Time Destruction ~CWaveData(void); UINT m_uNumChannels; UINT m_uSampleRate; UINT m_uSampleCount; UINT m_uLoopCount; UINT m_uLoopStartIndex; UINT m_uLoopEndIndex; UINT m_uLoopType; UINT m_uMIDINote; UINT m_uMIDIPitchFraction; UINT m_uSMPTEFormat; UINT m_uSMPTEOffset; bool m_bWaveLoaded; // the WAV file converted to floats on range of -1.0 --> +1.0 float* m_pWaveBuffer; protected: bool readWaveFile(char* pFilePath); }; #endif // --- CUICtrl --- // // CUICtrl is the C++ obhect that manages your GUI objects // like sliders and buttons. Do not ever edit or change this code as the // objects are shared with the Client and you may break the app. // // enum for VU Colors enum {csVU, csRed, csOrange, csYellow, csGreen, csBlue, csViolet}; class CUICtrl { public: CUICtrl(void); ~CUICtrl(void); CUICtrl(const CUICtrl& initCUICtrl); public: UINT uControlType; UINT uControlId; UINT uDetectorMode; float fUserDisplayDataLoLimit; float fUserDisplayDataHiLimit; UINT uUserDataType; float fInitUserIntValue; float fInitUserFloatValue; float fInitUserDoubleValue; float fInitUserUINTValue; // FOR VST PRESETS ONLY! float fUserCookedIntData; float fUserCookedFloatData; float fUserCookedDoubleData; float fUserCookedUINTData; int* m_pUserCookedIntData; float* m_pUserCookedFloatData; double* m_pUserCookedDoubleData; UINT* m_pUserCookedUINTData; float* m_pCurrentMeterValue; char* cControlName; char* cControlUnits; char* cVariableName; char* cEnumeratedList; char* cMeterVariableName; char cName[1024]; char cUnits[1024]; char cVName[1024]; char cMeterVName[1024]; char cVEnumeratedList[1024]; bool bOwnerControl; bool bUseMeter; bool bUpsideDownMeter; bool bLogMeter; bool bLogSlider; bool bExpSlider; UINT uMeterColorScheme; float fMeterAttack_ms; float fMeterRelease_ms; bool bMIDIControl; UINT uMIDIControlCommand; // pitchbend or CC UINT uMIDIControlName; // eg Continuous Controller #3 UINT uMIDIControlChannel; // eg Continuous Controller #3 int nGUIRow; int nGUIColumn; UINT uControlTheme[CONTROL_THEME_SIZE]; double dPresetData[PRESET_COUNT]; UINT uFluxCapControl[PLUGIN_CONTROL_THEME_SIZE]; float fFluxCapData[PLUGIN_CONTROL_THEME_SIZE]; void* pvAddlData; // ---------------------------------------------------------------------------------------- public: CUICtrl& operator=(const CUICtrl& aCUICtrl) // need this override for collections to work { if(this == &aCUICtrl) return *this; this->uControlType = aCUICtrl.uControlType; this->uControlId = aCUICtrl.uControlId; this->bOwnerControl = aCUICtrl.bOwnerControl; this->bUseMeter = aCUICtrl.bUseMeter; this->bUpsideDownMeter = aCUICtrl.bUpsideDownMeter; this->uDetectorMode = aCUICtrl.uDetectorMode; this->bLogMeter = aCUICtrl.bLogMeter; this->bLogSlider = aCUICtrl.bLogSlider; this->bExpSlider = aCUICtrl.bExpSlider; this->uMeterColorScheme = aCUICtrl.uMeterColorScheme; this->fMeterAttack_ms = aCUICtrl.fMeterAttack_ms; this->fMeterRelease_ms = aCUICtrl.fMeterRelease_ms; this->fUserDisplayDataLoLimit = aCUICtrl.fUserDisplayDataLoLimit; this->fUserDisplayDataHiLimit = aCUICtrl.fUserDisplayDataHiLimit; this->uUserDataType = aCUICtrl.uUserDataType; this->fInitUserIntValue = aCUICtrl.fInitUserIntValue; this->fInitUserFloatValue = aCUICtrl.fInitUserFloatValue; this->fInitUserDoubleValue = aCUICtrl.fInitUserDoubleValue; this->fInitUserUINTValue = aCUICtrl.fInitUserUINTValue; // VST PRESETS ONLY this->fUserCookedIntData = aCUICtrl.fUserCookedIntData; this->fUserCookedFloatData = aCUICtrl.fInitUserFloatValue; this->fUserCookedDoubleData = aCUICtrl.fUserCookedDoubleData; this->fUserCookedUINTData = aCUICtrl.fUserCookedUINTData; this->m_pUserCookedIntData = aCUICtrl.m_pUserCookedIntData; this->m_pUserCookedFloatData = aCUICtrl.m_pUserCookedFloatData; this->m_pUserCookedDoubleData = aCUICtrl.m_pUserCookedDoubleData; this->m_pUserCookedUINTData = aCUICtrl.m_pUserCookedUINTData; this->m_pCurrentMeterValue = aCUICtrl.m_pCurrentMeterValue; this->bMIDIControl = aCUICtrl.bMIDIControl; this->uMIDIControlCommand = aCUICtrl.uMIDIControlCommand; this->uMIDIControlName = aCUICtrl.uMIDIControlName; this->uMIDIControlChannel = aCUICtrl.uMIDIControlChannel; this->nGUIRow = aCUICtrl.nGUIRow; this->nGUIColumn = aCUICtrl.nGUIColumn; this->pvAddlData = aCUICtrl.pvAddlData; for(int i=0; i<PRESET_COUNT; i++) { this->dPresetData[i] = aCUICtrl.dPresetData[i]; } for(int i=0; i<CONTROL_THEME_SIZE; i++) { this->uControlTheme[i] = aCUICtrl.uControlTheme[i]; } for(int i=0; i<PLUGIN_CONTROL_THEME_SIZE; i++) { this->uFluxCapControl[i] = aCUICtrl.uFluxCapControl[i]; } for(int i=0; i<PLUGIN_CONTROL_THEME_SIZE; i++) { this->fFluxCapData[i] = aCUICtrl.fFluxCapData[i]; } cControlName = &cName[0]; cControlUnits = &cUnits[0]; cVariableName = &cVName[0]; cMeterVariableName = &cMeterVName[0]; cEnumeratedList = &cVEnumeratedList[0]; strncpy(this->cControlName, aCUICtrl.cControlName, 1023); cControlName[1023] = '\0'; strncpy(this->cControlUnits, aCUICtrl.cControlUnits, 1023); cControlUnits[1023] = '\0'; strncpy(this->cVariableName, aCUICtrl.cVariableName, 1023); cVariableName[1023] = '\0'; strncpy(this->cEnumeratedList, aCUICtrl.cEnumeratedList, 1023); cEnumeratedList[1023] = '\0'; strncpy(this->cMeterVariableName, aCUICtrl.cMeterVariableName, 1023); cMeterVariableName[1023] = '\0'; return *this; } }; // -- CUIControlList -- // This is the linked list of control objects const UINT uMaxVSTProgramNameLen = 24; class CUIControlList { private: struct node { CUICtrl data; node *link; }*p; public: CUIControlList(); void append( CUICtrl data); void add_as_first( CUICtrl data ); void addafter( int c, CUICtrl data); void update(CUICtrl data); void del( CUICtrl data); void display(); int count(); int countLegalVSTIF(); int countLegalCustomVSTGUI(); CUICtrl* getAt(int nIndex); // for VST preset storage char name[uMaxVSTProgramNameLen+1]; ~CUIControlList(); CUIControlList& operator=(CUIControlList& aCUICtrlList) // need this override for collections to work { if(this == &aCUICtrlList) return *this; strncpy(this->name, aCUICtrlList.name, uMaxVSTProgramNameLen); name[uMaxVSTProgramNameLen] = '\0'; int nCount = aCUICtrlList.count(); for(int j=0; j<nCount; j++) { CUICtrl* p = aCUICtrlList.getAt(j); CUICtrl* pClone = new CUICtrl(*p); this->append(*pClone); } return *this; } };
25.92864
130
0.659811
[ "render", "object", "vector" ]
1971b47573fad7e20d6b3a61f55951ac953cba4f
1,485
h
C
include/webservice/in_memory_index_search.h
FreshDISKANN/FreshDISKANN
c7750ed7ae2df202b3f3a98477199963245c8ba7
[ "MIT" ]
6
2020-10-13T11:30:53.000Z
2021-12-03T15:50:15.000Z
include/webservice/in_memory_index_search.h
FreshDISKANN/FreshDISKANN
c7750ed7ae2df202b3f3a98477199963245c8ba7
[ "MIT" ]
null
null
null
include/webservice/in_memory_index_search.h
FreshDISKANN/FreshDISKANN
c7750ed7ae2df202b3f3a98477199963245c8ba7
[ "MIT" ]
3
2020-10-13T11:30:55.000Z
2021-12-02T14:29:42.000Z
#pragma once #include <string> #include <vector> #include <distance.h> #include <index.h> #include <cosine_similarity.h> namespace diskann { class IndexSearchResult { public: IndexSearchResult(unsigned int k, unsigned int elapsedTimeInMs) : K(k), searchTimeInMs(elapsedTimeInMs) { finalResults.reserve(k); } void addResult(const std::wstring& result) { finalResults.push_back(result); } unsigned int K; unsigned int searchTimeInMs; std::vector<unsigned int> finalResultIndices; // TEMPORARY FOR RECALL. std::vector<std::wstring> finalResults; std::vector<float> distances; }; class InMemoryIndexSearch { public: InMemoryIndexSearch(const char* baseFile, const char* indexFile, const char* idsFile, Metric m); virtual IndexSearchResult search(const float* query, const unsigned int dimensions, const unsigned int K); virtual ~InMemoryIndexSearch(); static void load_data(const char* filename, float*& data, unsigned& num, unsigned& dim); static std::vector<std::wstring> load_ids(const char* idsFile); private: float* _baseVectors; unsigned int _dimensions, _numPoints; std::vector<std::wstring> _ids; std::unique_ptr<diskann::Index<float>> _nsgIndex; }; } // namespace diskann
28.557692
76
0.618855
[ "vector" ]
1977415d3337791c6e650b472918a24c8d3bae82
5,282
h
C
sys/src/cmd/gs/opdef.h
Plan9-Archive/plan9-2e
ce6d0434246216e848babe4f56919dc28981ad04
[ "MIT" ]
1
2021-03-23T22:40:43.000Z
2021-03-23T22:40:43.000Z
sys/src/cmd/gs/opdef.h
Plan9-Archive/plan9-2e
ce6d0434246216e848babe4f56919dc28981ad04
[ "MIT" ]
null
null
null
sys/src/cmd/gs/opdef.h
Plan9-Archive/plan9-2e
ce6d0434246216e848babe4f56919dc28981ad04
[ "MIT" ]
1
2021-12-21T06:19:58.000Z
2021-12-21T06:19:58.000Z
/* Copyright (C) 1991, 1992, 1994 Aladdin Enterprises. All rights reserved. This file is part of Aladdin Ghostscript. Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or distributor accepts any responsibility for the consequences of using it, or for whether it serves any particular purpose or works at all, unless he or she says so in writing. Refer to the Aladdin Ghostscript Free Public License (the "License") for full details. Every copy of Aladdin Ghostscript must include a copy of the License, normally in a plain ASCII text file named PUBLIC. The License grants you the right to copy, modify and redistribute Aladdin Ghostscript, but only under certain conditions described in the License. Among other things, the License requires that the copyright notice and this notice be preserved on all copies. */ /* opdef.h */ /* Operator definition interface for Ghostscript */ /* * Operator procedures take the pointer to the top of the o-stack * as their argument. They return 0 for success, a negative code * for an error, or a positive code for some uncommon situations (see below). */ /* Structure for initializing the operator table. */ /* * Each operator file declares an array of these, of the following kind: BEGIN_OP_DEFS(my_defs) { {"1name", zname}, ... END_OP_DEFS(iproc) } * where iproc is an initialization procedure for the file, or 0. * This definition always appears at the END of the file, * to avoid the need for forward declarations for all the * operator procedures. * * Operators may be stored in dictionaries other than systemdict. * We support this with op_def entries of a special form: op_def_begin_dict("dictname"), */ typedef struct { const char _ds *oname; op_proc_p proc; } op_def; typedef const op_def *op_def_ptr; #define op_def_begin_dict(dname) {dname, 0} #define op_def_begin_filter() op_def_begin_dict("filterdict") #define op_def_begin_level2() op_def_begin_dict("level2dict") #define op_def_is_begin_dict(def) ((def)->proc == 0) #define op_def_end(iproc) {(char _ds *)0, (op_proc_p)iproc} /* * We need to define each op_defs table as a procedure that returns * the actual table, because of cross-segment linking restrictions * in the Borland C compiler for MS Windows. */ #define BEGIN_OP_DEFS(xx_op_defs)\ const op_def *xx_op_defs(P0())\ { static const far_data op_def op_defs_[] = #define END_OP_DEFS(iproc)\ op_def_end(iproc)\ };\ return op_defs_; /* * Internal operators whose names begin with %, such as continuation * operators, do not appear in systemdict. Ghostscript assumes * that these operators cannot appear anywhere (in executable form) * except on the e-stack; to maintain this invariant, the execstack * operator converts them to literal form, and cvx refuses to convert * them back. As a result of this invariant, they do not need to * push themselves back on the e-stack when executed, since the only * place they could have come from was the e-stack. */ #define op_def_is_internal(def) ((def)->oname[1] == '%') /* * All operators are catalogued in a table, primarily so * that they can have a convenient packed representation. * The `size' of an operator is normally its index in this table; * however, internal operators have a `size' of 0, and their true index * must be found by searching the table for their procedure address. */ ushort op_find_index(P1(const ref *)); #define op_index(opref)\ (r_size(opref) == 0 ? op_find_index(opref) : r_size(opref)) /* * There are actually two kinds of operators: the real ones (t_operator), * and ones defined by procedures (t_oparray). The catalog for t_operators * is op_def_table, and their index is in the range [1..op_def_count). */ #define op_index_is_operator(index) ((index) < op_def_count) /* * Because of a bug in Sun's SC1.0 compiler, * we have to spell out the typedef for op_def_ptr here: */ extern const op_def **op_def_table; extern uint op_def_count; #define op_num_args(opref) (op_def_table[op_index(opref)]->oname[0] - '0') #define op_index_proc(index) (op_def_table[index]->proc) /* * The catalog for t_oparrays is op_array_table, and their index is in * the range [op_def_count..op_def_count+op_array_count). The actual * index in op_array_table is the operator index minus op_def_count. */ extern ref op_array_table; /* t_array */ extern ushort *op_array_nx_table; extern uint op_array_count; /* * The procedure defining a t_oparray operator may be in any VM space. * Note that it is OK to store a local t_oparray operator into a global object * if the operator was defined when the save level was zero, because * restore cannot free local objects defined in this situation. * We support this with a .makeglobaloperator operator that defines * a local procedure as a global operator (if permitted). We keep track of * this in a separate op_array_attrs_table. */ extern byte *op_array_attrs_table; #define op_index_oparray_ref(index,pref)\ (r_set_type_attrs(pref, t_oparray, op_array_attrs_table[(index) - op_def_count]),\ r_set_size(pref, index)) #define op_index_ref(index,pref)\ (op_index_is_operator(index) ?\ make_oper(pref, index, op_index_proc(index)) :\ op_index_oparray_ref(index, pref))
39.125926
85
0.751231
[ "object" ]
1986ca01d10356f21c654d1a88290248dc7836fe
3,606
h
C
src/operators/LineSampler/avtLineSamplerFilter.h
visit-dav/vis
c08bc6e538ecd7d30ddc6399ec3022b9e062127e
[ "BSD-3-Clause" ]
226
2018-12-29T01:13:49.000Z
2022-03-30T19:16:31.000Z
src/operators/LineSampler/avtLineSamplerFilter.h
visit-dav/vis
c08bc6e538ecd7d30ddc6399ec3022b9e062127e
[ "BSD-3-Clause" ]
5,100
2019-01-14T18:19:25.000Z
2022-03-31T23:08:36.000Z
src/operators/LineSampler/avtLineSamplerFilter.h
visit-dav/vis
c08bc6e538ecd7d30ddc6399ec3022b9e062127e
[ "BSD-3-Clause" ]
84
2019-01-24T17:41:50.000Z
2022-03-10T10:01:46.000Z
// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt // Project developers. See the top-level LICENSE file for dates and other // details. No copyright assignment is required to contribute to VisIt. // ************************************************************************* // // File: avtLineSamplerFilter.h // ************************************************************************* // #ifndef AVT_LineSampler_FILTER_H #define AVT_LineSampler_FILTER_H //#include <avtPluginDataTreeIterator.h> #include <avtPluginFilter.h> #include <avtTimeLoopFilter.h> #include <avtDatasetToDatasetFilter.h> #include <avtVector.h> #include <avtExtents.h> #include <LineSamplerAttributes.h> class vtkTransform; class vtkDataSet; class vtkPolyData; class vtkUnstructuredGrid; // **************************************************************************** // Class: avtLineSamplerFilter // // Purpose: // A plugin operator for LineSampler. // // Programmer: allen -- generated by xml2avt // Creation: Thu Oct 14 15:05:33 PST 2010 // // **************************************************************************** class avtLineSamplerFilter : virtual public avtPluginFilter, virtual public avtTimeLoopFilter, virtual public avtDatasetToDatasetFilter { public: avtLineSamplerFilter(); virtual ~avtLineSamplerFilter(); static avtFilter *Create(); virtual const char *GetType(void) { return "avtLineSamplerFilter"; }; virtual const char *GetDescription(void) { return "LineSampler"; }; virtual void SetAtts(const AttributeGroup*); virtual bool Equivalent(const AttributeGroup*); protected: LineSamplerAttributes atts; virtual void InitializeTimeLoop(void); virtual void ExamineContract(avtContract_p in_contract); virtual void Execute(void); virtual void CreateFinalOutput(void); virtual bool ExecutionSuccessful(void); virtual vtkDataSet* ExecuteChannelData(vtkDataSet *, int, std::string); // virtual vtkDataSet* ExecuteChannelList(vtkDataSet *, int, std::string); virtual vtkPolyData* createPoint( avtVector startPoint, avtVector stopPoint, bool allocateScalars ); virtual vtkPolyData* createLine( avtVector startPoint, avtVector stopPoint, bool allocateScalars ); virtual vtkDataSet* createCone( avtVector startPoint, avtVector stopPoint, avtVector normal, double radius, double divergence, bool allocateScalars ); avtVector ProjectPointOnPlane( avtVector planePoint, avtVector planeNormal, avtVector point, avtVector direction ); void applyTransform( vtkTransform* transform, avtVector &point ); void checkBounds( vtkDataSet *in_ds, avtVector &startPoint, avtVector &stopPoint ); unsigned int checkWall( avtVector &startPoint, avtVector &stopPoint ); std::vector< std::vector< std::pair< avtVector, float > > > lineSamples; vtkDataSet *composite_ds; int nTimeSteps; double cachedAngle; bool validTimeAxis; double lastTimeAxisValue; }; #endif
33.388889
79
0.56711
[ "vector", "transform" ]
198babda8391da160917b75f2b11337431ac99e1
23,689
c
C
src/acvp_kdf_tls13.c
livebe01/libacvp
7ae24850caa06cefcd370771825f9365bf36bd6b
[ "BSD-2-Clause", "Apache-2.0" ]
45
2016-08-01T11:47:34.000Z
2022-02-22T21:27:27.000Z
src/acvp_kdf_tls13.c
livebe01/libacvp
7ae24850caa06cefcd370771825f9365bf36bd6b
[ "BSD-2-Clause", "Apache-2.0" ]
221
2016-08-04T17:10:36.000Z
2022-01-21T19:53:36.000Z
src/acvp_kdf_tls13.c
livebe01/libacvp
7ae24850caa06cefcd370771825f9365bf36bd6b
[ "BSD-2-Clause", "Apache-2.0" ]
94
2016-10-23T11:08:19.000Z
2022-01-21T11:50:16.000Z
/** @file */ /* * Copyright (c) 2019, Cisco Systems, Inc. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://github.com/cisco/libacvp/LICENSE */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include "acvp.h" #include "acvp_lcl.h" #include "parson.h" #include "safe_lib.h" /* * Forward prototypes for local functions */ static ACVP_RESULT acvp_kdf_tls13_output_tc(ACVP_CTX *ctx, ACVP_KDF_TLS13_TC *stc, JSON_Object *tc_rsp); static ACVP_RESULT acvp_kdf_tls13_init_tc(ACVP_CTX *ctx, ACVP_KDF_TLS13_TC *stc, unsigned int tc_id, ACVP_CIPHER alg_id, ACVP_KDF_TLS13_TESTTYPE type, ACVP_KDF_TLS13_RUN_MODE run_mode, ACVP_HASH_ALG hmac, const char *psk, const char *dhe, const char *sh_rnd, const char *ch_rnd, const char *s_fin_rnd, const char *c_fin_rnd); static ACVP_RESULT acvp_kdf_tls13_release_tc(ACVP_KDF_TLS13_TC *stc); static ACVP_KDF_TLS13_RUN_MODE read_run_mode(const char *str) { int diff = 0; strcmp_s(ACVP_STR_KDF_TLS13_PSK, sizeof(ACVP_STR_KDF_TLS13_PSK) -1, str, &diff); if (!diff) return ACVP_KDF_TLS13_RUN_MODE_PSK; strcmp_s(ACVP_STR_KDF_TLS13_DHE, sizeof(ACVP_STR_KDF_TLS13_DHE) -1, str, &diff); if (!diff) return ACVP_KDF_TLS13_RUN_MODE_DHE; strcmp_s(ACVP_STR_KDF_TLS13_PSK_DHE, sizeof(ACVP_STR_KDF_TLS13_PSK_DHE) -1, str, &diff); if (!diff) return ACVP_KDF_TLS13_RUN_MODE_PSK_DHE; return 0; } static ACVP_KDF_TLS13_TESTTYPE read_test_type(const char *str) { int diff = 1; strcmp_s("AFT", 3, str, &diff); if (!diff) return ACVP_KDF_TLS13_TEST_TYPE_AFT; return 0; } ACVP_RESULT acvp_kdf_tls13_kat_handler(ACVP_CTX *ctx, JSON_Object *obj) { unsigned int tc_id; JSON_Value *groupval; JSON_Object *groupobj = NULL; JSON_Value *testval; JSON_Object *testobj = NULL; JSON_Array *groups; JSON_Array *tests; JSON_Value *reg_arry_val = NULL; JSON_Object *reg_obj = NULL; JSON_Array *reg_arry = NULL; int i, g_cnt; int j, t_cnt; JSON_Value *r_vs_val = NULL; JSON_Object *r_vs = NULL; JSON_Array *r_tarr = NULL, *r_garr = NULL; /* Response testarray, grouparray */ JSON_Value *r_tval = NULL, *r_gval = NULL; /* Response testval, groupval */ JSON_Object *r_tobj = NULL, *r_gobj = NULL; /* Response testobj, groupobj */ ACVP_CAPS_LIST *cap; ACVP_KDF_TLS13_TC stc; ACVP_TEST_CASE tc; ACVP_RESULT rv; const char *alg_str = json_object_get_string(obj, "algorithm"); const char *mode_str = NULL; const char *hmac_str = NULL; const char *run_str = NULL; const char *type_str = NULL; ACVP_CIPHER alg_id; ACVP_KDF_TLS13_TESTTYPE type = 0; ACVP_HASH_ALG hmac = 0; ACVP_KDF_TLS13_RUN_MODE runmode = 0; char *json_result; if (!ctx) { ACVP_LOG_ERR("No ctx for handler operation"); return ACVP_NO_CTX; } if (!alg_str) { ACVP_LOG_ERR("unable to parse 'algorithm' from JSON"); return ACVP_MALFORMED_JSON; } mode_str = json_object_get_string(obj, "mode"); if (!mode_str) { ACVP_LOG_ERR("unable to parse 'mode' from JSON"); return ACVP_MALFORMED_JSON; } alg_id = acvp_lookup_cipher_w_mode_index(alg_str, mode_str); if (alg_id != ACVP_KDF_TLS13) { ACVP_LOG_ERR("Server JSON invalid 'algorithm' or 'mode'"); return ACVP_INVALID_ARG; } /* * Get a reference to the abstracted test case */ tc.tc.kdf_tls13 = &stc; cap = acvp_locate_cap_entry(ctx, alg_id); if (!cap) { ACVP_LOG_ERR("ACVP server requesting unsupported capability"); return ACVP_UNSUPPORTED_OP; } /* * Create ACVP array for response */ rv = acvp_create_array(&reg_obj, &reg_arry_val, &reg_arry); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("Failed to create JSON response struct. "); return rv; } /* * Start to build the JSON response */ rv = acvp_setup_json_rsp_group(&ctx, &reg_arry_val, &r_vs_val, &r_vs, alg_str, &r_garr); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("Failed to setup json response"); goto err; } groups = json_object_get_array(obj, "testGroups"); g_cnt = json_array_get_count(groups); for (i = 0; i < g_cnt; i++) { int tgId = 0; groupval = json_array_get_value(groups, i); groupobj = json_value_get_object(groupval); /* * Create a new group in the response with the tgid * and an array of tests */ r_gval = json_value_init_object(); r_gobj = json_value_get_object(r_gval); tgId = json_object_get_number(groupobj, "tgId"); if (!tgId) { ACVP_LOG_ERR("Missing tgid from server JSON groub obj"); rv = ACVP_MALFORMED_JSON; goto err; } json_object_set_number(r_gobj, "tgId", tgId); json_object_set_value(r_gobj, "tests", json_value_init_array()); r_tarr = json_object_get_array(r_gobj, "tests"); type_str = json_object_get_string(groupobj, "testType"); if (!type_str) { ACVP_LOG_ERR("Missing testType from server JSON group obj"); rv = ACVP_MISSING_ARG; goto err; } type = read_test_type(type_str); if (!type) { ACVP_LOG_ERR("Invalid testType from server JSON group obj"); rv = ACVP_MALFORMED_JSON; goto err; } hmac_str = json_object_get_string(groupobj, "hmacAlg"); if (!hmac_str) { ACVP_LOG_ERR("Missing hmacAlg from server JSON group obj"); rv = ACVP_MISSING_ARG; goto err; } hmac = acvp_lookup_hash_alg(hmac_str); if (!hmac) { ACVP_LOG_ERR("Invalid hmacAlg from server JSON group obj"); rv = ACVP_MALFORMED_JSON; goto err; } run_str = json_object_get_string(groupobj, "runningMode"); if (!run_str) { ACVP_LOG_ERR("Missing runningMode from server JSON group obj"); rv = ACVP_MISSING_ARG; goto err; } runmode = read_run_mode(run_str); if (!runmode) { ACVP_LOG_ERR("Invalid runningMode from server JSON group obj"); rv = ACVP_MALFORMED_JSON; goto err; } ACVP_LOG_VERBOSE(" Test group: %d", i); ACVP_LOG_VERBOSE(" hmacAlg: %s", hmac_str); ACVP_LOG_VERBOSE(" runningMode: %s", run_str); tests = json_object_get_array(groupobj, "tests"); t_cnt = json_array_get_count(tests); for (j = 0; j < t_cnt; j++) { const char *psk = NULL; const char *dhe = NULL; const char *sh_rnd = NULL; const char *ch_rnd = NULL; const char *s_fin_rnd = NULL; const char *c_fin_rnd = NULL; ACVP_LOG_VERBOSE("Found new TLS 1.3 test vector..."); testval = json_array_get_value(tests, j); testobj = json_value_get_object(testval); tc_id = json_object_get_number(testobj, "tcId"); if (!tc_id) { ACVP_LOG_ERR("Server json missing 'tcId"); rv = ACVP_MISSING_ARG; goto err; } if (runmode == ACVP_KDF_TLS13_RUN_MODE_PSK || runmode == ACVP_KDF_TLS13_RUN_MODE_PSK_DHE) { psk = json_object_get_string(testobj, "psk"); if (!psk) { ACVP_LOG_ERR("Server json missing 'psk'"); rv = ACVP_MISSING_ARG; goto err; } } if (runmode == ACVP_KDF_TLS13_RUN_MODE_DHE || runmode == ACVP_KDF_TLS13_RUN_MODE_PSK_DHE) { dhe = json_object_get_string(testobj, "dhe"); if (!dhe) { ACVP_LOG_ERR("Server json missing 'dhe'"); rv = ACVP_MISSING_ARG; goto err; } } sh_rnd = json_object_get_string(testobj, "helloServerRandom"); if (!sh_rnd) { ACVP_LOG_ERR("Failed to include helloServeroRandom"); rv = ACVP_MISSING_ARG; goto err; } ch_rnd = json_object_get_string(testobj, "helloClientRandom"); if (!ch_rnd) { ACVP_LOG_ERR("Failed to include helloClientoRandom"); rv = ACVP_MISSING_ARG; goto err; } s_fin_rnd = json_object_get_string(testobj, "finishedServerRandom"); if (!s_fin_rnd) { ACVP_LOG_ERR("Failed to include finishedServerRandom"); rv = ACVP_MISSING_ARG; goto err; } c_fin_rnd = json_object_get_string(testobj, "finishedClientRandom"); if (!c_fin_rnd) { ACVP_LOG_ERR("Failed to include finishedClientRandom"); rv = ACVP_MISSING_ARG; goto err; } ACVP_LOG_VERBOSE(" Test case: %d", j); ACVP_LOG_VERBOSE(" tcId: %d", tc_id); if (psk) { ACVP_LOG_VERBOSE(" psk: %s", psk); } if (dhe) { ACVP_LOG_VERBOSE(" dhe: %s", dhe); } ACVP_LOG_VERBOSE(" serverHelloRand: %s", sh_rnd); ACVP_LOG_VERBOSE(" clientHelloRand: %s", ch_rnd); ACVP_LOG_VERBOSE(" serverFinRand: %s", s_fin_rnd); ACVP_LOG_VERBOSE(" clientFinRand: %s", c_fin_rnd); /* * Create a new test case in the response */ r_tval = json_value_init_object(); r_tobj = json_value_get_object(r_tval); json_object_set_number(r_tobj, "tcId", tc_id); /* * Setup the test case data that will be passed down to * the crypto module. */ rv = acvp_kdf_tls13_init_tc(ctx, &stc, tc_id, alg_id, type, runmode, hmac, psk, dhe, sh_rnd, ch_rnd, s_fin_rnd, c_fin_rnd); if (rv != ACVP_SUCCESS) { acvp_kdf_tls13_release_tc(&stc); json_value_free(r_tval); goto err; } /* Process the current test vector... */ if ((cap->crypto_handler)(&tc)) { ACVP_LOG_ERR("crypto module failed the operation"); acvp_kdf_tls13_release_tc(&stc); rv = ACVP_CRYPTO_MODULE_FAIL; json_value_free(r_tval); goto err; } /* * Output the test case results using JSON */ rv = acvp_kdf_tls13_output_tc(ctx, &stc, r_tobj); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("JSON output failure in hash module"); acvp_kdf_tls13_release_tc(&stc); json_value_free(r_tval); goto err; } /* * Release all the memory associated with the test case */ acvp_kdf_tls13_release_tc(&stc); /* Append the test response value to array */ json_array_append_value(r_tarr, r_tval); } json_array_append_value(r_garr, r_gval); } json_array_append_value(reg_arry, r_vs_val); json_result = json_serialize_to_string_pretty(ctx->kat_resp, NULL); ACVP_LOG_VERBOSE("\n\n%s\n\n", json_result); json_free_serialized_string(json_result); rv = ACVP_SUCCESS; err: if (rv != ACVP_SUCCESS) { acvp_release_json(r_vs_val, r_gval); } return rv; } /* * After the test case has been processed by the DUT, the results * need to be JSON formated to be included in the vector set results * file that will be uploaded to the server. This routine handles * the JSON processing for a single test case. */ static ACVP_RESULT acvp_kdf_tls13_output_tc(ACVP_CTX *ctx, ACVP_KDF_TLS13_TC *stc, JSON_Object *tc_rsp) { char *tmp = NULL; ACVP_RESULT rv = ACVP_SUCCESS; tmp = calloc(1, ACVP_KDF_TLS13_DATA_LEN_STR_MAX + 1); if (!tmp) { ACVP_LOG_ERR("Unable to malloc in acvp_kdf_tls13_output_tc"); return ACVP_MALLOC_FAIL; } //append client early traffic secret if (stc->cets_len > ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX) { ACVP_LOG_ERR("Provided length for test case output too long: cets_len"); rv = ACVP_INVALID_ARG; goto err; } rv = acvp_bin_to_hexstr(stc->c_early_traffic_secret, stc->cets_len, tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("hex conversion failure (client early traffic secret)"); goto err; } json_object_set_string(tc_rsp, "clientEarlyTrafficSecret", tmp); memzero_s(tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); //append early export master secret if (stc->eems_len > ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX) { ACVP_LOG_ERR("Provided length for test case output too long: eems_len"); rv = ACVP_INVALID_ARG; goto err; } rv = acvp_bin_to_hexstr(stc->early_expt_master_secret, stc->eems_len, tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("hex conversion failure (early export master secret)"); goto err; } json_object_set_string(tc_rsp, "earlyExporterMasterSecret", tmp); memzero_s(tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); //append client handshake traffic secret if (stc->chts_len > ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX) { ACVP_LOG_ERR("Provided length for test case output too long: chts_len"); rv = ACVP_INVALID_ARG; goto err; } rv = acvp_bin_to_hexstr(stc->c_hs_traffic_secret, stc->chts_len, tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("hex conversion failure (client handshake traffic secret)"); goto err; } json_object_set_string(tc_rsp, "clientHandshakeTrafficSecret", tmp); memzero_s(tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); //append server handshake traffic secret if (stc->shts_len > ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX) { ACVP_LOG_ERR("Provided length for test case output too long: shts_len"); rv = ACVP_INVALID_ARG; goto err; } rv = acvp_bin_to_hexstr(stc->s_hs_traffic_secret, stc->shts_len, tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("hex conversion failure (server handshake traffic secret)"); goto err; } json_object_set_string(tc_rsp, "serverHandshakeTrafficSecret", tmp); memzero_s(tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); //append client app traffic secret if (stc->cats_len > ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX) { ACVP_LOG_ERR("Provided length for test case output too long: cats_len"); rv = ACVP_INVALID_ARG; goto err; } rv = acvp_bin_to_hexstr(stc->c_app_traffic_secret, stc->cats_len, tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("hex conversion failure (client app traffic secret)"); goto err; } json_object_set_string(tc_rsp, "clientApplicationTrafficSecret", tmp); memzero_s(tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); //append server app traffic secret if (stc->sats_len > ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX) { ACVP_LOG_ERR("Provided length for test case output too long: sats_len"); rv = ACVP_INVALID_ARG; goto err; } rv = acvp_bin_to_hexstr(stc->s_app_traffic_secret, stc->sats_len, tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("hex conversion failure (server app traffic secret)"); goto err; } json_object_set_string(tc_rsp, "serverApplicationTrafficSecret", tmp); memzero_s(tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); //append exporter master secret if (stc->ems_len > ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX) { ACVP_LOG_ERR("Provided length for test case output too long: ems_len"); rv = ACVP_INVALID_ARG; goto err; } rv = acvp_bin_to_hexstr(stc->expt_master_secret, stc->ems_len, tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("hex conversion failure (exporter master secret)"); goto err; } json_object_set_string(tc_rsp, "exporterMasterSecret", tmp); memzero_s(tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); //append resumption master secret if (stc->rms_len > ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX) { ACVP_LOG_ERR("Provided length for test case output too long: rms_len"); rv = ACVP_INVALID_ARG; goto err; } rv = acvp_bin_to_hexstr(stc->resume_master_secret, stc->rms_len, tmp, ACVP_KDF_TLS13_DATA_LEN_STR_MAX); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("hex conversion failure (resumption master secret)"); goto err; } json_object_set_string(tc_rsp, "resumptionMasterSecret", tmp); err: free(tmp); return rv; } static ACVP_RESULT acvp_kdf_tls13_init_tc(ACVP_CTX *ctx, ACVP_KDF_TLS13_TC *stc, unsigned int tc_id, ACVP_CIPHER alg_id, ACVP_KDF_TLS13_TESTTYPE type, ACVP_KDF_TLS13_RUN_MODE run_mode, ACVP_HASH_ALG hmac, const char *psk, const char *dhe, const char *s_hello_rand, const char *c_hello_rand, const char *fin_s_hello_rand, const char *fin_c_hello_rand) { ACVP_RESULT rv; memzero_s(stc, sizeof(ACVP_KDF_TLS13_TC)); stc->tc_id = tc_id; stc->cipher = alg_id; stc->test_type = type; stc->running_mode = run_mode; stc->hmac_alg = hmac; stc->psk = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->psk) { return ACVP_MALLOC_FAIL; } if (psk) { rv = acvp_hexstr_to_bin(psk, stc->psk, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX, &(stc->psk_len)); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("Hex conversion failure (psk)"); return rv; } } else { //either SHA256 or SHA384 if (hmac == ACVP_SHA256) { stc->psk_len = 32; } else { stc->psk_len = 48; } } stc->dhe = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->dhe) { return ACVP_MALLOC_FAIL; } if (dhe) { rv = acvp_hexstr_to_bin(dhe, stc->dhe, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX, &(stc->dhe_len)); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("Hex conversion failure (s_hello_rand)"); return rv; } } else { //either SHA256 or SHA384 if (hmac == ACVP_SHA256) { stc->dhe_len = 32; } else { stc->dhe_len = 48; } } stc->c_hello_rand = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->c_hello_rand) { return ACVP_MALLOC_FAIL; } rv = acvp_hexstr_to_bin(c_hello_rand, stc->c_hello_rand, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX, &(stc->c_hello_rand_len)); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("Hex conversion failure (c_hello_rand)"); return rv; } stc->s_hello_rand = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->s_hello_rand) { return ACVP_MALLOC_FAIL; } rv = acvp_hexstr_to_bin(s_hello_rand, stc->s_hello_rand, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX, &(stc->s_hello_rand_len)); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("Hex conversion failure (s_hello_rand)"); return rv; } stc->fin_c_hello_rand = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->fin_c_hello_rand) { return ACVP_MALLOC_FAIL; } rv = acvp_hexstr_to_bin(fin_c_hello_rand, stc->fin_c_hello_rand, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX, &(stc->fin_c_hello_rand_len)); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("Hex conversion failure (fin_c_hello_rand)"); return rv; } stc->fin_s_hello_rand = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->fin_s_hello_rand) { return ACVP_MALLOC_FAIL; } rv = acvp_hexstr_to_bin(fin_s_hello_rand, stc->fin_s_hello_rand, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX, &(stc->fin_s_hello_rand_len)); if (rv != ACVP_SUCCESS) { ACVP_LOG_ERR("Hex conversion failure (fin_s_hello_rand)"); return rv; } stc->c_early_traffic_secret = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->c_early_traffic_secret) { return ACVP_MALLOC_FAIL; } stc->early_expt_master_secret = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->early_expt_master_secret) { return ACVP_MALLOC_FAIL; } stc->c_hs_traffic_secret = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->c_hs_traffic_secret) { return ACVP_MALLOC_FAIL; } stc->s_hs_traffic_secret = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->s_hs_traffic_secret) { return ACVP_MALLOC_FAIL; } stc->c_app_traffic_secret = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->c_app_traffic_secret) { return ACVP_MALLOC_FAIL; } stc->s_app_traffic_secret = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->s_app_traffic_secret) { return ACVP_MALLOC_FAIL; } stc->expt_master_secret = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->expt_master_secret) { return ACVP_MALLOC_FAIL; } stc->resume_master_secret = calloc(1, ACVP_KDF_TLS13_DATA_LEN_BYTE_MAX); if (!stc->resume_master_secret) { return ACVP_MALLOC_FAIL; } return ACVP_SUCCESS; } /* * This function simply releases the data associated with * a test case. */ static ACVP_RESULT acvp_kdf_tls13_release_tc(ACVP_KDF_TLS13_TC *stc) { if (stc->psk) free(stc->psk); if (stc->dhe) free(stc->dhe); if (stc->c_hello_rand) free(stc->s_hello_rand); if (stc->s_hello_rand) free(stc->c_hello_rand); if (stc->fin_c_hello_rand) free(stc->fin_c_hello_rand); if (stc->fin_s_hello_rand) free(stc->fin_s_hello_rand); if (stc->c_early_traffic_secret) free(stc->c_early_traffic_secret); if (stc->early_expt_master_secret) free(stc->early_expt_master_secret); if (stc->c_hs_traffic_secret) free(stc->c_hs_traffic_secret); if (stc->s_hs_traffic_secret) free(stc->s_hs_traffic_secret); if (stc->c_app_traffic_secret) free(stc->c_app_traffic_secret); if (stc->s_app_traffic_secret) free(stc->s_app_traffic_secret); if (stc->expt_master_secret) free(stc->expt_master_secret); if (stc->resume_master_secret) free(stc->resume_master_secret); memzero_s(stc, sizeof(ACVP_KDF_TLS13_TC)); return ACVP_SUCCESS; } ;
37.423381
133
0.612267
[ "vector" ]
198dde8312d783399a97a851952162282018cdc1
1,494
h
C
actor-apps/core-async-cocoa/src/im/actor/model/entity/compat/content/ObsoleteVideo.h
DragonStuff/actor-platform
d262e6bb3c18b20eb35551313bce16c471cd2928
[ "MIT" ]
null
null
null
actor-apps/core-async-cocoa/src/im/actor/model/entity/compat/content/ObsoleteVideo.h
DragonStuff/actor-platform
d262e6bb3c18b20eb35551313bce16c471cd2928
[ "MIT" ]
null
null
null
actor-apps/core-async-cocoa/src/im/actor/model/entity/compat/content/ObsoleteVideo.h
DragonStuff/actor-platform
d262e6bb3c18b20eb35551313bce16c471cd2928
[ "MIT" ]
null
null
null
// // Generated by the J2ObjC translator. DO NOT EDIT! // source: /Users/ex3ndr/Develop/actor-platform/actor-apps/core/src/main/java/im/actor/model/entity/compat/content/ObsoleteVideo.java // #ifndef _ImActorModelEntityCompatContentObsoleteVideo_H_ #define _ImActorModelEntityCompatContentObsoleteVideo_H_ #include "J2ObjC_header.h" #include "im/actor/model/entity/compat/content/ObsoleteDocument.h" @class BSBserValues; @class BSBserWriter; @class ImActorModelEntityContentInternalAbsContentContainer; @interface ImActorModelEntityCompatContentObsoleteVideo : ImActorModelEntityCompatContentObsoleteDocument #pragma mark Public - (instancetype)initWithBSBserValues:(BSBserValues *)values; - (jint)getDuration; - (jint)getH; - (jint)getW; - (void)parseWithBSBserValues:(BSBserValues *)values; - (void)serializeWithBSBserWriter:(BSBserWriter *)writer; - (ImActorModelEntityContentInternalAbsContentContainer *)toContainer; @end J2OBJC_EMPTY_STATIC_INIT(ImActorModelEntityCompatContentObsoleteVideo) FOUNDATION_EXPORT void ImActorModelEntityCompatContentObsoleteVideo_initWithBSBserValues_(ImActorModelEntityCompatContentObsoleteVideo *self, BSBserValues *values); FOUNDATION_EXPORT ImActorModelEntityCompatContentObsoleteVideo *new_ImActorModelEntityCompatContentObsoleteVideo_initWithBSBserValues_(BSBserValues *values) NS_RETURNS_RETAINED; J2OBJC_TYPE_LITERAL_HEADER(ImActorModelEntityCompatContentObsoleteVideo) #endif // _ImActorModelEntityCompatContentObsoleteVideo_H_
33.2
177
0.862115
[ "model" ]
1993f31e79f6a111cc5f96333914124eedb09e10
3,326
h
C
src/kernel/src/sched/rwlock.h
GrieferAtWork/KOS
5376a813854b35e3a3532a6e3b8dbb168478b40f
[ "Zlib" ]
2
2017-02-24T17:14:19.000Z
2017-10-12T19:26:13.000Z
src/kernel/src/sched/rwlock.h
GrieferAtWork/KOS
5376a813854b35e3a3532a6e3b8dbb168478b40f
[ "Zlib" ]
1
2019-11-02T10:21:11.000Z
2019-11-02T10:21:11.000Z
src/kernel/src/sched/rwlock.h
GabrielRavier/KOSmk3
5376a813854b35e3a3532a6e3b8dbb168478b40f
[ "Zlib" ]
1
2019-11-02T10:20:19.000Z
2019-11-02T10:20:19.000Z
/* Copyright (c) 2018 Griefer@Work * * * * This software is provided 'as-is', without any express or implied * * warranty. In no event will the authors be held liable for any damages * * arising from the use of this software. * * * * Permission is granted to anyone to use this software for any purpose, * * including commercial applications, and to alter it and redistribute it * * freely, subject to the following restrictions: * * * * 1. The origin of this software must not be misrepresented; you must not * * claim that you wrote the original software. If you use this software * * in a product, an acknowledgement in the product documentation would be * * appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and must not be * * misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source distribution. * */ #ifndef GUARD_KERNEL_SRC_SCHED_RWLOCK_H #define GUARD_KERNEL_SRC_SCHED_RWLOCK_H 1 #define _KOS_SOURCE 1 #include <hybrid/compiler.h> #include <kos/types.h> #include <kernel/sections.h> #include <kernel/heap.h> DECL_BEGIN /* A dummy R/W lock pointer. */ #define READLOCK_DUMMYLOCK ((struct rwlock *)-1) struct read_lock { uintptr_t rl_recursion; /* [valid_if(rl_rwlock != NULL && rl_rwlock != READLOCK_DUMMYLOCK)] * Amount of recursive read-locks held. */ struct rwlock *rl_rwlock; /* [valid_if(!= NULL && != READLOCK_DUMMYLOCK)] Associated R/W-lock. */ }; #define CONFIG_TASK_STATIC_READLOCKS 2 #define RWLOCK_HASH(x) ((uintptr_t)(x) / HEAP_ALIGNMENT) struct read_locks { struct read_lock rls_sbuf[CONFIG_TASK_STATIC_READLOCKS]; size_t rls_use; /* Amount of read-locks in use. */ size_t rls_cnt; /* Amount of non-NULL R/W locks. */ size_t rls_msk; /* Allocated hash-mask of the read-hash-vector. */ struct read_lock *rls_vec; /* [1..rls_msk+1][owned_if(!= rls_sbuf)] * Hash-vector of thread-locally held read-locks. * As hash-index, use `RWLOCK_HASH()' */ }; INTDEF ATTR_PERTASK struct read_locks my_readlocks; /* Find an existing read-lock descriptor for `lock', or return NULL. */ INTDEF ATTR_NOTHROW struct read_lock *KCALL rwlock_find_readlock(struct rwlock *__restrict lock); /* Return a read-lock descriptor for `lock', or allocate a new one. */ INTDEF ATTR_RETNONNULL struct read_lock *KCALL rwlock_get_readlock(struct rwlock *__restrict lock); /* Return a read-lock descriptor for `lock', or allocate a new one. */ INTDEF struct read_lock *KCALL rwlock_get_readlock_nothrow(struct rwlock *__restrict lock); /* Delete the given rlock. */ INTDEF void KCALL rwlock_delete_readlock(struct read_lock *__restrict rlock); DECL_END #endif /* !GUARD_KERNEL_SRC_SCHED_RWLOCK_H */
45.561644
104
0.614251
[ "vector" ]
19949f6851c36bfece74387b99f76fb4965be034
3,242
h
C
middleware/common/include/common/communication/stream.h
casualcore/casual
047a4eaabbba52ad3ce63dc698a9325ad5fcec6d
[ "MIT" ]
null
null
null
middleware/common/include/common/communication/stream.h
casualcore/casual
047a4eaabbba52ad3ce63dc698a9325ad5fcec6d
[ "MIT" ]
null
null
null
middleware/common/include/common/communication/stream.h
casualcore/casual
047a4eaabbba52ad3ce63dc698a9325ad5fcec6d
[ "MIT" ]
1
2022-02-21T18:30:25.000Z
2022-02-21T18:30:25.000Z
//! //! Copyright (c) 2020, The casual project //! //! This software is licensed under the MIT license, https://opensource.org/licenses/MIT //! #pragma once #include "common/communication/tcp/message.h" #include "common/communication/device.h" #include "common/serialize/native/network.h" #include <iosfwd> namespace casual { namespace common::communication::stream { // Forwards namespace inbound { struct Connector; } // inbound namespace outbound { struct Connector; } // inbound namespace message { using Header = communication::tcp::message::Header; namespace header { using namespace communication::tcp::message::header; } // header //! TODO: stream probably needs it's own complete struct Complete : communication::tcp::message::Complete { using communication::tcp::message::Complete::Complete; }; } // message namespace policy { using complete_type = message::Complete; using cache_type = std::vector< complete_type>; using cache_range_type = range::type_t< cache_type>; struct Blocking { cache_range_type receive( inbound::Connector& connector, cache_type& cache); strong::correlation::id send( outbound::Connector& connector, complete_type&& complete); }; namespace non { struct Blocking { cache_range_type receive( inbound::Connector& connector, cache_type& cache); }; } // non } // policy namespace outbound { struct Connector { using blocking_policy = policy::Blocking; using complete_type = policy::complete_type; inline Connector( std::ostream& out) : m_out{ &out} {} inline std::ostream& stream() { return *m_out;} CASUAL_LOG_SERIALIZE( CASUAL_SERIALIZE_NAME( m_out, "out"); ) private: std::ostream* m_out; }; using Device = communication::device::Outbound< Connector>; } // outbound namespace inbound { struct Connector { using blocking_policy = policy::Blocking; using non_blocking_policy = policy::non::Blocking; using cache_type = policy::cache_type; inline Connector( std::istream& in) : m_in{ &in} {} inline std::istream& stream() { return *m_in;} CASUAL_LOG_SERIALIZE( CASUAL_SERIALIZE_NAME( m_in, "in"); ) private: std::istream* m_in; }; using Device = communication::device::Inbound< Connector>; } // outbound } // common::communication::stream namespace common::serialize::native::customization { template<> struct point< communication::stream::message::Complete> { using writer = binary::network::create::Writer; using reader = binary::network::create::Reader; }; } // common::serialize::native::customization } // casual
25.328125
100
0.568168
[ "vector" ]
199898acf6ed87b4a559f27126b99db4f36a154a
3,752
h
C
engine/Dalbaragi/physics/d_collider.h
SausageTaste/Little-Ruler
f6fb2f28948519981e063a33e978b2f8310d8181
[ "MIT" ]
24
2019-05-25T07:43:09.000Z
2022-03-16T17:37:32.000Z
engine/Dalbaragi/physics/d_collider.h
SausageTaste/Little-Ruler
f6fb2f28948519981e063a33e978b2f8310d8181
[ "MIT" ]
5
2019-10-14T08:57:55.000Z
2020-07-28T14:52:12.000Z
engine/Dalbaragi/physics/d_collider.h
SausageTaste/Little-Ruler
f6fb2f28948519981e063a33e978b2f8310d8181
[ "MIT" ]
null
null
null
#pragma once #include <array> #include <vector> #include <variant> #include <optional> #include <functional> #include <glm/glm.hpp> #include <glm/gtc/quaternion.hpp> #include <d_geometrymath.h> #include <d_transform.h> // Structs namespace dal { class PhysicalProperty { private: float m_massInv = 0.0f; public: void setMassInv(const float v) noexcept { this->m_massInv = v; } float getMassInv(void) const noexcept { return this->m_massInv; } }; } // For polymorphism namespace dal { enum class ColliderType { sphere = 0, aabb, triangle_soup, eoe }; class ICollider { private: ColliderType m_type; protected: ICollider(const ColliderType type); public: virtual ~ICollider(void) = default; ColliderType getColType(void) const noexcept; }; } // Polymorphic colliders namespace dal { class ColSphere : public Sphere, public ICollider { public: ColSphere(void) : ICollider(ColliderType::sphere) { } ColSphere(const glm::vec3& center, const float radius) : Sphere(center, radius) , ICollider(ColliderType::sphere) { } ColSphere(const Sphere& sphere) : Sphere(sphere) , ICollider(ColliderType::sphere) { } }; class ColAABB : public AABB, public ICollider { public: ColAABB(void) : ICollider(ColliderType::aabb) { } ColAABB(const glm::vec3& p1, const glm::vec3& p2) : AABB(p1, p2) , ICollider(ColliderType::aabb) { } ColAABB(const AABB& aabb) : AABB(aabb) , ICollider(ColliderType::aabb) { } }; } // Complex colliders namespace dal { class ColTriangleSoup : public ICollider, public dal::TriangleSoup { public: ColTriangleSoup(void) : ICollider(ColliderType::triangle_soup) { } }; } // checkCollision funcs namespace dal { bool checkCollisionAbs(const ICollider& one, const ICollider& two, const Transform& transOne, const Transform& transTwo); bool checkCollisionAbs(const Segment& seg, const ICollider& col, const Transform& transCol); } // calcResolveInfo funcs namespace dal { CollisionResolveInfo calcResolveInfoABS( const ICollider& one, const PhysicalProperty& physicsOne, const Transform& transOne, const ICollider& two, const PhysicalProperty& physicsTwo, const Transform& transTwo ); //CollisionResolveInfo calcResolveInfo(const AABB& one, const AABB& other, const PhysicalProperty& physicsOne, const PhysicalProperty& physicsTwo); CollisionResolveInfo calcResolveInfo( const AABB& one, const PhysicalProperty& physicsOne, const Transform& transOne, const AABB& two, const PhysicalProperty& physicsTwo, const Transform& transTwo ); CollisionResolveInfo calcResolveInfo(const AABB& aabb, const PhysicalProperty& physicsOne, const Transform& transOne, const dal::ColTriangleSoup& soup, const PhysicalProperty& physicsTwo, const Transform& transTwo); } // Resolve AABB namespace dal { static glm::vec3 resolveAABB_abs(const dal::MovingAABBInfo& aabb, const dal::ICollider& other, const dal::Transform& trans); } // calcCollisionInfo funcs namespace dal { std::optional<RayCastingResult> calcCollisionInfoAbs(const Segment& ray, const ICollider& col, const Transform& transCol); std::optional<RayCastingResult> calcCollisionInfo(const Segment& ray, const ColTriangleSoup triSoup, const Transform& transTriSoup); }
20.960894
151
0.646055
[ "vector", "transform" ]
19a634e537d074f8f019761ba3b158671a3542ef
1,076
h
C
TheTruth/TheTruth.h
pv42/the-truth-plugin
03043f31801f70a92ba410cdfd33efc07c5088e6
[ "MIT" ]
null
null
null
TheTruth/TheTruth.h
pv42/the-truth-plugin
03043f31801f70a92ba410cdfd33efc07c5088e6
[ "MIT" ]
null
null
null
TheTruth/TheTruth.h
pv42/the-truth-plugin
03043f31801f70a92ba410cdfd33efc07c5088e6
[ "MIT" ]
null
null
null
#pragma once #include <memory> #include "arcdps.h" #include "MumbleApi.h" #include "Settings.h" #include "SheetsAPI.h" class TheTruth { public: TheTruth(); static std::unique_ptr<TheTruth> theTruth; static arcdps_exports* s_init(); static uintptr_t s_release(); static uintptr_t s_imgui(uint32_t not_charsel_or_loading); static void s_uiOptions(); static uintptr_t s_window_nofilter(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); uintptr_t WindowNFCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); arcdps_exports* Init(); uintptr_t Release(); void ImGui(uint32_t not_charsel_or_loading); void UIOptions(); private: void drawSettingsUI(); void drawBigUI(int currentWing); void drawSmallUI(int wing, vector<string>& roles); MumbleApi mumbleApi; shared_ptr<SheetsAPI> sheetsAPI; Settings settings; arcdps_exports arc_exports; bool showSetting; bool showBigUI; bool showSmallUI; bool io_shiftDown; bool io_altDown; static bool crashed; // if an uncaught exception is encountered at top level try to disable this plugin at top level };
28.315789
117
0.77974
[ "vector" ]
19ae2aa4475bff6c17d0d2449e6e8ac6ed21bb88
1,093
h
C
osh-sdk/sdk/includes.h
RahimxD/osh_sdk
cd4cabcf8ada8e48a6109bd207aac32c81b5ee2e
[ "MIT" ]
1
2021-07-04T19:49:13.000Z
2021-07-04T19:49:13.000Z
osh-sdk/sdk/includes.h
RahimxD/osh_sdk
cd4cabcf8ada8e48a6109bd207aac32c81b5ee2e
[ "MIT" ]
null
null
null
osh-sdk/sdk/includes.h
RahimxD/osh_sdk
cd4cabcf8ada8e48a6109bd207aac32c81b5ee2e
[ "MIT" ]
2
2021-01-20T21:17:35.000Z
2022-03-12T08:18:43.000Z
#pragma once #pragma warning( disable : 4307 ) // warning C4307: '*': integral constant overflow #pragma warning( disable : 4244 ) // warning C4244: '=': conversion possible loss of data using ulong_t = unsigned long; #define WIN32_LEAN_AND_MEAN #define NOCOMM #include <windows.h> #include <intrin.h> #include <cstdint> #include <string> #include <stdio.h> #include <array> #include <vector> #include <map> #include <memory> #include <sstream> #include <fstream> #include <iostream> #include <iomanip> #include <cctype> #include <random> #include <thread> #include <chrono> // Direct X #include <d3d9.h> #include <d3dx9.h> #pragma comment( lib, "d3d9.lib" ) #pragma comment( lib, "d3dx9.lib" ) // oshgui. #include "../../oshgui/OSHGui.hpp" #include "../../oshgui/Drawing/Direct3D9/Direct3D9Renderer.hpp" #include "../../oshgui/Drawing/RenderTarget.hpp" #include "../../oshgui/Input/Input.hpp" #include "../renderer/renderer.h" #include "../utils/pattern.h" using namespace renderer; extern c_renderer g_renderer; using OSHColor = OSHGui::Drawing::Color; #include "../hooks/hooks.h"
21.86
89
0.712717
[ "vector" ]
19af6f3c754e97d1fb70b2024724ca9d3478e768
4,168
h
C
analyzer/store/bigtable_store.h
reMarkable/cobalt
3feead337a6bdf620df7a62abb72c910a566a38c
[ "BSD-3-Clause" ]
null
null
null
analyzer/store/bigtable_store.h
reMarkable/cobalt
3feead337a6bdf620df7a62abb72c910a566a38c
[ "BSD-3-Clause" ]
null
null
null
analyzer/store/bigtable_store.h
reMarkable/cobalt
3feead337a6bdf620df7a62abb72c910a566a38c
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2017 The Fuchsia Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef COBALT_ANALYZER_STORE_BIGTABLE_STORE_H_ #define COBALT_ANALYZER_STORE_BIGTABLE_STORE_H_ #include <google/bigtable/admin/v2/bigtable_table_admin.grpc.pb.h> #include <google/bigtable/v2/bigtable.grpc.pb.h> #include <grpc++/grpc++.h> #include <map> #include <memory> #include <string> #include <vector> #include "analyzer/store/data_store.h" namespace cobalt { namespace analyzer { namespace store { // An implementation of DataStore backed by Google Cloud Bigtable class BigtableStore : public DataStore { public: // Creates and returns an instance of BigtableStore using the well-known // URI of Google Cloud Bigtable, credentials for for the Cobalt service // account read from the file named in the environment variable // GOOGLE_APPLICATION_CREDENTIALS, and the project and instance // names read from flags. static std::unique_ptr<BigtableStore> CreateFromFlagsOrDie(); BigtableStore(const std::string& uri, const std::string& admin_uri, std::shared_ptr<grpc::ChannelCredentials> credentials, const std::string& project_name, const std::string& instance_id); Status WriteRow(Table table, DataStore::Row row) override; Status WriteRows(Table table, std::vector<Row> rows) override; Status ReadRow(Table table, const std::vector<std::string>& column_names, Row* row) override; ReadResponse ReadRows(Table table, std::string start_row_key, bool inclusive, std::string limit_row_key, const std::vector<std::string>& column_names, size_t max_rows) override; Status DeleteRow(Table table, std::string row_key) override; Status DeleteRowsWithPrefix(Table table, std::string row_key_prefix) override; Status DeleteAllRows(Table table) override; private: std::string TableName(DataStore::Table table); // DoWriteRows does the work of WriteRows(). WriteRows() invokes DoWriteRows() // in a loop, retrying with exponential backoff when a retryable error occurs. grpc::Status DoWriteRows(Table table, const std::vector<Row>& rows); // This method invokes ReadRowsInternal() multiple times until it succeeds, // returns a non-retryable error, or exceeds a maximum number of attempts. ReadResponse ReadRowsWithRetry(Table table, std::string start_row_key, bool inclusive_start, std::string end_row_key, bool inclusive_end, const std::vector<std::string>& column_names, size_t max_rows); // This method is used to implement ReadRow and ReadRows. It is identical to // ReadRows except that instead of limit_row_key it has end_row_key and // inclusive_end. In other words it supports intervals that are closed on // the right. ReadResponse ReadRowsInternal(Table table, std::string start_row_key, bool inclusive_start, std::string end_row_key, bool inclusive_end, const std::vector<std::string>& column_names, size_t max_rows); std::unique_ptr<google::bigtable::v2::Bigtable::Stub> stub_; std::unique_ptr<google::bigtable::admin::v2::BigtableTableAdmin::Stub> admin_stub_; std::string observations_table_name_, report_progress_table_name_, report_rows_table_name_; }; } // namespace store } // namespace analyzer } // namespace cobalt #endif // COBALT_ANALYZER_STORE_BIGTABLE_STORE_H_
40.466019
80
0.698177
[ "vector" ]
19c60d8aac32f7b95cbd6772debb4d8b2b65c350
14,656
h
C
Examples/include/asposecpplib/system/enumerator_adapter.h
kashifiqb/Aspose.PDF-for-C
13d49bba591c5704685820185741e64a462a5bdc
[ "MIT" ]
null
null
null
Examples/include/asposecpplib/system/enumerator_adapter.h
kashifiqb/Aspose.PDF-for-C
13d49bba591c5704685820185741e64a462a5bdc
[ "MIT" ]
null
null
null
Examples/include/asposecpplib/system/enumerator_adapter.h
kashifiqb/Aspose.PDF-for-C
13d49bba591c5704685820185741e64a462a5bdc
[ "MIT" ]
null
null
null
#pragma once #include <system/smart_ptr.h> #include <system/boxable_traits.h> #include <system/object_ext.h> #include <iterator> #include <utility> #include <type_traits> namespace System { namespace Details { /// Alias for Enumerator type of Enumerable /// @tparam Enumerable Type which implements IEnumerable interface template<typename Enumerable> using EnumeratorOf = std::remove_reference_t<decltype(*(std::declval<Enumerable>().GetEnumerator()))>; /// Alias for Value type of Enumerable /// @tparam Enumerable Type which implements IEnumerable interface template<typename Enumerable> using ValueTypeOfEnumerable = decltype(std::declval<EnumeratorOf<Enumerable>>().get_Current()); /// Checks if a given type has begin() and end() methods /// Can be used in std::enable_if /// @tparam T Type under check template <typename T, typename = void> struct IsIterable : std::false_type {}; template <typename T> struct IsIterable<T, decltype(std::declval<T>().begin(), std::declval<T>().end(), void())> : std::true_type {}; /// Alias for a value type of iterable of a given type /// @tparam T Type with begin() method template<typename T> using IterableValueType = decltype(*(std::declval<T>().begin())); /// Type trait which find return type for given T /// Should return correct SmartPtr if T is derived from Object, or Value type overwise /// @tparam T Type under check template<typename T, typename = void> struct ReturnTypeTrait {}; /// Specialization for T == SmartPtr<Something> template<typename T> struct ReturnTypeTrait<T, std::enable_if_t<IsSmartPtr<T>::value>> { using Pointee = std::remove_reference_t<decltype(*(std::declval<T>()))>; using ReturnType = SmartPtr<Pointee>; static constexpr bool value = true; }; /// Specialization for T != SmartPtr<Something> and if T boxable template<typename T> struct ReturnTypeTrait<T, std::enable_if_t<!IsSmartPtr<T>::value && IsBoxable<T>::value>> { using Pointee = void; using ReturnType = T; static constexpr bool value = false; }; /// Specialization for T != SmartPtr<Something> and if T derived from Object template<typename T> struct ReturnTypeTrait<T, std::enable_if_t<!IsSmartPtr<T>::value && !IsBoxable<T>::value>> { using Pointee = T; using ReturnType = SmartPtr<Pointee>; static constexpr bool value = true; }; /// Type trait which checks if any cast is required /// Can be used in std::enable_if /// @tparam D destination type /// @tparam S source type template<typename D, typename S> using WithoutCast = std::integral_constant<bool, std::is_same<typename ReturnTypeTrait<D>::ReturnType, typename ReturnTypeTrait<S>::ReturnType>::value>; /// Type trait which checks if a dynamic cast is required /// Can be used in std::enable_if /// @tparam D destination type /// @tparam S source type template<typename D, typename S> using WithDynamicCast = std::integral_constant<bool, ReturnTypeTrait<D>::value && ReturnTypeTrait<S>::value && !std::is_same<typename ReturnTypeTrait<D>::Pointee, typename ReturnTypeTrait<S>::Pointee>::value>; /// Type trait which checks if unboxing (from Object to Value type) is required /// Can be used in std::enable_if /// @tparam D destination type /// @tparam S source type template<typename D, typename S> using WithUnboxing = std::integral_constant<bool, !ReturnTypeTrait<D>::value && ReturnTypeTrait<S>::value && std::is_same<typename ReturnTypeTrait<S>::Pointee, System::Object>::value>; /// Type trait which checks if boxing (from ValueType to SmartPtr<Object> type) is required /// Can be used in std::enable_if /// @tparam D destination type /// @tparam S source type template<typename D, typename S> using WithBoxing = std::integral_constant<bool, ReturnTypeTrait<D>::value && !ReturnTypeTrait<S>::value && std::is_same<typename ReturnTypeTrait<D>::Pointee, System::Object>::value>; /// Wrapping iterator around IEnumerator /// It satisfies Fowrard Iterator requirements /// @tparam T target type which iterator has to return /// @tparam Enumerator Wrapped enumerator type template<typename T, typename Enumerator> struct WrappingIterator { using TargetType = T; using SourceType = typename Enumerator::ValueType; using iterator_category = std::forward_iterator_tag; using value_type = typename ReturnTypeTrait<TargetType>::ReturnType; using difference_type = std::ptrdiff_t; using pointer = value_type*; using reference = value_type&; WrappingIterator() : mIsEnd(true) {} WrappingIterator(SmartPtr<Enumerator> enumerator) : mEnumerator(std::move(enumerator)) , mIsEnd(!mEnumerator->MoveNext()) {} WrappingIterator(const WrappingIterator& other) = default; WrappingIterator(WrappingIterator&& other) = default; WrappingIterator& operator=(const WrappingIterator& other) = default; WrappingIterator& operator=(WrappingIterator&& other) = default; ~WrappingIterator() = default; bool operator!=(const WrappingIterator& other) const { if (mIsEnd && other.mIsEnd) return false; if (mIsEnd || other.mIsEnd) return true; // The correct comparison, but we use this iterator only for range-based loops // so it doesn't matter // mEnumerator->get_Current() != other.mEnumerator->get_Current(); return false; } template<typename Q = TargetType> std::enable_if_t<WithoutCast<Q, SourceType>::value, SourceType> operator*() const { return mEnumerator->get_Current(); } template<typename Q = TargetType> std::enable_if_t<WithDynamicCast<Q, SourceType>::value, value_type> operator*() const { return System::DynamicCast<typename ReturnTypeTrait<Q>::Pointee>(mEnumerator->get_Current()); } template<typename Q = TargetType> std::enable_if_t<WithUnboxing<Q, SourceType>::value, value_type> operator*() const { return ObjectExt::Unbox<typename ReturnTypeTrait<Q>::ReturnType>(mEnumerator->get_Current()); } template<typename Q = TargetType> std::enable_if_t<WithBoxing<Q, SourceType>::value, value_type> operator*() const { return ObjectExt::Box(mEnumerator->get_Current()); } WrappingIterator& operator++() { mIsEnd = ! mEnumerator->MoveNext(); return *this; } private: /// Wrapped enumerator SmartPtr<Enumerator> mEnumerator; /// End of iterator flag bool mIsEnd; }; /// Enumerator adapter which impements begin() and end() methods /// It keeps original enumerable object /// It lifetype is extended until the end of the loop (according to C++ standard) /// @tparam Enumerable The type of the Enumerable object /// @tparam T The target type which has to be returned from iterator /// @tparam Payload The payload type - can be SharedPtr or Pointer to Enumerable template<typename Enumerable, typename T = ValueTypeOfEnumerable<Enumerable>, typename Payload = SmartPtr<Enumerable>> struct EnumeratorAdapter { using iterator = WrappingIterator<T, EnumeratorOf<Enumerable>>; EnumeratorAdapter(Payload enumerable) : mEnumerable(std::move(enumerable)) {} iterator begin() { return WrappingIterator<T, EnumeratorOf<Enumerable>>(mEnumerable->GetEnumerator()); } iterator end() { return iterator(); } private: Payload mEnumerable; }; /// Wraps other forward iterator inside /// Property cast target type /// @tparam T The target type which has to be returned from iterator template<typename T, typename Iterator> struct AdaptedIterator { using TargetType = T; using SourceType = typename std::iterator_traits<Iterator>::value_type; using iterator_category = std::forward_iterator_tag; using value_type = typename ReturnTypeTrait<TargetType>::ReturnType; using difference_type = std::ptrdiff_t; using pointer = value_type*; using reference = value_type&; AdaptedIterator(Iterator origin_iterator) : mOriginIterator(std::move(origin_iterator)) { } AdaptedIterator(const AdaptedIterator& other) = default; AdaptedIterator(AdaptedIterator&& other) = default; AdaptedIterator& operator=(const AdaptedIterator& other) = default; AdaptedIterator& operator=(AdaptedIterator&& other) = default; friend bool operator==(const AdaptedIterator& lhs, const AdaptedIterator& rhs) { return lhs.mOriginIterator == rhs.mOriginIterator; } friend bool operator!=(const AdaptedIterator& lhs, const AdaptedIterator& rhs) { return lhs.mOriginIterator != rhs.mOriginIterator; } template<typename Q = TargetType> std::enable_if_t<WithoutCast<Q, SourceType>::value, value_type> operator*() const { return *mOriginIterator; } template<typename Q = TargetType> std::enable_if_t<WithDynamicCast<Q, SourceType>::value, value_type> operator*() const { return System::DynamicCast<typename ReturnTypeTrait<Q>::Pointee>(*mOriginIterator); } template<typename Q = TargetType> std::enable_if_t<WithUnboxing<Q, SourceType>::value, value_type> operator*() const { return ObjectExt::Unbox<typename ReturnTypeTrait<Q>::ReturnType>(*mOriginIterator); } template<typename Q = TargetType> std::enable_if_t<WithBoxing<Q, SourceType>::value, value_type> operator*() const { return ObjectExt::Box(*mOriginIterator); } AdaptedIterator& operator++() { ++mOriginIterator; return *this; } private: Iterator mOriginIterator; }; /// Implements begin() and end() methods with required value type /// @tparam Iterable The type which implements begin() and end() methods /// @tparam T The target type which has to be returned from iterator template<typename Iterable, typename T> struct CppIteratorAdapter { CppIteratorAdapter(SmartPtr<Iterable> enumerable) : mEnumerable(std::move(enumerable)) {} using origin_iterator = decltype(std::declval<Iterable>().begin()); using iterator = AdaptedIterator<T, origin_iterator>; iterator begin() { return iterator(mEnumerable->begin()); } iterator end() { return iterator(mEnumerable->end()); } private: SmartPtr<Iterable> mEnumerable; }; } /// This function property wraps enumerable (or iterable) object so it can be used with range-based for loop /// This overload for Enumerable without begin(), end() methods with target type argument /// for (auto& value : IterateOver<SomeType>(enumerable)) /// @tparam T The target type, it has to be returned from iterator /// @tparam Enumerable The type of a wrapped object template<typename T, typename Enumerable> std::enable_if_t<!Details::IsIterable<Enumerable>::value, Details::EnumeratorAdapter<Enumerable, T>> IterateOver(System::SmartPtr<Enumerable> enumerable) { return Details::EnumeratorAdapter<Enumerable, T>(std::move(enumerable)); } /// This function property wraps enumerable (or iterable) object so it can be used with range-based for loop /// This overload for Enumerable without begin(), end() methods with default target type argument /// for (auto& value : IterateOver(enumerable)) /// analog to the following C# code /// foreach (var value in enumerable) /// @tparam Enumerable The type of a wrapped object template<typename Enumerable> std::enable_if_t<!Details::IsIterable<Enumerable>::value, Details::EnumeratorAdapter<Enumerable>> IterateOver(System::SmartPtr<Enumerable> enumerable) { return Details::EnumeratorAdapter<Enumerable>(std::move(enumerable)); } /// This function property wraps enumerable (or iterable) object so it can be used with range-based for loop /// This overload for Enumerable with begin(), end() methods with default target type argument /// for (auto& value : IterateOver(enumerable)) /// @tparam Enumerable The type of a wrapped object template<typename Enumerable> std::enable_if_t<Details::IsIterable<Enumerable>::value, System::SmartPtr<Enumerable>> IterateOver(System::SmartPtr<Enumerable> enumerable) { return enumerable; } /// This function property wraps enumerable (or iterable) object so it can be used with range-based for loop /// This overload for Enumerable with begin(), end() methods with target type same as original value_type of iterator /// @tparam Enumerable The type of a wrapped object /// @tparam T The target type which has to returned from iterator template<typename T, typename Enumerable> std::enable_if_t<Details::IsIterable<Enumerable>::value && std::is_same<typename Details::ReturnTypeTrait<T>::ReturnType, Details::IterableValueType<Enumerable>>::value, System::SmartPtr<Enumerable>> IterateOver(System::SmartPtr<Enumerable> enumerable) { return enumerable; } /// This function property wraps enumerable (or iterable) object so it can be used with range-based for loop /// This overload for Enumerable with begin(), end() methods with different target type and original value_type of iterator /// @tparam Enumerable The type of a wrapped object /// @tparam T The target type which has to returned from iterator template<typename T, typename Enumerable> std::enable_if_t<Details::IsIterable<Enumerable>::value && !std::is_same<typename Details::ReturnTypeTrait<T>::ReturnType, Details::IterableValueType<Enumerable>>::value, Details::CppIteratorAdapter<Enumerable, T>> IterateOver(System::SmartPtr<Enumerable> enumerable) { return Details::CppIteratorAdapter<Enumerable, T>(std::move(enumerable)); } /// This function property wraps enumerable (or iterable) object so it can be used with range-based for loop /// This overload for Enumerable this with default target type /// @tparam Enumerable The type of a wrapped object template<typename Enumerable> std::enable_if_t<!IsSmartPtr<Enumerable>::value, Details::EnumeratorAdapter<Enumerable, Details::ValueTypeOfEnumerable<Enumerable>, Enumerable*>> IterateOver(Enumerable* enumerable) { return Details::EnumeratorAdapter<Enumerable, Details::ValueTypeOfEnumerable<Enumerable>, Enumerable*>(enumerable); } /// This function property wraps enumerable (or iterable) object so it can be used with range-based for loop /// This overload for Enumerable without begin(), end() methods with target type argument /// for (auto& value : IterateOver<SomeType>(enumerable)) /// @tparam T The target type, it has to be returned from iterator /// @tparam Enumerable The type of a wrapped object template<typename T, typename Enumerable> std::enable_if_t<!IsSmartPtr<Enumerable>::value, Details::EnumeratorAdapter<Enumerable, T, Enumerable*>> IterateOver(Enumerable* enumerable) { return Details::EnumeratorAdapter<Enumerable, T, Enumerable*>(enumerable); } }
37.773196
214
0.731236
[ "object" ]
9fc64635ea17073d417c158349c553825755af28
18,647
h
C
sdktools/debuggers/oca/oca_tools/ocadata/_ocadata.h
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
sdktools/debuggers/oca/oca_tools/ocadata/_ocadata.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
sdktools/debuggers/oca/oca_tools/ocadata/_ocadata.h
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
#pragma warning( disable: 4049 ) /* more than 64k source lines */ /* this ALWAYS GENERATED file contains the definitions for the interfaces */ /* File created by MIDL compiler version 6.00.0347 */ /* at Mon May 20 11:18:54 2002 */ /* Compiler settings for _OCAData.idl: Os, W1, Zp8, env=Win32 (32b run) protocol : dce , ms_ext, c_ext error checks: allocation ref bounds_check enum stub_data VC __declspec() decoration level: __declspec(uuid()), __declspec(selectany), __declspec(novtable) DECLSPEC_UUID(), MIDL_INTERFACE() */ //@@MIDL_FILE_HEADING( ) /* verify that the <rpcndr.h> version is high enough to compile this file*/ #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 440 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of <rpcndr.h> #endif // __RPCNDR_H_VERSION__ #ifndef COM_NO_WINDOWS_H #include "windows.h" #include "ole2.h" #endif /*COM_NO_WINDOWS_H*/ #ifndef ___OCAData_h__ #define ___OCAData_h__ #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once #endif /* Forward Declarations */ #ifndef __ICountDaily_FWD_DEFINED__ #define __ICountDaily_FWD_DEFINED__ typedef interface ICountDaily ICountDaily; #endif /* __ICountDaily_FWD_DEFINED__ */ #ifndef __CCountDaily_FWD_DEFINED__ #define __CCountDaily_FWD_DEFINED__ #ifdef __cplusplus typedef class CCountDaily CCountDaily; #else typedef struct CCountDaily CCountDaily; #endif /* __cplusplus */ #endif /* __CCountDaily_FWD_DEFINED__ */ /* header files for imported files */ #include "prsht.h" #include "mshtml.h" #include "mshtmhst.h" #include "exdisp.h" #include "objsafe.h" #include "oledb.h" #ifdef __cplusplus extern "C"{ #endif void * __RPC_USER MIDL_user_allocate(size_t); void __RPC_USER MIDL_user_free( void * ); /* interface __MIDL_itf__OCAData_0000 */ /* [local] */ enum ServerLocation { Watson = 0, Archive = 1 } ; extern RPC_IF_HANDLE __MIDL_itf__OCAData_0000_v0_0_c_ifspec; extern RPC_IF_HANDLE __MIDL_itf__OCAData_0000_v0_0_s_ifspec; #ifndef __ICountDaily_INTERFACE_DEFINED__ #define __ICountDaily_INTERFACE_DEFINED__ /* interface ICountDaily */ /* [unique][helpstring][dual][uuid][object] */ EXTERN_C const IID IID_ICountDaily; #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("CEF1A8A8-F31A-4C4B-96EB-EF31CFDB40F5") ICountDaily : public IDispatch { public: virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetDailyCount( /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount) = 0; virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetDailyCountADO( /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount) = 0; virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ReportDailyBuckets( /* [in] */ DATE dDate, /* [retval][out] */ IDispatch **p_Rs) = 0; virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetFileCount( /* [in] */ enum ServerLocation eServer, /* [in] */ BSTR b_Location, /* [in] */ DATE d_Date, /* [retval][out] */ LONG *iCount) = 0; virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetDailyAnon( /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount) = 0; virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetSpecificSolutions( /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount) = 0; virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetGeneralSolutions( /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount) = 0; virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetStopCodeSolutions( /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount) = 0; virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetFileMiniCount( /* [in] */ enum ServerLocation eServer, /* [in] */ BSTR b_Location, /* [in] */ DATE d_Date, /* [retval][out] */ LONG *iCount) = 0; virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetIncompleteUploads( /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount) = 0; virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetManualUploads( /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount) = 0; virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetAutoUploads( /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount) = 0; virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetTest( /* [in] */ enum ServerLocation eServer, /* [in] */ BSTR b_Location, /* [in] */ DATE d_Date, /* [retval][out] */ LONG *iCount) = 0; }; #else /* C style interface */ typedef struct ICountDailyVtbl { BEGIN_INTERFACE HRESULT ( STDMETHODCALLTYPE *QueryInterface )( ICountDaily * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject); ULONG ( STDMETHODCALLTYPE *AddRef )( ICountDaily * This); ULONG ( STDMETHODCALLTYPE *Release )( ICountDaily * This); HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( ICountDaily * This, /* [out] */ UINT *pctinfo); HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( ICountDaily * This, /* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ ITypeInfo **ppTInfo); HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( ICountDaily * This, /* [in] */ REFIID riid, /* [size_is][in] */ LPOLESTR *rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID *rgDispId); /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( ICountDaily * This, /* [in] */ DISPID dispIdMember, /* [in] */ REFIID riid, /* [in] */ LCID lcid, /* [in] */ WORD wFlags, /* [out][in] */ DISPPARAMS *pDispParams, /* [out] */ VARIANT *pVarResult, /* [out] */ EXCEPINFO *pExcepInfo, /* [out] */ UINT *puArgErr); /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *GetDailyCount )( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *GetDailyCountADO )( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *ReportDailyBuckets )( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ IDispatch **p_Rs); /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *GetFileCount )( ICountDaily * This, /* [in] */ enum ServerLocation eServer, /* [in] */ BSTR b_Location, /* [in] */ DATE d_Date, /* [retval][out] */ LONG *iCount); /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *GetDailyAnon )( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *GetSpecificSolutions )( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *GetGeneralSolutions )( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *GetStopCodeSolutions )( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *GetFileMiniCount )( ICountDaily * This, /* [in] */ enum ServerLocation eServer, /* [in] */ BSTR b_Location, /* [in] */ DATE d_Date, /* [retval][out] */ LONG *iCount); /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *GetIncompleteUploads )( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *GetManualUploads )( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *GetAutoUploads )( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); /* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *GetTest )( ICountDaily * This, /* [in] */ enum ServerLocation eServer, /* [in] */ BSTR b_Location, /* [in] */ DATE d_Date, /* [retval][out] */ LONG *iCount); END_INTERFACE } ICountDailyVtbl; interface ICountDaily { CONST_VTBL struct ICountDailyVtbl *lpVtbl; }; #ifdef COBJMACROS #define ICountDaily_QueryInterface(This,riid,ppvObject) \ (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) #define ICountDaily_AddRef(This) \ (This)->lpVtbl -> AddRef(This) #define ICountDaily_Release(This) \ (This)->lpVtbl -> Release(This) #define ICountDaily_GetTypeInfoCount(This,pctinfo) \ (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) #define ICountDaily_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) #define ICountDaily_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) #define ICountDaily_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) #define ICountDaily_GetDailyCount(This,dDate,iCount) \ (This)->lpVtbl -> GetDailyCount(This,dDate,iCount) #define ICountDaily_GetDailyCountADO(This,dDate,iCount) \ (This)->lpVtbl -> GetDailyCountADO(This,dDate,iCount) #define ICountDaily_ReportDailyBuckets(This,dDate,p_Rs) \ (This)->lpVtbl -> ReportDailyBuckets(This,dDate,p_Rs) #define ICountDaily_GetFileCount(This,eServer,b_Location,d_Date,iCount) \ (This)->lpVtbl -> GetFileCount(This,eServer,b_Location,d_Date,iCount) #define ICountDaily_GetDailyAnon(This,dDate,iCount) \ (This)->lpVtbl -> GetDailyAnon(This,dDate,iCount) #define ICountDaily_GetSpecificSolutions(This,dDate,iCount) \ (This)->lpVtbl -> GetSpecificSolutions(This,dDate,iCount) #define ICountDaily_GetGeneralSolutions(This,dDate,iCount) \ (This)->lpVtbl -> GetGeneralSolutions(This,dDate,iCount) #define ICountDaily_GetStopCodeSolutions(This,dDate,iCount) \ (This)->lpVtbl -> GetStopCodeSolutions(This,dDate,iCount) #define ICountDaily_GetFileMiniCount(This,eServer,b_Location,d_Date,iCount) \ (This)->lpVtbl -> GetFileMiniCount(This,eServer,b_Location,d_Date,iCount) #define ICountDaily_GetIncompleteUploads(This,dDate,iCount) \ (This)->lpVtbl -> GetIncompleteUploads(This,dDate,iCount) #define ICountDaily_GetManualUploads(This,dDate,iCount) \ (This)->lpVtbl -> GetManualUploads(This,dDate,iCount) #define ICountDaily_GetAutoUploads(This,dDate,iCount) \ (This)->lpVtbl -> GetAutoUploads(This,dDate,iCount) #define ICountDaily_GetTest(This,eServer,b_Location,d_Date,iCount) \ (This)->lpVtbl -> GetTest(This,eServer,b_Location,d_Date,iCount) #endif /* COBJMACROS */ #endif /* C style interface */ /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICountDaily_GetDailyCount_Proxy( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); void __RPC_STUB ICountDaily_GetDailyCount_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICountDaily_GetDailyCountADO_Proxy( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); void __RPC_STUB ICountDaily_GetDailyCountADO_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICountDaily_ReportDailyBuckets_Proxy( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ IDispatch **p_Rs); void __RPC_STUB ICountDaily_ReportDailyBuckets_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICountDaily_GetFileCount_Proxy( ICountDaily * This, /* [in] */ enum ServerLocation eServer, /* [in] */ BSTR b_Location, /* [in] */ DATE d_Date, /* [retval][out] */ LONG *iCount); void __RPC_STUB ICountDaily_GetFileCount_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICountDaily_GetDailyAnon_Proxy( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); void __RPC_STUB ICountDaily_GetDailyAnon_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICountDaily_GetSpecificSolutions_Proxy( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); void __RPC_STUB ICountDaily_GetSpecificSolutions_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICountDaily_GetGeneralSolutions_Proxy( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); void __RPC_STUB ICountDaily_GetGeneralSolutions_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICountDaily_GetStopCodeSolutions_Proxy( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); void __RPC_STUB ICountDaily_GetStopCodeSolutions_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICountDaily_GetFileMiniCount_Proxy( ICountDaily * This, /* [in] */ enum ServerLocation eServer, /* [in] */ BSTR b_Location, /* [in] */ DATE d_Date, /* [retval][out] */ LONG *iCount); void __RPC_STUB ICountDaily_GetFileMiniCount_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICountDaily_GetIncompleteUploads_Proxy( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); void __RPC_STUB ICountDaily_GetIncompleteUploads_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICountDaily_GetManualUploads_Proxy( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); void __RPC_STUB ICountDaily_GetManualUploads_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICountDaily_GetAutoUploads_Proxy( ICountDaily * This, /* [in] */ DATE dDate, /* [retval][out] */ LONG *iCount); void __RPC_STUB ICountDaily_GetAutoUploads_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE ICountDaily_GetTest_Proxy( ICountDaily * This, /* [in] */ enum ServerLocation eServer, /* [in] */ BSTR b_Location, /* [in] */ DATE d_Date, /* [retval][out] */ LONG *iCount); void __RPC_STUB ICountDaily_GetTest_Stub( IRpcStubBuffer *This, IRpcChannelBuffer *_pRpcChannelBuffer, PRPC_MESSAGE _pRpcMessage, DWORD *_pdwStubPhase); #endif /* __ICountDaily_INTERFACE_DEFINED__ */ #ifndef __OCAData_LIBRARY_DEFINED__ #define __OCAData_LIBRARY_DEFINED__ /* library OCAData */ /* [helpstring][uuid][version] */ EXTERN_C const IID LIBID_OCAData; EXTERN_C const CLSID CLSID_CCountDaily; #ifdef __cplusplus class DECLSPEC_UUID("1614E060-0196-4771-AD9B-FEA1A6778B59") CCountDaily; #endif #endif /* __OCAData_LIBRARY_DEFINED__ */ /* Additional Prototypes for ALL interfaces */ unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * ); unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * ); unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * ); void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * ); /* end of Additional Prototypes */ #ifdef __cplusplus } #endif #endif
32.094664
112
0.612967
[ "object" ]
9fd71965df263a8329ff83537dc99e311bb656e7
2,843
c
C
src/move.c
ludocode/clayfish
af301f9f4077ac6942732de7f34c137644399620
[ "MIT" ]
2
2021-11-23T19:07:35.000Z
2021-11-24T02:57:46.000Z
src/move.c
ludocode/clayfish
af301f9f4077ac6942732de7f34c137644399620
[ "MIT" ]
null
null
null
src/move.c
ludocode/clayfish
af301f9f4077ac6942732de7f34c137644399620
[ "MIT" ]
null
null
null
/* * MIT License * * Copyright (c) 2020-2021 11037650 Canada Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include "move.h" #include "moves.t.h" #include "pottery/vector/pottery_vector_define.t.h" void move_format(move_t* move, char buf[6]) { if (coords_is_null(move->from)) { strcpy(buf, "0000"); return; } buf[0] = (char)(move->from.col + 'a'), buf[1] = (char)(move->from.row + '1'), buf[2] = (char)(move->to.col + 'a'), buf[3] = (char)(move->to.row + '1'); if (move->promotion != '.') { buf[4] = piece_make_black(move->promotion); buf[5] = '\0'; } else { buf[4] = '\0'; } } void move_print(move_t* move) { char buf[6]; move_format(move, buf); fputs(buf, stdout); } static inline bool move_parse_coord(char input, char base, signed char* out) { if (input < base || input > base + 7) return false; *out = (signed char)(input - base); return true; } bool move_parse(move_t* move, string_t* string, bool white_to_move) { const char* cstr = string_cstr(string); size_t len = string_length(string); if (len != 4 && len != 5) return false; if (!move_parse_coord(cstr[0], 'a', &move->from.col) || !move_parse_coord(cstr[1], '1', &move->from.row) || !move_parse_coord(cstr[2], 'a', &move->to.col) || !move_parse_coord(cstr[3], '1', &move->to.row)) return false; if (len == 5) { piece_t promotion = piece_make_black(cstr[4]); if (promotion != 'q' && promotion != 'r' && promotion != 'b' && promotion != 'n') return false; move->promotion = white_to_move ? piece_make_white(promotion) : promotion; } else { move->promotion = '.'; } return true; }
33.447059
82
0.633837
[ "vector" ]
9fdbd1346117a30194c292aafbbb2cf25512526d
1,535
h
C
src/transition_system.h
r2im/pickaxe
d277f008eba6761b0cf210bf19ba1439678cdb46
[ "MIT" ]
1
2018-01-27T18:51:06.000Z
2018-01-27T18:51:06.000Z
src/transition_system.h
r2im/pickaxe
d277f008eba6761b0cf210bf19ba1439678cdb46
[ "MIT" ]
null
null
null
src/transition_system.h
r2im/pickaxe
d277f008eba6761b0cf210bf19ba1439678cdb46
[ "MIT" ]
1
2018-04-14T01:02:31.000Z
2018-04-14T01:02:31.000Z
#ifndef TRANSITION_SYSTEM_H #define TRANSITION_SYSTEM_H struct state { int id; char *activity; int children_size; struct state **children; int parents_size; struct state **parents; int is_end; int cardinality; }; struct transition { int src; int dest; }; struct labels { char *activity; int states_size; int *states; BDD states_bdd; }; typedef struct labels Labels; typedef struct state State; typedef struct transition Transition; struct transition_system { State *pseudo_initial; int states_size; BDD *states_bdds; BDD *states_primed_bdds; BDD all_states; BDD initial_states; Transition **transitions; int transition_size; BDD transitions_bdd; BDD unprimed2primed; BDD unprimed_vars; BDD primed_vars; BDD pseudo_end; Labels **labels; int activities_size; }; typedef struct transition_system TransitionSystem; //State PSEUDO_END = {.id = 0, .activity = "__END__", .children = NULL, .children_size = 0}; //functions TransitionSystem* create_emtpty_model(void); void add_trace(TransitionSystem *model, char **activities); void print_model(TransitionSystem *model); void create_bdds(TransitionSystem *model); BDD f_bdd_and_with(BDD l, BDD r); BDD f_bdd_or_with(BDD l, BDD r); BDD pre_exists(TransitionSystem *model, BDD p); BDD pre_all(TransitionSystem *model, BDD p); double support(TransitionSystem *model, BDD result); Labels* get_labels_for(TransitionSystem *model, char *activity); #endif /* TRANSITION_SYSTEM_H */
20.466667
93
0.731596
[ "model" ]
9fede8bf829bc6089cf948620c13b9b7cbb92982
5,100
h
C
PROX/APPLICATIONS/RIGID_BODY/RIGID_BODY_GUI_SHARED/include/rigid_body_gui_draw_contacts.h
diku-dk/PROX
c6be72cc253ff75589a1cac28e4e91e788376900
[ "MIT" ]
null
null
null
PROX/APPLICATIONS/RIGID_BODY/RIGID_BODY_GUI_SHARED/include/rigid_body_gui_draw_contacts.h
diku-dk/PROX
c6be72cc253ff75589a1cac28e4e91e788376900
[ "MIT" ]
null
null
null
PROX/APPLICATIONS/RIGID_BODY/RIGID_BODY_GUI_SHARED/include/rigid_body_gui_draw_contacts.h
diku-dk/PROX
c6be72cc253ff75589a1cac28e4e91e788376900
[ "MIT" ]
null
null
null
#ifndef RIGID_BODY_GUI_DRAW_CONTACTS_H #define RIGID_BODY_GUI_DRAW_CONTACTS_H #include <rigid_body_gui_lighting.h> #include <rigid_body_gui_geometry.h> #include <gl3_shader_program_manager.h> #include <gl3_glm.h> #include <content.h> #include <mesh_array.h> #include <tiny.h> #include <cmath> // std::acos, std::fabs namespace rigid_body { namespace gui { inline void make_contact_geometry( gl3::ShaderProgramManager & program_manager , GeometryManager & geometry_manager ) { typedef tiny::MathTypes<float> MT; typedef typename MT::vector3_type V; gl3::Program & program = program_manager.get(2); float height = 0.5f; float radius1 = 0.25f; float radius2 = 0.15f; mesh_array::T3Mesh base; mesh_array::VertexAttribute<float, mesh_array::T3Mesh> baseX; mesh_array::VertexAttribute<float, mesh_array::T3Mesh> baseY; mesh_array::VertexAttribute<float, mesh_array::T3Mesh> baseZ; mesh_array::T3Mesh shaft; mesh_array::VertexAttribute<float, mesh_array::T3Mesh> shaftX; mesh_array::VertexAttribute<float, mesh_array::T3Mesh> shaftY; mesh_array::VertexAttribute<float, mesh_array::T3Mesh> shaftZ; mesh_array::T3Mesh head; mesh_array::VertexAttribute<float, mesh_array::T3Mesh> headX; mesh_array::VertexAttribute<float, mesh_array::T3Mesh> headY; mesh_array::VertexAttribute<float, mesh_array::T3Mesh> headZ; mesh_array::make_sphere<MT>(radius1, 12, 12, base, baseX, baseY, baseZ); mesh_array::make_cone<MT>(radius1, height, 12, head, headX, headY, headZ); mesh_array::make_cylinder<MT>(radius2, height, 12, shaft, shaftX, shaftY, shaftZ); mesh_array::translate<MT>(V::make(0, height/2, 0), shaft, shaftX, shaftY, shaftZ); mesh_array::translate<MT>(V::make(0, height, 0), head, headX, headY, headZ); mesh_array::T3Mesh mesh; mesh_array::VertexAttribute<float, mesh_array::T3Mesh> X; mesh_array::VertexAttribute<float, mesh_array::T3Mesh> Y; mesh_array::VertexAttribute<float, mesh_array::T3Mesh> Z; mesh_array::concatenation<MT>( base, baseX, baseY, baseZ, mesh, X, Y, Z ); mesh_array::concatenation<MT>( shaft, shaftX, shaftY, shaftZ, mesh, X, Y, Z ); mesh_array::concatenation<MT>( head, headX, headY, headZ, mesh, X, Y, Z ); Geometry geometry; geometry.m_vbo = gl3::make_vbo(mesh, X, Y, Z); geometry.m_solid_vao = gl3::make_vao(geometry.m_vbo, program, "position", "normal"); geometry_manager.add("contact", geometry); } inline void draw_contacts( content::API * engine , util::ConfigFile const & params , glm::mat4 const & projection_matrix , glm::mat4 const & view_matrix , std::vector<LightInfo> & lights , gl3::ShaderProgramManager & program_manager , GeometryManager & geometry_manager ) { using std::acos; using std::fabs; gl3::check_errors("draw_contacts() invoked"); gl3::Program & program = program_manager.get(2); program.use(); program.set_uniform("projection_matrix", projection_matrix ); program.set_uniform("view_matrix", view_matrix ); set_lighting_uniforms(program, lights); Geometry const & geometry = geometry_manager.get("contact"); float x = 0.0; float y = 0.0; float z = 0.0; float nx = 0.0; float ny = 0.0; float nz = 0.0; glm::vec3 const up =glm::vec3(0,1,0); for( size_t c = 0; c < engine->get_number_of_contacts(); ++c) { engine->get_contact_position(c, x, y, z); engine->get_contact_normal(c, nx, ny, nz); glm::vec3 const p = glm::vec3(x,y,z); glm::vec3 const n = glm::normalize( glm::vec3(nx,ny,nz) ); float const cos_theta = glm::dot(up, n); glm::vec3 const axis = (fabs(cos_theta) < 0.99) ? glm::cross(up, n) : glm::vec3(1,0,0); float const radians = acos(cos_theta); float const scale = util::to_value<float>(params.get_value("draw_contacts_scaling", "1.0")); glm::mat4 const scale_matrix = glm::scale(glm::mat4(1.0), glm::vec3(scale,scale,scale)); glm::mat4 const rotation_matrix = glm::rotate( glm::mat4(1.0), radians, axis); glm::mat4 const translation_matrix = glm::translate( glm::mat4(1.0), p); glm::mat4 const model_view_matrix = view_matrix * translation_matrix * rotation_matrix * scale_matrix; program.set_uniform( "model_view_matrix", model_view_matrix); geometry.m_solid_vao.bind(); geometry.m_vbo.draw(); geometry.m_solid_vao.unbind(); } program.stop(); } }//namespace gui }//namespace rigid_body // RIGID_BODY_GUI_DRAW_CONTACTS_H #endif
35.664336
111
0.617255
[ "mesh", "geometry", "vector" ]
9ff3dd8248e366053077004cfbfff166ef0b900e
48,559
c
C
third_party/virtualbox/src/libs/kStuff/kStuff/kLdr/kLdrDyld.c
remynicol/icebox
5ebc3ca57c09c27493e5ec8236d6d028d34d5fbd
[ "MIT" ]
1
2015-04-30T14:18:45.000Z
2015-04-30T14:18:45.000Z
VirtualBox-5.0.0/src/libs/kStuff/kStuff/kLdr/kLdrDyld.c
egraba/vbox_openbsd
6cb82f2eed1fa697d088cecc91722b55b19713c2
[ "MIT" ]
null
null
null
VirtualBox-5.0.0/src/libs/kStuff/kStuff/kLdr/kLdrDyld.c
egraba/vbox_openbsd
6cb82f2eed1fa697d088cecc91722b55b19713c2
[ "MIT" ]
null
null
null
/* $Id: kLdrDyld.c 29 2009-07-01 20:30:29Z bird $ */ /** @file * kLdr - The Dynamic Loader. */ /* * Copyright (c) 2006-2007 Knut St. Osmundsen <bird-kStuff-spamix@anduin.net> * * 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. */ /******************************************************************************* * Header Files * *******************************************************************************/ #include <k/kLdr.h> #include "kLdrInternal.h" /******************************************************************************* * Defined Constants And Macros * *******************************************************************************/ /** @def KLDRDYLD_STRICT * Define KLDRDYLD_STRICT to enabled strict checks in kLdrDyld. */ #define KLDRDYLD_STRICT 1 /** @def KLDRDYLD_ASSERT * Assert that an expression is true when KLDRDYLD_STRICT is defined. */ #ifdef KLDRDYLD_STRICT # define KLDRDYLD_ASSERT(expr) kHlpAssert(expr) #else # define KLDRDYLD_ASSERT(expr) do {} while (0) #endif /******************************************************************************* * Structures and Typedefs * *******************************************************************************/ /******************************************************************************* * Global Variables * *******************************************************************************/ /** Pointer to the executable module. * (This is exported, so no prefix.) */ PKLDRDYLDMOD kLdrDyldExe = NULL; /** Pointer to the head module (the executable). * (This is exported, so no prefix.) */ PKLDRDYLDMOD kLdrDyldHead = NULL; /** Pointer to the tail module. * (This is exported, so no prefix.) */ PKLDRDYLDMOD kLdrDyldTail = NULL; /** Pointer to the head module of the initialization list. * The outermost load call will pop elements from this list in LIFO order (i.e. * from the tail). The list is only used during non-recursive initialization * and may therefore share the pNext/pPrev members with the termination list * since we don't push a module onto the termination list untill it has been * successfully initialized. */ PKLDRDYLDMOD g_pkLdrDyldInitHead; /** Pointer to the tail module of the initalization list.*/ PKLDRDYLDMOD g_pkLdrDyldInitTail; /** Pointer to the head module of the termination order list. * This is a LIFO just like the the init list. */ PKLDRDYLDMOD g_pkLdrDyldTermHead; /** Pointer to the tail module of the termination order list. */ PKLDRDYLDMOD g_pkLdrDyldTermTail; /** Pointer to the head module of the bind order list. * The modules in this list makes up the global namespace used when binding symbol unix fashion. */ PKLDRDYLDMOD g_pkLdrDyldBindHead; /** Pointer to the tail module of the bind order list. */ PKLDRDYLDMOD g_pkLdrDyldBindTail; /** Flag indicating bootstrap time. * When set the error behaviour changes. Any kind of serious failure * is fatal and will terminate the process. */ int g_fBootstrapping; /** The global error buffer. */ char g_szkLdrDyldError[1024]; /** The default flags. */ KU32 kLdrDyldFlags = 0; /** The default search method. */ KLDRDYLDSEARCH kLdrDyldSearch = KLDRDYLD_SEARCH_HOST; /** @name The main stack. * @{ */ /** Indicates that the other MainStack globals have been filled in. */ unsigned g_fkLdrDyldDoneMainStack = 0; /** Whether the stack was allocated seperatly or was part of the executable. */ unsigned g_fkLdrDyldMainStackAllocated = 0; /** Pointer to the main stack object. */ void *g_pvkLdrDyldMainStack = NULL; /** The size of the main stack object. */ KSIZE g_cbkLdrDyldMainStack = 0; /** @} */ /** The load stack. * This contains frames with modules affected by active loads. * * Each kLdrDyldLoad and kLdrDyldLoadExe call will create a new stack frame containing * all the modules involved in the operation. The modules will be ordered in recursive * init order within the frame. */ static PPKLDRDYLDMOD g_papStackMods; /** The number of used entries in the g_papStackMods array. */ static KU32 g_cStackMods; /** The number of entries allocated for the g_papStackMods array. */ static KU32 g_cStackModsAllocated; /** Number of active load calls. */ static KU32 g_cActiveLoadCalls; /** Number of active unload calls. */ static KU32 g_cActiveUnloadCalls; /** Total number of load calls. */ static KU32 g_cTotalLoadCalls; /** Total mumber of unload calls. */ static KU32 g_cTotalUnloadCalls; /** Boolean flag indicating that GC is active. */ static KU32 g_fActiveGC; /******************************************************************************* * Internal Functions * *******************************************************************************/ /** @name API worker routines. * @internal * @{ */ void kldrDyldDoLoadExeStackSwitch(PKLDRDYLDMOD pExe, void *pvStack, KSIZE cbStack); static int kldrDyldDoLoad(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, unsigned fFlags, PPKLDRDYLDMOD ppMod, char *pszErr, KSIZE cchErr); static int kldrDyldDoLoad2(PKLDRDYLDMOD pLoadedMod, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, unsigned fFlags); static int kldrDyldDoLoadPrerequisites(PKLDRDYLDMOD pMod, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, unsigned fFlags); static int kldrDyldDoUnload(PKLDRDYLDMOD pMod); static int kldrDyldDoFindByName(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, unsigned fFlags, PPKLDRDYLDMOD ppMod); static int kldrDyldDoFindByAddress(KUPTR Address, PPKLDRDYLDMOD ppMod, KU32 *piSegment, KUPTR *poffSegment); static int kldrDyldDoGetName(PKLDRDYLDMOD pMod, char *pszName, KSIZE cchName); static int kldrDyldDoGetFilename(PKLDRDYLDMOD pMod, char *pszFilename, KSIZE cchFilename); static int kldrDyldDoQuerySymbol(PKLDRDYLDMOD pMod, KU32 uSymbolOrdinal, const char *pszSymbolName, KUPTR *pValue, KU32 *pfKind); /** @} */ /** @name Misc load/unload workers * @internal * @{ */ static void kldrDyldDoModuleTerminationAndGarabageCollection(void); /** @} */ /** @name The load stack. * @internal * @{ */ static KU32 kldrDyldStackNewFrame(PKLDRDYLDMOD pMod); static int kldrDyldStackAddModule(PKLDRDYLDMOD pMod); static int kldrDyldStackFrameCompleted(void); static void kldrDyldStackCleanupOne(PKLDRDYLDMOD pMod, int rc); static void kldrDyldStackDropFrame(KU32 iLoad1st, KU32 iLoadEnd, int rc); /** @} */ static int kldrDyldCopyError(int rc, char *pszErr, KSIZE cchErr); /** * Initialize the dynamic loader. */ int kldrDyldInit(void) { kLdrDyldHead = kLdrDyldTail = NULL; g_pkLdrDyldTermHead = g_pkLdrDyldTermTail = NULL; g_pkLdrDyldBindHead = g_pkLdrDyldBindTail = NULL; kLdrDyldFlags = 0; g_szkLdrDyldError[0] = '\0'; g_fkLdrDyldDoneMainStack = 0; g_fkLdrDyldMainStackAllocated = 0; g_pvkLdrDyldMainStack = NULL; g_cbkLdrDyldMainStack = 0; return kldrDyldFindInit(); } /** * Terminate the dynamic loader. */ void kldrDyldTerm(void) { } /** * Bootstrap an executable. * * This is called from the executable stub to replace the stub and run the * executable specified in the argument package. * * Since this is boostrap time there isn't anything to return to. So, instead * the process will be terminated upon failure. * * We also have to keep in mind that this function is called on a small, small, * stack and therefore any kind of large stack objects or deep recursions must * be avoided. Since loading the executable will involve more or less all * operations in the loader, this restriction really applies everywhere. * * @param pArgs Pointer to the argument package residing in the executable stub. * @param pvOS OS specific argument. */ #ifndef __OS2__ /* kLdrDyldLoadExe is implemented in assembly on OS/2. */ void kLdrDyldLoadExe(PCKLDREXEARGS pArgs, void *pvOS) #else void kldrDyldLoadExe(PCKLDREXEARGS pArgs, void *pvOS) #endif { void *pvStack; KSIZE cbStack; PKLDRDYLDMOD pExe; int rc; /* * Indicate that we're boostrapping and ensure that initialization was successful. */ g_fBootstrapping = 1; rc = kldrInit(); if (rc) kldrDyldFailure(rc, "Init failure, rc=%d", rc); /* * Validate the argument package. */ if (pArgs->fFlags & ~( KLDRYDLD_LOAD_FLAGS_GLOBAL_SYMBOLS | KLDRYDLD_LOAD_FLAGS_DEEP_SYMBOLS | KLDRDYLD_LOAD_FLAGS_RECURSIVE_INIT | KLDRYDLD_LOAD_FLAGS_SPECIFIC_MODULE)) kldrDyldFailure(KERR_INVALID_PARAMETER, "Bad fFlags=%#x", pArgs->fFlags); if ( pArgs->enmSearch <= KLDRDYLD_SEARCH_INVALID || pArgs->enmSearch >= KLDRDYLD_SEARCH_END) kldrDyldFailure(KERR_INVALID_PARAMETER, "Bad enmSearch=%d", pArgs->enmSearch); /* * Set defaults. */ kLdrDyldFlags |= (pArgs->fFlags & KLDRDYLD_LOAD_FLAGS_RECURSIVE_INIT); kLdrDyldSearch = pArgs->enmSearch; /** @todo make sense of this default prefix/suffix stuff. */ if (pArgs->szDefPrefix[0] != '\0') kHlpMemCopy(kLdrDyldDefPrefix, pArgs->szDefPrefix, K_MIN(sizeof(pArgs->szDefPrefix), sizeof(kLdrDyldDefPrefix))); if (pArgs->szDefSuffix[0] != '\0') kHlpMemCopy(kLdrDyldDefSuffix, pArgs->szDefSuffix, K_MIN(sizeof(pArgs->szDefSuffix), sizeof(kLdrDyldDefSuffix))); /** @todo append that path to the one for the specified search method. */ /** @todo create a function for doing this, an exposed api preferably. */ /* append path */ cbStack = sizeof(kLdrDyldLibraryPath) - kHlpStrLen(kLdrDyldLibraryPath); /* borrow cbStack for a itty bit. */ kHlpMemCopy(kLdrDyldLibraryPath, pArgs->szLibPath, K_MIN(sizeof(pArgs->szLibPath), cbStack)); kLdrDyldLibraryPath[sizeof(kLdrDyldLibraryPath) - 1] = '\0'; /* * Make sure we own the loader semaphore (necessary for init). */ rc = kLdrDyldSemRequest(); if (rc) kldrDyldFailure(rc, "Sem req. failure, rc=%d", rc); /* * Open and map the executable module before we join paths with kLdrDyldLoad(). */ rc = kldrDyldFindNewModule(pArgs->szExecutable, NULL, NULL, pArgs->enmSearch, pArgs->fFlags | KLDRDYLD_LOAD_FLAGS_EXECUTABLE, &pExe); if (rc) kldrDyldFailure(rc, "Can't find/open the executable '%s', rc=%d", pArgs->szExecutable, rc); rc = kldrDyldModMap(pExe); if (rc) kldrDyldFailure(rc, "Failed to map the executable '%s', rc=%d", pExe->pMod->pszFilename, rc); kLdrDyldExe = pExe; /* * Query the stack and go to OS specific code to * setup and switch stack. The OS specific code will call us * back at kldrDyldDoLoadExe. */ rc = kldrDyldModGetMainStack(pExe, &pvStack, &cbStack); if (rc) kldrDyldFailure(rc, "Failed to map the executable '%s', rc=%d", pExe->pMod->pszFilename, rc); kldrDyldDoLoadExeStackSwitch(pExe, pvStack, cbStack); kldrDyldFailure(-1, "Failed to setup the stack for '%s'.", pExe->pMod->pszFilename); } /** * Loads a module into the current process. * * @returns 0 on success, non-zero native OS status code or kLdr status code on failure. * @param pszDll The name of the dll to open. * @param pszPrefix Prefix to use when searching. * @param pszSuffix Suffix to use when searching. * @param enmSearch Method to use when locating the module and any modules it may depend on. * @param fFlags Flags, a combintation of the KLDRYDLD_LOAD_FLAGS_* \#defines. * @param phMod Where to store the handle to the loaded module. * @param pszErr Where to store extended error information. (optional) * @param cchErr The size of the buffer pointed to by pszErr. */ int kLdrDyldLoad(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, unsigned fFlags, PHKLDRMOD phMod, char *pszErr, KSIZE cchErr) { int rc; /* validate arguments and initialize return values. */ if (pszErr && cchErr) *pszErr = '\0'; *phMod = NIL_HKLDRMOD; K_VALIDATE_STRING(pszDll); K_VALIDATE_OPTIONAL_STRING(pszPrefix); K_VALIDATE_OPTIONAL_STRING(pszSuffix); K_VALIDATE_ENUM(enmSearch, KLDRDYLD_SEARCH); K_VALIDATE_OPTIONAL_BUFFER(pszErr, cchErr); /* get the semaphore and do the job. */ rc = kLdrDyldSemRequest(); if (!rc) { PKLDRDYLDMOD pMod = NULL; g_cTotalLoadCalls++; g_cActiveLoadCalls++; rc = kldrDyldDoLoad(pszDll, pszPrefix, pszSuffix, enmSearch, fFlags, &pMod, pszErr, cchErr); g_cActiveLoadCalls--; kldrDyldDoModuleTerminationAndGarabageCollection(); kLdrDyldSemRelease(); *phMod = pMod ? pMod->hMod : NIL_HKLDRMOD; } return rc; } /** * Unloads a module loaded by kLdrDyldLoad. * * @returns 0 on success, non-zero native OS status code or kLdr status code on failure. * @param hMod Module handle. */ int kLdrDyldUnload(HKLDRMOD hMod) { int rc; /* validate */ KLDRDYLD_VALIDATE_HKLDRMOD(hMod); /* get sem & do work */ rc = kLdrDyldSemRequest(); if (!rc) { g_cTotalUnloadCalls++; g_cActiveUnloadCalls++; rc = kldrDyldDoUnload(hMod); g_cActiveUnloadCalls--; kldrDyldDoModuleTerminationAndGarabageCollection(); kLdrDyldSemRelease(); } return rc; } /** * Finds a module by name or filename. * * This call does not increase any reference counters and must not be * paired with kLdrDyldUnload() like kLdrDyldLoad(). * * @returns 0 on success. * @returns KLDR_ERR_MODULE_NOT_FOUND or some I/O error on failure. * @param pszDll The name of the dll to look for. * @param pszPrefix Prefix than can be used when searching. * @param pszSuffix Suffix than can be used when searching. * @param enmSearch Method to use when locating the module. * @param fFlags Flags, a combintation of the KLDRYDLD_LOAD_FLAGS_* \#defines. * @param phMod Where to store the handle of the module on success. */ int kLdrDyldFindByName(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, unsigned fFlags, PHKLDRMOD phMod) { int rc; /* validate & initialize */ *phMod = NIL_HKLDRMOD; K_VALIDATE_STRING(pszDll); /* get sem & do work */ rc = kLdrDyldSemRequest(); if (!rc) { PKLDRDYLDMOD pMod = NULL; rc = kldrDyldDoFindByName(pszDll, pszPrefix, pszSuffix, enmSearch, fFlags, &pMod); kLdrDyldSemRelease(); *phMod = pMod ? pMod->hMod : NIL_HKLDRMOD; } return rc; } /** * Finds a module by address. * * This call does not increase any reference counters and must not be * paired with kLdrDyldUnload() like kLdrDyldLoad(). * * @returns 0 on success. * @returns KLDR_ERR_MODULE_NOT_FOUND on failure. * @param Address The address believed to be within some module. * @param phMod Where to store the module handle on success. * @param piSegment Where to store the segment number. (optional) * @param poffSegment Where to store the offset into the segment. (optional) */ int kLdrDyldFindByAddress(KUPTR Address, PHKLDRMOD phMod, KU32 *piSegment, KUPTR *poffSegment) { int rc; /* validate & initialize */ *phMod = NIL_HKLDRMOD; if (piSegment) *piSegment = ~(KU32)0; if (poffSegment) *poffSegment = ~(KUPTR)0; /* get sem & do work */ rc = kLdrDyldSemRequest(); if (!rc) { PKLDRDYLDMOD pMod = NULL; rc = kldrDyldDoFindByAddress(Address, &pMod, piSegment, poffSegment); kLdrDyldSemRelease(); *phMod = pMod ? pMod->hMod : NIL_HKLDRMOD; } return rc; } /** * Gets the module name. * * @returns 0 on success and pszName filled with the name. * @returns KERR_INVALID_HANDLE or KERR_BUFFER_OVERFLOW on failure. * @param hMod The module handle. * @param pszName Where to put the name. * @param cchName The size of the name buffer. * @see kLdrDyldGetFilename */ int kLdrDyldGetName(HKLDRMOD hMod, char *pszName, KSIZE cchName) { int rc; /* validate */ if (pszName && cchName) *pszName = '\0'; KLDRDYLD_VALIDATE_HKLDRMOD(hMod); K_VALIDATE_BUFFER(pszName, cchName); /* get sem & do work */ rc = kLdrDyldSemRequest(); if (!rc) { rc = kldrDyldDoGetName(hMod, pszName, cchName); kLdrDyldSemRelease(); } return rc; } /** * Gets the module filename. * * @returns 0 on success and pszFilename filled with the name. * @returns KERR_INVALID_HANDLE or KERR_BUFFER_OVERFLOW on failure. * @param hMod The module handle. * @param pszFilename Where to put the filename. * @param cchFilename The size of the filename buffer. * @see kLdrDyldGetName */ int kLdrDyldGetFilename(HKLDRMOD hMod, char *pszFilename, KSIZE cchFilename) { int rc; /* validate & initialize */ if (pszFilename && cchFilename); *pszFilename = '\0'; KLDRDYLD_VALIDATE_HKLDRMOD(hMod); K_VALIDATE_BUFFER(pszFilename, cchFilename); /* get sem & do work */ rc = kLdrDyldSemRequest(); if (!rc) { rc = kldrDyldDoGetFilename(hMod, pszFilename, cchFilename); kLdrDyldSemRelease(); } return rc; } /** * Queries the value and type of a symbol. * * @returns 0 on success and pValue and pfKind set. * @returns KERR_INVALID_HANDLE or KLDR_ERR_SYMBOL_NOT_FOUND on failure. * @param hMod The module handle. * @param uSymbolOrdinal The symbol ordinal. This is ignored if pszSymbolName is non-zero. * @param pszSymbolName The symbol name. * @param pszSymbolVersion The symbol version. Optional. * @param pValue Where to put the symbol value. Optional if pfKind is non-zero. * @param pfKind Where to put the symbol kind flags. Optional if pValue is non-zero. */ int kLdrDyldQuerySymbol(HKLDRMOD hMod, KU32 uSymbolOrdinal, const char *pszSymbolName, const char *pszSymbolVersion, KUPTR *pValue, KU32 *pfKind) { int rc; /* validate & initialize */ if (pfKind) *pfKind = 0; if (pValue) *pValue = 0; if (!pfKind && !pValue) return KERR_INVALID_PARAMETER; KLDRDYLD_VALIDATE_HKLDRMOD(hMod); K_VALIDATE_OPTIONAL_STRING(pszSymbolName); /* get sem & do work */ rc = kLdrDyldSemRequest(); if (!rc) { rc = kldrDyldDoQuerySymbol(hMod, uSymbolOrdinal, pszSymbolName, pValue, pfKind); kLdrDyldSemRelease(); } return rc; } /** * Worker kLdrDoLoadExe(). * Used after we've switch to the final process stack. * * @param pExe The executable module. * @internal */ void kldrDyldDoLoadExe(PKLDRDYLDMOD pExe) { int rc; /* * Load the executable module with its prerequisites and initialize them. */ g_cActiveLoadCalls++; rc = kldrDyldDoLoad2(pExe, NULL, NULL, kLdrDyldSearch, kLdrDyldFlags | KLDRDYLD_LOAD_FLAGS_EXECUTABLE); if (rc) kldrDyldFailure(rc, "load 2 failed for '%s', rc=%d", pExe->pMod->pszFilename); g_cActiveLoadCalls--; kldrDyldDoModuleTerminationAndGarabageCollection(); /* * Invoke the executable entry point. */ kldrDyldModStartExe(pExe); kldrDyldFailure(-1, "failed to invoke main!"); } /** * Worker for kLdrDyldLoad() and helper for kLdrDyldLoadExe(). * @internal */ static int kldrDyldDoLoad(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, unsigned fFlags, PPKLDRDYLDMOD ppMod, char *pszErr, KSIZE cchErr) { int rc; /* * Try find the module among the ones that's already loaded. */ rc = kldrDyldFindExistingModule(pszDll, pszPrefix, pszSuffix, enmSearch, fFlags, ppMod); if (!rc) { switch ((*ppMod)->enmState) { /* * Prerequisites are ok, so nothing to do really. */ case KLDRSTATE_GOOD: case KLDRSTATE_INITIALIZING: return kldrDyldModDynamicLoad(*ppMod); /* * The module can't be loaded because it failed to initialize. */ case KLDRSTATE_INITIALIZATION_FAILED: return KLDR_ERR_MODULE_INIT_FAILED_ALREADY; /* * Prerequisites needs loading / reattaching and the module * (may depending on fFlags) needs to be initialized. */ case KLDRSTATE_PENDING_INITIALIZATION: break; /* * Prerequisites needs to be loaded again */ case KLDRSTATE_PENDING_TERMINATION: break; /* * The module has been terminated so it need to be reloaded, have it's * prereqs loaded, fixed up and initialized before we can use it again. */ case KLDRSTATE_PENDING_GC: rc = kldrDyldModReload(*ppMod); if (rc) return kldrDyldCopyError(rc, pszErr, cchErr); break; /* * Forget it, we don't know how to deal with re-initialization here. */ case KLDRSTATE_TERMINATING: KLDRDYLD_ASSERT(!"KLDR_ERR_MODULE_TERMINATING"); return KLDR_ERR_MODULE_TERMINATING; /* * Invalid state. */ default: KLDRDYLD_ASSERT(!"invalid state"); break; } } else { /* * We'll have to load it from file. */ rc = kldrDyldFindNewModule(pszDll, pszPrefix, pszSuffix, enmSearch, fFlags, ppMod); if (rc) return kldrDyldCopyError(rc, pszErr, cchErr); rc = kldrDyldModMap(*ppMod); } /* * Join cause with kLdrDyldLoadExe. */ if (!rc) rc = kldrDyldDoLoad2(*ppMod, pszPrefix, pszSuffix, enmSearch, fFlags); else kldrDyldStackCleanupOne(*ppMod, rc); /* * Copy any error or warning to the error buffer. */ return kldrDyldCopyError(rc, pszErr, cchErr); } /** * 2nd half of kLdrDyldLoad() and kLdrDyldLoadExe(). * * @internal */ static int kldrDyldDoLoad2(PKLDRDYLDMOD pLoadedMod, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, unsigned fFlags) { /* * Load prerequisites. */ KU32 i; KU32 iLoad1st = kldrDyldStackNewFrame(pLoadedMod); int rc = kldrDyldDoLoadPrerequisites(pLoadedMod, pszPrefix, pszSuffix, enmSearch, fFlags); KU32 iLoadEnd = kldrDyldStackFrameCompleted(); if (rc) { kldrDyldModAddRef(pLoadedMod); kldrDyldStackCleanupOne(pLoadedMod, rc); /* in case it didn't get pushed onto the stack. */ kldrDyldModDeref(pLoadedMod); } /* * Apply fixups. */ for (i = iLoad1st; !rc && i < iLoadEnd; i++) { PKLDRDYLDMOD pMod = g_papStackMods[i]; if ( pMod->enmState == KLDRSTATE_LOADED_PREREQUISITES || pMod->enmState == KLDRSTATE_RELOADED_LOADED_PREREQUISITES) rc = kldrDyldModFixup(pMod); } /* * Advance fixed up module onto initialization. */ for (i = iLoad1st; !rc && i < iLoadEnd; i++) { PKLDRDYLDMOD pMod = g_papStackMods[i]; if ( pMod->enmState == KLDRSTATE_FIXED_UP || pMod->enmState == KLDRSTATE_RELOADED_FIXED_UP) pMod->enmState = KLDRSTATE_PENDING_INITIALIZATION; KLDRDYLD_ASSERT( pMod->enmState == KLDRSTATE_PENDING_INITIALIZATION || pMod->enmState == KLDRSTATE_GOOD); } /* * Call the initializers if we're loading in recursive mode or * if we're the outermost load call. */ if (fFlags & KLDRDYLD_LOAD_FLAGS_RECURSIVE_INIT) { for (i = iLoad1st; !rc && i < iLoadEnd; i++) { PKLDRDYLDMOD pMod = g_papStackMods[i]; if (pMod->enmState == KLDRSTATE_PENDING_INITIALIZATION) rc = kldrDyldModCallInit(pMod); else if (pMod->enmState == KLDRSTATE_INITIALIZATION_FAILED) rc = KLDR_ERR_PREREQUISITE_MODULE_INIT_FAILED_ALREADY; else KLDRDYLD_ASSERT(g_papStackMods[i]->enmState == KLDRSTATE_GOOD); } #ifdef KLDRDYLD_STRICT for (i = iLoad1st; !rc && i < iLoadEnd; i++) KLDRDYLD_ASSERT(g_papStackMods[i]->enmState == KLDRSTATE_GOOD); #endif } else if (g_cActiveLoadCalls <= 1) { while (!rc && g_pkLdrDyldInitHead) { PKLDRDYLDMOD pMod = g_pkLdrDyldInitHead; g_pkLdrDyldInitHead = pMod->InitTerm.pNext; if (pMod->InitTerm.pNext) pMod->InitTerm.pNext->InitTerm.pPrev = NULL; else g_pkLdrDyldInitTail = NULL; pMod->fInitList = 0; rc = kldrDyldModCallInit(pMod); } } /* * Complete the load by incrementing the dynamic load count of the * requested module (return handle is already set). */ if (!rc) { if (fFlags & KLDRDYLD_LOAD_FLAGS_EXECUTABLE) { pLoadedMod->cDepRefs++; /* just make it stick. */ pLoadedMod->cRefs++; } else rc = kldrDyldModDynamicLoad(pLoadedMod); } kldrDyldStackDropFrame(iLoad1st, iLoadEnd, rc); return rc; } /** * kldrDyldDoLoad() helper which will load prerequisites and * build the initialization array / list. * * @returns 0 on success, non-zero error code on failure. * @param pMod The module to start at. * @param pszPrefix Prefix to use when searching. * @param pszSuffix Suffix to use when searching. * @param enmSearch Method to use when locating the module and any modules it may depend on. * @param fFlags Flags, a combintation of the KLDRYDLD_LOAD_FLAGS_* \#defines. */ static int kldrDyldDoLoadPrerequisites(PKLDRDYLDMOD pMod, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, unsigned fFlags) { static struct { /** The module. */ PKLDRDYLDMOD pMod; /** The number of prerequisite modules left to process. * This starts at ~0U to inidicate that we need to load/check prerequisistes. */ unsigned cLeft; } s_aEntries[64]; unsigned cEntries; int rc = 0; /* Prerequisites are always global and they just aren't executables. */ fFlags &= ~(KLDRYDLD_LOAD_FLAGS_SPECIFIC_MODULE | KLDRDYLD_LOAD_FLAGS_EXECUTABLE); /* push the first entry. */ s_aEntries[0].pMod = pMod; s_aEntries[0].cLeft = ~0U; cEntries = 1; /* * The recursion loop. */ while (!rc && cEntries > 0) { const unsigned i = cEntries - 1; pMod = s_aEntries[i].pMod; if (s_aEntries[i].cLeft == ~0U) { /* * Load prerequisite modules. */ switch (pMod->enmState) { /* * Load immediate prerequisite modules and push the ones needing * attention onto the stack. */ case KLDRSTATE_MAPPED: case KLDRSTATE_RELOADED: case KLDRSTATE_PENDING_TERMINATION: rc = kldrDyldModLoadPrerequisites(pMod, pszPrefix, pszSuffix, enmSearch, fFlags); KLDRDYLD_ASSERT( pMod->enmState == KLDRSTATE_GOOD || pMod->enmState == KLDRSTATE_RELOADED_LOADED_PREREQUISITES || pMod->enmState == KLDRSTATE_LOADED_PREREQUISITES || rc); if (!rc) s_aEntries[i].cLeft = pMod->cPrereqs; break; /* * Check its prerequisite modules the first time around. */ case KLDRSTATE_PENDING_INITIALIZATION: if (pMod->fAlreadySeen) break; pMod->fAlreadySeen = 1; s_aEntries[i].cLeft = pMod->cPrereqs; break; /* * These are ok. */ case KLDRSTATE_LOADED_PREREQUISITES: case KLDRSTATE_RELOADED_LOADED_PREREQUISITES: case KLDRSTATE_INITIALIZING: case KLDRSTATE_GOOD: s_aEntries[i].cLeft = 0; break; /* * All other stats are invalid. */ default: KLDRDYLD_ASSERT(!"invalid state"); break; } } else if (s_aEntries[i].cLeft > 0) { /* * Recurse down into the next prereq. */ KLDRDYLD_ASSERT(s_aEntries[i].cLeft <= pMod->cPrereqs); if (cEntries < sizeof(s_aEntries) / sizeof(s_aEntries[0])) { s_aEntries[cEntries].cLeft = ~(KU32)0; s_aEntries[cEntries].pMod = pMod->papPrereqs[pMod->cPrereqs - s_aEntries[i].cLeft]; s_aEntries[i].cLeft--; cEntries++; } else rc = KLDR_ERR_PREREQUISITE_RECURSED_TOO_DEEPLY; } else { /* * We're done with this module, record it for init/cleanup. */ cEntries--; if (pMod->enmState != KLDRSTATE_GOOD) { kldrDyldStackAddModule(pMod); if ( !(fFlags & KLDRDYLD_LOAD_FLAGS_RECURSIVE_INIT) && !pMod->fInitList) { pMod->fInitList = 1; pMod->InitTerm.pNext = NULL; pMod->InitTerm.pPrev = g_pkLdrDyldInitTail; if (g_pkLdrDyldInitTail) g_pkLdrDyldInitTail->InitTerm.pNext = pMod; else g_pkLdrDyldInitHead = pMod; g_pkLdrDyldInitTail = pMod; } } } } return rc; } /** * Gets prerequisite module. * * This will try load the requested module if necessary, returning it in the MAPPED state. * * @returns 0 on success. * @returns KLDR_ERR_MODULE_NOT_FOUND or I/O error on failure. * @param pszDll The name of the dll to look for. * @param pszPrefix Prefix than can be used when searching. * @param pszSuffix Suffix than can be used when searching. * @param enmSearch Method to use when locating the module. * @param fFlags Flags, a combintation of the KLDRYDLD_LOAD_FLAGS_* \#defines. * @param pDep The depentant module. * @param ppMod Where to put the module we get. */ int kldrDyldGetPrerequisite(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, unsigned fFlags, PKLDRDYLDMOD pDep, PPKLDRDYLDMOD ppMod) { int rc; PKLDRDYLDMOD pMod; *ppMod = NULL; /* * Try find the module among the ones that's already loaded. * * This is very similar to the kldrDyldDoLoad code, except it has to deal with * a couple of additional states and occurs only during prerequisite loading * and the action taken is a little bit different. */ rc = kldrDyldFindExistingModule(pszDll, pszPrefix, pszSuffix, enmSearch, fFlags, &pMod); if (!rc) { switch (pMod->enmState) { /* * These are good. */ case KLDRSTATE_MAPPED: case KLDRSTATE_RELOADED: case KLDRSTATE_LOADED_PREREQUISITES: case KLDRSTATE_RELOADED_LOADED_PREREQUISITES: case KLDRSTATE_PENDING_INITIALIZATION: case KLDRSTATE_INITIALIZING: case KLDRSTATE_GOOD: case KLDRSTATE_PENDING_TERMINATION: break; /* * The module has been terminated so it need to be reloaded, have it's * prereqs loaded, fixed up and initialized before we can use it again. */ case KLDRSTATE_PENDING_GC: rc = kldrDyldModReload(pMod); break; /* * The module can't be loaded because it failed to initialize already. */ case KLDRSTATE_INITIALIZATION_FAILED: rc = KLDR_ERR_PREREQUISITE_MODULE_INIT_FAILED; break; /* * Forget it, no idea how to deal with re-initialization. */ case KLDRSTATE_TERMINATING: return KLDR_ERR_PREREQUISITE_MODULE_TERMINATING; /* * Invalid state. */ default: KLDRDYLD_ASSERT(!"invalid state"); break; } } else { /* * We'll have to load it from file. */ rc = kldrDyldFindNewModule(pszDll, pszPrefix, pszSuffix, enmSearch, fFlags, &pMod); if (!rc) rc = kldrDyldModMap(pMod); } /* * On success add dependency. */ if (!rc) { kldrDyldModAddDep(pMod, pDep); *ppMod = pMod; } return rc; } /** * Starts a new load stack frame. * * @returns Where the new stack frame starts. * @param pLoadMod The module being loaded (only used for asserting). */ static KU32 kldrDyldStackNewFrame(PKLDRDYLDMOD pLoadMod) { /* * Clear the fAlreadySeen flags. */ PKLDRDYLDMOD pMod = kLdrDyldHead; while (pMod) { pMod->fAlreadySeen = 0; #ifdef KLDRDYLD_ASSERT switch (pMod->enmState) { case KLDRSTATE_MAPPED: case KLDRSTATE_RELOADED: /* only the just loaded module can be in this state. */ KLDRDYLD_ASSERT(pMod == pLoadMod); break; case KLDRSTATE_PENDING_INITIALIZATION: case KLDRSTATE_INITIALIZING: case KLDRSTATE_PENDING_TERMINATION: case KLDRSTATE_PENDING_GC: case KLDRSTATE_TERMINATING: case KLDRSTATE_INITIALIZATION_FAILED: case KLDRSTATE_PENDING_DESTROY: /* requires recursion. */ KLDRDYLD_ASSERT(g_cActiveLoadCalls + g_cActiveLoadCalls + g_fActiveGC > 1); break; case KLDRSTATE_GOOD: /* requires nothing. */ break; default: KLDRDYLD_ASSERT(!"Invalid state"); break; } #endif /* next */ pMod = pMod->Load.pNext; } return g_cStackMods; } /** * Records the module. * * @return 0 on success, KERR_NO_MEMORY if we can't expand the table. * @param pMod The module to record. */ static int kldrDyldStackAddModule(PKLDRDYLDMOD pMod) { /* * Grow the stack if necessary. */ if (g_cStackMods + 1 > g_cStackModsAllocated) { KU32 cNew = g_cStackModsAllocated ? g_cStackModsAllocated * 2 : 128; void *pvOld = g_papStackMods; void *pvNew = kHlpAlloc(cNew * sizeof(g_papStackMods[0])); if (!pvNew) return KERR_NO_MEMORY; kHlpMemCopy(pvNew, pvOld, g_cStackMods * sizeof(g_papStackMods[0])); g_papStackMods = (PPKLDRDYLDMOD)pvNew; kHlpFree(pvOld); } /* * Add a reference and push the module onto the stack. */ kldrDyldModAddRef(pMod); g_papStackMods[g_cStackMods++] = pMod; return 0; } /** * The frame has been completed. * * @returns Where the frame ends. */ static int kldrDyldStackFrameCompleted(void) { return g_cStackMods; } /** * Worker routine for kldrDyldStackDropFrame() and kldrDyldDoLoad(). * * @param pMod The module to perform cleanups on. * @param rc Used for state verification. */ static void kldrDyldStackCleanupOne(PKLDRDYLDMOD pMod, int rc) { switch (pMod->enmState) { /* * Just push it along to the PENDING_DESTROY state. */ case KLDRSTATE_MAPPED: KLDRDYLD_ASSERT(rc); kldrDyldModUnmap(pMod); KLDRDYLD_ASSERT(pMod->enmState == KLDRSTATE_PENDING_DESTROY); break; /* * Move back to PENDING_GC. */ case KLDRSTATE_RELOADED: KLDRDYLD_ASSERT(rc); pMod->enmState = KLDRSTATE_PENDING_GC; break; /* * Unload prerequisites and unmap the modules. */ case KLDRSTATE_LOADED_PREREQUISITES: case KLDRSTATE_FIXED_UP: KLDRDYLD_ASSERT(rc); kldrDyldModUnloadPrerequisites(pMod); KLDRDYLD_ASSERT(pMod->enmState == KLDRSTATE_PENDING_DESTROY); kldrDyldModUnmap(pMod); KLDRDYLD_ASSERT(pMod->enmState == KLDRSTATE_PENDING_DESTROY); break; /* * Unload prerequisites and push it back to PENDING_GC. */ case KLDRSTATE_RELOADED_LOADED_PREREQUISITES: case KLDRSTATE_RELOADED_FIXED_UP: kldrDyldModUnloadPrerequisites(pMod); KLDRDYLD_ASSERT(pMod->enmState == KLDRSTATE_PENDING_GC); break; /* * Nothing to do, just asserting sanity. */ case KLDRSTATE_INITIALIZING: /* Implies there is another load going on. */ KLDRDYLD_ASSERT(g_cActiveLoadCalls > 1); break; case KLDRSTATE_TERMINATING: /* GC in progress. */ KLDRDYLD_ASSERT(g_fActiveGC); break; case KLDRSTATE_PENDING_TERMINATION: case KLDRSTATE_PENDING_INITIALIZATION: case KLDRSTATE_PENDING_GC: case KLDRSTATE_PENDING_DESTROY: KLDRDYLD_ASSERT(rc); break; case KLDRSTATE_GOOD: break; /* * Bad states. */ default: KLDRDYLD_ASSERT(!"drop frame bad state (a)"); break; } } /** * Done with the stack frame, dereference all the modules in it. * * @param iLoad1st The start of the stack frame. * @param iLoadEnd The end of the stack frame. * @param rc Used for state verification. */ static void kldrDyldStackDropFrame(KU32 iLoad1st, KU32 iLoadEnd, int rc) { KU32 i; KLDRDYLD_ASSERT(iLoad1st <= g_cStackMods); KLDRDYLD_ASSERT(iLoadEnd == g_cStackMods); /* * First pass: Do all the cleanups we can, but don't destroy anything just yet. */ i = iLoadEnd; while (i-- > iLoad1st) { PKLDRDYLDMOD pMod = g_papStackMods[i]; kldrDyldStackCleanupOne(pMod, rc); } /* * Second pass: Release the references so modules pending destruction * can be completely removed. */ for (i = iLoad1st; i < iLoadEnd ; i++) { PKLDRDYLDMOD pMod = g_papStackMods[i]; /* * Revalidate the module state. */ switch (pMod->enmState) { case KLDRSTATE_INITIALIZING: case KLDRSTATE_TERMINATING: case KLDRSTATE_PENDING_TERMINATION: case KLDRSTATE_PENDING_INITIALIZATION: case KLDRSTATE_PENDING_GC: case KLDRSTATE_PENDING_DESTROY: case KLDRSTATE_GOOD: break; default: KLDRDYLD_ASSERT(!"drop frame bad state (b)"); break; } /* * Release it. */ kldrDyldModDeref(pMod); } /* * Drop the stack frame. */ g_cStackMods = iLoad1st; } /** * Do garbage collection. * * This isn't doing anything unless it's called from the last * load or unload call. */ static void kldrDyldDoModuleTerminationAndGarabageCollection(void) { PKLDRDYLDMOD pMod; /* * We don't do anything until we're got rid of all recursive calls. * This will ensure that we get the most optimal termination order and * that we don't unload anything too early. */ if (g_cActiveLoadCalls || g_cActiveUnloadCalls || g_fActiveGC) return; g_fActiveGC = 1; do { /* * 1. Release prerequisites for any left over modules. */ for (pMod = kLdrDyldHead; pMod; pMod = pMod->Load.pNext) { kldrDyldModAddRef(pMod); switch (pMod->enmState) { case KLDRSTATE_GOOD: case KLDRSTATE_PENDING_GC: case KLDRSTATE_PENDING_TERMINATION: break; case KLDRSTATE_INITIALIZATION_FAILED: /* just in case */ case KLDRSTATE_PENDING_INITIALIZATION: kldrDyldModUnloadPrerequisites(pMod); break; default: KLDRDYLD_ASSERT(!"invalid GC state (a)"); break; } kldrDyldModDeref(pMod); } /* * 2. Do init calls until we encounter somebody calling load/unload. */ for (pMod = g_pkLdrDyldTermHead; pMod; pMod = pMod->InitTerm.pNext) { int fRestart = 0; kldrDyldModAddRef(pMod); switch (pMod->enmState) { case KLDRSTATE_GOOD: case KLDRSTATE_PENDING_GC: break; case KLDRSTATE_PENDING_TERMINATION: { const KU32 cTotalLoadCalls = g_cTotalLoadCalls; const KU32 cTotalUnloadCalls = g_cTotalUnloadCalls; kldrDyldModCallTerm(pMod); fRestart = cTotalLoadCalls != g_cTotalLoadCalls || cTotalUnloadCalls != g_cTotalUnloadCalls; break; } default: KLDRDYLD_ASSERT(!"invalid GC state (b)"); break; } kldrDyldModDeref(pMod); if (fRestart) break; } } while (pMod); /* * Unmap and destroy modules pending for GC. */ pMod = kLdrDyldHead; while (pMod) { PKLDRDYLDMOD pNext = pMod->Load.pNext; kldrDyldModAddRef(pMod); switch (pMod->enmState) { case KLDRSTATE_INITIALIZATION_FAILED: case KLDRSTATE_PENDING_GC: KLDRDYLD_ASSERT(!pMod->cDepRefs); KLDRDYLD_ASSERT(!pMod->cDynRefs); pMod->enmState = KLDRSTATE_GC; kldrDyldModUnmap(pMod); KLDRDYLD_ASSERT(pMod->enmState == KLDRSTATE_PENDING_DESTROY); kldrDyldModDestroy(pMod); KLDRDYLD_ASSERT(pMod->enmState == KLDRSTATE_DESTROYED); break; case KLDRSTATE_GOOD: break; default: KLDRDYLD_ASSERT(!"invalid GC state (c)"); break; } kldrDyldModDeref(pMod); /* next */ pMod = pNext; } g_fActiveGC = 0; } /** * Worker for kLdrDyldUnload(). * @internal */ static int kldrDyldDoUnload(PKLDRDYLDMOD pMod) { return kldrDyldModDynamicUnload(pMod); } /** * Worker for kLdrDyldFindByName(). * @internal */ static int kldrDyldDoFindByName(const char *pszDll, const char *pszPrefix, const char *pszSuffix, KLDRDYLDSEARCH enmSearch, unsigned fFlags, PPKLDRDYLDMOD ppMod) { return kldrDyldFindExistingModule(pszDll, pszPrefix, pszSuffix, enmSearch, fFlags, ppMod); } /** * Worker for kLdrDyldFindByAddress(). * @internal */ static int kldrDyldDoFindByAddress(KUPTR Address, PPKLDRDYLDMOD ppMod, KU32 *piSegment, KUPTR *poffSegment) { /* Scan the segments of each module in the load list. */ PKLDRDYLDMOD pMod = kLdrDyldHead; while (pMod) { KU32 iSeg; for (iSeg = 0; iSeg < pMod->pMod->cSegments; iSeg++) { KLDRADDR off = (KLDRADDR)Address - pMod->pMod->aSegments[iSeg].MapAddress; if (off < pMod->pMod->aSegments[iSeg].cb) { *ppMod = pMod->hMod; if (piSegment) *piSegment = iSeg; if (poffSegment) *poffSegment = (KUPTR)off; return 0; } } /* next */ pMod = pMod->Load.pNext; } return KLDR_ERR_MODULE_NOT_FOUND; } /** * Worker for kLdrDyldGetName(). * @internal */ static int kldrDyldDoGetName(PKLDRDYLDMOD pMod, char *pszName, KSIZE cchName) { return kldrDyldModGetName(pMod, pszName, cchName); } /** * Worker for kLdrDyldGetFilename(). * @internal */ static int kldrDyldDoGetFilename(PKLDRDYLDMOD pMod, char *pszFilename, KSIZE cchFilename) { return kldrDyldModGetFilename(pMod, pszFilename, cchFilename); } /** * Worker for kLdrDyldQuerySymbol(). * @internal */ static int kldrDyldDoQuerySymbol(PKLDRDYLDMOD pMod, KU32 uSymbolOrdinal, const char *pszSymbolName, KUPTR *pValue, KU32 *pfKind) { return kldrDyldModQuerySymbol(pMod, uSymbolOrdinal, pszSymbolName, pValue, pfKind); } /** * Panic / failure * * @returns rc if we're in a position where we can return. * @param rc Return code. * @param pszFormat Message string. Limited fprintf like formatted. * @param ... Message string arguments. */ int kldrDyldFailure(int rc, const char *pszFilename, ...) { /** @todo print it. */ if (g_fBootstrapping); kHlpExit(1); return rc; } /** * Copies the error string to the user buffer. * * @returns rc. * @param rc The status code. * @param pszErr Where to copy the error string to. * @param cchErr The size of the destination buffer. */ static int kldrDyldCopyError(int rc, char *pszErr, KSIZE cchErr) { KSIZE cchToCopy; /* if no error string, format the rc into a string. */ if (!g_szkLdrDyldError[0] && rc) kHlpInt2Ascii(g_szkLdrDyldError, sizeof(g_szkLdrDyldError), rc, 10); /* copy it if we got something. */ if (cchErr && pszErr && g_szkLdrDyldError[0]) { cchToCopy = kHlpStrLen(g_szkLdrDyldError); if (cchToCopy >= cchErr) cchToCopy = cchErr - 1; kHlpMemCopy(pszErr, g_szkLdrDyldError, cchToCopy); pszErr[cchToCopy] = '\0'; } return rc; }
32.158278
129
0.596532
[ "object" ]
9ff5025387a439e25354c1396d344d8281b4d5b1
1,587
h
C
xlTetris/NullRenderer.h
cnsuhao/xlTetris
a3dbd9d085e67bbe5655086e48f67fd79d18e4b8
[ "MIT" ]
1
2021-06-03T07:19:54.000Z
2021-06-03T07:19:54.000Z
xlTetris/NullRenderer.h
cnsuhao/xlTetris
a3dbd9d085e67bbe5655086e48f67fd79d18e4b8
[ "MIT" ]
null
null
null
xlTetris/NullRenderer.h
cnsuhao/xlTetris
a3dbd9d085e67bbe5655086e48f67fd79d18e4b8
[ "MIT" ]
1
2021-06-03T07:19:56.000Z
2021-06-03T07:19:56.000Z
//-------------------------------------------------------------------- // // Copyright (C) Streamlet. All rights reserved. // // File Name: NullRenderer.h // Author: Streamlet // Create Time: 2015-04-03 // Description: // // Version history: // // //-------------------------------------------------------------------- #ifndef __NULLRENDERER_H_F649909F_9650_4919_972A_FA57CC1F92EA_INCLUDED__ #define __NULLRENDERER_H_F649909F_9650_4919_972A_FA57CC1F92EA_INCLUDED__ #include "Renderer.h" class NullRenderContext : public RenderContext { public: // RenderMethods methods void FillSolidRect(LPCRECT lpRect, const RGBQUAD &color) override; void DrawText(LPCTSTR lpszText, int cchText, LPCRECT lplpRectrc, UINT uFormat, const RGBQUAD &color) override; void DrawImage(HBITMAP hBitmap, LPCRECT lprcDest, LPCRECT lprcSource, BYTE byAlpha) override; void DrawImageGaussianBlur(HBITMAP hBitmap, LPCRECT lprcDest, LPCRECT lprcSource, BYTE byAlpha, BYTE byRadius) override; // RenderContext Methods bool Initialize() override; void Uninitialize() override; void BeginDraw() override; void EndDraw() override; }; class NullRenderer : public Renderer { public: // Render methods LPCTSTR GetName() override; bool Initialize() override; void Uninitialize() override; RenderContext *CreateContext(HWND hWnd) override; void ReleaseContext(RenderContext *pContext) override; }; #endif // #ifndef __NULLRENDERER_H_F649909F_9650_4919_972A_FA57CC1F92EA_INCLUDED__
32.387755
125
0.662256
[ "render" ]
9ff7d41f325c8cc498e343ba46d40f5d0c934d9e
2,256
h
C
emr/include/alibabacloud/emr/model/ListFlowJobHistoryResult.h
iamzken/aliyun-openapi-cpp-sdk
3c991c9ca949b6003c8f498ce7a672ea88162bf1
[ "Apache-2.0" ]
89
2018-02-02T03:54:39.000Z
2021-12-13T01:32:55.000Z
emr/include/alibabacloud/emr/model/ListFlowJobHistoryResult.h
sdk-team/aliyun-openapi-cpp-sdk
d0e92f6f33126dcdc7e40f60582304faf2c229b7
[ "Apache-2.0" ]
89
2018-03-14T07:44:54.000Z
2021-11-26T07:43:25.000Z
emr/include/alibabacloud/emr/model/ListFlowJobHistoryResult.h
sdk-team/aliyun-openapi-cpp-sdk
d0e92f6f33126dcdc7e40f60582304faf2c229b7
[ "Apache-2.0" ]
69
2018-01-22T09:45:52.000Z
2022-03-28T07:58:38.000Z
/* * Copyright 2009-2017 Alibaba Cloud All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ALIBABACLOUD_EMR_MODEL_LISTFLOWJOBHISTORYRESULT_H_ #define ALIBABACLOUD_EMR_MODEL_LISTFLOWJOBHISTORYRESULT_H_ #include <string> #include <vector> #include <utility> #include <alibabacloud/core/ServiceResult.h> #include <alibabacloud/emr/EmrExport.h> namespace AlibabaCloud { namespace Emr { namespace Model { class ALIBABACLOUD_EMR_EXPORT ListFlowJobHistoryResult : public ServiceResult { public: struct NodeInstance { std::string failAct; long endTime; std::string nodeName; long gmtModified; std::string jobName; std::string externalStatus; std::string paramConf; std::string externalInfo; int retries; std::string jobId; std::string jobParams; std::string hostName; std::string status; std::string clusterId; std::string externalId; std::string projectId; long startTime; int maxRetry; long gmtCreate; std::string type; std::string jobType; std::string envConf; std::string id; long retryInterval; std::string runConf; bool pending; }; ListFlowJobHistoryResult(); explicit ListFlowJobHistoryResult(const std::string &payload); ~ListFlowJobHistoryResult(); int getPageSize()const; int getPageNumber()const; int getTotal()const; std::vector<NodeInstance> getNodeInstances()const; protected: void parse(const std::string &payload); private: int pageSize_; int pageNumber_; int total_; std::vector<NodeInstance> nodeInstances_; }; } } } #endif // !ALIBABACLOUD_EMR_MODEL_LISTFLOWJOBHISTORYRESULT_H_
26.232558
80
0.708333
[ "vector", "model" ]
9ff84dc220fe7b8a2b6abe891ed2108ae9da55b7
2,005
h
C
wdbecmbd/WdbeMtpPlhfpga/WdbeMtpPlhfpga_blks.h
mpsitech/wdbe-WhizniumDBE
27360ce6569dc55098a248b8a0a4b7e3913a6ce6
[ "MIT" ]
4
2020-10-27T14:33:25.000Z
2021-08-07T20:55:42.000Z
wdbecmbd/WdbeMtpPlhfpga/WdbeMtpPlhfpga_blks.h
mpsitech/wdbe-WhizniumDBE
27360ce6569dc55098a248b8a0a4b7e3913a6ce6
[ "MIT" ]
null
null
null
wdbecmbd/WdbeMtpPlhfpga/WdbeMtpPlhfpga_blks.h
mpsitech/wdbe-WhizniumDBE
27360ce6569dc55098a248b8a0a4b7e3913a6ce6
[ "MIT" ]
null
null
null
/** * \file WdbeMtpPlhfpga_blks.h * invocation / return data blocks for operation pack WdbeMtpPlhfpga (declarations) * \copyright (C) 2016-2020 MPSI Technologies GmbH * \author Alexander Wirthmueller (auto-generation) * \date created: 28 Nov 2020 */ // IP header --- ABOVE #ifndef WDBEMTPPLHFPGA_BLKS_H #define WDBEMTPPLHFPGA_BLKS_H #include "Wdbe.h" /** * DpchInvWdbeMtpPlhfpga */ class DpchInvWdbeMtpPlhfpga : public DpchInvWdbe { public: static const Sbecore::uint SCROREF = 1; static const Sbecore::uint OREF = 1; static const Sbecore::uint SCRJREF = 2; static const Sbecore::uint JREF = 2; static const Sbecore::uint SREFKCUSTOP = 3; static const Sbecore::uint REFWDBEMMODULE = 4; public: DpchInvWdbeMtpPlhfpga(const Sbecore::ubigint oref = 0, const std::string& srefKCustop = "", const Sbecore::ubigint jref = 0, const Sbecore::ubigint refWdbeMModule = 0); public: std::string srefKCustop; Sbecore::ubigint refWdbeMModule; public: void readXML(xmlXPathContext* docctx, std::string basexpath = "", bool addbasetag = false); void writeXML(xmlTextWriter* wr); }; /** * DpchRetWdbeMtpPlhfpga */ class DpchRetWdbeMtpPlhfpga : public DpchRetWdbe { public: static const Sbecore::uint SCROREF = 1; static const Sbecore::uint OREF = 1; static const Sbecore::uint SCRJREF = 2; static const Sbecore::uint JREF = 2; static const Sbecore::uint IXOPVOPRES = 3; static const Sbecore::uint PDONE = 4; static const Sbecore::uint KEYS = 5; static const Sbecore::uint VALS = 6; public: DpchRetWdbeMtpPlhfpga(const std::string& scrOref = "", const std::string& scrJref = "", const Sbecore::uint ixOpVOpres = 0, const Sbecore::utinyint pdone = 0, const std::vector<std::string>& keys = {}, const std::vector<std::string>& vals = {}); public: std::vector<std::string> keys; std::vector<std::string> vals; public: void readXML(xmlXPathContext* docctx, std::string basexpath = "", bool addbasetag = false); void writeXML(xmlTextWriter* wr); }; // IP cust --- INSERT #endif
28.239437
246
0.727681
[ "vector" ]
b0023df07a35ae1917833307314eef05fc5b7815
1,050
h
C
src/xg/font_loader.h
kctan0805/xg
2935d0c7dac442b007cbf50b81ecd10a470dd087
[ "MIT" ]
6
2019-12-05T08:01:54.000Z
2019-12-14T09:37:11.000Z
src/xg/font_loader.h
kctan0805/xg
2935d0c7dac442b007cbf50b81ecd10a470dd087
[ "MIT" ]
null
null
null
src/xg/font_loader.h
kctan0805/xg
2935d0c7dac442b007cbf50b81ecd10a470dd087
[ "MIT" ]
1
2019-12-05T22:55:22.000Z
2019-12-05T22:55:22.000Z
// xg - XML Graphics Engine // Copyright (c) Jim Tan // // Free use of the XML Graphics Engine is // permitted under the guidelines and in accordance with the most // current version of the MIT License. // http://www.opensource.org/licenses/MIT #ifndef XG_FONT_LOADER_H_ #define XG_FONT_LOADER_H_ #include <memory> #include <string> #include <vector> #include "xg/layout.h" #include "xg/queue.h" #include "xg/resource_loader.h" #include "xg/types.h" namespace xg { struct FontLoaderInfo { LayoutOverlay* loverlay = nullptr; AccessFlags dst_access_mask = AccessFlags::kShaderRead; ImageLayout new_layout = ImageLayout::kShaderReadOnlyOptimal; Queue* dst_queue = nullptr; PipelineStageFlags dst_stage_mask = PipelineStageFlags::kFragmentShader; }; class FontLoader : public ResourceLoader { public: static std::shared_ptr<FontLoader> Load(const FontLoaderInfo& info); void Run(std::shared_ptr<Task> self) override; void Finish() override; protected: FontLoaderInfo info_; }; } // namespace xg #endif // XG_FONT_LOADER_H_
23.863636
74
0.75619
[ "vector" ]
b00db09020e0fa39e86f5929d71726d0d1a71efb
7,923
c
C
base/ntos/ke/timersup.c
987432340/wrk-v1.2
423d4c22b892bcc97778385bc0a646ed7a3cfbde
[ "Intel" ]
1
2022-03-12T13:57:18.000Z
2022-03-12T13:57:18.000Z
base/ntos/ke/timersup.c
987432340/wrk-v1.2
423d4c22b892bcc97778385bc0a646ed7a3cfbde
[ "Intel" ]
null
null
null
base/ntos/ke/timersup.c
987432340/wrk-v1.2
423d4c22b892bcc97778385bc0a646ed7a3cfbde
[ "Intel" ]
1
2021-11-25T08:18:04.000Z
2021-11-25T08:18:04.000Z
/*++ Copyright (c) Microsoft Corporation. All rights reserved. You may only use this code if you agree to the terms of the Windows Research Kernel Source Code License agreement (see License.txt). If you do not agree to the terms, do not use the code. Module Name: timersup.c Abstract: This module contains the support routines for the timer object. It contains functions to insert and remove from the timer queue. --*/ #include "ki.h" VOID FASTCALL KiCompleteTimer ( __inout PKTIMER Timer, __inout PKSPIN_LOCK_QUEUE LockQueue ) /*++ Routine Description: This function completes a timer that could not be inserted in the timer table because its due time has already passed. N.B. This function must be called with the corresponding timer table entry locked at raised IRQL. N.B. This function returns with no locks held at raised IRQL. Arguments: Timer - Supplies a pointer to a dispatcher object of type timer. LockQueue - Supplies a pointer to a timer table lock queue entry. Return Value: None. -*/ { LIST_ENTRY ListHead; BOOLEAN RequestInterrupt; // // Remove the timer from the specified timer table list and insert // the timer in a dummy list in case the timer is cancelled while // releasing the timer table lock and acquiring the dispatcher lock. // KiRemoveEntryTimer(Timer); ListHead.Flink = &Timer->TimerListEntry; ListHead.Blink = &Timer->TimerListEntry; Timer->TimerListEntry.Flink = &ListHead; Timer->TimerListEntry.Blink = &ListHead; KiReleaseTimerTableLock(LockQueue); RequestInterrupt = FALSE; KiLockDispatcherDatabaseAtSynchLevel(); // // If the timer has not been removed from the dummy list, then signal // the timer. // if (ListHead.Flink != &ListHead) { RequestInterrupt = KiSignalTimer(Timer); } // // Release the dispatcher lock and request a DPC interrupt if required. // KiUnlockDispatcherDatabaseFromSynchLevel(); if (RequestInterrupt == TRUE) { KiRequestSoftwareInterrupt(DISPATCH_LEVEL); } return; } LOGICAL FASTCALL KiInsertTimerTable ( IN PKTIMER Timer, IN ULONG Hand ) /*++ Routine Description: This function inserts a timer object in the timer table. N.B. This routine assumes that the timer table lock has been acquired. Arguments: Timer - Supplies a pointer to a dispatcher object of type timer. Hand - supplies the timer table hand value. Return Value: If the timer has expired, than a value of TRUE is returned. Otherwise, a value of FALSE is returned. --*/ { ULONG64 DueTime; LOGICAL Expired; ULARGE_INTEGER InterruptTime; PLIST_ENTRY ListHead; PLIST_ENTRY NextEntry; PKTIMER NextTimer; // // Set the signal state to FALSE if the period is zero. // // N.B. The timer state is set to inserted. // Expired = FALSE; if (Timer->Period == 0) { Timer->Header.SignalState = FALSE; } // // If the timer is due before the first entry in the computed list // or the computed list is empty, then insert the timer at the front // of the list and check if the timer has already expired. Otherwise, // insert then timer in the sorted order of the list searching from // the back of the list forward. // // N.B. The sequence of operations below is critical to avoid the race // condition that exists between this code and the clock interrupt // code that examines the timer table lists to detemine when timers // expire. // DueTime = Timer->DueTime.QuadPart; ASSERT(Hand == KiComputeTimerTableIndex(DueTime)); ListHead = &KiTimerTableListHead[Hand].Entry; NextEntry = ListHead->Blink; while (NextEntry != ListHead) { // // Compute the maximum search count. // NextTimer = CONTAINING_RECORD(NextEntry, KTIMER, TimerListEntry); if (DueTime >= (ULONG64)NextTimer->DueTime.QuadPart) { break; } NextEntry = NextEntry->Blink; } InsertHeadList(NextEntry, &Timer->TimerListEntry); if (NextEntry == ListHead) { // // The computed list is empty or the timer is due to expire before // the first entry in the list. // // Make sure the writes for the update of the due time table are done // before reading the interrupt time. // KiTimerTableListHead[Hand].Time.QuadPart = DueTime; KeMemoryBarrier(); KiQueryInterruptTime((PLARGE_INTEGER)&InterruptTime); if (DueTime <= (ULONG64)InterruptTime.QuadPart) { Expired = TRUE; } } return Expired; } BOOLEAN FASTCALL KiSignalTimer ( __inout PKTIMER Timer ) /*++ Routine Description: This function signals a timer that could not be inserted in the timer table because its due time has already passed. N.B. This function must be called with the dispatcher database locked at at raised IRQL. Arguments: Timer - Supplies a pointer to a dispatcher object of type timer. Return Value: If a software interrupt should be requested, then TRUE is returned. Otherwise, a value of FALSE is returned. -*/ { PKDPC Dpc; LARGE_INTEGER Interval; LONG Period; BOOLEAN RequestInterrupt; LARGE_INTEGER SystemTime; // // Set time timer state to not inserted and the signal state to signaled. // RequestInterrupt = FALSE; Timer->Header.Inserted = FALSE; Timer->Header.SignalState = 1; // // Capture the DPC and period fields from the timer object. Once wait // test is called, the timer must not be touched again unless it is // periodic. The reason for this is that a thread may allocate a timer // on its local stack and wait on it. Wait test can cause that thread // to immediately start running on another processor on an MP system. // If the thread returns, then the timer will be corrupted. // Dpc = Timer->Dpc; Period = Timer->Period; if (IsListEmpty(&Timer->Header.WaitListHead) == FALSE) { if (Timer->Header.Type == TimerNotificationObject) { KiWaitTestWithoutSideEffects(Timer, TIMER_EXPIRE_INCREMENT); } else { KiWaitTestSynchronizationObject(Timer, TIMER_EXPIRE_INCREMENT); } } // // If the timer is periodic, then compute the next interval time and // reinsert the timer in the timer tree. // // N.B. Even though the timer insertion is relative, it can still fail // if the period of the timer elapses in between computing the time // and inserting the timer. If this happens, then the insertion is // retried. // if (Period != 0) { Interval.QuadPart = Int32x32To64(Period, - 10 * 1000); do { } while (KiInsertTreeTimer(Timer, Interval) == FALSE); } // // If a DPC is specified, then insert it in the target processor's DPC // queue or capture the parameters in the DPC table for subsequent // execution on the current processor. // // N.B. A dispatch interrupt must be forced on the current processor, // however, this will occur very infrequently. // if (Dpc != NULL) { KiQuerySystemTime(&SystemTime); KeInsertQueueDpc(Dpc, ULongToPtr(SystemTime.LowPart), ULongToPtr(SystemTime.HighPart)); RequestInterrupt = TRUE; } return RequestInterrupt; }
26.676768
133
0.635365
[ "object" ]
b0134806ef99e7f2672aab21afc80fbb38de8e8d
2,304
h
C
core/settings_interface.h
konstantin-fedorov/PROWOGENE
6aebbdea88015bd186ed16cc0b6d2a845bcf7fed
[ "MIT" ]
3
2020-02-22T18:34:17.000Z
2021-05-06T07:40:14.000Z
core/settings_interface.h
konstantin-fedorov/PROWOGENE
6aebbdea88015bd186ed16cc0b6d2a845bcf7fed
[ "MIT" ]
null
null
null
core/settings_interface.h
konstantin-fedorov/PROWOGENE
6aebbdea88015bd186ed16cc0b6d2a845bcf7fed
[ "MIT" ]
null
null
null
#ifndef PROWOGENE_CORE_SETTINGS_INTERFACE_H_ #define PROWOGENE_CORE_SETTINGS_INTERFACE_H_ #include <stdexcept> #include "utils/json.h" namespace prowogene { /** @brief Excteption that will be thrown if any troubles are detected when processing settings or module execution. Other exceptions like (std::bad_alloc) will not be modified and will be presented as-is. */ class LogicException : public std::logic_error { public: LogicException(const std::string& msg) : std::logic_error(msg) { } }; /** @brief Settings interface which describes preferences storage. Allows to integrate settings to generator. Can be filled from and saved to JSON file. All module's settings must be inside root JSON object, placed in separate JSON object and named by their name. */ struct ISettings { /** Fill all values from config. If there are missings, settings will be set to default type value (not default setting!). @param [in] config - JSON object with settings. */ virtual void Deserialize(utils::JsonObject config) = 0; /** Save all values to JSON config. @return JSON object with settings. */ virtual utils::JsonObject Serialize() const = 0; /** Get setting's name that must be unique. That key is name of JSON object and also the key that used for settings connection with modules. @return Text name. */ virtual std::string GetName() const = 0; /** Check settings for correctness. @return @c true if all settings are filled correctly, @c false otherwise. */ virtual void Check() const { } protected: static void CheckCondition(bool cond, const std::string& text_cond_fail) { if (!cond) { throw LogicException(text_cond_fail); } } template <typename T> static void CheckInRange(T val, T min, T max, const std::string& var_name) { if ((val < min) || (val > max)) { std::string msg = "'" + var_name + "' must be in range [" + std::to_string(min) + ", " + std::to_string(max) + "]. Presented: " + std::to_string(val); throw LogicException(msg); } } }; } // namespace prowogene #endif // PROWOGENE_CORE_SETTINGS_INTERFACE_H_
34.909091
81
0.651476
[ "object" ]