blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
sequencelengths
1
1
author_id
stringlengths
0
158
0747ba462e4df4374889a7d871d4ec5ebd680bd4
13bed30fd2f729cbcafc319c62ab6b0a65ab8863
/georgelok-cs207-sbalanovichs-georgelok-cs207/mesh_mass_spring.cpp
933363a10980f0000ec851a3010d97973defd99d
[]
no_license
jonahkall/JBParallel
eac0cd9c96d3a1de0378e1ca6bcf60c6ba7e007f
256492adac0320be836916e2cd38887f13048e25
refs/heads/master
2016-09-05T18:18:40.119827
2014-12-16T03:44:24
2014-12-16T03:44:24
27,520,312
1
0
null
null
null
null
UTF-8
C++
false
false
17,608
cpp
/** * @file mesh_mass_spring.cpp * Implementation of mass-spring system using Mesh * * @brief Reads in two files specified on the command line. * First file: 3D Points (one per line) defined by three doubles * Second file: Tetrahedra (one per line) defined by 4 indices into the point * list */ #include <fstream> #include "CS207/SDLViewer.hpp" #include "CS207/Util.hpp" #include "CS207/Color.hpp" #include "Mesh.hpp" #include "Point.hpp" #include "../jb_parallel.hpp" #include <omp.h> // Gravity in meters/sec^2 static constexpr double grav = 9.81; static constexpr double K = 100.; static constexpr double C = 30.; /** Custom structure of data to store with Nodes */ struct NodeData { Point velocity; //< Node velocity double mass; //< Node mass }; typedef Mesh<NodeData, double, int> MeshType; typedef typename MeshType::node_type Node; typedef typename MeshType::edge_type Edge; typedef typename MeshType::triangle_type Triangle; template <typename F> struct vmod { F force; double dt; double t; void operator () (Node n) { // n.value().velocity += force(n, t) * (dt / n.value().mass); } vmod(F forcei, double dti, double ti) : force(forcei), dt(dti), t(ti) {}; }; template <typename F> struct pmod { double dt; void operator () (Node n) { n.position() += n.value().value_.velocity * dt; } pmod(double dti) : dt(dti) {}; }; // template<typename Tri> // struct msv_mod { // volume // void operator () (Tri t) { // double volume = 0.; // Point sn = t.surface_normal(); // int val = t.value(); // if ((sn.z < 0 && val > 0) || (sn.z > 0 && val < 0)) // sn *= -1; // // Increment the volume // volume += (sn.z * val * t.area()) * // ((t.node(0).position().z + // t.node(1).position().z + // t.node(2).position().z) / 3.); // } // }; /** Change a mesh's nodes according to a step of the symplectic Euler * method with the given node force. * @param[in,out] m Mesh * @param[in] t The current time (useful for time-dependent forces) * @param[in] dt The time step * @param[in] force Function object defining the force per node * @return the next time step (usually @a t + @a dt) * * @tparam G::node_value_type supports any struct with velocity and mass * @tparam F is a function object called as @a force(n, @a t), * where n is a node of the mesh and @a t is the current time. * @a force must return a Point representing the force vector on Node * at time @a t. */ template <typename M, typename F, typename C> double symp_euler_step(M& m, double t, double dt, F force, C constraints) { // Compute the {n+1} node positions /*for (auto it = m.node_begin(); it != m.node_end(); ++it) { auto n = *it; // Update the position of the node according to its velocity // x^{n+1} = x^{n} + v^{n} * dt n.position() += n.value().value_.velocity * dt; }*/ pmod<F> pm(dt); jb_parallel::for_each(m.node_begin(), m.node_end(), pm); // Enfore constraints after position update but before force calculation. constraints(m, t); // Compute the {n+1} node velocities for (auto it = m.node_begin(); it != m.node_end(); ++it) { auto n = *it; // v^{n+1} = v^{n} + F(x^{n+1},t) * dt / m n.value().value_.velocity += force(n, t) * (dt / n.value().value_.mass); } return t + dt; } /** Set the direction flags on each triangle in order to * keep track of the direction in which they are facing * @param[in] mesh, the current Mesh * * @pre: @a mesh is a valid mesh * @post: for i in range(mesh), i.value() = -1 if i faces away from center and 1 otherwise * * Complexity: O(n) */ template <typename M> void set_tri_directions(M& mesh) { // Set flags for surface normals // Approximate center of sphere Point sphere_center = Point(0,0,0); for (auto it = mesh.node_begin(); it != mesh.node_end(); ++it) { sphere_center += (*it).position(); } sphere_center /= mesh.num_nodes(); for(auto it = mesh.triangle_begin(); it != mesh.triangle_end(); ++it) { // Approximate center of triangle auto tri = (*it); Point tri_center = Point(0,0,0); for(unsigned i = 0; i < 3; ++i) { tri_center += tri.node(i).position(); } tri_center /= 3.0; // Determine direction of surface normal. Point d_vector = tri_center - sphere_center; if(d_vector.z * tri.surface_normal().z > 0) { tri.value() = 1; } else { tri.value() = -1; } } } /** A boolean functor that compares two nodes * based on their velocity values and returns true * if the first node's velocity is smaller than the * second one's */ struct VelComparator { template <typename Node> bool operator()(const Node& n1, const Node& n2) const { return (norm(n1.value().value_.velocity) < norm(n2.value().value_.velocity)); } }; /** A NodeColor functor that colors nodes based off * of node velocities */ struct VelHeatMap { public: template <typename Node> // Returns a heat value for a node based off velocity(n) CS207::Color operator()(const Node& n) const { return CS207::Color::make_heat( norm(n.value().value_.velocity)/max_vel_); } /* Constructor */ VelHeatMap(double max_vel) : max_vel_(max_vel) {} private: const double max_vel_; }; struct volume_inc { double operator () (Triangle t) { double volume = 0.; Point sn = t.surface_normal(); int val = t.value(); if ((sn.z < 0 && val > 0) || (sn.z > 0 && val < 0)) sn *= -1; // Increment the volume volume += (sn.z * val * t.area()) * ((t.node(0).position().z + t.node(1).position().z + t.node(2).position().z) / 3.); return volume; } }; /** Calculate the volume of the mesh shape * @param[in] m, the Mesh * * @return the volume of the mesh * * Complexity: O(n) */ template <typename M> double mesh_shape_volume(M* m) { double volume = 0.; volume_inc vi; jb_parallel::parallel_reduction(m->triangle_begin(), m->triangle_end(), vi, volume); return volume; } /** Air Pressure force functor for the mesh. * Return the force being applied to @a n at time @a t. */ struct AirPressureForce { // Constructor. Establishes the current sphere's volume AirPressureForce(double volume) : volume_(volume) {} // Return the air pressure force being applied to @a n at time @a t. Point operator()(Node n, double t) { (void) t; Point n_i = Point(0,0,0); for(unsigned i = 0; i < n.value().neighbor_triangles_.size(); ++i) { auto tri = n.value().neighbor_triangle(i); n_i += (C) * tri.area() * tri.value() * tri.surface_normal(); } return n_i; } private: double volume_; }; /** Gravity force functor for the mesh. * Return the force being applied to @a n at time @a t. */ struct GravityForce { Point operator()(Node n, double t) { (void) t; return Point(0,0, -grav * n.value().value_.mass); } }; /** Mass spring force functor for the mesh. * Return the force being applied to @a n at time @a t. */ struct MassSpringForce { Point operator()(Node n, double t) { (void) t; // initialize force Point force = Point(0,0,0); // calculate spring force for(auto it = n.edge_begin(); it != n.edge_end(); ++it) { MeshType::edge_type temp_edge = *it; MeshType::node_type temp_node = temp_edge.node2(); Point diff = n.position() - temp_node.position(); force += (-K) * (diff) / norm(diff) * (norm(diff) - temp_edge.value().value_); } return force; } }; /** Wind force functor for the mesh. * Return the force being applied to @a n at time @a t. */ struct WindForce { // Constructor. Establishes constants for interaction and air velocty WindForce(const double& c, const double& w) : c_(c), w_(w) {}; // Return the wind force being applied to @a n at time @a t. Point operator()(Node n, double t) { (void) t; // initialize, calculate, and normalize the n_i surface normal Point n_i = Point(0,0,0); for(unsigned i = 0; i < n.value().neighbor_triangles_.size(); ++i) { n_i += n.value().neighbor_triangle(i).surface_normal(); } // n_i = n_i /norm(n_i); // return the force based on the wind formula return c_ * ((w_ - n.value().value_.velocity) * n_i) * n_i; } private: double c_; double w_; }; /** Damping force functor for the mesh. * Return the force being applied to @a n at time @a t. */ struct DampingForce { double c_; // Constructor. Establishes constant for damping. DampingForce(const double& c) : c_(c) {}; // Return the damping force being applied to @a n at time @a t. Point operator()(Node n, double t) { (void) t; return -c_ * n.value().value_.velocity; } }; /** MetaForce construction as shown in class * Constructs a new force given two forces. * @param[in] force_1 First force * @param[in] force_2 Second force * * @return a function object such output() = force_1_() + force_2_() * * @tparam force_1, force_2 are function objects called as @a force_#(n, @a t), * where n is a node of the mesh and @a t is the current time. * @a force must return a Point representing the force vector on Node * at time @a t. */ template<typename F1, typename F2> struct MetaForce { Point operator()(Node n, double t) { return force_1_(n, t) + force_2_(n, t); } MetaForce(F1 force_1, F2 force_2) : force_1_(force_1), force_2_(force_2) { } private: F1 force_1_; F2 force_2_; }; /** Combines two forces to create a new force * * @pre Inputs can be called as @a fun(n, @a t), * where n is a node and t is time. * Returns a MetaForce */ template<typename F1, typename F2> MetaForce<F1, F2> make_combined_force(F1 force_1, F2 force_2) { return MetaForce<F1, F2>(force_1, force_2); } /** Combines three forces to create a new force * * @pre Inputs can be called as @a fun(n, @a t), * where n is a node and t is time. * Returns a MetaForce */ template<typename F1, typename F2, typename F3> MetaForce<F1, MetaForce<F2, F3>> make_combined_force(F1 force_1, F2 force_2, F3 force_3) { MetaForce<F2, F3> f2_f3_combo = MetaForce<F2, F3>(force_2, force_3); return MetaForce<F1, MetaForce<F2, F3>>(force_1, f2_f3_combo); } /** Checks nodes in the graph to see if they are at a certain point and fixes them * @post n.position() == n.position() is true for all nodes at (0,0,0) and (0,0,1) * O(n) time * */ template <typename G> struct FixedConstraint { void operator()(G& g, double t) { (void) t; for(auto it = g.node_begin(); it != g.node_end(); ++it) { if((*it).position() == Point(0,0,0) || (*it).position() == Point(1,0,0) ) { (*it).value().value_.velocity = Point(0,0,0); } } } }; /** Constrains points to be above z = -0.75 * O(N) Time */ template <typename M> struct PlaneConstraint { void operator()(M& m, double t) { (void) t; for(auto it = m.node_begin(); it != m.node_end(); ++it) { if (dot((*it).position(), Point(0,0,1)) < -2) { (*it).position().z = -2; (*it).value().value_.velocity.z = 0; } } } }; /** Constrains points to be outside sphere of radius r with center c * O(N) Time */ template <typename M> struct SphereConstraint { SphereConstraint(Point c, double r) : c_(c), r_(r) {} void operator()(M& m, double t) { (void) t; for(auto it = m.node_begin(); it != m.node_end(); ++it) { if ( norm((*it).position() - c_) < r_ ) { Point Ri = ((*it).position() - c_) / norm((*it).position() - c_); (*it).position() = Ri * 0.15 + c_; (*it).value().value_.velocity -= dot((*it).value().value_.velocity, Ri)*Ri; } } } private: Point c_; double r_; }; /** Constrains points to radius of r * O(N) Time */ template <typename M> struct BallConstraint { // Constructor. Establishes the ball radius constant BallConstraint(double r) : r_(r) {} void operator()(M& m, double t) { (void) t; Point sphere_center = Point(0,0,0); // Calculate center of sphere for(auto it = m.node_begin(); it != m.node_end(); ++it) { sphere_center += (*it).position(); } sphere_center /= m.num_nodes(); // Constrain nodes to a particular radius. for(auto it = m.node_begin(); it != m.node_end(); ++it) { Point vector = (*it).position() - sphere_center; if(norm(vector) > r_) { vector = vector / norm(vector) * r_; (*it).position() = vector + sphere_center; } } } private: double r_; }; /** MetaConstraint in the same vein as the MetaForce * Constructs a new constraint given two constraints. * @param[in] constraint_1 First constraint * @param[in] constraint_2 Second constraint * * @return a function object such output() = constraint_1_() + constraint_2_() * * @tparam constraint_1, constraint_2 are function objects called as @a pconstraint_#(g, @a t), * where g is a mesh and @a t is the current time. * no return value */ template<typename M, typename C1, typename C2> struct MetaConstraint { void operator()(M& m, double t) { constraint_1_(m, t); constraint_2_(m, t); } MetaConstraint(C1 constraint_1, C2 constraint_2) : constraint_1_(constraint_1), constraint_2_(constraint_2) { } C1 constraint_1_; C2 constraint_2_; }; /** Combines two constraints to create a new constraint * * @pre Inputs can be called as @a fun(g, @a t), * where g is a node and t is time. * Returns a MetaConstraint */ template<typename C1, typename C2, typename M = MeshType> MetaConstraint<M, C1, C2> make_combined_constraint(C1 constraint_1, C2 constraint_2) { return MetaConstraint<M, C1, C2>(constraint_1, constraint_2); } /** Combines three constraints to create a new constraint * * @pre Inputs can be called as @a fun(g, @a t), * where g is a node and t is time. * Returns a MetaConstraint */ template<typename C1, typename C2, typename C3, typename M = MeshType> MetaConstraint<M, C1, MetaConstraint<M, C2, C3>> make_combined_constraint(C1 constraint_1, C2 constraint_2, C3 constraint_3) { MetaConstraint<M, C2, C3> c2_c3_combo = MetaConstraint<M, C2, C3>(constraint_2, constraint_3); return MetaConstraint<M, C1, MetaConstraint<M, C2, C3>>(constraint_1, c2_c3_combo); } int main(int argc, char** argv) { // Check arguments if (argc < 3) { std::cerr << "Usage: " << argv[0] << " NODES_FILE TETS_FILE\n"; exit(1); } // Construct a mesh MeshType mesh; std::vector<typename MeshType::node_type> mesh_node; // Read all Points and add them to the Mesh std::ifstream nodes_file(argv[1]); Point p; while (CS207::getline_parsed(nodes_file, p)) { mesh_node.push_back(mesh.add_node(p)); } // Read all mesh triangles and add them to the Mesh std::ifstream tris_file(argv[2]); std::array<int,3> t; while (CS207::getline_parsed(tris_file, t)) { mesh.add_triangle(mesh_node[t[0]], mesh_node[t[1]], mesh_node[t[2]]); } // Zero intial velocities and have constant density. for(MeshType::node_iterator it = mesh.node_begin(); it != mesh.node_end(); ++it) { MeshType::node_type temp_node = *it; temp_node.value().value_.velocity = Point(0,0,0); temp_node.value().value_.mass = 1 / double(mesh.num_nodes()); } // Set initial lengths to initial distances. for(MeshType::edge_iterator it = mesh.edge_begin(); it != mesh.edge_end(); ++it) { MeshType::edge_type temp_edge = *it; temp_edge.value().value_ = temp_edge.length(); } // Print out the stats //std::cout << mesh.num_nodes() << " " << mesh.num_edges() << std::endl; // Launch the SDLViewer //CS207::SDLViewer viewer; //auto node_map = viewer.empty_node_map(mesh); //viewer.launch(); //viewer.add_nodes(mesh.node_begin(), mesh.node_end(), node_map); //viewer.add_edges(mesh.edge_begin(), mesh.edge_end(), node_map); //viewer.center_view(); set_tri_directions(mesh); //std::cout << "Starting\n"; // Begin the mass-spring simulation double dt = 0.0001; double t_start = 0.0; double t_end = 0.001; double max_vel = -UINT_MAX; {jb_parallel::Timer timer(""); for (double t = t_start; t < t_end; t += dt) { auto force = make_combined_force( make_combined_force(MassSpringForce(), GravityForce()), AirPressureForce(mesh_shape_volume(&mesh)), // WindForce(3., 0.7), DampingForce(1/(mesh.num_nodes() * 10)) ); auto constraints = make_combined_constraint( FixedConstraint<MeshType>(), BallConstraint<MeshType>(1.9), PlaneConstraint<MeshType>() ); symp_euler_step(mesh, t, dt, force, constraints); // Clear the viewer's nodes and edges. //viewer.clear(); //node_map.clear(); // Update the viewer with new node positions and color // auto max_node = *std::max_element(mesh.node_begin(), // mesh.node_end(), // VelComparator()); // max_vel = std::max(max_vel, norm(max_node.value().value_.velocity)); // Update viewer with nodes' new positions and new edges. //viewer.add_nodes(mesh.node_begin(), mesh.node_end(), VelHeatMap(max_vel), node_map); //viewer.add_edges(mesh.edge_begin(), mesh.edge_end(), node_map); //viewer.set_label(t); } } return 0; }
027e77dc08a5900136aae507901186a762678c6d
5c34abe10630b23da8ba7d1cbce38bda53a4b6fa
/RootAnalysis/src/LeaningTower/Residual.h
71ce6bbd478b017c865d09df2534b5f52ddf97a6
[]
no_license
fermi-lat/GlastRelease-scons-old
cde76202f706b1c8edbf47b52ff46fe6204ee608
95f1daa22299272314025a350f0c6ef66eceda08
refs/heads/master
2021-07-23T02:41:48.198247
2017-05-09T17:27:58
2017-05-09T17:27:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,026
h
#include "TCut.h" #include "TF1.h" #include "TFile.h" #include "TGraph.h" #include "TLine.h" #include "TList.h" #include "TPaveStats.h" #include "TString.h" #include "TStyle.h" #include "TSystem.h" #include "TTree.h" #include "Tracker.h" #include "Layer.h" #include "Event.h" #include "Recon.h" #include "Progress.h" const float damp = 0.63f; class Residual { private: Event* myEvent; Tracker* myTracker; TString myResFileName; int m_temid; public: Residual(const TString="MyRootFile.root", const TString="residual.root", const TString geo="", int temid=0); virtual ~Residual() { delete myEvent; delete myTracker; } void Go(int numEntries=-1, int firstEntry=0); // general for DrawXxx: residual is defined as h_abs_ext-h_abs // *********** // draws the residual, top without fitting, bottom with gauss fit void DrawResidual(TString plane, TCut=""); // draws top the residual vs. inv. slope, bottom the profile with pol1 fit void DrawResSlope(TString plane, TCut=""); // draws top the residual vs. other coordinate, bottom profile with pol1 fit void DrawResOrd(TString plane, TCut=""); // draws top the residual vs. position, bottom profile with pol1 fit void DrawResPos(TString plane, TCut=""); // draws the slope profiles for all planes void DrawResSlopeAll(TCut="abs(h_abs_ext-h_abs)<1"); // draws the ordinate profiles for all planes void DrawResOrdAll(TCut="abs(h_abs_ext-h_abs)<1"); // draws the position profiles for all planes void DrawResPosAll(TCut="abs(h_abs_ext-h_abs)<1"); // attempt to do a "statistical" (not event be event) correction of rotZ of // planes. 2x3 histograms. Left uncorrected, right rotZ corrected. Top // ordinate vs. residual, middle profile of that, bottom residual. void DrawResOrdCorr(TString plane, TCut=""); // saves the geometry into geoFileName void Residual::SaveGeometry(TString geoFileName=""); ClassDef(Residual,1) };
[ "" ]
13651d243149db666cff59d6813e20218d5428af
7fca22474c2741cf7e3fb31c8b8b89799068cdea
/examples/sample.cpp
d3b7184917b38bf95b71002bb8685d5bc27cdd74
[ "BSD-2-Clause" ]
permissive
rbock/sqlpp-concepts-experiments
fc0783d5ecc2dc852edd6950e60102888617f110
6ff7a93ba5bfa27e2aaa29d6860a6cbd3b806ad4
refs/heads/master
2020-05-07T15:10:38.256652
2015-03-31T07:58:06
2015-03-31T07:58:06
32,673,691
1
0
null
null
null
null
UTF-8
C++
false
false
2,141
cpp
/* * Copyright (c) 2014-2015 Roland Bock * 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. * * 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 "Sample.h" #include "MockDb.h" #include <sqlpp11/sqlpp11.h> int main() { MockDb db; test::TabPerson p; test::TabFeature f; db(insert_into(f).set(f.name = "Loves C++", p.fatal = false)); db(insert_into(f).set(p.name = "Roland", p.feature = 1)); auto s = select(all_of(p)) .from(p, q) .where(p.name == any(select(q.name) .from(q) .where(true))) .group_by(q.name) .having(p.name.like("%Bee%")) .order_by(p.name.asc()) .limit(3).offset(7); auto x = s.as(sqlpp::alias::x); for (const auto& row : db(select(p.id, x.name) .from(p.join(x).on(p.feature == x.feature)) .where(true))) { int id = row.id; std::string name = row.name; } }
c991b139f24c51d4376a9b3c8716a98af550c5a4
a0dce37339bf2e60d7ddff5b1b9346e364a04bc8
/comdiv.cpp
2ba71102f1f7b4efb7e10dd5759219247482b9d7
[]
no_license
archiver/spoj
c0dfdc2bfea0c4d811ee0b95dce83c720bea3eae
ac78437594b4ff062db886d03db2a7192478b603
refs/heads/master
2020-05-18T00:58:53.697941
2013-01-18T22:00:38
2013-01-18T22:00:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,394
cpp
#include <stdio.h> #define T 1000002 #define P 168 int divisors[T]; int primes[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997}; void solve() { int i,j; int var,prod,cnt,num; divisors[1]=1; for(i=2;i<T;++i) { var=0; prod=1; j=0; num=i; for(;j<P;++j) { cnt=1; while(!(num%primes[j])) { num=num/primes[j]; cnt+=1; } if(cnt>1) { prod*=cnt; prod*=divisors[num]; break; } } if(1==cnt) prod=2; divisors[i]=prod; } } int gcd(int a, int b) { if(b==0) return a; return gcd(b,a%b); } int main() { int t,a,b; int hcf; scanf("%d",&t); solve(); while(t--) { scanf("%d %d",&a,&b); hcf=a>b?gcd(a,b):gcd(b,a); printf("%d\n",divisors[hcf]); } return 0; }
[ "pavan@pavan.(none)" ]
pavan@pavan.(none)
eb6d5ae824aa2a73bbe6d3351012da3fdc358cb4
c00a2490947ad10582b5d675f070ccb62b70901d
/chromium/media/renderers/default_renderer_factory.h
63828af52e0f6f149855a71af234f712957dd18b
[ "BSD-3-Clause" ]
permissive
teotikalki/vivaldi-source
543d0ab336fb5784eaae1904457598f95f426186
22a46f2c969f6a0b7ca239a05575d1ea2738768c
refs/heads/master
2021-01-23T01:17:34.305328
2016-04-29T20:28:18
2016-04-29T20:28:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,663
h
// Copyright 2014 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 MEDIA_RENDERERS_DEFAULT_RENDERER_FACTORY_H_ #define MEDIA_RENDERERS_DEFAULT_RENDERER_FACTORY_H_ #include "base/callback.h" #include "base/macros.h" #include "media/base/media_export.h" #include "media/base/renderer_factory.h" namespace media { class AudioHardwareConfig; class AudioRendererSink; class GpuVideoAcceleratorFactories; class MediaLog; class VideoRendererSink; // The default factory class for creating RendererImpl. class MEDIA_EXPORT DefaultRendererFactory : public RendererFactory { public: DefaultRendererFactory(const scoped_refptr<MediaLog>& media_log, GpuVideoAcceleratorFactories* gpu_factories, const AudioHardwareConfig& audio_hardware_config); ~DefaultRendererFactory() final; scoped_ptr<Renderer> CreateRenderer( const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, const scoped_refptr<base::TaskRunner>& worker_task_runner, AudioRendererSink* audio_renderer_sink, VideoRendererSink* video_renderer_sink, bool use_platform_media_pipeline, bool platform_pipeline_enlarges_buffers_on_underflow) final; private: scoped_refptr<MediaLog> media_log_; // Factories for supporting video accelerators. May be null. GpuVideoAcceleratorFactories* gpu_factories_; const AudioHardwareConfig& audio_hardware_config_; DISALLOW_COPY_AND_ASSIGN(DefaultRendererFactory); }; } // namespace media #endif // MEDIA_RENDERERS_DEFAULT_RENDERER_FACTORY_H_
c818b103e2bd1f584873a454d31aeff6d22ea29e
21d7c1def6efcaf9ba5b74f521f75d2aaeae8192
/scorched3d/scorched3d.ver01/scorched-dep-win32/include/wx/wx/msw/dirdlg.h
6eacd391ba4694cf10b62ee4b1221eac3e9e31fc
[]
no_license
QuangNhat/GitHub
99f3714fc38f3cf007ccc947b1647f41fe8aa29b
bc9a35c5bfe53a648b717c46b6bf5ddbca9b2ea3
refs/heads/master
2021-01-10T16:06:11.305568
2015-12-17T16:45:59
2015-12-17T16:45:59
48,186,201
0
0
null
null
null
null
UTF-8
C++
false
false
1,472
h
///////////////////////////////////////////////////////////////////////////// // Name: wx/msw/dirdlg.h // Purpose: wxDirDialog class // Author: Julian Smart // Modified by: // Created: 01/02/97 // RCS-ID: $Id: dirdlg.h,v 1.1 2006/12/02 15:58:30 scara Exp $ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_DIRDLG_H_ #define _WX_DIRDLG_H_ #ifdef __GNUG__ #pragma interface "dirdlg.h" #endif class WXDLLEXPORT wxDirDialog : public wxDialog { public: wxDirDialog(wxWindow *parent, const wxString& message = wxDirSelectorPromptStr, const wxString& defaultPath = wxEmptyString, long style = 0, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxString& name = wxDirDialogNameStr); void SetMessage(const wxString& message) { m_message = message; } void SetPath(const wxString& path); void SetStyle(long style) { m_dialogStyle = style; } wxString GetMessage() const { return m_message; } wxString GetPath() const { return m_path; } long GetStyle() const { return m_dialogStyle; } virtual int ShowModal(); protected: wxString m_message; long m_dialogStyle; wxString m_path; private: DECLARE_DYNAMIC_CLASS(wxDirDialog) }; #endif // _WX_DIRDLG_H_
724a8e8ae27052cb05a718fbc8cf8285808ba4cd
7843de0205e0276b6c7e552f8ef4c63ee9cbe28d
/Program1_BenDiegel_Less3.cpp
f6f588ffdaa6ba2680aa2450ee107d78ae222acc
[]
no_license
DiegelB/CPPHW
721615b23655a1c3558ee58e898b9a51ae107061
ec2416ce2f01335e79b39a19bd0746b81dc740f2
refs/heads/master
2021-01-20T10:04:30.963230
2017-10-30T02:47:23
2017-10-30T02:47:23
101,620,470
0
0
null
null
null
null
UTF-8
C++
false
false
1,093
cpp
/* Program: Points calculator Programmer: Ben Diegel Date: 9/2/17 */ #include <iostream> using namespace std; int main() { int numberOfBooks, earnedPoints; cout << "Please enter the amount of books you've read this month. Please enter a\n" << "negative value to exit the program\n>>"; cin >> numberOfBooks; while (numberOfBooks > 0) { if (numberOfBooks == 0) { earnedPoints = 0; } else if (numberOfBooks == 1) { earnedPoints = 5; } else if (numberOfBooks == 2) { earnedPoints = 15; } else if (numberOfBooks == 3) { earnedPoints = 30; } else if (numberOfBooks >= 4) { earnedPoints = 60; } cout << "You've read " << numberOfBooks << " books and have earned " << earnedPoints << " points.\n\n"; cout << "Please enter the amount of books you've read this month. Please enter a\n" << "negative value to exit the program\n>>"; cin >> numberOfBooks; } return 0; }
11d9b20d9d50292749ac4697b42ce887bedf30d9
2f814827ffab9d8d9cc23cb4c3622feb45fa5770
/PWGGA/GammaConv/AliAnalysisTaskElectronStudies.cxx
4cd2ba5d738b167d721896605d7bdad0d9121ec4
[]
permissive
urasantonio/AliPhysics
dd3a851f84674846e45f4b1fdea65700dee80223
8ca4a9abc72a6b94e75048d08748a1debf41873e
refs/heads/master
2022-12-17T21:54:22.246566
2020-09-11T14:04:20
2020-09-11T14:04:20
268,796,481
1
0
BSD-3-Clause
2020-09-11T13:50:03
2020-06-02T12:35:23
C++
UTF-8
C++
false
false
40,561
cxx
/************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * * Authors: Florian Jonas * * Version 1.0 * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ #include "AliAnalysisTaskElectronStudies.h" #include "TChain.h" #include "TRandom.h" #include "AliAnalysisManager.h" #include "TParticle.h" #include "TVectorF.h" #include "AliPIDResponse.h" #include "TFile.h" #include "AliESDtrackCuts.h" #include "AliAODMCParticle.h" #include "AliAODConversionPhoton.h" #include "AliAODMCHeader.h" #include "AliAODEvent.h" #include "AliMultSelection.h" #include "AliAODCaloCluster.h" #include "AliAODTrack.h" #include "AliVTrack.h" #include "AliEMCALRecoUtilsBase.h" #include "AliAODConversionMother.h" #include "TObjectTable.h" ClassImp(AliAnalysisTaskElectronStudies) //________________________________________________________________________ AliAnalysisTaskElectronStudies::AliAnalysisTaskElectronStudies() : AliAnalysisTaskSE(), fInputEvent(NULL), fMCEvent(NULL), fWeightJetJetMC(1), fOutputList(NULL), fAnalysisTree(NULL), fIsMC(0), fIsHeavyIon(0), fV0Reader(NULL), fV0ReaderName(""), fPIDResponse(NULL), fReaderGammas(NULL), fAODMCTrackArray(NULL), fGeomEMCAL(NULL), fCorrTaskSetting(""), fEventCuts(NULL), fClusterCutsEMC(NULL), fTMCuts(NULL), fConvCuts(NULL), fCaloUtils(NULL), fMinClsTPC(0), fChi2PerClsTPC(9999), fMinClsITS(0), fEtaCut(9999), fPtCut(0), fYMCCut(9999), fMinNsigmaElec(-1), fMaxNsigmaElec(3), fMatchingParamsPhi(), fMatchingParamsEta(), fUseRTrackMatching(kFALSE), fRTrackMatching(999), fHistoNEvents(NULL), fHistoNEventsWOWeight(NULL), fPtElectronTrack(NULL), fPtElectronTrackInEmcalAcc(NULL), fTruePtCluster(NULL), fTruePtElectronCluster(NULL), fTruePtElectronClusterMatchedWithTrack(NULL), fTruePtElectronTrack(NULL), fTruePtElectronTrackInEmcalAcc(NULL), fGenPtElectrons(NULL), fGenPtElectronsInEmcalAcc(NULL), fTreeBuffSize(60*1024*1024), fMemCountAOD(0), fTrackMatcherRunningMode(0), fBuffer_ClusterE(0), fBuffer_ClusterEta(0), fBuffer_ClusterPhi(0), fBuffer_ClusterM02(0), fBuffer_ClusterM20(0), fBuffer_Track_Pt(0), fBuffer_Track_P(0), fBuffer_Track_Eta(0), fBuffer_Track_Phi(0), fBuffer_Track_NSigmaElec(0), fBuffer_Track_IsFromV0(0), fBuffer_MC_True_Cluster_E(0), fBuffer_MC_True_Track_E(0), fBuffer_MC_True_Track_Pt(0), fBuffer_MC_True_Track_P(0), fBuffer_MC_Track_Is_Electron(0), fBuffer_MC_Cluster_Is_Electron(0), fBuffer_MC_ClusterTrack_Same_Electron(0), fBuffer_MC_JetJetWeight(1) { SetEtaMatching(0.010,4.07,-2.5); SetPhiMatching(0.015,3.65,3.65); } AliAnalysisTaskElectronStudies::AliAnalysisTaskElectronStudies(const char *name) : AliAnalysisTaskSE(name), fInputEvent(NULL), fMCEvent(NULL), fWeightJetJetMC(1), fOutputList(NULL), fAnalysisTree(NULL), fIsMC(0), fIsHeavyIon(0), fV0Reader(NULL), fV0ReaderName(""), fPIDResponse(NULL), fReaderGammas(NULL), fAODMCTrackArray(NULL), fGeomEMCAL(NULL), fCorrTaskSetting(""), fEventCuts(NULL), fClusterCutsEMC(NULL), fTMCuts(NULL), fConvCuts(NULL), fCaloUtils(NULL), fMinClsTPC(0), fChi2PerClsTPC(9999), fMinClsITS(0), fEtaCut(9999), fPtCut(0), fYMCCut(9999), fMinNsigmaElec(-1), fMaxNsigmaElec(3), fMatchingParamsPhi(), fMatchingParamsEta(), fUseRTrackMatching(kFALSE), fRTrackMatching(999), fHistoNEvents(NULL), fHistoNEventsWOWeight(NULL), fPtElectronTrack(NULL), fPtElectronTrackInEmcalAcc(NULL), fTruePtCluster(NULL), fTruePtElectronCluster(NULL), fTruePtElectronClusterMatchedWithTrack(NULL), fTruePtElectronTrack(NULL), fTruePtElectronTrackInEmcalAcc(NULL), fGenPtElectrons(NULL), fGenPtElectronsInEmcalAcc(NULL), fTreeBuffSize(60*1024*1024), fMemCountAOD(0), fTrackMatcherRunningMode(0), fBuffer_ClusterE(0), fBuffer_ClusterEta(0), fBuffer_ClusterPhi(0), fBuffer_ClusterM02(0), fBuffer_ClusterM20(0), fBuffer_Track_Pt(0), fBuffer_Track_P(0), fBuffer_Track_Eta(0), fBuffer_Track_Phi(0), fBuffer_Track_NSigmaElec(0), fBuffer_Track_IsFromV0(0), fBuffer_MC_True_Cluster_E(0), fBuffer_MC_True_Track_E(0), fBuffer_MC_True_Track_Pt(0), fBuffer_MC_True_Track_P(0), fBuffer_MC_Track_Is_Electron(0), fBuffer_MC_Cluster_Is_Electron(0), fBuffer_MC_ClusterTrack_Same_Electron(0), fBuffer_MC_JetJetWeight(1.) { DefineInput(0, TChain::Class()); DefineOutput(1, TList::Class()); DefineOutput(2, TTree::Class()); SetEtaMatching(0.010,4.07,-2.5); SetPhiMatching(0.015,3.65,3.65); } //________________________________________________________________________ AliAnalysisTaskElectronStudies::~AliAnalysisTaskElectronStudies() { // default deconstructor } //________________________________________________________________________ void AliAnalysisTaskElectronStudies::UserCreateOutputObjects() { // Create User Output Objects fOutputList = new TList(); fOutputList->SetOwner(kTRUE); if(((AliConvEventCuts*)fEventCuts)->GetCutHistograms()){ fOutputList->Add(((AliConvEventCuts*)fEventCuts)->GetCutHistograms()); } if(((AliCaloPhotonCuts*)fClusterCutsEMC)->GetCutHistograms()){ fOutputList->Add(((AliCaloPhotonCuts*)fClusterCutsEMC)->GetCutHistograms()); } if(((AliCaloPhotonCuts*)fTMCuts)->GetCutHistograms()){ fOutputList->Add(((AliCaloPhotonCuts*)fTMCuts)->GetCutHistograms()); } if(((AliConversionPhotonCuts*)fConvCuts)->GetCutHistograms()){ fOutputList->Add(((AliConversionPhotonCuts*)fConvCuts)->GetCutHistograms()); } for(Int_t iMatcherTask = 0; iMatcherTask < 5; iMatcherTask++){ AliCaloTrackMatcher* temp = 0x0; if(!fCorrTaskSetting.CompareTo("")){ temp = (AliCaloTrackMatcher*) (AliAnalysisManager::GetAnalysisManager()->GetTask(Form("CaloTrackMatcherSignal_%i_%i",iMatcherTask,fTrackMatcherRunningMode))); } else { temp = (AliCaloTrackMatcher*) (AliAnalysisManager::GetAnalysisManager()->GetTask(Form("CaloTrackMatcherSignal_%i_%i_%s",iMatcherTask,fTrackMatcherRunningMode,fCorrTaskSetting.Data()))); } if(temp) fOutputList->Add(temp->GetCaloTrackMatcherHistograms()); } fHistoNEvents = new TH1F("NEvents","NEvents",14,-0.5,13.5); fHistoNEvents->GetXaxis()->SetBinLabel(1,"Accepted"); fHistoNEvents->GetXaxis()->SetBinLabel(2,"Centrality"); fHistoNEvents->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev."); if (((AliConvEventCuts*)fEventCuts)->IsSpecialTrigger() > 1 ){ TString TriggerNames = "Not Trigger: "; TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCuts)->GetSpecialTriggerName(); fHistoNEvents->GetXaxis()->SetBinLabel(4,TriggerNames.Data()); } else { fHistoNEvents->GetXaxis()->SetBinLabel(4,"Trigger"); } fHistoNEvents->GetXaxis()->SetBinLabel(5,"Vertex Z"); fHistoNEvents->GetXaxis()->SetBinLabel(6,"Cont. Vertex"); fHistoNEvents->GetXaxis()->SetBinLabel(7,"Pile-Up"); fHistoNEvents->GetXaxis()->SetBinLabel(8,"no SDD"); fHistoNEvents->GetXaxis()->SetBinLabel(9,"no V0AND"); fHistoNEvents->GetXaxis()->SetBinLabel(10,"EMCAL/TPC problem"); fHistoNEvents->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet"); fHistoNEvents->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future"); fHistoNEvents->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks"); fHistoNEvents->GetYaxis()->SetTitle("N_{events}"); fOutputList->Add(fHistoNEvents); fPtElectronTrack = new TH1F("fPtElectronTrack","fPtElectronTrack;p_{T} (GeV/c; counts",200,0.,50.); fOutputList->Add(fPtElectronTrack); fPtElectronTrackInEmcalAcc = new TH1F("fPtElectronTrackInEmcalAcc","fPtElectronTrackInEmcalAcc;p_{T} (GeV/c; counts",200,0.,50.); fOutputList->Add(fPtElectronTrackInEmcalAcc); if(fIsMC > 1){ fHistoNEventsWOWeight = new TH1F("NEventsWOWeight","NEventsWOWeight",14,-0.5,13.5); fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(1,"Accepted"); fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(2,"Centrality"); fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev."); if (((AliConvEventCuts*)fEventCuts)->IsSpecialTrigger() > 1 ){ TString TriggerNames = "Not Trigger: "; TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCuts)->GetSpecialTriggerName(); fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(4,TriggerNames.Data()); } else { fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(4,"Trigger"); } fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(5,"Vertex Z"); fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(6,"Cont. Vertex"); fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(7,"Pile-Up"); fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(8,"no SDD"); fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(9,"no V0AND"); fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(10,"EMCAL problem"); fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet"); fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future"); fHistoNEventsWOWeight->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks"); fHistoNEventsWOWeight->GetYaxis()->SetTitle("N_{events}"); fOutputList->Add(fHistoNEventsWOWeight); } if(fIsMC){ fTruePtCluster = new TH1F("fTruePtCluster","fTruePtCluster;p_{T} (GeV/c; counts",200,0.,50.); fOutputList->Add(fTruePtCluster); fTruePtElectronCluster = new TH1F("fTruePtElectronCluster","fTruePtElectronCluster;p_{T} (GeV/c; counts",200,0.,50.); fOutputList->Add(fTruePtElectronCluster); fTruePtElectronClusterMatchedWithTrack = new TH1F("fTruePtElectronClusterMatchedWithTrack","fTruePtElectronClusterMatchedWithTrack;p_{T} (GeV/c; counts",200,0.,50.); fOutputList->Add(fTruePtElectronClusterMatchedWithTrack); fTruePtElectronTrack = new TH1F("fTruePtElectronTrack","fTruePtElectronTrack;p_{T} (GeV/c; counts",200,0.,50.); fOutputList->Add(fTruePtElectronTrack); fTruePtElectronTrackInEmcalAcc = new TH1F("fTruePtElectronTrackInEmcalAcc","fTruePtElectronTrackInEmcalAcc;p_{T} (GeV/c; counts",200,0.,50.); fOutputList->Add(fTruePtElectronTrackInEmcalAcc); fGenPtElectrons = new TH1F("fGenPtElectrons","fGenPtElectrons;p_{T} (GeV/c; counts",200,0.,50.); fOutputList->Add(fGenPtElectrons); fGenPtElectronsInEmcalAcc = new TH1F("fGenPtElectronsInEmcalAcc","fGenPtElectronsInEmcalAcc;p_{T} (GeV/c; counts",200,0.,50.); fOutputList->Add(fGenPtElectronsInEmcalAcc); } PostData(1, fOutputList); OpenFile(2); fAnalysisTree = new TTree(Form("AnalysisTree_%s",fCorrTaskSetting.Data()),Form("AnalysisTree_%s",fCorrTaskSetting.Data())); fAnalysisTree->Branch("Cluster_E", &fBuffer_ClusterE, "Cluster_E/F"); fAnalysisTree->Branch("Cluster_Eta", &fBuffer_ClusterEta, "Cluster_Eta/F"); fAnalysisTree->Branch("Cluster_Phi", &fBuffer_ClusterPhi, "Cluster_Phi/F"); fAnalysisTree->Branch("Cluster_M02", &fBuffer_ClusterM02, "Cluster_M02/F"); fAnalysisTree->Branch("Cluster_M20", &fBuffer_ClusterM20, "Cluster_M20/F"); fAnalysisTree->Branch("Track_Pt", &fBuffer_Track_Pt, "Track_Pt/F"); fAnalysisTree->Branch("Track_P", &fBuffer_Track_P, "Track_P/F"); fAnalysisTree->Branch("Track_Eta", &fBuffer_Track_Eta, "Track_Eta/F"); fAnalysisTree->Branch("Track_Phi", &fBuffer_Track_Phi, "Track_Phi/F"); fAnalysisTree->Branch("Track_NSigmaElec", &fBuffer_Track_NSigmaElec, "Track_NSigmaElec/F"); fAnalysisTree->Branch("Track_IsFromV0", &fBuffer_Track_IsFromV0, "Track_Track_IsFromV0/I"); if(fIsMC>0){ fAnalysisTree->Branch("MC_True_Cluster_E", &fBuffer_MC_True_Cluster_E, "MC_True_Cluster_E/F"); fAnalysisTree->Branch("MC_True_Track_E", &fBuffer_MC_True_Track_E, "MC_True_Track_E/F"); fAnalysisTree->Branch("MC_True_Track_Pt", &fBuffer_MC_True_Track_Pt, "MC_True_Track_Pt/F"); fAnalysisTree->Branch("MC_True_Track_P", &fBuffer_MC_True_Track_P, "MC_True_Track_P/F"); fAnalysisTree->Branch("MC_Track_Is_Electron", &fBuffer_MC_Track_Is_Electron, "MC_Track_Is_Electron/I"); fAnalysisTree->Branch("MC_Cluster_Is_Electron", &fBuffer_MC_Cluster_Is_Electron, "MC_Cluster_Is_Electron/I"); fAnalysisTree->Branch("MC_ClusterTrack_Same_Electron", &fBuffer_MC_ClusterTrack_Same_Electron, "MC_ClusterTrack_Same_Electron/I"); fAnalysisTree->Branch("MC_JetJetWeight", &fBuffer_MC_JetJetWeight, "MC_JetJetWeight/F"); } PostData(2, fAnalysisTree); } //_____________________________________________________________________________ Bool_t AliAnalysisTaskElectronStudies::Notify() { return kTRUE; } //________________________________________________________________________ void AliAnalysisTaskElectronStudies::UserExec(Option_t *){ fInputEvent = InputEvent(); ((AliCaloPhotonCuts*)fClusterCutsEMC)->InitializeEMCAL(fInputEvent); //((AliCaloPhotonCuts*)fTMCuts)->InitializeEMCAL(fInputEvent); if(fIsMC>0) fMCEvent = MCEvent(); if((fIsMC) > 0 && (!fMCEvent)) {printf("Error: No MC Event");return;} // Get V0 reader fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()); if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader if(fIsMC > 0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){ RelabelAODPhotonCandidates(kTRUE); // In case of AODMC relabeling MC fV0Reader->RelabelAODs(kTRUE); } Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality(); if(InputEvent()->IsIncompleteDAQ()==kTRUE) eventQuality = 2; // incomplete event if(eventQuality == 2 || eventQuality == 3){// Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1 or because it is incomplete fHistoNEvents->Fill(eventQuality); if (fIsMC>1) fHistoNEventsWOWeight->Fill(eventQuality); return; } Int_t eventNotAccepted = fEventCuts->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,kFALSE); if(eventNotAccepted) return; // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1 if (fIsMC > 1){ fWeightJetJetMC = 1; Float_t maxjetpt = -1.; Float_t pthard = -1; Bool_t isMCJet = ((AliConvEventCuts*)fEventCuts)->IsJetJetMCEventAccepted( fMCEvent, fWeightJetJetMC ,pthard, fInputEvent, maxjetpt); if (!isMCJet){ fHistoNEvents->Fill(10,fWeightJetJetMC); if (fIsMC>1) fHistoNEventsWOWeight->Fill(10); return; } } AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); fPIDResponse = inputHandler->GetPIDResponse(); if (!fPIDResponse){AliFatal("fPIDResponse does not exist!"); return;} if (fIsMC > 1){ fWeightJetJetMC = 1; Float_t maxjetpt = -1.; Float_t pthard = -1; Bool_t isMCJet = ((AliConvEventCuts*)fEventCuts)->IsJetJetMCEventAccepted( fMCEvent, fWeightJetJetMC ,pthard, fInputEvent, maxjetpt); if (fIsMC == 3){ Double_t weightMult = ((AliConvEventCuts*)fEventCuts)->GetWeightForMultiplicity(fV0Reader->GetNumberOfPrimaryTracks()); fWeightJetJetMC = fWeightJetJetMC*weightMult; } if (!isMCJet){ fHistoNEvents->Fill(10,fWeightJetJetMC); if (fIsMC>1) fHistoNEventsWOWeight->Fill(10); return; } } Bool_t triggered = kTRUE; if(eventNotAccepted!=0){ fHistoNEvents->Fill(eventNotAccepted,fWeightJetJetMC); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1 if (fIsMC>1) fHistoNEventsWOWeight->Fill(eventNotAccepted); if (eventNotAccepted==3 && fIsMC > 0){ triggered = kFALSE; }else { return; } } if(eventQuality != 0 && triggered== kTRUE){// Event Not Accepted fHistoNEvents->Fill(eventQuality, fWeightJetJetMC); if (fIsMC>1) fHistoNEventsWOWeight->Fill(eventQuality); // Should be 0 here return; } if (triggered == kTRUE) { fHistoNEvents->Fill(eventQuality,fWeightJetJetMC); if (fIsMC>1) fHistoNEventsWOWeight->Fill(eventQuality); // Should be 0 here } fGeomEMCAL = AliEMCALGeometry::GetInstance(); if(!fGeomEMCAL){ AliFatal("EMCal geometry not initialized!");} fBuffer_MC_JetJetWeight = fWeightJetJetMC; // // ─── MAIN PROCESSING ──────────────────────────────────────────────────────────── // if (triggered==kFALSE) return; ProcessCaloPhotons(); // track matching is done here as well ProcessTracks(); if(fIsMC>0) ProcessMCParticles(); // vertex Double_t vertex[3] = {0}; InputEvent()->GetPrimaryVertex()->GetXYZ(vertex); if( fIsMC > 0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){ RelabelAODPhotonCandidates(kFALSE); // Back to ESDMC Label fV0Reader->RelabelAODs(kFALSE); } // fill output PostData(2, fAnalysisTree); ResetBuffer(); //gObjectTable->Print(); PostData(1,fOutputList); } //________________________________________________________________________ void AliAnalysisTaskElectronStudies::Terminate(Option_t *){ } //________________________________________________________________________ void AliAnalysisTaskElectronStudies::ResetBuffer(){ } //________________________________________________________________________ void AliAnalysisTaskElectronStudies::ProcessCaloPhotons(){ Int_t nclus = 0; Int_t nclusCorr = 0; if(fIsMC && !fAODMCTrackArray) fAODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName())); TClonesArray * arrClustersProcess = NULL; if(!fCorrTaskSetting.CompareTo("")){ nclus = fInputEvent->GetNumberOfCaloClusters(); nclusCorr = nclus; } else { arrClustersProcess = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data()))); if(!arrClustersProcess) AliFatal(Form("%sClustersBranch was not found in AliAnalysisTaskGammaCalo! Check the correction framework settings!",fCorrTaskSetting.Data())); nclusCorr = arrClustersProcess->GetEntries(); nclus = fInputEvent->GetNumberOfCaloClusters(); } if(nclus == 0) return; // ((AliCaloPhotonCuts*)fClusterCutsEMC)->FillHistogramsExtendedQA(fInputEvent,fIsMC); // ((AliCaloPhotonCuts*)fClusterCutsPHOS)->FillHistogramsExtendedQA(fInputEvent,fIsMC); // in case user wants to use default track matching fTMCuts->MatchTracksToClusters(fInputEvent,fWeightJetJetMC,kTRUE, fMCEvent); AliAODCaloCluster* clus = NULL; if(arrClustersProcess){ // EMCal correction framework was used // we need to loop over this for EMCal clusters and // over the others for PHOS cluster // Loop over EMCal clusters for(Long_t i = 0; i < nclusCorr; i++){ Double_t tempClusterWeight = fWeightJetJetMC; clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersProcess->At(i)); if(!clus) continue; if ( !clus->IsEMCAL()){ // for PHOS: cluster->GetType() == AliVCluster::kPHOSNeutral delete clus; continue; } // check if given EMC cuts are fulfilled if(!((AliCaloPhotonCuts*)fClusterCutsEMC)->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC, tempClusterWeight,i)){ delete clus; continue; } if(fIsMC){ Int_t *mclabelsCluster = clus->GetLabels(); if (clus->GetNLabels() > 0) { if(mclabelsCluster[0]!=-1){ AliAODMCParticle* clusterMother = (AliAODMCParticle* )fAODMCTrackArray->At(mclabelsCluster[0]); fTruePtCluster->Fill(clusterMother->Pt(),fWeightJetJetMC); if (TMath::Abs(clusterMother->PdgCode()) == 11) { fTruePtElectronCluster->Fill(clusterMother->Pt(),fWeightJetJetMC); } } } } AliAODTrack *aodt = NULL; //ProcessTrackMatching(clus); if(fTMCuts->CheckClusterForTrackMatch(clus)){ Int_t labelTrack = -1; if(fTMCuts->GetClosestMatchedTrackToCluster(fInputEvent,clus,labelTrack)){ Int_t properLabel = labelTrack; // if(labelTrack<0) properLabel = (-1 * labelTrack) - 1; // conversion hybrid none hybrid aodt = dynamic_cast<AliAODTrack*> (fInputEvent->GetTrack(properLabel)); if(aodt) ProcessMatchedTrack(aodt,clus,kFALSE); } } delete clus; } // end of initial cluster loop } // no need to loop over normal clusters as well if(arrClustersProcess) return; // Loop over normal clusters for(Long_t i = 0; i < nclus; i++){ Double_t tempClusterWeight = fWeightJetJetMC; clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i)); if(!clus) continue; if(clus->IsEMCAL()){ // if is was not saved already if(!((AliCaloPhotonCuts*)fClusterCutsEMC)->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC, tempClusterWeight,i)){ delete clus; continue; } if(fIsMC){ Int_t *mclabelsCluster = clus->GetLabels(); if (clus->GetNLabels() > 0) { if(mclabelsCluster[0]!=-1){ AliAODMCParticle* clusterMother = (AliAODMCParticle* )fAODMCTrackArray->At(mclabelsCluster[0]); fTruePtCluster->Fill(clusterMother->Pt(),fWeightJetJetMC); if (TMath::Abs(clusterMother->PdgCode()) == 11) { fTruePtElectronCluster->Fill(clusterMother->Pt(),fWeightJetJetMC); } } } } AliAODTrack *aodt = NULL; //ProcessTrackMatching(clus); if(fTMCuts->CheckClusterForTrackMatch(clus)){ Int_t labelTrack = -1; if(fTMCuts->GetClosestMatchedTrackToCluster(fInputEvent,clus,labelTrack)){ Int_t properLabel = labelTrack; // if(labelTrack<0) properLabel = (-1 * labelTrack) - 1; // conversion hybrid none hybrid aodt = dynamic_cast<AliAODTrack*> (fInputEvent->GetTrack(properLabel)); if(aodt) ProcessMatchedTrack(aodt,clus,kFALSE); } } //ProcessTrackMatching(clus); // tree filling done here too delete clus; continue; } delete clus; } } //________________________________________________________________________ void AliAnalysisTaskElectronStudies::ProcessTracks(){ for(Int_t t=0;t<fInputEvent->GetNumberOfTracks();t++){ AliAODTrack *aodt = dynamic_cast<AliAODTrack*> (fInputEvent->GetTrack(t)); if(!aodt) continue; if(!TrackIsSelectedAOD(aodt)) continue; // apply electron PID cut Float_t nsigmaelec = fPIDResponse->NumberOfSigmasTPC(aodt,AliPID::kElectron); if ((nsigmaelec > fMaxNsigmaElec) || (nsigmaelec < fMinNsigmaElec)) continue; fPtElectronTrack->Fill(aodt->Pt(),fWeightJetJetMC); if(IsInEMCalAcceptance(aodt)) fPtElectronTrackInEmcalAcc->Fill(aodt->Pt(),fWeightJetJetMC); if(fIsMC){ Int_t mclabel = aodt->GetLabel(); if(mclabel != -1){ if(mclabel<0) mclabel = (-1 * mclabel) - 1; AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(fAODMCTrackArray->At(mclabel)); if(particle){ if(TMath::Abs(particle->GetPdgCode())== 11){ fTruePtElectronTrack->Fill(particle->Pt(),fWeightJetJetMC); if(IsInEMCalAcceptance(particle)) fTruePtElectronTrackInEmcalAcc->Fill(particle->Pt(),fWeightJetJetMC); } } } } } } ///________________________________________________________________________ Bool_t AliAnalysisTaskElectronStudies::TrackIsSelectedAOD(AliAODTrack* lTrack) { // apply filter bits if( ! lTrack->IsHybridGlobalConstrainedGlobal()){ return kFALSE; } // Absolute TPC Cluster cut if(lTrack->GetTPCNcls()<fMinClsTPC) return kFALSE; if(lTrack->GetTPCchi2perCluster()>fChi2PerClsTPC) return kFALSE; // DCA cut //if(!IsDCACutAccepted(lTrack)) return kFALSE; // ITS Cluster Cut // SetClusterRequirementITS and SetRequireITSRefit can // not be set for AODs after filtering if(lTrack->GetITSNcls()<fMinClsITS) return kFALSE; if( TMath::Abs(lTrack->Eta()) > fEtaCut ) { return kFALSE; } if( lTrack->Pt() < fPtCut ) { return kFALSE; } // n sigma preselection Float_t nsigmaelec = fPIDResponse->NumberOfSigmasTPC(lTrack,AliPID::kElectron); if ((nsigmaelec > 10) || (nsigmaelec < -10)) return kFALSE; return kTRUE; } //_____________________________________________________________________________ void AliAnalysisTaskElectronStudies::ProcessMatchedTrack(AliAODTrack* track, AliAODCaloCluster* clus, Bool_t isV0){ Float_t clusPos[3] = { 0,0,0 }; clus->GetPosition(clusPos); TVector3 clusterVector(clusPos[0],clusPos[1],clusPos[2]); fBuffer_ClusterE = clus->E(); fBuffer_ClusterEta = clusterVector.Eta(); fBuffer_ClusterPhi = clusterVector.Phi(); fBuffer_ClusterM02 = clus->GetM02(); fBuffer_ClusterM20 = clus->GetM20(); fBuffer_Track_Pt = track->Pt(); fBuffer_Track_P = track->P(); fBuffer_Track_Eta = track->Eta(); fBuffer_Track_Phi = track->Phi(); fBuffer_Track_NSigmaElec = fPIDResponse->NumberOfSigmasTPC(track,AliPID::kElectron); fBuffer_Track_IsFromV0 = (Int_t) isV0; fBuffer_MC_True_Cluster_E = 0; fBuffer_MC_True_Track_E = 0; fBuffer_MC_True_Track_Pt = 0; fBuffer_MC_True_Track_P = 0; fBuffer_MC_Track_Is_Electron= 0; fBuffer_MC_Cluster_Is_Electron= 0; fBuffer_MC_ClusterTrack_Same_Electron= 0; if(fIsMC){ // check if leading contribution is electron Int_t *mclabelsCluster = clus->GetLabels(); AliAODMCParticle* clusterMother = NULL; if (clus->GetNLabels() > 0) { // for (Int_t k = 0; k < (Int_t)clusterE->GetNLabels(); k++) // { if(mclabelsCluster[0]!=-1){ clusterMother = (AliAODMCParticle* )fAODMCTrackArray->At(mclabelsCluster[0]); if (TMath::Abs(clusterMother->PdgCode()) == 11) { fBuffer_MC_Cluster_Is_Electron = 1; fBuffer_MC_True_Cluster_E = clusterMother->E(); fTruePtElectronClusterMatchedWithTrack->Fill(clusterMother->Pt(),fWeightJetJetMC); } } } // Check Track Int_t trackMCLabel = track->GetLabel(); AliAODMCParticle* trackMother = NULL; if(trackMCLabel>-1){ trackMother = (AliAODMCParticle* )fAODMCTrackArray->At(trackMCLabel); if(TMath::Abs(trackMother->GetPdgCode()) == 11){ fBuffer_MC_Track_Is_Electron = 1; fBuffer_MC_True_Track_E = trackMother->E(); fBuffer_MC_True_Track_Pt = trackMother->Pt(); fBuffer_MC_True_Track_P = trackMother->P(); } } if((clus->GetNLabels()>0) && (mclabelsCluster[0] == trackMCLabel) && (fBuffer_MC_Track_Is_Electron ==1)){ fBuffer_MC_ClusterTrack_Same_Electron = 1; } // } } // end is MC fAnalysisTree->Fill(); } //_____________________________________________________________________________ void AliAnalysisTaskElectronStudies::ProcessMCParticles(){ // Loop over all primary MC particle if(!fAODMCTrackArray) fAODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName())); if (fAODMCTrackArray){ for(Int_t i = 0; i < fAODMCTrackArray->GetEntriesFast(); i++) { AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(fAODMCTrackArray->At(i)); if(!particle) continue; if(particle->MCStatusCode() != 1 || !particle->IsPhysicalPrimary()) continue; if(TMath::Abs(particle->PdgCode()) != 11 ) continue; fGenPtElectrons->Fill(particle->Pt(),fWeightJetJetMC); if(IsInEMCalAcceptance(particle)){ fGenPtElectronsInEmcalAcc->Fill(particle->Pt(),fWeightJetJetMC); } } } } //_____________________________________________________________________________ void AliAnalysisTaskElectronStudies::ProcessTrackMatching(AliAODCaloCluster* clus){ Int_t nModules = fGeomEMCAL->GetNumberOfSuperModules(); AliExternalTrackParam *trackParam = 0; for(Int_t t=0;t<fInputEvent->GetNumberOfTracks();t++){ AliAODTrack *aodt = dynamic_cast<AliAODTrack*> (fInputEvent->GetTrack(t)); if(!aodt) continue; if(!TrackIsSelectedAOD(aodt)) continue; Double_t xyz[3] = {0}, pxpypz[3] = {0}, cv[21] = {0}; aodt->GetPxPyPz(pxpypz); aodt->GetXYZ(xyz); aodt->GetCovarianceXYZPxPyPz(cv); trackParam = new AliExternalTrackParam(xyz,pxpypz,cv,aodt->Charge()); AliExternalTrackParam emcParam(*trackParam); Float_t eta, phi, pt; //propagate tracks to emc surfaces if (!AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&emcParam, 440., 0.139, 20., eta, phi, pt)) { delete trackParam; continue; } if( TMath::Abs(eta) > 0.75 ) { delete trackParam; continue; } // Save some time and memory in case of no DCal present if( nModules < 13 && ( phi < 70*TMath::DegToRad() || phi > 190*TMath::DegToRad())){ delete trackParam; continue; } // Save some time and memory in case of run2 if( nModules > 12 ){ if (( phi < 70*TMath::DegToRad() || phi > 190*TMath::DegToRad()) && ( phi < 250*TMath::DegToRad() || phi > 340*TMath::DegToRad())){ delete trackParam; continue; } } Float_t dEta=-999, dPhi=-999; Double_t trkPos[3] = {0.,0.,0.}; if (!emcParam.GetXYZ(trkPos)){ delete trackParam; continue; } AliExternalTrackParam trackParamTmp(emcParam);//Retrieve the starting point every time before the extrapolation if(!AliEMCALRecoUtils::ExtrapolateTrackToCluster(&trackParamTmp, clus, 0.139, 5., dEta, dPhi)){ delete trackParam; continue; } if(!fUseRTrackMatching){ if(TMath::Abs(dEta) > (fMatchingParamsEta[0] + pow(aodt->Pt() + fMatchingParamsEta[1],fMatchingParamsEta[2]))){ delete trackParam; continue; } if(TMath::Abs(dPhi) > (fMatchingParamsPhi[0] + pow(aodt->Pt() + fMatchingParamsPhi[1],fMatchingParamsPhi[2]))){ delete trackParam; continue; } } else{ // use R track matching Double_t dR = TMath::Sqrt(dEta*dEta + dPhi*dPhi); if(dR > fRTrackMatching){ delete trackParam; continue; } } // track is matched ProcessMatchedTrack(aodt,clus,kFALSE); delete trackParam; } // check also conversion sample to be sure nothing from there is missing if(!fReaderGammas) fReaderGammas = fV0Reader->GetReconstructedGammas(); for (Int_t c = 0; c < fReaderGammas->GetEntriesFast(); c++) { AliAODConversionPhoton* photon = (AliAODConversionPhoton*) fReaderGammas->At(c); if(!photon) continue; if(!((AliConversionPhotonCuts*)fConvCuts)->PhotonIsSelected(photon,fInputEvent)) continue; for (Int_t iElec = 0;iElec < 2;iElec++){ Int_t tracklabel = photon->GetLabel(iElec); AliAODTrack *convtrack = dynamic_cast<AliAODTrack*> (fInputEvent->GetTrack(tracklabel)); if(!convtrack) continue; if(convtrack->IsHybridGlobalConstrainedGlobal()) continue; // that means we already treated it; Double_t xyz[3] = {0}, pxpypz[3] = {0}, cv[21] = {0}; convtrack->GetPxPyPz(pxpypz); convtrack->GetXYZ(xyz); convtrack->GetCovarianceXYZPxPyPz(cv); trackParam = new AliExternalTrackParam(xyz,pxpypz,cv,convtrack->Charge()); AliExternalTrackParam emcParam(*trackParam); Float_t eta, phi, pt; //propagate tracks to emc surfaces if (!AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&emcParam, 440., 0.139, 20., eta, phi, pt)) { delete trackParam; continue; } if( TMath::Abs(eta) > 0.75 ) { delete trackParam; continue; } // Save some time and memory in case of no DCal present if( nModules < 13 && ( phi < 70*TMath::DegToRad() || phi > 190*TMath::DegToRad())){ delete trackParam; continue; } // Save some time and memory in case of run2 if( nModules > 12 ){ if (( phi < 70*TMath::DegToRad() || phi > 190*TMath::DegToRad()) && ( phi < 250*TMath::DegToRad() || phi > 340*TMath::DegToRad())){ delete trackParam; continue; } } Float_t dEta=-999, dPhi=-999; Double_t trkPos[3] = {0.,0.,0.}; if (!emcParam.GetXYZ(trkPos)){ delete trackParam; continue; } AliExternalTrackParam trackParamTmp(emcParam);//Retrieve the starting point every time before the extrapolation if(!AliEMCALRecoUtils::ExtrapolateTrackToCluster(&trackParamTmp, clus, 0.139, 5., dEta, dPhi)){ delete trackParam; continue; } if(TMath::Abs(dEta) > (fMatchingParamsEta[0] + pow(convtrack->Pt() + fMatchingParamsEta[1],fMatchingParamsEta[2]))){ delete trackParam; continue; } if(TMath::Abs(dPhi) > (fMatchingParamsPhi[0] + pow(convtrack->Pt() + fMatchingParamsPhi[1],fMatchingParamsPhi[2]))){ delete trackParam; continue; } // track is matched ProcessMatchedTrack(convtrack,clus,kTRUE); delete trackParam; } } // return highestMatchIndex; } Bool_t AliAnalysisTaskElectronStudies::IsSameTrack(Int_t id1, Int_t id2){ if((id1 == -999) || (id2 == -999)){ cout << "ERROR: Track info is missing for one track!" << endl; return kFALSE; } Int_t esdID1 = id1; Int_t esdID2 = id2; if(id1<0) esdID1 = (-1 * id1) - 1; if(id2<0) esdID2 = (-1 * id2) - 1; if(esdID1 == esdID2){ return kTRUE; } else{ return kFALSE; } } Bool_t AliAnalysisTaskElectronStudies::IsInEMCalAcceptance(AliAODConversionPhoton *photon) { Double_t eta = photon->GetPhotonEta(); Double_t phi = photon->GetPhotonPhi(); // cout << phi << endl; // cout << eta << endl; if (phi < 0) phi += 2 * TMath::Pi(); if ((eta < -0.6687) || (eta > 0.66465)) return kFALSE; if ((phi < 1.39626) || (phi > 3.15)) return kFALSE; return kTRUE; } Bool_t AliAnalysisTaskElectronStudies::IsInEMCalAcceptance(AliAODMCParticle *part) { Double_t eta = part->Eta(); Double_t phi = part->Phi(); if (phi < 0) phi += 2 * TMath::Pi(); // cout << phi << endl; // cout << eta << endl; if ((eta < -0.6687) || (eta > 0.66465)) return kFALSE; if ((phi < 1.39626) || (phi > 3.15)) return kFALSE; return kTRUE; } Bool_t AliAnalysisTaskElectronStudies::IsInEMCalAcceptance(AliAODTrack *part) { Double_t eta = part->Eta(); Double_t phi = part->Phi(); if (phi < 0) phi += 2 * TMath::Pi(); // cout << phi << endl; // cout << eta << endl; if ((eta < -0.6687) || (eta > 0.66465)) return kFALSE; if ((phi < 1.39626) || (phi > 3.15)) return kFALSE; return kTRUE; } Int_t AliAnalysisTaskElectronStudies::CheckClustersForMCContribution(Int_t mclabel, TClonesArray *vclus) { Int_t clusterLabel = -1; // position of cluster in array where mc label was found as contribution for (Int_t p = 0; p < vclus->GetEntriesFast(); p++) { AliAODCaloCluster *clus = (AliAODCaloCluster *)vclus->At(p); if (!clus) continue; Int_t *mclabelsCluster = clus->GetLabels(); if (clus->GetNLabels() > 0) { for (Int_t k = 0; k < (Int_t)clus->GetNLabels(); k++) { if (mclabelsCluster[p] == mclabel) clusterLabel = p; } } } return clusterLabel; } //________________________________________________________________________ void AliAnalysisTaskElectronStudies::RelabelAODPhotonCandidates(Bool_t mode){ // Relabeling For AOD Event // ESDiD -> AODiD // MCLabel -> AODMCLabel Int_t* fMCEventPos = nullptr; Int_t* fMCEventNeg = nullptr; Int_t* fESDArrayPos = nullptr; Int_t* fESDArrayNeg = nullptr; if(mode){ fMCEventPos = new Int_t[fReaderGammas->GetEntries()]; fMCEventNeg = new Int_t[fReaderGammas->GetEntries()]; fESDArrayPos = new Int_t[fReaderGammas->GetEntries()]; fESDArrayNeg = new Int_t[fReaderGammas->GetEntries()]; } for(Int_t iGamma = 0;iGamma<fReaderGammas->GetEntries();iGamma++){ AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(iGamma); if(!PhotonCandidate) continue; if(!mode){// Back to ESD Labels PhotonCandidate->SetMCLabelPositive(fMCEventPos[iGamma]); PhotonCandidate->SetMCLabelNegative(fMCEventNeg[iGamma]); PhotonCandidate->SetLabelPositive(fESDArrayPos[iGamma]); PhotonCandidate->SetLabelNegative(fESDArrayNeg[iGamma]); continue; } fMCEventPos[iGamma] = PhotonCandidate->GetMCLabelPositive(); fMCEventNeg[iGamma] = PhotonCandidate->GetMCLabelNegative(); fESDArrayPos[iGamma] = PhotonCandidate->GetTrackLabelPositive(); fESDArrayNeg[iGamma] = PhotonCandidate->GetTrackLabelNegative(); Bool_t AODLabelPos = kFALSE; Bool_t AODLabelNeg = kFALSE; for(Int_t i = 0; i<fInputEvent->GetNumberOfTracks();i++){ AliAODTrack *tempDaughter = static_cast<AliAODTrack*>(fInputEvent->GetTrack(i)); if(!AODLabelPos){ if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelPositive() ){ PhotonCandidate->SetMCLabelPositive(TMath::Abs(tempDaughter->GetLabel())); PhotonCandidate->SetLabelPositive(i); AODLabelPos = kTRUE; } } if(!AODLabelNeg){ if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelNegative()){ PhotonCandidate->SetMCLabelNegative(TMath::Abs(tempDaughter->GetLabel())); PhotonCandidate->SetLabelNegative(i); AODLabelNeg = kTRUE; } } if(AODLabelNeg && AODLabelPos){ break; } } if(!AODLabelPos || !AODLabelNeg){ cout<<"WARNING!!! AOD TRACKS NOT FOUND FOR"<<endl; if(!AODLabelNeg){ PhotonCandidate->SetMCLabelNegative(-999999); PhotonCandidate->SetLabelNegative(-999999); } if(!AODLabelPos){ PhotonCandidate->SetMCLabelPositive(-999999); PhotonCandidate->SetLabelPositive(-999999); } } } if(!mode){ delete[] fMCEventPos; delete[] fMCEventNeg; delete[] fESDArrayPos; delete[] fESDArrayNeg; } }
cff7d23724fc1a46fdc807ed9decb0a2302df391
7d6c1d7e135cdb5e42f0762907cdd1927abf435b
/on_line_planning/pt_paper/src/lm_plan_recognition.cxx
093dc81e5eb6c1ef4aa3863145c6a4829cf78ef7
[ "MIT" ]
permissive
miquelramirez/aamas18-planning-for-transparency
058285ca12c0f270efd213b36225f5fc8d530c7a
dff3e635102bf351906807c5181113fbf4b67083
refs/heads/master
2020-07-01T10:32:01.898653
2019-08-18T22:04:48
2019-08-18T22:04:48
201,146,315
0
0
null
null
null
null
UTF-8
C++
false
false
16,061
cxx
/* Purpose: POM17 plan recognizer */ #include <map> #include <set> #include <limits> #include <algorithm> #include <strips_prob.hxx> #include <fluent.hxx> #include <action.hxx> #include <cond_eff.hxx> #include <fwd_search_prob.hxx> #include <landmark_graph.hxx> #include <landmark_graph_manager.hxx> #include <landmark_graph_generator.hxx> #include "lm_plan_recognition.hxx" #include "utility.hxx" using aptk::agnostic::Fwd_Search_Problem; using Goal_set = std::vector<std::vector<unsigned int>>; using Goal = std::vector<unsigned int>; using aptk::agnostic::Landmarks_Graph_Generator; using aptk::agnostic::Landmarks_Graph; typedef Landmarks_Graph_Generator<Fwd_Search_Problem> Gen_Lms_Fwd; typedef Landmarks_Graph::Node Search_Node; namespace pr_lm{ PlanRecognitionEngine_LM::PlanRecognitionEngine_LM(aptk::STRIPS_Problem * s_prob, Goal_set goal_set, double theta, bool verbose, std::vector<double> priors) : m_strips_model(s_prob), m_goal_set(goal_set), m_theta(theta),m_verbose(verbose), m_goal_set_priors(priors) { generate_landmarks_graphs(); } PlanRecognitionEngine_LM::PlanRecognitionEngine_LM(aptk::STRIPS_Problem const * s_prob, Goal_set goal_set, double theta, bool verbose, std::vector<double> priors) : m_strips_model(NULL), m_goal_set(goal_set), m_theta(theta),m_verbose(verbose), m_goal_set_priors(priors) { aptk::STRIPS_Problem * n = new aptk::STRIPS_Problem(*s_prob); m_strips_model = n; generate_landmarks_graphs(); } void PlanRecognitionEngine_LM::generate_landmarks_graphs(){ Goal_set new_goal_set; for(unsigned i = 0; i < m_goal_set.size(); i++){ new_goal_set.push_back(m_goal_set[i]); for(unsigned j = 0; j < m_goal_set[i].size(); j++){ Goal g; g.push_back(m_goal_set[i][j]); new_goal_set.push_back(g); } } for(unsigned int i = 0; i < new_goal_set.size(); i++){ m_strips_model->set_goal(*m_strips_model, new_goal_set[i]); Fwd_Search_Problem search_prob (m_strips_model); Gen_Lms_Fwd gen_lms( search_prob ); Landmarks_Graph * graph = new Landmarks_Graph( *m_strips_model ); gen_lms.compute_lm_graph_set_additive( *graph ); bool verbose = false; if (verbose){ std::cout << "For Goal: "; for (auto f : new_goal_set[i]){ std::cout << m_strips_model->fluents()[f]->signature() << ","; } std::cout << std::endl; std::cout << "\tLandmarks found are: "; auto e = extract_fluents_from_graph(*graph); for(auto f : e){ std::cout << m_strips_model->fluents()[f]->signature() << ","; } std::cout << std::endl; } Landmarks_Graph_Manager * lm = new Landmarks_Graph_Manager(search_prob, graph); m_lgm_v[new_goal_set[i]] = lm; } } PlanRecognitionEngine_LM::~PlanRecognitionEngine_LM(){ //for(Goal g : m_goal_set){ //delete m_lgm_v[g]; //} } void PlanRecognitionEngine_LM::update_graph(std::vector<unsigned int> observations){ auto init = m_strips_model->init(); for( auto g : m_goal_set ){ auto i = m_lgm_v[g]; i->reset_graph(); i->apply_state(init); aptk::State * root = new aptk::State(*m_strips_model); root->set(init); for(unsigned j = 0; j < observations.size(); j++){ aptk::State* next_root_state = root->progress_through( *(m_strips_model->actions()[observations[j]]) ); i->apply_action( next_root_state, observations[j]); root = next_root_state; } } } std::vector<unsigned int> PlanRecognitionEngine_LM::extract_landmarks(aptk::STRIPS_Problem& s_prob, Goal& g, bool verbose){ s_prob.set_goal(s_prob, g); Fwd_Search_Problem search_prob (&s_prob); Gen_Lms_Fwd gen_lms( search_prob ); Landmarks_Graph graph( s_prob ); gen_lms.compute_lm_graph_set_additive( graph ); std::vector<unsigned int> land_marks_fluents = extract_fluents_from_graph(graph); if (verbose){ std::cout << "For Goal: "; for (auto f : g){ std::cout << s_prob.fluents()[f]->signature() << ","; } std::cout << std::endl; std::cout << "\tLandmarks found are: "; for(auto f : land_marks_fluents){ std::cout << s_prob.fluents()[f]->signature() << ","; } } return land_marks_fluents; } std::vector<unsigned int> PlanRecognitionEngine_LM::extract_fluents_from_graph(Landmarks_Graph& lm){ std::vector<unsigned int> land_marks; std::vector<aptk::agnostic::Landmarks_Graph::Node*> m_lm = lm.m_lm_graph; for ( unsigned k = 0; k < m_lm.size(); k++ ) { auto n = m_lm[k]; land_marks.push_back(n->fluent()); } return land_marks; } std::tuple<std::vector<unsigned int>,std::vector<unsigned int>, std::vector<unsigned int>> PlanRecognitionEngine_LM::partition_facts( aptk::STRIPS_Problem& s_prob, std::vector<unsigned int>& land_marks) { std::vector<unsigned int> f_strictly_activating; std::vector<unsigned int> f_strictly_terminal; std::vector<unsigned int> f_unstable_activating; auto init = s_prob.init(); for (unsigned int f : land_marks){ // Is f in the initial State bool f_init_state = false; if(std::find(init.begin(), init.end(), f) != init.end()) { f_init_state = true; } bool not_in_any_adds = true; bool not_in_any_dels = true; bool not_in_any_precs = true; bool exists_a_f_as_prec = false; bool exists_a_f_as_del = false; bool exists_a_f_as_add = false; for( auto a_p : s_prob.actions() ){ auto adds = a_p->add_vec(); auto dels = a_p->del_vec(); auto precs = a_p->prec_vec(); if(std::find(adds.begin(), adds.end(), f) != adds.end()) { not_in_any_adds = false; exists_a_f_as_add = true; } if(std::find(dels.begin(), dels.end(), f) != dels.end()) { not_in_any_dels = false; exists_a_f_as_del = true; } if(std::find(precs.begin(), precs.end(), f) != precs.end()) { not_in_any_precs = false; exists_a_f_as_prec = true; } } if (f_init_state && not_in_any_adds && not_in_any_dels && exists_a_f_as_prec) f_strictly_activating.push_back(f); if(f_init_state && not_in_any_adds && exists_a_f_as_prec && exists_a_f_as_del) f_unstable_activating.push_back(f); if(exists_a_f_as_add && not_in_any_precs && not_in_any_dels) f_strictly_terminal.push_back(f); } std::tuple<std::vector<unsigned int>,std::vector<unsigned int>, std::vector<unsigned int>> t( f_strictly_activating, f_unstable_activating, f_strictly_terminal ); return t; } double PlanRecognitionEngine_LM::percentage_complete_lm(Goal g, unsigned int f, std::vector<unsigned int> observations){ //auto lmg = m_lgm_v[g]; std::vector<unsigned int> f_s = {f}; std::vector<unsigned int> lms = extract_fluents_from_graph(*(m_lgm_v[f_s]->graph())); if(m_verbose){ std::cout << "\t" << print_fluent_vec(*m_strips_model, f_s) << ": " << print_fluent_vec(*m_strips_model, lms)<< std::endl; } if(lms.size() == 0){ return 0; } std::set<unsigned int> g_a_lm; double percentage_complete; for(auto o : observations){ auto a = m_strips_model->actions()[o]; auto adds = a->add_vec(); auto precs = a->prec_vec(); for ( auto l : lms ){ if ( std::find(adds.begin(), adds.end(),l) != adds.end() ){ g_a_lm.insert(l); continue; } if ( std::find(precs.begin(), precs.end(),l) != precs.end() ){ g_a_lm.insert(l); continue; } } } //std::vector<unsigned int> output(g_a_lm.begin(), g_a_lm.end()); //std::cout << print_fluent_vec(*m_strips_model, output) << std::endl; percentage_complete = (double) g_a_lm.size() / (double) lms.size(); return percentage_complete; } std::map<Goal, double> PlanRecognitionEngine_LM::goal_filtering( std::vector<unsigned int> observations){ std::map<Goal, double> map_goal_percent; double max = 0; //for( unsigned int k = 0 ; k < m_goal_set.size(); k++ ){ //Goal g = m_goal_set[k]; //std::vector<unsigned int> land_marks_g = extract_fluents_from_graph(*(m_lgm_v[g]->graph())); //std::tuple<std::vector<unsigned int>, //std::vector<unsigned int>, std::vector<unsigned int>> fact_partition; //fact_partition = partition_facts(*m_strips_model, land_marks_g); //auto f_strictly_activating = std::get<0>(fact_partition); //auto f_unstable_activating = std::get<1>(fact_partition); //auto f_strictly_terminal = std::get<2>(fact_partition); //if(m_verbose){ //std::cout << "Strictly Activating: " << f_strictly_activating.size() << std::endl; //std::cout << "Unstable Activating: " << f_unstable_activating.size() << std::endl; //std::cout << "Strictly Terminal: " << f_strictly_terminal.size() << std::endl; //} //std::vector<unsigned int> int_fsa_init; //auto init = m_strips_model->init(); //sort(f_strictly_activating.begin(), f_strictly_activating.end()); //sort(init.begin(), init.end()); //std::set_intersection(f_strictly_activating.begin(),f_strictly_activating.end(), //init.begin(),init.end(),back_inserter(int_fsa_init)); //TODO: CLARIFY THIS ////if (int_fsa_init.empty() && f_strictly_activating.size() != 0){ //std::cout << "\tLandmarks found are: "; //for(auto f : land_marks_fluents){ //std::cout << m_strips_model.fluents()[f]->signature() << ","; //} //map_goal_percent[g] = -1; //continue; //} //std::set<unsigned int> achieved_landmarks_g; //bool discardg = false; //for(unsigned int o : observations){ //auto a = m_strips_model->actions()[o]; //auto adds_v = a->add_vec(); //std::set<unsigned int> adds(adds_v.begin(), adds_v.end()); //auto prec_v = a->prec_vec(); //std::set<unsigned int> precs(prec_v.begin(), prec_v.end()); //auto del_v = a->del_vec(); //std::set<unsigned int> dels(del_v.begin(), del_v.end()); //std::set<unsigned int> prec_adds; //std::set<unsigned int> prec_adds_dels; //std::set_union(adds.begin(), adds.end(), //precs.begin(), precs.end(), //std::inserter(prec_adds, prec_adds.begin())); //std::set_union(prec_adds.begin(), prec_adds.end(), //dels.begin(), dels.end(), //std::inserter(prec_adds_dels, prec_adds_dels.begin())); //std::set<unsigned int> fua_fst; //std::set_union(f_unstable_activating.begin(), f_unstable_activating.end(), //f_strictly_terminal.begin(), f_strictly_terminal.end(), //std::inserter(fua_fst, fua_fst.begin())); //std::set<unsigned int> intersect; //std::set_intersection(fua_fst.begin(),fua_fst.end(),prec_adds_dels.begin(), //prec_adds_dels.end(), std::inserter(intersect, intersect.begin())); //if(intersect.empty() && fua_fst.size() != 0){ //discardg = true; //map_goal_percent[g] = -1; //break; //} //if(m_verbose){ //std::cout << "\t\t\tLandmarks in Observation " << a->signature() << ": "; //} //for ( auto l : land_marks_g ){ //if (prec_adds.count(l)) { //if(m_verbose){ //std::cout << m_strips_model->fluents()[l]->signature() << ","; //} //achieved_landmarks_g.insert(l); //} //} //if(m_verbose) //std::cout << std::endl; //} //if(discardg) //break; //auto g1 = g; //double percentage = (double) achieved_landmarks_g.size() / (double)land_marks_g.size(); //if(percentage > max){ //max = percentage; //} //map_goal_percent[g] = percentage; //if(m_verbose){ //std::cout << std::endl; //} //} //for(std::map<Goal,double>::iterator iter = map_goal_percent.begin(); //iter != map_goal_percent.end(); ++iter){ //if(iter->second < max - m_theta) //map_goal_percent[iter->first] = -1; //} return map_goal_percent; } std::map<Goal,double> PlanRecognitionEngine_LM::heuristic(std::vector<unsigned int> observations){ auto goal = m_strips_model->goal(); //auto A_g = goal_filtering(observations); std::map<Goal, double> heuristic; //for(std::map<Goal,double>::iterator iter = A_g.begin(); //iter != A_g.end(); ++iter){ //Goal G = iter->first; for(auto G : m_goal_set){ double sum = 0; //if(iter->second == -1){ //heuristic[G] = -1; //continue; //} if(m_verbose) std::cout << "Goal: " << print_fluent_vec(*m_strips_model, G) << std::endl; for(unsigned int g : G){ int a = percentage_complete_lm(G,g,observations); sum += a; } heuristic[G] = sum / (double) G.size(); //heuristic[G] = (double) iter->second / (double) G.size(); } m_strips_model->set_goal(*m_strips_model, goal); return heuristic; } std::vector<double> PlanRecognitionEngine_LM::plan_recognition( std::vector<unsigned int> observations){ auto h = heuristic(observations); std::vector<double> probs; for (auto G : m_goal_set){ if(h[G] == -1) probs.push_back(0); else probs.push_back(h[G]); } //float sum = 0; //for(auto i : probs){ //sum += i; //} //std::vector<double> priors; //if (sum != 0) //probs = normalize_vector(probs); //else //{ //for (unsigned int i = 0; i < m_goal_set.size(); i++){ //priors.push_back(0.5); //} //probs = normalize_vector(priors); //} probs = normalize_vector(probs); std::vector<double> pOGpG; for (unsigned int i = 0 ; i < probs.size() ; i++){ pOGpG.push_back(probs[i]*(m_goal_set_priors[i])); } return normalize_vector(pOGpG); } //OLD //std::vector<double> PlanRecognitionEngine_LM::plan_recognition( //std::vector<unsigned int> observations){ //std::map<Goal,std::vector<unsigned int>> land_marks_g; //for (Goal g : m_goal_set){ //land_marks_g[g] = extract_fluents_from_graph(*(m_lgm_v[g]->graph())); //} //auto init = m_strips_model->init(); //std::set<unsigned int> observation_landmarks; //for(auto o : observations){ //auto a = m_strips_model->actions()[o]; //auto adds = a->add_vec(); //auto precs = a->prec_vec(); //for (auto a : adds){ //if (std::find(init.begin(), init.end(),a) == init.end()) //observation_landmarks.insert(a); //} //for (auto a : precs){ //if (std::find(init.begin(), init.end(),a) == init.end()) //observation_landmarks.insert(a); //} //} //std::vector<unsigned int> obs_lms(observation_landmarks.begin(),observation_landmarks.end()); //std::vector<double> liklihoods; //for(Goal G : m_goal_set){ //double counter = 0; //for(Goal g : m_goal_set){ //auto int_l = instersection<unsigned int>(land_marks_g[G],land_marks_g[g]); //if(!int_l.empty()) //counter++; //} //auto obs_int = instersection<unsigned int>(land_marks_g[G], obs_lms); //double liklihood = ((double) obs_int.size()) / (counter); //liklihoods.push_back(liklihood); //} //auto normalize_liklihoods = normalize_vector(liklihoods); //print_vector(normalize_liklihoods); //std::vector<double> pOGpG; //for (unsigned int i = 0 ; i < normalize_liklihoods.size() ; i++){ //pOGpG.push_back(normalize_liklihoods[i]*(m_strips_model->m_priors[i])); //} //return normalize_vector(pOGpG); //} }
bf604670f217b0c17d93eb4a31c78cacf026c289
4ef69f0044f45be4fbce54f7b7c0319e4c5ec53d
/include/cv/core/cmd/out/dhseqr.inl
916e4f4aba4fc9b5981781279e494c69b73adb94
[]
no_license
15831944/cstd
c6c3996103953ceda7c06625ee1045127bf79ee8
53b7e5ba73cbdc9b5bbc61094a09bf3d5957f373
refs/heads/master
2021-09-15T13:44:37.937208
2018-06-02T10:14:16
2018-06-02T10:14:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
276
inl
#ifndef __dhseqr__ #define __dhseqr__ #define c_b11 c_b11_dhseqr #define c_b12 c_b12_dhseqr #define c__12 c__12_dhseqr #define c__2 c__2_dhseqr #define c__49 c__49_dhseqr #include "dhseqr.c" #undef c_b11 #undef c_b12 #undef c__12 #undef c__2 #undef c__49 #endif // __dhseqr__
515d0a35f121c01fd16cbef73c087905ea33076f
1d9df1156e49f768ed2633641075f4c307d24ad2
/tizen_src/chromium_impl/content/browser/compositor/evasgl_context_provider.cc
699dd42323d0cdd32a999319b0cb2f3592a8c699
[ "BSD-3-Clause", "LGPL-2.1-or-later", "BSD-2-Clause" ]
permissive
GSIL-Monitor/platform.framework.web.chromium-efl
8056d94301c67a8524f6106482087fd683c889ce
e156100b0c5cfc84c19de612dbdb0987cddf8867
refs/heads/master
2022-10-26T00:23:44.061873
2018-10-30T03:41:51
2018-10-30T03:41:51
161,171,104
0
1
BSD-3-Clause
2022-10-20T23:50:20
2018-12-10T12:24:06
C++
UTF-8
C++
false
false
2,193
cc
// Copyright 2015 Samsung Electronics. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/browser/compositor/evasgl_context_provider.h" #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" #include "third_party/skia/include/gpu/GrContext.h" namespace content { EvasGLContextProvider::EvasGLContextProvider(Evas_GL_API* evas_gl_api, Evas_GL* evas_gl) : evasgl_implementation_(evas_gl_api, evas_gl) { cache_controller_.reset( new viz::ContextCacheController(&evasgl_implementation_, nullptr)); } EvasGLContextProvider::~EvasGLContextProvider() {} bool EvasGLContextProvider::BindToCurrentThread() { return true; } void EvasGLContextProvider::DetachFromThread() {} const gpu::Capabilities& EvasGLContextProvider::ContextCapabilities() const { return capabilities_; } const gpu::GpuFeatureInfo& EvasGLContextProvider::GetGpuFeatureInfo() const { return gpu_feature_info_; } gpu::gles2::GLES2Interface* EvasGLContextProvider::ContextGL() { return &evasgl_implementation_; } gpu::ContextSupport* EvasGLContextProvider::ContextSupport() { return &evasgl_implementation_; } class GrContext* EvasGLContextProvider::GrContext() { if (gr_context_) return gr_context_->get(); gr_context_.reset(new skia_bindings::GrContextForGLES2Interface( ContextGL(), ContextCapabilities())); cache_controller_->SetGrContext(gr_context_->get()); // If GlContext is already lost, also abandon the new GrContext. if (gr_context_->get() && ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { gr_context_->get()->abandonContext(); } return gr_context_->get(); } viz::ContextCacheController* EvasGLContextProvider::CacheController() { return cache_controller_.get(); } void EvasGLContextProvider::InvalidateGrContext(uint32_t state) { if (gr_context_) gr_context_->ResetContext(state); } base::Lock* EvasGLContextProvider::GetLock() { return nullptr; } void EvasGLContextProvider::SetLostContextCallback( const LostContextCallback& lost_context_callback) {} } // namespace content
[ "RetZero@desktop" ]
RetZero@desktop
ce769fce217719f3eb3148a416826ce2dd472e3e
62ca57c22b47d1ce2be9cef57df13aaee2544eb3
/MyGrid/Content/GridRenderer.h
84c44f82e43700d35b8163e94f36fe9f6dfb7ec4
[]
no_license
marcisolti/MyGrid
feffc68bef377c7e920877a68981f44646b377c2
06a093796fda44f3d618d0223d6135ee98fab21a
refs/heads/master
2023-06-25T06:37:23.573819
2021-07-30T09:08:38
2021-07-30T09:08:38
390,695,926
0
0
null
null
null
null
UTF-8
C++
false
false
1,540
h
#pragma once #include "..\Common\DeviceResources.h" #include "..\Common\StepTimer.h" // You can find the docs at %(SolutionDir)..\docs\index.html namespace MyGrid { struct alignas(16) ConstantBufferData { DirectX::XMFLOAT4X4 model; DirectX::XMFLOAT4X4 view; DirectX::XMFLOAT4X4 projection; DirectX::XMFLOAT4 eyePos; DirectX::XMFLOAT2 resolution; }; class GridRenderer { // Constants: const double m_revolutionsPerMinute; const float m_gridOrientation; const float m_gridSize; const int m_totalSegmentCount; public: GridRenderer(const std::shared_ptr<DX::DeviceResources>& deviceResources); void CreateDeviceDependentResources(); void CreateWindowSizeDependentResources(); void ReleaseDeviceDependentResources(); void Update(const DX::StepTimer& timer); void Render(); private: void CreateVertexBuffer(); std::shared_ptr<DX::DeviceResources> m_deviceResources; Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader; Microsoft::WRL::ComPtr<ID3D11GeometryShader> m_geometryShader; Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader; Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout; Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer; uint32_t m_vertexCount; uint32_t m_stride; uint32_t m_offset; Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBuffer; ConstantBufferData m_constantBufferData; Microsoft::WRL::ComPtr<ID3D11BlendState> m_blendState; bool m_loadingComplete; }; }
66648d243f3d684b29abe7cb60c4e78240995665
d41f4166f65f7b6ca163d9d5e9ef1889edcd2654
/Simplifier/Geometry.cpp
47c94fd16a9458df584d6bac71fb0a64a78a7383
[]
no_license
AlexandrShcherbakov/Demo3
ad073a0712de7275899505f3256017b2c357d8dd
0c387fdf9cea8cff8eab8b17bc1b2251aa3b04d7
refs/heads/master
2021-01-21T21:43:13.658982
2016-03-22T11:31:36
2016-03-22T11:31:36
51,869,564
0
0
null
null
null
null
UTF-8
C++
false
false
26,086
cpp
#include "Geometry.h" ///Small changes void Geometry::mergeTwoPoints(uint p1, uint p2) { mergeTwoPoints(p1, p2, (points[p1] + points[p2]) / 2.0f); } void Geometry::mergeTwoPoints(uint p1, uint p2, vec4 newP) { ///Update points /*points[p1] = newP; indices[p2] = p1;*/ uint tmp = std::min(p1, p2); p2 = std::max(p1, p2); p1 = tmp; std::vector<uint> newTriangles; for (uint i = 0; i < triangles.size(); i += 3) { if (triangles[i + 0] == p2) triangles[i + 0] = p1; if (triangles[i + 1] == p2) triangles[i + 1] = p1; if (triangles[i + 2] == p2) triangles[i + 2] = p1; sort(triangles.begin() + i, triangles.begin() + i + 3); if (triangles[i + 0] == triangles[i + 1] || triangles[i + 1] == triangles[i + 2]) continue; newTriangles.push_back(triangles[i + 0]); newTriangles.push_back(triangles[i + 1]); newTriangles.push_back(triangles[i + 2]); } points.erase(points.begin() + p2); points[p1] = newP; } void Geometry::removeTriangle(uint p1, uint p2, uint p3) { vec4 resP = (points[p1] + points[p2] + points[p3]) / 3.0f; mergeTwoPoints(p1, p2, resP); mergeTwoPoints(p1, p3, resP); } void Geometry::removePointsIntoPolygons() { ///Create sets of plants for points and sets of edges std::vector<std::vector<vec4> > plants(points.size()); std::vector<std::set<uint> > edgeList(points.size()); for (uint i = 0; i < triangles.size(); i += 3) { sort(triangles.begin() + i, triangles.begin() + i + 3); uint a_ind = triangles[i + 0]; uint b_ind = triangles[i + 1]; uint c_ind = triangles[i + 2]; vec4 plant = getTrianglePlant(i / 3); bool flag = false; for (uint i = 0; i < plants[a_ind].size() && !flag; ++i) { flag = flag || plant == plants[a_ind][i]; } if (!flag) { plants[a_ind].push_back(plant); } flag = false; for (uint i = 0; i < plants[b_ind].size() && !flag; ++i) { flag = flag || plant == plants[b_ind][i]; } if (!flag) { plants[b_ind].push_back(plant); } flag = false; for (uint i = 0; i < plants[c_ind].size() && !flag; ++i) { flag = flag || plant == plants[c_ind][i]; } if (!flag) { plants[c_ind].push_back(plant); } edgeList[a_ind].insert(b_ind); edgeList[a_ind].insert(c_ind); edgeList[b_ind].insert(a_ind); edgeList[b_ind].insert(c_ind); edgeList[c_ind].insert(a_ind); edgeList[c_ind].insert(b_ind); } ///Remove bad points for (uint i = 0; i < plants.size(); ++i) { //std::cout << i << ' ' << plants[i].size() << ' ' << edgeList[i].size() << std::endl; if (100 * (i + 1) / plants.size() > 100 * i / plants.size()) std::cout << 100 * i / plants.size() << "% bad points removed!" << std::endl; if (plants[i].size() != 1) continue; auto j = edgeList[i].begin(); uint mn = *j; for (j++; j != edgeList[i].end(); ++j) { if (length(points[i] - points[mn]) > length(points[i] - points[*j])) { mn = *j; } } //std::cout << "Nearest point found" << std::endl; mergeTwoPoints(mn, i, points[mn]); for (uint j = i + 1; j < edgeList.size(); ++j) { auto badNumIt = edgeList[j].find(i); if (badNumIt != edgeList[j].end()) { edgeList[j].erase(badNumIt); if (j != mn) edgeList[j].insert(mn); edgeList[j].insert(mn); } } //std::cout << i << " removed" << std::endl; } compressData(); repairGeometry(); } vec3 Geometry::positiveOrient(vec3 v) { if (v.x < 0) return v * -1; if (v.x > 0) return v; if (v.y < 0) return vec3(0, -v.y, -v.z); if (v.y > 0) return v; if (v.z < 0) return vec3(0, 0, -v.z); if (v.z > 0) return v; return v; } void Geometry::removePointsIntoLines() { std::cout << "Remove points into lines start: " << points.size() << ' ' << triangles.size() << std::endl; auto pointLines = getOutLines(); auto edgeList = getBidirAdjacencyListIndices(); std::vector<uint> IndexMap(points.size()); for (uint i = 0; i < pointLines.size(); ++i) { IndexMap[i] = i; if (pointLines[i].size() == 1) { int nearest = -1; for (auto j = edgeList[i].begin(); j != edgeList[i].end(); ++j) { if (IndexMap[*j] == i) continue; if (nearest == -1 || length(points[i] - points[*j]) < length(points[i] - points[nearest])) { nearest = *j; } } IndexMap[i] = nearest; } } for (uint i = 0; i < IndexMap.size(); ++i) { uint j = i; while (j != IndexMap[j]) { j = IndexMap[j]; std::cout << j << ' ' << IndexMap[j] << std::endl; } IndexMap[i] = j; points[i] = points[j]; } mergeSimilarPoints(); std::cout << "Remove points into lines end: " << points.size() << ' ' << triangles.size() << std::endl; /*///Create sets of lines for points and sets of edges //std::vector<std::set<vec3> > lines(points.size()); std::vector<std::vector<vec3> > lines(points.size()); std::vector<std::set<uint> > edgeList(points.size()); for (uint i = 0; i < edges.size(); i += 2) { uint a_ind = edges[i + 0]; uint b_ind = edges[i + 1]; vec3 a = points[a_ind].xyz(); vec3 b = points[b_ind].xyz(); vec3 line = normalize(b - a); bool flag = false; for (uint j = 0; j < lines[a_ind].size() && !flag; ++j) { flag = flag || length(cross(lines[a_ind][j], line)) < VEC_EPS; } if (!flag) { lines[a_ind].push_back(line); edgeList[a_ind].insert(b_ind); } flag = false; for (uint j = 0; j < lines[b_ind].size() && !flag; ++j) { flag = flag || length(cross(lines[b_ind][j], line)) < VEC_EPS; } if (!flag) { lines[b_ind].push_back(line); edgeList[b_ind].insert(a_ind); } } ///Remove bad points for (uint i = 0; i < points.size(); ++i) { if (lines[i].size() != 1) continue; auto j = edgeList[i].begin(); int mn = -1; for (; j != edgeList[i].end(); ++j) { //vec3 line = normalize(points[i].xyz() - points[*j].xyz()); vec3 line = lines[i][0]; if (mn == -1 || (length(points[i] - points[mn]) > length(points[i] - points[*j]) && length(cross(points[i].xyz() - points[mn].xyz(), line)) < VEC_EPS * 1e5)) { mn = *j; } } mergeTwoPoints(mn, i, points[mn]); } compressData(); repairGeometry();*/ } void Geometry::compressData() { ///Create new indices std::vector<vec4> newPoints; std::vector<uint> newIndices; std::vector<uint> indexMap(points.size()); /*for (uint i = 0; i < points.size(); ++i) { if (indices[i] == i) { indexMap[i] = newIndices.size(); newIndices.push_back(newPoints.size()); newPoints.push_back(points[i]); } } for (uint i = 0; i < indices.size(); ++i) { if (indices[i] != i) { indexMap[i] = indexMap[indices[i]]; } } for (uint i = 0; i < edges.size(); ++i) { edges[i] = indexMap[edges[i]]; } for (uint i = 0; i < triangles.size(); ++i) { triangles[i] = indexMap[triangles[i]]; } points = newPoints; indices = newIndices; ////Create index map //std::sort(removedPoints.begin(), removedPoints.end()); std::vector<uint> newIndices(points.size()); for (uint i = 0, sh = 0; i < points.size(); ++i) { if (removedPoints.size() > sh && i == removedPoints[sh]) sh++; newIndices[i] = i - sh; } ///Update edges std::vector<uint> newEdges; for (uint i = 0; i < edges.size(); i += 2) { if (edges[i] == edges[i + 1]) continue; newEdges.push_back(newIndices[edges[i]]); newEdges.push_back(newIndices[edges[i + 1]]); } edges = newEdges; ///Update triangles std::vector<uint> newTriangles; for (uint i = 0; i < triangles.size(); i += 3) { if (triangles[i] == triangles[i + 1] || triangles[i] == triangles[i + 2] || triangles[i + 1] == triangles[i + 2]) continue; newTriangles.push_back(newIndices[triangles[i]]); newTriangles.push_back(newIndices[triangles[i + 1]]); newTriangles.push_back(newIndices[triangles[i + 2]]); } triangles = newTriangles; ///Update points std::vector<vec4> newPoints; for (uint i = 0, sh = 0; i < points.size(); ++i) { if (removedPoints.size() > sh && i == removedPoints[sh]) sh++; else newPoints.push_back(points[i]); } points = newPoints; removedPoints.clear();*/ } void Geometry::compressIndices() { /*std::vector<vec4> edgeBegin; std::vector<std::vector<vec4> > edgeEnds; for (uint i = 0; i < this->edges.size(); i += 2) { vec4 a;// = points[this->edges[i]]; vec4 b;// = points[this->edges[i + 1]]; if (a == b) continue; bool flag1 = false; for (uint j = 0; j < edgeBegin.size() && !flag1; ++j) { if (a == edgeBegin[j]) { flag1 = true; bool flag2 = false; for (uint h = 0; h < edgeEnds[j].size() && !flag2; ++h) { flag2 = flag2 || edgeEnds[j][h] == b; } if (!flag2) edgeEnds[j].push_back(b); } } } std::vector<vec4> edges; for (auto i = 0; i < edgeBegin.size(); ++i) { for (auto j = 0; j < edgeEnds[i].size(); ++j) { edges.push_back(edgeBegin[i]); edges.push_back(edgeEnds[i][j]); } } loadFromEdges(edges);*/ } void Geometry::loadFromTriangles(const std::vector<vec4> &points, const std::vector<uint>& indices) { this->points = std::vector<vec4>(points.begin(), points.end()); this->triangles = std::vector<uint>(indices.begin(), indices.end()); /*this->indices = std::vector<uint>(this->points.size()); for (uint i = 0; i < this->indices.size(); ++i) this->indices[i] = i; edges.clear(); std::vector<std::set<uint> > edgeList(points.size()); for (uint i = 0; i < triangles.size(); i += 3) { sort(triangles.begin() + i, triangles.begin() + i + 3); uint a = triangles[i]; uint b = triangles[i + 1]; uint c = triangles[i + 2]; if (a < b) edgeList[a].insert(b); if (a < c) edgeList[a].insert(c); if (b < c) edgeList[b].insert(c); } for (uint i = 0; i < edgeList.size(); ++i) { for (auto j = edgeList[i].begin(); j != edgeList[i].end(); ++j) { edges.push_back(i); edges.push_back(*j); } }*/ } void Geometry::loadFromEdges(const std::vector<vec4> &edges) { std::vector<vec4> points; std::vector<uint> edgesIndices; for (uint i = 0; i < edges.size(); ++i) { bool flag = false; for (uint j = 0; j < points.size() && !flag; ++j) { flag = edges[i] == points[j]; if (flag) edgesIndices.push_back(j); } if (!flag) { points.push_back(edges[i]); edgesIndices.push_back(points.size() - 1); } } this->points = points; std::vector<std::set<uint> > edgeList(points.size()); for (uint i = 0; i < edgesIndices.size(); i += 2) { uint ind1 = std::min(edgesIndices[i], edgesIndices[i + 1]); uint ind2 = std::max(edgesIndices[i], edgesIndices[i + 1]); if (ind1 == ind2) continue; edgeList[ind1].insert(ind2); } triangles.clear(); for (uint i = 0; i < points.size(); ++i) { for (auto j = edgeList[i].begin(); j != edgeList[i].end(); ++j) { for (auto h = j; h != edgeList[i].end(); ++h) { if (*h == *j) continue; if (edgeList[*j].find(*h) != edgeList[*j].end()) { triangles.push_back(i); triangles.push_back(*j); triangles.push_back(*h); } } } } } std::vector<vec4>& Geometry::getPoints() { return points; } std::vector<uint>& Geometry::getTriangles() { return triangles; } std::vector<uint>& Geometry::getEdges() { //return edges; } const std::vector<vec4>& Geometry::getPoints() const { const std::vector<vec4> &rf = points; return rf; } const std::vector<uint>& Geometry::getTriangles() const { const std::vector<uint> &rf = triangles; return rf; } const std::vector<uint>& Geometry::getEdges() const { //const std::vector<uint> &rf = edges; //return rf; } std::vector<vec4> Geometry::getEdgesAsPoints() const { std::vector<vec4> result; //for (uint i = 0; i < edges.size(); ++i) // result.push_back(points[edges[i]]); return result; } uint Geometry::getTrianglesNumber() const { return triangles.size() / 3; } uint Geometry::getEdgesNumber() const { // return edges.size() / 2; } uint Geometry::getPointsNumber() const { return points.size(); } vec4 Geometry::getTrianglePlant(const uint index) const { vec3 a = points[triangles[3 * index + 0]].xyz(); vec3 b = points[triangles[3 * index + 1]].xyz(); vec3 c = points[triangles[3 * index + 2]].xyz(); vec3 norm = normalize(cross(b - a, c - a)); return vec4(norm, dot(norm, a)); } void Geometry::removeNullEdges() { std::vector<uint> newEdges; // for (uint i = 0; i < edges.size(); i += 2) { // if (edges[i] == edges[i + 1]) continue; // newEdges.push_back(edges[i + 0]); // newEdges.push_back(edges[i + 1]); //} //edges = newEdges; } void Geometry::mergeSimilarPoints() { std::cout << "Merge similar points begin: " << points.size() << ' ' << triangles.size() << std::endl; std::vector<vec4> goodPoints; std::vector<uint> IndexMap(points.size()); for (uint i = 0; i < points.size(); ++i) { bool flag = false; uint goodInd; for (uint j = 0; j < goodPoints.size() && !flag; ++j) { goodInd = j; flag = points[i] == goodPoints[j]; } if (flag) IndexMap[i] = goodInd; else { IndexMap[i] = goodPoints.size(); goodPoints.push_back(points[i]); } } points = goodPoints; std::vector<uint> newTri; for (uint i = 0; i < triangles.size(); i += 3) { triangles[i + 0] = IndexMap[triangles[i + 0]]; triangles[i + 1] = IndexMap[triangles[i + 1]]; triangles[i + 2] = IndexMap[triangles[i + 2]]; sort(triangles.begin() + i, triangles.begin() + i + 3); if (triangles[i] == triangles[i + 1] || triangles[i + 1] == triangles[i + 2]) continue; newTri.push_back(triangles[i + 0]); newTri.push_back(triangles[i + 1]); newTri.push_back(triangles[i + 2]); } triangles = newTri; std::cout << "Merge similar points end: " << points.size() << ' ' << triangles.size() << std::endl; } void Geometry::removeBadTriangles() { std::vector<uint> newTriangles; for (uint i = 0; i < triangles.size(); i += 3) { sort(triangles.begin() + i, triangles.begin() + i + 3); if (triangles[i] == triangles[i + 1] || triangles[i + 1] == triangles[i + 2]) continue; newTriangles.push_back(triangles[i + 0]); newTriangles.push_back(triangles[i + 1]); newTriangles.push_back(triangles[i + 2]); } triangles = newTriangles; } void Geometry::removeSmallTriangles(const float minSqure) { std::cout << "Remove small triangles begin: " << points.size() << ' ' << triangles.size() << std::endl; uint cnt = 0; for (uint i = 0; i < triangles.size(); i += 3) { if (100 * (i + 3) / triangles.size() > 100 * i / triangles.size()) std::cout << 100 * i / triangles.size() << "% small triangles removed " << cnt << std::endl; vec4 a = points[triangles[i + 0]]; vec4 b = points[triangles[i + 1]]; vec4 c = points[triangles[i + 2]]; if (length(cross((a - b).xyz(), (a - c).xyz()) / 2) < minSqure / 100) { cnt++; mergeTwoPoints(triangles[i], triangles[i + 1], (a + b + c) / 3); mergeTwoPoints(triangles[i], triangles[i + 2], (a + b + c) / 3); } } std::cout << "Remove small triangles end: " << points.size() << ' ' << triangles.size() << std::endl; } void Geometry::removeEqualEdges() { /*std::vector<std::set<uint> > edgeList(points.size()); for (uint i = 0; i < edges.size(); i += 2) { sort(edges.begin() + i, edges.begin() + i + 2); edgeList[edges[i]].insert(edges[i + 1]); } std::vector<uint> newEdges; for (uint i = 0; i < edgeList.size(); ++i) { for (auto j = edgeList[i].begin(); j != edgeList[i].end(); ++j) { newEdges.push_back(i); newEdges.push_back(*j); } } edges = newEdges;*/ } void Geometry::repairGeometry() { /*std::cout << points.size() << ' ' << edges.size() << ' ' << triangles.size() << std::endl; mergeSimilarPoints(); std::cout << points.size() << ' ' << edges.size() << ' ' << triangles.size() << std::endl; removeNullEdges(); std::cout << points.size() << ' ' << edges.size() << ' ' << triangles.size() << std::endl; removeEqualEdges(); std::cout << points.size() << ' ' << edges.size() << ' ' << triangles.size() << std::endl; removeBadTriangles(); std::cout << points.size() << ' ' << edges.size() << ' ' << triangles.size() << std::endl;*/ } void Geometry::Write(const std::string &path) const { std::ofstream out(path); out << points.size() << std::endl; out.precision(10); for (auto v: points) out << std::fixed << v.x << ' ' << std::fixed << v.y << ' ' << std::fixed << v.z << ' ' << std::fixed << v.w << ' '; out << std::endl << triangles.size() << std::endl; for (auto i: triangles) out << i << ' '; out.close(); } void Geometry::Read(const std::string &path) { std::ifstream in(path); uint pC; in >> pC; points.resize(pC); for (uint i = 0; i < pC; ++i) { vec4 v; in >> v.x >> v.y >> v.z >> v.w; points[i] = v; } in >> pC; triangles.resize(pC); for (uint i = 0; i < pC; ++i) in >> triangles[i]; in.close(); } std::vector<std::set<uint> > Geometry::getAdjacencyListIndices() { std::vector<std::set<uint> > result(points.size()); for (uint i = 0; i < triangles.size(); i += 3) { std::sort(triangles.begin() + i, triangles.begin() + i + 3); result[triangles[i + 0]].insert(triangles[i + 1]); result[triangles[i + 0]].insert(triangles[i + 2]); result[triangles[i + 1]].insert(triangles[i + 2]); } return result; } std::vector<uint> Geometry::getEdgeListIndices(){ std::vector<uint> result; auto adjListInd = getAdjacencyListIndices(); for (uint i = 0; i < adjListInd.size(); ++i) { for (auto j = adjListInd[i].begin(); j != adjListInd[i].end(); ++j) { result.push_back(i); result.push_back(*j); } } return result; } std::vector<vec4> Geometry::getEdgeList(){ std::vector<vec4> result; auto edgeList = getEdgeListIndices(); for (uint i = 0; i < edgeList.size(); ++i) { result.push_back(points[edgeList[i]]); } return result; } std::vector<std::vector<vec4> > Geometry::getOutLines() { std::vector<std::vector<vec4> > result(points.size()); auto edgeList = getAdjacencyListIndices(); for (uint i = 0; i < points.size(); ++i) { for (auto j = edgeList[i].begin(); j != edgeList[i].end(); ++j) { vec4 newVec = points[*j] - points[i]; bool flag = true; for (uint h = 0; h < result[i].size() && flag; ++h) flag = length(cross(newVec.xyz(), result[i][h].xyz())) >= VEC_EPS; if (flag) result[i].push_back(newVec); } } return result; } std::vector<std::set<uint> > Geometry::getBidirAdjacencyListIndices() { std::vector<std::set<uint> > result(points.size()); for (uint i = 0; i < triangles.size(); i += 3) { result[triangles[i + 0]].insert(triangles[i + 1]); result[triangles[i + 0]].insert(triangles[i + 2]); result[triangles[i + 1]].insert(triangles[i + 0]); result[triangles[i + 1]].insert(triangles[i + 2]); result[triangles[i + 2]].insert(triangles[i + 0]); result[triangles[i + 2]].insert(triangles[i + 1]); } return result; } std::vector<uint> splitPolygonByTriangles(const std::vector<uint> &polygon) { //std::cout << "Split polygons by triangles begin" << std::endl; std::vector<uint> result; for (uint i = 2; i < polygon.size(); ++i) { result.push_back(polygon[0]); result.push_back(polygon[i - 1]); result.push_back(polygon[i]); } //std::cout << "Split polygons by triangles end" << std::endl; return result; } std::vector<std::vector<uint> > mergeTriangles(const std::vector<std::vector<uint> > &triangles) { //std::cout << "Merge triangles begin" << std::endl; std::map<uint, std::map<uint, uint> > neibors; for (uint i = 0; i < triangles.size(); i++) { neibors[triangles[i][0]][triangles[i][1]]++; neibors[triangles[i][0]][triangles[i][2]]++; neibors[triangles[i][1]][triangles[i][0]]++; neibors[triangles[i][1]][triangles[i][2]]++; neibors[triangles[i][2]][triangles[i][1]]++; neibors[triangles[i][2]][triangles[i][0]]++; } std::set<uint> cont; for (auto i = neibors.begin(); i != neibors.end(); ++i) { uint sum = 0; for (auto j = i->second.begin(); j != i->second.end(); ++j) sum += j->second & 1; if (sum) cont.insert(i->first); } std::map<uint, std::set<uint> > edgeList; for (uint i = 0; i < triangles.size(); ++i) { std::vector<uint> subcont; for (uint j = 0; j < 3; ++j) if (cont.find(triangles[i][j]) != cont.end()) subcont.push_back(triangles[i][j]); for (uint j = 0; j < subcont.size(); ++j) { for (uint h = 0; h < subcont.size(); ++h) { if (h == j) continue; edgeList[triangles[i][j]].insert(triangles[i][h]); } } } std::vector<std::vector<uint> > result; std::set<uint> removed; for (auto i = cont.begin(); i != cont.end(); ++i) { uint value = *i; if (removed.find(value) != removed.end()) continue; result.push_back(std::vector<uint>()); while (removed.find(value) == removed.end()) { result.back().push_back(value); removed.insert(value); for (auto j = edgeList[value].begin(); j != edgeList[value].end(); ++j) if (removed.find(*j) == removed.end() && cont.find(*j) != cont.end()) { value = *j; break; } } } //std::cout << "Merge triangles end" << std::endl; return result; } void Geometry::removeExcessPoints() { std::cout << "Remove excess points begin" << std::endl; std::set<uint> badPoints; for (uint i = 0; i < points.size(); ++i) badPoints.insert(i); for (uint i = 0; i < triangles.size(); ++i) badPoints.erase(triangles[i]); std::vector<vec4> newPoints; std::vector<uint> newInd(points.size()); for (uint i = 0; i < points.size(); ++i) { if (badPoints.find(i) == badPoints.end()) { newInd[i] = newPoints.size(); newPoints.push_back(points[i]); } } points = newPoints; for (uint i = 0; i < triangles.size(); ++i) triangles[i] = newInd[triangles[i]]; std::cout << "Remove excess points end" << std::endl; } std::vector<std::vector<uint> > removeNotAnglePoints(const std::vector<std::vector<uint> > &polys, const std::vector<vec4> points) { std::vector<std::vector<uint> > res(polys.size()); for (uint i = 0; i < polys.size(); ++i) { vec3 direct = (points[polys[i][0]] - points[polys[i][1]]).xyz(); for (uint j = 0; j < polys[i].size(); ++j) { vec3 newDir = (points[polys[i][(j + 1) % polys[i].size()]] - points[polys[i][j]]).xyz(); if (length(cross(direct, newDir)) > VEC_EPS) { res[i].push_back(polys[i][j]); } direct = newDir; } } return res; } std::vector<std::vector<std::vector<uint> > > Geometry::groupTrianglesByPlanes() { std::cout << "Group triangles by planes begin" << std::endl; std::vector<std::vector<std::vector<uint> > > result; std::vector<vec4> planes; for (uint i = 0; i < triangles.size(); i += 3) { vec4 plane = getTrianglePlant(i / 3); uint ind = 0; for (; ind < planes.size() && planes[ind] != plane; ++ind); if (ind == planes.size()) { planes.push_back(plane); result.resize(result.size() + 1); } result[ind].push_back(std::vector<uint>(triangles.begin() + i, triangles.begin() + i + 3)); } std::cout << "Group triangles by planes end" << std::endl; return result; } void Geometry::removeInternalPoints() { std::cout << "Remove internal points begin" << std::endl; std::vector<uint> newTriangles; for (auto &plant: groupTrianglesByPlanes()) { for (auto &polygon: mergeTriangles(plant)) { for (auto i: splitPolygonByTriangles(polygon)) { newTriangles.push_back(i); } } break; } triangles = newTriangles; removeExcessPoints(); std::cout << "Remove internal points end" << std::endl; } void Geometry::FirstPlane() { auto plant = groupTrianglesByPlanes()[0]; std::vector<uint> newTriangles; for (uint i = 0; i < plant.size(); ++i) for (uint j = 0; j < plant[i].size(); ++j) newTriangles.push_back(plant[i][j]); triangles = newTriangles; removeExcessPoints(); }
a96af18ac17f1733c882c18738739fd5fe0fab0a
28a43c8d0403d661f85a986e25e14adb29c50106
/arduino_code/arduino_code.ino
e2a042a7ae00abe054b818735fefa21e2240b7fd
[ "MIT" ]
permissive
darmbrus/plant-watering-tracker
53ed53c1e8d6a81c4449c1ded3cd4dbbb01b56e1
cb4f797104c2c4b2ea889d3725157861fcc19399
refs/heads/master
2021-01-11T00:39:19.172170
2016-10-19T04:18:12
2016-10-19T04:18:12
70,503,048
0
2
null
2016-10-19T04:18:13
2016-10-10T15:44:30
Ruby
UTF-8
C++
false
false
357
ino
const int buttonPin = 2; int buttonState = 0; void setup() { Serial.begin(9600); pinMode(buttonPin, INPUT); } void loop() { int randNum = random(300); buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { Serial.println(randNum); while(buttonState) { buttonState = digitalRead(buttonPin); } } delay(50); }
d8a48d1da26efb82b52230f1b657d28e28255eb8
bd6b62b691f2e5fef2d0ad053616de20efbe1fd8
/cpp_c/gcc/lang_spec/inherit/override-by-non-vertual.cpp
b96f7ed08032c2e1bc1f7635d0866d421eee15fd
[]
no_license
kurokawh/test
ed273acb0f559ec17bbc529745e8cf6fb3130e95
172ba3cb4ed89ce5f6d4dfc2dbeccaf0d285bcc8
refs/heads/master
2023-01-25T02:59:49.617869
2023-01-19T05:40:08
2023-01-19T05:40:08
42,255,830
0
0
null
null
null
null
UTF-8
C++
false
false
1,152
cpp
#include <stdlib.h> #include <stdio.h> #include <stdint.h> // check if vertual func can be overrided by non-vertual func. // => non virtuan func can be called. class A { int a; public: virtual void test(A& arg) { printf("A::test(): %d\n", arg.a); } void publicFuncA() { printf("A::pulicFuncA(): \n"); } void publicFuncB() { printf("A::pulicFuncB(): \n"); } protected: void protectedFuncA() { printf("A::pulicFuncA(): \n"); } }; class SubVirtual : public A { int b; public: virtual void test(A& arg) { printf("SubVirtual::test()\n"); A::test(arg); protectedFuncA(); } }; class SubNonVirtual : public A { int b; public: void test(A& arg) { printf("SubNonVirtual::test()\n"); A::test(arg); protectedFuncA(); } }; void test(A& a, const char* s) { printf("== test(%s) ==>\n", s); a.test(a); a.publicFuncA(); printf("<== test(%s) ==\n", s); } int main(int argc, char** argv) { A* a = new A; A* spa = new SubVirtual; spa->test(*spa); spa->publicFuncA(); test(*a, "A"); test(*spa, "SubVirtual"); A* snv = new SubNonVirtual; test(*snv, "SubNonVirtual"); delete snv; delete a; delete spa; return 0; }
a7bcdc72e709f1eccbdd82ae91bed9a5f93fc4fd
af0ecafb5428bd556d49575da2a72f6f80d3d14b
/CodeJamCrawler/dataset/14_23342_6.cpp
1c3fcb70c1814aa6784be1ce3fcca0152aed4d0f
[]
no_license
gbrlas/AVSP
0a2a08be5661c1b4a2238e875b6cdc88b4ee0997
e259090bf282694676b2568023745f9ffb6d73fd
refs/heads/master
2021-06-16T22:25:41.585830
2017-06-09T06:32:01
2017-06-09T06:32:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
939
cpp
#include <iostream> #include <set> #include <vector> using namespace std; int main() { int t,T; cin >> T; int board[4][4]; set<int> s; int i,j; for( t = 0; t < T; t++) { int row; cin >> row; for( i = 0; i < 4; i++ ) { for( j = 0; j < 4; j++ ) { cin >> board[i][j]; } } s.clear(); for( i = 0; i < 4; i++ ) { s.insert(board[row-1][i]); } cin >> row; for( i = 0; i < 4; i++) { for( j = 0; j < 4; j++ ) { cin >> board[i][j]; } } vector<int> result; result.clear(); for( i = 0; i < 4; i++ ) { if( s.find(board[row-1][i]) != s.end() ) { result.push_back(board[row-1][i]); } } cout << "Case #" << (t+1) << ": "; if( result.size() == 1 ) cout << result[0]; else if( result.size() > 1 ) cout << "Bad magician!"; else cout << "Volunteer cheated!"; cout << endl; } return 0; }
d051ee2439151facf88044e833fb25a88c843d07
d0c44dd3da2ef8c0ff835982a437946cbf4d2940
/cmake-build-debug/programs_tiling/function14276/function14276_schedule_0/function14276_schedule_0.cpp
19bad50d62f4787e41fdccac84fa4c51b34a18b6
[]
no_license
IsraMekki/tiramisu_code_generator
8b3f1d63cff62ba9f5242c019058d5a3119184a3
5a259d8e244af452e5301126683fa4320c2047a3
refs/heads/master
2020-04-29T17:27:57.987172
2019-04-23T16:50:32
2019-04-23T16:50:32
176,297,755
1
2
null
null
null
null
UTF-8
C++
false
false
1,698
cpp
#include <tiramisu/tiramisu.h> using namespace tiramisu; int main(int argc, char **argv){ tiramisu::init("function14276_schedule_0"); constant c0("c0", 65536), c1("c1", 1024); var i0("i0", 0, c0), i1("i1", 0, c1), i01("i01"), i02("i02"), i03("i03"), i04("i04"); input input00("input00", {i0}, p_int32); input input01("input01", {i0}, p_int32); input input02("input02", {i1}, p_int32); input input03("input03", {i1}, p_int32); input input04("input04", {i0}, p_int32); input input05("input05", {i0}, p_int32); input input06("input06", {i0}, p_int32); computation comp0("comp0", {i0, i1}, input00(i0) - input01(i0) + input02(i1) + input03(i1) + input04(i0) - input05(i0) * input06(i0)); comp0.tile(i0, i1, 32, 32, i01, i02, i03, i04); comp0.parallelize(i01); buffer buf00("buf00", {65536}, p_int32, a_input); buffer buf01("buf01", {65536}, p_int32, a_input); buffer buf02("buf02", {1024}, p_int32, a_input); buffer buf03("buf03", {1024}, p_int32, a_input); buffer buf04("buf04", {65536}, p_int32, a_input); buffer buf05("buf05", {65536}, p_int32, a_input); buffer buf06("buf06", {65536}, p_int32, a_input); buffer buf0("buf0", {65536, 1024}, p_int32, a_output); input00.store_in(&buf00); input01.store_in(&buf01); input02.store_in(&buf02); input03.store_in(&buf03); input04.store_in(&buf04); input05.store_in(&buf05); input06.store_in(&buf06); comp0.store_in(&buf0); tiramisu::codegen({&buf00, &buf01, &buf02, &buf03, &buf04, &buf05, &buf06, &buf0}, "../data/programs/function14276/function14276_schedule_0/function14276_schedule_0.o"); return 0; }
20f44ac01e4a639ff2659dc043b3a70d96f28af0
349fe789ab1e4e46aae6812cf60ada9423c0b632
/Forms/HOT_SprObject/UHOT_FormaElementaSprObjectImpl.cpp
0e2ad0b3252b5615a355cadf7ac5960cd1c7019c
[]
no_license
presscad/ERP
a6acdaeb97b3a53f776677c3a585ca860d4de980
18ecc6c8664ed7fc3f01397d587cce91fc3ac78b
refs/heads/master
2020-08-22T05:24:15.449666
2019-07-12T12:59:13
2019-07-12T12:59:13
216,326,440
1
0
null
2019-10-20T07:52:26
2019-10-20T07:52:26
null
WINDOWS-1251
C++
false
false
8,775
cpp
#include "vcl.h" #pragma hdrstop #include "UHOT_FormaElementaSprObjectImpl.h" #pragma package(smart_init) extern int NumObject; //--------------------------------------------------------------- THOT_FormaElementaSprObjectImpl::THOT_FormaElementaSprObjectImpl() { Object=new THOT_FormaElementaSprObject(Application); Object->FunctionDeleteImpl=DeleteImpl; NumRefs=0; ++NumObject; flDeleteObject=true; } //--------------------------------------------------------------- THOT_FormaElementaSprObjectImpl::~THOT_FormaElementaSprObjectImpl() { if (flDeleteObject==true) { Object->flDeleteImpl=false; delete Object; } --NumObject; } //--------------------------------------------------------------- void THOT_FormaElementaSprObjectImpl::DeleteImpl(void) { flDeleteObject=false; delete this; } //--------------------------------------------------------------- int THOT_FormaElementaSprObjectImpl::kanQueryInterface(REFIID id_interface, void ** ppv) { int result=0; if (id_interface==IID_IkanUnknown) { *ppv=static_cast<IkanUnknown*> (static_cast<IMainInterface*>(this)); result=-1; } else if (id_interface==IID_IMainInterface) { *ppv=static_cast<IMainInterface*> (this); result=-1; } else if (id_interface==IID_IkanCallBack) { *ppv=static_cast<IkanCallBack*> (this); result=-1; } else if (id_interface==IID_IHOT_FormaElementaSprObject) { *ppv=static_cast<IHOT_FormaElementaSprObject*> (this); result=-1; } else { *ppv=NULL; result=1; return result; } kanAddRef(); return result; } //--------------------------------------------------------------- int THOT_FormaElementaSprObjectImpl::kanAddRef(void) { return (++NumRefs); } //--------------------------------------------------------------- int THOT_FormaElementaSprObjectImpl::kanRelease(void) { if (--NumRefs==0) { delete this; return 0; } return NumRefs; } //--------------------------------------------------------------- //IMainInterface int THOT_FormaElementaSprObjectImpl::get_CodeError(void) { return Object->CodeError; } //--------------------------------------------------------------- void THOT_FormaElementaSprObjectImpl::set_CodeError(int CodeError) { } //--------------------------------------------------------------- UnicodeString THOT_FormaElementaSprObjectImpl::get_TextError(void) { return Object->TextError; } //--------------------------------------------------------------- void THOT_FormaElementaSprObjectImpl::set_TextError(UnicodeString TextError) { } //--------------------------------------------------------------- int THOT_FormaElementaSprObjectImpl::Init(IkanUnknown * i_main_object, IkanUnknown * i_owner_object) { kanQueryInterface(IID_IkanUnknown,(void**) &Object->InterfaceImpl); kanRelease(); Object->ClsIdImpl=CLSID_THOT_FormaElementaSprObjectImpl; Object->InterfaceMainObject=i_main_object; Object->InterfaceOwnerObject=i_owner_object; return Object->Init(); } //--------------------------------------------------------------- int THOT_FormaElementaSprObjectImpl::Done(void) { return Object->Done(); } //--------------------------------------------------------------- //IkanCallBack int THOT_FormaElementaSprObjectImpl::kanExternalEvent(IkanUnknown * pUnk, REFIID id_object,int type_event, int number_procedure_end) { return Object->ExternalEvent(pUnk, //интерфейс на дочерний объект id_object, //тип дочернего объекта type_event, //тип события в дочернем объекте number_procedure_end //номер процедуры в род. форме, обрабатывающей событие выбора ); } //--------------------------------------------------------------- //IHOT_FormaElementaSprObject IHOT_DMSprObject * THOT_FormaElementaSprObjectImpl::get_DM(void) { return Object->DM; } //--------------------------------------------------------------- void THOT_FormaElementaSprObjectImpl::set_DM(IHOT_DMSprObject * DM) { Object->DM=DM; } //--------------------------------------------------------------- bool THOT_FormaElementaSprObjectImpl::get_Vibor(void) { return Object->Vibor; } //--------------------------------------------------------------- void THOT_FormaElementaSprObjectImpl::set_Vibor(bool Vibor) { Object->Vibor=Vibor; } //--------------------------------------------------------------- int THOT_FormaElementaSprObjectImpl::get_NumberProcVibor(void) { return Object->NumberProcVibor; } //--------------------------------------------------------------- void THOT_FormaElementaSprObjectImpl::set_NumberProcVibor(int NumberProcVibor) { Object->NumberProcVibor=NumberProcVibor; } //--------------------------------------------------------------- void THOT_FormaElementaSprObjectImpl::UpdateForm(void) { return Object->UpdateForm(); } //---------------------------------------------------------------
119943f722c510b727fb0c7fc6d8bcb6db01b047
bd1e457d3bc7aba76c1200d15416fa5c1bf847de
/DSA/LAB/Lab 6/Task2.cpp
d57dd5a64bf34c562ff7e33039d90897ee3207c0
[]
no_license
Mu-Ahmad/OOP-CMP-244-241
6da4f2fee88c207a688b8c70a8dd3ad8655921c3
3dd826fff83c9a539f89fc2483ac80c032b269dc
refs/heads/main
2023-06-06T16:30:06.089789
2021-06-18T15:33:35
2021-06-18T15:33:35
303,761,272
17
6
null
2020-10-26T11:14:37
2020-10-13T16:19:04
C++
UTF-8
C++
false
false
4,647
cpp
/* Name: Muhammad Ahmad Roll: BCSF19M509 */ #include <iostream> using namespace std; #define DUMMY 0 class DNode { public: DNode *prev, *next; int data; DNode (int d, DNode *p = NULL , DNode *n = NULL ) { data = d; prev = p; next = n; } }; class DHCLList { public: DNode *head; DHCLList() { head = new DNode(DUMMY); head -> next = head -> prev = head; } void addNodeAtHead(int d) { DNode *newNode = new DNode(d, head, head->next); head -> next -> prev = newNode; head -> next = newNode; } void addNodeAtTail(int d) { DNode *newNode = new DNode(d, head->prev, head); head -> prev -> next = newNode; head -> prev = newNode; } void print(DNode *t) { if (t == head) return; cout << t -> data << ' '; print(t->next); } void print() { print(head->next); cout << '\n'; } void printR(DNode *t) { if (t == head) return; cout << t -> data << ' '; printR(t->prev); } void printR() { printR(head->prev); cout << '\n'; } void addInOrder(int d, DNode *t) { if (t == head || t -> data > d) { DNode *newNode = new DNode (d, t -> prev, t); t -> prev -> next = newNode; t -> prev = newNode; return; } addInOrder(d, t -> next) ; } void addNodeInOrder(int d) { if (head -> next == head) { addNodeAtHead(d); return; } addInOrder(d, head -> next) ; } // ================= Task A ============== // Helper Functions int indexOf(const int& ELEMENT) const { int index = 1; // 1 Based indexing DNode* temp = head->next; while (temp != head) { if (temp->data == ELEMENT) return index; index++; temp = temp->next; } return -1; } void swapNodes(int d1, int d2) { int i1 = indexOf(d1); int i2 = indexOf(d2); // if elements are same or one of element is not found if (i1 == i2 or i1 == -1 or i2 == -1) return; // Do nothing DNode *Node1 = head, *Node2 = head; if (i1 > i2) swap(i1, i2); // Node1 will come before Node2 int t1 = i1, t2 = i2; while (t1--) Node1 = Node1->next; while (t2--) Node2 = Node2->next; if (i2 - i1 == 1) { // Updating Links for neighbors DNode* tempPrev = Node1->prev; Node1->next = Node2->next; Node2->next->prev = Node1; Node1->prev = Node2; Node2->next = Node1; Node2->prev = tempPrev; tempPrev->next = Node2; } else { // Updating Links for non-neighbors DNode* tempPrev = Node1->prev; DNode* tempNext = Node1->next; Node1->next = Node2->next; Node2->next->prev = Node1; Node1->prev = Node2->prev; Node2->prev->next = Node1; Node2->next = tempNext; tempNext->prev = Node2; Node2->prev = tempPrev; tempPrev->next = Node2; } } // ================= Task B ============== void reverse() { head->prev = reverse(head->next); } DNode* reverse(DNode *curr) { //Base Case // Empty list if (curr == head) return head; //Last Element i.e tail or new head if (curr->next == head) { head->next = curr; curr->prev = head; return curr; } // Recursive Case DNode* the_next = reverse(curr->next); // This Will reverse the rest of the list and return a reference to next node // move the current node infront of next the_next->next = curr; //curr node becomes the last curr->next = head; // Repair the prev reference curr->prev = the_next; return curr; } void reverse2() { reverse2(head->next); swap(head->next, head->prev); } void reverse2(DNode* curr) { if (curr == head) return; swap(curr->next, curr->prev); return reverse2(curr->prev); } }; int main() { DHCLList list; cout << "================ Task A ============\n"; list.addNodeAtTail(1); list.addNodeAtTail(2); list.addNodeAtTail(3); list.addNodeAtTail(4); list.addNodeAtTail(5); list.addNodeAtTail(6); list.print(); cout << "Swapping 3 and 4:\n"; list.swapNodes(3, 4); // Swapping Neighbors list.print(); cout << "Swapping 1 and 6:\n"; list.swapNodes(1, 6); // Swapping Non-Neighbors list.print(); cout << "Swapping 2 and 5:\n"; list.swapNodes(2, 5); // Swapping Non-Neighbors list.print(); // Swaping Back to original state cout << "================ Task B ============\n"; list.swapNodes(3, 4); // Swapping Neighbors list.swapNodes(1, 6); // Swapping Non-Neighbors list.swapNodes(2, 5); // Swapping Non-Neighbors cout << "Original List:\n"; list.print(); list.reverse2(); cout << "Reversed List:\n"; list.print(); cout << "Using prev Reference: (In Reverse Order)\n"; // This prove that previous reference are also updated correctly // during the reversing process DNode* start = list.head->prev; while (start != list.head) { cout << start->data << ' '; start = start->prev; } return 0; }
8596d0c908734000468bf1781892c9fbc28d0e06
5852e3aab5677d380c22b2de9508ab043ea28657
/Console Test Chess/FieldG2.cpp
8ed116c7f0c837b1b6f13e665eb8affbdd5bab2a
[]
no_license
ongornbk/Chessy
b1307df6f8bdc95780094d1aa8be709e30f64754
efa0b2cdf0e6d60084b51e409414207f6a01a637
refs/heads/master
2023-04-16T09:54:36.266850
2021-05-01T18:47:40
2021-05-01T18:47:40
363,280,402
0
0
null
null
null
null
UTF-8
C++
false
false
711
cpp
#include "FieldG2.h" const __int64 _stdcall FieldG2::GetIndex() const noexcept { return FIELD_G2; } modern_array<IField*>& FieldG2::GetWhitePawnMoves() { modern_array<IField*>* fields = new modern_array<IField*>(2); if (m_board->GetFieldByIndex(FIELD_F3)->HasBlackPiece()) fields->push_back(m_board->GetFieldByIndex(FIELD_F3)); if (m_board->GetFieldByIndex(FIELD_H3)->HasBlackPiece()) fields->push_back(m_board->GetFieldByIndex(FIELD_H3)); if (m_board->GetFieldByIndex(FIELD_G3)->IsEmpty()) fields->push_back(m_board->GetFieldByIndex(FIELD_G3)); else return *fields; if (m_board->GetFieldByIndex(FIELD_G4)->IsEmpty()) fields->push_back(m_board->GetFieldByIndex(FIELD_G4)); return *fields; }
[ "MSI@DESKTOP-RIEGR2K" ]
MSI@DESKTOP-RIEGR2K
d93b7a1c7fd1e77c85d5c9a69ce93b1f4e2a367a
4002bc4433e1493cea98d1a54a3247c7a14cd39d
/ejemplo 3.cpp
fa6f660fe7a64edc9bc106910aeb374269db4a48
[]
no_license
rafaelapure82/C-Parte-3
481e8cea7afdf6df105e15d5c0096d16766374a1
ec33f0afc12c68dcab50541abc0e6a77de610f58
refs/heads/master
2021-09-04T12:38:40.801038
2018-01-18T18:53:53
2018-01-18T18:53:53
118,021,386
0
0
null
null
null
null
UTF-8
C++
false
false
336
cpp
#include <iostream> // ejemplo 3 #include <string> using namespace std; int main() { string s1 = "Hola ", s3="maria"; string s2="maria"; s2 = "carlos"; //Cambio del valor de la variable string s = s1 + s2; cout << s1 << s2 << '\n'; //Primer mensaje cout << s << '\n'; //Segundo Mensaje s += '\n'; cout << s;//Tercer mensaje }
[ "ing.rafaelmontenegro" ]
ing.rafaelmontenegro
230f1b9c314506328dab84d3f41c115654df9ff7
7c6d70f9fb2bc1aae675e6359f8bcc3026aef7f7
/engine/sdk/inc/RenderTextParam.h
8e53a0b6ff138fd834ad87dfc38ed1b38b6f3fa1
[]
no_license
lxq2537664558/RushGame
1143d05fbf5cba43ff81d350caca5134a9f7dfdd
361ecd2d44c80194460770d3c81355191b5f79eb
refs/heads/master
2020-05-16T23:51:15.655169
2014-04-25T03:43:35
2014-04-25T03:43:35
null
0
0
null
null
null
null
GB18030
C++
false
false
8,046
h
#pragma once #include "CColor.h" #include "CVector3.h" #include "CRectangle.h" #include "CGraphicMallocObject.h" namespace sqr { /// 字体绘制效果.表情是一种特殊的字体 struct FontEffect { enum { Italic = 1<<0, ///< 斜体 Outline = 1<<1, ///< 描边 Shadow = 1<<2, ///< 阴影 Gradual = 1<<3, ///< 渐变色 Vertical = 1<<29, ///< 文字竖排 AutoAdapy = 1<<30, ///< 表情自适应 Multiline = 1<<31, ///< 多行 }; typedef uint32 Mask; }; struct RenderTextParam : public CGraphicMallocObject { public: RenderTextParam(float size); RenderTextParam(); public: void SetPosition(float x, float y, float z = 0.0f, float offset = 0.0f); void SetPosition(const CVector3f& pos); void SetOffset(float offset); const CVector3f& GetPosition() const; float GetSize() const; void SetText(const char* text); void SetText(const char* text, size_t length); void SetText(const string& text); void SetText(const wstring& text); const wchar_t* GetText() const; void SetColor(const CColor& color); const CColor& GetColor() const; void SetGradualColor(const CColor& color); const CColor& GetGradualColor() const; void SetBackColor(const CColor& color); const CColor& GetBackColor() const; void SetRect(const CFRect& rect); const CFRect& GetRect() const; void SetMultiline(bool multiline); bool IsMultiline() const; void SetVertical(bool Vertical); bool IsVertical() const; void SetOutline(bool outline); bool IsOutline() const; void SetShadow(bool shadow); bool IsShadow() const; void SetItalic(bool italic); bool IsItalic() const; void SetFontEffect(FontEffect::Mask mask); FontEffect::Mask GetFontEffect() const; void SetIdx(uint8 idx); const uint8 GetIdx() const; private: CVector3f m_position; CFRect m_rect; GWString m_text; CColor m_color; CColor m_gradualColor; CColor m_backColor; float m_size; uint8 m_idx; FontEffect::Mask m_effectMask; }; //------------------------------------------------------------------------------ inline void RenderTextParam::SetText( const string& text ) { SetText(text.c_str()); } //------------------------------------------------------------------------------ inline void RenderTextParam::SetText( const char* text, size_t length ) { if(length != -1) SetText(string(text, length)); else SetText(text); } //------------------------------------------------------------------------------ inline void RenderTextParam::SetText( const wstring& text ) { m_text = text.c_str(); } //------------------------------------------------------------------------------ inline float RenderTextParam::GetSize() const { return m_size; } //------------------------------------------------------------------------------ inline void RenderTextParam::SetPosition( float x, float y, float z /*= 0.0f*/, float offset /*= 0.0f*/ ) { m_position.Init(x - offset, y, z); } //------------------------------------------------------------------------------ inline void RenderTextParam::SetOffset( float offset ) { m_position.x -= offset; } //------------------------------------------------------------------------------ inline void RenderTextParam::SetGradualColor( const CColor& color ) { m_gradualColor = color; } //------------------------------------------------------------------------------ inline void RenderTextParam::SetBackColor( const CColor& color ) { m_backColor = color; } //------------------------------------------------------------------------------ inline void RenderTextParam::SetRect( const CFRect& rect ) { m_rect = rect; } //------------------------------------------------------------------------------ inline void RenderTextParam::SetMultiline( bool multiline ) { if (multiline) m_effectMask |= FontEffect::Multiline; else m_effectMask &= ~FontEffect::Multiline; } //------------------------------------------------------------------------------ inline void RenderTextParam::SetVertical( bool Vertical ) { if (Vertical) m_effectMask |= FontEffect::Vertical; else m_effectMask &= ~FontEffect::Vertical; } //------------------------------------------------------------------------------ inline void RenderTextParam::SetOutline( bool outline ) { if (outline) m_effectMask |= FontEffect::Outline; else m_effectMask &= ~FontEffect::Outline; } //------------------------------------------------------------------------------ inline void RenderTextParam::SetShadow( bool shadow ) { if (shadow) m_effectMask |= FontEffect::Shadow; else m_effectMask &= ~FontEffect::Shadow; } //------------------------------------------------------------------------------ inline void RenderTextParam::SetItalic( bool italic ) { if (italic) m_effectMask |= FontEffect::Italic; else m_effectMask &= ~FontEffect::Italic; } //------------------------------------------------------------------------------ inline void RenderTextParam::SetPosition( const CVector3f& pos ) { m_position = pos; } //------------------------------------------------------------------------------ inline const CVector3f& RenderTextParam::GetPosition() const { return m_position; } //------------------------------------------------------------------------------ inline const wchar_t* RenderTextParam::GetText() const { return m_text.c_str(); } //------------------------------------------------------------------------------ inline const CColor& RenderTextParam::GetColor() const { return m_color; } //------------------------------------------------------------------------------ inline void RenderTextParam::SetColor( const CColor& color) { m_color = color; } //------------------------------------------------------------------------------ inline const CColor& RenderTextParam::GetGradualColor() const { if (0 == m_gradualColor || (0 == (m_effectMask & FontEffect::Gradual))) return m_color; return m_gradualColor; } //------------------------------------------------------------------------------ inline const CColor& RenderTextParam::GetBackColor() const { return m_backColor; } //------------------------------------------------------------------------------ inline const CFRect& RenderTextParam::GetRect() const { return m_rect; } //------------------------------------------------------------------------------ inline bool RenderTextParam::IsMultiline() const { return 0 != (m_effectMask & FontEffect::Multiline); } //------------------------------------------------------------------------------ inline bool RenderTextParam::IsVertical() const { return 0 != (m_effectMask & FontEffect::Vertical); } //------------------------------------------------------------------------------ inline bool RenderTextParam::IsOutline() const { return 0 != (m_effectMask & FontEffect::Outline); } //------------------------------------------------------------------------------ inline bool RenderTextParam::IsShadow() const { return 0 != (m_effectMask & FontEffect::Shadow); } //------------------------------------------------------------------------------ inline bool RenderTextParam::IsItalic() const { return 0 != (m_effectMask & FontEffect::Italic); } //------------------------------------------------------------------------------ inline void RenderTextParam::SetFontEffect( FontEffect::Mask mask ) { m_effectMask = mask; } //------------------------------------------------------------------------------ inline FontEffect::Mask RenderTextParam::GetFontEffect() const { return m_effectMask; } //------------------------------------------------------------------------------- inline void RenderTextParam::SetIdx(uint8 idx) { m_idx = idx; } //------------------------------------------------------------------------------- inline const uint8 RenderTextParam::GetIdx() const { return m_idx; } }
a8ed1387e8a143a87b47156cae493118a10e00da
c0e0138bff95c2eac038349772e36754887a10ae
/mdk_release_18.08.10_general_purpose/mdk/common/components/imageWarpDyn/compShvDynApps/imageWarpDynlib/Entry.cpp
07c26e08a49b370ed278dbfb6038da9bef214b80
[]
no_license
elfmedy/vvdn_tofa
f24d2e1adc617db5f2b1aef85f478998aa1840c9
ce514e0506738a50c0e3f098d8363f206503a311
refs/heads/master
2020-04-13T17:52:19.490921
2018-09-25T12:01:21
2018-09-25T12:01:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
19,912
cpp
/// /// @file /// @copyright All code copyright Movidius Ltd 2012, all rights reserved. /// For License Warranty see: common/license.txt /// /// @brief Image warp component /// // 1: Includes // ---------------------------------------------------------------------------- #include <math.h> #include <stdio.h> #include <string.h> #include <assert.h> #include <svuCommonShave.h> #include "warpMeshExpand.h" #include "warpMeshSample8bit.h" #include "imageWarpDefines.h" #include "imageWarp.h" #ifdef USE_CMX_DMA_NEW_DRIVER #include <scCmxDma.h> #else #include "swcCdma.h" #endif #include "swcFrameTypes.h" #include "moviVectorUtils.h" // 2: Source Specific #defines and types (typedef,enum,struct) // ---------------------------------------------------------------------------- #define NO_DDR_OUTPUT ((u32)0xFFFFFFFF) //#define USE_DMA typedef struct meshPortion { tileList* head; }meshPortion; // 3: Global Data (Only if absolutely necessary) // ---------------------------------------------------------------------------- // Sections decoration is required here for downstream tool // 4: Static Local Data // ---------------------------------------------------------------------------- // Buffers __attribute__((aligned(16))) unsigned char inputBufferMem[CMX_BUFFER_SIZE]; __attribute__((aligned(16))) unsigned char outBufferMem[2][OUT_TILE_SIZE]; #ifdef USE_CMX_DMA_NEW_DRIVER ScCmxDmaTransaction list[2]; ScCmxDmaTransactionHnd ref[2]; #else dmaTransactionList_t list[2]; dmaTransactionList_t *ref[2]; #endif meshPortion meshLUT[MESH_LUT_LENGTH + 1]; u32 tileLutElemCount; reTileEntry tiles[2]; reTileEntry referenceTile; __attribute__((aligned(16))) half mx[OUT_TILE_WIDTH * OUT_TILE_WIDTH + 8]; __attribute__((aligned(16))) half my[OUT_TILE_WIDTH * OUT_TILE_WIDTH + 8]; // 5: Static Function Prototypes // ---------------------------------------------------------------------------- // 6: Functions Implementation // ---------------------------------------------------------------------------- static inline float min4Elem(float4 vec) { float xmin; xmin = __builtin_shave_cmu_min_f32_rr_float(vec[0], vec[1]); xmin = __builtin_shave_cmu_min_f32_rr_float(xmin, vec[2]); return __builtin_shave_cmu_min_f32_rr_float(xmin, vec[3]); } static inline float max4Elem(float4 vec) { float xmax; xmax = __builtin_shave_cmu_max_f32_rr_float(vec[0], vec[1]); xmax = __builtin_shave_cmu_max_f32_rr_float(xmax, vec[2]); return __builtin_shave_cmu_max_f32_rr_float(xmax, vec[3]); } static void initTileBuffers(reTileEntry* currTile, u8* buffer, u32 lineLength) { u32 ix; for(ix = 0; ix < VERTICAL_PAD; ix++) { currTile->cmxInBuffP[ix] = (u8*)buffer + CMX_BUFFER_LINES * lineLength + HORIZONTAL_PAD; currTile->cmxInBuffP[ix + CMX_BUFFER_LINES + VERTICAL_PAD] = (u8*)buffer + CMX_BUFFER_LINES * lineLength + HORIZONTAL_PAD; } for(ix = 0; ix < CMX_BUFFER_LINES; ix++) { currTile->cmxInBuffP[ix + VERTICAL_PAD] = (u8*)buffer + ix * lineLength + HORIZONTAL_PAD; } currTile->swapP = (u8*)buffer + (CMX_BUFFER_LINES + 1) * lineLength + HORIZONTAL_PAD; } static inline void rotateBufferPointers(reTileEntry* currTile) { // TODO: optimize u32 i; u8* swapP = currTile->cmxInBuffP[VERTICAL_PAD]; for(i = 0; i < CMX_BUFFER_LINES - 1 ; i++) { currTile->cmxInBuffP[i + VERTICAL_PAD] = currTile->cmxInBuffP[i + VERTICAL_PAD + 1]; } currTile->cmxInBuffP[CMX_BUFFER_LINES + VERTICAL_PAD - 1] = currTile->swapP; currTile->swapP = swapP; } static inline void adjustBufferPointers(reTileEntry* currTile, reTileEntry* refTile, int amount) { // TODO: optimize u32 i; uint4* lineP = (uint4*)&currTile->cmxInBuffP[VERTICAL_PAD]; uint4* lineP2 = (uint4*)&refTile->cmxInBuffP[VERTICAL_PAD]; for(i = 0; i < CMX_BUFFER_LINES >> 2 ; i++) { lineP[i] = lineP2[i] + (uint4)amount; } currTile->cmxInBuffP[CMX_BUFFER_LINES + VERTICAL_PAD - 1] = refTile->cmxInBuffP[CMX_BUFFER_LINES + VERTICAL_PAD - 1] + amount; } static inline void prepareMesh(meshStruct* mesh, frameSpec* frSpec, tileList* tileNodes) { unsigned int i, j, k; unsigned int meshH = mesh->meshHeight; unsigned int meshW = mesh->meshWidth; float *my = mesh->meshY; for (j = 0; j < frSpec->height; j++ ) { meshLUT[j].head = NULL; } meshLUT[MESH_LUT_LENGTH].head = NULL; tileLutElemCount = 0; for (i = 0; i < (meshH - 1); i++ ) { // Process all cells horizontally. We are doing vectorized processing here, we process 3 elements in an iteration // We use elements j, j+1, j+2, j+3 for (j = 0; j < meshW - 3; j += 3 ) { u32 ind = i * meshW + j; float4* first = (float4*)&my[ind]; float4* second = (float4*)&my[ind + meshW]; float4 min = __builtin_shave_cmu_min_f32_rr_float4(first[0], second[0]); float4 max = __builtin_shave_cmu_max_f32_rr_float4(first[0], second[0]); float4 min2 = __builtin_shave_cmu_alignvec_rri_float4(min, min, 4); float4 max2 = __builtin_shave_cmu_alignvec_rri_float4(max, max, 4); min = __builtin_shave_cmu_min_f32_rr_float4(min, min2); max = __builtin_shave_cmu_max_f32_rr_float4(max, max2); int4 minInt = mvuConvert_int4(min); int4 maxInt = mvuConvert_int4(max); int4 diff = maxInt - minInt; for(k = 0; k < 3; k++) { if ((diff[k] <= CMX_BUFFER_LINES) && (minInt[k] < (int)frSpec->height) && (maxInt[k] >= 0) && (minInt[k] > - VERTICAL_PAD)) { if (minInt[k] > 0) { tileNodes[tileLutElemCount].next = meshLUT[minInt[k]].head; tileNodes[tileLutElemCount].x = j + k; tileNodes[tileLutElemCount].y = i; meshLUT[minInt[k]].head = &tileNodes[tileLutElemCount++]; } else { tileNodes[tileLutElemCount].next = meshLUT[0].head; tileNodes[tileLutElemCount].x = j + k; tileNodes[tileLutElemCount].y = i; meshLUT[0].head = &tileNodes[tileLutElemCount++]; } } else { tileNodes[tileLutElemCount].next = meshLUT[MESH_LUT_LENGTH].head; tileNodes[tileLutElemCount].x = j + k; tileNodes[tileLutElemCount].y = i; meshLUT[MESH_LUT_LENGTH].head = &tileNodes[tileLutElemCount++]; } } } // In case the mesh width was not multiple of 3, we need to process the last elements u32 ind = i * meshW + j; float4* first = (float4*)&my[ind]; float4* second = (float4*)&my[ind + meshW]; float4 min = __builtin_shave_cmu_min_f32_rr_float4(first[0], second[0]); float4 max = __builtin_shave_cmu_max_f32_rr_float4(first[0], second[0]); float4 min2 = __builtin_shave_cmu_alignvec_rri_float4(min, min, 4); float4 max2 = __builtin_shave_cmu_alignvec_rri_float4(max, max, 4); min = __builtin_shave_cmu_min_f32_rr_float4(min, min2); max = __builtin_shave_cmu_max_f32_rr_float4(max, max2); int4 minInt = mvuConvert_int4(min); int4 maxInt = mvuConvert_int4(max); int4 diff = maxInt - minInt; // Processing last cells. for(k = 0; j + k < meshW - 1; k++) { if ((diff[k] <= CMX_BUFFER_LINES) && (minInt[k] < (int)frSpec->height) && (maxInt[k] >= 0) && (minInt[k] > - VERTICAL_PAD)) { if (minInt[k] > 0) { tileNodes[tileLutElemCount].next = meshLUT[minInt[k]].head; tileNodes[tileLutElemCount].x = j + k; tileNodes[tileLutElemCount].y = i; meshLUT[minInt[k]].head = &tileNodes[tileLutElemCount++]; } else { tileNodes[tileLutElemCount].next = meshLUT[0].head; tileNodes[tileLutElemCount].x = j + k; tileNodes[tileLutElemCount].y = i; meshLUT[0].head = &tileNodes[tileLutElemCount++]; } } else { tileNodes[tileLutElemCount].next = meshLUT[MESH_LUT_LENGTH].head; tileNodes[tileLutElemCount].x = j + k; tileNodes[tileLutElemCount].y = i; meshLUT[MESH_LUT_LENGTH].head = &tileNodes[tileLutElemCount++]; } } } } static inline void prepareTile(reTileEntry* tile, meshStruct* mesh, frameBuffer *inputFb, frameBuffer *outputFb, tileList* coord, unsigned int cmxY) { float4 x,y; unsigned int out_width = outputFb->spec.width; unsigned int in_width = inputFb->spec.width; unsigned int meshW = mesh->meshWidth; float *mx = mesh->meshX; float *my = mesh->meshY; unsigned int tileIndex = coord->y * meshW + coord->x; x[0] = mx[tileIndex]; x[1] = mx[tileIndex + 1]; x[2] = mx[tileIndex + meshW]; x[3] = mx[tileIndex + meshW + 1]; y[0] = my[tileIndex] - cmxY; y[1] = my[tileIndex + 1] - cmxY; y[2] = my[tileIndex + meshW] - cmxY; y[3] = my[tileIndex + meshW + 1] - cmxY; float min = min4Elem(x); float max = max4Elem(x); float minFloor = (int)(min - __builtin_shave_sau_frac_f32_r(min)); x -= minFloor; tile->dstOffsetDDR = coord->y * OUT_TILE_HEIGHT * out_width + coord->x * OUT_TILE_WIDTH; if (min > in_width || max < 0) { tile->isInsideImg = 0; // insert in the list which will be filled with padding } else { tile->isInsideImg = 1; adjustBufferPointers(tile, &referenceTile, (unsigned int) minFloor); tile->xCoords = mvuConvert_half4(x); tile->yCoords = mvuConvert_half4(y); } } static inline void processTile(reTileEntry* tile, frameBuffer *inputFb, frameBuffer *outputFb, unsigned short paddingvalue, dmaRequesterId dmaId) { UNUSED(outputFb); UNUSED(paddingvalue); UNUSED(dmaId); mvcvWarpMeshExpand_asm((half*)&tile->xCoords, (half*)&tile->yCoords, mx, my); mvcvWarpMeshSample8bit_asm(&tile->cmxInBuffP[VERTICAL_PAD], tile->cmxOutBuff, mx, my, inputFb->spec.width + 2 * HORIZONTAL_PAD, CMX_BUFFER_LINES); } // scCmxDmaResolveRelAddr is static inline in CMXDMA driver; TODO find a better solution than copying the function here // static uint32_t scCmxDmaResolveRelAddr(uint32_t in_addr, uint32_t shave_number) { uint32_t window = 0; uint32_t window_base; uint32_t *win_reg_ptr = (uint32_t *)(SHAVE_0_BASE_ADR + (SVU_SLICE_OFFSET * shave_number) + SLC_TOP_OFFSET_WIN_A); uint32_t resolved; switch (in_addr >> 24) { case 0x1C: window = 0; break; case 0x1D: window = 1; break; case 0x1E: window = 2; break; case 0x1F: window = 3; break; default: return (in_addr); break; // absolute address, no translation is to be done } window_base = win_reg_ptr[window]; resolved = ((in_addr & 0x00FFFFFF) + window_base); return resolved; } extern "C" void Entry(meshStruct* mesh, frameBuffer *inputFb, frameBuffer *outputFb, tileList* tileNodes, unsigned short paddingvalue) { unsigned int lineId; unsigned char *img = inputFb->p1; unsigned char *out_img = outputFb->p1; unsigned int out_width = outputFb->spec.width; unsigned int out_height = outputFb->spec.height; unsigned int in_width = inputFb->spec.width; unsigned int in_width_pad = inputFb->spec.width + 2* HORIZONTAL_PAD; reTileEntry* currTile, *nextTile, *swapTile; static u32 id1; #ifdef USE_CMX_DMA_NEW_DRIVER ScCmxDmaInitialize(NULL); #else id1 = dmaInitRequester(3); #endif assert((CMX_BUFFER_LINES - 1) % 4 == 0); // memset(inputBufferMem, paddingvalue, CMX_BUFFER_SIZE); currTile = &tiles[0]; nextTile = &tiles[1]; initTileBuffers(currTile, inputBufferMem, in_width_pad); initTileBuffers(nextTile, inputBufferMem, in_width_pad); initTileBuffers(&referenceTile, inputBufferMem, in_width_pad); prepareMesh(mesh, &inputFb->spec, tileNodes); lineId = 0; while (meshLUT[lineId].head == NULL) lineId++; #ifdef USE_CMX_DMA_NEW_DRIVER ScCmxDmaCreateStrideTransaction( &ref[0], &list[0], img + lineId * in_width, currTile->cmxInBuffP[VERTICAL_PAD], in_width, in_width, in_width, in_width_pad, in_width * CMX_BUFFER_LINES); ScCmxDmaStartTransfer(&ref[0]); // create output transaction with dummy addresses. We will fill it later ScCmxDmaCreateStrideTransaction( &ref[1], &list[1], img + lineId * in_width, // new CMXDMA driver requires addr!=NULL here, even if addr is updated later out_img + NO_DDR_OUTPUT, OUT_TILE_WIDTH, OUT_TILE_WIDTH, OUT_TILE_WIDTH, inputFb->spec.width, OUT_TILE_WIDTH * OUT_TILE_HEIGHT); ScCmxDmaWaitTransaction(&ref[0]); #else ref[0] = dmaCreateTransactionFullOptions( id1, &list[0], img + lineId * in_width, currTile->cmxInBuffP[VERTICAL_PAD], in_width * CMX_BUFFER_LINES, in_width, in_width, in_width, in_width_pad); dmaStartListTask(ref[0]); // create output transaction with dummy addresses. We will fill it later ref[1] = dmaCreateTransactionFullOptions( id1, &list[1], NULL, out_img + NO_DDR_OUTPUT, OUT_TILE_WIDTH * OUT_TILE_HEIGHT, OUT_TILE_WIDTH, OUT_TILE_WIDTH, OUT_TILE_WIDTH, inputFb->spec.width); dmaWaitTask(ref[0]); #endif // USE_CMX_DMA_NEW_DRIVER u8* dmaSrcAddress = img + in_width * (lineId + CMX_BUFFER_LINES); #ifdef USE_CMX_DMA_NEW_DRIVER ScCmxDmaCreateTransaction( &ref[0], &list[0], dmaSrcAddress, referenceTile.swapP, in_width); #else ref[0] = dmaCreateTransaction( id1, &list[0], dmaSrcAddress, referenceTile.swapP, in_width); #endif // USE_CMX_DMA_NEW_DRIVER currTile->cmxOutBuff = outBufferMem[0]; nextTile->cmxOutBuff = outBufferMem[1]; //main loop for (; lineId + 1 + CMX_BUFFER_LINES < out_height;lineId++) { u32 i; list[0].src = img + in_width * (lineId + CMX_BUFFER_LINES); list[0].dst = (u8 *)scCmxDmaResolveRelAddr((u32)referenceTile.swapP, scGetShaveNumber()); #ifdef USE_CMX_DMA_NEW_DRIVER ScCmxDmaStartTransfer(&ref[0]); #else dmaStartListTask(ref[0]); #endif // USE_CMX_DMA_NEW_DRIVER tileList *listP2, * listP = meshLUT[lineId].head; list[1].dst = (void*)NO_DDR_OUTPUT; if (listP != NULL) { #ifdef USE_CMX_DMA_NEW_DRIVER ScCmxDmaWaitTransaction(&ref[0]); #else dmaWaitTask(ref[0]); #endif while (listP != NULL) { if (list[1].dst != (void*)NO_DDR_OUTPUT) { #ifdef USE_CMX_DMA_NEW_DRIVER ScCmxDmaWaitTransaction(&ref[1]); #else dmaWaitTask(ref[1]); #endif // USE_CMX_DMA_NEW_DRIVER } //prepare tile may reorganize the list listP2 = listP; listP = listP->next; prepareTile(currTile, mesh, inputFb, outputFb, listP2, lineId); if (currTile->isInsideImg) processTile(currTile, inputFb, outputFb, paddingvalue, id1); u8* dstAddress = outputFb->p1 + currTile->dstOffsetDDR; u8* srcAddress = currTile->cmxOutBuff; if (currTile->isInsideImg) { #ifdef USE_DMA list[1].src = srcAddress; list[1].dst = dstAddress; ScCmxDmaStartTransfer(&ref[1]); #else for(i = 0; i < OUT_TILE_HEIGHT; ++i) { memcpy(dstAddress, srcAddress, OUT_TILE_WIDTH); dstAddress += inputFb->spec.width; srcAddress += OUT_TILE_WIDTH; } #endif } else { for(i = 0; i < OUT_TILE_HEIGHT; ++i) { memset(dstAddress, paddingvalue, OUT_TILE_WIDTH); dstAddress += inputFb->spec.width; } list[1].dst = (void*)NO_DDR_OUTPUT; } swapTile = currTile; currTile = nextTile; nextTile = swapTile; } #ifdef USE_DMA if (nextTile->dstOffsetDDR != NO_DDR_OUTPUT) dmaWaitTask(ref[1]); #endif } else { #ifdef USE_CMX_DMA_NEW_DRIVER ScCmxDmaWaitTransaction(&ref[0]); #else dmaWaitTask(ref[0]); #endif // USE_CMX_DMA_NEW_DRIVER } rotateBufferPointers(&referenceTile); } int i; // padding for (; lineId < out_height;lineId++) { referenceTile.swapP = referenceTile.cmxInBuffP[0]; tileList* listP = meshLUT[lineId].head; while (listP != NULL) { prepareTile(currTile, mesh, inputFb, outputFb, listP, lineId); processTile(currTile, inputFb, outputFb, paddingvalue, id1); u8* dstAddress = outputFb->p1 + currTile->dstOffsetDDR; u8* srcAddress = currTile->cmxOutBuff; if (currTile->dstOffsetDDR != NO_DDR_OUTPUT) for(i = 0; i < OUT_TILE_HEIGHT; ++i) { memcpy(dstAddress, srcAddress, OUT_TILE_WIDTH); dstAddress += inputFb->spec.width; srcAddress += OUT_TILE_WIDTH; } listP = listP->next; } rotateBufferPointers(&referenceTile); } // fill out the tiles which are out of image tileList* listP = meshLUT[MESH_LUT_LENGTH].head; while (listP != NULL) { u8* dstAddress = out_img + listP->y * OUT_TILE_HEIGHT * out_width + listP->x * OUT_TILE_WIDTH; for(i = 0; i < OUT_TILE_HEIGHT; ++i) { memset(dstAddress, paddingvalue, OUT_TILE_WIDTH); dstAddress += inputFb->spec.width; } listP = listP->next; } }
8e865311140b493eab6287c49553ba57a4195c95
54fae68239e935143f77e3bca9513cb0a0263476
/Chapter20/exercises/20.09/ex_2009.cpp
4f8d747c089b0280a1ffda39468279fb6245835c
[]
no_license
CHENGCHANGHU/Cpp-How-To-Program-9E
9e3406c0079960b366f6c636ab56caed807e3ac7
e9a37f2717e17dd5b37f80e27ab52b7f664853be
refs/heads/master
2021-04-03T05:38:48.952450
2018-02-20T23:10:50
2018-02-20T23:10:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,209
cpp
/* * ===================================================================================== * * Filename: ex_2009.cpp * * Description: Exercise 20.09 - Copying a List in Reverse Order * * Version: 1.0 * Created: 13/06/17 12:12:56 * Revision: none * Compiler: g++ * * Author: Siidney Watson - [email protected] * Organization: LolaDog Studio * * ===================================================================================== */ #include <iostream> #include "List.hpp" int main(int argc, const char* argv[]) { List<char> charList; List<char> charListRev; // populate base list for (char c = 'a'; c <= 'j'; ++c) { charList.insertAtBack(c); } // iterate over base insert at front on charListRev auto iter = charList.begin(); while (iter != charList.end()) { charListRev.insertAtFront(iter->getData()); iter = iter->next(); // copy last element if (iter == charList.end()) { charListRev.insertAtFront(iter->getData()); } } charList.print(); std::cout << std::endl; charListRev.print(); std::cout << std::endl; return 0; }
c22c1fe3a1a2b3916f0fb5e6a9cd679f2353c418
8ab64d4f95421180c7238a707a59753eb7102428
/chrome/browser/chromeos/policy/remote_commands/device_command_start_crd_session_job.h
76c4b2daeb37787393d28d8e7f7f6eddda3f2aec
[ "BSD-3-Clause" ]
permissive
cyCao350/chromium
3400144ab22bde9ca179547602857cc3306de857
90ed3e55ebf1db93db956c753f48d692e8f46c8b
refs/heads/master
2023-01-09T13:09:00.816731
2018-08-02T06:33:19
2018-08-02T06:33:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,078
h
// Copyright 2018 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 CHROME_BROWSER_CHROMEOS_POLICY_REMOTE_COMMANDS_DEVICE_COMMAND_START_CRD_SESSION_JOB_H_ #define CHROME_BROWSER_CHROMEOS_POLICY_REMOTE_COMMANDS_DEVICE_COMMAND_START_CRD_SESSION_JOB_H_ #include <string> #include "base/callback.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "base/values.h" #include "components/policy/core/common/remote_commands/remote_command_job.h" namespace policy { // Remote command that would start Chrome Remote Desktop host and return auth // code. This command is usable only for devices running Kiosk sessions. class DeviceCommandStartCRDSessionJob : public RemoteCommandJob { public: enum ResultCode { // Successfully obtained access code. SUCCESS = 0, // Failed as required services are not launched on the device. FAILURE_SERVICES_NOT_READY = 1, // Failed as device is not running in Kiosk mode. FAILURE_NOT_A_KIOSK = 2, // Failed as device is currently in use and no interruptUser flag is set. FAILURE_NOT_IDLE = 3, // Failed as we could not get OAuth token for whatever reason. FAILURE_NO_OAUTH_TOKEN = 4, // Failed as we could not get ICE configuration for whatever reason. FAILURE_NO_ICE_CONFIG = 5, // Failure during attempt to start CRD host and obtain CRD token. FAILURE_CRD_HOST_ERROR = 6, }; using OAuthTokenCallback = base::OnceCallback<void(const std::string&)>; using AuthCodeCallback = base::OnceCallback<void(const std::string&)>; using ICEConfigCallback = base::OnceCallback<void(base::Value)>; using ErrorCallback = base::OnceCallback<void(ResultCode, const std::string&)>; // A delegate interface used by DeviceCommandStartCRDSessionJob to retrieve // its dependencies. class Delegate { public: virtual ~Delegate() {} // Check if there exists an active CRD session. virtual bool HasActiveSession() = 0; // Run |callback| once active CRD session is terminated. virtual void TerminateSession(base::OnceClosure callback) = 0; // Check if required system services are ready. virtual bool AreServicesReady() = 0; // Check if device is running in Kiosk mode. virtual bool IsRunningKiosk() = 0; // Return current user idleness period. virtual base::TimeDelta GetIdlenessPeriod() = 0; // Attempts to get OAuth token for CRD Host. virtual void FetchOAuthToken(OAuthTokenCallback success_callback, ErrorCallback error_callback) = 0; // Attempts to get ICE configuration for CRD Host. virtual void FetchICEConfig(const std::string& oauth_token, ICEConfigCallback success_callback, ErrorCallback error_callback) = 0; // Attempts to start CRD host and get Auth Code. virtual void StartCRDHostAndGetCode(const std::string& directory_bot_jid, const std::string& oauth_token, base::Value ice_config, AuthCodeCallback success_callback, ErrorCallback error_callback) = 0; }; explicit DeviceCommandStartCRDSessionJob(Delegate* crd_host_delegate); ~DeviceCommandStartCRDSessionJob() override; // RemoteCommandJob: enterprise_management::RemoteCommand_Type GetType() const override; protected: // RemoteCommandJob: bool ParseCommandPayload(const std::string& command_payload) override; void RunImpl(CallbackWithResult succeeded_callback, CallbackWithResult failed_callback) override; void TerminateImpl() override; private: class ResultPayload; // Finishes command with error code and optional message. void FinishWithError(ResultCode result_code, const std::string& message); void OnOAuthTokenReceived(const std::string& token); void OnICEConfigReceived(base::Value ice_config); void OnAuthCodeReceived(const std::string& token); // The callback that will be called when the access code was successfully // obtained. CallbackWithResult succeeded_callback_; // The callback that will be called when this command failed. CallbackWithResult failed_callback_; // -- Command parameters -- // Defines whether connection attempt to active user should succeed or fail. base::TimeDelta idleness_cutoff_; std::string oauth_token_; std::string directory_bot_jid_; base::Value ice_config_; // The Delegate is used to interact with chrome services and CRD host. // Owned by DeviceCommandsFactoryChromeOS. Delegate* delegate_; bool terminate_session_attemtpted_; base::WeakPtrFactory<DeviceCommandStartCRDSessionJob> weak_factory_; DISALLOW_COPY_AND_ASSIGN(DeviceCommandStartCRDSessionJob); }; } // namespace policy #endif // CHROME_BROWSER_CHROMEOS_POLICY_REMOTE_COMMANDS_DEVICE_COMMAND_START_CRD_SESSION_JOB_H_
07bb1f6083086356842b64afc58add57c8ddadc6
c2f436afd2fbce2d20caf001b5ff93519b5e7ee8
/flashlight/autograd/Functions.cpp
1dcb2e083e767eb7601d0815db6df5c0d10783fd
[ "MIT" ]
permissive
pzelasko/flashlight
395fd62348f477f4ecad8cc76bf0508b057a05ca
ea702c05403600d1339d0744a456f68694553187
refs/heads/master
2020-04-13T03:20:09.335863
2018-12-23T01:15:23
2018-12-23T01:17:19
162,928,354
0
1
MIT
2018-12-23T22:31:24
2018-12-23T22:31:24
null
UTF-8
C++
false
false
33,216
cpp
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ /******************************************************* * Copyright (c) 2017, ArrayFire * All rights reserved. * * This file is distributed under 3-clause BSD license. * The complete license agreement can be obtained at: * http://arrayfire.com/licenses/BSD-3-Clause ********************************************************/ #include <algorithm> #include <array> #include <stdexcept> #include <af/internal.h> #include "Functions.h" #include "Variable.h" namespace fl { namespace detail { af::array tileAs(const af::array& input, const af::dim4& rdims) { af::dim4 dims(1, 1, 1, 1); af::dim4 idims = input.dims(); for (int i = 0; i < 4; i++) { dims[i] = rdims[i] / idims[i]; } return tile(input, dims); } af::array sumAs(const af::array& input, const af::dim4& rdims) { af::dim4 idims = input.dims(); auto result = input; for (int i = 0; i < 4; i++) { if (idims[i] != rdims[i]) { result = sum(result, i); } } return result; } } // namespace detail Variable operator+(const Variable& lhs, const Variable& rhs) { auto result = lhs.array() + rhs.array(); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable(grad_output.array(), false)); inputs[1].addGrad(Variable(grad_output.array(), false)); }; return Variable(result, {lhs.withoutData(), rhs.withoutData()}, gradFunc); } Variable operator+(const Variable& lhs, const double& rhs_val) { auto result = lhs.array() + rhs_val; auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable(grad_output.array(), false)); }; return Variable(result, {lhs.withoutData()}, gradFunc); } Variable operator+(const double& lhs_val, const Variable& rhs) { return rhs + lhs_val; } Variable operator-(const Variable& lhs, const Variable& rhs) { auto result = lhs.array() - rhs.array(); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable(grad_output.array(), false)); inputs[1].addGrad(Variable(negate(grad_output).array(), false)); }; return Variable(result, {lhs.withoutData(), rhs.withoutData()}, gradFunc); } Variable operator-(const Variable& lhs, const double& rhs_val) { auto result = lhs.array() - rhs_val; auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable(grad_output.array(), false)); }; return Variable(result, {lhs.withoutData()}, gradFunc); } Variable operator-(const double& lhs_val, const Variable& rhs) { auto result = lhs_val - rhs.array(); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable(negate(grad_output).array(), false)); }; return Variable(result, {rhs.withoutData()}, gradFunc); } Variable operator*(const Variable& lhs, const Variable& rhs) { auto result = lhs.array() * rhs.array(); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { if (inputs[0].isCalcGrad()) { inputs[0].addGrad(Variable((grad_output * inputs[1]).array(), false)); } if (inputs[1].isCalcGrad()) { inputs[1].addGrad(Variable((grad_output * inputs[0]).array(), false)); } }; return Variable( result, {rhs.isCalcGrad() ? lhs : lhs.withoutData(), lhs.isCalcGrad() ? rhs : rhs.withoutData()}, gradFunc); } Variable operator*(const Variable& lhs, const double& rhs_val) { auto result = lhs.array() * rhs_val; auto gradFunc = [rhs_val](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable((grad_output * rhs_val).array(), false)); }; return Variable(result, {lhs.withoutData()}, gradFunc); } Variable operator*(const double& lhs_val, const Variable& rhs) { return rhs * lhs_val; } Variable operator/(const Variable& lhs, const Variable& rhs) { auto result = lhs.array() / rhs.array(); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { auto inputs_1_rec = reciprocal(inputs[1]); auto grad_input_0 = grad_output * inputs_1_rec; if (inputs[0].isCalcGrad()) { inputs[0].addGrad(Variable(grad_input_0.array(), false)); } if (inputs[1].isCalcGrad()) { inputs[1].addGrad(Variable( (grad_input_0 * negate(inputs[0]) * inputs_1_rec).array(), false)); } }; return Variable( result, {rhs.isCalcGrad() ? lhs : lhs.withoutData(), rhs}, gradFunc); } Variable operator/(const Variable& lhs, const double& rhs_val) { auto result = lhs.array() / rhs_val; auto gradFunc = [rhs_val](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable((grad_output / rhs_val).array(), false)); }; return Variable(result, {lhs.withoutData()}, gradFunc); } Variable operator/(const double& lhs_val, const Variable& rhs) { auto result = lhs_val / rhs.array(); auto gradFunc = [lhs_val]( std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable( (grad_output * (-lhs_val) / (inputs[0] * inputs[0])).array(), false)); }; return Variable(result, {rhs}, gradFunc); } Variable operator>(const Variable& lhs, const Variable& rhs) { auto result = lhs.array() > rhs.array(); return Variable(result, false); } Variable operator>(const Variable& lhs, const double& rhs_val) { auto result = lhs.array() > rhs_val; return Variable(result, false); } Variable operator>(const double& lhs_val, const Variable& rhs) { auto result = lhs_val > rhs.array(); return Variable(result, false); } Variable operator<(const Variable& lhs, const Variable& rhs) { auto result = lhs.array() < rhs.array(); return Variable(result, false); } Variable operator<(const Variable& lhs, const double& rhs_val) { auto result = lhs.array() < rhs_val; return Variable(result, false); } Variable operator<(const double& lhs_val, const Variable& rhs) { auto result = lhs_val < rhs.array(); return Variable(result, false); } Variable operator>=(const Variable& lhs, const Variable& rhs) { auto result = lhs.array() >= rhs.array(); return Variable(result, false); } Variable operator>=(const Variable& lhs, const double& rhs_val) { auto result = lhs.array() >= rhs_val; return Variable(result, false); } Variable operator>=(const double& lhs_val, const Variable& rhs) { auto result = lhs_val >= rhs.array(); return Variable(result, false); } Variable operator<=(const Variable& lhs, const Variable& rhs) { auto result = lhs.array() <= rhs.array(); return Variable(result, false); } Variable operator<=(const Variable& lhs, const double& rhs_val) { auto result = lhs.array() <= rhs_val; return Variable(result, false); } Variable operator<=(const double& lhs_val, const Variable& rhs) { auto result = lhs_val <= rhs.array(); return Variable(result, false); } Variable operator&&(const Variable& lhs, const Variable& rhs) { auto result = lhs.array() && rhs.array(); return Variable(result, false); } Variable operator!(const Variable& input) { auto result = !input.array(); return Variable(result, false); } Variable max(const Variable& lhs, const Variable& rhs) { auto result = max(lhs.array(), rhs.array()); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { auto mask = Variable(inputs[0].array() > inputs[1].array(), false); inputs[0].addGrad(Variable((mask * grad_output).array(), false)); inputs[1].addGrad(Variable((!mask * grad_output).array(), false)); }; return Variable(result, {lhs, rhs}, gradFunc); } Variable max(const Variable& lhs, const double& rhs_val) { auto result = max(lhs.array(), rhs_val); auto gradFunc = [rhs_val](std::vector<Variable>& inputs, const Variable& grad_output) { auto mask = Variable(inputs[0].array() > rhs_val, false); inputs[0].addGrad(Variable((mask * grad_output).array(), false)); }; return Variable(result, {lhs}, gradFunc); } Variable max(const double& lhs_val, const Variable& rhs) { return max(rhs, lhs_val); } Variable min(const Variable& lhs, const Variable& rhs) { auto result = min(lhs.array(), rhs.array()); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { auto mask = Variable(inputs[0].array() < inputs[1].array(), false); inputs[0].addGrad(Variable((mask * grad_output).array(), false)); inputs[1].addGrad(Variable((!mask * grad_output).array(), false)); }; return Variable(result, {lhs, rhs}, gradFunc); } Variable min(const Variable& lhs, const double& rhs_val) { auto result = min(lhs.array(), rhs_val); auto gradFunc = [rhs_val](std::vector<Variable>& inputs, const Variable& grad_output) { auto mask = Variable(inputs[0].array() < rhs_val, false); inputs[0].addGrad(Variable((mask * grad_output).array(), false)); }; return Variable(result, {lhs}, gradFunc); } Variable min(const double& lhs_val, const Variable& rhs) { return min(rhs, lhs_val); } Variable negate(const Variable& input) { auto result = 0.0 - input.array(); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable(negate(grad_output).array(), false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable reciprocal(const Variable& input) { auto result = 1.0 / input.array(); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { auto res = reciprocal(inputs[0]); inputs[0].addGrad( Variable((negate(grad_output) * res * res).array(), false)); }; return Variable(result, {input}, gradFunc); } Variable exp(const Variable& input) { auto result = exp(input.array()); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable((grad_output * exp(inputs[0])).array(), false)); }; return Variable(result, {input}, gradFunc); } Variable log(const Variable& input) { auto result = log(input.array()); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable((grad_output / inputs[0]).array(), false)); }; return Variable(result, {input}, gradFunc); } Variable sin(const Variable& input) { auto result = sin(input.array()); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable((grad_output * cos(inputs[0])).array(), false)); }; return Variable(result, {input}, gradFunc); } Variable cos(const Variable& input) { auto result = cos(input.array()); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad( Variable((grad_output * negate(sin(inputs[0]))).array(), false)); }; return Variable(result, {input}, gradFunc); } Variable tanh(const Variable& input) { auto result = tanh(input.array()); auto gradFunc = [result](std::vector<Variable>& inputs, const Variable& grad_output) { auto grad = Variable((1.0 - result * result) * grad_output.array(), false); inputs[0].addGrad(Variable(grad.array(), false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable clamp(const Variable& input, const double lo, const double hi) { auto result = clamp(input.array(), lo, hi); auto gradFunc = [lo, hi, result]( std::vector<Variable>& inputs, const Variable& grad_output) { af::array grad_mask = grad_output.array(); replace(grad_mask, (result > lo) && (result < hi), 0); inputs[0].addGrad(Variable(grad_mask, false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable sqrt(const Variable& input) { auto result = af::sqrt(input.array()); auto gradFunc = [result]( std::vector<Variable>& inputs, const Variable& grad_output) { auto output = Variable(result, false); inputs[0].addGrad(Variable((grad_output / (2 * output)).array(), false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable sigmoid(const Variable& input) { auto result = sigmoid(input.array()); auto gradFunc = [result](std::vector<Variable>& inputs, const Variable& grad_output) { auto grad = grad_output.array() * result * (1 - result); inputs[0].addGrad(Variable(grad, false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable transpose(const Variable& input) { auto result = transpose(input.array()); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable(transpose(grad_output).array(), false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable tileAs(const Variable& input, const af::dim4& rdims) { auto result = detail::tileAs(input.array(), rdims); af::dim4 in_dims = input.dims(); auto gradFunc = [in_dims](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable(sumAs(grad_output, in_dims).array(), false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable tileAs(const Variable& input, const Variable& reference) { return tileAs(input, reference.dims()); } Variable sumAs(const Variable& input, const af::dim4& rdims) { auto result = detail::sumAs(input.array(), rdims); auto idims = input.dims(); auto gradFunc = [idims](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable(tileAs(grad_output, idims).array(), false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable sumAs(const Variable& input, const Variable& reference) { return sumAs(input, reference.dims()); } Variable concatenate(const std::vector<Variable>& concatInputs, int dim) { if (concatInputs.empty()) { throw std::invalid_argument("cannot concatenate zero variables"); } if (dim < 0 || dim > 3) { throw std::invalid_argument("invalid dimension to concatenate along"); } auto dims = concatInputs[0].dims(); int concat_size = dims[dim]; for (int i = 1; i < concatInputs.size(); i++) { concat_size += concatInputs[i].dims(dim); for (int d = 0; d < 4; d++) { if (dim != d && concatInputs[i].dims(d) != dims[d]) { throw std::invalid_argument( "mismatch in dimension not being concatenated"); } } } dims[dim] = concat_size; af::array result(dims, concatInputs[0].type()); std::array<af::index, 4> slice{af::span, af::span, af::span, af::span}; int start = 0; for (const auto& input : concatInputs) { slice[dim] = af::seq(start, start + input.dims(dim) - 1); result(slice[0], slice[1], slice[2], slice[3]) = input.array(); start += input.dims(dim); } std::vector<Variable> inputs_nodata; std::vector<af::dim4> in_dims; for (const auto& in : concatInputs) { inputs_nodata.push_back(in.withoutData()); in_dims.push_back(in.dims()); } auto gradFunc = [dim, in_dims]( std::vector<Variable>& inputs, const Variable& grad_output) { std::array<af::index, 4> sx{af::span, af::span, af::span, af::span}; int s = 0; for (size_t i = 0; i < inputs.size(); ++i) { sx[dim] = af::seq(s, s + in_dims[i][dim] - 1); inputs[i].addGrad( Variable(grad_output.array()(sx[0], sx[1], sx[2], sx[3]), false)); s += in_dims[i][dim]; } }; return Variable(result, inputs_nodata, gradFunc); } Variable tile(const Variable& input, const af::dim4& dims) { auto result = tile(input.array(), dims); af::dim4 idims = input.dims(); auto gradFunc = [idims](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable(sumAs(grad_output, idims).array(), false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable sum(const Variable& input, const std::vector<int>& axes) { auto result = input.array(); for (size_t i = 0; i < axes.size(); i++) { result = sum(result, axes[i]); } af::dim4 indims = input.dims(); auto gradFunc = [indims](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable(tileAs(grad_output, indims).array(), false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable mean(const Variable& input, const std::vector<int>& axes) { auto result = input.array(); for (size_t i = 0; i < axes.size(); i++) { result = mean(result, axes[i]); } af::dim4 idims = input.dims(); auto gradFunc = [idims](std::vector<Variable>& inputs, const Variable& grad_output) { af::dim4 odims = grad_output.dims(); dim_t count = 1; for (int i = 0; i < 4; i++) { count *= idims[i] / odims[i]; } inputs[0].addGrad( Variable((tileAs(grad_output, idims) / count).array(), false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable var( const Variable& input, const std::vector<int>& axes, const bool isbiased /* = false */) { auto result = sum(input * input, axes); auto avg = mean(input, axes); auto n = 1; for (auto ax : axes) { n *= input.dims(ax); } if (!isbiased && n == 1) { throw std::invalid_argument( "cannot compute unbiased variance with only one sample"); } auto val = 1.0 / (isbiased ? n : n - 1); result = val * (result - n * avg * avg); auto gradFunc = [val, axes](std::vector<Variable>& inputs, const Variable& grad_output) { af::dim4 tiledims(1, 1, 1, 1); for (auto ax : axes) { tiledims[ax] = inputs[0].dims(ax); } inputs[0].addGrad(Variable( (2 * val * tile(grad_output, tiledims) * (inputs[0] - tile(mean(inputs[0], axes), tiledims))) .array(), false)); }; return Variable(result.array(), {input}, gradFunc); } Variable norm(const Variable& input, const std::vector<int>& axes) { auto result = input.array() * input.array(); for (size_t i = 0; i < axes.size(); i++) { result = sum(result, axes[i]); } result = af::sqrt(result); result.eval(); auto gradFunc = [result]( std::vector<Variable>& inputs, const Variable& grad_output) { auto output = Variable(result, false); inputs[0].addGrad(Variable( (inputs[0] * tileAs(grad_output / output, inputs[0])).array(), false)); }; return Variable(result, {input}, gradFunc); } Variable matmul(const Variable& lhs, const Variable& rhs) { // lhs:Input[0] -- [M, N] // rhs:Input[1] -- [N, K] // matmul(lhs, rhs) // -- matmul([M, N], [N, K]) -- [M, K] // result:grad_output -- [M, K] auto result = matmul(lhs.array(), rhs.array()); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { if (inputs[0].isCalcGrad()) { // matmulNT(grad_output, inputs[1]) // -- matmulNT([M, K], [N, K]) // -- matmul([M, K], [K, N]) -- [M, K] inputs[0].addGrad( Variable(matmulNT(grad_output, inputs[1]).array(), false)); } if (inputs[1].isCalcGrad()) { // matmulTN(inputs[0], grad_output) // -- matmulTN([M, N], [M, K]) // -- matmul([N, M], [M, K]) -- [N, K] inputs[1].addGrad( Variable(matmulTN(inputs[0], grad_output).array(), false)); } }; return Variable(result, {lhs, rhs}, gradFunc); } Variable matmulTN(const Variable& lhs, const Variable& rhs) { // lhs:Input[0] -- [N, M] // rhs:Input[1] -- [N, K] // matmulTN(lhs, rhs) // -- matmulTN([N, M], [N, K]) // -- matmul([M, N], [N, K]) -- [M, K] // result:grad_output -- [M, K] auto result = matmulTN(lhs.array(), rhs.array()); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { if (inputs[0].isCalcGrad()) { // matmulNT(inputs[1], grad_output) // -- matmulNT([N, K], [M, K]) // -- matmul([N, K], [K, M]) -- [N, M] inputs[0].addGrad( Variable(matmulNT(inputs[1], grad_output).array(), false)); } if (inputs[1].isCalcGrad()) { // matmul(inputs[0], grad_output) // -- matmulNT([N, M], [M, K]) -- [N, K] inputs[1].addGrad( Variable(matmul(inputs[0], grad_output).array(), false)); } }; return Variable(result, {lhs, rhs}, gradFunc); } Variable matmulNT(const Variable& lhs, const Variable& rhs) { // lhs:Input[0] -- [M, N] // rhs:Input[1] -- [K, N] // matmulNT(lhs, rhs) // -- matmulNT([M, N], [K, N]) // -- matmul([M, N], [N, K]) -- [M, K] // result:grad_output -- [M, K] auto result = matmulNT(lhs.array(), rhs.array()); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { if (inputs[0].isCalcGrad()) { // matmul(grad_output, inputs[1]) // -- matmul([M, K], [K, N]) -- [M, N] inputs[0].addGrad( Variable(matmul(grad_output, inputs[1]).array(), false)); } if (inputs[1].isCalcGrad()) { // matmulTN(grad_output, inputs[0]) // -- matmulTN([M, K], [M, N]) // -- matmul([K, M], [M, N]) -- [K, N] inputs[1].addGrad( Variable(matmulTN(grad_output, inputs[0]).array(), false)); } }; return Variable(result, {lhs, rhs}, gradFunc); } Variable abs(const Variable& input) { auto result = af::abs(input.array()); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { // af::sign returns signbit // Convert it into -1, 1 auto sign = Variable(1 - 2 * af::sign(inputs[0].array()), false); inputs[0].addGrad(Variable((sign * grad_output).array(), false)); }; return Variable(result, {input}, gradFunc); } Variable flat(const Variable& input) { auto result = af::flat(input.array()); af::dim4 idims = input.dims(); auto gradFunc = [idims](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable(moddims(grad_output, idims).array(), false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable moddims(const Variable& input, const af::dim4& dims) { af::dim4 infer_dims = dims; // Infer any 0 dim for (int i = 0; i < 4; ++i) { if (infer_dims[i] == 0) { infer_dims[i] = input.dims(i); } } // Infer any -1 dim int n_infer = 0; for (int i = 0; i < 4; i++) { if (infer_dims[i] == -1) { n_infer++; infer_dims[i] = -(input.elements() / infer_dims.elements()); } } if (n_infer > 1) { throw std::invalid_argument("too many dimensions for moddims to infer"); } if (infer_dims.elements() != input.elements()) { throw std::invalid_argument("mismatched # of elements in moddims"); } auto result = af::moddims(input.array(), infer_dims); af::dim4 in_dims = input.dims(); auto gradFunc = [in_dims]( std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable(moddims(grad_output, in_dims).array(), false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable softmax(const Variable& input, const int dim) { auto maxvals = max((input.array()), dim); af::dim4 tiledims(1, 1, 1, 1); tiledims[dim] = input.dims(dim); auto exp_input = exp(input.array() - tile(maxvals, tiledims)); auto result = exp_input / tile(sum(exp_input, dim), tiledims); result.eval(); auto gradFunc = [dim, tiledims, result]( std::vector<Variable>& inputs, const Variable& grad_output) { auto rbyg = grad_output.array() * result; auto grad_sm = rbyg - result * tile(sum(rbyg, dim), tiledims); inputs[0].addGrad(Variable(grad_sm, false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable logSoftmax(const Variable& input, const int dim) { auto maxvals = max((input.array()), dim); af::dim4 tiledims(1, 1, 1, 1); tiledims[dim] = input.dims(dim); auto result = input.array() - tile(log(sum(exp(input.array() - tile(maxvals, tiledims)), dim)) + maxvals, tiledims); result.eval(); auto gradFunc = [dim, tiledims, result]( std::vector<Variable>& inputs, const Variable& grad_output) { auto grad_lsm = grad_output.array() - exp(result) * tile(sum(grad_output.array(), dim), tiledims); inputs[0].addGrad(Variable(grad_lsm, false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable binaryCrossEntropy(const Variable& inputs, const Variable& targets) { return negate(targets * log(inputs) + (1 - targets) * log(1 - inputs)); } Variable categoricalCrossEntropy( const Variable& input, const Variable& targets, ReduceMode reduction /* =ReduceMode::MEAN */) { // input -- [C, X1, X2, X3] // target -- [X1, X2, X3, 1] for (int i = 1; i < 4; i++) { if (input.dims(i) != targets.dims(i - 1)) { throw std::invalid_argument( "dimension mismatch in categorical cross entropy"); } } if (targets.dims(3) != 1) { throw std::invalid_argument( "dimension mismatch in categorical cross entropy"); } int categories = input.dims(0); int num_elems = input.elements() / categories; af::array A = af::range(af::dim4(categories, num_elems)); af::array B = af::moddims(targets.array(), af::dim4(1, targets.elements())); B = tile(B, af::dim4(categories, 1, 1, 1)); auto mask = -(A == B); auto result = mask * af::moddims(input.array(), af::dim4(categories, num_elems)); result = af::sum(result, 0); if (reduction == ReduceMode::NONE) { result = af::moddims(result, targets.dims()); } else if (reduction == ReduceMode::MEAN) { result = af::mean(result, 1); } else if (reduction == ReduceMode::SUM) { result = af::sum(result, 1); } else { throw std::invalid_argument( "unknown reduction method for categorical cross entropy"); } af::dim4 in_dims = input.dims(); auto gradFunc = [mask, reduction, num_elems, in_dims]( std::vector<Variable>& inputs, const Variable& grad_output) { auto grad = grad_output; if (reduction == ReduceMode::NONE) { grad = moddims(grad, af::dim4(1, num_elems)); } grad = Variable(detail::tileAs(grad.array(), mask.dims()) * mask, false); if (reduction == ReduceMode::MEAN) { grad = grad / num_elems; } inputs[0].addGrad(Variable(moddims(grad, in_dims).array(), false)); }; return Variable(result, {input.withoutData(), targets}, gradFunc); } Variable reorder( const Variable& input, const int dim0, const int dim1, const int dim2, const int dim3) { auto result = reorder(input.array(), dim0, dim1, dim2, dim3); if (!af::isLinear(result)) { auto tmp = af::array(result.dims(), input.type()); af::copy(tmp, result, af::span); result = tmp; } std::vector<std::pair<int, int>> dimgrad = { {dim0, 0}, {dim1, 1}, {dim2, 2}, {dim3, 3}}; std::sort(dimgrad.begin(), dimgrad.end()); auto gradFunc = [dimgrad](std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(Variable( reorder( grad_output, dimgrad[0].second, dimgrad[1].second, dimgrad[2].second, dimgrad[3].second) .array(), false)); }; return Variable(result, {input.withoutData()}, gradFunc); } Variable linear(const Variable& input, const Variable& weight) { auto dummy_bias = Variable(af::array(), false); return linear(input, weight, dummy_bias); } Variable linear(const Variable& input, const Variable& weight, const Variable& bias) { auto has_bias = bias.elements() > 0; af::dim4 to2d(input.dims(0), input.elements() / input.dims(0)); auto to4d = input.dims(); to4d[0] = weight.dims(0); auto output = moddims(matmul(weight.array(), moddims(input.array(), to2d)), to4d); if (has_bias) { auto tiledims = output.dims(); tiledims[0] = 1; output = output + tile(bias.array(), tiledims); } auto gradFunc = [has_bias]( std::vector<Variable>& inputs, const Variable& grad_output) { auto& in = inputs[0]; auto& wt = inputs[1]; auto nframes = in.elements() / in.dims(0); if (has_bias && inputs[2].isCalcGrad()) { auto& bs = inputs[2]; bs.addGrad(Variable(sumAs(grad_output, bs).array(), false)); } if (in.isCalcGrad()) { af::dim4 to2dout(wt.dims(0), nframes); in.addGrad(Variable( moddims(matmulTN(wt, moddims(grad_output, to2dout)), in.dims()) .array(), false)); } if (wt.isCalcGrad()) { af::dim4 to2din(wt.dims(1), nframes); af::dim4 to2dout(wt.dims(0), nframes); wt.addGrad(Variable( matmulNT(moddims(grad_output, to2dout), moddims(in, to2din)).array(), false)); } }; if (has_bias) { return Variable(output, {input, weight, bias}, gradFunc); } return Variable(output, {input, weight}, gradFunc); } Variable gatedlinearunit(const Variable& input, const int dim) { auto in_size = input.dims(dim); if (in_size % 2 == 1) { throw std::invalid_argument("halving dimension must be even for GLU"); } std::array<af::seq, 4> fhalf = {af::span, af::span, af::span, af::span}; fhalf[dim] = af::seq(in_size / 2); std::array<af::seq, 4> shalf = {af::span, af::span, af::span, af::span}; shalf[dim] = af::seq(in_size / 2, in_size - 1); auto result = input.array()(fhalf[0], fhalf[1], fhalf[2], fhalf[3]) * sigmoid(input.array()(shalf[0], shalf[1], shalf[2], shalf[3])); auto gradFunc = [fhalf, shalf]( std::vector<Variable>& inputs, const Variable& grad_output) { auto& input = inputs[0]; auto grad_glu = af::array(input.dims(), input.type()); auto shalfout = sigmoid(input.array()(shalf[0], shalf[1], shalf[2], shalf[3])); grad_glu(fhalf[0], fhalf[1], fhalf[2], fhalf[3]) = shalfout * grad_output.array(); grad_glu(shalf[0], shalf[1], shalf[2], shalf[3]) = shalfout * (1.0 - shalfout) * input.array()(fhalf[0], fhalf[1], fhalf[2], fhalf[3]) * grad_output.array(); inputs[0].addGrad(Variable(grad_glu, false)); }; return Variable(result, {input}, gradFunc); } Variable embedding(const Variable& input, const Variable& embeddings) { if (input.numdims() >= 4) { throw std::invalid_argument("embedding input must have 3 or fewer dims"); } auto idxs = af::flat(input.array()); Variable result = Variable(embeddings.array()(af::span, idxs), false); auto in_dims = input.dims(); af::dim4 result_dims = { embeddings.dims(0), in_dims[0], in_dims[1], in_dims[2]}; result = moddims(result, result_dims); auto gradFunc = [](std::vector<Variable>& inputs, const Variable& grad_output) { auto& w = inputs[1]; if (!w.isCalcGrad()) { return; } auto ip = af::flat(inputs[0].array()); auto deltas = af::moddims(grad_output.array(), w.dims(0), ip.elements()); auto sp = sparse( ip.elements(), w.dims(1), af::constant(1, ip.elements(), deltas.type()), af::range(af::dim4(ip.elements() + 1), 0, s32), ip.as(s32), AF_STORAGE_CSR); auto grad = transpose(matmulTN(sp, transpose(deltas))); w.addGrad(Variable(grad, false)); }; return Variable(result.array(), {input, embeddings}, gradFunc); } Variable padding( const Variable& input, std::vector<std::pair<int, int>> pad, double val) { af::dim4 op_dims = input.dims(); std::array<af::seq, 4> in_seq = {af::span, af::span, af::span, af::span}; for (int i = 0; i < pad.size(); ++i) { op_dims[i] += (pad[i].first + pad[i].second); in_seq[i] = af::seq(pad[i].first, op_dims[i] - pad[i].second - 1); } af::array result = af::constant(val, op_dims, input.type()); result(in_seq[0], in_seq[1], in_seq[2], in_seq[3]) = input.array(); auto gradFunc = [in_seq]( std::vector<Variable>& inputs, const Variable& grad_output) { inputs[0].addGrad(grad_output(in_seq[0], in_seq[1], in_seq[2], in_seq[3])); }; return Variable(result, {input.withoutData()}, gradFunc); } } // namespace fl
366187213f3110a6521e6bea5c0bae6ba4e7ffc1
019d64d5fb05b266dc6e4f281403ae9ba1b9a0be
/src/lib/sparse_matrix/msr_matrix.h
fde6f89897f3f191f56bcf08ef6d0a7151f19e28
[]
no_license
mrFlatiron/3d_interpol
590f8a57b625b79fb59ec3d556bdbd87210bfc83
5780b28ad07af32fbc0c77227abac6cf2f096d29
refs/heads/master
2021-01-20T13:44:17.368731
2017-05-30T23:21:04
2017-05-30T23:21:04
90,523,814
0
0
null
null
null
null
UTF-8
C++
false
false
1,069
h
#ifndef MSR_MATRIX_H #define MSR_MATRIX_H #include "containers/simple_vector.h" #include <cstdio> #include <vector> class msr_thread_dqgmres_solver; class msr_matrix { private: int m_n; int m_arr_size; simple_vector m_aa; std::vector<int> m_ja; public: friend class msr_thread_dqgmres_solver; msr_matrix (); ~msr_matrix (); void dump (FILE *fout = stdout); void convert (const int n, simple_vector matrix); int n () const; void set_n (const int n); int arr_size () const; void set_arr_size (const int size); double aa (const int i) const; void aa (const int i, const double val); int ja (const int i) const; void ja (const int i, const int val); void set_diagonal (const simple_vector &diag_vals); void mult_vector (const simple_vector &in, simple_vector &out); bool is_symmetrical () const; double ij (const int i, const int j) const; private: void print_row (FILE *fout, const int i, const int row_begin, const int row_end); void get_ja_row_bounds (const int i, int &begin, int &end) const; }; #endif // MSR_MATRIX_H
89112359f67cf7c373905735e2fc41664359413b
d8010b0cfced1c941e632ed4cc927d20d7b7bf95
/devel/include/inspire_hand/set_gesture_noRequest.h
2d4d0366095439eb5125a2c9c97464d14a20d022
[]
no_license
ZJU-Robotics-Lab/motion-retargeting-rl
b143b7695d8813edc12def6e218975ad8a499329
073a511edfad5b758537d4564a05fea43c229004
refs/heads/master
2022-11-29T13:57:33.736198
2020-07-28T08:04:20
2020-07-28T08:04:20
283,143,525
1
1
null
null
null
null
UTF-8
C++
false
false
5,208
h
// Generated by gencpp from file inspire_hand/set_gesture_noRequest.msg // DO NOT EDIT! #ifndef INSPIRE_HAND_MESSAGE_SET_GESTURE_NOREQUEST_H #define INSPIRE_HAND_MESSAGE_SET_GESTURE_NOREQUEST_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 inspire_hand { template <class ContainerAllocator> struct set_gesture_noRequest_ { typedef set_gesture_noRequest_<ContainerAllocator> Type; set_gesture_noRequest_() : gesture_no(0) { } set_gesture_noRequest_(const ContainerAllocator& _alloc) : gesture_no(0) { (void)_alloc; } typedef int32_t _gesture_no_type; _gesture_no_type gesture_no; typedef boost::shared_ptr< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> const> ConstPtr; }; // struct set_gesture_noRequest_ typedef ::inspire_hand::set_gesture_noRequest_<std::allocator<void> > set_gesture_noRequest; typedef boost::shared_ptr< ::inspire_hand::set_gesture_noRequest > set_gesture_noRequestPtr; typedef boost::shared_ptr< ::inspire_hand::set_gesture_noRequest const> set_gesture_noRequestConstPtr; // constants requiring out of line definition template<typename ContainerAllocator> std::ostream& operator<<(std::ostream& s, const ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> & v) { ros::message_operations::Printer< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> >::stream(s, "", v); return s; } } // namespace inspire_hand namespace ros { namespace message_traits { // BOOLTRAITS {'IsFixedSize': True, 'IsMessage': True, 'HasHeader': False} // {'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< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsFixedSize< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct HasHeader< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> const> : FalseType { }; template<class ContainerAllocator> struct MD5Sum< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> > { static const char* value() { return "ea289c543a56bf8388893db17ebece7f"; } static const char* value(const ::inspire_hand::set_gesture_noRequest_<ContainerAllocator>&) { return value(); } static const uint64_t static_value1 = 0xea289c543a56bf83ULL; static const uint64_t static_value2 = 0x88893db17ebece7fULL; }; template<class ContainerAllocator> struct DataType< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> > { static const char* value() { return "inspire_hand/set_gesture_noRequest"; } static const char* value(const ::inspire_hand::set_gesture_noRequest_<ContainerAllocator>&) { return value(); } }; template<class ContainerAllocator> struct Definition< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> > { static const char* value() { return "int32 gesture_no\n\ "; } static const char* value(const ::inspire_hand::set_gesture_noRequest_<ContainerAllocator>&) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.gesture_no); } ROS_DECLARE_ALLINONE_SERIALIZER }; // struct set_gesture_noRequest_ } // namespace serialization } // namespace ros namespace ros { namespace message_operations { template<class ContainerAllocator> struct Printer< ::inspire_hand::set_gesture_noRequest_<ContainerAllocator> > { template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::inspire_hand::set_gesture_noRequest_<ContainerAllocator>& v) { s << indent << "gesture_no: "; Printer<int32_t>::stream(s, indent + " ", v.gesture_no); } }; } // namespace message_operations } // namespace ros #endif // INSPIRE_HAND_MESSAGE_SET_GESTURE_NOREQUEST_H
370a78de4bafa6fc8d647a8a287479af88ab7965
3912e69afbe91860a09bab2d8fa3d31263055766
/test_3_4_2_1.cpp
0dccd9b00179aea10e0ac7bf193106d0c5d2f263
[]
no_license
MagicSen/C_Plus_Plus_Primer
db4faa61d94aabc6c2ca6d66f9c93882ee7b573a
31d5ef74ebe143228ce71579ebd32eb5f1850896
refs/heads/master
2016-09-05T15:54:24.761932
2014-10-18T07:43:57
2014-10-18T07:43:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
581
cpp
#include <iostream> #include <vector> #include <string> using std::cout; using std::cin; using std::endl; using std::vector; using std::string; int main() { // vector<int> tm(10,42); // vector<int> tm{42 ... 42}; // vector<int> tm = {42 ... 42}; vector<int> sm; int temp=0; while(cin >> temp){ sm.push_back(temp); } for(auto i = sm.begin(),j = sm.end(); i != sm.begin() + sm.size()/2; i++,j--) { cout << *i + *(j-1) << " " ; } if(sm.size()%2 != 0) cout << *(sm.begin() + sm.size()/2) << " " ; cout << endl << "Vector's Size: " << sm.size() << endl; return 0; }
41ef37b9e95f4397ac1ca73b715b01c0a004a04e
10464800f55b04f9f821d9b6a12b58f4185bc7df
/RapidXML/zip.cpp
7a1583ce1d007d9fb55c2fbfb68c442bc9740a69
[ "MIT", "BSL-1.0" ]
permissive
TheGnewGuy/ODSUtilities
6c2b6681b4bd02714dbbf5c0963739e9431d1e92
b477e4af8b19cdf316e0e966690ea6cffa329257
refs/heads/master
2021-01-25T03:20:14.310574
2015-01-26T03:24:31
2015-01-26T03:24:31
28,576,223
0
0
null
null
null
null
UTF-8
C++
false
false
113,153
cpp
#include "stdafx.h" #include <windows.h> #include <stdio.h> #include <tchar.h> #include "zip.h" // On MSVC, disable "conditional expression is constant" warning (level 4). // This warning is almost impossible to avoid with certain types of templated code #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4996) // #endif // THIS FILE is almost entirely based upon code by info-zip. // It has been modified by Lucian Wischik. The modifications // were a complete rewrite of the bit of code that generates the // layout of the zipfile, and support for zipping to/from memory // or handles or pipes or pagefile or diskfiles, encryption, unicode. // The original code may be found at http://www.info-zip.org // The original copyright text follows. // // // // This is version 1999-Oct-05 of the Info-ZIP copyright and license. // The definitive version of this document should be available at // ftp://ftp.cdrom.com/pub/infozip/license.html indefinitely. // // Copyright (c) 1990-1999 Info-ZIP. All rights reserved. // // For the purposes of this copyright and license, "Info-ZIP" is defined as // the following set of individuals: // // Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, // Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk Haase, // Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David Kirschbaum, // Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve P. Miller, // Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, Kai Uwe Rommel, // Steve Salisbury, Dave Smith, Christian Spieler, Antoine Verheijen, // Paul von Behren, Rich Wales, Mike White // // This software is provided "as is," without warranty of any kind, express // or implied. In no event shall Info-ZIP or its contributors be held liable // for any direct, indirect, incidental, special or consequential damages // arising out of the use of or inability to use 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. Redistributions of source code must retain the above copyright notice, // definition, disclaimer, and this list of conditions. // // 2. Redistributions in binary form must reproduce the above copyright // notice, definition, disclaimer, and this list of conditions in // documentation and/or other materials provided with the distribution. // // 3. Altered versions--including, but not limited to, ports to new operating // systems, existing ports with new graphical interfaces, and dynamic, // shared, or static library versions--must be plainly marked as such // and must not be misrepresented as being the original source. Such // altered versions also must not be misrepresented as being Info-ZIP // releases--including, but not limited to, labeling of the altered // versions with the names "Info-ZIP" (or any variation thereof, including, // but not limited to, different capitalizations), "Pocket UnZip," "WiZ" // or "MacZip" without the explicit permission of Info-ZIP. Such altered // versions are further prohibited from misrepresentative use of the // Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s). // // 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip," // "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its own source and // binary releases. // typedef unsigned char uch; // unsigned 8-bit value typedef unsigned short ush; // unsigned 16-bit value typedef unsigned long ulg; // unsigned 32-bit value typedef size_t extent; // file size typedef unsigned Pos; // must be at least 32 bits typedef unsigned IPos; // A Pos is an index in the character window. Pos is used only for parameter passing #ifndef EOF #define EOF (-1) #endif // Error return values. The values 0..4 and 12..18 follow the conventions // of PKZIP. The values 4..10 are all assigned to "insufficient memory" // by PKZIP, so the codes 5..10 are used here for other purposes. #define ZE_MISS -1 // used by procname(), zipbare() #define ZE_OK 0 // success #define ZE_EOF 2 // unexpected end of zip file #define ZE_FORM 3 // zip file structure error #define ZE_MEM 4 // out of memory #define ZE_LOGIC 5 // internal logic error #define ZE_BIG 6 // entry too large to split #define ZE_NOTE 7 // invalid comment format #define ZE_TEST 8 // zip test (-T) failed or out of memory #define ZE_ABORT 9 // user interrupt or termination #define ZE_TEMP 10 // error using a temp file #define ZE_READ 11 // read or seek error #define ZE_NONE 12 // nothing to do #define ZE_NAME 13 // missing or empty zip file #define ZE_WRITE 14 // error writing to a file #define ZE_CREAT 15 // couldn't open to write #define ZE_PARMS 16 // bad command line #define ZE_OPEN 18 // could not open a specified file to read #define ZE_MAXERR 18 // the highest error number // internal file attribute #define UNKNOWN (-1) #define BINARY 0 #define ASCII 1 #define BEST -1 // Use best method (deflation or store) #define STORE 0 // Store method #define DEFLATE 8 // Deflation method #define CRCVAL_INITIAL 0L // MSDOS file or directory attributes #define MSDOS_HIDDEN_ATTR 0x02 #define MSDOS_DIR_ATTR 0x10 // Lengths of headers after signatures in bytes #define LOCHEAD 26 #define CENHEAD 42 #define ENDHEAD 18 // Definitions for extra field handling: #define EB_HEADSIZE 4 /* length of a extra field block header */ #define EB_LEN 2 /* offset of data length field in header */ #define EB_UT_MINLEN 1 /* minimal UT field contains Flags byte */ #define EB_UT_FLAGS 0 /* byte offset of Flags field */ #define EB_UT_TIME1 1 /* byte offset of 1st time value */ #define EB_UT_FL_MTIME (1 << 0) /* mtime present */ #define EB_UT_FL_ATIME (1 << 1) /* atime present */ #define EB_UT_FL_CTIME (1 << 2) /* ctime present */ #define EB_UT_LEN(n) (EB_UT_MINLEN + 4 * (n)) #define EB_L_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(3)) #define EB_C_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(1)) // Macros for writing machine integers to little-endian format #define PUTSH(a,f) {char _putsh_c=(char)((a)&0xff); wfunc(param,&_putsh_c,1); _putsh_c=(char)((a)>>8); wfunc(param,&_putsh_c,1);} #define PUTLG(a,f) {PUTSH((a) & 0xffff,(f)) PUTSH((a) >> 16,(f))} // -- Structure of a ZIP file -- // Signatures for zip file information headers #define LOCSIG 0x04034b50L #define CENSIG 0x02014b50L #define ENDSIG 0x06054b50L #define EXTLOCSIG 0x08074b50L #define MIN_MATCH 3 #define MAX_MATCH 258 // The minimum and maximum match lengths #define WSIZE (0x8000) // Maximum window size = 32K. If you are really short of memory, compile // with a smaller WSIZE but this reduces the compression ratio for files // of size > WSIZE. WSIZE must be a power of two in the current implementation. // #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) // Minimum amount of lookahead, except at the end of the input file. // See deflate.c for comments about the MIN_MATCH+1. // #define MAX_DIST (WSIZE-MIN_LOOKAHEAD) // In order to simplify the code, particularly on 16 bit machines, match // distances are limited to MAX_DIST instead of WSIZE. // #define ZIP_HANDLE 1 #define ZIP_FILENAME 2 #define ZIP_MEMORY 3 #define ZIP_FOLDER 4 // =========================================================================== // Constants // #define MAX_BITS 15 // All codes must not exceed MAX_BITS bits #define MAX_BL_BITS 7 // Bit length codes must not exceed MAX_BL_BITS bits #define LENGTH_CODES 29 // number of length codes, not counting the special END_BLOCK code #define LITERALS 256 // number of literal bytes 0..255 #define END_BLOCK 256 // end of block literal code #define L_CODES (LITERALS+1+LENGTH_CODES) // number of Literal or Length codes, including the END_BLOCK code #define D_CODES 30 // number of distance codes #define BL_CODES 19 // number of codes used to transfer the bit lengths #define STORED_BLOCK 0 #define STATIC_TREES 1 #define DYN_TREES 2 // The three kinds of block type #define LIT_BUFSIZE 0x8000 #define DIST_BUFSIZE LIT_BUFSIZE // Sizes of match buffers for literals/lengths and distances. There are // 4 reasons for limiting LIT_BUFSIZE to 64K: // - frequencies can be kept in 16 bit counters // - if compression is not successful for the first block, all input data is // still in the window so we can still emit a stored block even when input // comes from standard input. (This can also be done for all blocks if // LIT_BUFSIZE is not greater than 32K.) // - if compression is not successful for a file smaller than 64K, we can // even emit a stored file instead of a stored block (saving 5 bytes). // - creating new Huffman trees less frequently may not provide fast // adaptation to changes in the input data statistics. (Take for // example a binary file with poorly compressible code followed by // a highly compressible string table.) Smaller buffer sizes give // fast adaptation but have of course the overhead of transmitting trees // more frequently. // - I can't count above 4 // The current code is general and allows DIST_BUFSIZE < LIT_BUFSIZE (to save // memory at the expense of compression). Some optimizations would be possible // if we rely on DIST_BUFSIZE == LIT_BUFSIZE. // #define REP_3_6 16 // repeat previous bit length 3-6 times (2 bits of repeat count) #define REPZ_3_10 17 // repeat a zero length 3-10 times (3 bits of repeat count) #define REPZ_11_138 18 // repeat a zero length 11-138 times (7 bits of repeat count) #define HEAP_SIZE (2*L_CODES+1) // maximum heap size // =========================================================================== // Local data used by the "bit string" routines. // #define Buf_size (8 * 2*sizeof(char)) // Number of bits used within bi_buf. (bi_buf may be implemented on // more than 16 bits on some systems.) // Output a 16 bit value to the bit stream, lower (oldest) byte first #define PUTSHORT(state,w) \ { if (state.bs.out_offset >= state.bs.out_size-1) \ state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); \ state.bs.out_buf[state.bs.out_offset++] = (char) ((w) & 0xff); \ state.bs.out_buf[state.bs.out_offset++] = (char) ((ush)(w) >> 8); \ } #define PUTBYTE(state,b) \ { if (state.bs.out_offset >= state.bs.out_size) \ state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); \ state.bs.out_buf[state.bs.out_offset++] = (char) (b); \ } // DEFLATE.CPP HEADER #define HASH_BITS 15 // For portability to 16 bit machines, do not use values above 15. #define HASH_SIZE (unsigned)(1<<HASH_BITS) #define HASH_MASK (HASH_SIZE-1) #define WMASK (WSIZE-1) // HASH_SIZE and WSIZE must be powers of two #define NIL 0 // Tail of hash chains #define FAST 4 #define SLOW 2 // speed options for the general purpose bit flag #define TOO_FAR 4096 // Matches of length 3 are discarded if their distance exceeds TOO_FAR #define EQUAL 0 // result of memcmp for equal strings // =========================================================================== // Local data used by the "longest match" routines. #define H_SHIFT ((HASH_BITS+MIN_MATCH-1)/MIN_MATCH) // Number of bits by which ins_h and del_h must be shifted at each // input step. It must be such that after MIN_MATCH steps, the oldest // byte no longer takes part in the hash key, that is: // H_SHIFT * MIN_MATCH >= HASH_BITS #define max_insert_length max_lazy_match // Insert new strings in the hash table only if the match length // is not greater than this length. This saves time but degrades compression. // max_insert_length is used only for compression levels <= 3. const int extra_lbits[LENGTH_CODES] // extra bits for each length code = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; const int extra_dbits[D_CODES] // extra bits for each distance code = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; const int extra_blbits[BL_CODES]// extra bits for each bit length code = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; const uch bl_order[BL_CODES] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; // The lengths of the bit length codes are sent in order of decreasing // probability, to avoid transmitting the lengths for unused bit length codes. typedef struct config { ush good_length; // reduce lazy search above this match length ush max_lazy; // do not perform lazy search above this match length ush nice_length; // quit search above this match length ush max_chain; } config; // Values for max_lazy_match, good_match, nice_match and max_chain_length, // depending on the desired pack level (0..9). The values given below have // been tuned to exclude worst case performance for pathological files. // Better values may be found for specific files. // const config configuration_table[10] = { // good lazy nice chain {0, 0, 0, 0}, // 0 store only {4, 4, 8, 4}, // 1 maximum speed, no lazy matches {4, 5, 16, 8}, // 2 {4, 6, 32, 32}, // 3 {4, 4, 16, 16}, // 4 lazy matches */ {8, 16, 32, 32}, // 5 {8, 16, 128, 128}, // 6 {8, 32, 128, 256}, // 7 {32, 128, 258, 1024}, // 8 {32, 258, 258, 4096}};// 9 maximum compression */ // Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 // For deflate_fast() (levels <= 3) good is ignored and lazy has a different meaning. // Data structure describing a single value and its code string. typedef struct ct_data { union { ush freq; // frequency count ush code; // bit string } fc; union { ush dad; // father node in Huffman tree ush len; // length of bit string } dl; } ct_data; typedef struct tree_desc { ct_data *dyn_tree; // the dynamic tree ct_data *static_tree; // corresponding static tree or NULL const int *extra_bits; // extra bits for each code or NULL int extra_base; // base index for extra_bits int elems; // max number of elements in the tree int max_length; // max bit length for the codes int max_code; // largest code with non zero frequency } tree_desc; class TTreeState { public: TTreeState(); ct_data dyn_ltree[HEAP_SIZE]; // literal and length tree ct_data dyn_dtree[2*D_CODES+1]; // distance tree ct_data static_ltree[L_CODES+2]; // the static literal tree... // ... Since the bit lengths are imposed, there is no need for the L_CODES // extra codes used during heap construction. However the codes 286 and 287 // are needed to build a canonical tree (see ct_init below). ct_data static_dtree[D_CODES]; // the static distance tree... // ... (Actually a trivial tree since all codes use 5 bits.) ct_data bl_tree[2*BL_CODES+1]; // Huffman tree for the bit lengths tree_desc l_desc; tree_desc d_desc; tree_desc bl_desc; ush bl_count[MAX_BITS+1]; // number of codes at each bit length for an optimal tree int heap[2*L_CODES+1]; // heap used to build the Huffman trees int heap_len; // number of elements in the heap int heap_max; // element of largest frequency // The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. // The same heap array is used to build all trees. uch depth[2*L_CODES+1]; // Depth of each subtree used as tie breaker for trees of equal frequency uch length_code[MAX_MATCH-MIN_MATCH+1]; // length code for each normalized match length (0 == MIN_MATCH) uch dist_code[512]; // distance codes. The first 256 values correspond to the distances // 3 .. 258, the last 256 values correspond to the top 8 bits of // the 15 bit distances. int base_length[LENGTH_CODES]; // First normalized length for each code (0 = MIN_MATCH) int base_dist[D_CODES]; // First normalized distance for each code (0 = distance of 1) uch far l_buf[LIT_BUFSIZE]; // buffer for literals/lengths ush far d_buf[DIST_BUFSIZE]; // buffer for distances uch flag_buf[(LIT_BUFSIZE/8)]; // flag_buf is a bit array distinguishing literals from lengths in // l_buf, and thus indicating the presence or absence of a distance. unsigned last_lit; // running index in l_buf unsigned last_dist; // running index in d_buf unsigned last_flags; // running index in flag_buf uch flags; // current flags not yet saved in flag_buf uch flag_bit; // current bit used in flags // bits are filled in flags starting at bit 0 (least significant). // Note: these flags are overkill in the current code since we don't // take advantage of DIST_BUFSIZE == LIT_BUFSIZE. ulg opt_len; // bit length of current block with optimal trees ulg static_len; // bit length of current block with static trees ulg cmpr_bytelen; // total byte length of compressed file ulg cmpr_len_bits; // number of bits past 'cmpr_bytelen' ulg input_len; // total byte length of input file // input_len is for debugging only since we can get it by other means. ush *file_type; // pointer to UNKNOWN, BINARY or ASCII // int *file_method; // pointer to DEFLATE or STORE }; TTreeState::TTreeState() { tree_desc a = {dyn_ltree, static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS, 0}; l_desc = a; tree_desc b = {dyn_dtree, static_dtree, extra_dbits, 0, D_CODES, MAX_BITS, 0}; d_desc = b; tree_desc c = {bl_tree, NULL, extra_blbits, 0, BL_CODES, MAX_BL_BITS, 0}; bl_desc = c; last_lit=0; last_dist=0; last_flags=0; } class TBitState { public: int flush_flg; // unsigned bi_buf; // Output buffer. bits are inserted starting at the bottom (least significant // bits). The width of bi_buf must be at least 16 bits. int bi_valid; // Number of valid bits in bi_buf. All bits above the last valid bit // are always zero. char *out_buf; // Current output buffer. unsigned out_offset; // Current offset in output buffer. // On 16 bit machines, the buffer is limited to 64K. unsigned out_size; // Size of current output buffer ulg bits_sent; // bit length of the compressed data only needed for debugging??? }; class TDeflateState { public: TDeflateState() {window_size=0;} uch window[2L*WSIZE]; // Sliding window. Input bytes are read into the second half of the window, // and move to the first half later to keep a dictionary of at least WSIZE // bytes. With this organization, matches are limited to a distance of // WSIZE-MAX_MATCH bytes, but this ensures that IO is always // performed with a length multiple of the block size. Also, it limits // the window size to 64K, which is quite useful on MSDOS. // To do: limit the window size to WSIZE+CBSZ if SMALL_MEM (the code would // be less efficient since the data would have to be copied WSIZE/CBSZ times) Pos prev[WSIZE]; // Link to older string with same hash index. To limit the size of this // array to 64K, this link is maintained only for the last 32K strings. // An index in this array is thus a window index modulo 32K. Pos head[HASH_SIZE]; // Heads of the hash chains or NIL. If your compiler thinks that // HASH_SIZE is a dynamic value, recompile with -DDYN_ALLOC. ulg window_size; // window size, 2*WSIZE except for MMAP or BIG_MEM, where it is the // input file length plus MIN_LOOKAHEAD. long block_start; // window position at the beginning of the current output block. Gets // negative when the window is moved backwards. int sliding; // Set to false when the input file is already in memory unsigned ins_h; // hash index of string to be inserted unsigned int prev_length; // Length of the best match at previous step. Matches not greater than this // are discarded. This is used in the lazy match evaluation. unsigned strstart; // start of string to insert unsigned match_start; // start of matching string int eofile; // flag set at end of input file unsigned lookahead; // number of valid bytes ahead in window unsigned max_chain_length; // To speed up deflation, hash chains are never searched beyond this length. // A higher limit improves compression ratio but degrades the speed. unsigned int max_lazy_match; // Attempt to find a better match only when the current match is strictly // smaller than this value. This mechanism is used only for compression // levels >= 4. unsigned good_match; // Use a faster search when the previous match is longer than this int nice_match; // Stop searching when current match exceeds this }; typedef __int64 lutime_t; // define it ourselves since we don't include time.h typedef struct iztimes { lutime_t atime,mtime,ctime; } iztimes; // access, modify, create times typedef struct zlist { ush vem, ver, flg, how; // See central header in zipfile.c for what vem..off are ulg tim, crc, siz, len; extent nam, ext, cext, com; // offset of ext must be >= LOCHEAD ush dsk, att, lflg; // offset of lflg must be >= LOCHEAD ulg atx, off; char name[MAX_PATH]; // File name in zip file char *extra; // Extra field (set only if ext != 0) char *cextra; // Extra in central (set only if cext != 0) char *comment; // Comment (set only if com != 0) char iname[MAX_PATH]; // Internal file name after cleanup char zname[MAX_PATH]; // External version of internal name int mark; // Marker for files to operate on int trash; // Marker for files to delete int dosflag; // Set to force MSDOS file attributes struct zlist far *nxt; // Pointer to next header in list } TZipFileInfo; struct TState; typedef unsigned (*READFUNC)(TState &state, char *buf,unsigned size); typedef unsigned (*FLUSHFUNC)(void *param, const char *buf, unsigned *size); typedef unsigned (*WRITEFUNC)(void *param, const char *buf, unsigned size); struct TState { void *param; int level; bool seekable; READFUNC readfunc; FLUSHFUNC flush_outbuf; TTreeState ts; TBitState bs; TDeflateState ds; const char *err; }; void Assert(TState &state,bool cond, const char *msg) { if (cond) return; state.err=msg; } void __cdecl Trace(const char *x, ...) {va_list paramList; va_start(paramList, x); paramList; va_end(paramList);} void __cdecl Tracec(bool ,const char *x, ...) {va_list paramList; va_start(paramList, x); paramList; va_end(paramList);} // =========================================================================== // Local (static) routines in this file. // void init_block (TState &); void pqdownheap (TState &,ct_data *tree, int k); void gen_bitlen (TState &,tree_desc *desc); void gen_codes (TState &state,ct_data *tree, int max_code); void build_tree (TState &,tree_desc *desc); void scan_tree (TState &,ct_data *tree, int max_code); void send_tree (TState &state,ct_data *tree, int max_code); int build_bl_tree (TState &); void send_all_trees (TState &state,int lcodes, int dcodes, int blcodes); void compress_block (TState &state,ct_data *ltree, ct_data *dtree); void set_file_type (TState &); void send_bits (TState &state, int value, int length); unsigned bi_reverse (unsigned code, int len); void bi_windup (TState &state); void copy_block (TState &state,char *buf, unsigned len, int header); #define send_code(state, c, tree) send_bits(state, tree[c].fc.code, tree[c].dl.len) // Send a code of the given tree. c and tree must not have side effects // alternatively... //#define send_code(state, c, tree) // { if (state.verbose>1) fprintf(stderr,"\ncd %3d ",(c)); // send_bits(state, tree[c].fc.code, tree[c].dl.len); } #define d_code(dist) ((dist) < 256 ? state.ts.dist_code[dist] : state.ts.dist_code[256+((dist)>>7)]) // Mapping from a distance to a distance code. dist is the distance - 1 and // must not have side effects. dist_code[256] and dist_code[257] are never used. #define Max(a,b) (a >= b ? a : b) /* the arguments must not have side effects */ /* =========================================================================== * Allocate the match buffer, initialize the various tables and save the * location of the internal file attribute (ascii/binary) and method * (DEFLATE/STORE). */ void ct_init(TState &state, ush *attr) { int n; /* iterates over tree elements */ int bits; /* bit counter */ int length; /* length value */ int code; /* code value */ int dist; /* distance index */ state.ts.file_type = attr; //state.ts.file_method = method; state.ts.cmpr_bytelen = state.ts.cmpr_len_bits = 0L; state.ts.input_len = 0L; if (state.ts.static_dtree[0].dl.len != 0) return; /* ct_init already called */ /* Initialize the mapping length (0..255) -> length code (0..28) */ length = 0; for (code = 0; code < LENGTH_CODES-1; code++) { state.ts.base_length[code] = length; for (n = 0; n < (1<<extra_lbits[code]); n++) { state.ts.length_code[length++] = (uch)code; } } Assert(state,length == 256, "ct_init: length != 256"); /* Note that the length 255 (match length 258) can be represented * in two different ways: code 284 + 5 bits or code 285, so we * overwrite length_code[255] to use the best encoding: */ state.ts.length_code[length-1] = (uch)code; /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ dist = 0; for (code = 0 ; code < 16; code++) { state.ts.base_dist[code] = dist; for (n = 0; n < (1<<extra_dbits[code]); n++) { state.ts.dist_code[dist++] = (uch)code; } } Assert(state,dist == 256, "ct_init: dist != 256"); dist >>= 7; /* from now on, all distances are divided by 128 */ for ( ; code < D_CODES; code++) { state.ts.base_dist[code] = dist << 7; for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { state.ts.dist_code[256 + dist++] = (uch)code; } } Assert(state,dist == 256, "ct_init: 256+dist != 512"); /* Construct the codes of the static literal tree */ for (bits = 0; bits <= MAX_BITS; bits++) state.ts.bl_count[bits] = 0; n = 0; while (n <= 143) state.ts.static_ltree[n++].dl.len = 8, state.ts.bl_count[8]++; while (n <= 255) state.ts.static_ltree[n++].dl.len = 9, state.ts.bl_count[9]++; while (n <= 279) state.ts.static_ltree[n++].dl.len = 7, state.ts.bl_count[7]++; while (n <= 287) state.ts.static_ltree[n++].dl.len = 8, state.ts.bl_count[8]++; /* fc.codes 286 and 287 do not exist, but we must include them in the * tree construction to get a canonical Huffman tree (longest code * all ones) */ gen_codes(state,(ct_data *)state.ts.static_ltree, L_CODES+1); /* The static distance tree is trivial: */ for (n = 0; n < D_CODES; n++) { state.ts.static_dtree[n].dl.len = 5; state.ts.static_dtree[n].fc.code = (ush)bi_reverse(n, 5); } /* Initialize the first block of the first file: */ init_block(state); } /* =========================================================================== * Initialize a new block. */ void init_block(TState &state) { int n; /* iterates over tree elements */ /* Initialize the trees. */ for (n = 0; n < L_CODES; n++) state.ts.dyn_ltree[n].fc.freq = 0; for (n = 0; n < D_CODES; n++) state.ts.dyn_dtree[n].fc.freq = 0; for (n = 0; n < BL_CODES; n++) state.ts.bl_tree[n].fc.freq = 0; state.ts.dyn_ltree[END_BLOCK].fc.freq = 1; state.ts.opt_len = state.ts.static_len = 0L; state.ts.last_lit = state.ts.last_dist = state.ts.last_flags = 0; state.ts.flags = 0; state.ts.flag_bit = 1; } #define SMALLEST 1 /* Index within the heap array of least frequent node in the Huffman tree */ /* =========================================================================== * Remove the smallest element from the heap and recreate the heap with * one less element. Updates heap and heap_len. */ #define pqremove(tree, top) \ {\ top = state.ts.heap[SMALLEST]; \ state.ts.heap[SMALLEST] = state.ts.heap[state.ts.heap_len--]; \ pqdownheap(state,tree, SMALLEST); \ } /* =========================================================================== * Compares to subtrees, using the tree depth as tie breaker when * the subtrees have equal frequency. This minimizes the worst case length. */ #define smaller(tree, n, m) \ (tree[n].fc.freq < tree[m].fc.freq || \ (tree[n].fc.freq == tree[m].fc.freq && state.ts.depth[n] <= state.ts.depth[m])) /* =========================================================================== * Restore the heap property by moving down the tree starting at node k, * exchanging a node with the smallest of its two sons if necessary, stopping * when the heap property is re-established (each father smaller than its * two sons). */ void pqdownheap(TState &state,ct_data *tree, int k) { int v = state.ts.heap[k]; int j = k << 1; /* left son of k */ int htemp; /* required because of bug in SASC compiler */ while (j <= state.ts.heap_len) { /* Set j to the smallest of the two sons: */ if (j < state.ts.heap_len && smaller(tree, state.ts.heap[j+1], state.ts.heap[j])) j++; /* Exit if v is smaller than both sons */ htemp = state.ts.heap[j]; if (smaller(tree, v, htemp)) break; /* Exchange v with the smallest son */ state.ts.heap[k] = htemp; k = j; /* And continue down the tree, setting j to the left son of k */ j <<= 1; } state.ts.heap[k] = v; } /* =========================================================================== * Compute the optimal bit lengths for a tree and update the total bit length * for the current block. * IN assertion: the fields freq and dad are set, heap[heap_max] and * above are the tree nodes sorted by increasing frequency. * OUT assertions: the field len is set to the optimal bit length, the * array bl_count contains the frequencies for each bit length. * The length opt_len is updated; static_len is also updated if stree is * not null. */ void gen_bitlen(TState &state,tree_desc *desc) { ct_data *tree = desc->dyn_tree; const int *extra = desc->extra_bits; int base = desc->extra_base; int max_code = desc->max_code; int max_length = desc->max_length; ct_data *stree = desc->static_tree; int h; /* heap index */ int n, m; /* iterate over the tree elements */ int bits; /* bit length */ int xbits; /* extra bits */ ush f; /* frequency */ int overflow = 0; /* number of elements with bit length too large */ for (bits = 0; bits <= MAX_BITS; bits++) state.ts.bl_count[bits] = 0; /* In a first pass, compute the optimal bit lengths (which may * overflow in the case of the bit length tree). */ tree[state.ts.heap[state.ts.heap_max]].dl.len = 0; /* root of the heap */ for (h = state.ts.heap_max+1; h < HEAP_SIZE; h++) { n = state.ts.heap[h]; bits = tree[tree[n].dl.dad].dl.len + 1; if (bits > max_length) bits = max_length, overflow++; tree[n].dl.len = (ush)bits; /* We overwrite tree[n].dl.dad which is no longer needed */ if (n > max_code) continue; /* not a leaf node */ state.ts.bl_count[bits]++; xbits = 0; if (n >= base) xbits = extra[n-base]; f = tree[n].fc.freq; state.ts.opt_len += (ulg)f * (bits + xbits); if (stree) state.ts.static_len += (ulg)f * (stree[n].dl.len + xbits); } if (overflow == 0) return; Trace("\nbit length overflow\n"); /* This happens for example on obj2 and pic of the Calgary corpus */ /* Find the first bit length which could increase: */ do { bits = max_length-1; while (state.ts.bl_count[bits] == 0) bits--; state.ts.bl_count[bits]--; /* move one leaf down the tree */ state.ts.bl_count[bits+1] += (ush)2; /* move one overflow item as its brother */ state.ts.bl_count[max_length]--; /* The brother of the overflow item also moves one step up, * but this does not affect bl_count[max_length] */ overflow -= 2; } while (overflow > 0); /* Now recompute all bit lengths, scanning in increasing frequency. * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all * lengths instead of fixing only the wrong ones. This idea is taken * from 'ar' written by Haruhiko Okumura.) */ for (bits = max_length; bits != 0; bits--) { n = state.ts.bl_count[bits]; while (n != 0) { m = state.ts.heap[--h]; if (m > max_code) continue; if (tree[m].dl.len != (ush)bits) { Trace("code %d bits %d->%d\n", m, tree[m].dl.len, bits); state.ts.opt_len += ((long)bits-(long)tree[m].dl.len)*(long)tree[m].fc.freq; tree[m].dl.len = (ush)bits; } n--; } } } /* =========================================================================== * Generate the codes for a given tree and bit counts (which need not be * optimal). * IN assertion: the array bl_count contains the bit length statistics for * the given tree and the field len is set for all tree elements. * OUT assertion: the field code is set for all tree elements of non * zero code length. */ void gen_codes (TState &state, ct_data *tree, int max_code) { ush next_code[MAX_BITS+1]; /* next code value for each bit length */ ush code = 0; /* running code value */ int bits; /* bit index */ int n; /* code index */ /* The distribution counts are first used to generate the code values * without bit reversal. */ for (bits = 1; bits <= MAX_BITS; bits++) { next_code[bits] = code = (ush)((code + state.ts.bl_count[bits-1]) << 1); } /* Check that the bit counts in bl_count are consistent. The last code * must be all ones. */ Assert(state,code + state.ts.bl_count[MAX_BITS]-1 == (1<< ((ush) MAX_BITS)) - 1, "inconsistent bit counts"); Trace("\ngen_codes: max_code %d ", max_code); for (n = 0; n <= max_code; n++) { int len = tree[n].dl.len; if (len == 0) continue; /* Now reverse the bits */ tree[n].fc.code = (ush)bi_reverse(next_code[len]++, len); //Tracec(tree != state.ts.static_ltree, "\nn %3d %c l %2d c %4x (%x) ", n, (isgraph(n) ? n : ' '), len, tree[n].fc.code, next_code[len]-1); } } /* =========================================================================== * Construct one Huffman tree and assigns the code bit strings and lengths. * Update the total bit length for the current block. * IN assertion: the field freq is set for all tree elements. * OUT assertions: the fields len and code are set to the optimal bit length * and corresponding code. The length opt_len is updated; static_len is * also updated if stree is not null. The field max_code is set. */ void build_tree(TState &state,tree_desc *desc) { ct_data *tree = desc->dyn_tree; ct_data *stree = desc->static_tree; int elems = desc->elems; int n, m; /* iterate over heap elements */ int max_code = -1; /* largest code with non zero frequency */ int node = elems; /* next internal node of the tree */ /* Construct the initial heap, with least frequent element in * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. * heap[0] is not used. */ state.ts.heap_len = 0, state.ts.heap_max = HEAP_SIZE; for (n = 0; n < elems; n++) { if (tree[n].fc.freq != 0) { state.ts.heap[++state.ts.heap_len] = max_code = n; state.ts.depth[n] = 0; } else { tree[n].dl.len = 0; } } /* The pkzip format requires that at least one distance code exists, * and that at least one bit should be sent even if there is only one * possible code. So to avoid special checks later on we force at least * two codes of non zero frequency. */ while (state.ts.heap_len < 2) { int newcp = state.ts.heap[++state.ts.heap_len] = (max_code < 2 ? ++max_code : 0); tree[newcp].fc.freq = 1; state.ts.depth[newcp] = 0; state.ts.opt_len--; if (stree) state.ts.static_len -= stree[newcp].dl.len; /* new is 0 or 1 so it does not have extra bits */ } desc->max_code = max_code; /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, * establish sub-heaps of increasing lengths: */ for (n = state.ts.heap_len/2; n >= 1; n--) pqdownheap(state,tree, n); /* Construct the Huffman tree by repeatedly combining the least two * frequent nodes. */ do { pqremove(tree, n); /* n = node of least frequency */ m = state.ts.heap[SMALLEST]; /* m = node of next least frequency */ state.ts.heap[--state.ts.heap_max] = n; /* keep the nodes sorted by frequency */ state.ts.heap[--state.ts.heap_max] = m; /* Create a new node father of n and m */ tree[node].fc.freq = (ush)(tree[n].fc.freq + tree[m].fc.freq); state.ts.depth[node] = (uch) (Max(state.ts.depth[n], state.ts.depth[m]) + 1); tree[n].dl.dad = tree[m].dl.dad = (ush)node; /* and insert the new node in the heap */ state.ts.heap[SMALLEST] = node++; pqdownheap(state,tree, SMALLEST); } while (state.ts.heap_len >= 2); state.ts.heap[--state.ts.heap_max] = state.ts.heap[SMALLEST]; /* At this point, the fields freq and dad are set. We can now * generate the bit lengths. */ gen_bitlen(state,(tree_desc *)desc); /* The field len is now set, we can generate the bit codes */ gen_codes (state,(ct_data *)tree, max_code); } /* =========================================================================== * Scan a literal or distance tree to determine the frequencies of the codes * in the bit length tree. Updates opt_len to take into account the repeat * counts. (The contribution of the bit length codes will be added later * during the construction of bl_tree.) */ void scan_tree (TState &state,ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ int nextlen = tree[0].dl.len; /* length of next code */ int count = 0; /* repeat count of the current code */ int max_count = 7; /* max repeat count */ int min_count = 4; /* min repeat count */ if (nextlen == 0) max_count = 138, min_count = 3; tree[max_code+1].dl.len = (ush)-1; /* guard */ for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[n+1].dl.len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { state.ts.bl_tree[curlen].fc.freq = (ush)(state.ts.bl_tree[curlen].fc.freq + count); } else if (curlen != 0) { if (curlen != prevlen) state.ts.bl_tree[curlen].fc.freq++; state.ts.bl_tree[REP_3_6].fc.freq++; } else if (count <= 10) { state.ts.bl_tree[REPZ_3_10].fc.freq++; } else { state.ts.bl_tree[REPZ_11_138].fc.freq++; } count = 0; prevlen = curlen; if (nextlen == 0) { max_count = 138, min_count = 3; } else if (curlen == nextlen) { max_count = 6, min_count = 3; } else { max_count = 7, min_count = 4; } } } /* =========================================================================== * Send a literal or distance tree in compressed form, using the codes in * bl_tree. */ void send_tree (TState &state, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ int nextlen = tree[0].dl.len; /* length of next code */ int count = 0; /* repeat count of the current code */ int max_count = 7; /* max repeat count */ int min_count = 4; /* min repeat count */ /* tree[max_code+1].dl.len = -1; */ /* guard already set */ if (nextlen == 0) max_count = 138, min_count = 3; for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[n+1].dl.len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { do { send_code(state, curlen, state.ts.bl_tree); } while (--count != 0); } else if (curlen != 0) { if (curlen != prevlen) { send_code(state, curlen, state.ts.bl_tree); count--; } Assert(state,count >= 3 && count <= 6, " 3_6?"); send_code(state,REP_3_6, state.ts.bl_tree); send_bits(state,count-3, 2); } else if (count <= 10) { send_code(state,REPZ_3_10, state.ts.bl_tree); send_bits(state,count-3, 3); } else { send_code(state,REPZ_11_138, state.ts.bl_tree); send_bits(state,count-11, 7); } count = 0; prevlen = curlen; if (nextlen == 0) { max_count = 138, min_count = 3; } else if (curlen == nextlen) { max_count = 6, min_count = 3; } else { max_count = 7, min_count = 4; } } } /* =========================================================================== * Construct the Huffman tree for the bit lengths and return the index in * bl_order of the last bit length code to send. */ int build_bl_tree(TState &state) { int max_blindex; /* index of last bit length code of non zero freq */ /* Determine the bit length frequencies for literal and distance trees */ scan_tree(state,(ct_data *)state.ts.dyn_ltree, state.ts.l_desc.max_code); scan_tree(state,(ct_data *)state.ts.dyn_dtree, state.ts.d_desc.max_code); /* Build the bit length tree: */ build_tree(state,(tree_desc *)(&state.ts.bl_desc)); /* opt_len now includes the length of the tree representations, except * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. */ /* Determine the number of bit length codes to send. The pkzip format * requires that at least 4 bit length codes be sent. (appnote.txt says * 3 but the actual value used is 4.) */ for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { if (state.ts.bl_tree[bl_order[max_blindex]].dl.len != 0) break; } /* Update opt_len to include the bit length tree and counts */ state.ts.opt_len += 3*(max_blindex+1) + 5+5+4; Trace("\ndyn trees: dyn %ld, stat %ld", state.ts.opt_len, state.ts.static_len); return max_blindex; } /* =========================================================================== * Send the header for a block using dynamic Huffman trees: the counts, the * lengths of the bit length codes, the literal tree and the distance tree. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. */ void send_all_trees(TState &state,int lcodes, int dcodes, int blcodes) { int rank; /* index in bl_order */ Assert(state,lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); Assert(state,lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, "too many codes"); Trace("\nbl counts: "); send_bits(state,lcodes-257, 5); /* not +255 as stated in appnote.txt 1.93a or -256 in 2.04c */ send_bits(state,dcodes-1, 5); send_bits(state,blcodes-4, 4); /* not -3 as stated in appnote.txt */ for (rank = 0; rank < blcodes; rank++) { Trace("\nbl code %2d ", bl_order[rank]); send_bits(state,state.ts.bl_tree[bl_order[rank]].dl.len, 3); } Trace("\nbl tree: sent %ld", state.bs.bits_sent); send_tree(state,(ct_data *)state.ts.dyn_ltree, lcodes-1); /* send the literal tree */ Trace("\nlit tree: sent %ld", state.bs.bits_sent); send_tree(state,(ct_data *)state.ts.dyn_dtree, dcodes-1); /* send the distance tree */ Trace("\ndist tree: sent %ld", state.bs.bits_sent); } /* =========================================================================== * Determine the best encoding for the current block: dynamic trees, static * trees or store, and output the encoded block to the zip file. This function * returns the total compressed length (in bytes) for the file so far. */ ulg flush_block(TState &state,char *buf, ulg stored_len, int eof) { ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ int max_blindex; /* index of last bit length code of non zero freq */ state.ts.flag_buf[state.ts.last_flags] = state.ts.flags; /* Save the flags for the last 8 items */ /* Check if the file is ascii or binary */ if (*state.ts.file_type == (ush)UNKNOWN) set_file_type(state); /* Construct the literal and distance trees */ build_tree(state,(tree_desc *)(&state.ts.l_desc)); Trace("\nlit data: dyn %ld, stat %ld", state.ts.opt_len, state.ts.static_len); build_tree(state,(tree_desc *)(&state.ts.d_desc)); Trace("\ndist data: dyn %ld, stat %ld", state.ts.opt_len, state.ts.static_len); /* At this point, opt_len and static_len are the total bit lengths of * the compressed block data, excluding the tree representations. */ /* Build the bit length tree for the above two trees, and get the index * in bl_order of the last bit length code to send. */ max_blindex = build_bl_tree(state); /* Determine the best encoding. Compute first the block length in bytes */ opt_lenb = (state.ts.opt_len+3+7)>>3; static_lenb = (state.ts.static_len+3+7)>>3; state.ts.input_len += stored_len; /* for debugging only */ Trace("\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ", opt_lenb, state.ts.opt_len, static_lenb, state.ts.static_len, stored_len, state.ts.last_lit, state.ts.last_dist); if (static_lenb <= opt_lenb) opt_lenb = static_lenb; // Originally, zip allowed the file to be transformed from a compressed // into a stored file in the case where compression failed, there // was only one block, and it was allowed to change. I've removed this // possibility since the code's cleaner if no changes are allowed. //if (stored_len <= opt_lenb && eof && state.ts.cmpr_bytelen == 0L // && state.ts.cmpr_len_bits == 0L && state.seekable) //{ // && state.ts.file_method != NULL // // Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: // Assert(state,buf!=NULL,"block vanished"); // copy_block(state,buf, (unsigned)stored_len, 0); // without header // state.ts.cmpr_bytelen = stored_len; // Assert(state,false,"unimplemented *state.ts.file_method = STORE;"); // //*state.ts.file_method = STORE; //} //else if (stored_len+4 <= opt_lenb && buf != (char*)NULL) { /* 4: two words for the lengths */ /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. * Otherwise we can't have processed more than WSIZE input bytes since * the last block flush, because compression would have been * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to * transform a block into a stored block. */ send_bits(state,(STORED_BLOCK<<1)+eof, 3); /* send block type */ state.ts.cmpr_bytelen += ((state.ts.cmpr_len_bits + 3 + 7) >> 3) + stored_len + 4; state.ts.cmpr_len_bits = 0L; copy_block(state,buf, (unsigned)stored_len, 1); /* with header */ } else if (static_lenb == opt_lenb) { send_bits(state,(STATIC_TREES<<1)+eof, 3); compress_block(state,(ct_data *)state.ts.static_ltree, (ct_data *)state.ts.static_dtree); state.ts.cmpr_len_bits += 3 + state.ts.static_len; state.ts.cmpr_bytelen += state.ts.cmpr_len_bits >> 3; state.ts.cmpr_len_bits &= 7L; } else { send_bits(state,(DYN_TREES<<1)+eof, 3); send_all_trees(state,state.ts.l_desc.max_code+1, state.ts.d_desc.max_code+1, max_blindex+1); compress_block(state,(ct_data *)state.ts.dyn_ltree, (ct_data *)state.ts.dyn_dtree); state.ts.cmpr_len_bits += 3 + state.ts.opt_len; state.ts.cmpr_bytelen += state.ts.cmpr_len_bits >> 3; state.ts.cmpr_len_bits &= 7L; } Assert(state,((state.ts.cmpr_bytelen << 3) + state.ts.cmpr_len_bits) == state.bs.bits_sent, "bad compressed size"); init_block(state); if (eof) { // Assert(state,input_len == isize, "bad input size"); bi_windup(state); state.ts.cmpr_len_bits += 7; /* align on byte boundary */ } Trace("\n"); return state.ts.cmpr_bytelen + (state.ts.cmpr_len_bits >> 3); } /* =========================================================================== * Save the match info and tally the frequency counts. Return true if * the current block must be flushed. */ int ct_tally (TState &state,int dist, int lc) { state.ts.l_buf[state.ts.last_lit++] = (uch)lc; if (dist == 0) { /* lc is the unmatched char */ state.ts.dyn_ltree[lc].fc.freq++; } else { /* Here, lc is the match length - MIN_MATCH */ dist--; /* dist = match distance - 1 */ Assert(state,(ush)dist < (ush)MAX_DIST && (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && (ush)d_code(dist) < (ush)D_CODES, "ct_tally: bad match"); state.ts.dyn_ltree[state.ts.length_code[lc]+LITERALS+1].fc.freq++; state.ts.dyn_dtree[d_code(dist)].fc.freq++; state.ts.d_buf[state.ts.last_dist++] = (ush)dist; state.ts.flags |= state.ts.flag_bit; } state.ts.flag_bit <<= 1; /* Output the flags if they fill a byte: */ if ((state.ts.last_lit & 7) == 0) { state.ts.flag_buf[state.ts.last_flags++] = state.ts.flags; state.ts.flags = 0, state.ts.flag_bit = 1; } /* Try to guess if it is profitable to stop the current block here */ if (state.level > 2 && (state.ts.last_lit & 0xfff) == 0) { /* Compute an upper bound for the compressed length */ ulg out_length = (ulg)state.ts.last_lit*8L; ulg in_length = (ulg)state.ds.strstart-state.ds.block_start; int dcode; for (dcode = 0; dcode < D_CODES; dcode++) { out_length += (ulg)state.ts.dyn_dtree[dcode].fc.freq*(5L+extra_dbits[dcode]); } out_length >>= 3; Trace("\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ", state.ts.last_lit, state.ts.last_dist, in_length, out_length, 100L - out_length*100L/in_length); if (state.ts.last_dist < state.ts.last_lit/2 && out_length < in_length/2) return 1; } return (state.ts.last_lit == LIT_BUFSIZE-1 || state.ts.last_dist == DIST_BUFSIZE); /* We avoid equality with LIT_BUFSIZE because of wraparound at 64K * on 16 bit machines and because stored blocks are restricted to * 64K-1 bytes. */ } /* =========================================================================== * Send the block data compressed using the given Huffman trees */ void compress_block(TState &state,ct_data *ltree, ct_data *dtree) { unsigned dist; /* distance of matched string */ int lc; /* match length or unmatched char (if dist == 0) */ unsigned lx = 0; /* running index in l_buf */ unsigned dx = 0; /* running index in d_buf */ unsigned fx = 0; /* running index in flag_buf */ uch flag = 0; /* current flags */ unsigned code; /* the code to send */ int extra; /* number of extra bits to send */ if (state.ts.last_lit != 0) do { if ((lx & 7) == 0) flag = state.ts.flag_buf[fx++]; lc = state.ts.l_buf[lx++]; if ((flag & 1) == 0) { send_code(state,lc, ltree); /* send a literal byte */ } else { /* Here, lc is the match length - MIN_MATCH */ code = state.ts.length_code[lc]; send_code(state,code+LITERALS+1, ltree); /* send the length code */ extra = extra_lbits[code]; if (extra != 0) { lc -= state.ts.base_length[code]; send_bits(state,lc, extra); /* send the extra length bits */ } dist = state.ts.d_buf[dx++]; /* Here, dist is the match distance - 1 */ code = d_code(dist); Assert(state,code < D_CODES, "bad d_code"); send_code(state,code, dtree); /* send the distance code */ extra = extra_dbits[code]; if (extra != 0) { dist -= state.ts.base_dist[code]; send_bits(state,dist, extra); /* send the extra distance bits */ } } /* literal or match pair ? */ flag >>= 1; } while (lx < state.ts.last_lit); send_code(state,END_BLOCK, ltree); } /* =========================================================================== * Set the file type to ASCII or BINARY, using a crude approximation: * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. * IN assertion: the fields freq of dyn_ltree are set and the total of all * frequencies does not exceed 64K (to fit in an int on 16 bit machines). */ void set_file_type(TState &state) { int n = 0; unsigned ascii_freq = 0; unsigned bin_freq = 0; while (n < 7) bin_freq += state.ts.dyn_ltree[n++].fc.freq; while (n < 128) ascii_freq += state.ts.dyn_ltree[n++].fc.freq; while (n < LITERALS) bin_freq += state.ts.dyn_ltree[n++].fc.freq; *state.ts.file_type = (ush)(bin_freq > (ascii_freq >> 2) ? BINARY : ASCII); } /* =========================================================================== * Initialize the bit string routines. */ void bi_init (TState &state,char *tgt_buf, unsigned tgt_size, int flsh_allowed) { state.bs.out_buf = tgt_buf; state.bs.out_size = tgt_size; state.bs.out_offset = 0; state.bs.flush_flg = flsh_allowed; state.bs.bi_buf = 0; state.bs.bi_valid = 0; state.bs.bits_sent = 0L; } /* =========================================================================== * Send a value on a given number of bits. * IN assertion: length <= 16 and value fits in length bits. */ void send_bits(TState &state,int value, int length) { Assert(state,length > 0 && length <= 15, "invalid length"); state.bs.bits_sent += (ulg)length; /* If not enough room in bi_buf, use (bi_valid) bits from bi_buf and * (Buf_size - bi_valid) bits from value to flush the filled bi_buf, * then fill in the rest of (value), leaving (length - (Buf_size-bi_valid)) * unused bits in bi_buf. */ state.bs.bi_buf |= (value << state.bs.bi_valid); state.bs.bi_valid += length; if (state.bs.bi_valid > (int)Buf_size) { PUTSHORT(state,state.bs.bi_buf); state.bs.bi_valid -= Buf_size; state.bs.bi_buf = (unsigned)value >> (length - state.bs.bi_valid); } } /* =========================================================================== * Reverse the first len bits of a code, using straightforward code (a faster * method would use a table) * IN assertion: 1 <= len <= 15 */ unsigned bi_reverse(unsigned code, int len) { register unsigned res = 0; do { res |= code & 1; code >>= 1, res <<= 1; } while (--len > 0); return res >> 1; } /* =========================================================================== * Write out any remaining bits in an incomplete byte. */ void bi_windup(TState &state) { if (state.bs.bi_valid > 8) { PUTSHORT(state,state.bs.bi_buf); } else if (state.bs.bi_valid > 0) { PUTBYTE(state,state.bs.bi_buf); } if (state.bs.flush_flg) { state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); } state.bs.bi_buf = 0; state.bs.bi_valid = 0; state.bs.bits_sent = (state.bs.bits_sent+7) & ~7; } /* =========================================================================== * Copy a stored block to the zip file, storing first the length and its * one's complement if requested. */ void copy_block(TState &state, char *block, unsigned len, int header) { bi_windup(state); /* align on byte boundary */ if (header) { PUTSHORT(state,(ush)len); PUTSHORT(state,(ush)~len); state.bs.bits_sent += 2*16; } if (state.bs.flush_flg) { state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); state.bs.out_offset = len; state.flush_outbuf(state.param,block, &state.bs.out_offset); } else if (state.bs.out_offset + len > state.bs.out_size) { Assert(state,false,"output buffer too small for in-memory compression"); } else { memcpy(state.bs.out_buf + state.bs.out_offset, block, len); state.bs.out_offset += len; } state.bs.bits_sent += (ulg)len<<3; } /* =========================================================================== * Prototypes for functions. */ void fill_window (TState &state); ulg deflate_fast (TState &state); int longest_match (TState &state,IPos cur_match); /* =========================================================================== * Update a hash value with the given input byte * IN assertion: all calls to to UPDATE_HASH are made with consecutive * input characters, so that a running hash key can be computed from the * previous key instead of complete recalculation each time. */ #define UPDATE_HASH(h,c) (h = (((h)<<H_SHIFT) ^ (c)) & HASH_MASK) /* =========================================================================== * Insert string s in the dictionary and set match_head to the previous head * of the hash chain (the most recent string with same hash key). Return * the previous length of the hash chain. * IN assertion: all calls to to INSERT_STRING are made with consecutive * input characters and the first MIN_MATCH bytes of s are valid * (except for the last MIN_MATCH-1 bytes of the input file). */ #define INSERT_STRING(s, match_head) \ (UPDATE_HASH(state.ds.ins_h, state.ds.window[(s) + (MIN_MATCH-1)]), \ state.ds.prev[(s) & WMASK] = match_head = state.ds.head[state.ds.ins_h], \ state.ds.head[state.ds.ins_h] = (s)) /* =========================================================================== * Initialize the "longest match" routines for a new file * * IN assertion: window_size is > 0 if the input file is already read or * mmap'ed in the window[] array, 0 otherwise. In the first case, * window_size is sufficient to contain the whole input file plus * MIN_LOOKAHEAD bytes (to avoid referencing memory beyond the end * of window[] when looking for matches towards the end). */ void lm_init (TState &state, int pack_level, ush *flags) { register unsigned j; Assert(state,pack_level>=1 && pack_level<=8,"bad pack level"); /* Do not slide the window if the whole input is already in memory * (window_size > 0) */ state.ds.sliding = 0; if (state.ds.window_size == 0L) { state.ds.sliding = 1; state.ds.window_size = (ulg)2L*WSIZE; } /* Initialize the hash table (avoiding 64K overflow for 16 bit systems). * prev[] will be initialized on the fly. */ state.ds.head[HASH_SIZE-1] = NIL; memset((char*)state.ds.head, NIL, (unsigned)(HASH_SIZE-1)*sizeof(*state.ds.head)); /* Set the default configuration parameters: */ state.ds.max_lazy_match = configuration_table[pack_level].max_lazy; state.ds.good_match = configuration_table[pack_level].good_length; state.ds.nice_match = configuration_table[pack_level].nice_length; state.ds.max_chain_length = configuration_table[pack_level].max_chain; if (pack_level <= 2) { *flags |= FAST; } else if (pack_level >= 8) { *flags |= SLOW; } /* ??? reduce max_chain_length for binary files */ state.ds.strstart = 0; state.ds.block_start = 0L; j = WSIZE; j <<= 1; // Can read 64K in one step state.ds.lookahead = state.readfunc(state, (char*)state.ds.window, j); if (state.ds.lookahead == 0 || state.ds.lookahead == (unsigned)EOF) { state.ds.eofile = 1, state.ds.lookahead = 0; return; } state.ds.eofile = 0; /* Make sure that we always have enough lookahead. This is important * if input comes from a device such as a tty. */ if (state.ds.lookahead < MIN_LOOKAHEAD) fill_window(state); state.ds.ins_h = 0; for (j=0; j<MIN_MATCH-1; j++) UPDATE_HASH(state.ds.ins_h, state.ds.window[j]); /* If lookahead < MIN_MATCH, ins_h is garbage, but this is * not important since only literal bytes will be emitted. */ } /* =========================================================================== * Set match_start to the longest match starting at the given string and * return its length. Matches shorter or equal to prev_length are discarded, * in which case the result is equal to prev_length and match_start is * garbage. * IN assertions: cur_match is the head of the hash chain for the current * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 */ // For 80x86 and 680x0 and ARM, an optimized version is in match.asm or // match.S. The code is functionally equivalent, so you can use the C version // if desired. Which I do so desire! int longest_match(TState &state,IPos cur_match) { unsigned chain_length = state.ds.max_chain_length; /* max hash chain length */ register uch far *scan = state.ds.window + state.ds.strstart; /* current string */ register uch far *match; /* matched string */ register int len; /* length of current match */ int best_len = state.ds.prev_length; /* best match length so far */ IPos limit = state.ds.strstart > (IPos)MAX_DIST ? state.ds.strstart - (IPos)MAX_DIST : NIL; /* Stop when cur_match becomes <= limit. To simplify the code, * we prevent matches with the string of window index 0. */ // The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. // It is easy to get rid of this optimization if necessary. Assert(state,HASH_BITS>=8 && MAX_MATCH==258,"Code too clever"); register uch far *strend = state.ds.window + state.ds.strstart + MAX_MATCH; register uch scan_end1 = scan[best_len-1]; register uch scan_end = scan[best_len]; /* Do not waste too much time if we already have a good match: */ if (state.ds.prev_length >= state.ds.good_match) { chain_length >>= 2; } Assert(state,state.ds.strstart <= state.ds.window_size-MIN_LOOKAHEAD, "insufficient lookahead"); do { Assert(state,cur_match < state.ds.strstart, "no future"); match = state.ds.window + cur_match; /* Skip to next match if the match length cannot increase * or if the match length is less than 2: */ if (match[best_len] != scan_end || match[best_len-1] != scan_end1 || *match != *scan || *++match != scan[1]) continue; /* The check at best_len-1 can be removed because it will be made * again later. (This heuristic is not always a win.) * It is not necessary to compare scan[2] and match[2] since they * are always equal when the other bytes match, given that * the hash keys are equal and that HASH_BITS >= 8. */ scan += 2, match++; /* We check for insufficient lookahead only every 8th comparison; * the 256th check will be made at strstart+258. */ do { } while (*++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && scan < strend); Assert(state,scan <= state.ds.window+(unsigned)(state.ds.window_size-1), "wild scan"); len = MAX_MATCH - (int)(strend - scan); scan = strend - MAX_MATCH; if (len > best_len) { state.ds.match_start = cur_match; best_len = len; if (len >= state.ds.nice_match) break; scan_end1 = scan[best_len-1]; scan_end = scan[best_len]; } } while ((cur_match = state.ds.prev[cur_match & WMASK]) > limit && --chain_length != 0); return best_len; } #define check_match(state,start, match, length) // or alternatively... //void check_match(TState &state,IPos start, IPos match, int length) //{ // check that the match is indeed a match // if (memcmp((char*)state.ds.window + match, // (char*)state.ds.window + start, length) != EQUAL) { // fprintf(stderr, // " start %d, match %d, length %d\n", // start, match, length); // error("invalid match"); // } // if (state.verbose > 1) { // fprintf(stderr,"\\[%d,%d]", start-match, length); // do { fprintf(stdout,"%c",state.ds.window[start++]); } while (--length != 0); // } //} /* =========================================================================== * Fill the window when the lookahead becomes insufficient. * Updates strstart and lookahead, and sets eofile if end of input file. * * IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0 * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD * At least one byte has been read, or eofile is set; file reads are * performed for at least two bytes (required for the translate_eol option). */ void fill_window(TState &state) { register unsigned n, m; unsigned more; /* Amount of free space at the end of the window. */ do { more = (unsigned)(state.ds.window_size - (ulg)state.ds.lookahead - (ulg)state.ds.strstart); /* If the window is almost full and there is insufficient lookahead, * move the upper half to the lower one to make room in the upper half. */ if (more == (unsigned)EOF) { /* Very unlikely, but possible on 16 bit machine if strstart == 0 * and lookahead == 1 (input done one byte at time) */ more--; /* For MMAP or BIG_MEM, the whole input file is already in memory so * we must not perform sliding. We must however call (*read_buf)() in * order to compute the crc, update lookahead and possibly set eofile. */ } else if (state.ds.strstart >= WSIZE+MAX_DIST && state.ds.sliding) { /* By the IN assertion, the window is not empty so we can't confuse * more == 0 with more == 64K on a 16 bit machine. */ memcpy((char*)state.ds.window, (char*)state.ds.window+WSIZE, (unsigned)WSIZE); state.ds.match_start -= WSIZE; state.ds.strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */ state.ds.block_start -= (long) WSIZE; for (n = 0; n < HASH_SIZE; n++) { m = state.ds.head[n]; state.ds.head[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL); } for (n = 0; n < WSIZE; n++) { m = state.ds.prev[n]; state.ds.prev[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL); /* If n is not on any hash chain, prev[n] is garbage but * its value will never be used. */ } more += WSIZE; } if (state.ds.eofile) return; /* If there was no sliding: * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && * more == window_size - lookahead - strstart * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) * => more >= window_size - 2*WSIZE + 2 * In the MMAP or BIG_MEM case (not yet supported in gzip), * window_size == input_size + MIN_LOOKAHEAD && * strstart + lookahead <= input_size => more >= MIN_LOOKAHEAD. * Otherwise, window_size == 2*WSIZE so more >= 2. * If there was sliding, more >= WSIZE. So in all cases, more >= 2. */ Assert(state,more >= 2, "more < 2"); n = state.readfunc(state, (char*)state.ds.window+state.ds.strstart+state.ds.lookahead, more); if (n == 0 || n == (unsigned)EOF) { state.ds.eofile = 1; } else { state.ds.lookahead += n; } } while (state.ds.lookahead < MIN_LOOKAHEAD && !state.ds.eofile); } /* =========================================================================== * Flush the current block, with given end-of-file flag. * IN assertion: strstart is set to the end of the current match. */ #define FLUSH_BLOCK(state,eof) \ flush_block(state,state.ds.block_start >= 0L ? (char*)&state.ds.window[(unsigned)state.ds.block_start] : \ (char*)NULL, (long)state.ds.strstart - state.ds.block_start, (eof)) /* =========================================================================== * Processes a new input file and return its compressed length. This * function does not perform lazy evaluation of matches and inserts * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */ ulg deflate_fast(TState &state) { IPos hash_head = NIL; /* head of the hash chain */ int flush; /* set if current block must be flushed */ unsigned match_length = 0; /* length of best match */ state.ds.prev_length = MIN_MATCH-1; while (state.ds.lookahead != 0) { /* Insert the string window[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ if (state.ds.lookahead >= MIN_MATCH) INSERT_STRING(state.ds.strstart, hash_head); /* Find the longest match, discarding those <= prev_length. * At this point we have always match_length < MIN_MATCH */ if (hash_head != NIL && state.ds.strstart - hash_head <= MAX_DIST) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ /* Do not look for matches beyond the end of the input. * This is necessary to make deflate deterministic. */ if ((unsigned)state.ds.nice_match > state.ds.lookahead) state.ds.nice_match = (int)state.ds.lookahead; match_length = longest_match (state,hash_head); /* longest_match() sets match_start */ if (match_length > state.ds.lookahead) match_length = state.ds.lookahead; } if (match_length >= MIN_MATCH) { check_match(state,state.ds.strstart, state.ds.match_start, match_length); flush = ct_tally(state,state.ds.strstart-state.ds.match_start, match_length - MIN_MATCH); state.ds.lookahead -= match_length; /* Insert new strings in the hash table only if the match length * is not too large. This saves time but degrades compression. */ if (match_length <= state.ds.max_insert_length && state.ds.lookahead >= MIN_MATCH) { match_length--; /* string at strstart already in hash table */ do { state.ds.strstart++; INSERT_STRING(state.ds.strstart, hash_head); /* strstart never exceeds WSIZE-MAX_MATCH, so there are * always MIN_MATCH bytes ahead. */ } while (--match_length != 0); state.ds.strstart++; } else { state.ds.strstart += match_length; match_length = 0; state.ds.ins_h = state.ds.window[state.ds.strstart]; UPDATE_HASH(state.ds.ins_h, state.ds.window[state.ds.strstart+1]); Assert(state,MIN_MATCH==3,"Call UPDATE_HASH() MIN_MATCH-3 more times"); } } else { /* No match, output a literal byte */ flush = ct_tally (state,0, state.ds.window[state.ds.strstart]); state.ds.lookahead--; state.ds.strstart++; } if (flush) FLUSH_BLOCK(state,0), state.ds.block_start = state.ds.strstart; /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the * string following the next match. */ if (state.ds.lookahead < MIN_LOOKAHEAD) fill_window(state); } return FLUSH_BLOCK(state,1); /* eof */ } /* =========================================================================== * Same as above, but achieves better compression. We use a lazy * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ ulg deflate(TState &state) { IPos hash_head = NIL; /* head of hash chain */ IPos prev_match; /* previous match */ int flush; /* set if current block must be flushed */ int match_available = 0; /* set if previous match exists */ register unsigned match_length = MIN_MATCH-1; /* length of best match */ if (state.level <= 3) return deflate_fast(state); /* optimized for speed */ /* Process the input block. */ while (state.ds.lookahead != 0) { /* Insert the string window[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ if (state.ds.lookahead >= MIN_MATCH) INSERT_STRING(state.ds.strstart, hash_head); /* Find the longest match, discarding those <= prev_length. */ state.ds.prev_length = match_length, prev_match = state.ds.match_start; match_length = MIN_MATCH-1; if (hash_head != NIL && state.ds.prev_length < state.ds.max_lazy_match && state.ds.strstart - hash_head <= MAX_DIST) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ /* Do not look for matches beyond the end of the input. * This is necessary to make deflate deterministic. */ if ((unsigned)state.ds.nice_match > state.ds.lookahead) state.ds.nice_match = (int)state.ds.lookahead; match_length = longest_match (state,hash_head); /* longest_match() sets match_start */ if (match_length > state.ds.lookahead) match_length = state.ds.lookahead; /* Ignore a length 3 match if it is too distant: */ if (match_length == MIN_MATCH && state.ds.strstart-state.ds.match_start > TOO_FAR){ /* If prev_match is also MIN_MATCH, match_start is garbage * but we will ignore the current match anyway. */ match_length = MIN_MATCH-1; } } /* If there was a match at the previous step and the current * match is not better, output the previous match: */ if (state.ds.prev_length >= MIN_MATCH && match_length <= state.ds.prev_length) { unsigned max_insert = state.ds.strstart + state.ds.lookahead - MIN_MATCH; check_match(state,state.ds.strstart-1, prev_match, state.ds.prev_length); flush = ct_tally(state,state.ds.strstart-1-prev_match, state.ds.prev_length - MIN_MATCH); /* Insert in hash table all strings up to the end of the match. * strstart-1 and strstart are already inserted. */ state.ds.lookahead -= state.ds.prev_length-1; state.ds.prev_length -= 2; do { if (++state.ds.strstart <= max_insert) { INSERT_STRING(state.ds.strstart, hash_head); /* strstart never exceeds WSIZE-MAX_MATCH, so there are * always MIN_MATCH bytes ahead. */ } } while (--state.ds.prev_length != 0); state.ds.strstart++; match_available = 0; match_length = MIN_MATCH-1; if (flush) FLUSH_BLOCK(state,0), state.ds.block_start = state.ds.strstart; } else if (match_available) { /* If there was no match at the previous position, output a * single literal. If there was a match but the current match * is longer, truncate the previous match to a single literal. */ if (ct_tally (state,0, state.ds.window[state.ds.strstart-1])) { FLUSH_BLOCK(state,0), state.ds.block_start = state.ds.strstart; } state.ds.strstart++; state.ds.lookahead--; } else { /* There is no previous match to compare with, wait for * the next step to decide. */ match_available = 1; state.ds.strstart++; state.ds.lookahead--; } // Assert(state,strstart <= isize && lookahead <= isize, "a bit too far"); /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the * string following the next match. */ if (state.ds.lookahead < MIN_LOOKAHEAD) fill_window(state); } if (match_available) ct_tally (state,0, state.ds.window[state.ds.strstart-1]); return FLUSH_BLOCK(state,1); /* eof */ } int putlocal(struct zlist far *z, WRITEFUNC wfunc,void *param) { // Write a local header described by *z to file *f. Return a ZE_ error code. PUTLG(LOCSIG, f); PUTSH(z->ver, f); PUTSH(z->lflg, f); PUTSH(z->how, f); PUTLG(z->tim, f); PUTLG(z->crc, f); PUTLG(z->siz, f); PUTLG(z->len, f); PUTSH(z->nam, f); PUTSH(z->ext, f); size_t res = (size_t)wfunc(param, z->iname, (unsigned int)z->nam); if (res!=z->nam) return ZE_TEMP; if (z->ext) { res = (size_t)wfunc(param, z->extra, (unsigned int)z->ext); if (res!=z->ext) return ZE_TEMP; } return ZE_OK; } int putextended(struct zlist far *z, WRITEFUNC wfunc, void *param) { // Write an extended local header described by *z to file *f. Returns a ZE_ code PUTLG(EXTLOCSIG, f); PUTLG(z->crc, f); PUTLG(z->siz, f); PUTLG(z->len, f); return ZE_OK; } int putcentral(struct zlist far *z, WRITEFUNC wfunc, void *param) { // Write a central header entry of *z to file *f. Returns a ZE_ code. PUTLG(CENSIG, f); PUTSH(z->vem, f); PUTSH(z->ver, f); PUTSH(z->flg, f); PUTSH(z->how, f); PUTLG(z->tim, f); PUTLG(z->crc, f); PUTLG(z->siz, f); PUTLG(z->len, f); PUTSH(z->nam, f); PUTSH(z->cext, f); PUTSH(z->com, f); PUTSH(z->dsk, f); PUTSH(z->att, f); PUTLG(z->atx, f); PUTLG(z->off, f); if ((size_t)wfunc(param, z->iname, (unsigned int)z->nam) != z->nam || (z->cext && (size_t)wfunc(param, z->cextra, (unsigned int)z->cext) != z->cext) || (z->com && (size_t)wfunc(param, z->comment, (unsigned int)z->com) != z->com)) return ZE_TEMP; return ZE_OK; } int putend(int n, ulg s, ulg c, extent m, char *z, WRITEFUNC wfunc, void *param) { // write the end of the central-directory-data to file *f. PUTLG(ENDSIG, f); PUTSH(0, f); PUTSH(0, f); PUTSH(n, f); PUTSH(n, f); PUTLG(s, f); PUTLG(c, f); PUTSH(m, f); // Write the comment, if any if (m && wfunc(param, z, (unsigned int)m) != m) return ZE_TEMP; return ZE_OK; } const ulg crc_table[256] = { 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL }; #define CRC32(c, b) (crc_table[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8)) #define DO1(buf) crc = CRC32(crc, *buf++) #define DO2(buf) DO1(buf); DO1(buf) #define DO4(buf) DO2(buf); DO2(buf) #define DO8(buf) DO4(buf); DO4(buf) ulg crc32(ulg crc, const uch *buf, extent len) { if (buf==NULL) return 0L; crc = crc ^ 0xffffffffL; while (len >= 8) {DO8(buf); len -= 8;} if (len) do {DO1(buf);} while (--len); return crc ^ 0xffffffffL; // (instead of ~c for 64-bit machines) } void update_keys(unsigned long *keys, char c) { keys[0] = CRC32(keys[0],c); keys[1] += keys[0] & 0xFF; keys[1] = keys[1]*134775813L +1; keys[2] = CRC32(keys[2], keys[1] >> 24); } char decrypt_byte(unsigned long *keys) { unsigned temp = ((unsigned)keys[2] & 0xffff) | 2; return (char)(((temp * (temp ^ 1)) >> 8) & 0xff); } char zencode(unsigned long *keys, char c) { int t=decrypt_byte(keys); update_keys(keys,c); return (char)(t^c); } bool HasZipSuffix(const TCHAR *fn) { const TCHAR *ext = fn+_tcslen(fn); while (ext>fn && *ext!='.') ext--; if (ext==fn && *ext!='.') return false; if (_tcsicmp(ext,_T(".Z"))==0) return true; if (_tcsicmp(ext,_T(".zip"))==0) return true; if (_tcsicmp(ext,_T(".zoo"))==0) return true; if (_tcsicmp(ext,_T(".arc"))==0) return true; if (_tcsicmp(ext,_T(".lzh"))==0) return true; if (_tcsicmp(ext,_T(".arj"))==0) return true; if (_tcsicmp(ext,_T(".gz"))==0) return true; if (_tcsicmp(ext,_T(".tgz"))==0) return true; return false; } lutime_t filetime2timet(const FILETIME ft) { __int64 i = *(__int64*)&ft; return (lutime_t)((i-116444736000000000)/10000000); } void filetime2dosdatetime(const FILETIME ft, WORD *dosdate,WORD *dostime) { // date: bits 0-4 are day of month 1-31. Bits 5-8 are month 1..12. Bits 9-15 are year-1980 // time: bits 0-4 are seconds/2, bits 5-10 are minute 0..59. Bits 11-15 are hour 0..23 SYSTEMTIME st; FileTimeToSystemTime(&ft,&st); *dosdate = (WORD)(((st.wYear-1980)&0x7f) << 9); *dosdate |= (WORD)((st.wMonth&0xf) << 5); *dosdate |= (WORD)((st.wDay&0x1f)); *dostime = (WORD)((st.wHour&0x1f) << 11); *dostime |= (WORD)((st.wMinute&0x3f) << 5); *dostime |= (WORD)((st.wSecond*2)&0x1f); } ZRESULT GetFileInfo(HANDLE hf, ulg *attr, long *size, iztimes *times, ulg *timestamp) { // The handle must be a handle to a file // The date and time is returned in a long with the date most significant to allow // unsigned integer comparison of absolute times. The attributes have two // high bytes unix attr, and two low bytes a mapping of that to DOS attr. //struct stat s; int res=stat(fn,&s); if (res!=0) return false; // translate windows file attributes into zip ones. BY_HANDLE_FILE_INFORMATION bhi; BOOL res=GetFileInformationByHandle(hf,&bhi); if (!res) return ZR_NOFILE; DWORD fa=bhi.dwFileAttributes; ulg a=0; // Zip uses the lower word for its interpretation of windows stuff if (fa&FILE_ATTRIBUTE_READONLY) a|=0x01; if (fa&FILE_ATTRIBUTE_HIDDEN) a|=0x02; if (fa&FILE_ATTRIBUTE_SYSTEM) a|=0x04; if (fa&FILE_ATTRIBUTE_DIRECTORY)a|=0x10; if (fa&FILE_ATTRIBUTE_ARCHIVE) a|=0x20; // It uses the upper word for standard unix attr, which we manually construct if (fa&FILE_ATTRIBUTE_DIRECTORY)a|=0x40000000; // directory else a|=0x80000000; // normal file a|=0x01000000; // readable if (fa&FILE_ATTRIBUTE_READONLY) {} else a|=0x00800000; // writeable // now just a small heuristic to check if it's an executable: DWORD red, hsize=GetFileSize(hf,NULL); if (hsize>40) { SetFilePointer(hf,0,NULL,FILE_BEGIN); unsigned short magic; ReadFile(hf,&magic,sizeof(magic),&red,NULL); SetFilePointer(hf,36,NULL,FILE_BEGIN); unsigned long hpos; ReadFile(hf,&hpos,sizeof(hpos),&red,NULL); if (magic==0x54AD && hsize>hpos+4+20+28) { SetFilePointer(hf,hpos,NULL,FILE_BEGIN); unsigned long signature; ReadFile(hf,&signature,sizeof(signature),&red,NULL); if (signature==IMAGE_DOS_SIGNATURE || signature==IMAGE_OS2_SIGNATURE || signature==IMAGE_OS2_SIGNATURE_LE || signature==IMAGE_NT_SIGNATURE) { a |= 0x00400000; // executable } } } // if (attr!=NULL) *attr = a; if (size!=NULL) *size = hsize; if (times!=NULL) { // lutime_t is 32bit number of seconds elapsed since 0:0:0GMT, Jan1, 1970. // but FILETIME is 64bit number of 100-nanosecs since Jan1, 1601 times->atime = filetime2timet(bhi.ftLastAccessTime); times->mtime = filetime2timet(bhi.ftLastWriteTime); times->ctime = filetime2timet(bhi.ftCreationTime); } if (timestamp!=NULL) { WORD dosdate,dostime; filetime2dosdatetime(bhi.ftLastWriteTime,&dosdate,&dostime); *timestamp = (WORD)dostime | (((DWORD)dosdate)<<16); } return ZR_OK; } class TZip { public: TZip(const char *pwd) : hfout(0),mustclosehfout(false),hmapout(0),zfis(0),obuf(0),hfin(0),writ(0),oerr(false),hasputcen(false),ooffset(0),encwriting(false),encbuf(0),password(0), state(0) {if (pwd!=0 && *pwd!=0) {password=new char[strlen(pwd)+1]; strcpy(password,pwd);}} ~TZip() {if (state!=0) delete state; state=0; if (encbuf!=0) delete[] encbuf; encbuf=0; if (password!=0) delete[] password; password=0;} // These variables say about the file we're writing into // We can write to pipe, file-by-handle, file-by-name, memory-to-memmapfile char *password; // keep a copy of the password HANDLE hfout; // if valid, we'll write here (for files or pipes) bool mustclosehfout; // if true, we are responsible for closing hfout HANDLE hmapout; // otherwise, we'll write here (for memmap) unsigned ooffset; // for hfout, this is where the pointer was initially ZRESULT oerr; // did a write operation give rise to an error? unsigned writ; // how far have we written. This is maintained by Add, not write(), to avoid confusion over seeks bool ocanseek; // can we seek? char *obuf; // this is where we've locked mmap to view. unsigned int opos; // current pos in the mmap unsigned int mapsize; // the size of the map we created bool hasputcen; // have we yet placed the central directory? bool encwriting; // if true, then we'll encrypt stuff using 'keys' before we write it to disk unsigned long keys[3]; // keys are initialised inside Add() char *encbuf; // if encrypting, then this is a temporary workspace for encrypting the data unsigned int encbufsize; // (to be used and resized inside write(), and deleted in the destructor) // TZipFileInfo *zfis; // each file gets added onto this list, for writing the table at the end TState *state; // we use just one state object per zip, because it's big (500k) ZRESULT Create(void *z,unsigned int len,DWORD flags); static unsigned sflush(void *param,const char *buf, unsigned *size); static unsigned swrite(void *param,const char *buf, unsigned size); unsigned int write(const char *buf,unsigned int size); bool oseek(unsigned int pos); ZRESULT GetMemory(void **pbuf, unsigned long *plen); ZRESULT Close(); // some variables to do with the file currently being read: // I haven't done it object-orientedly here, just put them all // together, since OO didn't seem to make the design any clearer. ulg attr; iztimes times; ulg timestamp; // all open_* methods set these bool iseekable; long isize,ired; // size is not set until close() on pips ulg crc; // crc is not set until close(). iwrit is cumulative HANDLE hfin; bool selfclosehf; // for input files and pipes const char *bufin; unsigned int lenin,posin; // for memory // and a variable for what we've done with the input: (i.e. compressed it!) ulg csize; // compressed size, set by the compression routines // and this is used by some of the compression routines char buf[16384]; ZRESULT open_file(const TCHAR *fn); ZRESULT open_handle(HANDLE hf,unsigned int len); ZRESULT open_mem(void *src,unsigned int len); ZRESULT open_dir(); static unsigned sread(TState &s,char *buf,unsigned size); unsigned read(char *buf, unsigned size); ZRESULT iclose(); ZRESULT ideflate(TZipFileInfo *zfi); ZRESULT istore(); ZRESULT Add(const TCHAR *odstzn, void *src,unsigned int len, DWORD flags); ZRESULT AddCentral(); }; ZRESULT TZip::Create(void *z,unsigned int len,DWORD flags) { if (hfout!=0 || hmapout!=0 || obuf!=0 || writ!=0 || oerr!=ZR_OK || hasputcen) return ZR_NOTINITED; // if (flags==ZIP_HANDLE) { HANDLE hf = (HANDLE)z; hfout=hf; mustclosehfout=false; #ifdef DuplicateHandle BOOL res = DuplicateHandle(GetCurrentProcess(),hf,GetCurrentProcess(),&hfout,0,FALSE,DUPLICATE_SAME_ACCESS); if (res) mustclosehandle=true; #endif // now we have hfout. Either we duplicated the handle and we close it ourselves // (while the caller closes h themselves), or we couldn't duplicate it. DWORD res = SetFilePointer(hfout,0,0,FILE_CURRENT); ocanseek = (res!=0xFFFFFFFF); if (ocanseek) ooffset=res; else ooffset=0; return ZR_OK; } else if (flags==ZIP_FILENAME) { const TCHAR *fn = (const TCHAR*)z; hfout = CreateFile(fn,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); if (hfout==INVALID_HANDLE_VALUE) {hfout=0; return ZR_NOFILE;} ocanseek=true; ooffset=0; mustclosehfout=true; return ZR_OK; } else if (flags==ZIP_MEMORY) { unsigned int size = len; if (size==0) return ZR_MEMSIZE; if (z!=0) obuf=(char*)z; else { hmapout = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,size,NULL); if (hmapout==NULL) return ZR_NOALLOC; obuf = (char*)MapViewOfFile(hmapout,FILE_MAP_ALL_ACCESS,0,0,size); if (obuf==0) {CloseHandle(hmapout); hmapout=0; return ZR_NOALLOC;} } ocanseek=true; opos=0; mapsize=size; return ZR_OK; } else return ZR_ARGS; } unsigned TZip::sflush(void *param,const char *buf, unsigned *size) { // static if (*size==0) return 0; TZip *zip = (TZip*)param; unsigned int writ = zip->write(buf,*size); if (writ!=0) *size=0; return writ; } unsigned TZip::swrite(void *param,const char *buf, unsigned size) { // static if (size==0) return 0; TZip *zip=(TZip*)param; return zip->write(buf,size); } unsigned int TZip::write(const char *buf,unsigned int size) { const char *srcbuf=buf; if (encwriting) { if (encbuf!=0 && encbufsize<size) {delete[] encbuf; encbuf=0;} if (encbuf==0) {encbuf=new char[size*2]; encbufsize=size;} memcpy(encbuf,buf,size); for (unsigned int i=0; i<size; i++) encbuf[i]=zencode(keys,encbuf[i]); srcbuf=encbuf; } if (obuf!=0) { if (opos+size>=mapsize) {oerr=ZR_MEMSIZE; return 0;} memcpy(obuf+opos, srcbuf, size); opos+=size; return size; } else if (hfout!=0) { DWORD writ; WriteFile(hfout,srcbuf,size,&writ,NULL); return writ; } oerr=ZR_NOTINITED; return 0; } bool TZip::oseek(unsigned int pos) { if (!ocanseek) {oerr=ZR_SEEK; return false;} if (obuf!=0) { if (pos>=mapsize) {oerr=ZR_MEMSIZE; return false;} opos=pos; return true; } else if (hfout!=0) { SetFilePointer(hfout,pos+ooffset,NULL,FILE_BEGIN); return true; } oerr=ZR_NOTINITED; return 0; } ZRESULT TZip::GetMemory(void **pbuf, unsigned long *plen) { // When the user calls GetMemory, they're presumably at the end // of all their adding. In any case, we have to add the central // directory now, otherwise the memory we tell them won't be complete. if (!hasputcen) AddCentral(); hasputcen=true; if (pbuf!=NULL) *pbuf=(void*)obuf; if (plen!=NULL) *plen=writ; if (obuf==NULL) return ZR_NOTMMAP; return ZR_OK; } ZRESULT TZip::Close() { // if the directory hadn't already been added through a call to GetMemory, // then we do it now ZRESULT res=ZR_OK; if (!hasputcen) res=AddCentral(); hasputcen=true; if (obuf!=0 && hmapout!=0) UnmapViewOfFile(obuf); obuf=0; if (hmapout!=0) CloseHandle(hmapout); hmapout=0; if (hfout!=0 && mustclosehfout) CloseHandle(hfout); hfout=0; mustclosehfout=false; return res; } ZRESULT TZip::open_file(const TCHAR *fn) { hfin=0; bufin=0; selfclosehf=false; crc=CRCVAL_INITIAL; isize=0; csize=0; ired=0; if (fn==0) return ZR_ARGS; HANDLE hf = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL); if (hf==INVALID_HANDLE_VALUE) return ZR_NOFILE; ZRESULT res = open_handle(hf,0); if (res!=ZR_OK) {CloseHandle(hf); return res;} selfclosehf=true; return ZR_OK; } ZRESULT TZip::open_handle(HANDLE hf,unsigned int len) { hfin=0; bufin=0; selfclosehf=false; crc=CRCVAL_INITIAL; isize=0; csize=0; ired=0; if (hf==0 || hf==INVALID_HANDLE_VALUE) return ZR_ARGS; DWORD res = SetFilePointer(hfout,0,0,FILE_CURRENT); if (res!=0xFFFFFFFF) { ZRESULT res = GetFileInfo(hf,&attr,&isize,&times,&timestamp); if (res!=ZR_OK) return res; SetFilePointer(hf,0,NULL,FILE_BEGIN); // because GetFileInfo will have screwed it up iseekable=true; hfin=hf; return ZR_OK; } else { attr= 0x80000000; // just a normal file isize = -1; // can't know size until at the end if (len!=0) isize=len; // unless we were told explicitly! iseekable=false; SYSTEMTIME st; GetLocalTime(&st); FILETIME ft; SystemTimeToFileTime(&st,&ft); WORD dosdate,dostime; filetime2dosdatetime(ft,&dosdate,&dostime); times.atime = filetime2timet(ft); times.mtime = times.atime; times.ctime = times.atime; timestamp = (WORD)dostime | (((DWORD)dosdate)<<16); hfin=hf; return ZR_OK; } } ZRESULT TZip::open_mem(void *src,unsigned int len) { hfin=0; bufin=(const char*)src; selfclosehf=false; crc=CRCVAL_INITIAL; ired=0; csize=0; ired=0; lenin=len; posin=0; if (src==0 || len==0) return ZR_ARGS; attr= 0x80000000; // just a normal file isize = len; iseekable=true; SYSTEMTIME st; GetLocalTime(&st); FILETIME ft; SystemTimeToFileTime(&st,&ft); WORD dosdate,dostime; filetime2dosdatetime(ft,&dosdate,&dostime); times.atime = filetime2timet(ft); times.mtime = times.atime; times.ctime = times.atime; timestamp = (WORD)dostime | (((DWORD)dosdate)<<16); return ZR_OK; } ZRESULT TZip::open_dir() { hfin=0; bufin=0; selfclosehf=false; crc=CRCVAL_INITIAL; isize=0; csize=0; ired=0; attr= 0x41C00010; // a readable writable directory, and again directory isize = 0; iseekable=false; SYSTEMTIME st; GetLocalTime(&st); FILETIME ft; SystemTimeToFileTime(&st,&ft); WORD dosdate,dostime; filetime2dosdatetime(ft,&dosdate,&dostime); times.atime = filetime2timet(ft); times.mtime = times.atime; times.ctime = times.atime; timestamp = (WORD)dostime | (((DWORD)dosdate)<<16); return ZR_OK; } unsigned TZip::sread(TState &s,char *buf,unsigned size) { // static TZip *zip = (TZip*)s.param; return zip->read(buf,size); } unsigned TZip::read(char *buf, unsigned size) { if (bufin!=0) { if (posin>=lenin) return 0; // end of input ulg red = lenin-posin; if (red>size) red=size; memcpy(buf, bufin+posin, red); posin += red; ired += red; crc = crc32(crc, (uch*)buf, red); return red; } else if (hfin!=0) { DWORD red; BOOL ok = ReadFile(hfin,buf,size,&red,NULL); if (!ok) return 0; ired += red; crc = crc32(crc, (uch*)buf, red); return red; } else {oerr=ZR_NOTINITED; return 0;} } ZRESULT TZip::iclose() { if (selfclosehf && hfin!=0) CloseHandle(hfin); hfin=0; bool mismatch = (isize!=-1 && isize!=ired); isize=ired; // and crc has been being updated anyway if (mismatch) return ZR_MISSIZE; else return ZR_OK; } ZRESULT TZip::ideflate(TZipFileInfo *zfi) { if (state==0) state=new TState(); // It's a very big object! 500k! We allocate it on the heap, because PocketPC's // stack breaks if we try to put it all on the stack. It will be deleted lazily state->err=0; state->readfunc=sread; state->flush_outbuf=sflush; state->param=this; state->level=8; state->seekable=iseekable; state->err=NULL; // the following line will make ct_init realise it has to perform the init state->ts.static_dtree[0].dl.len = 0; // Thanks to Alvin77 for this crucial fix: state->ds.window_size=0; // I think that covers everything that needs to be initted. // bi_init(*state,buf, sizeof(buf), TRUE); // it used to be just 1024-size, not 16384 as here ct_init(*state,&zfi->att); lm_init(*state,state->level, &zfi->flg); ulg sz = deflate(*state); csize=sz; ZRESULT r=ZR_OK; if (state->err!=NULL) r=ZR_FLATE; return r; } ZRESULT TZip::istore() { ulg size=0; for (;;) { unsigned int cin=read(buf,16384); if (cin<=0 || cin==(unsigned int)EOF) break; unsigned int cout = write(buf,cin); if (cout!=cin) return ZR_MISSIZE; size += cin; } csize=size; return ZR_OK; } bool has_seeded=false; ZRESULT TZip::Add(const TCHAR *odstzn, void *src,unsigned int len, DWORD flags) { if (oerr) return ZR_FAILED; if (hasputcen) return ZR_ENDED; // if we use password encryption, then every isize and csize is 12 bytes bigger int passex=0; if (password!=0 && flags!=ZIP_FOLDER) passex=12; // zip has its own notion of what its names should look like: i.e. dir/file.stuff TCHAR dstzn[MAX_PATH]; _tcscpy(dstzn,odstzn); if (*dstzn==0) return ZR_ARGS; TCHAR *d=dstzn; while (*d!=0) {if (*d=='\\') *d='/'; d++;} bool isdir = (flags==ZIP_FOLDER); bool needs_trailing_slash = (isdir && dstzn[_tcslen(dstzn)-1]!='/'); int method=DEFLATE; if (isdir || HasZipSuffix(dstzn)) method=STORE; // now open whatever was our input source: ZRESULT openres; if (flags==ZIP_FILENAME) openres=open_file((const TCHAR*)src); else if (flags==ZIP_HANDLE) openres=open_handle((HANDLE)src,len); else if (flags==ZIP_MEMORY) openres=open_mem(src,len); else if (flags==ZIP_FOLDER) openres=open_dir(); else return ZR_ARGS; if (openres!=ZR_OK) return openres; // A zip "entry" consists of a local header (which includes the file name), // then the compressed data, and possibly an extended local header. // Initialize the local header TZipFileInfo zfi; zfi.nxt=NULL; strcpy(zfi.name,""); #ifdef UNICODE WideCharToMultiByte(CP_UTF8,0,dstzn,-1,zfi.iname,MAX_PATH,0,0); #else strcpy(zfi.iname,dstzn); #endif zfi.nam=strlen(zfi.iname); if (needs_trailing_slash) {strcat(zfi.iname,"/"); zfi.nam++;} strcpy(zfi.zname,""); zfi.extra=NULL; zfi.ext=0; // extra header to go after this compressed data, and its length zfi.cextra=NULL; zfi.cext=0; // extra header to go in the central end-of-zip directory, and its length zfi.comment=NULL; zfi.com=0; // comment, and its length zfi.mark = 1; zfi.dosflag = 0; zfi.att = (ush)BINARY; zfi.vem = (ush)0xB17; // 0xB00 is win32 os-code. 0x17 is 23 in decimal: zip 2.3 zfi.ver = (ush)20; // Needs PKUNZIP 2.0 to unzip it zfi.tim = timestamp; // Even though we write the header now, it will have to be rewritten, since we don't know compressed size or crc. zfi.crc = 0; // to be updated later zfi.flg = 8; // 8 means 'there is an extra header'. Assume for the moment that we need it. if (password!=0 && !isdir) zfi.flg=9; // and 1 means 'password-encrypted' zfi.lflg = zfi.flg; // to be updated later zfi.how = (ush)method; // to be updated later zfi.siz = (ulg)(method==STORE && isize>=0 ? isize+passex : 0); // to be updated later zfi.len = (ulg)(isize); // to be updated later zfi.dsk = 0; zfi.atx = attr; zfi.off = writ+ooffset; // offset within file of the start of this local record // stuff the 'times' structure into zfi.extra // nb. apparently there's a problem with PocketPC CE(zip)->CE(unzip) fails. And removing the following block fixes it up. char xloc[EB_L_UT_SIZE]; zfi.extra=xloc; zfi.ext=EB_L_UT_SIZE; char xcen[EB_C_UT_SIZE]; zfi.cextra=xcen; zfi.cext=EB_C_UT_SIZE; xloc[0] = 'U'; xloc[1] = 'T'; xloc[2] = EB_UT_LEN(3); // length of data part of e.f. xloc[3] = 0; xloc[4] = EB_UT_FL_MTIME | EB_UT_FL_ATIME | EB_UT_FL_CTIME; xloc[5] = (char)(times.mtime); xloc[6] = (char)(times.mtime >> 8); xloc[7] = (char)(times.mtime >> 16); xloc[8] = (char)(times.mtime >> 24); xloc[9] = (char)(times.atime); xloc[10] = (char)(times.atime >> 8); xloc[11] = (char)(times.atime >> 16); xloc[12] = (char)(times.atime >> 24); xloc[13] = (char)(times.ctime); xloc[14] = (char)(times.ctime >> 8); xloc[15] = (char)(times.ctime >> 16); xloc[16] = (char)(times.ctime >> 24); memcpy(zfi.cextra,zfi.extra,EB_C_UT_SIZE); zfi.cextra[EB_LEN] = EB_UT_LEN(1); // (1) Start by writing the local header: int r = putlocal(&zfi,swrite,this); if (r!=ZE_OK) {iclose(); return ZR_WRITE;} writ += 4 + LOCHEAD + (unsigned int)zfi.nam + (unsigned int)zfi.ext; if (oerr!=ZR_OK) {iclose(); return oerr;} // (1.5) if necessary, write the encryption header keys[0]=305419896L; keys[1]=591751049L; keys[2]=878082192L; for (const char *cp=password; cp!=0 && *cp!=0; cp++) update_keys(keys,*cp); // generate some random bytes if (!has_seeded) srand(GetTickCount()^(unsigned long)GetDesktopWindow()); char encbuf[12]; for (int i=0; i<12; i++) encbuf[i]=(char)((rand()>>7)&0xff); encbuf[11] = (char)((zfi.tim>>8)&0xff); for (int ei=0; ei<12; ei++) encbuf[ei]=zencode(keys,encbuf[ei]); if (password!=0 && !isdir) {swrite(this,encbuf,12); writ+=12;} //(2) Write deflated/stored file to zip file ZRESULT writeres=ZR_OK; encwriting = (password!=0 && !isdir); // an object member variable to say whether we write to disk encrypted if (!isdir && method==DEFLATE) writeres=ideflate(&zfi); else if (!isdir && method==STORE) writeres=istore(); else if (isdir) csize=0; encwriting = false; iclose(); writ += csize; if (oerr!=ZR_OK) return oerr; if (writeres!=ZR_OK) return ZR_WRITE; // (3) Either rewrite the local header with correct information... bool first_header_has_size_right = (zfi.siz==csize+passex); zfi.crc = crc; zfi.siz = csize+passex; zfi.len = isize; if (ocanseek && (password==0 || isdir)) { zfi.how = (ush)method; if ((zfi.flg & 1) == 0) zfi.flg &= ~8; // clear the extended local header flag zfi.lflg = zfi.flg; // rewrite the local header: if (!oseek(zfi.off-ooffset)) return ZR_SEEK; if ((r = putlocal(&zfi, swrite,this)) != ZE_OK) return ZR_WRITE; if (!oseek(writ)) return ZR_SEEK; } else { // (4) ... or put an updated header at the end if (zfi.how != (ush) method) return ZR_NOCHANGE; if (method==STORE && !first_header_has_size_right) return ZR_NOCHANGE; if ((r = putextended(&zfi, swrite,this)) != ZE_OK) return ZR_WRITE; writ += 16L; zfi.flg = zfi.lflg; // if flg modified by inflate, for the central index } if (oerr!=ZR_OK) return oerr; // Keep a copy of the zipfileinfo, for our end-of-zip directory char *cextra = new char[zfi.cext]; memcpy(cextra,zfi.cextra,zfi.cext); zfi.cextra=cextra; TZipFileInfo *pzfi = new TZipFileInfo; memcpy(pzfi,&zfi,sizeof(zfi)); if (zfis==NULL) zfis=pzfi; else {TZipFileInfo *z=zfis; while (z->nxt!=NULL) z=z->nxt; z->nxt=pzfi;} return ZR_OK; } ZRESULT TZip::AddCentral() { // write central directory int numentries = 0; ulg pos_at_start_of_central = writ; //ulg tot_unc_size=0, tot_compressed_size=0; bool okay=true; for (TZipFileInfo *zfi=zfis; zfi!=NULL; ) { if (okay) { int res = putcentral(zfi, swrite,this); if (res!=ZE_OK) okay=false; } writ += 4 + CENHEAD + (unsigned int)zfi->nam + (unsigned int)zfi->cext + (unsigned int)zfi->com; //tot_unc_size += zfi->len; //tot_compressed_size += zfi->siz; numentries++; // TZipFileInfo *zfinext = zfi->nxt; if (zfi->cextra!=0) delete[] zfi->cextra; delete zfi; zfi = zfinext; } ulg center_size = writ - pos_at_start_of_central; if (okay) { int res = putend(numentries, center_size, pos_at_start_of_central+ooffset, 0, NULL, swrite,this); if (res!=ZE_OK) okay=false; writ += 4 + ENDHEAD + 0; } if (!okay) return ZR_WRITE; return ZR_OK; } ZRESULT lasterrorZ=ZR_OK; unsigned int FormatZipMessageZ(ZRESULT code, char *buf,unsigned int len) { if (code==ZR_RECENT) code=lasterrorZ; const char *msg="unknown zip result code"; switch (code) { case ZR_OK: msg="Success"; break; case ZR_NODUPH: msg="Culdn't duplicate handle"; break; case ZR_NOFILE: msg="Couldn't create/open file"; break; case ZR_NOALLOC: msg="Failed to allocate memory"; break; case ZR_WRITE: msg="Error writing to file"; break; case ZR_NOTFOUND: msg="File not found in the zipfile"; break; case ZR_MORE: msg="Still more data to unzip"; break; case ZR_CORRUPT: msg="Zipfile is corrupt or not a zipfile"; break; case ZR_READ: msg="Error reading file"; break; case ZR_ARGS: msg="Caller: faulty arguments"; break; case ZR_PARTIALUNZ: msg="Caller: the file had already been partially unzipped"; break; case ZR_NOTMMAP: msg="Caller: can only get memory of a memory zipfile"; break; case ZR_MEMSIZE: msg="Caller: not enough space allocated for memory zipfile"; break; case ZR_FAILED: msg="Caller: there was a previous error"; break; case ZR_ENDED: msg="Caller: additions to the zip have already been ended"; break; case ZR_ZMODE: msg="Caller: mixing creation and opening of zip"; break; case ZR_NOTINITED: msg="Zip-bug: internal initialisation not completed"; break; case ZR_SEEK: msg="Zip-bug: trying to seek the unseekable"; break; case ZR_MISSIZE: msg="Zip-bug: the anticipated size turned out wrong"; break; case ZR_NOCHANGE: msg="Zip-bug: tried to change mind, but not allowed"; break; case ZR_FLATE: msg="Zip-bug: an internal error during flation"; break; } unsigned int mlen=(unsigned int)strlen(msg); if (buf==0 || len==0) return mlen; unsigned int n=mlen; if (n+1>len) n=len-1; strncpy(buf,msg,n); buf[n]=0; return mlen; } typedef struct { DWORD flag; TZip *zip; } TZipHandleData; HZIP CreateZipInternal(void *z,unsigned int len,DWORD flags, const char *password) { TZip *zip = new TZip(password); lasterrorZ = zip->Create(z,len,flags); if (lasterrorZ!=ZR_OK) {delete zip; return 0;} TZipHandleData *han = new TZipHandleData; han->flag=2; han->zip=zip; return (HZIP)han; } HZIP CreateZipHandle(HANDLE h, const char *password) {return CreateZipInternal(h,0,ZIP_HANDLE,password);} HZIP CreateZip(const TCHAR *fn, const char *password) {return CreateZipInternal((void*)fn,0,ZIP_FILENAME,password);} HZIP CreateZip(void *z,unsigned int len, const char *password) {return CreateZipInternal(z,len,ZIP_MEMORY,password);} ZRESULT ZipAddInternal(HZIP hz,const TCHAR *dstzn, void *src,unsigned int len, DWORD flags) { if (hz==0) {lasterrorZ=ZR_ARGS;return ZR_ARGS;} TZipHandleData *han = (TZipHandleData*)hz; if (han->flag!=2) {lasterrorZ=ZR_ZMODE;return ZR_ZMODE;} TZip *zip = han->zip; lasterrorZ = zip->Add(dstzn,src,len,flags); return lasterrorZ; } ZRESULT ZipAdd(HZIP hz,const TCHAR *dstzn, const TCHAR *fn) {return ZipAddInternal(hz,dstzn,(void*)fn,0,ZIP_FILENAME);} ZRESULT ZipAdd(HZIP hz,const TCHAR *dstzn, void *src,unsigned int len) {return ZipAddInternal(hz,dstzn,src,len,ZIP_MEMORY);} ZRESULT ZipAddHandle(HZIP hz,const TCHAR *dstzn, HANDLE h) {return ZipAddInternal(hz,dstzn,h,0,ZIP_HANDLE);} ZRESULT ZipAddHandle(HZIP hz,const TCHAR *dstzn, HANDLE h, unsigned int len) {return ZipAddInternal(hz,dstzn,h,len,ZIP_HANDLE);} ZRESULT ZipAddFolder(HZIP hz,const TCHAR *dstzn) {return ZipAddInternal(hz,dstzn,0,0,ZIP_FOLDER);} ZRESULT ZipGetMemory(HZIP hz, void **buf, unsigned long *len) { if (hz==0) {if (buf!=0) *buf=0; if (len!=0) *len=0; lasterrorZ=ZR_ARGS;return ZR_ARGS;} TZipHandleData *han = (TZipHandleData*)hz; if (han->flag!=2) {lasterrorZ=ZR_ZMODE;return ZR_ZMODE;} TZip *zip = han->zip; lasterrorZ = zip->GetMemory(buf,len); return lasterrorZ; } ZRESULT CloseZipZ(HZIP hz) { if (hz==0) {lasterrorZ=ZR_ARGS;return ZR_ARGS;} TZipHandleData *han = (TZipHandleData*)hz; if (han->flag!=2) {lasterrorZ=ZR_ZMODE;return ZR_ZMODE;} TZip *zip = han->zip; lasterrorZ = zip->Close(); delete zip; delete han; return lasterrorZ; } bool IsZipHandleZ(HZIP hz) { if (hz==0) return false; TZipHandleData *han = (TZipHandleData*)hz; return (han->flag==2); }
1f319770ce89cd6e26c16890f54679399916ff81
515289d2bf3171001efa6d9676207c2dbf7edd3f
/Game/Stage8.cpp
45f2b5e16d9e9ef564d34af5f9b5b579cc4380ac
[ "MIT" ]
permissive
Gutt4N/Synchro
a3231a9c9e46023231b3c283cdb0e6d5fe59473e
e4c882078d361dc656139c926a96d7806fbd4b74
refs/heads/master
2021-01-13T01:07:42.478114
2017-02-09T04:34:34
2017-02-09T04:34:34
81,408,289
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
2,666
cpp
//__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/ //! @file Stage8.cpp //! //! @brief Map関連のソースファイル //! //! @date 日付 //! //! @author GF3_01_安藤 祥大 //__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/__/ // ヘッダファイルの読み込み ================================================ #include "AllStage.h" #include "define.h" #include "Player.h" #include "Player2.h" #include "Object.h" void Stage8(); // グローバル ================================================ //*†*:;;;:*†*:;;;:*†*:;;;:*†*:;;;:*†*:;;;:*†*// // 関数名:MapFirstInit // // 概要 :マップデータ読み込み // // 引数 :省略 // // 戻り値:省略 // //*†*:;;;:*†*:;;;:*†*:;;;:*†*:;;;:*†*:;;;:*†*// void Stage8Init(void) { FILE *fp = NULL; char buf[512]; char *tok; char *next_token = NULL; int i, j; switch (MapFlagNumber) { case 8: //マップファイいるをオープンする switch (MapChange) { case 0: fopen_s(&fp, "Map\\MapEighth\\Map.csv", "r"); break; case 1: fopen_s(&fp, "Map\\MapEighth\\Map2.csv", "r"); break; } break; } //マップの読み込み for (i = 0; i < MAP_H; i++) { fgets(buf, sizeof(buf), fp); for (j = 0; j < MAP_W; j++) { if (j == 0) { tok = strtok_s(buf, ",", &next_token); } else { tok = strtok_s(NULL, ",", &next_token); } StageMap[i][j] = atoi(tok); } } fclose(fp); } ///////////////////////////////////////Stage8の初期化 void Stage8() { if (Scene == Game && MapFlagNumber == 8) { S_init = 0; //時間の初期化 Time = 0; STime = 0; DTime = 0; TTime = 0; FTime = 0; //表示の初期化 DrawSTime = 0; DrawDTime = 0; DrawTTime = 0; DrawFTime = 0; Player.Down = 0; //カウンター系の初期化 MapChange = 0; count = 0; muinit = 0; g_mCnt = 0; //プレイヤーの初期化 FirstMapPlayer(); FirstMapPlayer2(); //ゴール、パーツの初期化 InitGoalPartsFirst1(); InitGoalPartsSecond1(); InitGoalPartsThird1(); InitGoalPartsFourth1(); InitGoal1(); InitZanzo1(); //デバッグ GameScene = STAGE8; } } //*†*:;;;:*†*:;;;:*†*:;;;:*†*:;;;:*†*:;;;:*†*// // 関数名:MapLoad1 // // 概要 :マップデータ読み込み // // 引数 :省略 // // 戻り値:省略 // //*†*:;;;:*†*:;;;:*†*:;;;:*†*:;;;:*†*:;;;:*†*// void Stage8Load() { //map読み込み Stage8Init(); //マップ表示 DrawStageMap(); }
8d372dcf75a92c930d581fc96e6cfc70265a206b
97398fef26adee8f02d173d1355abed2f8ff5ffa
/ue.spat/externals/ue.binaural.decoder~.mxo/ue.binaural.decoder.cpp
2c04161cca7b8958e3173cecfbfe20eda182c3dc
[]
no_license
etiennedemoulin/spat4unreal
ccb2feb8f7f7accb7c89cc8e59af4e4541db15b0
5a40feca322884eb52d9d51c7a25216f73ef7a9c
refs/heads/master
2022-12-09T15:39:02.380492
2020-08-29T23:23:16
2020-08-29T23:23:16
290,445,185
0
0
null
null
null
null
UTF-8
C++
false
false
598,428
cpp
/* ------------------------------------------------------------ author: "Pierre Lecomte" copyright: "(c) Pierre Lecomte 2015" license: "GPL)" name: "Binaural decoder" version: "1.0" Code generated with Faust 2.26.2 (https://faust.grame.fr) Compilation options: -lang cpp -double -ftz 0 ------------------------------------------------------------ */ #ifndef __ue_binaural_decoder_H__ #define __ue_binaural_decoder_H__ /************************************************************************ IMPORTANT NOTE : this file contains two clearly delimited sections : the ARCHITECTURE section (in two parts) and the USER section. Each section is governed by its own copyright and license. Please check individually each section for license and copyright information. *************************************************************************/ /*******************BEGIN ARCHITECTURE SECTION (part 1/2)****************/ /************************************************************************ FAUST Architecture File Copyright (C) 2004-2020 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. MAX MSP SDK : in order to compile a MaxMSP external with this architecture file you will need the official MaxMSP SDK from cycling'74. Please check the corresponding license. ************************************************************************ ************************************************************************/ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <limits.h> #include <errno.h> #include <time.h> #include <unistd.h> #include <fcntl.h> #include <assert.h> #include <string> #include <vector> #include <map> #include <iostream> #include <fstream> #include <sstream> #ifdef __APPLE__ #include <Carbon/Carbon.h> #include <unistd.h> #endif #ifdef WIN32 #ifndef NAN static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff}; #define NAN (*(const float *) __nan) #endif #endif // FAUSTFLOAT is setup by faust2max6 /************************** BEGIN UI.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2020 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __UI_H__ #define __UI_H__ #ifndef FAUSTFLOAT #define FAUSTFLOAT float #endif /******************************************************************************* * UI : Faust DSP User Interface * User Interface as expected by the buildUserInterface() method of a DSP. * This abstract class contains only the method that the Faust compiler can * generate to describe a DSP user interface. ******************************************************************************/ struct Soundfile; template <typename REAL> struct UIReal { UIReal() {} virtual ~UIReal() {} // -- widget's layouts virtual void openTabBox(const char* label) = 0; virtual void openHorizontalBox(const char* label) = 0; virtual void openVerticalBox(const char* label) = 0; virtual void closeBox() = 0; // -- active widgets virtual void addButton(const char* label, REAL* zone) = 0; virtual void addCheckButton(const char* label, REAL* zone) = 0; virtual void addVerticalSlider(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) = 0; virtual void addHorizontalSlider(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) = 0; virtual void addNumEntry(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) = 0; // -- passive widgets virtual void addHorizontalBargraph(const char* label, REAL* zone, REAL min, REAL max) = 0; virtual void addVerticalBargraph(const char* label, REAL* zone, REAL min, REAL max) = 0; // -- soundfiles virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) = 0; // -- metadata declarations virtual void declare(REAL* zone, const char* key, const char* val) {} }; struct UI : public UIReal<FAUSTFLOAT> { UI() {} virtual ~UI() {} }; #endif /************************** END UI.h **************************/ /************************** BEGIN SimpleParser.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef SIMPLEPARSER_H #define SIMPLEPARSER_H // --------------------------------------------------------------------- // Simple Parser // A parser returns true if it was able to parse what it is // supposed to parse and advance the pointer. Otherwise it returns false // and the pointer is not advanced so that another parser can be tried. // --------------------------------------------------------------------- #include <vector> #include <map> #include <string> #include <fstream> #include <sstream> #include <iostream> #include <ctype.h> #ifndef _WIN32 # pragma GCC diagnostic ignored "-Wunused-function" #endif struct itemInfo { std::string type; std::string label; std::string url; std::string address; int index; double init; double min; double max; double step; std::vector<std::pair<std::string, std::string> > meta; itemInfo():index(0), init(0.), min(0.), max(0.), step(0.) {} }; // --------------------------------------------------------------------- // Elementary parsers // --------------------------------------------------------------------- // Report a parsing error static bool parseError(const char*& p, const char* errmsg) { std::cerr << "Parse error : " << errmsg << " here : " << p << std::endl; return true; } /** * @brief skipBlank : advance pointer p to the first non blank character * @param p the string to parse, then the remaining string */ static void skipBlank(const char*& p) { while (isspace(*p)) { p++; } } // Parse character x, but don't report error if fails static bool tryChar(const char*& p, char x) { skipBlank(p); if (x == *p) { p++; return true; } else { return false; } } /** * @brief parseChar : parse a specific character x * @param p the string to parse, then the remaining string * @param x the character to recognize * @return true if x was found at the begin of p */ static bool parseChar(const char*& p, char x) { skipBlank(p); if (x == *p) { p++; return true; } else { return false; } } /** * @brief parseWord : parse a specific string w * @param p the string to parse, then the remaining string * @param w the string to recognize * @return true if string w was found at the begin of p */ static bool parseWord(const char*& p, const char* w) { skipBlank(p); const char* saved = p; // to restore position if we fail while ((*w == *p) && (*w)) {++w; ++p;} if (*w) { p = saved; return false; } else { return true; } } /** * @brief parseDouble : parse number [s]dddd[.dddd] and store the result in x * @param p the string to parse, then the remaining string * @param x the float number found if any * @return true if a float number was found at the begin of p */ static bool parseDouble(const char*& p, double& x) { std::stringstream reader(p); std::streambuf* pbuf = reader.rdbuf(); // Keep position before parsing std::streamsize size1 = pbuf->in_avail(); // Parse the number reader >> x; // Keep position after parsing std::streamsize size2 = pbuf->in_avail(); // Move from the actual size p += (size1 - size2); // True if the number contains at least one digit return (size1 > size2); } /** * @brief parseString, parse an arbitrary quoted string q...q and store the result in s * @param p the string to parse, then the remaining string * @param quote the character used to quote the string * @param s the (unquoted) string found if any * @return true if a string was found at the begin of p */ static bool parseString(const char*& p, char quote, std::string& s) { std::string str; skipBlank(p); const char* saved = p; // to restore position if we fail if (*p++ == quote) { while ((*p != 0) && (*p != quote)) { str += *p++; } if (*p++ == quote) { s = str; return true; } } p = saved; return false; } /** * @brief parseSQString, parse a single quoted string '...' and store the result in s * @param p the string to parse, then the remaining string * @param s the (unquoted) string found if any * @return true if a string was found at the begin of p */ static bool parseSQString(const char*& p, std::string& s) { return parseString(p, '\'', s); } /** * @brief parseDQString, parse a double quoted string "..." and store the result in s * @param p the string to parse, then the remaining string * @param s the (unquoted) string found if any * @return true if a string was found at the begin of p */ static bool parseDQString(const char*& p, std::string& s) { return parseString(p, '"', s); } // --------------------------------------------------------------------- // // IMPLEMENTATION // // --------------------------------------------------------------------- /** * @brief parseMenuItem, parse a menu item ...'low':440.0... * @param p the string to parse, then the remaining string * @param name the name found * @param value the value found * @return true if a nemu item was found */ static bool parseMenuItem(const char*& p, std::string& name, double& value) { const char* saved = p; // to restore position if we fail if (parseSQString(p, name) && parseChar(p, ':') && parseDouble(p, value)) { return true; } else { p = saved; return false; } } static bool parseMenuItem2(const char*& p, std::string& name) { const char* saved = p; // to restore position if we fail // single quoted if (parseSQString(p, name)) { return true; } else { p = saved; return false; } } /** * @brief parseMenuList, parse a menu list {'low' : 440.0; 'mid' : 880.0; 'hi' : 1760.0}... * @param p the string to parse, then the remaining string * @param names the vector of names found * @param values the vector of values found * @return true if a menu list was found */ static bool parseMenuList(const char*& p, std::vector<std::string>& names, std::vector<double>& values) { std::vector<std::string> tmpnames; std::vector<double> tmpvalues; const char* saved = p; // to restore position if we fail if (parseChar(p, '{')) { do { std::string n; double v; if (parseMenuItem(p, n, v)) { tmpnames.push_back(n); tmpvalues.push_back(v); } else { p = saved; return false; } } while (parseChar(p, ';')); if (parseChar(p, '}')) { // we suceeded names = tmpnames; values = tmpvalues; return true; } } p = saved; return false; } static bool parseMenuList2(const char*& p, std::vector<std::string>& names, bool debug) { std::vector<std::string> tmpnames; const char* saved = p; // to restore position if we fail if (parseChar(p, '{')) { do { std::string n; if (parseMenuItem2(p, n)) { tmpnames.push_back(n); } else { goto error; } } while (parseChar(p, ';')); if (parseChar(p, '}')) { // we suceeded names = tmpnames; return true; } } error: if (debug) { std::cerr << "parseMenuList2 : (" << saved << ") is not a valid list !\n"; } p = saved; return false; } /// --------------------------------------------------------------------- // Parse list of strings /// --------------------------------------------------------------------- static bool parseList(const char*& p, std::vector<std::string>& items) { const char* saved = p; // to restore position if we fail if (parseChar(p, '[')) { do { std::string item; if (!parseDQString(p, item)) { p = saved; return false; } items.push_back(item); } while (tryChar(p, ',')); return parseChar(p, ']'); } else { p = saved; return false; } } static bool parseMetaData(const char*& p, std::map<std::string, std::string>& metadatas) { const char* saved = p; // to restore position if we fail std::string metaKey, metaValue; if (parseChar(p, ':') && parseChar(p, '[')) { do { if (parseChar(p, '{') && parseDQString(p, metaKey) && parseChar(p, ':') && parseDQString(p, metaValue) && parseChar(p, '}')) { metadatas[metaKey] = metaValue; } } while (tryChar(p, ',')); return parseChar(p, ']'); } else { p = saved; return false; } } static bool parseItemMetaData(const char*& p, std::vector<std::pair<std::string, std::string> >& metadatas) { const char* saved = p; // to restore position if we fail std::string metaKey, metaValue; if (parseChar(p, ':') && parseChar(p, '[')) { do { if (parseChar(p, '{') && parseDQString(p, metaKey) && parseChar(p, ':') && parseDQString(p, metaValue) && parseChar(p, '}')) { metadatas.push_back(std::make_pair(metaKey, metaValue)); } } while (tryChar(p, ',')); return parseChar(p, ']'); } else { p = saved; return false; } } // --------------------------------------------------------------------- // Parse metadatas of the interface: // "name" : "...", "inputs" : "...", "outputs" : "...", ... // and store the result as key/value /// --------------------------------------------------------------------- static bool parseGlobalMetaData(const char*& p, std::string& key, std::string& value, double& dbl, std::map<std::string, std::string>& metadatas, std::vector<std::string>& items) { const char* saved = p; // to restore position if we fail if (parseDQString(p, key)) { if (key == "meta") { return parseMetaData(p, metadatas); } else { return parseChar(p, ':') && (parseDQString(p, value) || parseList(p, items) || parseDouble(p, dbl)); } } else { p = saved; return false; } } // --------------------------------------------------------------------- // Parse gui: // "type" : "...", "label" : "...", "address" : "...", ... // and store the result in uiItems Vector /// --------------------------------------------------------------------- static bool parseUI(const char*& p, std::vector<itemInfo>& uiItems, int& numItems) { const char* saved = p; // to restore position if we fail if (parseChar(p, '{')) { std::string label; std::string value; double dbl = 0; do { if (parseDQString(p, label)) { if (label == "type") { if (uiItems.size() != 0) { numItems++; } if (parseChar(p, ':') && parseDQString(p, value)) { itemInfo item; item.type = value; uiItems.push_back(item); } } else if (label == "label") { if (parseChar(p, ':') && parseDQString(p, value)) { uiItems[numItems].label = value; } } else if (label == "url") { if (parseChar(p, ':') && parseDQString(p, value)) { uiItems[numItems].url = value; } } else if (label == "address") { if (parseChar(p, ':') && parseDQString(p, value)) { uiItems[numItems].address = value; } } else if (label == "index") { if (parseChar(p, ':') && parseDouble(p, dbl)) { uiItems[numItems].index = int(dbl); } } else if (label == "meta") { if (!parseItemMetaData(p, uiItems[numItems].meta)) { return false; } } else if (label == "init") { if (parseChar(p, ':') && parseDouble(p, dbl)) { uiItems[numItems].init = dbl; } } else if (label == "min") { if (parseChar(p, ':') && parseDouble(p, dbl)) { uiItems[numItems].min = dbl; } } else if (label == "max") { if (parseChar(p, ':') && parseDouble(p, dbl)) { uiItems[numItems].max = dbl; } } else if (label == "step") { if (parseChar(p, ':') && parseDouble(p, dbl)) { uiItems[numItems].step = dbl; } } else if (label == "items") { if (parseChar(p, ':') && parseChar(p, '[')) { do { if (!parseUI(p, uiItems, numItems)) { p = saved; return false; } } while (tryChar(p, ',')); if (parseChar(p, ']')) { itemInfo item; item.type = "close"; uiItems.push_back(item); numItems++; } } } } else { p = saved; return false; } } while (tryChar(p, ',')); return parseChar(p, '}'); } else { return true; // "items": [] is valid } } // --------------------------------------------------------------------- // Parse full JSON record describing a JSON/Faust interface : // {"metadatas": "...", "ui": [{ "type": "...", "label": "...", "items": [...], "address": "...","init": "...", "min": "...", "max": "...","step": "..."}]} // // and store the result in map Metadatas and vector containing the items of the interface. Returns true if parsing was successfull. /// --------------------------------------------------------------------- static bool parseJson(const char*& p, std::map<std::string, std::pair<std::string, double> >& metaDatas0, std::map<std::string, std::string>& metaDatas1, std::map<std::string, std::vector<std::string> >& metaDatas2, std::vector<itemInfo>& uiItems) { parseChar(p, '{'); do { std::string key; std::string value; double dbl = 0; std::vector<std::string> items; if (parseGlobalMetaData(p, key, value, dbl, metaDatas1, items)) { if (key != "meta") { // keep "name", "inputs", "outputs" key/value pairs if (items.size() > 0) { metaDatas2[key] = items; items.clear(); } else if (value != "") { metaDatas0[key].first = value; } else { metaDatas0[key].second = dbl; } } } else if (key == "ui") { int numItems = 0; parseChar(p, '[') && parseUI(p, uiItems, numItems); } } while (tryChar(p, ',')); return parseChar(p, '}'); } #endif // SIMPLEPARSER_H /************************** END SimpleParser.h **************************/ /************************** BEGIN PathBuilder.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef FAUST_PATHBUILDER_H #define FAUST_PATHBUILDER_H #include <vector> #include <string> #include <algorithm> /******************************************************************************* * PathBuilder : Faust User Interface * Helper class to build complete hierarchical path for UI items. ******************************************************************************/ class PathBuilder { protected: std::vector<std::string> fControlsLevel; public: PathBuilder() {} virtual ~PathBuilder() {} std::string buildPath(const std::string& label) { std::string res = "/"; for (size_t i = 0; i < fControlsLevel.size(); i++) { res += fControlsLevel[i]; res += "/"; } res += label; std::replace(res.begin(), res.end(), ' ', '_'); return res; } void pushLabel(const std::string& label) { fControlsLevel.push_back(label); } void popLabel() { fControlsLevel.pop_back(); } }; #endif // FAUST_PATHBUILDER_H /************************** END PathBuilder.h **************************/ /************************** BEGIN dsp-combiner.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2019 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __dsp_combiner__ #define __dsp_combiner__ #include <string.h> #include <string> #include <assert.h> #include <sstream> /************************** BEGIN dsp.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __dsp__ #define __dsp__ #include <string> #include <vector> #ifndef FAUSTFLOAT #define FAUSTFLOAT float #endif struct UI; struct Meta; /** * DSP memory manager. */ struct dsp_memory_manager { virtual ~dsp_memory_manager() {} virtual void* allocate(size_t size) = 0; virtual void destroy(void* ptr) = 0; }; /** * Signal processor definition. */ class dsp { public: dsp() {} virtual ~dsp() {} /* Return instance number of audio inputs */ virtual int getNumInputs() = 0; /* Return instance number of audio outputs */ virtual int getNumOutputs() = 0; /** * Trigger the ui_interface parameter with instance specific calls * to 'openTabBox', 'addButton', 'addVerticalSlider'... in order to build the UI. * * @param ui_interface - the user interface builder */ virtual void buildUserInterface(UI* ui_interface) = 0; /* Returns the sample rate currently used by the instance */ virtual int getSampleRate() = 0; /** * Global init, calls the following methods: * - static class 'classInit': static tables initialization * - 'instanceInit': constants and instance state initialization * * @param sample_rate - the sampling rate in Hertz */ virtual void init(int sample_rate) = 0; /** * Init instance state * * @param sample_rate - the sampling rate in Hertz */ virtual void instanceInit(int sample_rate) = 0; /** * Init instance constant state * * @param sample_rate - the sampling rate in Hertz */ virtual void instanceConstants(int sample_rate) = 0; /* Init default control parameters values */ virtual void instanceResetUserInterface() = 0; /* Init instance state (delay lines...) */ virtual void instanceClear() = 0; /** * Return a clone of the instance. * * @return a copy of the instance on success, otherwise a null pointer. */ virtual dsp* clone() = 0; /** * Trigger the Meta* parameter with instance specific calls to 'declare' (key, value) metadata. * * @param m - the Meta* meta user */ virtual void metadata(Meta* m) = 0; /** * DSP instance computation, to be called with successive in/out audio buffers. * * @param count - the number of frames to compute * @param inputs - the input audio buffers as an array of non-interleaved FAUSTFLOAT samples (eiher float, double or quad) * @param outputs - the output audio buffers as an array of non-interleaved FAUSTFLOAT samples (eiher float, double or quad) * */ virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) = 0; /** * DSP instance computation: alternative method to be used by subclasses. * * @param date_usec - the timestamp in microsec given by audio driver. * @param count - the number of frames to compute * @param inputs - the input audio buffers as an array of non-interleaved FAUSTFLOAT samples (either float, double or quad) * @param outputs - the output audio buffers as an array of non-interleaved FAUSTFLOAT samples (either float, double or quad) * */ virtual void compute(double /*date_usec*/, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { compute(count, inputs, outputs); } }; /** * Generic DSP decorator. */ class decorator_dsp : public dsp { protected: dsp* fDSP; public: decorator_dsp(dsp* dsp = nullptr):fDSP(dsp) {} virtual ~decorator_dsp() { delete fDSP; } virtual int getNumInputs() { return fDSP->getNumInputs(); } virtual int getNumOutputs() { return fDSP->getNumOutputs(); } virtual void buildUserInterface(UI* ui_interface) { fDSP->buildUserInterface(ui_interface); } virtual int getSampleRate() { return fDSP->getSampleRate(); } virtual void init(int sample_rate) { fDSP->init(sample_rate); } virtual void instanceInit(int sample_rate) { fDSP->instanceInit(sample_rate); } virtual void instanceConstants(int sample_rate) { fDSP->instanceConstants(sample_rate); } virtual void instanceResetUserInterface() { fDSP->instanceResetUserInterface(); } virtual void instanceClear() { fDSP->instanceClear(); } virtual decorator_dsp* clone() { return new decorator_dsp(fDSP->clone()); } virtual void metadata(Meta* m) { fDSP->metadata(m); } // Beware: subclasses usually have to overload the two 'compute' methods virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { fDSP->compute(count, inputs, outputs); } virtual void compute(double date_usec, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { fDSP->compute(date_usec, count, inputs, outputs); } }; /** * DSP factory class. */ class dsp_factory { protected: // So that to force sub-classes to use deleteDSPFactory(dsp_factory* factory); virtual ~dsp_factory() {} public: virtual std::string getName() = 0; virtual std::string getSHAKey() = 0; virtual std::string getDSPCode() = 0; virtual std::string getCompileOptions() = 0; virtual std::vector<std::string> getLibraryList() = 0; virtual std::vector<std::string> getIncludePathnames() = 0; virtual dsp* createDSPInstance() = 0; virtual void setMemoryManager(dsp_memory_manager* manager) = 0; virtual dsp_memory_manager* getMemoryManager() = 0; }; /** * On Intel set FZ (Flush to Zero) and DAZ (Denormals Are Zero) * flags to avoid costly denormals. */ #ifdef __SSE__ #include <xmmintrin.h> #ifdef __SSE2__ #define AVOIDDENORMALS _mm_setcsr(_mm_getcsr() | 0x8040) #else #define AVOIDDENORMALS _mm_setcsr(_mm_getcsr() | 0x8000) #endif #else #define AVOIDDENORMALS #endif #endif /************************** END dsp.h **************************/ // Base class and common code for binary combiners class dsp_binary_combiner : public dsp { protected: dsp* fDSP1; dsp* fDSP2; void buildUserInterfaceAux(UI* ui_interface, const char* name) { ui_interface->openTabBox(name); ui_interface->openVerticalBox("DSP1"); fDSP1->buildUserInterface(ui_interface); ui_interface->closeBox(); ui_interface->openVerticalBox("DSP2"); fDSP2->buildUserInterface(ui_interface); ui_interface->closeBox(); ui_interface->closeBox(); } FAUSTFLOAT** allocateChannels(int num, int buffer_size) { FAUSTFLOAT** channels = new FAUSTFLOAT*[num]; for (int chan = 0; chan < num; chan++) { channels[chan] = new FAUSTFLOAT[buffer_size]; memset(channels[chan], 0, sizeof(FAUSTFLOAT) * buffer_size); } return channels; } void deleteChannels(FAUSTFLOAT** channels, int num) { for (int chan = 0; chan < num; chan++) { delete [] channels[chan]; } delete [] channels; } public: dsp_binary_combiner(dsp* dsp1, dsp* dsp2):fDSP1(dsp1), fDSP2(dsp2) {} virtual ~dsp_binary_combiner() { delete fDSP1; delete fDSP2; } virtual int getSampleRate() { return fDSP1->getSampleRate(); } virtual void init(int sample_rate) { fDSP1->init(sample_rate); fDSP2->init(sample_rate); } virtual void instanceInit(int sample_rate) { fDSP1->instanceInit(sample_rate); fDSP2->instanceInit(sample_rate); } virtual void instanceConstants(int sample_rate) { fDSP1->instanceConstants(sample_rate); fDSP2->instanceConstants(sample_rate); } virtual void instanceResetUserInterface() { fDSP1->instanceResetUserInterface(); fDSP2->instanceResetUserInterface(); } virtual void instanceClear() { fDSP1->instanceClear(); fDSP2->instanceClear(); } virtual void metadata(Meta* m) { fDSP1->metadata(m); fDSP2->metadata(m); } }; // Combine two 'compatible' DSP in sequence class dsp_sequencer : public dsp_binary_combiner { private: FAUSTFLOAT** fDSP1Outputs; public: dsp_sequencer(dsp* dsp1, dsp* dsp2, int buffer_size = 4096):dsp_binary_combiner(dsp1, dsp2) { fDSP1Outputs = allocateChannels(fDSP1->getNumOutputs(), buffer_size); } virtual ~dsp_sequencer() { deleteChannels(fDSP1Outputs, fDSP1->getNumOutputs()); } virtual int getNumInputs() { return fDSP1->getNumInputs(); } virtual int getNumOutputs() { return fDSP2->getNumOutputs(); } virtual void buildUserInterface(UI* ui_interface) { buildUserInterfaceAux(ui_interface, "Sequencer"); } virtual dsp* clone() { return new dsp_sequencer(fDSP1->clone(), fDSP2->clone()); } virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { fDSP1->compute(count, inputs, fDSP1Outputs); fDSP2->compute(count, fDSP1Outputs, outputs); } virtual void compute(double date_usec, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { compute(count, inputs, outputs); } }; // Combine two DSP in parallel class dsp_parallelizer : public dsp_binary_combiner { private: FAUSTFLOAT** fDSP2Inputs; FAUSTFLOAT** fDSP2Outputs; public: dsp_parallelizer(dsp* dsp1, dsp* dsp2, int buffer_size = 4096):dsp_binary_combiner(dsp1, dsp2) { fDSP2Inputs = new FAUSTFLOAT*[fDSP2->getNumInputs()]; fDSP2Outputs = new FAUSTFLOAT*[fDSP2->getNumOutputs()]; } virtual ~dsp_parallelizer() { delete [] fDSP2Inputs; delete [] fDSP2Outputs; } virtual int getNumInputs() { return fDSP1->getNumInputs() + fDSP2->getNumInputs(); } virtual int getNumOutputs() { return fDSP1->getNumOutputs() + fDSP2->getNumOutputs(); } virtual void buildUserInterface(UI* ui_interface) { buildUserInterfaceAux(ui_interface, "Parallelizer"); } virtual dsp* clone() { return new dsp_parallelizer(fDSP1->clone(), fDSP2->clone()); } virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { fDSP1->compute(count, inputs, outputs); // Shift inputs/outputs channels for fDSP2 for (int chan = 0; chan < fDSP2->getNumInputs(); chan++) { fDSP2Inputs[chan] = inputs[fDSP1->getNumInputs() + chan]; } for (int chan = 0; chan < fDSP2->getNumOutputs(); chan++) { fDSP2Outputs[chan] = outputs[fDSP1->getNumOutputs() + chan]; } fDSP2->compute(count, fDSP2Inputs, fDSP2Outputs); } virtual void compute(double date_usec, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { compute(count, inputs, outputs); } }; // Combine two 'compatible' DSP in splitter class dsp_splitter : public dsp_binary_combiner { private: FAUSTFLOAT** fDSP1Outputs; FAUSTFLOAT** fDSP2Inputs; public: dsp_splitter(dsp* dsp1, dsp* dsp2, int buffer_size = 4096):dsp_binary_combiner(dsp1, dsp2) { fDSP1Outputs = allocateChannels(fDSP1->getNumOutputs(), buffer_size); fDSP2Inputs = new FAUSTFLOAT*[fDSP2->getNumInputs()]; } virtual ~dsp_splitter() { deleteChannels(fDSP1Outputs, fDSP1->getNumOutputs()); delete [] fDSP2Inputs; } virtual int getNumInputs() { return fDSP1->getNumInputs(); } virtual int getNumOutputs() { return fDSP2->getNumOutputs(); } virtual void buildUserInterface(UI* ui_interface) { buildUserInterfaceAux(ui_interface, "Splitter"); } virtual dsp* clone() { return new dsp_splitter(fDSP1->clone(), fDSP2->clone()); } virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { fDSP1->compute(count, inputs, fDSP1Outputs); for (int chan = 0; chan < fDSP2->getNumInputs(); chan++) { fDSP2Inputs[chan] = fDSP1Outputs[chan % fDSP1->getNumOutputs()]; } fDSP2->compute(count, fDSP2Inputs, outputs); } }; // Combine two 'compatible' DSP in merger class dsp_merger : public dsp_binary_combiner { private: FAUSTFLOAT** fDSP1Inputs; FAUSTFLOAT** fDSP1Outputs; FAUSTFLOAT** fDSP2Inputs; void mix(int count, FAUSTFLOAT* dst, FAUSTFLOAT* src) { for (int frame = 0; frame < count; frame++) { dst[frame] += src[frame]; } } public: dsp_merger(dsp* dsp1, dsp* dsp2, int buffer_size = 4096):dsp_binary_combiner(dsp1, dsp2) { fDSP1Inputs = allocateChannels(fDSP1->getNumInputs(), buffer_size); fDSP1Outputs = allocateChannels(fDSP1->getNumOutputs(), buffer_size); fDSP2Inputs = new FAUSTFLOAT*[fDSP2->getNumInputs()]; } virtual ~dsp_merger() { deleteChannels(fDSP1Inputs, fDSP1->getNumInputs()); deleteChannels(fDSP1Outputs, fDSP1->getNumOutputs()); delete [] fDSP2Inputs; } virtual int getNumInputs() { return fDSP1->getNumInputs(); } virtual int getNumOutputs() { return fDSP2->getNumOutputs(); } virtual void buildUserInterface(UI* ui_interface) { buildUserInterfaceAux(ui_interface, "Merge"); } virtual dsp* clone() { return new dsp_merger(fDSP1->clone(), fDSP2->clone()); } virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { fDSP1->compute(count, fDSP1Inputs, fDSP1Outputs); memset(fDSP2Inputs, 0, sizeof(FAUSTFLOAT*) * fDSP2->getNumInputs()); for (int chan = 0; chan < fDSP1->getNumOutputs(); chan++) { int mchan = chan % fDSP2->getNumInputs(); if (fDSP2Inputs[mchan]) { mix(count, fDSP2Inputs[mchan], fDSP1Outputs[chan]); } else { fDSP2Inputs[mchan] = fDSP1Outputs[chan]; } } fDSP2->compute(count, fDSP2Inputs, outputs); } }; // Combine two 'compatible' DSP in a recursive way class dsp_recursiver : public dsp_binary_combiner { private: FAUSTFLOAT** fDSP1Inputs; FAUSTFLOAT** fDSP1Outputs; FAUSTFLOAT** fDSP2Inputs; FAUSTFLOAT** fDSP2Outputs; public: dsp_recursiver(dsp* dsp1, dsp* dsp2):dsp_binary_combiner(dsp1, dsp2) { fDSP1Inputs = allocateChannels(fDSP1->getNumInputs(), 1); fDSP1Outputs = allocateChannels(fDSP1->getNumOutputs(), 1); fDSP2Inputs = allocateChannels(fDSP2->getNumInputs(), 1); fDSP2Outputs = allocateChannels(fDSP2->getNumOutputs(), 1); } virtual ~dsp_recursiver() { deleteChannels(fDSP1Inputs, fDSP1->getNumInputs()); deleteChannels(fDSP1Outputs, fDSP1->getNumOutputs()); deleteChannels(fDSP2Inputs, fDSP2->getNumInputs()); deleteChannels(fDSP2Outputs, fDSP2->getNumOutputs()); } virtual int getNumInputs() { return fDSP1->getNumInputs() - fDSP2->getNumOutputs(); } virtual int getNumOutputs() { return fDSP1->getNumOutputs(); } virtual void buildUserInterface(UI* ui_interface) { buildUserInterfaceAux(ui_interface, "Recursiver"); } virtual dsp* clone() { return new dsp_recursiver(fDSP1->clone(), fDSP2->clone()); } virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { for (int frame = 0; (frame < count); frame++) { for (int chan = 0; chan < fDSP2->getNumOutputs(); chan++) { fDSP1Inputs[chan][0] = fDSP2Outputs[chan][0]; } for (int chan = 0; chan < fDSP1->getNumInputs() - fDSP2->getNumOutputs(); chan++) { fDSP1Inputs[chan + fDSP2->getNumOutputs()][0] = inputs[chan][frame]; } fDSP1->compute(1, fDSP1Inputs, fDSP1Outputs); for (int chan = 0; chan < fDSP1->getNumOutputs(); chan++) { outputs[chan][frame] = fDSP1Outputs[chan][0]; } for (int chan = 0; chan < fDSP2->getNumInputs(); chan++) { fDSP2Inputs[chan][0] = fDSP1Outputs[chan][0]; } fDSP2->compute(1, fDSP2Inputs, fDSP2Outputs); } } virtual void compute(double date_usec, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { compute(count, inputs, outputs); } }; #ifndef __dsp_algebra_api__ #define __dsp_algebra_api__ // DSP algebra API /* Each operation takes two DSP as parameters, returns the combined DSPs, or null if failure with an error message. */ static dsp* createDSPSequencer(dsp* dsp1, dsp* dsp2, std::string& error) { if (dsp1->getNumOutputs() != dsp2->getNumInputs()) { std::stringstream error_aux; error_aux << "Connection error int dsp_sequencer : the number of outputs (" << dsp1->getNumOutputs() << ") of A " << "must be equal to the number of inputs (" << dsp2->getNumInputs() << ") of B" << std::endl; error = error_aux.str(); return nullptr; } else { return new dsp_sequencer(dsp1, dsp2); } } static dsp* createDSPParallelizer(dsp* dsp1, dsp* dsp2, std::string& error) { return new dsp_parallelizer(dsp1, dsp2); } static dsp* createDSPSplitter(dsp* dsp1, dsp* dsp2, std::string& error) { if (dsp1->getNumOutputs() == 0) { error = "Connection error in dsp_splitter : the first expression has no outputs\n"; return nullptr; } else if (dsp2->getNumInputs() == 0) { error = "Connection error in dsp_splitter : the second expression has no inputs\n"; return nullptr; } else if (dsp2->getNumInputs() % dsp1->getNumOutputs() != 0) { std::stringstream error_aux; error_aux << "Connection error in dsp_splitter : the number of outputs (" << dsp1->getNumOutputs() << ") of the first expression should be a divisor of the number of inputs (" << dsp2->getNumInputs() << ") of the second expression" << std::endl; error = error_aux.str(); return nullptr; } else if (dsp2->getNumInputs() == dsp1->getNumOutputs()) { return new dsp_sequencer(dsp1, dsp2); } else { return new dsp_splitter(dsp1, dsp2); } } static dsp* createDSPMerger(dsp* dsp1, dsp* dsp2, std::string& error) { if (dsp1->getNumOutputs() == 0) { error = "Connection error in dsp_merger : the first expression has no outputs\n"; return nullptr; } else if (dsp2->getNumInputs() == 0) { error = "Connection error in dsp_merger : the second expression has no inputs\n"; return nullptr; } else if (dsp1->getNumOutputs() % dsp2->getNumInputs() != 0) { std::stringstream error_aux; error_aux << "Connection error in dsp_merger : the number of outputs (" << dsp1->getNumOutputs() << ") of the first expression should be a multiple of the number of inputs (" << dsp2->getNumInputs() << ") of the second expression" << std::endl; error = error_aux.str(); return nullptr; } else if (dsp2->getNumInputs() == dsp1->getNumOutputs()) { return new dsp_sequencer(dsp1, dsp2); } else { return new dsp_merger(dsp1, dsp2); } } static dsp* createDSPRecursiver(dsp* dsp1, dsp* dsp2, std::string& error) { if ((dsp2->getNumInputs() > dsp1->getNumOutputs()) || (dsp2->getNumOutputs() > dsp1->getNumInputs())) { std::stringstream error_aux; error_aux << "Connection error in : dsp_recursiver" << std::endl; if (dsp2->getNumInputs() > dsp1->getNumOutputs()) { error_aux << "The number of outputs " << dsp1->getNumOutputs() << " of the first expression should be greater or equal to the number of inputs (" << dsp2->getNumInputs() << ") of the second expression" << std::endl; } if (dsp2->getNumOutputs() > dsp1->getNumInputs()) { error_aux << "The number of inputs " << dsp1->getNumInputs() << " of the first expression should be greater or equal to the number of outputs (" << dsp2->getNumOutputs() << ") of the second expression" << std::endl; } error = error_aux.str(); return nullptr; } else { return new dsp_recursiver(dsp1, dsp2); } } #endif #endif /************************** END dsp-combiner.h **************************/ /************************** BEGIN dsp-adapter.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2020 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __dsp_adapter__ #define __dsp_adapter__ #ifndef _WIN32 #include <alloca.h> #endif #include <string.h> #include <iostream> #include <cmath> // Adapts a DSP for a different number of inputs/outputs class dsp_adapter : public decorator_dsp { private: FAUSTFLOAT** fAdaptedInputs; FAUSTFLOAT** fAdaptedOutputs; int fHardwareInputs; int fHardwareOutputs; void adaptBuffers(FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { for (int i = 0; i < fHardwareInputs; i++) { fAdaptedInputs[i] = inputs[i]; } for (int i = 0; i < fHardwareOutputs; i++) { fAdaptedOutputs[i] = outputs[i]; } } public: dsp_adapter(dsp* dsp, int hardware_inputs, int hardware_outputs, int buffer_size):decorator_dsp(dsp) { fHardwareInputs = hardware_inputs; fHardwareOutputs = hardware_outputs; fAdaptedInputs = new FAUSTFLOAT*[dsp->getNumInputs()]; for (int i = 0; i < dsp->getNumInputs() - fHardwareInputs; i++) { fAdaptedInputs[i + fHardwareInputs] = new FAUSTFLOAT[buffer_size]; memset(fAdaptedInputs[i + fHardwareInputs], 0, sizeof(FAUSTFLOAT) * buffer_size); } fAdaptedOutputs = new FAUSTFLOAT*[dsp->getNumOutputs()]; for (int i = 0; i < dsp->getNumOutputs() - fHardwareOutputs; i++) { fAdaptedOutputs[i + fHardwareOutputs] = new FAUSTFLOAT[buffer_size]; memset(fAdaptedOutputs[i + fHardwareOutputs], 0, sizeof(FAUSTFLOAT) * buffer_size); } } virtual ~dsp_adapter() { for (int i = 0; i < fDSP->getNumInputs() - fHardwareInputs; i++) { delete [] fAdaptedInputs[i + fHardwareInputs]; } delete [] fAdaptedInputs; for (int i = 0; i < fDSP->getNumOutputs() - fHardwareOutputs; i++) { delete [] fAdaptedOutputs[i + fHardwareOutputs]; } delete [] fAdaptedOutputs; } virtual int getNumInputs() { return fHardwareInputs; } virtual int getNumOutputs() { return fHardwareOutputs; } virtual void compute(double date_usec, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { adaptBuffers(inputs, outputs); fDSP->compute(date_usec, count, fAdaptedInputs, fAdaptedOutputs); } virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { adaptBuffers(inputs, outputs); fDSP->compute(count, fAdaptedInputs, fAdaptedOutputs); } }; // Adapts a DSP for a different sample size template <typename REAL_INT, typename REAL_EXT> class dsp_sample_adapter : public decorator_dsp { protected: REAL_INT** fAdaptedInputs; REAL_INT** fAdaptedOutputs; void adaptInputBuffers(int count, FAUSTFLOAT** inputs) { for (int chan = 0; chan < fDSP->getNumInputs(); chan++) { for (int frame = 0; frame < count; frame++) { fAdaptedInputs[chan][frame] = REAL_INT(reinterpret_cast<REAL_EXT**>(inputs)[chan][frame]); } } } void adaptOutputsBuffers(int count, FAUSTFLOAT** outputs) { for (int chan = 0; chan < fDSP->getNumOutputs(); chan++) { for (int frame = 0; frame < count; frame++) { reinterpret_cast<REAL_EXT**>(outputs)[chan][frame] = REAL_EXT(fAdaptedOutputs[chan][frame]); } } } public: dsp_sample_adapter(dsp* dsp):decorator_dsp(dsp) { fAdaptedInputs = new REAL_INT*[dsp->getNumInputs()]; for (int i = 0; i < dsp->getNumInputs(); i++) { fAdaptedInputs[i] = new REAL_INT[4096]; } fAdaptedOutputs = new REAL_INT*[dsp->getNumOutputs()]; for (int i = 0; i < dsp->getNumOutputs(); i++) { fAdaptedOutputs[i] = new REAL_INT[4096]; } } virtual ~dsp_sample_adapter() { for (int i = 0; i < fDSP->getNumInputs(); i++) { delete [] fAdaptedInputs[i]; } delete [] fAdaptedInputs; for (int i = 0; i < fDSP->getNumOutputs(); i++) { delete [] fAdaptedOutputs[i]; } delete [] fAdaptedOutputs; } virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { adaptInputBuffers(count, inputs); // DSP base class uses FAUSTFLOAT** type, so reinterpret_cast has to be used even if the real DSP uses REAL_INT fDSP->compute(count, reinterpret_cast<FAUSTFLOAT**>(fAdaptedInputs), reinterpret_cast<FAUSTFLOAT**>(fAdaptedOutputs)); adaptOutputsBuffers(count, outputs); } virtual void compute(double date_usec, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { adaptInputBuffers(count, inputs); // DSP base class uses FAUSTFLOAT** type, so reinterpret_cast has to be used even if the real DSP uses REAL_INT fDSP->compute(date_usec, count, reinterpret_cast<FAUSTFLOAT**>(fAdaptedInputs), reinterpret_cast<FAUSTFLOAT**>(fAdaptedOutputs)); adaptOutputsBuffers(count, outputs); } }; // Template used to specialize double parameters expressed as NUM/DENOM template <int NUM, int DENOM> struct Double { static constexpr double value() { return double(NUM)/double(DENOM); } }; // Base class for filters template <class fVslider0, int fVslider1> struct Filter { inline int getFactor() { return fVslider1; } }; // Identity filter: copy input to output template <class fVslider0, int fVslider1> struct Identity : public Filter<fVslider0, fVslider1> { inline int getFactor() { return fVslider1; } inline void compute(int count, FAUSTFLOAT* input0, FAUSTFLOAT* output0) { memcpy(output0, input0, count * sizeof(FAUSTFLOAT)); } }; // Generated with process = fi.lowpass(3, ma.SR*hslider("FCFactor", 0.4, 0.4, 0.5, 0.01)/hslider("Factor", 2, 2, 8, 1)); template <class fVslider0, int fVslider1, typename REAL> struct LowPass3 : public Filter<fVslider0, fVslider1> { REAL fVec0[2]; REAL fRec1[2]; REAL fRec0[3]; inline REAL LowPass3_faustpower2_f(REAL value) { return (value * value); } LowPass3() { for (int l0 = 0; (l0 < 2); l0 = (l0 + 1)) { fVec0[l0] = 0.0; } for (int l1 = 0; (l1 < 2); l1 = (l1 + 1)) { fRec1[l1] = 0.0; } for (int l2 = 0; (l2 < 3); l2 = (l2 + 1)) { fRec0[l2] = 0.0; } } inline void compute(int count, FAUSTFLOAT* input0, FAUSTFLOAT* output0) { // Computed at template specialization time REAL fSlow0 = std::tan((3.1415926535897931 * (REAL(fVslider0::value()) / REAL(fVslider1)))); REAL fSlow1 = (1.0 / fSlow0); REAL fSlow2 = (1.0 / (((fSlow1 + 1.0000000000000002) / fSlow0) + 1.0)); REAL fSlow3 = (1.0 / (fSlow1 + 1.0)); REAL fSlow4 = (1.0 - fSlow1); REAL fSlow5 = (((fSlow1 + -1.0000000000000002) / fSlow0) + 1.0); REAL fSlow6 = (2.0 * (1.0 - (1.0 / LowPass3_faustpower2_f(fSlow0)))); // Computed at runtime for (int i = 0; (i < count); i = (i + 1)) { REAL fTemp0 = REAL(input0[i]); fVec0[0] = fTemp0; fRec1[0] = (0.0 - (fSlow3 * ((fSlow4 * fRec1[1]) - (fTemp0 + fVec0[1])))); fRec0[0] = (fRec1[0] - (fSlow2 * ((fSlow5 * fRec0[2]) + (fSlow6 * fRec0[1])))); output0[i] = FAUSTFLOAT((fSlow2 * (fRec0[2] + (fRec0[0] + (2.0 * fRec0[1]))))); fVec0[1] = fVec0[0]; fRec1[1] = fRec1[0]; fRec0[2] = fRec0[1]; fRec0[1] = fRec0[0]; } } }; // Generated with process = fi.lowpass(4, ma.SR*hslider("FCFactor", 0.4, 0.4, 0.5, 0.01)/hslider("Factor", 2, 2, 8, 1)); template <class fVslider0, int fVslider1, typename REAL> struct LowPass4 : public Filter<fVslider0, fVslider1> { REAL fRec1[3]; REAL fRec0[3]; inline REAL LowPass4_faustpower2_f(REAL value) { return (value * value); } LowPass4() { for (int l0 = 0; (l0 < 3); l0 = (l0 + 1)) { fRec1[l0] = 0.0f; } for (int l1 = 0; (l1 < 3); l1 = (l1 + 1)) { fRec0[l1] = 0.0f; } } inline void compute(int count, FAUSTFLOAT* input0, FAUSTFLOAT* output0) { // Computed at template specialization time REAL fSlow0 = std::tan((3.1415926535897931 * (REAL(fVslider0::value()) / REAL(fVslider1)))); REAL fSlow1 = (1.0 / fSlow0); REAL fSlow2 = (1.0 / (((fSlow1 + 0.76536686473017945) / fSlow0) + 1.0)); REAL fSlow3 = (1.0 / (((fSlow1 + 1.8477590650225735) / fSlow0) + 1.0)); REAL fSlow4 = (((fSlow1 + -1.8477590650225735) / fSlow0) + 1.0); REAL fSlow5 = (2.0 * (1.0 - (1.0 / LowPass4_faustpower2_f(fSlow0)))); REAL fSlow6 = (((fSlow1 + -0.76536686473017945) / fSlow0) + 1.0); // Computed at runtime for (int i = 0; (i < count); i = (i + 1)) { fRec1[0] = (REAL(input0[i]) - (fSlow3 * ((fSlow4 * fRec1[2]) + (fSlow5 * fRec1[1])))); fRec0[0] = ((fSlow3 * (fRec1[2] + (fRec1[0] + (2.0 * fRec1[1])))) - (fSlow2 * ((fSlow6 * fRec0[2]) + (fSlow5 * fRec0[1])))); output0[i] = FAUSTFLOAT((fSlow2 * (fRec0[2] + (fRec0[0] + (2.0 * fRec0[1]))))); fRec1[2] = fRec1[1]; fRec1[1] = fRec1[0]; fRec0[2] = fRec0[1]; fRec0[1] = fRec0[0]; } } }; // Generated with process = fi.lowpass3e(ma.SR*hslider("FCFactor", 0.4, 0.4, 0.5, 0.01)/hslider("Factor", 2, 2, 8, 1)); template <class fVslider0, int fVslider1, typename REAL> struct LowPass3e : public Filter<fVslider0, fVslider1> { REAL fRec1[3]; REAL fVec0[2]; REAL fRec0[2]; inline REAL LowPass3e_faustpower2_f(REAL value) { return (value * value); } LowPass3e() { for (int l0 = 0; (l0 < 3); l0 = (l0 + 1)) { fRec1[l0] = 0.0; } for (int l1 = 0; (l1 < 2); l1 = (l1 + 1)) { fVec0[l1] = 0.0; } for (int l2 = 0; (l2 < 2); l2 = (l2 + 1)) { fRec0[l2] = 0.0; } } inline void compute(int count, FAUSTFLOAT* input0, FAUSTFLOAT* output0) { // Computed at template specialization time REAL fSlow0 = std::tan((3.1415926535897931 * (REAL(fVslider0::value()) / REAL(fVslider1)))); REAL fSlow1 = (1.0 / fSlow0); REAL fSlow2 = (1.0 / (fSlow1 + 0.82244590899881598)); REAL fSlow3 = (0.82244590899881598 - fSlow1); REAL fSlow4 = (1.0 / (((fSlow1 + 0.80263676416103003) / fSlow0) + 1.4122708937742039)); REAL fSlow5 = LowPass3e_faustpower2_f(fSlow0); REAL fSlow6 = (0.019809144837788999 / fSlow5); REAL fSlow7 = (fSlow6 + 1.1615164189826961); REAL fSlow8 = (((fSlow1 + -0.80263676416103003) / fSlow0) + 1.4122708937742039); REAL fSlow9 = (2.0 * (1.4122708937742039 - (1.0 / fSlow5))); REAL fSlow10 = (2.0 * (1.1615164189826961 - fSlow6)); // Computed at runtime for (int i = 0; (i < count); i = (i + 1)) { fRec1[0] = (REAL(input0[i]) - (fSlow4 * ((fSlow8 * fRec1[2]) + (fSlow9 * fRec1[1])))); REAL fTemp0 = (fSlow4 * (((fSlow7 * fRec1[0]) + (fSlow10 * fRec1[1])) + (fSlow7 * fRec1[2]))); fVec0[0] = fTemp0; fRec0[0] = (0.0 - (fSlow2 * ((fSlow3 * fRec0[1]) - (fTemp0 + fVec0[1])))); output0[i] = FAUSTFLOAT(fRec0[0]); fRec1[2] = fRec1[1]; fRec1[1] = fRec1[0]; fVec0[1] = fVec0[0]; fRec0[1] = fRec0[0]; } } }; // Generated with process = fi.lowpass6e(ma.SR*hslider("FCFactor", 0.4, 0.4, 0.5, 0.01)/hslider("Factor", 2, 2, 8, 1)); template <class fVslider0, int fVslider1, typename REAL> struct LowPass6e : public Filter<fVslider0, fVslider1> { REAL fRec2[3]; REAL fRec1[3]; REAL fRec0[3]; inline REAL LowPass6e_faustpower2_f(REAL value) { return (value * value); } LowPass6e() { for (int l0 = 0; (l0 < 3); l0 = (l0 + 1)) { fRec2[l0] = 0.0; } for (int l1 = 0; (l1 < 3); l1 = (l1 + 1)) { fRec1[l1] = 0.0; } for (int l2 = 0; (l2 < 3); l2 = (l2 + 1)) { fRec0[l2] = 0.0; } } inline void compute(int count, FAUSTFLOAT* input0, FAUSTFLOAT* output0) { // Computed at template specialization time REAL fSlow0 = std::tan((3.1415926535897931 * (REAL(fVslider0::value()) / REAL(fVslider1)))); REAL fSlow1 = (1.0 / fSlow0); REAL fSlow2 = (1.0 / (((fSlow1 + 0.16840487111358901) / fSlow0) + 1.0693584077073119)); REAL fSlow3 = LowPass6e_faustpower2_f(fSlow0); REAL fSlow4 = (1.0 / fSlow3); REAL fSlow5 = (fSlow4 + 53.536152954556727); REAL fSlow6 = (1.0 / (((fSlow1 + 0.51247864188914105) / fSlow0) + 0.68962136448467504)); REAL fSlow7 = (fSlow4 + 7.6217312988706034); REAL fSlow8 = (1.0 / (((fSlow1 + 0.78241304682164503) / fSlow0) + 0.24529150870616001)); REAL fSlow9 = (9.9999997054999994e-05 / fSlow3); REAL fSlow10 = (fSlow9 + 0.00043322720055500002); REAL fSlow11 = (((fSlow1 + -0.78241304682164503) / fSlow0) + 0.24529150870616001); REAL fSlow12 = (2.0 * (0.24529150870616001 - fSlow4)); REAL fSlow13 = (2.0 * (0.00043322720055500002 - fSlow9)); REAL fSlow14 = (((fSlow1 + -0.51247864188914105) / fSlow0) + 0.68962136448467504); REAL fSlow15 = (2.0 * (0.68962136448467504 - fSlow4)); REAL fSlow16 = (2.0 * (7.6217312988706034 - fSlow4)); REAL fSlow17 = (((fSlow1 + -0.16840487111358901) / fSlow0) + 1.0693584077073119); REAL fSlow18 = (2.0 * (1.0693584077073119 - fSlow4)); REAL fSlow19 = (2.0 * (53.536152954556727 - fSlow4)); // Computed at runtime for (int i = 0; (i < count); i = (i + 1)) { fRec2[0] = (REAL(input0[i]) - (fSlow8 * ((fSlow11 * fRec2[2]) + (fSlow12 * fRec2[1])))); fRec1[0] = ((fSlow8 * (((fSlow10 * fRec2[0]) + (fSlow13 * fRec2[1])) + (fSlow10 * fRec2[2]))) - (fSlow6 * ((fSlow14 * fRec1[2]) + (fSlow15 * fRec1[1])))); fRec0[0] = ((fSlow6 * (((fSlow7 * fRec1[0]) + (fSlow16 * fRec1[1])) + (fSlow7 * fRec1[2]))) - (fSlow2 * ((fSlow17 * fRec0[2]) + (fSlow18 * fRec0[1])))); output0[i] = FAUSTFLOAT((fSlow2 * (((fSlow5 * fRec0[0]) + (fSlow19 * fRec0[1])) + (fSlow5 * fRec0[2])))); fRec2[2] = fRec2[1]; fRec2[1] = fRec2[0]; fRec1[2] = fRec1[1]; fRec1[1] = fRec1[0]; fRec0[2] = fRec0[1]; fRec0[1] = fRec0[0]; } } }; // A "si.bus(N)" like hard-coded class struct dsp_bus : public dsp { int fChannels; int fSampleRate; dsp_bus(int channels):fChannels(channels), fSampleRate(-1) {} virtual int getNumInputs() { return fChannels; } virtual int getNumOutputs() { return fChannels; } virtual int getSampleRate() { return fSampleRate; } virtual void buildUserInterface(UI* ui_interface) {} virtual void init(int sample_rate) { //classInit(sample_rate); instanceInit(sample_rate); } virtual void instanceInit(int sample_rate) { fSampleRate = sample_rate; instanceConstants(sample_rate); instanceResetUserInterface(); instanceClear(); } virtual void instanceConstants(int sample_rate) {} virtual void instanceResetUserInterface() {} virtual void instanceClear() {} virtual dsp* clone() { return new dsp_bus(fChannels); } virtual void metadata(Meta* m) {} virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { for (int chan = 0; chan < fChannels; chan++) { memcpy(outputs[chan], inputs[chan], sizeof(FAUSTFLOAT) * count); } } virtual void compute(double /*date_usec*/, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { compute(count, inputs, outputs); } }; // Base class for sample-rate adapter template <typename FILTER> class sr_sampler : public decorator_dsp { protected: std::vector<FILTER> fInputLowPass; std::vector<FILTER> fOutputLowPass; inline int getFactor() { return this->fOutputLowPass[0].getFactor(); } public: sr_sampler(dsp* dsp):decorator_dsp(dsp) { for (int chan = 0; chan < fDSP->getNumInputs(); chan++) { fInputLowPass.push_back(FILTER()); } for (int chan = 0; chan < fDSP->getNumOutputs(); chan++) { fOutputLowPass.push_back(FILTER()); } } }; // Down sample-rate adapter template <typename FILTER> class dsp_down_sampler : public sr_sampler<FILTER> { public: dsp_down_sampler(dsp* dsp):sr_sampler<FILTER>(dsp) {} virtual void init(int sample_rate) { this->fDSP->init(sample_rate / this->getFactor()); } virtual void instanceInit(int sample_rate) { this->fDSP->instanceInit(sample_rate / this->getFactor()); } virtual void instanceConstants(int sample_rate) { this->fDSP->instanceConstants(sample_rate / this->getFactor()); } virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { int real_count = count / this->getFactor(); // Adapt inputs FAUSTFLOAT* fInputs[this->fDSP->getNumInputs()]; for (int chan = 0; chan < this->fDSP->getNumInputs(); chan++) { // Lowpass filtering in place on 'inputs' this->fInputLowPass[chan].compute(count, inputs[chan], inputs[chan]); // Allocate fInputs with 'real_count' frames fInputs[chan] = (FAUSTFLOAT*)alloca(sizeof(FAUSTFLOAT) * real_count); // Decimate for (int frame = 0; frame < real_count; frame++) { fInputs[chan][frame] = inputs[chan][frame * this->getFactor()]; } } // Allocate fOutputs with 'real_count' frames FAUSTFLOAT* fOutputs[this->fDSP->getNumOutputs()]; for (int chan = 0; chan < this->fDSP->getNumOutputs(); chan++) { fOutputs[chan] = (FAUSTFLOAT*)alloca(sizeof(FAUSTFLOAT) * real_count); } // Compute at lower rate this->fDSP->compute(real_count, fInputs, fOutputs); // Adapt outputs for (int chan = 0; chan < this->fDSP->getNumOutputs(); chan++) { // Puts zeros memset(outputs[chan], 0, sizeof(FAUSTFLOAT) * count); for (int frame = 0; frame < real_count; frame++) { // Copy one sample every 'DownFactor' // Apply volume //outputs[chan][frame * this->getFactor()] = fOutputs[chan][frame] * this->getFactor(); outputs[chan][frame * this->getFactor()] = fOutputs[chan][frame]; } // Lowpass filtering in place on 'outputs' this->fOutputLowPass[chan].compute(count, outputs[chan], outputs[chan]); } } virtual void compute(double /*date_usec*/, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { compute(count, inputs, outputs); } }; // Up sample-rate adapter template <typename FILTER> class dsp_up_sampler : public sr_sampler<FILTER> { public: dsp_up_sampler(dsp* dsp):sr_sampler<FILTER>(dsp) {} virtual void init(int sample_rate) { this->fDSP->init(sample_rate * this->getFactor()); } virtual void instanceInit(int sample_rate) { this->fDSP->instanceInit(sample_rate * this->getFactor()); } virtual void instanceConstants(int sample_rate) { this->fDSP->instanceConstants(sample_rate * this->getFactor()); } virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { int real_count = count * this->getFactor(); // Adapt inputs FAUSTFLOAT** fInputs = (FAUSTFLOAT**)alloca(this->fDSP->getNumInputs() * sizeof(FAUSTFLOAT*)); for (int chan = 0; chan < this->fDSP->getNumInputs(); chan++) { // Allocate fInputs with 'real_count' frames fInputs[chan] = (FAUSTFLOAT*)alloca(sizeof(FAUSTFLOAT) * real_count); // Puts zeros memset(fInputs[chan], 0, sizeof(FAUSTFLOAT) * real_count); for (int frame = 0; frame < count; frame++) { // Copy one sample every 'UpFactor' fInputs[chan][frame * this->getFactor()] = inputs[chan][frame]; } // Lowpass filtering in place on 'fInputs' this->fInputLowPass[chan].compute(real_count, fInputs[chan], fInputs[chan]); } // Allocate fOutputs with 'real_count' frames FAUSTFLOAT** fOutputs = (FAUSTFLOAT**)alloca(this->fDSP->getNumOutputs() * sizeof(FAUSTFLOAT*)); for (int chan = 0; chan < this->fDSP->getNumOutputs(); chan++) { fOutputs[chan] = (FAUSTFLOAT*)alloca(sizeof(FAUSTFLOAT) * real_count); } // Compute at upper rate this->fDSP->compute(real_count, fInputs, fOutputs); // Adapt outputs for (int chan = 0; chan < this->fDSP->getNumOutputs(); chan++) { // Lowpass filtering in place on 'fOutputs' this->fOutputLowPass[chan].compute(real_count, fOutputs[chan], fOutputs[chan]); // Decimate for (int frame = 0; frame < count; frame++) { // Apply volume //outputs[chan][frame] = fOutputs[chan][frame * this->getFactor()] * this->getFactor(); outputs[chan][frame] = fOutputs[chan][frame * this->getFactor()]; } } } virtual void compute(double /*date_usec*/, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { compute(count, inputs, outputs); } }; #endif /************************** END dsp-adapter.h **************************/ /************************** BEGIN misc.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __misc__ #define __misc__ #include <algorithm> #include <map> #include <cstdlib> #include <string.h> #include <fstream> #include <string> /************************** BEGIN meta.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __meta__ #define __meta__ struct Meta { virtual ~Meta() {}; virtual void declare(const char* key, const char* value) = 0; }; #endif /************************** END meta.h **************************/ using std::max; using std::min; struct XXXX_Meta : std::map<const char*, const char*> { void declare(const char* key, const char* value) { (*this)[key] = value; } }; struct MY_Meta : Meta, std::map<const char*, const char*> { void declare(const char* key, const char* value) { (*this)[key] = value; } }; static int lsr(int x, int n) { return int(((unsigned int)x) >> n); } static int int2pow2(int x) { int r = 0; while ((1<<r) < x) r++; return r; } static long lopt(char* argv[], const char* name, long def) { for (int i = 0; argv[i]; i++) if (!strcmp(argv[i], name)) return std::atoi(argv[i+1]); return def; } static long lopt1(int argc, char* argv[], const char* longname, const char* shortname, long def) { for (int i = 2; i < argc; i++) { if (strcmp(argv[i-1], shortname) == 0 || strcmp(argv[i-1], longname) == 0) { return atoi(argv[i]); } } return def; } static const char* lopts(char* argv[], const char* name, const char* def) { for (int i = 0; argv[i]; i++) if (!strcmp(argv[i], name)) return argv[i+1]; return def; } static const char* lopts1(int argc, char* argv[], const char* longname, const char* shortname, const char* def) { for (int i = 2; i < argc; i++) { if (strcmp(argv[i-1], shortname) == 0 || strcmp(argv[i-1], longname) == 0) { return argv[i]; } } return def; } static bool isopt(char* argv[], const char* name) { for (int i = 0; argv[i]; i++) if (!strcmp(argv[i], name)) return true; return false; } static std::string pathToContent(const std::string& path) { std::ifstream file(path.c_str(), std::ifstream::binary); file.seekg(0, file.end); int size = int(file.tellg()); file.seekg(0, file.beg); // And allocate buffer to that a single line can be read... char* buffer = new char[size + 1]; file.read(buffer, size); // Terminate the string buffer[size] = 0; std::string result = buffer; file.close(); delete [] buffer; return result; } #endif /************************** END misc.h **************************/ /************************** BEGIN SaveUI.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2019-2020 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef FAUST_SAVEUI_H #define FAUST_SAVEUI_H /************************** BEGIN DecoratorUI.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef Decorator_UI_H #define Decorator_UI_H //---------------------------------------------------------------- // Generic UI empty implementation //---------------------------------------------------------------- class GenericUI : public UI { public: GenericUI() {} virtual ~GenericUI() {} // -- widget's layouts virtual void openTabBox(const char* label) {} virtual void openHorizontalBox(const char* label) {} virtual void openVerticalBox(const char* label) {} virtual void closeBox() {} // -- active widgets virtual void addButton(const char* label, FAUSTFLOAT* zone) {} virtual void addCheckButton(const char* label, FAUSTFLOAT* zone) {} virtual void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) {} virtual void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) {} virtual void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) {} // -- passive widgets virtual void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) {} virtual void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) {} // -- soundfiles virtual void addSoundfile(const char* label, const char* soundpath, Soundfile** sf_zone) {} virtual void declare(FAUSTFLOAT* zone, const char* key, const char* val) {} }; //---------------------------------------------------------------- // Generic UI decorator //---------------------------------------------------------------- class DecoratorUI : public UI { protected: UI* fUI; public: DecoratorUI(UI* ui = 0):fUI(ui) {} virtual ~DecoratorUI() { delete fUI; } // -- widget's layouts virtual void openTabBox(const char* label) { fUI->openTabBox(label); } virtual void openHorizontalBox(const char* label) { fUI->openHorizontalBox(label); } virtual void openVerticalBox(const char* label) { fUI->openVerticalBox(label); } virtual void closeBox() { fUI->closeBox(); } // -- active widgets virtual void addButton(const char* label, FAUSTFLOAT* zone) { fUI->addButton(label, zone); } virtual void addCheckButton(const char* label, FAUSTFLOAT* zone) { fUI->addCheckButton(label, zone); } virtual void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { fUI->addVerticalSlider(label, zone, init, min, max, step); } virtual void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { fUI->addHorizontalSlider(label, zone, init, min, max, step); } virtual void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { fUI->addNumEntry(label, zone, init, min, max, step); } // -- passive widgets virtual void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { fUI->addHorizontalBargraph(label, zone, min, max); } virtual void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { fUI->addVerticalBargraph(label, zone, min, max); } // -- soundfiles virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) { fUI->addSoundfile(label, filename, sf_zone); } virtual void declare(FAUSTFLOAT* zone, const char* key, const char* val) { fUI->declare(zone, key, val); } }; #endif /************************** END DecoratorUI.h **************************/ // Base class to handle controllers state save/load class SaveUI : public GenericUI { protected: struct SavedZone { FAUSTFLOAT* fZone; FAUSTFLOAT fCurrent; FAUSTFLOAT fInit; SavedZone():fZone(nullptr), fCurrent(FAUSTFLOAT(0)), fInit(FAUSTFLOAT(0)) {} SavedZone(FAUSTFLOAT* zone, FAUSTFLOAT current, FAUSTFLOAT init) :fZone(zone), fCurrent(current), fInit(init) { *fZone = current; } ~SavedZone() {} }; std::map<std::string, SavedZone> fName2Zone; virtual void addItem(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init) = 0; public: SaveUI() {} virtual ~SaveUI() {} void addButton(const char* label, FAUSTFLOAT* zone) { addItem(label, zone, FAUSTFLOAT(0)); } void addCheckButton(const char* label, FAUSTFLOAT* zone) { addItem(label, zone, FAUSTFLOAT(0)); } void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { addItem(label, zone, init); } void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { addItem(label, zone, init); } void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { addItem(label, zone, init); } void reset() { for (auto& it : fName2Zone) { *it.second.fZone = it.second.fInit; } } void display() { for (auto& it : fName2Zone) { std::cout << "SaveUI::display path = " << it.first << " value = " << *it.second.fZone << std::endl; } } void save() { for (auto& it : fName2Zone) { it.second.fCurrent = *it.second.fZone; } } }; /* Save/load current value using the label, reset to init value */ class SaveLabelUI : public SaveUI { protected: void addItem(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init) { if (fName2Zone.find(label) != fName2Zone.end()) { FAUSTFLOAT current = fName2Zone[label].fCurrent; fName2Zone[label] = SavedZone(zone, current, init); } else { fName2Zone[label] = SavedZone(zone, init, init); } } public: SaveLabelUI() : SaveUI() {} virtual ~SaveLabelUI() {} }; /* Save/load current value using the complete path, reset to init value */ class SavePathUI : public SaveUI, public PathBuilder { protected: void openTabBox(const char* label) { pushLabel(label); } void openHorizontalBox(const char* label) { pushLabel(label);; } void openVerticalBox(const char* label) { pushLabel(label); } void closeBox() { popLabel(); }; void addItem(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init) { std::string path = buildPath(label); if (fName2Zone.find(path) != fName2Zone.end()) { FAUSTFLOAT current = fName2Zone[path].fCurrent; fName2Zone[path] = SavedZone(zone, current, init); } else { fName2Zone[path] = SavedZone(zone, init, init); } } public: SavePathUI(): SaveUI() {} virtual ~SavePathUI() {} }; #endif /************************** END SaveUI.h **************************/ // Always included /************************** BEGIN OSCUI.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __OSCUI__ #define __OSCUI__ #include <vector> #include <string> /* Faust Project Copyright (C) 2011 Grame This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France [email protected] */ #ifndef __OSCControler__ #define __OSCControler__ #include <string> /* Copyright (C) 2011 Grame This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France [email protected] */ #ifndef __FaustFactory__ #define __FaustFactory__ #include <stack> #include <string> #include <sstream> /* Copyright (C) 2011 Grame This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France [email protected] */ #ifndef __FaustNode__ #define __FaustNode__ #include <string> #include <vector> /* Copyright (C) 2011 Grame This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France [email protected] */ #ifndef __MessageDriven__ #define __MessageDriven__ #include <string> #include <vector> /* Copyright (C) 2010 Grame This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France [email protected] */ #ifndef __MessageProcessor__ #define __MessageProcessor__ namespace oscfaust { class Message; //-------------------------------------------------------------------------- /*! \brief an abstract class for objects able to process OSC messages */ class MessageProcessor { public: virtual ~MessageProcessor() {} virtual void processMessage( const Message* msg ) = 0; }; } // end namespoace #endif /* Copyright (C) 2011 Grame This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France [email protected] */ #ifndef __smartpointer__ #define __smartpointer__ #include <cassert> namespace oscfaust { /*! \brief the base class for smart pointers implementation Any object that want to support smart pointers should inherit from the smartable class which provides reference counting and automatic delete when the reference count drops to zero. */ class smartable { private: unsigned refCount; public: //! gives the reference count of the object unsigned refs() const { return refCount; } //! addReference increments the ref count and checks for refCount overflow void addReference() { refCount++; assert(refCount != 0); } //! removeReference delete the object when refCount is zero void removeReference() { if (--refCount == 0) delete this; } protected: smartable() : refCount(0) {} smartable(const smartable&): refCount(0) {} //! destructor checks for non-zero refCount virtual ~smartable() { /* See "Static SFaustNode create (const char* name, C* zone, C init, C min, C max, const char* prefix, GUI* ui)" comment. assert (refCount == 0); */ } smartable& operator=(const smartable&) { return *this; } }; /*! \brief the smart pointer implementation A smart pointer is in charge of maintaining the objects reference count by the way of pointers operators overloading. It supports class inheritance and conversion whenever possible. \n Instances of the SMARTP class are supposed to use \e smartable types (or at least objects that implements the \e addReference and \e removeReference methods in a consistent way). */ template<class T> class SMARTP { private: //! the actual pointer to the class T* fSmartPtr; public: //! an empty constructor - points to null SMARTP() : fSmartPtr(0) {} //! build a smart pointer from a class pointer SMARTP(T* rawptr) : fSmartPtr(rawptr) { if (fSmartPtr) fSmartPtr->addReference(); } //! build a smart pointer from an convertible class reference template<class T2> SMARTP(const SMARTP<T2>& ptr) : fSmartPtr((T*)ptr) { if (fSmartPtr) fSmartPtr->addReference(); } //! build a smart pointer from another smart pointer reference SMARTP(const SMARTP& ptr) : fSmartPtr((T*)ptr) { if (fSmartPtr) fSmartPtr->addReference(); } //! the smart pointer destructor: simply removes one reference count ~SMARTP() { if (fSmartPtr) fSmartPtr->removeReference(); } //! cast operator to retrieve the actual class pointer operator T*() const { return fSmartPtr; } //! '*' operator to access the actual class pointer T& operator*() const { // checks for null dereference assert (fSmartPtr != 0); return *fSmartPtr; } //! operator -> overloading to access the actual class pointer T* operator->() const { // checks for null dereference assert (fSmartPtr != 0); return fSmartPtr; } //! operator = that moves the actual class pointer template <class T2> SMARTP& operator=(T2 p1_) { *this=(T*)p1_; return *this; } //! operator = that moves the actual class pointer SMARTP& operator=(T* p_) { // check first that pointers differ if (fSmartPtr != p_) { // increments the ref count of the new pointer if not null if (p_ != 0) p_->addReference(); // decrements the ref count of the old pointer if not null if (fSmartPtr != 0) fSmartPtr->removeReference(); // and finally stores the new actual pointer fSmartPtr = p_; } return *this; } //! operator < to support SMARTP map with Visual C++ bool operator<(const SMARTP<T>& p_) const { return fSmartPtr < ((T *) p_); } //! operator = to support inherited class reference SMARTP& operator=(const SMARTP<T>& p_) { return operator=((T *) p_); } //! dynamic cast support template<class T2> SMARTP& cast(T2* p_) { return operator=(dynamic_cast<T*>(p_)); } //! dynamic cast support template<class T2> SMARTP& cast(const SMARTP<T2>& p_) { return operator=(dynamic_cast<T*>(p_)); } }; } #endif namespace oscfaust { class Message; class OSCRegexp; class MessageDriven; typedef class SMARTP<MessageDriven> SMessageDriven; //-------------------------------------------------------------------------- /*! \brief a base class for objects accepting OSC messages Message driven objects are hierarchically organized in a tree. They provides the necessary to dispatch an OSC message to its destination node, according to the message OSC address. The principle of the dispatch is the following: - first the processMessage() method should be called on the top level node - next processMessage call propose */ class MessageDriven : public MessageProcessor, public smartable { std::string fName; ///< the node name std::string fOSCPrefix; ///< the node OSC address prefix (OSCAddress = fOSCPrefix + '/' + fName) std::vector<SMessageDriven> fSubNodes; ///< the subnodes of the current node protected: MessageDriven(const char *name, const char *oscprefix) : fName (name), fOSCPrefix(oscprefix) {} virtual ~MessageDriven() {} public: static SMessageDriven create(const char* name, const char *oscprefix) { return new MessageDriven(name, oscprefix); } /*! \brief OSC message processing method. \param msg the osc message to be processed The method should be called on the top level node. */ virtual void processMessage(const Message* msg); /*! \brief propose an OSc message at a given hierarchy level. \param msg the osc message currently processed \param regexp a regular expression based on the osc address head \param addrTail the osc address tail The method first tries to match the regular expression with the object name. When it matches: - it calls \c accept when \c addrTail is empty - or it \c propose the message to its subnodes when \c addrTail is not empty. In this case a new \c regexp is computed with the head of \c addrTail and a new \c addrTail as well. */ virtual void propose(const Message* msg, const OSCRegexp* regexp, const std::string& addrTail); /*! \brief accept an OSC message. \param msg the osc message currently processed \return true when the message is processed by the node The method is called only for the destination nodes. The real message acceptance is the node responsability and may depend on the message content. */ virtual bool accept(const Message* msg); /*! \brief handler for the \c 'get' message \param ipdest the output message destination IP The \c 'get' message is supported by every node: - it is propagated to the subnodes until it reaches terminal nodes - a terminal node send its state on \c 'get' request to the IP address given as parameter. The \c get method is basically called by the accept method. */ virtual void get(unsigned long ipdest) const; /*! \brief handler for the \c 'get' 'attribute' message \param ipdest the output message destination IP \param what the requested attribute The \c 'get' message is supported by every node: - it is propagated to the subnodes until it reaches terminal nodes - a terminal node send its state on \c 'get' request to the IP address given as parameter. The \c get method is basically called by the accept method. */ virtual void get(unsigned long ipdest, const std::string& what) const {} void add(SMessageDriven node) { fSubNodes.push_back (node); } const char* getName() const { return fName.c_str(); } std::string getOSCAddress() const; int size() const { return (int)fSubNodes.size (); } const std::string& name() const { return fName; } SMessageDriven subnode(int i) { return fSubNodes[i]; } }; } // end namespoace #endif /* Copyright (C) 2011 Grame This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France [email protected] */ #ifndef __Message__ #define __Message__ #include <string> #include <vector> namespace oscfaust { class OSCStream; template <typename T> class MsgParam; class baseparam; typedef SMARTP<baseparam> Sbaseparam; //-------------------------------------------------------------------------- /*! \brief base class of a message parameters */ class baseparam : public smartable { public: virtual ~baseparam() {} /*! \brief utility for parameter type checking */ template<typename X> bool isType() const { return dynamic_cast<const MsgParam<X>*> (this) != 0; } /*! \brief utility for parameter convertion \param errvalue the returned value when no conversion applies \return the parameter value when the type matches */ template<typename X> X value(X errvalue) const { const MsgParam<X>* o = dynamic_cast<const MsgParam<X>*> (this); return o ? o->getValue() : errvalue; } /*! \brief utility for parameter comparison */ template<typename X> bool equal(const baseparam& p) const { const MsgParam<X>* a = dynamic_cast<const MsgParam<X>*> (this); const MsgParam<X>* b = dynamic_cast<const MsgParam<X>*> (&p); return a && b && (a->getValue() == b->getValue()); } /*! \brief utility for parameter comparison */ bool operator==(const baseparam& p) const { return equal<float>(p) || equal<int>(p) || equal<std::string>(p); } bool operator!=(const baseparam& p) const { return !equal<float>(p) && !equal<int>(p) && !equal<std::string>(p); } virtual SMARTP<baseparam> copy() const = 0; }; //-------------------------------------------------------------------------- /*! \brief template for a message parameter */ template <typename T> class MsgParam : public baseparam { T fParam; public: MsgParam(T val) : fParam(val) {} virtual ~MsgParam() {} T getValue() const { return fParam; } virtual Sbaseparam copy() const { return new MsgParam<T>(fParam); } }; //-------------------------------------------------------------------------- /*! \brief a message description A message is composed of an address (actually an OSC address), a message string that may be viewed as a method name and a list of message parameters. */ class Message { public: typedef SMARTP<baseparam> argPtr; ///< a message argument ptr type typedef std::vector<argPtr> argslist; ///< args list type private: unsigned long fSrcIP; ///< the message source IP number std::string fAddress; ///< the message osc destination address std::string fAlias; ///< the message alias osc destination address argslist fArguments; ///< the message arguments public: /*! \brief an empty message constructor */ Message() {} /*! \brief a message constructor \param address the message destination address */ Message(const std::string& address) : fAddress(address), fAlias("") {} Message(const std::string& address, const std::string& alias) : fAddress(address), fAlias(alias) {} /*! \brief a message constructor \param address the message destination address \param args the message parameters */ Message(const std::string& address, const argslist& args) : fAddress(address), fArguments(args) {} /*! \brief a message constructor \param msg a message */ Message(const Message& msg); virtual ~Message() {} //{ freed++; std::cout << "running messages: " << (allocated - freed) << std::endl; } /*! \brief adds a parameter to the message \param val the parameter */ template <typename T> void add(T val) { fArguments.push_back(new MsgParam<T>(val)); } /*! \brief adds a float parameter to the message \param val the parameter value */ void add(float val) { add<float>(val); } /*! \brief adds a double parameter to the message \param val the parameter value */ void add(double val) { add<double>(val); } /*! \brief adds an int parameter to the message \param val the parameter value */ void add(int val) { add<int>(val); } /*! \brief adds a string parameter to the message \param val the parameter value */ void add(const std::string& val) { add<std::string>(val); } /*! \brief adds a parameter to the message \param val the parameter */ void add(argPtr val) { fArguments.push_back( val ); } /*! \brief sets the message address \param addr the address */ void setSrcIP(unsigned long addr) { fSrcIP = addr; } /*! \brief sets the message address \param addr the address */ void setAddress(const std::string& addr) { fAddress = addr; } /*! \brief print the message \param out the output stream */ void print(std::ostream& out) const; /*! \brief send the message to OSC \param out the OSC output stream */ void print(OSCStream& out) const; /*! \brief print message arguments \param out the OSC output stream */ void printArgs(OSCStream& out) const; /// \brief gives the message address const std::string& address() const { return fAddress; } /// \brief gives the message alias const std::string& alias() const { return fAlias; } /// \brief gives the message parameters list const argslist& params() const { return fArguments; } /// \brief gives the message parameters list argslist& params() { return fArguments; } /// \brief gives the message source IP unsigned long src() const { return fSrcIP; } /// \brief gives the message parameters count int size() const { return (int)fArguments.size(); } bool operator == (const Message& other) const; /*! \brief gives a message float parameter \param i the parameter index (0 <= i < size()) \param val on output: the parameter value when the parameter type matches \return false when types don't match */ bool param(int i, float& val) const { val = params()[i]->value<float>(val); return params()[i]->isType<float>(); } /*! \brief gives a message double parameter \param i the parameter index (0 <= i < size()) \param val on output: the parameter value when the parameter type matches \return false when types don't match */ bool param(int i, double& val) const { val = params()[i]->value<double>(val); return params()[i]->isType<double>(); } /*! \brief gives a message int parameter \param i the parameter index (0 <= i < size()) \param val on output: the parameter value when the parameter type matches \return false when types don't match */ bool param(int i, int& val) const { val = params()[i]->value<int>(val); return params()[i]->isType<int>(); } /*! \brief gives a message int parameter \param i the parameter index (0 <= i < size()) \param val on output: the parameter value when the parameter type matches \return false when types don't match */ bool param(int i, unsigned int& val) const { val = params()[i]->value<int>(val); return params()[i]->isType<int>(); } /*! \brief gives a message int parameter \param i the parameter index (0 <= i < size()) \param val on output: the parameter value when the parameter type matches \return false when types don't match \note a boolean value is handled as integer */ bool param(int i, bool& val) const { int ival = 0; ival = params()[i]->value<int>(ival); val = ival!=0; return params()[i]->isType<int>(); } /*! \brief gives a message int parameter \param i the parameter index (0 <= i < size()) \param val on output: the parameter value when the parameter type matches \return false when types don't match */ bool param(int i, long int& val) const { val = long(params()[i]->value<int>(val)); return params()[i]->isType<int>(); } /*! \brief gives a message string parameter \param i the parameter index (0 <= i < size()) \param val on output: the parameter value when the parameter type matches \return false when types don't match */ bool param(int i, std::string& val) const { val = params()[i]->value<std::string>(val); return params()[i]->isType<std::string>(); } }; } // end namespoace #endif /************************** BEGIN GUI.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __GUI_H__ #define __GUI_H__ #include <list> #include <map> #include <vector> #include <iostream> #include <assert.h> #ifdef _WIN32 # pragma warning (disable: 4100) #else # pragma GCC diagnostic ignored "-Wunused-parameter" #endif /************************** BEGIN ValueConverter.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __ValueConverter__ #define __ValueConverter__ /*************************************************************************************** ValueConverter.h (GRAME, Copyright 2015-2019) Set of conversion objects used to map user interface values (for example a gui slider delivering values between 0 and 1) to faust values (for example a vslider between 20 and 20000) using a log scale. -- Utilities Range(lo,hi) : clip a value x between lo and hi Interpolator(lo,hi,v1,v2) : Maps a value x between lo and hi to a value y between v1 and v2 Interpolator3pt(lo,mi,hi,v1,vm,v2) : Map values between lo mid hi to values between v1 vm v2 -- Value Converters ValueConverter::ui2faust(x) ValueConverter::faust2ui(x) -- ValueConverters used for sliders depending of the scale LinearValueConverter(umin, umax, fmin, fmax) LinearValueConverter2(lo, mi, hi, v1, vm, v2) using 2 segments LogValueConverter(umin, umax, fmin, fmax) ExpValueConverter(umin, umax, fmin, fmax) -- ValueConverters used for accelerometers based on 3 points AccUpConverter(amin, amid, amax, fmin, fmid, fmax) -- curve 0 AccDownConverter(amin, amid, amax, fmin, fmid, fmax) -- curve 1 AccUpDownConverter(amin, amid, amax, fmin, fmid, fmax) -- curve 2 AccDownUpConverter(amin, amid, amax, fmin, fmid, fmax) -- curve 3 -- lists of ZoneControl are used to implement accelerometers metadata for each axes ZoneControl(zone, valueConverter) : a zone with an accelerometer data converter -- ZoneReader are used to implement screencolor metadata ZoneReader(zone, valueConverter) : a zone with a data converter ****************************************************************************************/ #include <float.h> #include <algorithm> // std::max #include <cmath> #include <vector> #include <assert.h> //-------------------------------------------------------------------------------------- // Interpolator(lo,hi,v1,v2) // Maps a value x between lo and hi to a value y between v1 and v2 // y = v1 + (x-lo)/(hi-lo)*(v2-v1) // y = v1 + (x-lo) * coef with coef = (v2-v1)/(hi-lo) // y = v1 + x*coef - lo*coef // y = v1 - lo*coef + x*coef // y = offset + x*coef with offset = v1 - lo*coef //-------------------------------------------------------------------------------------- class Interpolator { private: //-------------------------------------------------------------------------------------- // Range(lo,hi) clip a value between lo and hi //-------------------------------------------------------------------------------------- struct Range { double fLo; double fHi; Range(double x, double y) : fLo(std::min<double>(x,y)), fHi(std::max<double>(x,y)) {} double operator()(double x) { return (x<fLo) ? fLo : (x>fHi) ? fHi : x; } }; Range fRange; double fCoef; double fOffset; public: Interpolator(double lo, double hi, double v1, double v2) : fRange(lo,hi) { if (hi != lo) { // regular case fCoef = (v2-v1)/(hi-lo); fOffset = v1 - lo*fCoef; } else { // degenerate case, avoids division by zero fCoef = 0; fOffset = (v1+v2)/2; } } double operator()(double v) { double x = fRange(v); return fOffset + x*fCoef; } void getLowHigh(double& amin, double& amax) { amin = fRange.fLo; amax = fRange.fHi; } }; //-------------------------------------------------------------------------------------- // Interpolator3pt(lo,mi,hi,v1,vm,v2) // Map values between lo mid hi to values between v1 vm v2 //-------------------------------------------------------------------------------------- class Interpolator3pt { private: Interpolator fSegment1; Interpolator fSegment2; double fMid; public: Interpolator3pt(double lo, double mi, double hi, double v1, double vm, double v2) : fSegment1(lo, mi, v1, vm), fSegment2(mi, hi, vm, v2), fMid(mi) {} double operator()(double x) { return (x < fMid) ? fSegment1(x) : fSegment2(x); } void getMappingValues(double& amin, double& amid, double& amax) { fSegment1.getLowHigh(amin, amid); fSegment2.getLowHigh(amid, amax); } }; //-------------------------------------------------------------------------------------- // Abstract ValueConverter class. Converts values between UI and Faust representations //-------------------------------------------------------------------------------------- class ValueConverter { public: virtual ~ValueConverter() {} virtual double ui2faust(double x) = 0; virtual double faust2ui(double x) = 0; }; //-------------------------------------------------------------------------------------- // A converter than can be updated //-------------------------------------------------------------------------------------- class UpdatableValueConverter : public ValueConverter { protected: bool fActive; public: UpdatableValueConverter():fActive(true) {} virtual ~UpdatableValueConverter() {} virtual void setMappingValues(double amin, double amid, double amax, double min, double init, double max) = 0; virtual void getMappingValues(double& amin, double& amid, double& amax) = 0; void setActive(bool on_off) { fActive = on_off; } bool getActive() { return fActive; } }; //-------------------------------------------------------------------------------------- // Linear conversion between ui and Faust values //-------------------------------------------------------------------------------------- class LinearValueConverter : public ValueConverter { private: Interpolator fUI2F; Interpolator fF2UI; public: LinearValueConverter(double umin, double umax, double fmin, double fmax) : fUI2F(umin,umax,fmin,fmax), fF2UI(fmin,fmax,umin,umax) {} LinearValueConverter() : fUI2F(0.,0.,0.,0.), fF2UI(0.,0.,0.,0.) {} virtual double ui2faust(double x) { return fUI2F(x); } virtual double faust2ui(double x) { return fF2UI(x); } }; //-------------------------------------------------------------------------------------- // Two segments linear conversion between ui and Faust values //-------------------------------------------------------------------------------------- class LinearValueConverter2 : public UpdatableValueConverter { private: Interpolator3pt fUI2F; Interpolator3pt fF2UI; public: LinearValueConverter2(double amin, double amid, double amax, double min, double init, double max) : fUI2F(amin, amid, amax, min, init, max), fF2UI(min, init, max, amin, amid, amax) {} LinearValueConverter2() : fUI2F(0.,0.,0.,0.,0.,0.), fF2UI(0.,0.,0.,0.,0.,0.) {} virtual double ui2faust(double x) { return fUI2F(x); } virtual double faust2ui(double x) { return fF2UI(x); } virtual void setMappingValues(double amin, double amid, double amax, double min, double init, double max) { fUI2F = Interpolator3pt(amin, amid, amax, min, init, max); fF2UI = Interpolator3pt(min, init, max, amin, amid, amax); } virtual void getMappingValues(double& amin, double& amid, double& amax) { fUI2F.getMappingValues(amin, amid, amax); } }; //-------------------------------------------------------------------------------------- // Logarithmic conversion between ui and Faust values //-------------------------------------------------------------------------------------- class LogValueConverter : public LinearValueConverter { public: LogValueConverter(double umin, double umax, double fmin, double fmax) : LinearValueConverter(umin, umax, std::log(std::max<double>(DBL_MIN, fmin)), std::log(std::max<double>(DBL_MIN, fmax))) {} virtual double ui2faust(double x) { return std::exp(LinearValueConverter::ui2faust(x)); } virtual double faust2ui(double x) { return LinearValueConverter::faust2ui(std::log(std::max<double>(x, DBL_MIN))); } }; //-------------------------------------------------------------------------------------- // Exponential conversion between ui and Faust values //-------------------------------------------------------------------------------------- class ExpValueConverter : public LinearValueConverter { public: ExpValueConverter(double umin, double umax, double fmin, double fmax) : LinearValueConverter(umin, umax, std::min<double>(DBL_MAX, std::exp(fmin)), std::min<double>(DBL_MAX, std::exp(fmax))) {} virtual double ui2faust(double x) { return std::log(LinearValueConverter::ui2faust(x)); } virtual double faust2ui(double x) { return LinearValueConverter::faust2ui(std::min<double>(DBL_MAX, std::exp(x))); } }; //-------------------------------------------------------------------------------------- // Convert accelerometer or gyroscope values to Faust values // Using an Up curve (curve 0) //-------------------------------------------------------------------------------------- class AccUpConverter : public UpdatableValueConverter { private: Interpolator3pt fA2F; Interpolator3pt fF2A; public: AccUpConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax) : fA2F(amin,amid,amax,fmin,fmid,fmax), fF2A(fmin,fmid,fmax,amin,amid,amax) {} virtual double ui2faust(double x) { return fA2F(x); } virtual double faust2ui(double x) { return fF2A(x); } virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax) { //__android_log_print(ANDROID_LOG_ERROR, "Faust", "AccUpConverter update %f %f %f %f %f %f", amin,amid,amax,fmin,fmid,fmax); fA2F = Interpolator3pt(amin, amid, amax, fmin, fmid, fmax); fF2A = Interpolator3pt(fmin, fmid, fmax, amin, amid, amax); } virtual void getMappingValues(double& amin, double& amid, double& amax) { fA2F.getMappingValues(amin, amid, amax); } }; //-------------------------------------------------------------------------------------- // Convert accelerometer or gyroscope values to Faust values // Using a Down curve (curve 1) //-------------------------------------------------------------------------------------- class AccDownConverter : public UpdatableValueConverter { private: Interpolator3pt fA2F; Interpolator3pt fF2A; public: AccDownConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax) : fA2F(amin,amid,amax,fmax,fmid,fmin), fF2A(fmin,fmid,fmax,amax,amid,amin) {} virtual double ui2faust(double x) { return fA2F(x); } virtual double faust2ui(double x) { return fF2A(x); } virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax) { //__android_log_print(ANDROID_LOG_ERROR, "Faust", "AccDownConverter update %f %f %f %f %f %f", amin,amid,amax,fmin,fmid,fmax); fA2F = Interpolator3pt(amin, amid, amax, fmax, fmid, fmin); fF2A = Interpolator3pt(fmin, fmid, fmax, amax, amid, amin); } virtual void getMappingValues(double& amin, double& amid, double& amax) { fA2F.getMappingValues(amin, amid, amax); } }; //-------------------------------------------------------------------------------------- // Convert accelerometer or gyroscope values to Faust values // Using an Up-Down curve (curve 2) //-------------------------------------------------------------------------------------- class AccUpDownConverter : public UpdatableValueConverter { private: Interpolator3pt fA2F; Interpolator fF2A; public: AccUpDownConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax) : fA2F(amin,amid,amax,fmin,fmax,fmin), fF2A(fmin,fmax,amin,amax) // Special, pseudo inverse of a non monotonic function {} virtual double ui2faust(double x) { return fA2F(x); } virtual double faust2ui(double x) { return fF2A(x); } virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax) { //__android_log_print(ANDROID_LOG_ERROR, "Faust", "AccUpDownConverter update %f %f %f %f %f %f", amin,amid,amax,fmin,fmid,fmax); fA2F = Interpolator3pt(amin, amid, amax, fmin, fmax, fmin); fF2A = Interpolator(fmin, fmax, amin, amax); } virtual void getMappingValues(double& amin, double& amid, double& amax) { fA2F.getMappingValues(amin, amid, amax); } }; //-------------------------------------------------------------------------------------- // Convert accelerometer or gyroscope values to Faust values // Using a Down-Up curve (curve 3) //-------------------------------------------------------------------------------------- class AccDownUpConverter : public UpdatableValueConverter { private: Interpolator3pt fA2F; Interpolator fF2A; public: AccDownUpConverter(double amin, double amid, double amax, double fmin, double fmid, double fmax) : fA2F(amin,amid,amax,fmax,fmin,fmax), fF2A(fmin,fmax,amin,amax) // Special, pseudo inverse of a non monotonic function {} virtual double ui2faust(double x) { return fA2F(x); } virtual double faust2ui(double x) { return fF2A(x); } virtual void setMappingValues(double amin, double amid, double amax, double fmin, double fmid, double fmax) { //__android_log_print(ANDROID_LOG_ERROR, "Faust", "AccDownUpConverter update %f %f %f %f %f %f", amin,amid,amax,fmin,fmid,fmax); fA2F = Interpolator3pt(amin, amid, amax, fmax, fmin, fmax); fF2A = Interpolator(fmin, fmax, amin, amax); } virtual void getMappingValues(double& amin, double& amid, double& amax) { fA2F.getMappingValues(amin, amid, amax); } }; //-------------------------------------------------------------------------------------- // Base class for ZoneControl //-------------------------------------------------------------------------------------- class ZoneControl { protected: FAUSTFLOAT* fZone; public: ZoneControl(FAUSTFLOAT* zone) : fZone(zone) {} virtual ~ZoneControl() {} virtual void update(double v) {} virtual void setMappingValues(int curve, double amin, double amid, double amax, double min, double init, double max) {} virtual void getMappingValues(double& amin, double& amid, double& amax) {} FAUSTFLOAT* getZone() { return fZone; } virtual void setActive(bool on_off) {} virtual bool getActive() { return false; } virtual int getCurve() { return -1; } }; //-------------------------------------------------------------------------------------- // Useful to implement accelerometers metadata as a list of ZoneControl for each axes //-------------------------------------------------------------------------------------- class ConverterZoneControl : public ZoneControl { protected: ValueConverter* fValueConverter; public: ConverterZoneControl(FAUSTFLOAT* zone, ValueConverter* converter) : ZoneControl(zone), fValueConverter(converter) {} virtual ~ConverterZoneControl() { delete fValueConverter; } // Assuming fValueConverter is not kept elsewhere... virtual void update(double v) { *fZone = fValueConverter->ui2faust(v); } ValueConverter* getConverter() { return fValueConverter; } }; //-------------------------------------------------------------------------------------- // Association of a zone and a four value converter, each one for each possible curve. // Useful to implement accelerometers metadata as a list of ZoneControl for each axes //-------------------------------------------------------------------------------------- class CurveZoneControl : public ZoneControl { private: std::vector<UpdatableValueConverter*> fValueConverters; int fCurve; public: CurveZoneControl(FAUSTFLOAT* zone, int curve, double amin, double amid, double amax, double min, double init, double max) : ZoneControl(zone), fCurve(0) { assert(curve >= 0 && curve <= 3); fValueConverters.push_back(new AccUpConverter(amin, amid, amax, min, init, max)); fValueConverters.push_back(new AccDownConverter(amin, amid, amax, min, init, max)); fValueConverters.push_back(new AccUpDownConverter(amin, amid, amax, min, init, max)); fValueConverters.push_back(new AccDownUpConverter(amin, amid, amax, min, init, max)); fCurve = curve; } virtual ~CurveZoneControl() { std::vector<UpdatableValueConverter*>::iterator it; for (it = fValueConverters.begin(); it != fValueConverters.end(); it++) { delete(*it); } } void update(double v) { if (fValueConverters[fCurve]->getActive()) *fZone = fValueConverters[fCurve]->ui2faust(v); } void setMappingValues(int curve, double amin, double amid, double amax, double min, double init, double max) { fValueConverters[curve]->setMappingValues(amin, amid, amax, min, init, max); fCurve = curve; } void getMappingValues(double& amin, double& amid, double& amax) { fValueConverters[fCurve]->getMappingValues(amin, amid, amax); } void setActive(bool on_off) { std::vector<UpdatableValueConverter*>::iterator it; for (it = fValueConverters.begin(); it != fValueConverters.end(); it++) { (*it)->setActive(on_off); } } int getCurve() { return fCurve; } }; class ZoneReader { private: FAUSTFLOAT* fZone; Interpolator fInterpolator; public: ZoneReader(FAUSTFLOAT* zone, double lo, double hi) : fZone(zone), fInterpolator(lo, hi, 0, 255) {} virtual ~ZoneReader() {} int getValue() { return (fZone != nullptr) ? int(fInterpolator(*fZone)) : 127; } }; #endif /************************** END ValueConverter.h **************************/ /************************** BEGIN MetaDataUI.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef MetaData_UI_H #define MetaData_UI_H #ifndef FAUSTFLOAT #define FAUSTFLOAT float #endif #include <map> #include <set> #include <string> #include <string.h> #include <assert.h> static bool startWith(const std::string& str, const std::string& prefix) { return (str.substr(0, prefix.size()) == prefix); } /** * Convert a dB value into a scale between 0 and 1 (following IEC standard ?) */ static FAUSTFLOAT dB2Scale(FAUSTFLOAT dB) { FAUSTFLOAT scale = FAUSTFLOAT(1.0); /*if (dB < -70.0f) scale = 0.0f; else*/ if (dB < FAUSTFLOAT(-60.0)) scale = (dB + FAUSTFLOAT(70.0)) * FAUSTFLOAT(0.0025); else if (dB < FAUSTFLOAT(-50.0)) scale = (dB + FAUSTFLOAT(60.0)) * FAUSTFLOAT(0.005) + FAUSTFLOAT(0.025); else if (dB < FAUSTFLOAT(-40.0)) scale = (dB + FAUSTFLOAT(50.0)) * FAUSTFLOAT(0.0075) + FAUSTFLOAT(0.075); else if (dB < FAUSTFLOAT(-30.0)) scale = (dB + FAUSTFLOAT(40.0)) * FAUSTFLOAT(0.015) + FAUSTFLOAT(0.15); else if (dB < FAUSTFLOAT(-20.0)) scale = (dB + FAUSTFLOAT(30.0)) * FAUSTFLOAT(0.02) + FAUSTFLOAT(0.3); else if (dB < FAUSTFLOAT(-0.001) || dB > FAUSTFLOAT(0.001)) /* if (dB < 0.0) */ scale = (dB + FAUSTFLOAT(20.0)) * FAUSTFLOAT(0.025) + FAUSTFLOAT(0.5); return scale; } /******************************************************************************* * MetaDataUI : Common class for MetaData handling ******************************************************************************/ //============================= BEGIN GROUP LABEL METADATA=========================== // Unlike widget's label, metadata inside group's label are not extracted directly by // the Faust compiler. Therefore they must be extracted within the architecture file //----------------------------------------------------------------------------------- class MetaDataUI { protected: std::string fGroupTooltip; std::map<FAUSTFLOAT*, FAUSTFLOAT> fGuiSize; // map widget zone with widget size coef std::map<FAUSTFLOAT*, std::string> fTooltip; // map widget zone with tooltip strings std::map<FAUSTFLOAT*, std::string> fUnit; // map widget zone to unit string (i.e. "dB") std::map<FAUSTFLOAT*, std::string> fRadioDescription; // map zone to {'low':440; ...; 'hi':1000.0} std::map<FAUSTFLOAT*, std::string> fMenuDescription; // map zone to {'low':440; ...; 'hi':1000.0} std::set<FAUSTFLOAT*> fKnobSet; // set of widget zone to be knobs std::set<FAUSTFLOAT*> fLedSet; // set of widget zone to be LEDs std::set<FAUSTFLOAT*> fNumSet; // set of widget zone to be numerical bargraphs std::set<FAUSTFLOAT*> fLogSet; // set of widget zone having a log UI scale std::set<FAUSTFLOAT*> fExpSet; // set of widget zone having an exp UI scale std::set<FAUSTFLOAT*> fHiddenSet; // set of hidden widget zone void clearMetadata() { fGuiSize.clear(); fTooltip.clear(); fUnit.clear(); fRadioDescription.clear(); fMenuDescription.clear(); fKnobSet.clear(); fLedSet.clear(); fNumSet.clear(); fLogSet.clear(); fExpSet.clear(); fHiddenSet.clear(); } /** * rmWhiteSpaces(): Remove the leading and trailing white spaces of a string * (but not those in the middle of the string) */ static std::string rmWhiteSpaces(const std::string& s) { size_t i = s.find_first_not_of(" \t"); size_t j = s.find_last_not_of(" \t"); if ((i != std::string::npos) && (j != std::string::npos)) { return s.substr(i, 1+j-i); } else { return ""; } } /** * Format tooltip string by replacing some white spaces by * return characters so that line width doesn't exceed n. * Limitation : long words exceeding n are not cut */ std::string formatTooltip(int n, const std::string& tt) { std::string ss = tt; // ss string we are going to format int lws = 0; // last white space encountered int lri = 0; // last return inserted for (int i = 0; i < (int)tt.size(); i++) { if (tt[i] == ' ') lws = i; if (((i-lri) >= n) && (lws > lri)) { // insert return here ss[lws] = '\n'; lri = lws; } } return ss; } public: virtual ~MetaDataUI() {} enum Scale { kLin, kLog, kExp }; Scale getScale(FAUSTFLOAT* zone) { if (fLogSet.count(zone) > 0) return kLog; if (fExpSet.count(zone) > 0) return kExp; return kLin; } bool isKnob(FAUSTFLOAT* zone) { return fKnobSet.count(zone) > 0; } bool isRadio(FAUSTFLOAT* zone) { return fRadioDescription.count(zone) > 0; } bool isMenu(FAUSTFLOAT* zone) { return fMenuDescription.count(zone) > 0; } bool isLed(FAUSTFLOAT* zone) { return fLedSet.count(zone) > 0; } bool isNumerical(FAUSTFLOAT* zone) { return fNumSet.count(zone) > 0; } bool isHidden(FAUSTFLOAT* zone) { return fHiddenSet.count(zone) > 0; } /** * Extracts metadata from a label : 'vol [unit: dB]' -> 'vol' + metadata(unit=dB) */ static void extractMetadata(const std::string& fulllabel, std::string& label, std::map<std::string, std::string>& metadata) { enum {kLabel, kEscape1, kEscape2, kEscape3, kKey, kValue}; int state = kLabel; int deep = 0; std::string key, value; for (unsigned int i = 0; i < fulllabel.size(); i++) { char c = fulllabel[i]; switch (state) { case kLabel : assert(deep == 0); switch (c) { case '\\' : state = kEscape1; break; case '[' : state = kKey; deep++; break; default : label += c; } break; case kEscape1: label += c; state = kLabel; break; case kEscape2: key += c; state = kKey; break; case kEscape3: value += c; state = kValue; break; case kKey: assert(deep > 0); switch (c) { case '\\': state = kEscape2; break; case '[': deep++; key += c; break; case ':': if (deep == 1) { state = kValue; } else { key += c; } break; case ']': deep--; if (deep < 1) { metadata[rmWhiteSpaces(key)] = ""; state = kLabel; key=""; value=""; } else { key += c; } break; default : key += c; } break; case kValue: assert(deep > 0); switch (c) { case '\\': state = kEscape3; break; case '[': deep++; value += c; break; case ']': deep--; if (deep < 1) { metadata[rmWhiteSpaces(key)] = rmWhiteSpaces(value); state = kLabel; key = ""; value = ""; } else { value += c; } break; default : value += c; } break; default: std::cerr << "ERROR unrecognized state " << state << std::endl; } } label = rmWhiteSpaces(label); } /** * Analyses the widget zone metadata declarations and takes appropriate actions */ void declare(FAUSTFLOAT* zone, const char* key, const char* value) { if (zone == 0) { // special zone 0 means group metadata if (strcmp(key, "tooltip") == 0) { // only group tooltip are currently implemented fGroupTooltip = formatTooltip(30, value); } else if (strcmp(key, "hidden") == 0) { fHiddenSet.insert(zone); } } else { if (strcmp(key, "size") == 0) { fGuiSize[zone] = atof(value); } else if (strcmp(key, "tooltip") == 0) { fTooltip[zone] = formatTooltip(30, value); } else if (strcmp(key, "unit") == 0) { fUnit[zone] = value; } else if (strcmp(key, "hidden") == 0) { fHiddenSet.insert(zone); } else if (strcmp(key, "scale") == 0) { if (strcmp(value, "log") == 0) { fLogSet.insert(zone); } else if (strcmp(value, "exp") == 0) { fExpSet.insert(zone); } } else if (strcmp(key, "style") == 0) { if (strcmp(value, "knob") == 0) { fKnobSet.insert(zone); } else if (strcmp(value, "led") == 0) { fLedSet.insert(zone); } else if (strcmp(value, "numerical") == 0) { fNumSet.insert(zone); } else { const char* p = value; if (parseWord(p, "radio")) { fRadioDescription[zone] = std::string(p); } else if (parseWord(p, "menu")) { fMenuDescription[zone] = std::string(p); } } } } } }; #endif /************************** END MetaDataUI.h **************************/ /************************** BEGIN ring-buffer.h **************************/ /* Copyright (C) 2000 Paul Davis Copyright (C) 2003 Rohan Drape Copyright (C) 2016 GRAME (renaming for internal use) This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser 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. ISO/POSIX C version of Paul Davis's lock free ringbuffer C++ code. This is safe for the case of one read thread and one write thread. */ #ifndef __ring_buffer__ #define __ring_buffer__ #include <stdlib.h> #include <string.h> #ifdef WIN32 # pragma warning (disable: 4334) #else # pragma GCC diagnostic ignored "-Wunused-function" #endif typedef struct { char *buf; size_t len; } ringbuffer_data_t; typedef struct { char *buf; volatile size_t write_ptr; volatile size_t read_ptr; size_t size; size_t size_mask; int mlocked; } ringbuffer_t; static ringbuffer_t *ringbuffer_create(size_t sz); static void ringbuffer_free(ringbuffer_t *rb); static void ringbuffer_get_read_vector(const ringbuffer_t *rb, ringbuffer_data_t *vec); static void ringbuffer_get_write_vector(const ringbuffer_t *rb, ringbuffer_data_t *vec); static size_t ringbuffer_read(ringbuffer_t *rb, char *dest, size_t cnt); static size_t ringbuffer_peek(ringbuffer_t *rb, char *dest, size_t cnt); static void ringbuffer_read_advance(ringbuffer_t *rb, size_t cnt); static size_t ringbuffer_read_space(const ringbuffer_t *rb); static int ringbuffer_mlock(ringbuffer_t *rb); static void ringbuffer_reset(ringbuffer_t *rb); static void ringbuffer_reset_size (ringbuffer_t * rb, size_t sz); static size_t ringbuffer_write(ringbuffer_t *rb, const char *src, size_t cnt); static void ringbuffer_write_advance(ringbuffer_t *rb, size_t cnt); static size_t ringbuffer_write_space(const ringbuffer_t *rb); /* Create a new ringbuffer to hold at least `sz' bytes of data. The actual buffer size is rounded up to the next power of two. */ static ringbuffer_t * ringbuffer_create (size_t sz) { size_t power_of_two; ringbuffer_t *rb; if ((rb = (ringbuffer_t *) malloc (sizeof (ringbuffer_t))) == NULL) { return NULL; } for (power_of_two = 1u; 1u << power_of_two < sz; power_of_two++); rb->size = 1u << power_of_two; rb->size_mask = rb->size; rb->size_mask -= 1; rb->write_ptr = 0; rb->read_ptr = 0; if ((rb->buf = (char *) malloc (rb->size)) == NULL) { free (rb); return NULL; } rb->mlocked = 0; return rb; } /* Free all data associated with the ringbuffer `rb'. */ static void ringbuffer_free (ringbuffer_t * rb) { #ifdef USE_MLOCK if (rb->mlocked) { munlock (rb->buf, rb->size); } #endif /* USE_MLOCK */ free (rb->buf); free (rb); } /* Lock the data block of `rb' using the system call 'mlock'. */ static int ringbuffer_mlock (ringbuffer_t * rb) { #ifdef USE_MLOCK if (mlock (rb->buf, rb->size)) { return -1; } #endif /* USE_MLOCK */ rb->mlocked = 1; return 0; } /* Reset the read and write pointers to zero. This is not thread safe. */ static void ringbuffer_reset (ringbuffer_t * rb) { rb->read_ptr = 0; rb->write_ptr = 0; memset(rb->buf, 0, rb->size); } /* Reset the read and write pointers to zero. This is not thread safe. */ static void ringbuffer_reset_size (ringbuffer_t * rb, size_t sz) { rb->size = sz; rb->size_mask = rb->size; rb->size_mask -= 1; rb->read_ptr = 0; rb->write_ptr = 0; } /* Return the number of bytes available for reading. This is the number of bytes in front of the read pointer and behind the write pointer. */ static size_t ringbuffer_read_space (const ringbuffer_t * rb) { size_t w, r; w = rb->write_ptr; r = rb->read_ptr; if (w > r) { return w - r; } else { return (w - r + rb->size) & rb->size_mask; } } /* Return the number of bytes available for writing. This is the number of bytes in front of the write pointer and behind the read pointer. */ static size_t ringbuffer_write_space (const ringbuffer_t * rb) { size_t w, r; w = rb->write_ptr; r = rb->read_ptr; if (w > r) { return ((r - w + rb->size) & rb->size_mask) - 1; } else if (w < r) { return (r - w) - 1; } else { return rb->size - 1; } } /* The copying data reader. Copy at most `cnt' bytes from `rb' to `dest'. Returns the actual number of bytes copied. */ static size_t ringbuffer_read (ringbuffer_t * rb, char *dest, size_t cnt) { size_t free_cnt; size_t cnt2; size_t to_read; size_t n1, n2; if ((free_cnt = ringbuffer_read_space (rb)) == 0) { return 0; } to_read = cnt > free_cnt ? free_cnt : cnt; cnt2 = rb->read_ptr + to_read; if (cnt2 > rb->size) { n1 = rb->size - rb->read_ptr; n2 = cnt2 & rb->size_mask; } else { n1 = to_read; n2 = 0; } memcpy (dest, &(rb->buf[rb->read_ptr]), n1); rb->read_ptr = (rb->read_ptr + n1) & rb->size_mask; if (n2) { memcpy (dest + n1, &(rb->buf[rb->read_ptr]), n2); rb->read_ptr = (rb->read_ptr + n2) & rb->size_mask; } return to_read; } /* The copying data reader w/o read pointer advance. Copy at most `cnt' bytes from `rb' to `dest'. Returns the actual number of bytes copied. */ static size_t ringbuffer_peek (ringbuffer_t * rb, char *dest, size_t cnt) { size_t free_cnt; size_t cnt2; size_t to_read; size_t n1, n2; size_t tmp_read_ptr; tmp_read_ptr = rb->read_ptr; if ((free_cnt = ringbuffer_read_space (rb)) == 0) { return 0; } to_read = cnt > free_cnt ? free_cnt : cnt; cnt2 = tmp_read_ptr + to_read; if (cnt2 > rb->size) { n1 = rb->size - tmp_read_ptr; n2 = cnt2 & rb->size_mask; } else { n1 = to_read; n2 = 0; } memcpy (dest, &(rb->buf[tmp_read_ptr]), n1); tmp_read_ptr = (tmp_read_ptr + n1) & rb->size_mask; if (n2) { memcpy (dest + n1, &(rb->buf[tmp_read_ptr]), n2); } return to_read; } /* The copying data writer. Copy at most `cnt' bytes to `rb' from `src'. Returns the actual number of bytes copied. */ static size_t ringbuffer_write (ringbuffer_t * rb, const char *src, size_t cnt) { size_t free_cnt; size_t cnt2; size_t to_write; size_t n1, n2; if ((free_cnt = ringbuffer_write_space (rb)) == 0) { return 0; } to_write = cnt > free_cnt ? free_cnt : cnt; cnt2 = rb->write_ptr + to_write; if (cnt2 > rb->size) { n1 = rb->size - rb->write_ptr; n2 = cnt2 & rb->size_mask; } else { n1 = to_write; n2 = 0; } memcpy (&(rb->buf[rb->write_ptr]), src, n1); rb->write_ptr = (rb->write_ptr + n1) & rb->size_mask; if (n2) { memcpy (&(rb->buf[rb->write_ptr]), src + n1, n2); rb->write_ptr = (rb->write_ptr + n2) & rb->size_mask; } return to_write; } /* Advance the read pointer `cnt' places. */ static void ringbuffer_read_advance (ringbuffer_t * rb, size_t cnt) { size_t tmp = (rb->read_ptr + cnt) & rb->size_mask; rb->read_ptr = tmp; } /* Advance the write pointer `cnt' places. */ static void ringbuffer_write_advance (ringbuffer_t * rb, size_t cnt) { size_t tmp = (rb->write_ptr + cnt) & rb->size_mask; rb->write_ptr = tmp; } /* The non-copying data reader. `vec' is an array of two places. Set the values at `vec' to hold the current readable data at `rb'. If the readable data is in one segment the second segment has zero length. */ static void ringbuffer_get_read_vector (const ringbuffer_t * rb, ringbuffer_data_t * vec) { size_t free_cnt; size_t cnt2; size_t w, r; w = rb->write_ptr; r = rb->read_ptr; if (w > r) { free_cnt = w - r; } else { free_cnt = (w - r + rb->size) & rb->size_mask; } cnt2 = r + free_cnt; if (cnt2 > rb->size) { /* Two part vector: the rest of the buffer after the current write ptr, plus some from the start of the buffer. */ vec[0].buf = &(rb->buf[r]); vec[0].len = rb->size - r; vec[1].buf = rb->buf; vec[1].len = cnt2 & rb->size_mask; } else { /* Single part vector: just the rest of the buffer */ vec[0].buf = &(rb->buf[r]); vec[0].len = free_cnt; vec[1].len = 0; } } /* The non-copying data writer. `vec' is an array of two places. Set the values at `vec' to hold the current writeable data at `rb'. If the writeable data is in one segment the second segment has zero length. */ static void ringbuffer_get_write_vector (const ringbuffer_t * rb, ringbuffer_data_t * vec) { size_t free_cnt; size_t cnt2; size_t w, r; w = rb->write_ptr; r = rb->read_ptr; if (w > r) { free_cnt = ((r - w + rb->size) & rb->size_mask) - 1; } else if (w < r) { free_cnt = (r - w) - 1; } else { free_cnt = rb->size - 1; } cnt2 = w + free_cnt; if (cnt2 > rb->size) { /* Two part vector: the rest of the buffer after the current write ptr, plus some from the start of the buffer. */ vec[0].buf = &(rb->buf[w]); vec[0].len = rb->size - w; vec[1].buf = rb->buf; vec[1].len = cnt2 & rb->size_mask; } else { vec[0].buf = &(rb->buf[w]); vec[0].len = free_cnt; vec[1].len = 0; } } #endif // __ring_buffer__ /************************** END ring-buffer.h **************************/ /******************************************************************************* * GUI : Abstract Graphic User Interface * Provides additional mechanisms to synchronize widgets and zones. Widgets * should both reflect the value of a zone and allow to change this value. ******************************************************************************/ class uiItem; class GUI; struct clist; typedef void (*uiCallback)(FAUSTFLOAT val, void* data); struct uiItemBase { uiItemBase(GUI* ui, FAUSTFLOAT* zone) { assert(ui); assert(zone); } virtual ~uiItemBase() {} virtual void modifyZone(FAUSTFLOAT v) = 0; virtual void modifyZone(double date, FAUSTFLOAT v) {} virtual double cache() = 0; virtual void reflectZone() = 0; }; // Declared as 'static' to avoid code duplication at link time static void deleteClist(clist* cl); struct clist : public std::list<uiItemBase*> { virtual ~clist() { deleteClist(this); } }; static void createUiCallbackItem(GUI* ui, FAUSTFLOAT* zone, uiCallback foo, void* data); typedef std::map<FAUSTFLOAT*, clist*> zmap; typedef std::map<FAUSTFLOAT*, ringbuffer_t*> ztimedmap; class GUI : public UI { private: static std::list<GUI*> fGuiList; zmap fZoneMap; bool fStopped; public: GUI():fStopped(false) { fGuiList.push_back(this); } virtual ~GUI() { // delete all items for (auto& it : fZoneMap) { delete it.second; } // suppress 'this' in static fGuiList fGuiList.remove(this); } // -- registerZone(z,c) : zone management void registerZone(FAUSTFLOAT* z, uiItemBase* c) { if (fZoneMap.find(z) == fZoneMap.end()) fZoneMap[z] = new clist(); fZoneMap[z]->push_back(c); } void updateZone(FAUSTFLOAT* z) { FAUSTFLOAT v = *z; clist* cl = fZoneMap[z]; for (auto& c : *cl) { if (c->cache() != v) c->reflectZone(); } } void updateAllZones() { for (auto& m : fZoneMap) { updateZone(m.first); } } static void updateAllGuis() { for (auto& g : fGuiList) { g->updateAllZones(); } } static void runAllGuis() { for (auto& g : fGuiList) { g->run(); } } void addCallback(FAUSTFLOAT* zone, uiCallback foo, void* data) { createUiCallbackItem(this, zone, foo, data); } virtual void show() {}; virtual bool run() { return false; }; virtual void stop() { fStopped = true; } bool stopped() { return fStopped; } // -- widget's layouts virtual void openTabBox(const char* label) {}; virtual void openHorizontalBox(const char* label) {} virtual void openVerticalBox(const char* label) {} virtual void closeBox() {} // -- active widgets virtual void addButton(const char* label, FAUSTFLOAT* zone) {} virtual void addCheckButton(const char* label, FAUSTFLOAT* zone) {} virtual void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) {} virtual void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) {} virtual void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) {} // -- passive widgets virtual void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) {} virtual void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) {} // -- soundfiles virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) {} // -- metadata declarations virtual void declare(FAUSTFLOAT*, const char*, const char*) {} // Static global for timed zones, shared between all UI that will set timed values static ztimedmap gTimedZoneMap; }; /** * User Interface Item: abstract definition */ template <typename REAL> class uiTypedItem : public uiItemBase { protected: GUI* fGUI; REAL* fZone; REAL fCache; uiTypedItem(GUI* ui, REAL* zone):uiItemBase(ui, static_cast<FAUSTFLOAT*>(zone)), fGUI(ui), fZone(zone), fCache(REAL(-123456.654321)) { ui->registerZone(zone, this); } public: virtual ~uiTypedItem() {} void modifyZone(REAL v) { fCache = v; if (*fZone != v) { *fZone = v; fGUI->updateZone(fZone); } } double cache() { return fCache; } }; class uiItem : public uiTypedItem<FAUSTFLOAT> { protected: uiItem(GUI* ui, FAUSTFLOAT* zone):uiTypedItem<FAUSTFLOAT>(ui, zone) {} public: virtual ~uiItem() {} void modifyZone(FAUSTFLOAT v) { fCache = v; if (*fZone != v) { *fZone = v; fGUI->updateZone(fZone); } } }; /** * Base class for items with a converter */ struct uiConverter { ValueConverter* fConverter; uiConverter(MetaDataUI::Scale scale, FAUSTFLOAT umin, FAUSTFLOAT umax, FAUSTFLOAT fmin, FAUSTFLOAT fmax) { // Select appropriate converter according to scale mode if (scale == MetaDataUI::kLog) { fConverter = new LogValueConverter(umin, umax, fmin, fmax); } else if (scale == MetaDataUI::kExp) { fConverter = new ExpValueConverter(umin, umax, fmin, fmax); } else { fConverter = new LinearValueConverter(umin, umax, fmin, fmax); } } virtual ~uiConverter() { delete fConverter; } }; /** * User Interface item owned (and so deleted) by external code */ class uiOwnedItem : public uiItem { protected: uiOwnedItem(GUI* ui, FAUSTFLOAT* zone):uiItem(ui, zone) {} public: virtual ~uiOwnedItem() {} virtual void reflectZone() {} }; /** * Callback Item */ class uiCallbackItem : public uiItem { protected: uiCallback fCallback; void* fData; public: uiCallbackItem(GUI* ui, FAUSTFLOAT* zone, uiCallback foo, void* data) : uiItem(ui, zone), fCallback(foo), fData(data) {} virtual void reflectZone() { FAUSTFLOAT v = *fZone; fCache = v; fCallback(v, fData); } }; /** * For timestamped control */ struct DatedControl { double fDate; FAUSTFLOAT fValue; DatedControl(double d = 0., FAUSTFLOAT v = FAUSTFLOAT(0)):fDate(d), fValue(v) {} }; /** * Base class for timed items */ class uiTimedItem : public uiItem { protected: bool fDelete; public: using uiItem::modifyZone; uiTimedItem(GUI* ui, FAUSTFLOAT* zone):uiItem(ui, zone) { if (GUI::gTimedZoneMap.find(fZone) == GUI::gTimedZoneMap.end()) { GUI::gTimedZoneMap[fZone] = ringbuffer_create(8192); fDelete = true; } else { fDelete = false; } } virtual ~uiTimedItem() { ztimedmap::iterator it; if (fDelete && ((it = GUI::gTimedZoneMap.find(fZone)) != GUI::gTimedZoneMap.end())) { ringbuffer_free((*it).second); GUI::gTimedZoneMap.erase(it); } } virtual void modifyZone(double date, FAUSTFLOAT v) { size_t res; DatedControl dated_val(date, v); if ((res = ringbuffer_write(GUI::gTimedZoneMap[fZone], (const char*)&dated_val, sizeof(DatedControl))) != sizeof(DatedControl)) { std::cerr << "ringbuffer_write error DatedControl" << std::endl; } } }; /** * Allows to group a set of zones */ class uiGroupItem : public uiItem { protected: std::vector<FAUSTFLOAT*> fZoneMap; public: uiGroupItem(GUI* ui, FAUSTFLOAT* zone):uiItem(ui, zone) {} virtual ~uiGroupItem() {} virtual void reflectZone() { FAUSTFLOAT v = *fZone; fCache = v; // Update all zones of the same group for (auto& it : fZoneMap) { *it = v; } } void addZone(FAUSTFLOAT* zone) { fZoneMap.push_back(zone); } }; // Can not be defined as method in the classes static void createUiCallbackItem(GUI* ui, FAUSTFLOAT* zone, uiCallback foo, void* data) { new uiCallbackItem(ui, zone, foo, data); } static void deleteClist(clist* cl) { for (auto& it : *cl) { uiOwnedItem* owned = dynamic_cast<uiOwnedItem*>(it); // owned items are deleted by external code if (!owned) { delete it; } } } #endif /************************** END GUI.h **************************/ /* Copyright (C) 2011 Grame This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France [email protected] */ #ifndef __RootNode__ #define __RootNode__ #include <map> #include <string> #include <vector> /************************** BEGIN JSONUI.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef FAUST_JSONUI_H #define FAUST_JSONUI_H #include <vector> #include <map> #include <string> #include <iostream> #include <iomanip> #include <sstream> #include <algorithm> /******************************************************************************* * JSONUI : Faust User Interface * This class produce a complete JSON decription of the DSP instance. ******************************************************************************/ template <typename REAL> class JSONUIReal : public PathBuilder, public Meta, public UIReal<REAL> { protected: std::stringstream fUI; std::stringstream fMeta; std::vector<std::pair <std::string, std::string> > fMetaAux; std::string fVersion; // Compiler version std::string fCompileOptions; // Compilation options std::vector<std::string> fLibraryList; std::vector<std::string> fIncludePathnames; std::string fName; std::string fFileName; std::string fExpandedCode; std::string fSHAKey; int fDSPSize; // In bytes std::map<std::string, int> fPathTable; bool fExtended; char fCloseUIPar; char fCloseMetaPar; int fTab; int fInputs, fOutputs, fSRIndex; void tab(int n, std::ostream& fout) { fout << '\n'; while (n-- > 0) { fout << '\t'; } } std::string flatten(const std::string& src) { std::string dst; for (size_t i = 0; i < src.size(); i++) { switch (src[i]) { case '\n': case '\t': break; default: dst += src[i]; break; } } return dst; } void addMeta(int tab_val, bool quote = true) { if (fMetaAux.size() > 0) { tab(tab_val, fUI); fUI << "\"meta\": ["; std::string sep = ""; for (size_t i = 0; i < fMetaAux.size(); i++) { fUI << sep; tab(tab_val + 1, fUI); fUI << "{ \"" << fMetaAux[i].first << "\": \"" << fMetaAux[i].second << "\" }"; sep = ","; } tab(tab_val, fUI); fUI << ((quote) ? "],": "]"); fMetaAux.clear(); } } int getAddressIndex(const std::string& path) { return (fPathTable.find(path) != fPathTable.end()) ? fPathTable[path] : -1; } public: JSONUIReal(const std::string& name, const std::string& filename, int inputs, int outputs, int sr_index, const std::string& sha_key, const std::string& dsp_code, const std::string& version, const std::string& compile_options, const std::vector<std::string>& library_list, const std::vector<std::string>& include_pathnames, int size, const std::map<std::string, int>& path_table) { init(name, filename, inputs, outputs, sr_index, sha_key, dsp_code, version, compile_options, library_list, include_pathnames, size, path_table); } JSONUIReal(const std::string& name, const std::string& filename, int inputs, int outputs) { init(name, filename, inputs, outputs, -1, "", "", "", "", std::vector<std::string>(), std::vector<std::string>(), -1, std::map<std::string, int>()); } JSONUIReal(int inputs, int outputs) { init("", "", inputs, outputs, -1, "", "","", "", std::vector<std::string>(), std::vector<std::string>(), -1, std::map<std::string, int>()); } JSONUIReal() { init("", "", -1, -1, -1, "", "", "", "", std::vector<std::string>(), std::vector<std::string>(), -1, std::map<std::string, int>()); } virtual ~JSONUIReal() {} void setInputs(int inputs) { fInputs = inputs; } void setOutputs(int outputs) { fOutputs = outputs; } void setSRIndex(int sr_index) { fSRIndex = sr_index; } // Init may be called multiple times so fMeta and fUI are reinitialized void init(const std::string& name, const std::string& filename, int inputs, int outputs, int sr_index, const std::string& sha_key, const std::string& dsp_code, const std::string& version, const std::string& compile_options, const std::vector<std::string>& library_list, const std::vector<std::string>& include_pathnames, int size, const std::map<std::string, int>& path_table, bool extended = false) { fTab = 1; fExtended = extended; if (fExtended) { fUI << std::setprecision(std::numeric_limits<REAL>::max_digits10); fMeta << std::setprecision(std::numeric_limits<REAL>::max_digits10); } // Start Meta generation fMeta.str(""); tab(fTab, fMeta); fMeta << "\"meta\": ["; fCloseMetaPar = ' '; // Start UI generation fUI.str(""); tab(fTab, fUI); fUI << "\"ui\": ["; fCloseUIPar = ' '; fTab += 1; fName = name; fFileName = filename; fInputs = inputs; fOutputs = outputs; fSRIndex = sr_index; fExpandedCode = dsp_code; fSHAKey = sha_key; fDSPSize = size; fPathTable = path_table; fVersion = version; fCompileOptions = compile_options; fLibraryList = library_list; fIncludePathnames = include_pathnames; } // -- widget's layouts virtual void openGenericGroup(const char* label, const char* name) { pushLabel(label); fUI << fCloseUIPar; tab(fTab, fUI); fUI << "{"; fTab += 1; tab(fTab, fUI); fUI << "\"type\": \"" << name << "\","; tab(fTab, fUI); fUI << "\"label\": \"" << label << "\","; addMeta(fTab); tab(fTab, fUI); fUI << "\"items\": ["; fCloseUIPar = ' '; fTab += 1; } virtual void openTabBox(const char* label) { openGenericGroup(label, "tgroup"); } virtual void openHorizontalBox(const char* label) { openGenericGroup(label, "hgroup"); } virtual void openVerticalBox(const char* label) { openGenericGroup(label, "vgroup"); } virtual void closeBox() { popLabel(); fTab -= 1; tab(fTab, fUI); fUI << "]"; fTab -= 1; tab(fTab, fUI); fUI << "}"; fCloseUIPar = ','; } // -- active widgets virtual void addGenericButton(const char* label, const char* name) { std::string path = buildPath(label); fUI << fCloseUIPar; tab(fTab, fUI); fUI << "{"; fTab += 1; tab(fTab, fUI); fUI << "\"type\": \"" << name << "\","; tab(fTab, fUI); fUI << "\"label\": \"" << label << "\","; if (fPathTable.size() > 0) { tab(fTab, fUI); fUI << "\"address\": \"" << path << "\","; tab(fTab, fUI); fUI << "\"index\": " << getAddressIndex(path) << ((fMetaAux.size() > 0) ? "," : ""); } else { tab(fTab, fUI); fUI << "\"address\": \"" << path << "\"" << ((fMetaAux.size() > 0) ? "," : ""); } addMeta(fTab, false); fTab -= 1; tab(fTab, fUI); fUI << "}"; fCloseUIPar = ','; } virtual void addButton(const char* label, REAL* zone) { addGenericButton(label, "button"); } virtual void addCheckButton(const char* label, REAL* zone) { addGenericButton(label, "checkbox"); } virtual void addGenericEntry(const char* label, const char* name, REAL init, REAL min, REAL max, REAL step) { std::string path = buildPath(label); fUI << fCloseUIPar; tab(fTab, fUI); fUI << "{"; fTab += 1; tab(fTab, fUI); fUI << "\"type\": \"" << name << "\","; tab(fTab, fUI); fUI << "\"label\": \"" << label << "\","; tab(fTab, fUI); fUI << "\"address\": \"" << path << "\","; if (fPathTable.size() > 0) { tab(fTab, fUI); fUI << "\"index\": " << getAddressIndex(path) << ","; } addMeta(fTab); tab(fTab, fUI); fUI << "\"init\": " << init << ","; tab(fTab, fUI); fUI << "\"min\": " << min << ","; tab(fTab, fUI); fUI << "\"max\": " << max << ","; tab(fTab, fUI); fUI << "\"step\": " << step; fTab -= 1; tab(fTab, fUI); fUI << "}"; fCloseUIPar = ','; } virtual void addVerticalSlider(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) { addGenericEntry(label, "vslider", init, min, max, step); } virtual void addHorizontalSlider(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) { addGenericEntry(label, "hslider", init, min, max, step); } virtual void addNumEntry(const char* label, REAL* zone, REAL init, REAL min, REAL max, REAL step) { addGenericEntry(label, "nentry", init, min, max, step); } // -- passive widgets virtual void addGenericBargraph(const char* label, const char* name, REAL min, REAL max) { std::string path = buildPath(label); fUI << fCloseUIPar; tab(fTab, fUI); fUI << "{"; fTab += 1; tab(fTab, fUI); fUI << "\"type\": \"" << name << "\","; tab(fTab, fUI); fUI << "\"label\": \"" << label << "\","; tab(fTab, fUI); fUI << "\"address\": \"" << path << "\","; if (fPathTable.size() > 0) { tab(fTab, fUI); fUI << "\"index\": " << getAddressIndex(path) << ","; } addMeta(fTab); tab(fTab, fUI); fUI << "\"min\": " << min << ","; tab(fTab, fUI); fUI << "\"max\": " << max; fTab -= 1; tab(fTab, fUI); fUI << "}"; fCloseUIPar = ','; } virtual void addHorizontalBargraph(const char* label, REAL* zone, REAL min, REAL max) { addGenericBargraph(label, "hbargraph", min, max); } virtual void addVerticalBargraph(const char* label, REAL* zone, REAL min, REAL max) { addGenericBargraph(label, "vbargraph", min, max); } virtual void addSoundfile(const char* label, const char* url, Soundfile** zone) { std::string path = buildPath(label); fUI << fCloseUIPar; tab(fTab, fUI); fUI << "{"; fTab += 1; tab(fTab, fUI); fUI << "\"type\": \"" << "soundfile" << "\","; tab(fTab, fUI); fUI << "\"label\": \"" << label << "\"" << ","; tab(fTab, fUI); fUI << "\"url\": \"" << url << "\"" << ","; tab(fTab, fUI); fUI << "\"address\": \"" << path << "\"" << ((fPathTable.size() > 0) ? "," : ""); if (fPathTable.size() > 0) { tab(fTab, fUI); fUI << "\"index\": " << getAddressIndex(path); } fTab -= 1; tab(fTab, fUI); fUI << "}"; fCloseUIPar = ','; } // -- metadata declarations virtual void declare(REAL* zone, const char* key, const char* val) { fMetaAux.push_back(std::make_pair(key, val)); } // Meta interface virtual void declare(const char* key, const char* value) { fMeta << fCloseMetaPar; // fName found in metadata if ((strcmp(key, "name") == 0) && (fName == "")) fName = value; // fFileName found in metadata if ((strcmp(key, "filename") == 0) && (fFileName == "")) fFileName = value; tab(fTab, fMeta); fMeta << "{ " << "\"" << key << "\"" << ": " << "\"" << value << "\" }"; fCloseMetaPar = ','; } std::string JSON(bool flat = false) { fTab = 0; std::stringstream JSON; if (fExtended) { JSON << std::setprecision(std::numeric_limits<REAL>::max_digits10); } JSON << "{"; fTab += 1; tab(fTab, JSON); JSON << "\"name\": \"" << fName << "\","; tab(fTab, JSON); JSON << "\"filename\": \"" << fFileName << "\","; if (fVersion != "") { tab(fTab, JSON); JSON << "\"version\": \"" << fVersion << "\","; } if (fCompileOptions != "") { tab(fTab, JSON); JSON << "\"compile_options\": \"" << fCompileOptions << "\","; } if (fLibraryList.size() > 0) { tab(fTab, JSON); JSON << "\"library_list\": ["; for (size_t i = 0; i < fLibraryList.size(); i++) { JSON << "\"" << fLibraryList[i] << "\""; if (i < (fLibraryList.size() - 1)) JSON << ","; } JSON << "],"; } if (fIncludePathnames.size() > 0) { tab(fTab, JSON); JSON << "\"include_pathnames\": ["; for (size_t i = 0; i < fIncludePathnames.size(); i++) { JSON << "\"" << fIncludePathnames[i] << "\""; if (i < (fIncludePathnames.size() - 1)) JSON << ","; } JSON << "],"; } if (fDSPSize != -1) { tab(fTab, JSON); JSON << "\"size\": " << fDSPSize << ","; } if (fSHAKey != "") { tab(fTab, JSON); JSON << "\"sha_key\": \"" << fSHAKey << "\","; } if (fExpandedCode != "") { tab(fTab, JSON); JSON << "\"code\": \"" << fExpandedCode << "\","; } tab(fTab, JSON); JSON << "\"inputs\": " << fInputs << ","; tab(fTab, JSON); JSON << "\"outputs\": " << fOutputs << ","; if (fSRIndex != -1) { tab(fTab, JSON); JSON << "\"sr_index\": " << fSRIndex << ","; } tab(fTab, fMeta); fMeta << "],"; tab(fTab, fUI); fUI << "]"; fTab -= 1; if (fCloseMetaPar == ',') { // If "declare" has been called, fCloseMetaPar state is now ',' JSON << fMeta.str() << fUI.str(); } else { JSON << fUI.str(); } tab(fTab, JSON); JSON << "}"; return (flat) ? flatten(JSON.str()) : JSON.str(); } }; // Externally available class using FAUSTFLOAT struct JSONUI : public JSONUIReal<FAUSTFLOAT>, public UI { JSONUI(const std::string& name, const std::string& filename, int inputs, int outputs, int sr_index, const std::string& sha_key, const std::string& dsp_code, const std::string& version, const std::string& compile_options, const std::vector<std::string>& library_list, const std::vector<std::string>& include_pathnames, int size, const std::map<std::string, int>& path_table): JSONUIReal<FAUSTFLOAT>(name, filename, inputs, outputs, sr_index, sha_key, dsp_code, version, compile_options, library_list, include_pathnames, size, path_table) {} JSONUI(const std::string& name, const std::string& filename, int inputs, int outputs): JSONUIReal<FAUSTFLOAT>(name, filename, inputs, outputs) {} JSONUI(int inputs, int outputs):JSONUIReal<FAUSTFLOAT>(inputs, outputs) {} JSONUI():JSONUIReal<FAUSTFLOAT>() {} virtual void openTabBox(const char* label) { JSONUIReal<FAUSTFLOAT>::openTabBox(label); } virtual void openHorizontalBox(const char* label) { JSONUIReal<FAUSTFLOAT>::openHorizontalBox(label); } virtual void openVerticalBox(const char* label) { JSONUIReal<FAUSTFLOAT>::openVerticalBox(label); } virtual void closeBox() { JSONUIReal<FAUSTFLOAT>::closeBox(); } // -- active widgets virtual void addButton(const char* label, FAUSTFLOAT* zone) { JSONUIReal<FAUSTFLOAT>::addButton(label, zone); } virtual void addCheckButton(const char* label, FAUSTFLOAT* zone) { JSONUIReal<FAUSTFLOAT>::addCheckButton(label, zone); } virtual void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { JSONUIReal<FAUSTFLOAT>::addVerticalSlider(label, zone, init, min, max, step); } virtual void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { JSONUIReal<FAUSTFLOAT>::addHorizontalSlider(label, zone, init, min, max, step); } virtual void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { JSONUIReal<FAUSTFLOAT>::addNumEntry(label, zone, init, min, max, step); } // -- passive widgets virtual void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { JSONUIReal<FAUSTFLOAT>::addHorizontalBargraph(label, zone, min, max); } virtual void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { JSONUIReal<FAUSTFLOAT>::addVerticalBargraph(label, zone, min, max); } // -- soundfiles virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) { JSONUIReal<FAUSTFLOAT>::addSoundfile(label, filename, sf_zone); } // -- metadata declarations virtual void declare(FAUSTFLOAT* zone, const char* key, const char* val) { JSONUIReal<FAUSTFLOAT>::declare(zone, key, val); } virtual void declare(const char* key, const char* val) { JSONUIReal<FAUSTFLOAT>::declare(key, val); } virtual ~JSONUI() {} }; #endif // FAUST_JSONUI_H /************************** END JSONUI.h **************************/ namespace oscfaust { class OSCIO; class RootNode; typedef class SMARTP<RootNode> SRootNode; /** * an alias target includes a map to rescale input values to output values * and a target osc address. The input values can be given in reversed order * to reverse the control */ struct aliastarget { double fMinIn; double fMaxIn; double fMinOut; double fMaxOut; std::string fTarget; // the real osc address aliastarget(const char* address, double imin, double imax, double omin, double omax) : fMinIn(imin), fMaxIn(imax), fMinOut(omin), fMaxOut(omax), fTarget(address) {} aliastarget(const aliastarget& t) : fMinIn(t.fMinIn), fMaxIn(t.fMaxIn), fMinOut(t.fMinOut), fMaxOut(t.fMaxOut), fTarget(t.fTarget) {} double scale(double x) const { if (fMinIn < fMaxIn) { // increasing control double z = (x < fMinIn) ? fMinIn : (x > fMaxIn) ? fMaxIn : x; return fMinOut + (z-fMinIn)*(fMaxOut-fMinOut)/(fMaxIn-fMinIn); } else if (fMinIn > fMaxIn) { // reversed control double z = (x < fMaxIn) ? fMaxIn : (x > fMinIn) ? fMinIn : x; return fMinOut + (fMinIn-z)*(fMaxOut-fMinOut)/(fMinIn-fMaxIn); } else { // no control ! return (fMinOut+fMaxOut)/2.0f; } } double invscale(double x) const { if (fMinOut < fMaxOut) { // increasing control double z = (x < fMinOut) ? fMinOut : (x > fMaxOut) ? fMaxOut : x; return fMinIn + (z-fMinOut)*(fMaxIn-fMinIn)/(fMaxOut-fMinOut); } else if (fMinOut > fMaxOut) { // reversed control double z = (x < fMaxOut) ? fMaxOut : (x > fMinOut) ? fMinOut : x; return fMinIn + (fMinOut-z)*(fMaxIn-fMinIn)/(fMinOut-fMaxOut); } else { // no control ! return (fMinIn+fMaxIn)/2.0f; } } }; //-------------------------------------------------------------------------- /*! \brief a faust root node A Faust root node handles the \c 'hello' message and provides support for incoming osc signal data. */ class RootNode : public MessageDriven { private: int *fUPDIn, *fUDPOut, *fUDPErr; // the osc port numbers (required by the hello method) OSCIO* fIO; // an OSC IO controler JSONUI* fJSON; typedef std::map<std::string, std::vector<aliastarget> > TAliasMap; TAliasMap fAliases; template <typename T> void processAliasAux(const std::string& address, T val); void processAlias(const std::string& address, float val); void processAlias(const std::string& address, double val); void eraseAliases(const std::string& target); void eraseAlias(const std::string& target, const std::string& alias); bool aliasError(const Message* msg); protected: RootNode(const char *name, JSONUI* json, OSCIO* io = NULL) : MessageDriven(name, ""), fUPDIn(0), fUDPOut(0), fUDPErr(0), fIO(io), fJSON(json) {} virtual ~RootNode() {} public: static SRootNode create(const char* name, JSONUI* json, OSCIO* io = NULL) { return new RootNode(name, json, io); } virtual void processMessage(const Message* msg); virtual bool accept(const Message* msg); virtual void get(unsigned long ipdest) const; virtual void get(unsigned long ipdest, const std::string& what) const; template <typename T> bool aliasMsgAux(const Message* msg, T omin, T omax); bool aliasMsg(const Message* msg, double omin, double omax); bool aliasMsg(const Message* msg, float omin, float omax); template <typename T> void addAliasAux(const char* alias, const char* address, T imin, T imax, T omin, T omax); void addAlias(const char* alias, const char* address, float imin, float imax, float omin, float omax); void addAlias(const char* alias, const char* address, double imin, double imax, double omin, double omax); bool acceptSignal(const Message* msg); ///< handler for signal data void hello(unsigned long ipdest) const; ///< handler for the 'hello' message void setPorts(int* in, int* out, int* err); std::vector<std::pair<std::string, double> > getAliases(const std::string& address, double value); }; } // end namespoace #endif namespace oscfaust { /** * map (rescale) input values to output values */ template <typename C> struct mapping { const C fMinOut; const C fMaxOut; mapping(C omin, C omax) : fMinOut(omin), fMaxOut(omax) {} C clip (C x) { return (x < fMinOut) ? fMinOut : (x > fMaxOut) ? fMaxOut : x; } }; //-------------------------------------------------------------------------- /*! \brief a faust node is a terminal node and represents a faust parameter controler */ template <typename C> class FaustNode : public MessageDriven, public uiTypedItem<C> { mapping<C> fMapping; RootNode* fRoot; bool fInput; // true for input nodes (slider, button...) //--------------------------------------------------------------------- // Warning !!! // The cast (C*)fZone is necessary because the real size allocated is // only known at execution time. When the library is compiled, fZone is // uniquely defined by FAUSTFLOAT. //--------------------------------------------------------------------- bool store(C val) { *(C*)this->fZone = fMapping.clip(val); return true; } void sendOSC() const; protected: FaustNode(RootNode* root, const char *name, C* zone, C init, C min, C max, const char* prefix, GUI* ui, bool initZone, bool input) : MessageDriven(name, prefix), uiTypedItem<C>(ui, zone), fMapping(min, max), fRoot(root), fInput(input) { if (initZone) { *zone = init; } } virtual ~FaustNode() {} public: typedef SMARTP<FaustNode<C> > SFaustNode; static SFaustNode create(RootNode* root, const char* name, C* zone, C init, C min, C max, const char* prefix, GUI* ui, bool initZone, bool input) { SFaustNode node = new FaustNode(root, name, zone, init, min, max, prefix, ui, initZone, input); /* Since FaustNode is a subclass of uiItem, the pointer will also be kept in the GUI class, and it's desallocation will be done there. So we don't want to have smartpointer logic desallocate it and we increment the refcount. */ node->addReference(); return node; } bool accept(const Message* msg); void get(unsigned long ipdest) const; ///< handler for the 'get' message virtual void reflectZone() { sendOSC(); this->fCache = *this->fZone; } }; } // end namespace #endif class GUI; namespace oscfaust { class OSCIO; class RootNode; typedef class SMARTP<RootNode> SRootNode; class MessageDriven; typedef class SMARTP<MessageDriven> SMessageDriven; //-------------------------------------------------------------------------- /*! \brief a factory to build a OSC UI hierarchy Actually, makes use of a stack to build the UI hierarchy. It includes a pointer to a OSCIO controler, but just to give it to the root node. */ class FaustFactory { std::stack<SMessageDriven> fNodes; ///< maintains the current hierarchy level SRootNode fRoot; ///< keep track of the root node OSCIO* fIO; ///< hack to support audio IO via OSC, actually the field is given to the root node GUI* fGUI; ///< a GUI pointer to support updateAllGuis(), required for bi-directionnal OSC JSONUI* fJSON; private: std::string addressFirst(const std::string& address) const; std::string addressTail(const std::string& address) const; public: FaustFactory(GUI* ui, JSONUI* json, OSCIO * io = NULL); virtual ~FaustFactory(); template <typename C> void addnode(const char* label, C* zone, C init, C min, C max, bool initZone, bool input); template <typename C> void addAlias(const std::string& fullpath, C* zone, C imin, C imax, C init, C min, C max, const char* label); void addAlias(const char* alias, const char* address, float imin, float imax, float omin, float omax); void addAlias(const char* alias, const char* address, double imin, double imax, double omin, double omax); void opengroup(const char* label); void closegroup(); SRootNode root() const; }; /** * Add a node to the OSC UI tree in the current group at the top of the stack */ template <typename C> void FaustFactory::addnode(const char* label, C* zone, C init, C min, C max, bool initZone, bool input) { SMessageDriven top; if (fNodes.size()) top = fNodes.top(); if (top) { std::string prefix = top->getOSCAddress(); top->add(FaustNode<C>::create(root(), label, zone, init, min, max, prefix.c_str(), fGUI, initZone, input)); } } /** * Add an alias (actually stored and handled at root node level */ template <typename C> void FaustFactory::addAlias(const std::string& fullpath, C* zone, C imin, C imax, C init, C min, C max, const char* label) { std::istringstream ss(fullpath); std::string realpath; ss >> realpath >> imin >> imax; SMessageDriven top = fNodes.top(); if (top) { std::string target = top->getOSCAddress() + "/" + label; addAlias(realpath.c_str(), target.c_str(), C(imin), C(imax), C(min), C(max)); } } } // end namespoace #endif class GUI; typedef void (*ErrorCallback)(void*); namespace oscfaust { class OSCIO; class OSCSetup; class OSCRegexp; //-------------------------------------------------------------------------- /*! \brief the main Faust OSC Lib API The OSCControler is essentially a glue between the memory representation (in charge of the FaustFactory), and the network services (in charge of OSCSetup). */ class OSCControler { int fUDPPort, fUDPOut, fUPDErr; // the udp ports numbers std::string fDestAddress; // the osc messages destination address, used at initialization only // to collect the address from the command line std::string fBindAddress; // when non empty, the address used to bind the socket for listening OSCSetup* fOsc; // the network manager (handles the udp sockets) OSCIO* fIO; // hack for OSC IO support (actually only relayed to the factory) FaustFactory* fFactory; // a factory to build the memory representation bool fInit; public: /* base udp port is chosen in an unassigned range from IANA PORT NUMBERS (last updated 2011-01-24) see at http://www.iana.org/assignments/port-numbers 5507-5552 Unassigned */ enum { kUDPBasePort = 5510 }; OSCControler(int argc, char* argv[], GUI* ui, JSONUI* json, OSCIO* io = NULL, ErrorCallback errCallback = NULL, void* arg = NULL, bool init = true); virtual ~OSCControler(); //-------------------------------------------------------------------------- // addnode, opengroup and closegroup are simply relayed to the factory //-------------------------------------------------------------------------- // Add a node in the current group (top of the group stack) template <typename T> void addnode(const char* label, T* zone, T init, T min, T max, bool input = true) { fFactory->addnode(label, zone, init, min, max, fInit, input); } //-------------------------------------------------------------------------- // This method is used for alias messages. The arguments imin and imax allow // to map incomming values from the alias input range to the actual range template <typename T> void addAlias(const std::string& fullpath, T* zone, T imin, T imax, T init, T min, T max, const char* label) { fFactory->addAlias(fullpath, zone, imin, imax, init, min, max, label); } void opengroup(const char* label) { fFactory->opengroup(label); } void closegroup() { fFactory->closegroup(); } //-------------------------------------------------------------------------- void run(); // starts the network services void endBundle(); // when bundle mode is on, close and send the current bundle (if any) void stop(); // stop the network services std::string getInfos() const; // gives information about the current environment (version, port numbers,...) int getUDPPort() const { return fUDPPort; } int getUDPOut() const { return fUDPOut; } int getUDPErr() const { return fUPDErr; } const char* getDestAddress() const { return fDestAddress.c_str(); } const char* getRootName() const; // probably useless, introduced for UI extension experiments void setUDPPort(int port) { fUDPPort = port; } void setUDPOut(int port) { fUDPOut = port; } void setUDPErr(int port) { fUPDErr = port; } void setDestAddress(const char* address) { fDestAddress = address; } // By default, an osc interface emits all parameters. You can filter specific params dynamically. static std::vector<OSCRegexp*> fFilteredPaths; // filtered paths will not be emitted static void addFilteredPath(std::string path); static bool isPathFiltered(std::string path); static void resetFilteredPaths(); static float version(); // the Faust OSC library version number static const char* versionstr(); // the Faust OSC library version number as a string static int gXmit; // a static variable to control the transmission of values // i.e. the use of the interface as a controler static int gBundle; // a static variable to control the osc bundle mode }; #define kNoXmit 0 #define kAll 1 #define kAlias 2 } #endif #ifdef _WIN32 #define strcasecmp _stricmp #endif /****************************************************************************** ******************************************************************************* OSC (Open Sound Control) USER INTERFACE ******************************************************************************* *******************************************************************************/ /* Note about the OSC addresses and the Faust UI names: ---------------------------------------------------- There are potential conflicts between the Faust UI objects naming scheme and the OSC address space. An OSC symbolic names is an ASCII string consisting of printable characters other than the following: space # number sign * asterisk , comma / forward ? question mark [ open bracket ] close bracket { open curly brace } close curly brace a simple solution to address the problem consists in replacing space or tabulation with '_' (underscore) all the other osc excluded characters with '-' (hyphen) This solution is implemented in the proposed OSC UI; */ class OSCUI : public GUI { private: oscfaust::OSCControler* fCtrl; std::vector<const char*> fAlias; JSONUI fJSON; const char* tr(const char* label) const { static char buffer[1024]; char * ptr = buffer; int n=1; while (*label && (n++ < 1024)) { switch (*label) { case ' ': case ' ': *ptr++ = '_'; break; case '#': case '*': case ',': case '/': case '?': case '[': case ']': case '{': case '}': case '(': case ')': *ptr++ = '_'; break; default: *ptr++ = *label; } label++; } *ptr = 0; return buffer; } // add all accumulated alias void addalias(FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, const char* label) { for (unsigned int i = 0; i < fAlias.size(); i++) { fCtrl->addAlias(fAlias[i], zone, FAUSTFLOAT(0), FAUSTFLOAT(1), init, min, max, label); } fAlias.clear(); } public: OSCUI(const char* /*applicationname*/, int argc, char* argv[], oscfaust::OSCIO* io = NULL, ErrorCallback errCallback = NULL, void* arg = NULL, bool init = true) : GUI() { fCtrl = new oscfaust::OSCControler(argc, argv, this, &fJSON, io, errCallback, arg, init); // fCtrl->opengroup(applicationname); } virtual ~OSCUI() { delete fCtrl; } // -- widget's layouts virtual void openTabBox(const char* label) { fCtrl->opengroup(tr(label)); fJSON.openTabBox(label); } virtual void openHorizontalBox(const char* label) { fCtrl->opengroup(tr(label)); fJSON.openHorizontalBox(label); } virtual void openVerticalBox(const char* label) { fCtrl->opengroup(tr(label)); fJSON.openVerticalBox(label); } virtual void closeBox() { fCtrl->closegroup(); fJSON.closeBox(); } // -- active widgets virtual void addButton(const char* label, FAUSTFLOAT* zone) { const char* l = tr(label); addalias(zone, 0, 0, 1, l); fCtrl->addnode(l, zone, FAUSTFLOAT(0), FAUSTFLOAT(0), FAUSTFLOAT(1)); fJSON.addButton(label, zone); } virtual void addCheckButton(const char* label, FAUSTFLOAT* zone) { const char* l = tr(label); addalias(zone, 0, 0, 1, l); fCtrl->addnode(l, zone, FAUSTFLOAT(0), FAUSTFLOAT(0), FAUSTFLOAT(1)); fJSON.addCheckButton(label, zone); } virtual void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { const char* l = tr(label); addalias(zone, init, min, max, l); fCtrl->addnode(l, zone, init, min, max); fJSON.addVerticalSlider(label, zone, init, min, max, step); } virtual void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { const char* l = tr(label); addalias(zone, init, min, max, l); fCtrl->addnode(l, zone, init, min, max); fJSON.addHorizontalSlider(label, zone, init, min, max, step); } virtual void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { const char* l = tr(label); addalias(zone, init, min, max, l); fCtrl->addnode(l, zone, init, min, max); fJSON.addNumEntry(label, zone, init, min, max, step); } // -- passive widgets virtual void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { const char* l = tr(label); addalias(zone, 0, min, max, l); fCtrl->addnode(l, zone, FAUSTFLOAT(0), min, max, false); fJSON.addHorizontalBargraph(label, zone, min, max); } virtual void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { const char* l = tr(label); addalias(zone, 0, min, max, l); fCtrl->addnode(l, zone, FAUSTFLOAT(0), min, max, false); fJSON.addVerticalBargraph(label, zone, min, max); } // -- metadata declarations virtual void declare(FAUSTFLOAT* zone, const char* key, const char* alias) { if (strcasecmp(key, "OSC") == 0) fAlias.push_back(alias); fJSON.declare(zone, key, alias); } virtual void show() {} bool run() { fCtrl->run(); return true; } void stop() { fCtrl->stop(); } void endBundle() { fCtrl->endBundle(); } std::string getInfos() { return fCtrl->getInfos(); } const char* getRootName() { return fCtrl->getRootName(); } int getUDPPort() { return fCtrl->getUDPPort(); } int getUDPOut() { return fCtrl->getUDPOut(); } int getUDPErr() { return fCtrl->getUDPErr(); } const char* getDestAddress() { return fCtrl->getDestAddress(); } void setUDPPort(int port) { fCtrl->setUDPPort(port); } void setUDPOut(int port) { fCtrl->setUDPOut(port); } void setUDPErr(int port) { fCtrl->setUDPErr(port); } void setDestAddress(const char* address) { return fCtrl->setDestAddress(address); } }; #endif // __OSCUI__ /************************** END OSCUI.h **************************/ #ifdef POLY2 #include "effect.h" #endif #if SOUNDFILE /************************** BEGIN SoundUI.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2018 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __SoundUI_H__ #define __SoundUI_H__ #include <map> #include <vector> #include <string> #include <iostream> #ifdef __APPLE__ #include <CoreFoundation/CFBundle.h> #endif // Always included otherwise -i mode later on will not always include it (with the conditional includes) /************************** BEGIN Soundfile.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __Soundfile__ #define __Soundfile__ #include <iostream> #include <string.h> #ifndef FAUSTFLOAT #define FAUSTFLOAT float #endif #define BUFFER_SIZE 16384 #define SAMPLE_RATE 44100 #define MAX_CHAN 64 #define MAX_SOUNDFILE_PARTS 256 #ifdef _MSC_VER #define PRE_PACKED_STRUCTURE __pragma(pack(push, 1)) #define POST_PACKED_STRUCTURE \ ; \ __pragma(pack(pop)) #else #define PRE_PACKED_STRUCTURE #define POST_PACKED_STRUCTURE __attribute__((__packed__)) #endif /* The soundfile structure to be used by the DSP code. Soundfile has a MAX_SOUNDFILE_PARTS parts (even a single soundfile or an empty soundfile). fLength, fOffset and fSR fields are filled accordingly by repeating the actual parts if needed. It has to be 'packed' to that the LLVM backend can correctly access it. Index computation: - p is the current part number [0..MAX_SOUNDFILE_PARTS-1] (must be proved by the type system) - i is the current position in the part. It will be constrained between [0..length] - idx(p,i) = fOffset[p] + max(0, min(i, fLength[p])); */ PRE_PACKED_STRUCTURE struct Soundfile { FAUSTFLOAT** fBuffers; int* fLength; // length of each part int* fSR; // sample rate of each part int* fOffset; // offset of each part in the global buffer int fChannels; // max number of channels of all concatenated files Soundfile() { fBuffers = nullptr; fChannels = -1; fLength = new int[MAX_SOUNDFILE_PARTS]; fSR = new int[MAX_SOUNDFILE_PARTS]; fOffset = new int[MAX_SOUNDFILE_PARTS]; } ~Soundfile() { // Free the real channels only for (int chan = 0; chan < fChannels; chan++) { delete fBuffers[chan]; } delete[] fBuffers; delete[] fLength; delete[] fSR; delete[] fOffset; } } POST_PACKED_STRUCTURE; /* The generic soundfile reader. */ class SoundfileReader { protected: int fDriverSR; void emptyFile(Soundfile* soundfile, int part, int& offset) { soundfile->fLength[part] = BUFFER_SIZE; soundfile->fSR[part] = SAMPLE_RATE; soundfile->fOffset[part] = offset; // Update offset offset += soundfile->fLength[part]; } Soundfile* createSoundfile(int cur_chan, int length, int max_chan) { Soundfile* soundfile = new Soundfile(); soundfile->fBuffers = new FAUSTFLOAT*[max_chan]; for (int chan = 0; chan < cur_chan; chan++) { soundfile->fBuffers[chan] = new FAUSTFLOAT[length]; memset(soundfile->fBuffers[chan], 0, sizeof(FAUSTFLOAT) * length); } soundfile->fChannels = cur_chan; return soundfile; } void getBuffersOffset(Soundfile* soundfile, FAUSTFLOAT** buffers, int offset) { for (int chan = 0; chan < soundfile->fChannels; chan++) { buffers[chan] = &soundfile->fBuffers[chan][offset]; } } // Check if a soundfile exists and return its real path_name std::string checkFile(const std::vector<std::string>& sound_directories, const std::string& file_name) { if (checkFile(file_name)) { return file_name; } else { for (size_t i = 0; i < sound_directories.size(); i++) { std::string path_name = sound_directories[i] + "/" + file_name; if (checkFile(path_name)) { return path_name; } } return ""; } } bool isResampling(int sample_rate) { return (fDriverSR > 0 && fDriverSR != sample_rate); } // To be implemented by subclasses /** * Check the availability of a sound resource. * * @param path_name - the name of the file, or sound resource identified this way * * @return true if the sound resource is available, false otherwise. */ virtual bool checkFile(const std::string& path_name) = 0; /** * Check the availability of a sound resource. * * @param buffer - the sound buffer * @param buffer - the sound buffer length * * @return true if the sound resource is available, false otherwise. */ virtual bool checkFile(unsigned char* buffer, size_t length) { return true; } /** * Get the channels and length values of the given sound resource. * * @param path_name - the name of the file, or sound resource identified this way * @param channels - the channels value to be filled with the sound resource number of channels * @param length - the length value to be filled with the sound resource length in frames * */ virtual void getParamsFile(const std::string& path_name, int& channels, int& length) = 0; /** * Get the channels and length values of the given sound resource. * * @param buffer - the sound buffer * @param buffer - the sound buffer length * @param channels - the channels value to be filled with the sound resource number of channels * @param length - the length value to be filled with the sound resource length in frames * */ virtual void getParamsFile(unsigned char* buffer, size_t size, int& channels, int& length) {} /** * Read one sound resource and fill the 'soundfile' structure accordingly * * @param path_name - the name of the file, or sound resource identified this way * @param part - the part number to be filled in the soundfile * @param offset - the offset value to be incremented with the actual sound resource length in frames * @param max_chan - the maximum number of mono channels to fill * */ virtual void readFile(Soundfile* soundfile, const std::string& path_name, int part, int& offset, int max_chan) = 0; /** * Read one sound resource and fill the 'soundfile' structure accordingly * * @param buffer - the sound buffer * @param buffer - the sound buffer length * @param part - the part number to be filled in the soundfile * @param offset - the offset value to be incremented with the actual sound resource length in frames * @param max_chan - the maximum number of mono channels to fill * */ virtual void readFile(Soundfile* soundfile, unsigned char* buffer, size_t length, int part, int& offset, int max_chan) {} public: virtual ~SoundfileReader() {} void setSampleRate(int sample_rate) { fDriverSR = sample_rate; } Soundfile* createSoundfile(const std::vector<std::string>& path_name_list, int max_chan) { try { int cur_chan = 1; // At least one buffer int total_length = 0; // Compute total length and channels max of all files for (int i = 0; i < int(path_name_list.size()); i++) { int chan, length; if (path_name_list[i] == "__empty_sound__") { length = BUFFER_SIZE; chan = 1; } else { getParamsFile(path_name_list[i], chan, length); } cur_chan = std::max<int>(cur_chan, chan); total_length += length; } // Complete with empty parts total_length += (MAX_SOUNDFILE_PARTS - path_name_list.size()) * BUFFER_SIZE; // Create the soundfile Soundfile* soundfile = createSoundfile(cur_chan, total_length, max_chan); // Init offset int offset = 0; // Read all files for (int i = 0; i < int(path_name_list.size()); i++) { if (path_name_list[i] == "__empty_sound__") { emptyFile(soundfile, i, offset); } else { readFile(soundfile, path_name_list[i], i, offset, max_chan); } } // Complete with empty parts for (int i = int(path_name_list.size()); i < MAX_SOUNDFILE_PARTS; i++) { emptyFile(soundfile, i, offset); } // Share the same buffers for all other channels so that we have max_chan channels available for (int chan = cur_chan; chan < max_chan; chan++) { soundfile->fBuffers[chan] = soundfile->fBuffers[chan % cur_chan]; } return soundfile; } catch (...) { return nullptr; } } // Check if all soundfiles exist and return their real path_name std::vector<std::string> checkFiles(const std::vector<std::string>& sound_directories, const std::vector<std::string>& file_name_list) { std::vector<std::string> path_name_list; for (size_t i = 0; i < file_name_list.size(); i++) { std::string path_name = checkFile(sound_directories, file_name_list[i]); // If 'path_name' is not found, it is replaced by an empty sound (= silence) path_name_list.push_back((path_name == "") ? "__empty_sound__" : path_name); } return path_name_list; } }; #endif /************************** END Soundfile.h **************************/ #if defined(JUCE_32BIT) || defined(JUCE_64BIT) /************************** BEGIN JuceReader.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2018 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __JuceReader__ #define __JuceReader__ #include <assert.h> #include "../JuceLibraryCode/JuceHeader.h" struct JuceReader : public SoundfileReader { AudioFormatManager fFormatManager; JuceReader() { fFormatManager.registerBasicFormats(); } virtual ~JuceReader() {} bool checkFile(const std::string& path_name) { File file(path_name); if (file.existsAsFile()) { return true; } else { std::cerr << "ERROR : cannot open '" << path_name << "'" << std::endl; return false; } } void getParamsFile(const std::string& path_name, int& channels, int& length) { std::unique_ptr<AudioFormatReader> formatReader (fFormatManager.createReaderFor (File (path_name))); channels = int(formatReader->numChannels); length = int(formatReader->lengthInSamples); } void readFile(Soundfile* soundfile, const std::string& path_name, int part, int& offset, int max_chan) { std::unique_ptr<AudioFormatReader> formatReader (fFormatManager.createReaderFor (File (path_name))); soundfile->fLength[part] = int(formatReader->lengthInSamples); soundfile->fSR[part] = int(formatReader->sampleRate); soundfile->fOffset[part] = offset; FAUSTFLOAT** buffers = static_cast<FAUSTFLOAT**>(alloca(soundfile->fChannels * sizeof(FAUSTFLOAT*))); getBuffersOffset(soundfile, buffers, offset); if (formatReader->read(reinterpret_cast<int *const *>(buffers), int(formatReader->numChannels), 0, int(formatReader->lengthInSamples), false)) { // Possibly concert samples if (!formatReader->usesFloatingPointData) { for (int chan = 0; chan < int(formatReader->numChannels); ++chan) { FAUSTFLOAT* buffer = &soundfile->fBuffers[chan][soundfile->fOffset[part]]; FloatVectorOperations::convertFixedToFloat(buffer, reinterpret_cast<const int*>(buffer), 1.0f/0x7fffffff, int(formatReader->lengthInSamples)); } } } else { std::cerr << "Error reading the file : " << path_name << std::endl; } // Update offset offset += soundfile->fLength[part]; } }; #endif /************************** END JuceReader.h **************************/ JuceReader gReader; #elif defined(ESP32) /************************** BEGIN WaveReader.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2020 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __WaveReader__ #define __WaveReader__ #include <string.h> #include <assert.h> #include <iostream> // WAVE file description typedef struct { // The canonical WAVE format starts with the RIFF header /** Variable: chunk_id Contains the letters "RIFF" in ASCII form (0x52494646 big-endian form). **/ int chunk_id; /** Variable: chunk_size 36 + SubChunk2Size, or more precisely: 4 + (8 + SubChunk1Size) + (8 + SubChunk2Size) This is the size of the rest of the chunk following this number. This is the size of the entire file in bytes minus 8 bytes for the two fields not included in this count: ChunkID and ChunkSize. **/ int chunk_size; /** Variable: format Contains the letters "WAVE" (0x57415645 big-endian form). **/ int format; // The "WAVE" format consists of two subchunks: "fmt " and "data": // The "fmt " subchunk describes the sound data's format: /** Variable: subchunk_1_id Contains the letters "fmt " (0x666d7420 big-endian form). **/ int subchunk_1_id; /** Variable: subchunk_1_size 16 for PCM. This is the size of the rest of the Subchunk which follows this number. **/ int subchunk_1_size; /** Variable: audio_format PCM = 1 (i.e. Linear quantization) Values other than 1 indicate some form of compression. **/ short audio_format; /** Variable: num_channels Mono = 1, Stereo = 2, etc. **/ short num_channels; /** Variable: sample_rate 8000, 44100, etc. **/ int sample_rate; /** Variable: byte_rate == SampleRate * NumChannels * BitsPerSample/8 **/ int byte_rate; /** Variable: block_align == NumChannels * BitsPerSample/8 The number of bytes for one sample including all channels. I wonder what happens when this number isn't an integer? **/ short block_align; /** Variable: bits_per_sample 8 bits = 8, 16 bits = 16, etc. **/ short bits_per_sample; /** Here should come some extra parameters which i will avoid. **/ // The "data" subchunk contains the size of the data and the actual sound: /** Variable: subchunk_2_id Contains the letters "data" (0x64617461 big-endian form). **/ int subchunk_2_id; /** Variable: subchunk_2_size == NumSamples * NumChannels * BitsPerSample/8 This is the number of bytes in the data. You can also think of this as the size of the read of the subchunk following this number. **/ int subchunk_2_size; /** Variable: data The actual sound data. **/ char* data; } wave_t; // Base reader struct Reader { wave_t* fWave; inline int is_big_endian() { int a = 1; return !((char*)&a)[0]; } inline int convert_to_int(char* buffer, int len) { int a = 0; if (!is_big_endian()) { for(int i = 0; i < len; i++) { ((char*)&a)[i] = buffer[i]; } } else { for(int i = 0; i < len; i++) { ((char*)&a)[3-i] = buffer[i]; } } return a; } Reader() { fWave = (wave_t*)calloc(1, sizeof(wave_t)); } virtual ~Reader() { free(fWave->data); free(fWave); } bool load_wave_header() { char buffer[4]; read(buffer, 4); if (strncmp(buffer, "RIFF", 4) != 0) { std::cerr << "This is not valid WAV file!\n"; return false; } fWave->chunk_id = convert_to_int(buffer, 4); read(buffer, 4); fWave->chunk_size = convert_to_int(buffer, 4); read(buffer, 4); fWave->format = convert_to_int(buffer, 4); read(buffer, 4); fWave->subchunk_1_id = convert_to_int(buffer, 4); read(buffer, 4); fWave->subchunk_1_size = convert_to_int(buffer, 4); read(buffer, 2); fWave->audio_format = convert_to_int(buffer, 2); read(buffer, 2); fWave->num_channels = convert_to_int(buffer, 2); read(buffer, 4); fWave->sample_rate = convert_to_int(buffer, 4); read(buffer, 4); fWave->byte_rate = convert_to_int(buffer, 4); read(buffer, 2); fWave->block_align = convert_to_int(buffer, 2); read(buffer, 2); fWave->bits_per_sample = convert_to_int(buffer, 2); read(buffer, 4); if (strncmp(buffer, "data", 4) != 0) { read(buffer, 4); int _extra_size = convert_to_int(buffer, 4); char _extra_data[_extra_size]; read(_extra_data, _extra_size); read(buffer, 4); fWave->subchunk_2_id = convert_to_int(buffer, 4); } else { fWave->subchunk_2_id = convert_to_int(buffer, 4); } read(buffer, 4); fWave->subchunk_2_size = convert_to_int(buffer, 4); return true; } void load_wave() { // Read sound data fWave->data = (char*)malloc(fWave->subchunk_2_size); read(fWave->data, fWave->subchunk_2_size); } virtual void read(char* buffer, unsigned int size) = 0; }; struct FileReader : public Reader { FILE* fFile; FileReader(const std::string& file_path) { fFile = fopen(file_path.c_str(), "rb"); if (!fFile) { std::cerr << "FileReader : cannot open file!\n"; throw -1; } if (!load_wave_header()) { std::cerr << "FileReader : not a WAV file!\n"; throw -1; } } virtual ~FileReader() { fclose(fFile); } void read(char* buffer, unsigned int size) { fread(buffer, 1, size, fFile); } }; extern const uint8_t file_start[] asm("_binary_FILE_start"); extern const uint8_t file_end[] asm("_binary_FILE_end"); struct MemoryReader : public Reader { int fPos; const uint8_t* fStart; const uint8_t* fEnd; MemoryReader(const uint8_t* start, const uint8_t* end):fPos(0) { fStart = start; fEnd = end; if (!load_wave_header()) { std::cerr << "MemoryReader : not a WAV file!\n"; throw -1; } } virtual ~MemoryReader() {} void read(char* buffer, unsigned int size) { memcpy(buffer, fStart + fPos, size); fPos += size; } }; // Using a FileReader to implement SoundfileReader struct WaveReader : public SoundfileReader { WaveReader() {} bool checkFile(const std::string& path_name) { try { Reader* reader = new FileReader(path_name); delete reader; return true; } catch(...) { return false; } } void getParamsFile(const std::string& path_name, int& channels, int& length) { Reader* reader = new FileReader(path_name); assert(reader); channels = reader->fWave->num_channels; length = (reader->fWave->subchunk_2_size * 8) / (reader->fWave->num_channels * reader->fWave->bits_per_sample); delete reader; } void readFile(Soundfile* soundfile, const std::string& path_name, int part, int& offset, int max_chan) { Reader* reader = new FileReader(path_name); assert(reader); reader->load_wave(); soundfile->fLength[part] = (reader->fWave->subchunk_2_size * 8) / (reader->fWave->num_channels * reader->fWave->bits_per_sample); soundfile->fSR[part] = reader->fWave->sample_rate; soundfile->fOffset[part] = offset; // Audio frames have to be written for each chan if (reader->fWave->bits_per_sample == 16) { float factor = 1.f/32767.f; for (int sample = 0; sample < soundfile->fLength[part]; sample++) { short* frame = (short*)&reader->fWave->data[reader->fWave->block_align * sample]; for (int chan = 0; chan < reader->fWave->num_channels; chan++) { soundfile->fBuffers[chan][offset + sample] = frame[chan] * factor; } } } else if (reader->fWave->bits_per_sample == 32) { std::cerr << "readFile : not implemented \n"; } // Update offset offset += soundfile->fLength[part]; delete reader; } }; #endif /************************** END WaveReader.h **************************/ WaveReader gReader; #elif defined(MEMORY_READER) /************************** BEGIN MemoryReader.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2018 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __MemoryReader__ #define __MemoryReader__ /* A 'MemoryReader' object can be used to prepare a set of sound resources in memory, to be used by SoundUI::addSoundfile. A Soundfile* object will have to be filled with a list of sound resources: the fLength, fOffset, fSampleRate and fBuffers fields have to be completed with the appropriate values, and will be accessed in the DSP object while running. * */ // To adapt for a real case use #define SOUND_CHAN 2 #define SOUND_LENGTH 4096 #define SOUND_SR 40100 struct MemoryReader : public SoundfileReader { MemoryReader() {} /** * Check the availability of a sound resource. * * @param path_name - the name of the file, or sound resource identified this way * * @return true if the sound resource is available, false otherwise. */ virtual bool checkFile(const std::string& path_name) { return true; } /** * Get the channels and length values of the given sound resource. * * @param path_name - the name of the file, or sound resource identified this way * @param channels - the channels value to be filled with the sound resource number of channels * @param length - the length value to be filled with the sound resource length in frames * */ virtual void getParamsFile(const std::string& path_name, int& channels, int& length) { channels = SOUND_CHAN; length = SOUND_LENGTH; } /** * Read one sound resource and fill the 'soundfile' structure accordingly * * @param path_name - the name of the file, or sound resource identified this way * @param part - the part number to be filled in the soundfile * @param offset - the offset value to be incremented with the actual sound resource length in frames * @param max_chan - the maximum number of mono channels to fill * */ virtual void readFile(Soundfile* soundfile, const std::string& path_name, int part, int& offset, int max_chan) { soundfile->fLength[part] = SOUND_LENGTH; soundfile->fSR[part] = SOUND_SR; soundfile->fOffset[part] = offset; // Audio frames have to be written for each chan for (int sample = 0; sample < SOUND_LENGTH; sample++) { for (int chan = 0; chan < SOUND_CHAN; chan++) { soundfile->fBuffers[chan][offset + sample] = 0.f; } } // Update offset offset += SOUND_LENGTH; } }; #endif /************************** END MemoryReader.h **************************/ MemoryReader gReader; #else /************************** BEGIN LibsndfileReader.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2018 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __LibsndfileReader__ #define __LibsndfileReader__ #ifdef SAMPLERATE #include <samplerate.h> #endif #include <sndfile.h> #include <string.h> #include <assert.h> #include <iostream> struct VFLibsndfile { #define SIGNED_SIZEOF(x) ((int)sizeof(x)) unsigned char* fBuffer; size_t fLength; size_t fOffset; SF_VIRTUAL_IO fVIO; VFLibsndfile(unsigned char* buffer, size_t length):fBuffer(buffer), fLength(length), fOffset(0) { fVIO.get_filelen = vfget_filelen; fVIO.seek = vfseek; fVIO.read = vfread; fVIO.write = vfwrite; fVIO.tell = vftell; } static sf_count_t vfget_filelen(void* user_data) { VFLibsndfile* vf = static_cast<VFLibsndfile*>(user_data); return vf->fLength; } static sf_count_t vfseek(sf_count_t offset, int whence, void* user_data) { VFLibsndfile* vf = static_cast<VFLibsndfile*>(user_data); switch (whence) { case SEEK_SET: vf->fOffset = offset; break; case SEEK_CUR: vf->fOffset = vf->fOffset + offset; break; case SEEK_END: vf->fOffset = vf->fLength + offset; break; default: break; }; return vf->fOffset; } static sf_count_t vfread(void* ptr, sf_count_t count, void* user_data) { VFLibsndfile* vf = static_cast<VFLibsndfile*>(user_data); /* ** This will break badly for files over 2Gig in length, but ** is sufficient for testing. */ if (vf->fOffset + count > vf->fLength) { count = vf->fLength - vf->fOffset; } memcpy(ptr, vf->fBuffer + vf->fOffset, count); vf->fOffset += count; return count; } static sf_count_t vfwrite(const void* ptr, sf_count_t count, void* user_data) { VFLibsndfile* vf = static_cast<VFLibsndfile*>(user_data); /* ** This will break badly for files over 2Gig in length, but ** is sufficient for testing. */ if (vf->fOffset >= SIGNED_SIZEOF(vf->fBuffer)) { return 0; } if (vf->fOffset + count > SIGNED_SIZEOF(vf->fBuffer)) { count = sizeof (vf->fBuffer) - vf->fOffset; } memcpy(vf->fBuffer + vf->fOffset, ptr, (size_t)count); vf->fOffset += count; if (vf->fOffset > vf->fLength) { vf->fLength = vf->fOffset; } return count; } static sf_count_t vftell(void* user_data) { VFLibsndfile* vf = static_cast<VFLibsndfile*>(user_data); return vf->fOffset; } }; struct LibsndfileReader : public SoundfileReader { LibsndfileReader() {} typedef sf_count_t (* sample_read)(SNDFILE* sndfile, FAUSTFLOAT* ptr, sf_count_t frames); // Check file bool checkFile(const std::string& path_name) { SF_INFO snd_info; snd_info.format = 0; SNDFILE* snd_file = sf_open(path_name.c_str(), SFM_READ, &snd_info); return checkFileAux(snd_file, path_name); } bool checkFile(unsigned char* buffer, size_t length) { SF_INFO snd_info; snd_info.format = 0; VFLibsndfile vio(buffer, length); SNDFILE* snd_file = sf_open_virtual(&vio.fVIO, SFM_READ, &snd_info, &vio); return checkFileAux(snd_file, "virtual file"); } bool checkFileAux(SNDFILE* snd_file, const std::string& path_name) { if (snd_file) { sf_close(snd_file); return true; } else { std::cerr << "ERROR : cannot open '" << path_name << "' (" << sf_strerror(NULL) << ")" << std::endl; return false; } } // Open the file and returns its length and channels void getParamsFile(const std::string& path_name, int& channels, int& length) { SF_INFO snd_info; snd_info.format = 0; SNDFILE* snd_file = sf_open(path_name.c_str(), SFM_READ, &snd_info); getParamsFileAux(snd_file, snd_info, channels, length); } void getParamsFile(unsigned char* buffer, size_t size, int& channels, int& length) { SF_INFO snd_info; snd_info.format = 0; VFLibsndfile vio(buffer, size); SNDFILE* snd_file = sf_open_virtual(&vio.fVIO, SFM_READ, &snd_info, &vio); getParamsFileAux(snd_file, snd_info, channels, length); } void getParamsFileAux(SNDFILE* snd_file, const SF_INFO& snd_info, int& channels, int& length) { assert(snd_file); channels = int(snd_info.channels); #ifdef SAMPLERATE length = (isResampling(snd_info.samplerate)) ? ((double(snd_info.frames) * double(fDriverSR) / double(snd_info.samplerate)) + BUFFER_SIZE) : int(snd_info.frames); #else length = int(snd_info.frames); #endif sf_close(snd_file); } // Read the file void copyToOut(Soundfile* soundfile, int size, int channels, int max_channels, int offset, FAUSTFLOAT* buffer) { for (int sample = 0; sample < size; sample++) { for (int chan = 0; chan < channels; chan++) { soundfile->fBuffers[chan][offset + sample] = buffer[sample * max_channels + chan]; } } } void readFile(Soundfile* soundfile, const std::string& path_name, int part, int& offset, int max_chan) { SF_INFO snd_info; snd_info.format = 0; SNDFILE* snd_file = sf_open(path_name.c_str(), SFM_READ, &snd_info); readFileAux(soundfile, snd_file, snd_info, part, offset, max_chan); } void readFile(Soundfile* soundfile, unsigned char* buffer, size_t length, int part, int& offset, int max_chan) { SF_INFO snd_info; snd_info.format = 0; VFLibsndfile vio(buffer, length); SNDFILE* snd_file = sf_open_virtual(&vio.fVIO, SFM_READ, &snd_info, &vio); readFileAux(soundfile, snd_file, snd_info, part, offset, max_chan); } // Will be called to fill all parts from 0 to MAX_SOUNDFILE_PARTS-1 void readFileAux(Soundfile* soundfile, SNDFILE* snd_file, const SF_INFO& snd_info, int part, int& offset, int max_chan) { assert(snd_file); int channels = std::min<int>(max_chan, snd_info.channels); #ifdef SAMPLERATE if (isResampling(snd_info.samplerate)) { soundfile->fLength[part] = int(double(snd_info.frames) * double(fDriverSR) / double(snd_info.samplerate)); soundfile->fSR[part] = fDriverSR; } else { soundfile->fLength[part] = int(snd_info.frames); soundfile->fSR[part] = snd_info.samplerate; } #else soundfile->fLength[part] = int(snd_info.frames); soundfile->fSR[part] = snd_info.samplerate; #endif soundfile->fOffset[part] = offset; // Read and fill snd_info.channels number of channels sf_count_t nbf; FAUSTFLOAT* buffer_in = (FAUSTFLOAT*)alloca(BUFFER_SIZE * sizeof(FAUSTFLOAT) * snd_info.channels); sample_read reader; if (sizeof(FAUSTFLOAT) == 4) { reader = reinterpret_cast<sample_read>(sf_readf_float); } else { reader = reinterpret_cast<sample_read>(sf_readf_double); } #ifdef SAMPLERATE // Resampling SRC_STATE* resampler = nullptr; FAUSTFLOAT* buffer_out = nullptr; if (isResampling(snd_info.samplerate)) { int error; resampler = src_new(SRC_SINC_FASTEST, channels, &error); if (error != 0) { std::cerr << "ERROR : src_new " << src_strerror(error) << std::endl; throw -1; } buffer_out = (FAUSTFLOAT*)alloca(BUFFER_SIZE * sizeof(FAUSTFLOAT) * snd_info.channels); } #endif do { nbf = reader(snd_file, buffer_in, BUFFER_SIZE); #ifdef SAMPLERATE // Resampling if (isResampling(snd_info.samplerate)) { int in_offset = 0; SRC_DATA src_data; src_data.src_ratio = double(fDriverSR)/double(snd_info.samplerate); do { src_data.data_in = &buffer_in[in_offset * snd_info.channels]; src_data.data_out = buffer_out; src_data.input_frames = nbf - in_offset; src_data.output_frames = BUFFER_SIZE; src_data.end_of_input = (nbf < BUFFER_SIZE); int res = src_process(resampler, &src_data); if (res != 0) { std::cerr << "ERROR : src_process " << src_strerror(res) << std::endl; throw -1; } copyToOut(soundfile, src_data.output_frames_gen, channels, snd_info.channels, offset, buffer_out); in_offset += src_data.input_frames_used; // Update offset offset += src_data.output_frames_gen; } while (in_offset < nbf); } else { copyToOut(soundfile, nbf, channels, snd_info.channels, offset, buffer_in); // Update offset offset += nbf; } #else copyToOut(soundfile, nbf, channels, snd_info.channels, offset, buffer_in); // Update offset offset += nbf; #endif } while (nbf == BUFFER_SIZE); sf_close(snd_file); #ifdef SAMPLERATE if (resampler) src_delete(resampler); #endif } }; #endif /************************** END LibsndfileReader.h **************************/ LibsndfileReader gReader; #endif // To be used by DSP code if no SoundUI is used std::vector<std::string> path_name_list; Soundfile* defaultsound = gReader.createSoundfile(path_name_list, MAX_CHAN); class SoundUI : public GenericUI { private: std::vector<std::string> fSoundfileDir; // The soundfile directories std::map<std::string, Soundfile*> fSoundfileMap; // Map to share loaded soundfiles SoundfileReader* fSoundReader; public: /** * Create a soundfile loader which will typically use a concrete SoundfileReader like LibsndfileReader or JuceReader to load soundfiles. * * @param sound_directory - the base directory to look for files, which paths will be relative to this one * @param sample_rate - the audio driver SR which may be different from the file SR, to possibly resample files * @param reader - an alternative soundfile reader * * @return the soundfile loader. */ SoundUI(const std::string& sound_directory = "", int sample_rate = -1, SoundfileReader* reader = nullptr) { fSoundfileDir.push_back(sound_directory); fSoundReader = (reader) ? reader : &gReader; fSoundReader->setSampleRate(sample_rate); } /** * Create a soundfile loader which will typically use a concrete SoundfileReader like LibsndfileReader or JuceReader to load soundfiles. * * @param sound_directories - a vector of base directories to look for files, which paths will be relative to these ones * @param sample_rate - the audio driver SR which may be different from the file SR, to possibly resample files * @param reader - an alternative soundfile reader * * @return the soundfile loader. */ SoundUI(const std::vector<std::string>& sound_directories, int sample_rate = -1, SoundfileReader* reader = nullptr) :fSoundfileDir(sound_directories) { fSoundReader = (reader) ? reader : &gReader; fSoundReader->setSampleRate(sample_rate); } virtual ~SoundUI() { // Delete all soundfiles std::map<std::string, Soundfile*>::iterator it; for (it = fSoundfileMap.begin(); it != fSoundfileMap.end(); it++) { delete (*it).second; } } // -- soundfiles virtual void addSoundfile(const char* label, const char* url, Soundfile** sf_zone) { const char* saved_url = url; // 'url' is consumed by parseMenuList2 std::vector<std::string> file_name_list; bool menu = parseMenuList2(url, file_name_list, true); // If not a list, we have as single file if (!menu) { file_name_list.push_back(saved_url); } // Parse the possible list if (fSoundfileMap.find(saved_url) == fSoundfileMap.end()) { // Check all files and get their complete path std::vector<std::string> path_name_list = fSoundReader->checkFiles(fSoundfileDir, file_name_list); // Read them and create the Soundfile Soundfile* sound_file = fSoundReader->createSoundfile(path_name_list, MAX_CHAN); if (sound_file) { fSoundfileMap[saved_url] = sound_file; } else { // If failure, use 'defaultsound' std::cerr << "addSoundfile : soundfile for " << saved_url << " cannot be created !" << std::endl; *sf_zone = defaultsound; return; } } // Get the soundfile *sf_zone = fSoundfileMap[saved_url]; } /** * An OS dependant function to get the path of the running executable or plugin. * This will typically be used when creating a SoundUI soundfile loader, like new SoundUI(SoundUI::getBinaryPath()); * * @return the running executable or plugin path. */ static std::string getBinaryPath() { std::string bundle_path_str; #ifdef __APPLE__ CFURLRef bundle_ref = CFBundleCopyBundleURL(CFBundleGetMainBundle()); if (!bundle_ref) { std::cerr << "getBinaryPath CFBundleCopyBundleURL error\n"; return ""; } UInt8 bundle_path[1024]; if (CFURLGetFileSystemRepresentation(bundle_ref, true, bundle_path, 1024)) { bundle_path_str = std::string((char*)bundle_path); } else { std::cerr << "getBinaryPath CFURLGetFileSystemRepresentation error\n"; } #endif #ifdef ANDROID_DRIVER bundle_path_str = "/data/data/__CURRENT_ANDROID_PACKAGE__/files"; #endif return bundle_path_str; } /** * An OS dependant function to get the path of the running executable or plugin. * This will typically be used when creating a SoundUI soundfile loader, like new SoundUI(SoundUI::getBinaryPathFrom()); * * @param path - entry point to start getting the path of the running executable or plugin. * * @return the running executable or plugin path. */ static std::string getBinaryPathFrom(const std::string& path) { std::string bundle_path_str; #ifdef __APPLE__ CFBundleRef bundle = CFBundleGetBundleWithIdentifier(CFStringCreateWithCString(kCFAllocatorDefault, path.c_str(), CFStringGetSystemEncoding())); if (!bundle) { std::cerr << "getBinaryPathFrom CFBundleGetBundleWithIdentifier error '" << path << "'" << std::endl; return ""; } CFURLRef bundle_ref = CFBundleCopyBundleURL(bundle); if (!bundle_ref) { std::cerr << "getBinaryPathFrom CFBundleCopyBundleURL error\n"; return ""; } UInt8 bundle_path[1024]; if (CFURLGetFileSystemRepresentation(bundle_ref, true, bundle_path, 1024)) { bundle_path_str = std::string((char*)bundle_path); } else { std::cerr << "getBinaryPathFrom CFURLGetFileSystemRepresentation error\n"; } #endif #ifdef ANDROID_DRIVER bundle_path_str = "/data/data/__CURRENT_ANDROID_PACKAGE__/files"; #endif return bundle_path_str; } }; #endif /************************** END SoundUI.h **************************/ #endif // For FAUST_CLASS_NAME to be defined #define FAUST_UIMACROS // but we will ignore most of them #define FAUST_ADDBUTTON(l,f) #define FAUST_ADDCHECKBOX(l,f) #define FAUST_ADDVERTICALSLIDER(l,f,i,a,b,s) #define FAUST_ADDHORIZONTALSLIDER(l,f,i,a,b,s) #define FAUST_ADDNUMENTRY(l,f,i,a,b,s) #define FAUST_ADDVERTICALBARGRAPH(l,f,a,b) #define FAUST_ADDHORIZONTALBARGRAPH(l,f,a,b) #define FAUST_ADDSOUNDFILE(s,f) using namespace std; /****************************************************************************** ******************************************************************************* VECTOR INTRINSICS ******************************************************************************* *******************************************************************************/ /********************END ARCHITECTURE SECTION (part 1/2)****************/ /**************************BEGIN USER SECTION **************************/ #ifndef FAUSTFLOAT #define FAUSTFLOAT float #endif #include <algorithm> #include <cmath> #include <math.h> #ifndef FAUSTCLASS #define FAUSTCLASS ue_binaural_decoder #endif #ifdef __APPLE__ #define exp10f __exp10f #define exp10 __exp10 #endif class ue_binaural_decoder : public dsp { public: int fSampleRate; double fConst0; FAUSTFLOAT fVslider0; double fRec1[2]; FAUSTFLOAT fCheckbox0; FAUSTFLOAT fCheckbox1; FAUSTFLOAT fVslider1; double fRec3[2]; double fRec2[2]; FAUSTFLOAT fVbargraph0; int IOTA; double fVec0[128]; FAUSTFLOAT fCheckbox2; double fRec4[2]; FAUSTFLOAT fVbargraph1; double fVec1[128]; FAUSTFLOAT fCheckbox3; double fRec5[2]; FAUSTFLOAT fVbargraph2; double fVec2[128]; FAUSTFLOAT fCheckbox4; double fRec6[2]; FAUSTFLOAT fVbargraph3; double fVec3[128]; FAUSTFLOAT fCheckbox5; double fRec7[2]; FAUSTFLOAT fVbargraph4; double fVec4[128]; FAUSTFLOAT fCheckbox6; FAUSTFLOAT fCheckbox7; double fRec8[2]; FAUSTFLOAT fVbargraph5; double fVec5[128]; FAUSTFLOAT fCheckbox8; double fRec9[2]; FAUSTFLOAT fVbargraph6; double fVec6[128]; FAUSTFLOAT fCheckbox9; double fRec10[2]; FAUSTFLOAT fVbargraph7; double fVec7[128]; FAUSTFLOAT fCheckbox10; FAUSTFLOAT fCheckbox11; double fRec11[2]; FAUSTFLOAT fVbargraph8; double fVec8[128]; double fRec0[2]; FAUSTFLOAT fHbargraph0; double fRec12[2]; FAUSTFLOAT fHbargraph1; public: void metadata(Meta* m) { m->declare("author", "Pierre Lecomte"); m->declare("basics.lib/name", "Faust Basic Element Library"); m->declare("basics.lib/version", "0.1"); m->declare("copyright", "(c) Pierre Lecomte 2015"); m->declare("filename", "ue.binaural.decoder.dsp"); m->declare("filters.lib/fir:author", "Julius O. Smith III"); m->declare("filters.lib/fir:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <[email protected]>"); m->declare("filters.lib/fir:license", "MIT-style STK-4.3 license"); m->declare("filters.lib/lowpass0_highpass1", "Copyright (C) 2003-2019 by Julius O. Smith III <[email protected]>"); m->declare("filters.lib/name", "Faust Filters Library"); m->declare("gui.lib/author", "Pierre Lecomte"); m->declare("gui.lib/copyright", "(c) Pierre Lecomte 2016"); m->declare("gui.lib/license", "GPL"); m->declare("gui.lib/name", "GUI Library"); m->declare("gui.lib/version", "1.0"); m->declare("license", "GPL)"); m->declare("maths.lib/author", "GRAME"); m->declare("maths.lib/copyright", "GRAME"); m->declare("maths.lib/license", "LGPL with exception"); m->declare("maths.lib/name", "Faust Math Library"); m->declare("maths.lib/version", "2.3"); m->declare("name", "Binaural decoder"); m->declare("platform.lib/name", "Generic Platform Library"); m->declare("platform.lib/version", "0.1"); m->declare("signals.lib/name", "Faust Signal Routing Library"); m->declare("signals.lib/version", "0.0"); m->declare("version", "1.0"); } virtual int getNumInputs() { return 9; } virtual int getNumOutputs() { return 2; } virtual int getInputRate(int channel) { int rate; switch ((channel)) { case 0: { rate = 1; break; } case 1: { rate = 1; break; } case 2: { rate = 1; break; } case 3: { rate = 1; break; } case 4: { rate = 1; break; } case 5: { rate = 1; break; } case 6: { rate = 1; break; } case 7: { rate = 1; break; } case 8: { rate = 1; break; } default: { rate = -1; break; } } return rate; } virtual int getOutputRate(int channel) { int rate; switch ((channel)) { case 0: { rate = 1; break; } case 1: { rate = 1; break; } default: { rate = -1; break; } } return rate; } static void classInit(int sample_rate) { } virtual void instanceConstants(int sample_rate) { fSampleRate = sample_rate; fConst0 = (80.0 / std::min<double>(192000.0, std::max<double>(1.0, double(fSampleRate)))); } virtual void instanceResetUserInterface() { fVslider0 = FAUSTFLOAT(0.0); fCheckbox0 = FAUSTFLOAT(0.0); fCheckbox1 = FAUSTFLOAT(0.0); fVslider1 = FAUSTFLOAT(0.0); fCheckbox2 = FAUSTFLOAT(0.0); fCheckbox3 = FAUSTFLOAT(0.0); fCheckbox4 = FAUSTFLOAT(0.0); fCheckbox5 = FAUSTFLOAT(0.0); fCheckbox6 = FAUSTFLOAT(0.0); fCheckbox7 = FAUSTFLOAT(0.0); fCheckbox8 = FAUSTFLOAT(0.0); fCheckbox9 = FAUSTFLOAT(0.0); fCheckbox10 = FAUSTFLOAT(0.0); fCheckbox11 = FAUSTFLOAT(0.0); } virtual void instanceClear() { for (int l0 = 0; (l0 < 2); l0 = (l0 + 1)) { fRec1[l0] = 0.0; } for (int l1 = 0; (l1 < 2); l1 = (l1 + 1)) { fRec3[l1] = 0.0; } for (int l2 = 0; (l2 < 2); l2 = (l2 + 1)) { fRec2[l2] = 0.0; } IOTA = 0; for (int l3 = 0; (l3 < 128); l3 = (l3 + 1)) { fVec0[l3] = 0.0; } for (int l4 = 0; (l4 < 2); l4 = (l4 + 1)) { fRec4[l4] = 0.0; } for (int l5 = 0; (l5 < 128); l5 = (l5 + 1)) { fVec1[l5] = 0.0; } for (int l6 = 0; (l6 < 2); l6 = (l6 + 1)) { fRec5[l6] = 0.0; } for (int l7 = 0; (l7 < 128); l7 = (l7 + 1)) { fVec2[l7] = 0.0; } for (int l8 = 0; (l8 < 2); l8 = (l8 + 1)) { fRec6[l8] = 0.0; } for (int l9 = 0; (l9 < 128); l9 = (l9 + 1)) { fVec3[l9] = 0.0; } for (int l10 = 0; (l10 < 2); l10 = (l10 + 1)) { fRec7[l10] = 0.0; } for (int l11 = 0; (l11 < 128); l11 = (l11 + 1)) { fVec4[l11] = 0.0; } for (int l12 = 0; (l12 < 2); l12 = (l12 + 1)) { fRec8[l12] = 0.0; } for (int l13 = 0; (l13 < 128); l13 = (l13 + 1)) { fVec5[l13] = 0.0; } for (int l14 = 0; (l14 < 2); l14 = (l14 + 1)) { fRec9[l14] = 0.0; } for (int l15 = 0; (l15 < 128); l15 = (l15 + 1)) { fVec6[l15] = 0.0; } for (int l16 = 0; (l16 < 2); l16 = (l16 + 1)) { fRec10[l16] = 0.0; } for (int l17 = 0; (l17 < 128); l17 = (l17 + 1)) { fVec7[l17] = 0.0; } for (int l18 = 0; (l18 < 2); l18 = (l18 + 1)) { fRec11[l18] = 0.0; } for (int l19 = 0; (l19 < 128); l19 = (l19 + 1)) { fVec8[l19] = 0.0; } for (int l20 = 0; (l20 < 2); l20 = (l20 + 1)) { fRec0[l20] = 0.0; } for (int l21 = 0; (l21 < 2); l21 = (l21 + 1)) { fRec12[l21] = 0.0; } } virtual void init(int sample_rate) { classInit(sample_rate); instanceInit(sample_rate); } virtual void instanceInit(int sample_rate) { instanceConstants(sample_rate); instanceResetUserInterface(); instanceClear(); } virtual ue_binaural_decoder* clone() { return new ue_binaural_decoder(); } virtual int getSampleRate() { return fSampleRate; } virtual void buildUserInterface(UI* ui_interface) { ui_interface->openVerticalBox("Binaural decoder"); ui_interface->openHorizontalBox("Inputs"); ui_interface->openHorizontalBox("0"); ui_interface->openVerticalBox("0"); ui_interface->addCheckButton("Mute", &fCheckbox11); ui_interface->declare(&fVbargraph8, "unit", "dB"); ui_interface->addVerticalBargraph("0x7f86aec7ecc0", &fVbargraph8, -70.0, 6.0); ui_interface->closeBox(); ui_interface->addCheckButton("Mute", &fCheckbox10); ui_interface->closeBox(); ui_interface->openHorizontalBox("1"); ui_interface->openVerticalBox("1"); ui_interface->addCheckButton("Mute", &fCheckbox8); ui_interface->declare(&fVbargraph6, "unit", "dB"); ui_interface->addVerticalBargraph("0x7f86af00c9d0", &fVbargraph6, -70.0, 6.0); ui_interface->closeBox(); ui_interface->openVerticalBox("2"); ui_interface->addCheckButton("Mute", &fCheckbox9); ui_interface->declare(&fVbargraph7, "unit", "dB"); ui_interface->addVerticalBargraph("0x7f86af030f70", &fVbargraph7, -70.0, 6.0); ui_interface->closeBox(); ui_interface->openVerticalBox("3"); ui_interface->addCheckButton("Mute", &fCheckbox7); ui_interface->declare(&fVbargraph5, "unit", "dB"); ui_interface->addVerticalBargraph("0x7f86af2bdfb0", &fVbargraph5, -70.0, 6.0); ui_interface->closeBox(); ui_interface->addCheckButton("Mute", &fCheckbox6); ui_interface->closeBox(); ui_interface->openHorizontalBox("2"); ui_interface->openVerticalBox("4"); ui_interface->addCheckButton("Mute", &fCheckbox5); ui_interface->declare(&fVbargraph4, "unit", "dB"); ui_interface->addVerticalBargraph("0x7f86af28ef70", &fVbargraph4, -70.0, 6.0); ui_interface->closeBox(); ui_interface->openVerticalBox("5"); ui_interface->addCheckButton("Mute", &fCheckbox4); ui_interface->declare(&fVbargraph3, "unit", "dB"); ui_interface->addVerticalBargraph("0x7f86af24b780", &fVbargraph3, -70.0, 6.0); ui_interface->closeBox(); ui_interface->openVerticalBox("6"); ui_interface->addCheckButton("Mute", &fCheckbox3); ui_interface->declare(&fVbargraph2, "unit", "dB"); ui_interface->addVerticalBargraph("0x7f86af240d10", &fVbargraph2, -70.0, 6.0); ui_interface->closeBox(); ui_interface->openVerticalBox("7"); ui_interface->addCheckButton("Mute", &fCheckbox2); ui_interface->declare(&fVbargraph1, "unit", "dB"); ui_interface->addVerticalBargraph("0x7f86af218080", &fVbargraph1, -70.0, 6.0); ui_interface->closeBox(); ui_interface->openVerticalBox("8"); ui_interface->addCheckButton("Mute", &fCheckbox1); ui_interface->declare(&fVbargraph0, "unit", "dB"); ui_interface->addVerticalBargraph("0x7f86af20b8b0", &fVbargraph0, -70.0, 6.0); ui_interface->closeBox(); ui_interface->addCheckButton("Mute", &fCheckbox0); ui_interface->closeBox(); ui_interface->declare(&fVslider1, "1", ""); ui_interface->declare(&fVslider1, "osc", "/levelin -10 10"); ui_interface->declare(&fVslider1, "unit", "dB"); ui_interface->addVerticalSlider("Inputs Gain", &fVslider1, 0.0, -10.0, 10.0, 0.10000000000000001); ui_interface->declare(&fVslider0, "2", ""); ui_interface->declare(&fVslider0, "osc", "/levelout -10 10"); ui_interface->declare(&fVslider0, "unit", "dB"); ui_interface->addVerticalSlider("Outputs Gain", &fVslider0, 0.0, -10.0, 10.0, 0.10000000000000001); ui_interface->closeBox(); ui_interface->openVerticalBox("Outputs"); ui_interface->openHorizontalBox("Left"); ui_interface->declare(&fHbargraph0, "unit", "dB"); ui_interface->addHorizontalBargraph("0x7f86af061850", &fHbargraph0, -70.0, 6.0); ui_interface->closeBox(); ui_interface->openHorizontalBox("Right"); ui_interface->declare(&fHbargraph1, "unit", "dB"); ui_interface->addHorizontalBargraph("0x7f86af5b81e0", &fHbargraph1, -70.0, 6.0); ui_interface->closeBox(); ui_interface->closeBox(); ui_interface->closeBox(); } virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { FAUSTFLOAT* input0 = inputs[0]; FAUSTFLOAT* input1 = inputs[1]; FAUSTFLOAT* input2 = inputs[2]; FAUSTFLOAT* input3 = inputs[3]; FAUSTFLOAT* input4 = inputs[4]; FAUSTFLOAT* input5 = inputs[5]; FAUSTFLOAT* input6 = inputs[6]; FAUSTFLOAT* input7 = inputs[7]; FAUSTFLOAT* input8 = inputs[8]; FAUSTFLOAT* output0 = outputs[0]; FAUSTFLOAT* output1 = outputs[1]; double fSlow0 = (0.0010000000000000009 * std::pow(10.0, (0.050000000000000003 * double(fVslider0)))); double fSlow1 = (1.0 - double(fCheckbox0)); double fSlow2 = (fSlow1 * (1.0 - double(fCheckbox1))); double fSlow3 = (0.0010000000000000009 * std::pow(10.0, (0.050000000000000003 * double(fVslider1)))); double fSlow4 = (fSlow1 * (1.0 - double(fCheckbox2))); double fSlow5 = (fSlow1 * (1.0 - double(fCheckbox3))); double fSlow6 = (fSlow1 * (1.0 - double(fCheckbox4))); double fSlow7 = (fSlow1 * (1.0 - double(fCheckbox5))); double fSlow8 = (1.0 - double(fCheckbox6)); double fSlow9 = (fSlow8 * (1.0 - double(fCheckbox7))); double fSlow10 = (fSlow8 * (1.0 - double(fCheckbox8))); double fSlow11 = (fSlow8 * (1.0 - double(fCheckbox9))); double fSlow12 = ((1.0 - double(fCheckbox10)) * (1.0 - double(fCheckbox11))); for (int i = 0; (i < count); i = (i + 1)) { fRec1[0] = (fSlow0 + (0.999 * fRec1[1])); fRec3[0] = (fSlow3 + (0.999 * fRec3[1])); double fTemp0 = (fSlow2 * (double(input8[i]) * fRec3[0])); fRec2[0] = std::max<double>((fRec2[1] - fConst0), std::min<double>(6.0, (20.0 * std::log10(std::max<double>(0.00031622776601683794, std::fabs(fTemp0)))))); fVbargraph0 = FAUSTFLOAT(fRec2[0]); fVec0[(IOTA & 127)] = fTemp0; double fTemp1 = fVec0[((IOTA - 121) & 127)]; double fTemp2 = fVec0[((IOTA - 110) & 127)]; double fTemp3 = fVec0[((IOTA - 75) & 127)]; double fTemp4 = fVec0[((IOTA - 74) & 127)]; double fTemp5 = fVec0[((IOTA - 70) & 127)]; double fTemp6 = fVec0[((IOTA - 72) & 127)]; double fTemp7 = fVec0[((IOTA - 71) & 127)]; double fTemp8 = fVec0[((IOTA - 53) & 127)]; double fTemp9 = fVec0[((IOTA - 42) & 127)]; double fTemp10 = fVec0[((IOTA - 38) & 127)]; double fTemp11 = (fSlow4 * (double(input7[i]) * fRec3[0])); fRec4[0] = std::max<double>((fRec4[1] - fConst0), std::min<double>(6.0, (20.0 * std::log10(std::max<double>(0.00031622776601683794, std::fabs(fTemp11)))))); fVbargraph1 = FAUSTFLOAT(fRec4[0]); fVec1[(IOTA & 127)] = fTemp11; double fTemp12 = fVec1[((IOTA - 125) & 127)]; double fTemp13 = fVec1[((IOTA - 117) & 127)]; double fTemp14 = fVec1[((IOTA - 116) & 127)]; double fTemp15 = fVec1[((IOTA - 121) & 127)]; double fTemp16 = fVec1[((IOTA - 111) & 127)]; double fTemp17 = fVec1[((IOTA - 110) & 127)]; double fTemp18 = fVec1[((IOTA - 103) & 127)]; double fTemp19 = fVec1[((IOTA - 102) & 127)]; double fTemp20 = fVec1[((IOTA - 101) & 127)]; double fTemp21 = fVec1[((IOTA - 94) & 127)]; double fTemp22 = fVec1[((IOTA - 100) & 127)]; double fTemp23 = fVec1[((IOTA - 99) & 127)]; double fTemp24 = fVec1[((IOTA - 93) & 127)]; double fTemp25 = fVec1[((IOTA - 77) & 127)]; double fTemp26 = fVec1[((IOTA - 76) & 127)]; double fTemp27 = fVec1[((IOTA - 68) & 127)]; double fTemp28 = fVec1[((IOTA - 72) & 127)]; double fTemp29 = fVec1[((IOTA - 70) & 127)]; double fTemp30 = fVec1[((IOTA - 67) & 127)]; double fTemp31 = fVec1[((IOTA - 66) & 127)]; double fTemp32 = fVec1[((IOTA - 59) & 127)]; double fTemp33 = fVec1[((IOTA - 44) & 127)]; double fTemp34 = fVec1[((IOTA - 41) & 127)]; double fTemp35 = fVec1[((IOTA - 32) & 127)]; double fTemp36 = fVec1[((IOTA - 31) & 127)]; double fTemp37 = fVec1[((IOTA - 29) & 127)]; double fTemp38 = fVec1[((IOTA - 26) & 127)]; double fTemp39 = fVec1[((IOTA - 25) & 127)]; double fTemp40 = fVec0[((IOTA - 126) & 127)]; double fTemp41 = fVec0[((IOTA - 122) & 127)]; double fTemp42 = fVec0[((IOTA - 95) & 127)]; double fTemp43 = fVec0[((IOTA - 96) & 127)]; double fTemp44 = fVec0[((IOTA - 94) & 127)]; double fTemp45 = fVec0[((IOTA - 91) & 127)]; double fTemp46 = fVec0[((IOTA - 104) & 127)]; double fTemp47 = fVec0[((IOTA - 103) & 127)]; double fTemp48 = fVec0[((IOTA - 77) & 127)]; double fTemp49 = fVec0[((IOTA - 79) & 127)]; double fTemp50 = fVec0[((IOTA - 76) & 127)]; double fTemp51 = fVec0[((IOTA - 68) & 127)]; double fTemp52 = fVec0[((IOTA - 67) & 127)]; double fTemp53 = fVec0[((IOTA - 66) & 127)]; double fTemp54 = fVec0[((IOTA - 65) & 127)]; double fTemp55 = fVec0[((IOTA - 64) & 127)]; double fTemp56 = fVec0[((IOTA - 20) & 127)]; double fTemp57 = fVec0[((IOTA - 19) & 127)]; double fTemp58 = fVec0[((IOTA - 18) & 127)]; double fTemp59 = fVec0[((IOTA - 10) & 127)]; double fTemp60 = fVec0[((IOTA - 8) & 127)]; double fTemp61 = fVec0[((IOTA - 6) & 127)]; double fTemp62 = fVec0[((IOTA - 4) & 127)]; double fTemp63 = fVec0[((IOTA - 2) & 127)]; double fTemp64 = fVec1[((IOTA - 126) & 127)]; double fTemp65 = fVec1[((IOTA - 104) & 127)]; double fTemp66 = fVec1[((IOTA - 106) & 127)]; double fTemp67 = fVec1[((IOTA - 105) & 127)]; double fTemp68 = fVec1[((IOTA - 98) & 127)]; double fTemp69 = fVec1[((IOTA - 97) & 127)]; double fTemp70 = fVec1[((IOTA - 50) & 127)]; double fTemp71 = (fSlow5 * (double(input6[i]) * fRec3[0])); fRec5[0] = std::max<double>((fRec5[1] - fConst0), std::min<double>(6.0, (20.0 * std::log10(std::max<double>(0.00031622776601683794, std::fabs(fTemp71)))))); fVbargraph2 = FAUSTFLOAT(fRec5[0]); fVec2[(IOTA & 127)] = fTemp71; double fTemp72 = fVec2[((IOTA - 94) & 127)]; double fTemp73 = fVec2[((IOTA - 93) & 127)]; double fTemp74 = fVec2[((IOTA - 92) & 127)]; double fTemp75 = fVec2[((IOTA - 110) & 127)]; double fTemp76 = fVec2[((IOTA - 91) & 127)]; double fTemp77 = fVec2[((IOTA - 109) & 127)]; double fTemp78 = fVec2[((IOTA - 90) & 127)]; double fTemp79 = fVec2[((IOTA - 22) & 127)]; double fTemp80 = (fSlow6 * (double(input5[i]) * fRec3[0])); fRec6[0] = std::max<double>((fRec6[1] - fConst0), std::min<double>(6.0, (20.0 * std::log10(std::max<double>(0.00031622776601683794, std::fabs(fTemp80)))))); fVbargraph3 = FAUSTFLOAT(fRec6[0]); fVec3[(IOTA & 127)] = fTemp80; double fTemp81 = fVec3[((IOTA - 123) & 127)]; double fTemp82 = fVec2[((IOTA - 24) & 127)]; double fTemp83 = fVec3[((IOTA - 107) & 127)]; double fTemp84 = fVec3[((IOTA - 104) & 127)]; double fTemp85 = fVec3[((IOTA - 103) & 127)]; double fTemp86 = fVec3[((IOTA - 102) & 127)]; double fTemp87 = fVec3[((IOTA - 106) & 127)]; double fTemp88 = fVec3[((IOTA - 105) & 127)]; double fTemp89 = fVec2[((IOTA - 26) & 127)]; double fTemp90 = fVec2[((IOTA - 25) & 127)]; double fTemp91 = fVec3[((IOTA - 99) & 127)]; double fTemp92 = fVec1[((IOTA - 18) & 127)]; double fTemp93 = fVec1[((IOTA - 19) & 127)]; double fTemp94 = fVec1[((IOTA - 15) & 127)]; double fTemp95 = fVec1[((IOTA - 12) & 127)]; double fTemp96 = fVec1[((IOTA - 11) & 127)]; double fTemp97 = fVec1[((IOTA - 9) & 127)]; double fTemp98 = fVec1[((IOTA - 10) & 127)]; double fTemp99 = fVec1[((IOTA - 3) & 127)]; double fTemp100 = fVec1[((IOTA - 2) & 127)]; double fTemp101 = fVec1[((IOTA - 7) & 127)]; double fTemp102 = fVec1[((IOTA - 6) & 127)]; double fTemp103 = fVec2[((IOTA - 118) & 127)]; double fTemp104 = fVec2[((IOTA - 108) & 127)]; double fTemp105 = fVec2[((IOTA - 107) & 127)]; double fTemp106 = fVec2[((IOTA - 105) & 127)]; double fTemp107 = fVec2[((IOTA - 104) & 127)]; double fTemp108 = fVec2[((IOTA - 102) & 127)]; double fTemp109 = fVec2[((IOTA - 101) & 127)]; double fTemp110 = fVec2[((IOTA - 100) & 127)]; double fTemp111 = fVec2[((IOTA - 99) & 127)]; double fTemp112 = fVec2[((IOTA - 98) & 127)]; double fTemp113 = fVec2[((IOTA - 106) & 127)]; double fTemp114 = fVec2[((IOTA - 119) & 127)]; double fTemp115 = fVec2[((IOTA - 126) & 127)]; double fTemp116 = fVec2[((IOTA - 88) & 127)]; double fTemp117 = fVec2[((IOTA - 97) & 127)]; double fTemp118 = fVec2[((IOTA - 87) & 127)]; double fTemp119 = fVec2[((IOTA - 84) & 127)]; double fTemp120 = fVec2[((IOTA - 83) & 127)]; double fTemp121 = fVec2[((IOTA - 79) & 127)]; double fTemp122 = fVec2[((IOTA - 82) & 127)]; double fTemp123 = fVec2[((IOTA - 75) & 127)]; double fTemp124 = fVec2[((IOTA - 72) & 127)]; double fTemp125 = fVec2[((IOTA - 71) & 127)]; double fTemp126 = fVec2[((IOTA - 70) & 127)]; double fTemp127 = fVec2[((IOTA - 66) & 127)]; double fTemp128 = fVec2[((IOTA - 64) & 127)]; double fTemp129 = fVec2[((IOTA - 60) & 127)]; double fTemp130 = fVec2[((IOTA - 52) & 127)]; double fTemp131 = fVec2[((IOTA - 63) & 127)]; double fTemp132 = fVec2[((IOTA - 65) & 127)]; double fTemp133 = fVec3[((IOTA - 126) & 127)]; double fTemp134 = fVec3[((IOTA - 125) & 127)]; double fTemp135 = fVec3[((IOTA - 124) & 127)]; double fTemp136 = fVec3[((IOTA - 116) & 127)]; double fTemp137 = fVec3[((IOTA - 113) & 127)]; double fTemp138 = fVec3[((IOTA - 110) & 127)]; double fTemp139 = fVec3[((IOTA - 108) & 127)]; double fTemp140 = fVec3[((IOTA - 109) & 127)]; double fTemp141 = fVec3[((IOTA - 98) & 127)]; double fTemp142 = fVec3[((IOTA - 97) & 127)]; double fTemp143 = fVec3[((IOTA - 96) & 127)]; double fTemp144 = fVec3[((IOTA - 95) & 127)]; double fTemp145 = fVec3[((IOTA - 94) & 127)]; double fTemp146 = fVec3[((IOTA - 93) & 127)]; double fTemp147 = fVec3[((IOTA - 92) & 127)]; double fTemp148 = fVec3[((IOTA - 91) & 127)]; double fTemp149 = fVec3[((IOTA - 90) & 127)]; double fTemp150 = fVec3[((IOTA - 89) & 127)]; double fTemp151 = fVec3[((IOTA - 88) & 127)]; double fTemp152 = fVec3[((IOTA - 115) & 127)]; double fTemp153 = fVec3[((IOTA - 114) & 127)]; double fTemp154 = fVec3[((IOTA - 86) & 127)]; double fTemp155 = fVec3[((IOTA - 85) & 127)]; double fTemp156 = fVec3[((IOTA - 83) & 127)]; double fTemp157 = fVec3[((IOTA - 77) & 127)]; double fTemp158 = fVec3[((IOTA - 76) & 127)]; double fTemp159 = fVec3[((IOTA - 87) & 127)]; double fTemp160 = fVec3[((IOTA - 75) & 127)]; double fTemp161 = fVec3[((IOTA - 78) & 127)]; double fTemp162 = fVec3[((IOTA - 74) & 127)]; double fTemp163 = fVec3[((IOTA - 73) & 127)]; double fTemp164 = fVec3[((IOTA - 71) & 127)]; double fTemp165 = fVec3[((IOTA - 72) & 127)]; double fTemp166 = fVec3[((IOTA - 64) & 127)]; double fTemp167 = fVec3[((IOTA - 60) & 127)]; double fTemp168 = fVec3[((IOTA - 35) & 127)]; double fTemp169 = fVec3[((IOTA - 38) & 127)]; double fTemp170 = fVec3[((IOTA - 33) & 127)]; double fTemp171 = fVec3[((IOTA - 32) & 127)]; double fTemp172 = fVec3[((IOTA - 36) & 127)]; double fTemp173 = fVec3[((IOTA - 29) & 127)]; double fTemp174 = fVec3[((IOTA - 28) & 127)]; double fTemp175 = fVec3[((IOTA - 23) & 127)]; double fTemp176 = fVec3[((IOTA - 24) & 127)]; double fTemp177 = fVec3[((IOTA - 21) & 127)]; double fTemp178 = fVec3[((IOTA - 22) & 127)]; double fTemp179 = fVec3[((IOTA - 20) & 127)]; double fTemp180 = fVec3[((IOTA - 17) & 127)]; double fTemp181 = fVec3[((IOTA - 13) & 127)]; double fTemp182 = fVec3[((IOTA - 14) & 127)]; double fTemp183 = fVec3[((IOTA - 10) & 127)]; double fTemp184 = fVec3[((IOTA - 8) & 127)]; double fTemp185 = fVec3[((IOTA - 6) & 127)]; double fTemp186 = fVec3[((IOTA - 5) & 127)]; double fTemp187 = fVec3[((IOTA - 4) & 127)]; double fTemp188 = fVec3[((IOTA - 2) & 127)]; double fTemp189 = fVec3[((IOTA - 1) & 127)]; double fTemp190 = fVec3[((IOTA - 39) & 127)]; double fTemp191 = (fSlow7 * (double(input4[i]) * fRec3[0])); fRec7[0] = std::max<double>((fRec7[1] - fConst0), std::min<double>(6.0, (20.0 * std::log10(std::max<double>(0.00031622776601683794, std::fabs(fTemp191)))))); fVbargraph4 = FAUSTFLOAT(fRec7[0]); fVec4[(IOTA & 127)] = fTemp191; double fTemp192 = fVec4[((IOTA - 119) & 127)]; double fTemp193 = fVec3[((IOTA - 40) & 127)]; double fTemp194 = fVec4[((IOTA - 117) & 127)]; double fTemp195 = fVec4[((IOTA - 116) & 127)]; double fTemp196 = fVec4[((IOTA - 113) & 127)]; double fTemp197 = fVec4[((IOTA - 125) & 127)]; double fTemp198 = fVec4[((IOTA - 114) & 127)]; double fTemp199 = fVec4[((IOTA - 111) & 127)]; double fTemp200 = fVec4[((IOTA - 110) & 127)]; double fTemp201 = fVec4[((IOTA - 112) & 127)]; double fTemp202 = fVec4[((IOTA - 106) & 127)]; double fTemp203 = fVec4[((IOTA - 105) & 127)]; double fTemp204 = fVec4[((IOTA - 108) & 127)]; double fTemp205 = fVec4[((IOTA - 104) & 127)]; double fTemp206 = fVec4[((IOTA - 126) & 127)]; double fTemp207 = fVec4[((IOTA - 124) & 127)]; double fTemp208 = fVec4[((IOTA - 101) & 127)]; double fTemp209 = fVec4[((IOTA - 98) & 127)]; double fTemp210 = fVec4[((IOTA - 97) & 127)]; double fTemp211 = fVec4[((IOTA - 93) & 127)]; double fTemp212 = fVec4[((IOTA - 95) & 127)]; double fTemp213 = fVec4[((IOTA - 87) & 127)]; double fTemp214 = fVec4[((IOTA - 86) & 127)]; double fTemp215 = fVec4[((IOTA - 75) & 127)]; double fTemp216 = fVec4[((IOTA - 83) & 127)]; double fTemp217 = fVec4[((IOTA - 94) & 127)]; double fTemp218 = fVec4[((IOTA - 107) & 127)]; double fTemp219 = fVec4[((IOTA - 74) & 127)]; double fTemp220 = fVec4[((IOTA - 62) & 127)]; double fTemp221 = fVec4[((IOTA - 50) & 127)]; double fTemp222 = fVec4[((IOTA - 48) & 127)]; double fTemp223 = fVec4[((IOTA - 49) & 127)]; double fTemp224 = fVec4[((IOTA - 45) & 127)]; double fTemp225 = fVec4[((IOTA - 42) & 127)]; double fTemp226 = fVec4[((IOTA - 44) & 127)]; double fTemp227 = fVec4[((IOTA - 40) & 127)]; double fTemp228 = fVec4[((IOTA - 38) & 127)]; double fTemp229 = fVec4[((IOTA - 39) & 127)]; double fTemp230 = fVec4[((IOTA - 37) & 127)]; double fTemp231 = fVec4[((IOTA - 36) & 127)]; double fTemp232 = fVec4[((IOTA - 35) & 127)]; double fTemp233 = fVec4[((IOTA - 31) & 127)]; double fTemp234 = fVec4[((IOTA - 30) & 127)]; double fTemp235 = fVec0[((IOTA - 117) & 127)]; double fTemp236 = fVec0[((IOTA - 33) & 127)]; double fTemp237 = fVec0[((IOTA - 34) & 127)]; double fTemp238 = fVec1[((IOTA - 64) & 127)]; double fTemp239 = fVec1[((IOTA - 86) & 127)]; double fTemp240 = fVec1[((IOTA - 85) & 127)]; double fTemp241 = fVec1[((IOTA - 63) & 127)]; double fTemp242 = fVec1[((IOTA - 62) & 127)]; double fTemp243 = fVec1[((IOTA - 58) & 127)]; double fTemp244 = fVec1[((IOTA - 57) & 127)]; double fTemp245 = fVec1[((IOTA - 54) & 127)]; double fTemp246 = fVec1[((IOTA - 55) & 127)]; double fTemp247 = fVec1[((IOTA - 56) & 127)]; double fTemp248 = fVec1[((IOTA - 36) & 127)]; double fTemp249 = fVec1[((IOTA - 38) & 127)]; double fTemp250 = fVec1[((IOTA - 35) & 127)]; double fTemp251 = fVec2[((IOTA - 20) & 127)]; double fTemp252 = fVec2[((IOTA - 21) & 127)]; double fTemp253 = fVec2[((IOTA - 19) & 127)]; double fTemp254 = fVec2[((IOTA - 18) & 127)]; double fTemp255 = fVec2[((IOTA - 10) & 127)]; double fTemp256 = fVec2[((IOTA - 8) & 127)]; double fTemp257 = fVec2[((IOTA - 6) & 127)]; double fTemp258 = fVec2[((IOTA - 2) & 127)]; double fTemp259 = fVec4[((IOTA - 123) & 127)]; double fTemp260 = fVec4[((IOTA - 92) & 127)]; double fTemp261 = fVec4[((IOTA - 78) & 127)]; double fTemp262 = fVec4[((IOTA - 59) & 127)]; double fTemp263 = fVec4[((IOTA - 58) & 127)]; double fTemp264 = fVec4[((IOTA - 52) & 127)]; double fTemp265 = (fSlow9 * (double(input3[i]) * fRec3[0])); fRec8[0] = std::max<double>((fRec8[1] - fConst0), std::min<double>(6.0, (20.0 * std::log10(std::max<double>(0.00031622776601683794, std::fabs(fTemp265)))))); fVbargraph5 = FAUSTFLOAT(fRec8[0]); fVec5[(IOTA & 127)] = fTemp265; double fTemp266 = fVec5[((IOTA - 125) & 127)]; double fTemp267 = fVec4[((IOTA - 57) & 127)]; double fTemp268 = fVec4[((IOTA - 56) & 127)]; double fTemp269 = fVec5[((IOTA - 123) & 127)]; double fTemp270 = fVec0[((IOTA - 120) & 127)]; double fTemp271 = fVec0[((IOTA - 86) & 127)]; double fTemp272 = fVec0[((IOTA - 69) & 127)]; double fTemp273 = fVec0[((IOTA - 28) & 127)]; double fTemp274 = fVec0[((IOTA - 30) & 127)]; double fTemp275 = fVec0[((IOTA - 29) & 127)]; double fTemp276 = fVec0[((IOTA - 27) & 127)]; double fTemp277 = fVec0[((IOTA - 24) & 127)]; double fTemp278 = fVec0[((IOTA - 23) & 127)]; double fTemp279 = fVec0[((IOTA - 26) & 127)]; double fTemp280 = fVec1[((IOTA - 108) & 127)]; double fTemp281 = fVec1[((IOTA - 107) & 127)]; double fTemp282 = fVec1[((IOTA - 71) & 127)]; double fTemp283 = fVec1[((IOTA - 61) & 127)]; double fTemp284 = fVec1[((IOTA - 51) & 127)]; double fTemp285 = fVec3[((IOTA - 67) & 127)]; double fTemp286 = (fSlow10 * (double(input1[i]) * fRec3[0])); fRec9[0] = std::max<double>((fRec9[1] - fConst0), std::min<double>(6.0, (20.0 * std::log10(std::max<double>(0.00031622776601683794, std::fabs(fTemp286)))))); fVbargraph6 = FAUSTFLOAT(fRec9[0]); fVec6[(IOTA & 127)] = fTemp286; double fTemp287 = fVec6[((IOTA - 99) & 127)]; double fTemp288 = fVec4[((IOTA - 61) & 127)]; double fTemp289 = fVec4[((IOTA - 4) & 127)]; double fTemp290 = fVec4[((IOTA - 2) & 127)]; double fTemp291 = fVec4[((IOTA - 1) & 127)]; double fTemp292 = fVec4[((IOTA - 18) & 127)]; double fTemp293 = fVec4[((IOTA - 17) & 127)]; double fTemp294 = fVec4[((IOTA - 16) & 127)]; double fTemp295 = fVec4[((IOTA - 15) & 127)]; double fTemp296 = fVec4[((IOTA - 13) & 127)]; double fTemp297 = fVec4[((IOTA - 10) & 127)]; double fTemp298 = fVec4[((IOTA - 8) & 127)]; double fTemp299 = fVec4[((IOTA - 6) & 127)]; double fTemp300 = fVec5[((IOTA - 121) & 127)]; double fTemp301 = fVec5[((IOTA - 126) & 127)]; double fTemp302 = fVec4[((IOTA - 26) & 127)]; double fTemp303 = fVec4[((IOTA - 25) & 127)]; double fTemp304 = fVec5[((IOTA - 120) & 127)]; double fTemp305 = fVec5[((IOTA - 119) & 127)]; double fTemp306 = fVec5[((IOTA - 117) & 127)]; double fTemp307 = fVec5[((IOTA - 116) & 127)]; double fTemp308 = fVec5[((IOTA - 95) & 127)]; double fTemp309 = fVec5[((IOTA - 96) & 127)]; double fTemp310 = fVec5[((IOTA - 94) & 127)]; double fTemp311 = fVec5[((IOTA - 91) & 127)]; double fTemp312 = fVec5[((IOTA - 90) & 127)]; double fTemp313 = fVec5[((IOTA - 85) & 127)]; double fTemp314 = fVec5[((IOTA - 84) & 127)]; double fTemp315 = fVec5[((IOTA - 87) & 127)]; double fTemp316 = fVec5[((IOTA - 83) & 127)]; double fTemp317 = fVec5[((IOTA - 64) & 127)]; double fTemp318 = fVec5[((IOTA - 62) & 127)]; double fTemp319 = fVec5[((IOTA - 57) & 127)]; double fTemp320 = fVec5[((IOTA - 56) & 127)]; double fTemp321 = fVec5[((IOTA - 63) & 127)]; double fTemp322 = fVec5[((IOTA - 65) & 127)]; double fTemp323 = fVec5[((IOTA - 52) & 127)]; double fTemp324 = fVec5[((IOTA - 51) & 127)]; double fTemp325 = fVec5[((IOTA - 53) & 127)]; double fTemp326 = fVec5[((IOTA - 55) & 127)]; double fTemp327 = fVec5[((IOTA - 54) & 127)]; double fTemp328 = fVec5[((IOTA - 43) & 127)]; double fTemp329 = fVec5[((IOTA - 49) & 127)]; double fTemp330 = fVec5[((IOTA - 48) & 127)]; double fTemp331 = fVec5[((IOTA - 42) & 127)]; double fTemp332 = fVec5[((IOTA - 39) & 127)]; double fTemp333 = fVec5[((IOTA - 37) & 127)]; double fTemp334 = fVec5[((IOTA - 36) & 127)]; double fTemp335 = fVec5[((IOTA - 33) & 127)]; double fTemp336 = fVec5[((IOTA - 34) & 127)]; double fTemp337 = fVec5[((IOTA - 38) & 127)]; double fTemp338 = fVec5[((IOTA - 29) & 127)]; double fTemp339 = fVec5[((IOTA - 26) & 127)]; double fTemp340 = fVec5[((IOTA - 23) & 127)]; double fTemp341 = fVec5[((IOTA - 22) & 127)]; double fTemp342 = fVec5[((IOTA - 45) & 127)]; double fTemp343 = fVec5[((IOTA - 44) & 127)]; double fTemp344 = (fSlow11 * (double(input2[i]) * fRec3[0])); fRec10[0] = std::max<double>((fRec10[1] - fConst0), std::min<double>(6.0, (20.0 * std::log10(std::max<double>(0.00031622776601683794, std::fabs(fTemp344)))))); fVbargraph7 = FAUSTFLOAT(fRec10[0]); fVec7[(IOTA & 127)] = fTemp344; double fTemp345 = fVec7[((IOTA - 122) & 127)]; double fTemp346 = fVec7[((IOTA - 121) & 127)]; double fTemp347 = fVec7[((IOTA - 119) & 127)]; double fTemp348 = fVec7[((IOTA - 120) & 127)]; double fTemp349 = fVec7[((IOTA - 118) & 127)]; double fTemp350 = fVec7[((IOTA - 116) & 127)]; double fTemp351 = fVec7[((IOTA - 117) & 127)]; double fTemp352 = fVec7[((IOTA - 125) & 127)]; double fTemp353 = fVec7[((IOTA - 98) & 127)]; double fTemp354 = fVec7[((IOTA - 97) & 127)]; double fTemp355 = fVec7[((IOTA - 94) & 127)]; double fTemp356 = fVec7[((IOTA - 93) & 127)]; double fTemp357 = fVec7[((IOTA - 90) & 127)]; double fTemp358 = fVec7[((IOTA - 92) & 127)]; double fTemp359 = fVec7[((IOTA - 89) & 127)]; double fTemp360 = fVec7[((IOTA - 88) & 127)]; double fTemp361 = fVec7[((IOTA - 87) & 127)]; double fTemp362 = fVec7[((IOTA - 86) & 127)]; double fTemp363 = fVec7[((IOTA - 85) & 127)]; double fTemp364 = fVec7[((IOTA - 77) & 127)]; double fTemp365 = fVec7[((IOTA - 78) & 127)]; double fTemp366 = fVec7[((IOTA - 75) & 127)]; double fTemp367 = fVec7[((IOTA - 84) & 127)]; double fTemp368 = fVec7[((IOTA - 62) & 127)]; double fTemp369 = fVec7[((IOTA - 63) & 127)]; double fTemp370 = fVec7[((IOTA - 58) & 127)]; double fTemp371 = fVec7[((IOTA - 60) & 127)]; double fTemp372 = fVec7[((IOTA - 59) & 127)]; double fTemp373 = fVec7[((IOTA - 83) & 127)]; double fTemp374 = fVec7[((IOTA - 54) & 127)]; double fTemp375 = fVec7[((IOTA - 52) & 127)]; double fTemp376 = fVec7[((IOTA - 48) & 127)]; double fTemp377 = fVec7[((IOTA - 47) & 127)]; double fTemp378 = fVec7[((IOTA - 53) & 127)]; double fTemp379 = fVec7[((IOTA - 50) & 127)]; double fTemp380 = fVec7[((IOTA - 51) & 127)]; double fTemp381 = fVec7[((IOTA - 45) & 127)]; double fTemp382 = fVec7[((IOTA - 42) & 127)]; double fTemp383 = fVec7[((IOTA - 46) & 127)]; double fTemp384 = fVec7[((IOTA - 44) & 127)]; double fTemp385 = fVec7[((IOTA - 40) & 127)]; double fTemp386 = fVec7[((IOTA - 39) & 127)]; double fTemp387 = fVec7[((IOTA - 41) & 127)]; double fTemp388 = fVec7[((IOTA - 33) & 127)]; double fTemp389 = fVec7[((IOTA - 36) & 127)]; double fTemp390 = fVec7[((IOTA - 35) & 127)]; double fTemp391 = fVec7[((IOTA - 32) & 127)]; double fTemp392 = fVec7[((IOTA - 29) & 127)]; double fTemp393 = fVec7[((IOTA - 28) & 127)]; double fTemp394 = fVec7[((IOTA - 24) & 127)]; double fTemp395 = fVec7[((IOTA - 26) & 127)]; double fTemp396 = fVec7[((IOTA - 21) & 127)]; double fTemp397 = fVec7[((IOTA - 20) & 127)]; double fTemp398 = fVec7[((IOTA - 17) & 127)]; double fTemp399 = fVec7[((IOTA - 14) & 127)]; double fTemp400 = fVec7[((IOTA - 13) & 127)]; double fTemp401 = fVec7[((IOTA - 8) & 127)]; double fTemp402 = fVec7[((IOTA - 5) & 127)]; double fTemp403 = fVec7[((IOTA - 4) & 127)]; double fTemp404 = fVec7[((IOTA - 2) & 127)]; double fTemp405 = fVec7[((IOTA - 1) & 127)]; double fTemp406 = fVec6[((IOTA - 114) & 127)]; double fTemp407 = fVec6[((IOTA - 105) & 127)]; double fTemp408 = fVec6[((IOTA - 103) & 127)]; double fTemp409 = fVec6[((IOTA - 102) & 127)]; double fTemp410 = fVec6[((IOTA - 104) & 127)]; double fTemp411 = fVec6[((IOTA - 98) & 127)]; double fTemp412 = fVec6[((IOTA - 95) & 127)]; double fTemp413 = fVec6[((IOTA - 92) & 127)]; double fTemp414 = fVec6[((IOTA - 90) & 127)]; double fTemp415 = fVec6[((IOTA - 101) & 127)]; double fTemp416 = fVec6[((IOTA - 100) & 127)]; double fTemp417 = fVec6[((IOTA - 88) & 127)]; double fTemp418 = fVec6[((IOTA - 87) & 127)]; double fTemp419 = fVec6[((IOTA - 86) & 127)]; double fTemp420 = fVec6[((IOTA - 85) & 127)]; double fTemp421 = fVec6[((IOTA - 97) & 127)]; double fTemp422 = fVec6[((IOTA - 84) & 127)]; double fTemp423 = fVec6[((IOTA - 83) & 127)]; double fTemp424 = fVec6[((IOTA - 94) & 127)]; double fTemp425 = fVec6[((IOTA - 80) & 127)]; double fTemp426 = fVec6[((IOTA - 79) & 127)]; double fTemp427 = fVec6[((IOTA - 77) & 127)]; double fTemp428 = fVec6[((IOTA - 89) & 127)]; double fTemp429 = fVec6[((IOTA - 96) & 127)]; double fTemp430 = fVec6[((IOTA - 82) & 127)]; double fTemp431 = fVec6[((IOTA - 93) & 127)]; double fTemp432 = (fSlow12 * (double(input0[i]) * fRec3[0])); fRec11[0] = std::max<double>((fRec11[1] - fConst0), std::min<double>(6.0, (20.0 * std::log10(std::max<double>(0.00031622776601683794, std::fabs(fTemp432)))))); fVbargraph8 = FAUSTFLOAT(fRec11[0]); fVec8[(IOTA & 127)] = fTemp432; double fTemp433 = fVec8[((IOTA - 125) & 127)]; double fTemp434 = fVec8[((IOTA - 121) & 127)]; double fTemp435 = fVec8[((IOTA - 124) & 127)]; double fTemp436 = fVec8[((IOTA - 119) & 127)]; double fTemp437 = fVec8[((IOTA - 120) & 127)]; double fTemp438 = fVec8[((IOTA - 122) & 127)]; double fTemp439 = fVec8[((IOTA - 118) & 127)]; double fTemp440 = fVec8[((IOTA - 111) & 127)]; double fTemp441 = fVec8[((IOTA - 113) & 127)]; double fTemp442 = fVec8[((IOTA - 109) & 127)]; double fTemp443 = fVec8[((IOTA - 110) & 127)]; double fTemp444 = fVec8[((IOTA - 112) & 127)]; double fTemp445 = fVec8[((IOTA - 114) & 127)]; double fTemp446 = fVec8[((IOTA - 108) & 127)]; double fTemp447 = fVec8[((IOTA - 105) & 127)]; double fTemp448 = fVec8[((IOTA - 104) & 127)]; double fTemp449 = fVec8[((IOTA - 102) & 127)]; double fTemp450 = fVec8[((IOTA - 103) & 127)]; double fTemp451 = fVec8[((IOTA - 98) & 127)]; double fTemp452 = fVec8[((IOTA - 100) & 127)]; double fTemp453 = fVec8[((IOTA - 101) & 127)]; double fTemp454 = fVec8[((IOTA - 96) & 127)]; double fTemp455 = fVec8[((IOTA - 95) & 127)]; double fTemp456 = fVec8[((IOTA - 93) & 127)]; double fTemp457 = fVec8[((IOTA - 94) & 127)]; double fTemp458 = fVec8[((IOTA - 99) & 127)]; double fTemp459 = fVec8[((IOTA - 87) & 127)]; double fTemp460 = fVec8[((IOTA - 85) & 127)]; double fTemp461 = fVec8[((IOTA - 86) & 127)]; double fTemp462 = fVec8[((IOTA - 90) & 127)]; double fTemp463 = fVec8[((IOTA - 76) & 127)]; double fTemp464 = fVec8[((IOTA - 82) & 127)]; double fTemp465 = fVec8[((IOTA - 83) & 127)]; double fTemp466 = fVec8[((IOTA - 75) & 127)]; double fTemp467 = fVec8[((IOTA - 72) & 127)]; double fTemp468 = fVec8[((IOTA - 74) & 127)]; double fTemp469 = fVec8[((IOTA - 71) & 127)]; double fTemp470 = fVec8[((IOTA - 73) & 127)]; double fTemp471 = fVec8[((IOTA - 70) & 127)]; double fTemp472 = fVec8[((IOTA - 69) & 127)]; double fTemp473 = fVec8[((IOTA - 68) & 127)]; double fTemp474 = fVec8[((IOTA - 67) & 127)]; double fTemp475 = fVec8[((IOTA - 66) & 127)]; double fTemp476 = fVec8[((IOTA - 65) & 127)]; double fTemp477 = fVec8[((IOTA - 64) & 127)]; double fTemp478 = fVec8[((IOTA - 62) & 127)]; double fTemp479 = fVec8[((IOTA - 63) & 127)]; double fTemp480 = fVec8[((IOTA - 61) & 127)]; double fTemp481 = fVec8[((IOTA - 60) & 127)]; double fTemp482 = fVec8[((IOTA - 59) & 127)]; double fTemp483 = fVec8[((IOTA - 55) & 127)]; double fTemp484 = fVec8[((IOTA - 56) & 127)]; double fTemp485 = fVec8[((IOTA - 54) & 127)]; double fTemp486 = fVec8[((IOTA - 53) & 127)]; double fTemp487 = fVec8[((IOTA - 52) & 127)]; double fTemp488 = fVec8[((IOTA - 44) & 127)]; double fTemp489 = fVec8[((IOTA - 45) & 127)]; double fTemp490 = fVec8[((IOTA - 43) & 127)]; double fTemp491 = fVec8[((IOTA - 42) & 127)]; double fTemp492 = fVec8[((IOTA - 41) & 127)]; double fTemp493 = fVec8[((IOTA - 40) & 127)]; double fTemp494 = fVec8[((IOTA - 39) & 127)]; double fTemp495 = fVec8[((IOTA - 38) & 127)]; double fTemp496 = fVec8[((IOTA - 29) & 127)]; double fTemp497 = fVec8[((IOTA - 30) & 127)]; double fTemp498 = fVec8[((IOTA - 25) & 127)]; double fTemp499 = fVec8[((IOTA - 27) & 127)]; double fTemp500 = fVec8[((IOTA - 26) & 127)]; double fTemp501 = fVec8[((IOTA - 23) & 127)]; double fTemp502 = fVec8[((IOTA - 22) & 127)]; double fTemp503 = fVec8[((IOTA - 21) & 127)]; double fTemp504 = fVec8[((IOTA - 20) & 127)]; double fTemp505 = fVec8[((IOTA - 19) & 127)]; double fTemp506 = fVec8[((IOTA - 18) & 127)]; double fTemp507 = fVec8[((IOTA - 16) & 127)]; double fTemp508 = fVec8[((IOTA - 17) & 127)]; double fTemp509 = fVec8[((IOTA - 15) & 127)]; double fTemp510 = fVec8[((IOTA - 14) & 127)]; double fTemp511 = fVec3[((IOTA - 84) & 127)]; double fTemp512 = fVec3[((IOTA - 101) & 127)]; double fTemp513 = fVec3[((IOTA - 100) & 127)]; double fTemp514 = fVec3[((IOTA - 119) & 127)]; double fTemp515 = fVec3[((IOTA - 54) & 127)]; double fTemp516 = fVec3[((IOTA - 49) & 127)]; double fTemp517 = fVec3[((IOTA - 47) & 127)]; double fTemp518 = fVec3[((IOTA - 48) & 127)]; double fTemp519 = fVec3[((IOTA - 45) & 127)]; double fTemp520 = fVec3[((IOTA - 51) & 127)]; double fTemp521 = fVec3[((IOTA - 52) & 127)]; double fTemp522 = fVec3[((IOTA - 42) & 127)]; double fTemp523 = fVec4[((IOTA - 120) & 127)]; double fTemp524 = fVec4[((IOTA - 121) & 127)]; double fTemp525 = fVec4[((IOTA - 67) & 127)]; double fTemp526 = fVec4[((IOTA - 66) & 127)]; double fTemp527 = fVec4[((IOTA - 68) & 127)]; double fTemp528 = fVec5[((IOTA - 20) & 127)]; double fTemp529 = fVec5[((IOTA - 18) & 127)]; double fTemp530 = fVec5[((IOTA - 17) & 127)]; double fTemp531 = fVec5[((IOTA - 16) & 127)]; double fTemp532 = fVec5[((IOTA - 15) & 127)]; double fTemp533 = fVec5[((IOTA - 13) & 127)]; double fTemp534 = fVec5[((IOTA - 10) & 127)]; double fTemp535 = fVec5[((IOTA - 8) & 127)]; double fTemp536 = fVec5[((IOTA - 6) & 127)]; double fTemp537 = fVec5[((IOTA - 4) & 127)]; double fTemp538 = fVec5[((IOTA - 2) & 127)]; double fTemp539 = fVec5[((IOTA - 1) & 127)]; double fTemp540 = fVec6[((IOTA - 78) & 127)]; double fTemp541 = fVec7[((IOTA - 80) & 127)]; double fTemp542 = fVec7[((IOTA - 79) & 127)]; double fTemp543 = fVec6[((IOTA - 73) & 127)]; double fTemp544 = fVec6[((IOTA - 72) & 127)]; double fTemp545 = fVec6[((IOTA - 71) & 127)]; double fTemp546 = fVec8[((IOTA - 80) & 127)]; double fTemp547 = fVec8[((IOTA - 126) & 127)]; double fTemp548 = fVec8[((IOTA - 123) & 127)]; double fTemp549 = fVec8[((IOTA - 79) & 127)]; double fTemp550 = fVec8[((IOTA - 78) & 127)]; double fTemp551 = fVec8[((IOTA - 77) & 127)]; double fTemp552 = fVec8[((IOTA - 48) & 127)]; double fTemp553 = fVec8[((IOTA - 49) & 127)]; double fTemp554 = fVec8[((IOTA - 46) & 127)]; double fTemp555 = fVec8[((IOTA - 13) & 127)]; double fTemp556 = fVec8[((IOTA - 12) & 127)]; double fTemp557 = fVec8[((IOTA - 11) & 127)]; double fTemp558 = fVec8[((IOTA - 10) & 127)]; double fTemp559 = fVec8[((IOTA - 9) & 127)]; double fTemp560 = fVec8[((IOTA - 8) & 127)]; double fTemp561 = fVec8[((IOTA - 7) & 127)]; double fTemp562 = fVec8[((IOTA - 6) & 127)]; double fTemp563 = fVec8[((IOTA - 5) & 127)]; double fTemp564 = fVec8[((IOTA - 4) & 127)]; double fTemp565 = fVec8[((IOTA - 3) & 127)]; double fTemp566 = fVec8[((IOTA - 1) & 127)]; double fTemp567 = fVec5[((IOTA - 122) & 127)]; double fTemp568 = fVec5[((IOTA - 30) & 127)]; double fTemp569 = fVec5[((IOTA - 115) & 127)]; double fTemp570 = fVec5[((IOTA - 86) & 127)]; double fTemp571 = fVec7[((IOTA - 124) & 127)]; double fTemp572 = fVec7[((IOTA - 123) & 127)]; double fTemp573 = fVec7[((IOTA - 126) & 127)]; double fTemp574 = fVec6[((IOTA - 107) & 127)]; double fTemp575 = fVec8[((IOTA - 117) & 127)]; double fTemp576 = fVec8[((IOTA - 116) & 127)]; double fTemp577 = fVec8[((IOTA - 50) & 127)]; double fTemp578 = fVec8[((IOTA - 51) & 127)]; double fTemp579 = fVec6[((IOTA - 22) & 127)]; double fTemp580 = fVec6[((IOTA - 19) & 127)]; double fTemp581 = fVec6[((IOTA - 20) & 127)]; double fTemp582 = fVec6[((IOTA - 21) & 127)]; double fTemp583 = fVec6[((IOTA - 17) & 127)]; double fTemp584 = fVec6[((IOTA - 18) & 127)]; double fTemp585 = fVec6[((IOTA - 16) & 127)]; double fTemp586 = fVec6[((IOTA - 15) & 127)]; double fTemp587 = fVec6[((IOTA - 13) & 127)]; double fTemp588 = fVec6[((IOTA - 14) & 127)]; double fTemp589 = fVec6[((IOTA - 11) & 127)]; double fTemp590 = fVec6[((IOTA - 12) & 127)]; double fTemp591 = fVec6[((IOTA - 9) & 127)]; double fTemp592 = fVec6[((IOTA - 7) & 127)]; double fTemp593 = fVec6[((IOTA - 5) & 127)]; double fTemp594 = fVec6[((IOTA - 4) & 127)]; double fTemp595 = fVec6[((IOTA - 3) & 127)]; double fTemp596 = fVec6[((IOTA - 1) & 127)]; double fTemp597 = fVec8[((IOTA - 107) & 127)]; double fTemp598 = fVec8[((IOTA - 106) & 127)]; double fTemp599 = fVec8[((IOTA - 115) & 127)]; double fTemp600 = fVec8[((IOTA - 58) & 127)]; double fTemp601 = fVec8[((IOTA - 57) & 127)]; double fTemp602 = fVec8[((IOTA - 37) & 127)]; double fTemp603 = fVec8[((IOTA - 35) & 127)]; double fTemp604 = fVec8[((IOTA - 36) & 127)]; double fTemp605 = fVec8[((IOTA - 34) & 127)]; double fTemp606 = fVec8[((IOTA - 33) & 127)]; double fTemp607 = fVec8[((IOTA - 32) & 127)]; double fTemp608 = fVec8[((IOTA - 31) & 127)]; double fTemp609 = fVec2[((IOTA - 39) & 127)]; double fTemp610 = fVec2[((IOTA - 37) & 127)]; double fTemp611 = fVec2[((IOTA - 36) & 127)]; double fTemp612 = fVec2[((IOTA - 32) & 127)]; double fTemp613 = fVec2[((IOTA - 33) & 127)]; double fTemp614 = fVec2[((IOTA - 29) & 127)]; double fTemp615 = fVec2[((IOTA - 30) & 127)]; double fTemp616 = fVec3[((IOTA - 65) & 127)]; double fTemp617 = fVec2[((IOTA - 28) & 127)]; double fTemp618 = fVec1[((IOTA - 112) & 127)]; double fTemp619 = fVec0[((IOTA - 22) & 127)]; double fTemp620 = fVec0[((IOTA - 125) & 127)]; double fTemp621 = fVec0[((IOTA - 116) & 127)]; double fTemp622 = fVec0[((IOTA - 124) & 127)]; double fTemp623 = fVec0[((IOTA - 123) & 127)]; double fTemp624 = fVec0[((IOTA - 111) & 127)]; double fTemp625 = fVec4[((IOTA - 109) & 127)]; double fTemp626 = fVec1[((IOTA - 78) & 127)]; double fTemp627 = fVec0[((IOTA - 112) & 127)]; double fTemp628 = fVec0[((IOTA - 101) & 127)]; double fTemp629 = fVec0[((IOTA - 100) & 127)]; double fTemp630 = fVec0[((IOTA - 115) & 127)]; double fTemp631 = fVec0[((IOTA - 114) & 127)]; double fTemp632 = fVec0[((IOTA - 99) & 127)]; double fTemp633 = fVec0[((IOTA - 98) & 127)]; double fTemp634 = fVec0[((IOTA - 85) & 127)]; double fTemp635 = fVec0[((IOTA - 73) & 127)]; double fTemp636 = fVec0[((IOTA - 63) & 127)]; double fTemp637 = fVec0[((IOTA - 62) & 127)]; double fTemp638 = fVec0[((IOTA - 59) & 127)]; double fTemp639 = fVec0[((IOTA - 61) & 127)]; double fTemp640 = fVec0[((IOTA - 54) & 127)]; double fTemp641 = fVec0[((IOTA - 55) & 127)]; double fTemp642 = fVec0[((IOTA - 56) & 127)]; double fTemp643 = fVec0[((IOTA - 58) & 127)]; double fTemp644 = fVec0[((IOTA - 57) & 127)]; double fTemp645 = fVec0[((IOTA - 60) & 127)]; double fTemp646 = fVec0[((IOTA - 52) & 127)]; double fTemp647 = fVec0[((IOTA - 51) & 127)]; double fTemp648 = fVec0[((IOTA - 50) & 127)]; double fTemp649 = fVec0[((IOTA - 39) & 127)]; double fTemp650 = fVec0[((IOTA - 40) & 127)]; double fTemp651 = fVec0[((IOTA - 41) & 127)]; double fTemp652 = fVec0[((IOTA - 37) & 127)]; double fTemp653 = fVec0[((IOTA - 36) & 127)]; double fTemp654 = fVec1[((IOTA - 123) & 127)]; double fTemp655 = fVec1[((IOTA - 115) & 127)]; double fTemp656 = fVec1[((IOTA - 114) & 127)]; double fTemp657 = fVec1[((IOTA - 113) & 127)]; double fTemp658 = fVec1[((IOTA - 95) & 127)]; double fTemp659 = fVec1[((IOTA - 109) & 127)]; double fTemp660 = fVec1[((IOTA - 80) & 127)]; double fTemp661 = fVec1[((IOTA - 81) & 127)]; double fTemp662 = fVec1[((IOTA - 79) & 127)]; double fTemp663 = fVec1[((IOTA - 75) & 127)]; double fTemp664 = fVec1[((IOTA - 74) & 127)]; double fTemp665 = fVec1[((IOTA - 73) & 127)]; double fTemp666 = fVec1[((IOTA - 69) & 127)]; double fTemp667 = fVec1[((IOTA - 60) & 127)]; double fTemp668 = fVec1[((IOTA - 49) & 127)]; double fTemp669 = fVec1[((IOTA - 48) & 127)]; double fTemp670 = fVec1[((IOTA - 47) & 127)]; double fTemp671 = fVec1[((IOTA - 46) & 127)]; double fTemp672 = fVec1[((IOTA - 45) & 127)]; double fTemp673 = fVec1[((IOTA - 43) & 127)]; double fTemp674 = fVec1[((IOTA - 40) & 127)]; double fTemp675 = fVec1[((IOTA - 42) & 127)]; double fTemp676 = fVec1[((IOTA - 39) & 127)]; double fTemp677 = fVec1[((IOTA - 34) & 127)]; double fTemp678 = fVec1[((IOTA - 33) & 127)]; double fTemp679 = fVec1[((IOTA - 30) & 127)]; double fTemp680 = fVec1[((IOTA - 27) & 127)]; double fTemp681 = fVec1[((IOTA - 28) & 127)]; double fTemp682 = fVec0[((IOTA - 119) & 127)]; double fTemp683 = fVec0[((IOTA - 97) & 127)]; double fTemp684 = fVec0[((IOTA - 93) & 127)]; double fTemp685 = fVec0[((IOTA - 90) & 127)]; double fTemp686 = fVec0[((IOTA - 92) & 127)]; double fTemp687 = fVec0[((IOTA - 78) & 127)]; double fTemp688 = fVec0[((IOTA - 83) & 127)]; double fTemp689 = fVec0[((IOTA - 82) & 127)]; double fTemp690 = fVec0[((IOTA - 89) & 127)]; double fTemp691 = fVec0[((IOTA - 88) & 127)]; double fTemp692 = fVec0[((IOTA - 44) & 127)]; double fTemp693 = fVec0[((IOTA - 43) & 127)]; double fTemp694 = fVec0[((IOTA - 31) & 127)]; double fTemp695 = fVec0[((IOTA - 21) & 127)]; double fTemp696 = fVec0[((IOTA - 17) & 127)]; double fTemp697 = fVec0[((IOTA - 16) & 127)]; double fTemp698 = fVec0[((IOTA - 15) & 127)]; double fTemp699 = fVec0[((IOTA - 14) & 127)]; double fTemp700 = fVec0[((IOTA - 13) & 127)]; double fTemp701 = fVec0[((IOTA - 12) & 127)]; double fTemp702 = fVec0[((IOTA - 11) & 127)]; double fTemp703 = fVec0[((IOTA - 9) & 127)]; double fTemp704 = fVec0[((IOTA - 7) & 127)]; double fTemp705 = fVec0[((IOTA - 5) & 127)]; double fTemp706 = fVec0[((IOTA - 3) & 127)]; double fTemp707 = fVec0[((IOTA - 1) & 127)]; double fTemp708 = fVec1[((IOTA - 118) & 127)]; double fTemp709 = fVec1[((IOTA - 83) & 127)]; double fTemp710 = fVec1[((IOTA - 88) & 127)]; double fTemp711 = fVec1[((IOTA - 84) & 127)]; double fTemp712 = fVec1[((IOTA - 82) & 127)]; double fTemp713 = fVec2[((IOTA - 117) & 127)]; double fTemp714 = fVec2[((IOTA - 116) & 127)]; double fTemp715 = fVec2[((IOTA - 95) & 127)]; double fTemp716 = fVec2[((IOTA - 23) & 127)]; double fTemp717 = fVec2[((IOTA - 27) & 127)]; double fTemp718 = fVec3[((IOTA - 117) & 127)]; double fTemp719 = fVec3[((IOTA - 118) & 127)]; double fTemp720 = fVec2[((IOTA - 89) & 127)]; double fTemp721 = fVec1[((IOTA - 24) & 127)]; double fTemp722 = fVec1[((IOTA - 23) & 127)]; double fTemp723 = fVec1[((IOTA - 22) & 127)]; double fTemp724 = fVec1[((IOTA - 21) & 127)]; double fTemp725 = fVec1[((IOTA - 20) & 127)]; double fTemp726 = fVec1[((IOTA - 17) & 127)]; double fTemp727 = fVec1[((IOTA - 16) & 127)]; double fTemp728 = fVec1[((IOTA - 14) & 127)]; double fTemp729 = fVec1[((IOTA - 13) & 127)]; double fTemp730 = fVec1[((IOTA - 8) & 127)]; double fTemp731 = fVec1[((IOTA - 1) & 127)]; double fTemp732 = fVec1[((IOTA - 5) & 127)]; double fTemp733 = fVec1[((IOTA - 4) & 127)]; double fTemp734 = fVec2[((IOTA - 124) & 127)]; double fTemp735 = fVec2[((IOTA - 122) & 127)]; double fTemp736 = fVec2[((IOTA - 120) & 127)]; double fTemp737 = fVec2[((IOTA - 123) & 127)]; double fTemp738 = fVec2[((IOTA - 113) & 127)]; double fTemp739 = fVec2[((IOTA - 114) & 127)]; double fTemp740 = fVec2[((IOTA - 103) & 127)]; double fTemp741 = fVec2[((IOTA - 111) & 127)]; double fTemp742 = fVec2[((IOTA - 112) & 127)]; double fTemp743 = fVec2[((IOTA - 121) & 127)]; double fTemp744 = fVec2[((IOTA - 85) & 127)]; double fTemp745 = fVec2[((IOTA - 81) & 127)]; double fTemp746 = fVec2[((IOTA - 78) & 127)]; double fTemp747 = fVec2[((IOTA - 80) & 127)]; double fTemp748 = fVec2[((IOTA - 86) & 127)]; double fTemp749 = fVec2[((IOTA - 77) & 127)]; double fTemp750 = fVec2[((IOTA - 76) & 127)]; double fTemp751 = fVec2[((IOTA - 73) & 127)]; double fTemp752 = fVec2[((IOTA - 74) & 127)]; double fTemp753 = fVec2[((IOTA - 68) & 127)]; double fTemp754 = fVec2[((IOTA - 67) & 127)]; double fTemp755 = fVec2[((IOTA - 62) & 127)]; double fTemp756 = fVec2[((IOTA - 59) & 127)]; double fTemp757 = fVec2[((IOTA - 61) & 127)]; double fTemp758 = fVec2[((IOTA - 58) & 127)]; double fTemp759 = fVec2[((IOTA - 69) & 127)]; double fTemp760 = fVec2[((IOTA - 57) & 127)]; double fTemp761 = fVec2[((IOTA - 54) & 127)]; double fTemp762 = fVec2[((IOTA - 55) & 127)]; double fTemp763 = fVec2[((IOTA - 56) & 127)]; double fTemp764 = fVec2[((IOTA - 51) & 127)]; double fTemp765 = fVec2[((IOTA - 50) & 127)]; double fTemp766 = fVec2[((IOTA - 53) & 127)]; double fTemp767 = fVec2[((IOTA - 47) & 127)]; double fTemp768 = fVec2[((IOTA - 49) & 127)]; double fTemp769 = fVec2[((IOTA - 48) & 127)]; double fTemp770 = fVec2[((IOTA - 46) & 127)]; double fTemp771 = fVec2[((IOTA - 45) & 127)]; double fTemp772 = fVec2[((IOTA - 44) & 127)]; double fTemp773 = fVec2[((IOTA - 43) & 127)]; double fTemp774 = fVec2[((IOTA - 42) & 127)]; double fTemp775 = fVec3[((IOTA - 122) & 127)]; double fTemp776 = fVec3[((IOTA - 121) & 127)]; double fTemp777 = fVec3[((IOTA - 112) & 127)]; double fTemp778 = fVec3[((IOTA - 111) & 127)]; double fTemp779 = fVec3[((IOTA - 120) & 127)]; double fTemp780 = fVec3[((IOTA - 79) & 127)]; double fTemp781 = fVec3[((IOTA - 81) & 127)]; double fTemp782 = fVec3[((IOTA - 82) & 127)]; double fTemp783 = fVec3[((IOTA - 80) & 127)]; double fTemp784 = fVec3[((IOTA - 70) & 127)]; double fTemp785 = fVec3[((IOTA - 69) & 127)]; double fTemp786 = fVec3[((IOTA - 63) & 127)]; double fTemp787 = fVec3[((IOTA - 61) & 127)]; double fTemp788 = fVec3[((IOTA - 68) & 127)]; double fTemp789 = fVec3[((IOTA - 62) & 127)]; double fTemp790 = fVec3[((IOTA - 34) & 127)]; double fTemp791 = fVec3[((IOTA - 30) & 127)]; double fTemp792 = fVec3[((IOTA - 31) & 127)]; double fTemp793 = fVec3[((IOTA - 27) & 127)]; double fTemp794 = fVec3[((IOTA - 26) & 127)]; double fTemp795 = fVec3[((IOTA - 25) & 127)]; double fTemp796 = fVec3[((IOTA - 19) & 127)]; double fTemp797 = fVec3[((IOTA - 18) & 127)]; double fTemp798 = fVec3[((IOTA - 16) & 127)]; double fTemp799 = fVec3[((IOTA - 15) & 127)]; double fTemp800 = fVec3[((IOTA - 12) & 127)]; double fTemp801 = fVec3[((IOTA - 11) & 127)]; double fTemp802 = fVec3[((IOTA - 9) & 127)]; double fTemp803 = fVec3[((IOTA - 7) & 127)]; double fTemp804 = fVec3[((IOTA - 3) & 127)]; double fTemp805 = fVec3[((IOTA - 37) & 127)]; double fTemp806 = fVec4[((IOTA - 118) & 127)]; double fTemp807 = fVec4[((IOTA - 115) & 127)]; double fTemp808 = fVec4[((IOTA - 100) & 127)]; double fTemp809 = fVec4[((IOTA - 99) & 127)]; double fTemp810 = fVec4[((IOTA - 102) & 127)]; double fTemp811 = fVec3[((IOTA - 59) & 127)]; double fTemp812 = fVec4[((IOTA - 96) & 127)]; double fTemp813 = fVec4[((IOTA - 88) & 127)]; double fTemp814 = fVec4[((IOTA - 89) & 127)]; double fTemp815 = fVec4[((IOTA - 85) & 127)]; double fTemp816 = fVec4[((IOTA - 90) & 127)]; double fTemp817 = fVec4[((IOTA - 76) & 127)]; double fTemp818 = fVec4[((IOTA - 84) & 127)]; double fTemp819 = fVec4[((IOTA - 82) & 127)]; double fTemp820 = fVec4[((IOTA - 103) & 127)]; double fTemp821 = fVec4[((IOTA - 64) & 127)]; double fTemp822 = fVec4[((IOTA - 73) & 127)]; double fTemp823 = fVec4[((IOTA - 63) & 127)]; double fTemp824 = fVec4[((IOTA - 60) & 127)]; double fTemp825 = fVec4[((IOTA - 47) & 127)]; double fTemp826 = fVec4[((IOTA - 46) & 127)]; double fTemp827 = fVec4[((IOTA - 43) & 127)]; double fTemp828 = fVec4[((IOTA - 41) & 127)]; double fTemp829 = fVec4[((IOTA - 34) & 127)]; double fTemp830 = fVec4[((IOTA - 32) & 127)]; double fTemp831 = fVec4[((IOTA - 33) & 127)]; double fTemp832 = fVec4[((IOTA - 29) & 127)]; double fTemp833 = fVec4[((IOTA - 27) & 127)]; double fTemp834 = fVec0[((IOTA - 108) & 127)]; double fTemp835 = fVec0[((IOTA - 107) & 127)]; double fTemp836 = fVec0[((IOTA - 105) & 127)]; double fTemp837 = fVec0[((IOTA - 102) & 127)]; double fTemp838 = fVec0[((IOTA - 87) & 127)]; double fTemp839 = fVec0[((IOTA - 80) & 127)]; double fTemp840 = fVec0[((IOTA - 48) & 127)]; double fTemp841 = fVec0[((IOTA - 47) & 127)]; double fTemp842 = fVec0[((IOTA - 46) & 127)]; double fTemp843 = fVec0[((IOTA - 35) & 127)]; double fTemp844 = fVec0[((IOTA - 45) & 127)]; double fTemp845 = fVec0[((IOTA - 32) & 127)]; double fTemp846 = fVec1[((IOTA - 122) & 127)]; double fTemp847 = fVec1[((IOTA - 96) & 127)]; double fTemp848 = fVec1[((IOTA - 90) & 127)]; double fTemp849 = fVec1[((IOTA - 89) & 127)]; double fTemp850 = fVec1[((IOTA - 65) & 127)]; double fTemp851 = fVec1[((IOTA - 87) & 127)]; double fTemp852 = fVec1[((IOTA - 53) & 127)]; double fTemp853 = fVec1[((IOTA - 37) & 127)]; double fTemp854 = fVec1[((IOTA - 52) & 127)]; double fTemp855 = fVec2[((IOTA - 17) & 127)]; double fTemp856 = fVec2[((IOTA - 16) & 127)]; double fTemp857 = fVec2[((IOTA - 15) & 127)]; double fTemp858 = fVec2[((IOTA - 14) & 127)]; double fTemp859 = fVec2[((IOTA - 13) & 127)]; double fTemp860 = fVec2[((IOTA - 12) & 127)]; double fTemp861 = fVec2[((IOTA - 11) & 127)]; double fTemp862 = fVec2[((IOTA - 9) & 127)]; double fTemp863 = fVec2[((IOTA - 7) & 127)]; double fTemp864 = fVec2[((IOTA - 5) & 127)]; double fTemp865 = fVec2[((IOTA - 4) & 127)]; double fTemp866 = fVec2[((IOTA - 3) & 127)]; double fTemp867 = fVec2[((IOTA - 1) & 127)]; double fTemp868 = fVec4[((IOTA - 122) & 127)]; double fTemp869 = fVec4[((IOTA - 91) & 127)]; double fTemp870 = fVec4[((IOTA - 81) & 127)]; double fTemp871 = fVec4[((IOTA - 80) & 127)]; double fTemp872 = fVec4[((IOTA - 77) & 127)]; double fTemp873 = fVec4[((IOTA - 79) & 127)]; double fTemp874 = fVec4[((IOTA - 54) & 127)]; double fTemp875 = fVec4[((IOTA - 51) & 127)]; double fTemp876 = fVec4[((IOTA - 55) & 127)]; double fTemp877 = fVec0[((IOTA - 118) & 127)]; double fTemp878 = fVec0[((IOTA - 113) & 127)]; double fTemp879 = fVec0[((IOTA - 109) & 127)]; double fTemp880 = fVec0[((IOTA - 106) & 127)]; double fTemp881 = fVec0[((IOTA - 84) & 127)]; double fTemp882 = fVec0[((IOTA - 81) & 127)]; double fTemp883 = fVec0[((IOTA - 25) & 127)]; double fTemp884 = fVec1[((IOTA - 124) & 127)]; double fTemp885 = fVec1[((IOTA - 120) & 127)]; double fTemp886 = fVec1[((IOTA - 92) & 127)]; double fTemp887 = fVec1[((IOTA - 91) & 127)]; double fTemp888 = fVec2[((IOTA - 125) & 127)]; double fTemp889 = fVec2[((IOTA - 115) & 127)]; double fTemp890 = fVec1[((IOTA - 119) & 127)]; double fTemp891 = fVec2[((IOTA - 96) & 127)]; double fTemp892 = fVec6[((IOTA - 48) & 127)]; double fTemp893 = fVec6[((IOTA - 47) & 127)]; double fTemp894 = fVec6[((IOTA - 46) & 127)]; double fTemp895 = fVec6[((IOTA - 45) & 127)]; double fTemp896 = fVec6[((IOTA - 42) & 127)]; double fTemp897 = fVec4[((IOTA - 5) & 127)]; double fTemp898 = fVec4[((IOTA - 3) & 127)]; double fTemp899 = fVec4[((IOTA - 23) & 127)]; double fTemp900 = fVec4[((IOTA - 24) & 127)]; double fTemp901 = fVec4[((IOTA - 22) & 127)]; double fTemp902 = fVec4[((IOTA - 21) & 127)]; double fTemp903 = fVec4[((IOTA - 20) & 127)]; double fTemp904 = fVec4[((IOTA - 19) & 127)]; double fTemp905 = fVec4[((IOTA - 14) & 127)]; double fTemp906 = fVec4[((IOTA - 12) & 127)]; double fTemp907 = fVec4[((IOTA - 11) & 127)]; double fTemp908 = fVec4[((IOTA - 9) & 127)]; double fTemp909 = fVec4[((IOTA - 7) & 127)]; double fTemp910 = fVec5[((IOTA - 124) & 127)]; double fTemp911 = fVec4[((IOTA - 28) & 127)]; double fTemp912 = fVec5[((IOTA - 118) & 127)]; double fTemp913 = fVec5[((IOTA - 114) & 127)]; double fTemp914 = fVec5[((IOTA - 113) & 127)]; double fTemp915 = fVec5[((IOTA - 111) & 127)]; double fTemp916 = fVec5[((IOTA - 107) & 127)]; double fTemp917 = fVec5[((IOTA - 106) & 127)]; double fTemp918 = fVec5[((IOTA - 104) & 127)]; double fTemp919 = fVec5[((IOTA - 103) & 127)]; double fTemp920 = fVec5[((IOTA - 102) & 127)]; double fTemp921 = fVec5[((IOTA - 100) & 127)]; double fTemp922 = fVec5[((IOTA - 101) & 127)]; double fTemp923 = fVec5[((IOTA - 98) & 127)]; double fTemp924 = fVec5[((IOTA - 92) & 127)]; double fTemp925 = fVec5[((IOTA - 93) & 127)]; double fTemp926 = fVec5[((IOTA - 99) & 127)]; double fTemp927 = fVec5[((IOTA - 97) & 127)]; double fTemp928 = fVec5[((IOTA - 105) & 127)]; double fTemp929 = fVec5[((IOTA - 109) & 127)]; double fTemp930 = fVec5[((IOTA - 108) & 127)]; double fTemp931 = fVec5[((IOTA - 88) & 127)]; double fTemp932 = fVec5[((IOTA - 81) & 127)]; double fTemp933 = fVec5[((IOTA - 80) & 127)]; double fTemp934 = fVec5[((IOTA - 82) & 127)]; double fTemp935 = fVec5[((IOTA - 76) & 127)]; double fTemp936 = fVec5[((IOTA - 75) & 127)]; double fTemp937 = fVec5[((IOTA - 79) & 127)]; double fTemp938 = fVec5[((IOTA - 78) & 127)]; double fTemp939 = fVec5[((IOTA - 77) & 127)]; double fTemp940 = fVec5[((IOTA - 68) & 127)]; double fTemp941 = fVec5[((IOTA - 74) & 127)]; double fTemp942 = fVec5[((IOTA - 66) & 127)]; double fTemp943 = fVec5[((IOTA - 61) & 127)]; double fTemp944 = fVec5[((IOTA - 67) & 127)]; double fTemp945 = fVec5[((IOTA - 73) & 127)]; double fTemp946 = fVec5[((IOTA - 59) & 127)]; double fTemp947 = fVec5[((IOTA - 58) & 127)]; double fTemp948 = fVec5[((IOTA - 60) & 127)]; double fTemp949 = fVec5[((IOTA - 41) & 127)]; double fTemp950 = fVec5[((IOTA - 40) & 127)]; double fTemp951 = fVec5[((IOTA - 47) & 127)]; double fTemp952 = fVec5[((IOTA - 35) & 127)]; double fTemp953 = fVec5[((IOTA - 32) & 127)]; double fTemp954 = fVec5[((IOTA - 28) & 127)]; double fTemp955 = fVec5[((IOTA - 27) & 127)]; double fTemp956 = fVec5[((IOTA - 25) & 127)]; double fTemp957 = fVec5[((IOTA - 24) & 127)]; double fTemp958 = fVec5[((IOTA - 50) & 127)]; double fTemp959 = fVec5[((IOTA - 46) & 127)]; double fTemp960 = fVec7[((IOTA - 115) & 127)]; double fTemp961 = fVec7[((IOTA - 114) & 127)]; double fTemp962 = fVec7[((IOTA - 113) & 127)]; double fTemp963 = fVec7[((IOTA - 110) & 127)]; double fTemp964 = fVec7[((IOTA - 106) & 127)]; double fTemp965 = fVec7[((IOTA - 103) & 127)]; double fTemp966 = fVec7[((IOTA - 105) & 127)]; double fTemp967 = fVec7[((IOTA - 104) & 127)]; double fTemp968 = fVec7[((IOTA - 101) & 127)]; double fTemp969 = fVec7[((IOTA - 99) & 127)]; double fTemp970 = fVec7[((IOTA - 96) & 127)]; double fTemp971 = fVec7[((IOTA - 95) & 127)]; double fTemp972 = fVec7[((IOTA - 91) & 127)]; double fTemp973 = fVec7[((IOTA - 102) & 127)]; double fTemp974 = fVec7[((IOTA - 107) & 127)]; double fTemp975 = fVec7[((IOTA - 111) & 127)]; double fTemp976 = fVec7[((IOTA - 100) & 127)]; double fTemp977 = fVec7[((IOTA - 74) & 127)]; double fTemp978 = fVec7[((IOTA - 73) & 127)]; double fTemp979 = fVec7[((IOTA - 76) & 127)]; double fTemp980 = fVec7[((IOTA - 71) & 127)]; double fTemp981 = fVec7[((IOTA - 70) & 127)]; double fTemp982 = fVec7[((IOTA - 69) & 127)]; double fTemp983 = fVec7[((IOTA - 72) & 127)]; double fTemp984 = fVec7[((IOTA - 65) & 127)]; double fTemp985 = fVec7[((IOTA - 66) & 127)]; double fTemp986 = fVec7[((IOTA - 64) & 127)]; double fTemp987 = fVec7[((IOTA - 61) & 127)]; double fTemp988 = fVec7[((IOTA - 68) & 127)]; double fTemp989 = fVec7[((IOTA - 67) & 127)]; double fTemp990 = fVec7[((IOTA - 57) & 127)]; double fTemp991 = fVec7[((IOTA - 55) & 127)]; double fTemp992 = fVec7[((IOTA - 56) & 127)]; double fTemp993 = fVec7[((IOTA - 49) & 127)]; double fTemp994 = fVec7[((IOTA - 43) & 127)]; double fTemp995 = fVec7[((IOTA - 38) & 127)]; double fTemp996 = fVec7[((IOTA - 37) & 127)]; double fTemp997 = fVec7[((IOTA - 34) & 127)]; double fTemp998 = fVec7[((IOTA - 31) & 127)]; double fTemp999 = fVec7[((IOTA - 30) & 127)]; double fTemp1000 = fVec7[((IOTA - 27) & 127)]; double fTemp1001 = fVec7[((IOTA - 25) & 127)]; double fTemp1002 = fVec7[((IOTA - 23) & 127)]; double fTemp1003 = fVec7[((IOTA - 22) & 127)]; double fTemp1004 = fVec7[((IOTA - 19) & 127)]; double fTemp1005 = fVec7[((IOTA - 18) & 127)]; double fTemp1006 = fVec7[((IOTA - 16) & 127)]; double fTemp1007 = fVec7[((IOTA - 15) & 127)]; double fTemp1008 = fVec7[((IOTA - 12) & 127)]; double fTemp1009 = fVec7[((IOTA - 11) & 127)]; double fTemp1010 = fVec7[((IOTA - 10) & 127)]; double fTemp1011 = fVec7[((IOTA - 9) & 127)]; double fTemp1012 = fVec7[((IOTA - 7) & 127)]; double fTemp1013 = fVec7[((IOTA - 6) & 127)]; double fTemp1014 = fVec7[((IOTA - 3) & 127)]; double fTemp1015 = fVec6[((IOTA - 123) & 127)]; double fTemp1016 = fVec6[((IOTA - 122) & 127)]; double fTemp1017 = fVec6[((IOTA - 121) & 127)]; double fTemp1018 = fVec6[((IOTA - 120) & 127)]; double fTemp1019 = fVec6[((IOTA - 116) & 127)]; double fTemp1020 = fVec6[((IOTA - 117) & 127)]; double fTemp1021 = fVec6[((IOTA - 112) & 127)]; double fTemp1022 = fVec6[((IOTA - 113) & 127)]; double fTemp1023 = fVec6[((IOTA - 111) & 127)]; double fTemp1024 = fVec6[((IOTA - 124) & 127)]; double fTemp1025 = fVec6[((IOTA - 119) & 127)]; double fTemp1026 = fVec6[((IOTA - 115) & 127)]; double fTemp1027 = fVec6[((IOTA - 109) & 127)]; double fTemp1028 = fVec6[((IOTA - 108) & 127)]; double fTemp1029 = fVec6[((IOTA - 118) & 127)]; double fTemp1030 = fVec6[((IOTA - 110) & 127)]; double fTemp1031 = fVec6[((IOTA - 106) & 127)]; double fTemp1032 = fVec6[((IOTA - 125) & 127)]; double fTemp1033 = fVec6[((IOTA - 81) & 127)]; double fTemp1034 = fVec6[((IOTA - 91) & 127)]; double fTemp1035 = fVec6[((IOTA - 76) & 127)]; double fTemp1036 = fVec6[((IOTA - 75) & 127)]; double fTemp1037 = fVec6[((IOTA - 67) & 127)]; double fTemp1038 = fVec6[((IOTA - 64) & 127)]; double fTemp1039 = fVec6[((IOTA - 63) & 127)]; double fTemp1040 = fVec6[((IOTA - 61) & 127)]; double fTemp1041 = fVec6[((IOTA - 56) & 127)]; double fTemp1042 = fVec6[((IOTA - 62) & 127)]; double fTemp1043 = fVec6[((IOTA - 55) & 127)]; double fTemp1044 = fVec6[((IOTA - 49) & 127)]; double fTemp1045 = fVec6[((IOTA - 50) & 127)]; double fTemp1046 = fVec6[((IOTA - 44) & 127)]; double fTemp1047 = fVec6[((IOTA - 51) & 127)]; double fTemp1048 = fVec6[((IOTA - 54) & 127)]; double fTemp1049 = fVec6[((IOTA - 53) & 127)]; double fTemp1050 = fVec6[((IOTA - 52) & 127)]; double fTemp1051 = fVec8[((IOTA - 92) & 127)]; double fTemp1052 = fVec8[((IOTA - 91) & 127)]; double fTemp1053 = fVec8[((IOTA - 84) & 127)]; double fTemp1054 = fVec8[((IOTA - 97) & 127)]; double fTemp1055 = fVec8[((IOTA - 28) & 127)]; double fTemp1056 = fVec8[((IOTA - 24) & 127)]; double fTemp1057 = fVec3[((IOTA - 57) & 127)]; double fTemp1058 = fVec3[((IOTA - 58) & 127)]; double fTemp1059 = fVec3[((IOTA - 56) & 127)]; double fTemp1060 = fVec3[((IOTA - 50) & 127)]; double fTemp1061 = fVec3[((IOTA - 53) & 127)]; double fTemp1062 = fVec3[((IOTA - 55) & 127)]; double fTemp1063 = fVec3[((IOTA - 46) & 127)]; double fTemp1064 = fVec3[((IOTA - 44) & 127)]; double fTemp1065 = fVec3[((IOTA - 43) & 127)]; double fTemp1066 = fVec3[((IOTA - 41) & 127)]; double fTemp1067 = fVec4[((IOTA - 72) & 127)]; double fTemp1068 = fVec4[((IOTA - 71) & 127)]; double fTemp1069 = fVec4[((IOTA - 70) & 127)]; double fTemp1070 = fVec4[((IOTA - 65) & 127)]; double fTemp1071 = fVec4[((IOTA - 69) & 127)]; double fTemp1072 = fVec5[((IOTA - 72) & 127)]; double fTemp1073 = fVec5[((IOTA - 71) & 127)]; double fTemp1074 = fVec5[((IOTA - 70) & 127)]; double fTemp1075 = fVec5[((IOTA - 69) & 127)]; double fTemp1076 = fVec5[((IOTA - 21) & 127)]; double fTemp1077 = fVec5[((IOTA - 19) & 127)]; double fTemp1078 = fVec5[((IOTA - 14) & 127)]; double fTemp1079 = fVec5[((IOTA - 12) & 127)]; double fTemp1080 = fVec5[((IOTA - 11) & 127)]; double fTemp1081 = fVec5[((IOTA - 9) & 127)]; double fTemp1082 = fVec5[((IOTA - 7) & 127)]; double fTemp1083 = fVec5[((IOTA - 5) & 127)]; double fTemp1084 = fVec5[((IOTA - 3) & 127)]; double fTemp1085 = fVec7[((IOTA - 81) & 127)]; double fTemp1086 = fVec7[((IOTA - 82) & 127)]; double fTemp1087 = fVec6[((IOTA - 70) & 127)]; double fTemp1088 = fVec6[((IOTA - 68) & 127)]; double fTemp1089 = fVec8[((IOTA - 81) & 127)]; double fTemp1090 = fVec8[((IOTA - 47) & 127)]; double fTemp1091 = fVec6[((IOTA - 69) & 127)]; double fTemp1092 = fVec8[((IOTA - 2) & 127)]; double fTemp1093 = fVec5[((IOTA - 110) & 127)]; double fTemp1094 = fVec5[((IOTA - 112) & 127)]; double fTemp1095 = fVec5[((IOTA - 89) & 127)]; double fTemp1096 = fVec5[((IOTA - 31) & 127)]; double fTemp1097 = fVec4[((IOTA - 53) & 127)]; double fTemp1098 = fVec7[((IOTA - 112) & 127)]; double fTemp1099 = fVec7[((IOTA - 109) & 127)]; double fTemp1100 = fVec7[((IOTA - 108) & 127)]; double fTemp1101 = fVec6[((IOTA - 126) & 127)]; double fTemp1102 = fVec6[((IOTA - 43) & 127)]; double fTemp1103 = fVec6[((IOTA - 60) & 127)]; double fTemp1104 = fVec6[((IOTA - 59) & 127)]; double fTemp1105 = fVec6[((IOTA - 58) & 127)]; double fTemp1106 = fVec6[((IOTA - 57) & 127)]; double fTemp1107 = fVec8[((IOTA - 88) & 127)]; double fTemp1108 = fVec8[((IOTA - 89) & 127)]; double fTemp1109 = fVec6[((IOTA - 41) & 127)]; double fTemp1110 = fVec6[((IOTA - 40) & 127)]; double fTemp1111 = fVec6[((IOTA - 39) & 127)]; double fTemp1112 = fVec6[((IOTA - 37) & 127)]; double fTemp1113 = fVec6[((IOTA - 36) & 127)]; double fTemp1114 = fVec6[((IOTA - 38) & 127)]; double fTemp1115 = fVec6[((IOTA - 32) & 127)]; double fTemp1116 = fVec6[((IOTA - 31) & 127)]; double fTemp1117 = fVec6[((IOTA - 30) & 127)]; double fTemp1118 = fVec6[((IOTA - 29) & 127)]; double fTemp1119 = fVec6[((IOTA - 28) & 127)]; double fTemp1120 = fVec6[((IOTA - 27) & 127)]; double fTemp1121 = fVec6[((IOTA - 33) & 127)]; double fTemp1122 = fVec6[((IOTA - 34) & 127)]; double fTemp1123 = fVec6[((IOTA - 35) & 127)]; double fTemp1124 = fVec6[((IOTA - 25) & 127)]; double fTemp1125 = fVec6[((IOTA - 24) & 127)]; double fTemp1126 = fVec6[((IOTA - 23) & 127)]; double fTemp1127 = fVec6[((IOTA - 26) & 127)]; double fTemp1128 = fVec6[((IOTA - 10) & 127)]; double fTemp1129 = fVec6[((IOTA - 8) & 127)]; double fTemp1130 = fVec6[((IOTA - 6) & 127)]; double fTemp1131 = fVec6[((IOTA - 2) & 127)]; double fTemp1132 = fVec6[((IOTA - 66) & 127)]; double fTemp1133 = fVec6[((IOTA - 65) & 127)]; double fTemp1134 = fVec6[((IOTA - 74) & 127)]; double fTemp1135 = fVec2[((IOTA - 41) & 127)]; double fTemp1136 = fVec2[((IOTA - 40) & 127)]; double fTemp1137 = fVec2[((IOTA - 34) & 127)]; double fTemp1138 = fVec2[((IOTA - 38) & 127)]; double fTemp1139 = fVec2[((IOTA - 35) & 127)]; double fTemp1140 = fVec2[((IOTA - 31) & 127)]; double fTemp1141 = fVec3[((IOTA - 66) & 127)]; double fTemp1142 = fVec0[((IOTA - 49) & 127)]; double fTemp1143 = (fRec1[0] * (((5.611290000000001e-05 * fTemp1) + ((0.000144938 * fTemp2) + ((0.00098582100000000001 * fTemp3) + ((0.0010638000000000002 * fTemp4) + ((0.0018535400000000001 * fTemp5) + ((0.0020713300000000001 * fTemp6) + ((0.00287405 * fTemp7) + ((0.00066612700000000008 * fTemp8) + ((0.00021471700000000001 * fTemp9) + ((0.0083305600000000007 * fTemp10) + ((2.773e-06 * fTemp12) + ((2.8457499999999998e-06 * fTemp13) + ((2.4558300000000005e-05 * fTemp14) + ((5.3135e-06 * fTemp15) + ((0.00024796200000000001 * fTemp16) + ((0.00014221200000000001 * fTemp17) + ((0.00028535700000000003 * fTemp18) + ((0.00070562000000000001 * fTemp19) + ((0.0005151 * fTemp20) + ((0.00124614 * fTemp21) + ((0.00032077100000000002 * fTemp22) + ((9.0654800000000018e-05 * fTemp23) + ((0.0022713 * fTemp24) + ((6.2936500000000003e-05 * fTemp25) + ((2.0687900000000002e-05 * fTemp26) + ((0.00221192 * fTemp27) + ((0.00074920100000000001 * fTemp28) + ((0.00066226100000000003 * fTemp29) + ((0.0036181899999999999 * fTemp30) + ((3.8066800000000006e-05 * fTemp31) + ((0.0022166500000000001 * fTemp32) + ((0.0021549399999999997 * fTemp33) + ((0.0013761300000000001 * fTemp34) + ((0.023527200000000002 * fTemp35) + ((0.0021948500000000004 * fTemp36) + ((0.00051807200000000006 * fTemp37) + ((0.024944000000000001 * fTemp38) + ((0.0035849099999999997 * fTemp39) + ((1.06705e-06 * fTemp40) + ((3.8319600000000005e-05 * fTemp41) + ((0.0031629900000000001 * fTemp42) + ((0.0011606799999999999 * fTemp43) + ((0.00078389600000000007 * fTemp44) + ((3.61728e-05 * fTemp45) + ((7.2644700000000013e-05 * fTemp46) + ((1.0278999999999999e-06 * fTemp47) + ((0.00053547700000000002 * fTemp48) + ((0.00078204200000000005 * fTemp49) + ((0.00089492 * fTemp50) + ((0.0054627 * fTemp51) + ((0.0053478500000000003 * fTemp52) + ((0.0036506200000000003 * fTemp53) + ((0.0039108500000000004 * fTemp54) + ((0.00124406 * fTemp55) + ((0.041771900000000008 * fTemp56) + ((0.055177400000000001 * fTemp57) + ((0.0108086 * fTemp58) + ((0.0026607500000000004 * fTemp59) + ((0.00066903899999999996 * fTemp60) + ((0.0013556799999999999 * fTemp61) + ((0.00012807300000000001 * fTemp62) + ((0.000378556 * fTemp63) + ((4.9495899999999995e-07 * fTemp64) + ((0.00025383300000000002 * fTemp65) + ((0.00035608600000000003 * fTemp66) + ((0.00034403800000000002 * fTemp67) + ((0.00071143700000000009 * fTemp68) + ((0.0014366699999999999 * fTemp69) + ((0.0045955500000000003 * fTemp70) + ((0.00058266999999999998 * fTemp72) + ((0.00082486899999999999 * fTemp73) + ((0.0011506799999999998 * fTemp74) + ((0.00010084700000000001 * fTemp75) + ((3.5632800000000002e-05 * fTemp76) + ((0.00034166200000000001 * fTemp77) + ((3.64663e-05 * fTemp78) + ((0.035996800000000002 * fTemp79) + ((2.0105900000000003e-05 * fTemp81) + ((0.0124978 * fTemp82) + ((0.00053009599999999997 * fTemp83) + ((0.0011330000000000001 * fTemp84) + ((0.0016271899999999999 * fTemp85) + ((0.00069229100000000004 * fTemp86) + ((0.00050674400000000005 * fTemp87) + ((0.00049718700000000006 * fTemp88) + ((0.023463500000000002 * fTemp89) + ((0.052758300000000001 * fTemp90) + ((0.00038071900000000001 * fTemp91) + ((0.0094331200000000014 * fTemp92) + ((0.011300600000000001 * fTemp93) + ((0.0071840999999999997 * fTemp94) + ((0.00027813700000000002 * fTemp95) + ((0.00027818999999999999 * fTemp96) + ((0.00022609 * fTemp97) + ((0.00033955200000000002 * fTemp98) + ((2.4972599999999999e-05 * fTemp99) + ((5.2352700000000004e-05 * fTemp100) + ((4.2462999999999995e-06 * fTemp11) + ((0.00016021500000000001 * fTemp101) + ((0.000240886 * fTemp102) + ((3.0215200000000005e-05 * fTemp103) + ((0.000204718 * fTemp104) + ((0.00033797299999999998 * fTemp105) + ((0.00013590400000000001 * fTemp106) + ((6.0929900000000008e-05 * fTemp107) + ((0.000208667 * fTemp108) + ((0.00030785900000000001 * fTemp109) + ((0.00026147399999999998 * fTemp110) + ((0.00048677700000000003 * fTemp111) + ((0.0012107800000000001 * fTemp112) + ((0.00045785700000000004 * fTemp113) + ((4.86084e-05 * fTemp114) + ((8.9630500000000016e-08 * fTemp115) + ((0.00056137899999999998 * fTemp116) + ((0.00076490500000000008 * fTemp117) + ((0.00015598000000000001 * fTemp118) + ((0.00076870700000000009 * fTemp119) + ((0.0014322200000000001 * fTemp120) + ((0.00064690400000000001 * fTemp121) + ((0.00046067700000000005 * fTemp122) + ((0.00271718 * fTemp123) + ((6.2586200000000001e-05 * fTemp124) + ((0.00117567 * fTemp125) + ((0.0012521400000000001 * fTemp126) + ((0.00055114699999999999 * fTemp127) + ((0.0016155 * fTemp128) + ((0.0019438999999999999 * fTemp129) + ((0.00122438 * fTemp130) + ((0.0021511500000000001 * fTemp131) + ((0.00110439 * fTemp132) + ((3.43292e-08 * fTemp133) + ((3.3588899999999999e-06 * fTemp134) + ((3.9804799999999997e-06 * fTemp135) + ((5.0789799999999999e-05 * fTemp136) + ((3.2623300000000003e-05 * fTemp137) + ((0.00026027500000000002 * fTemp138) + ((0.00040571999999999998 * fTemp139) + ((0.00020187200000000002 * fTemp140) + ((0.00084254300000000007 * fTemp141) + ((0.00156339 * fTemp142) + ((0.0034697200000000004 * fTemp143) + ((0.0030116200000000004 * fTemp144) + ((0.00075465500000000002 * fTemp145) + ((0.00068181600000000002 * fTemp146) + ((0.00071934100000000008 * fTemp147) + ((0.00040184499999999996 * fTemp148) + ((0.00055143000000000011 * fTemp149) + ((0.0016723300000000001 * fTemp150) + ((0.0017063 * fTemp151) + ((0.00020361699999999999 * fTemp152) + ((0.00030080800000000001 * fTemp153) + ((0.0026214800000000003 * fTemp154) + ((0.0034494400000000002 * fTemp155) + ((0.0014532900000000001 * fTemp156) + ((0.0011545000000000001 * fTemp157) + ((0.00061171300000000006 * fTemp158) + ((0.0013395900000000001 * fTemp159) + ((0.00020694100000000001 * fTemp160) + ((0.00127111 * fTemp161) + ((0.00064708400000000003 * fTemp162) + ((0.0010632999999999999 * fTemp163) + ((0.00058977500000000006 * fTemp164) + ((0.000609699 * fTemp165) + ((0.00150508 * fTemp166) + ((0.0014054500000000001 * fTemp167) + ((0.0060181399999999999 * fTemp168) + ((0.0038672100000000003 * fTemp169) + ((0.0049045500000000006 * fTemp170) + ((0.0091428700000000009 * fTemp171) + ((4.1971900000000004e-05 * fTemp172) + ((0.0099856200000000006 * fTemp173) + ((0.010922899999999999 * fTemp174) + ((0.0016006100000000001 * fTemp175) + ((0.0013328999999999999 * fTemp176) + ((0.013603000000000001 * fTemp177) + ((0.0099153599999999998 * fTemp178) + ((0.016723499999999999 * fTemp179) + ((0.045127499999999994 * fTemp180) + ((0.0027371000000000001 * fTemp181) + ((0.0059659600000000002 * fTemp182) + ((4.6184399999999998e-05 * fTemp183) + ((0.0025209700000000004 * fTemp184) + ((0.00036855699999999999 * fTemp185) + ((0.00070276500000000005 * fTemp186) + ((0.00090358699999999997 * fTemp187) + ((0.000231406 * fTemp188) + ((4.4178200000000003e-05 * fTemp189) + ((1.57811e-05 * fTemp80) + ((0.0047945900000000005 * fTemp190) + ((8.2140799999999984e-06 * fTemp192) + ((0.0029068700000000002 * fTemp193) + ((3.8470500000000004e-05 * fTemp194) + ((9.096330000000001e-05 * fTemp195) + ((0.000227166 * fTemp196) + ((6.1820100000000001e-06 * fTemp197) + ((8.7317000000000004e-05 * fTemp198) + ((8.2866000000000002e-05 * fTemp199) + ((0.00014514899999999999 * fTemp200) + ((8.3273200000000014e-05 * fTemp201) + ((5.2586900000000003e-05 * fTemp202) + ((0.00036701000000000003 * fTemp203) + ((0.00010655300000000001 * fTemp204) + ((0.00050770799999999994 * fTemp205) + ((2.5137800000000002e-07 * fTemp206) + ((3.82797e-06 * fTemp207) + ((0.00025426099999999998 * fTemp208) + ((0.00018379600000000001 * fTemp209) + ((0.00035138200000000002 * fTemp210) + ((0.00063264199999999999 * fTemp211) + ((7.6149300000000013e-05 * fTemp212) + ((0.00086251900000000007 * fTemp213) + ((0.0019024199999999999 * fTemp214) + ((0.0013118799999999999 * fTemp215) + ((0.00129144 * fTemp216) + ((0.0015575400000000001 * fTemp217) + ((0.00020428199999999999 * fTemp218) + ((0.0011614100000000001 * fTemp219) + ((0.0020513699999999998 * fTemp220) + ((0.0016051100000000001 * fTemp221) + ((0.00196889 * fTemp222) + ((0.0079808199999999996 * fTemp223) + ((0.0044432300000000003 * fTemp224) + ((0.0013145500000000001 * fTemp225) + ((0.000208879 * fTemp226) + ((9.226730000000001e-05 * fTemp227) + ((0.0053043999999999999 * fTemp228) + ((0.0053560100000000005 * fTemp229) + ((0.00291413 * fTemp230) + ((0.010230900000000001 * fTemp231) + ((0.0073240200000000005 * fTemp232) + ((0.0073238899999999996 * fTemp233) + ((0.0105234 * fTemp234) + ((4.8748200000000002e-05 * fTemp235) + ((0.018119700000000002 * fTemp236) + ((0.0016041499999999999 * fTemp237) + ((2.7286800000000004e-05 * fTemp238) + ((0.00127749 * fTemp239) + ((0.00070097300000000003 * fTemp240) + ((0.0014662800000000001 * fTemp241) + ((0.0025716599999999999 * fTemp242) + ((0.0027539400000000003 * fTemp243) + ((0.000547636 * fTemp244) + ((0.00020467599999999999 * fTemp245) + ((0.0028814800000000001 * fTemp246) + ((0.0034324300000000002 * fTemp247) + ((0.0030387000000000001 * fTemp248) + ((0.002183 * fTemp249) + ((0.021556799999999997 * fTemp250) + ((0.0018844000000000001 * fTemp251) + ((0.013752100000000001 * fTemp252) + ((0.0448946 * fTemp253) + ((0.00033159299999999998 * fTemp254) + ((0.00255288 * fTemp255) + ((0.00094661300000000001 * fTemp256) + ((0.0010133200000000001 * fTemp257) + ((0.00025746299999999998 * fTemp258) + ((2.1185900000000001e-06 * fTemp259) + ((0.00014839199999999998 * fTemp260) + ((0.00047882000000000003 * fTemp261) + ((0.00147938 * fTemp262) + ((0.00013115699999999999 * fTemp263) + ((0.0011073599999999999 * fTemp264) + ((1.70273e-06 * fTemp266) + ((0.00050519600000000007 * fTemp267) + ((0.0016339300000000002 * fTemp268) + ((8.0341699999999997e-06 * fTemp269) + ((4.3469500000000001e-05 * fTemp270) + ((0.0022532999999999997 * fTemp271) + ((0.0024114399999999999 * fTemp272) + ((0.0048108300000000003 * fTemp273) + ((0.036438700000000004 * fTemp274) + ((0.027385400000000001 * fTemp275) + ((0.040978300000000002 * fTemp276) + ((0.038770699999999998 * fTemp277) + ((0.10758200000000001 * fTemp278) + ((0.049985600000000005 * fTemp279) + (((0.00010309 * fTemp280) + ((0.00018337600000000001 * fTemp281) + ((0.00108661 * fTemp282) + ((0.00040080500000000001 * fTemp283) + ((0.0025276200000000004 * fTemp284) + ((0.0005591420000000001 * fTemp285) + ((0.00045614100000000008 * fTemp287) + ((0.00160801 * fTemp288) + ((0.00084856599999999993 * fTemp289) + ((0.00020222799999999999 * fTemp290) + ((2.0016700000000001e-05 * fTemp291) + ((1.4622100000000002e-05 * fTemp191) + ((0.031673199999999999 * fTemp292) + ((0.0274497 * fTemp293) + ((0.0030908899999999998 * fTemp294) + ((0.0103427 * fTemp295) + ((0.0120915 * fTemp296) + ((0.0038904299999999998 * fTemp297) + ((0.0024724199999999999 * fTemp298) + ((0.0012886100000000001 * fTemp299) + ((0.000101833 * fTemp300) + ((2.4533100000000001e-06 * fTemp301) + ((0.0034125200000000005 * fTemp302) + ((0.0069197900000000003 * fTemp303) + ((0.000105639 * fTemp304) + ((3.9296600000000006e-05 * fTemp305) + ((3.85491e-05 * fTemp306) + ((0.00018456300000000003 * fTemp307) + ((0.0031713800000000001 * fTemp308) + ((0.0019589099999999999 * fTemp309) + ((0.00068253400000000005 * fTemp310) + ((0.00056285600000000003 * fTemp311) + ((0.0014036900000000002 * fTemp312) + ((0.0015441700000000001 * fTemp313) + ((0.00036768800000000002 * fTemp314) + ((0.00337025 * fTemp315) + ((0.00069545300000000007 * fTemp316) + ((0.00113331 * fTemp317) + ((0.00070883900000000006 * fTemp318) + ((0.0020663499999999998 * fTemp319) + ((0.00288332 * fTemp320) + ((0.0014698599999999999 * fTemp321) + ((0.0010311999999999999 * fTemp322) + ((0.0012247 * fTemp323) + ((0.00117636 * fTemp324) + ((0.0016634199999999999 * fTemp325) + ((0.0008817050000000001 * fTemp326) + ((0.0035919900000000002 * fTemp327) + ((0.0033690899999999999 * fTemp328) + ((0.0053477200000000003 * fTemp329) + ((0.00571347 * fTemp330) + ((0.0081425600000000001 * fTemp331) + ((0.0048383499999999999 * fTemp332) + ((0.0011593500000000002 * fTemp333) + ((0.00341282 * fTemp334) + ((0.0060068300000000003 * fTemp335) + ((0.0053672899999999994 * fTemp336) + ((1.73416e-05 * fTemp337) + ((0.0096774400000000007 * fTemp338) + ((0.03066 * fTemp339) + ((0.0019489700000000002 * fTemp340) + ((9.4065400000000002e-05 * fTemp341) + ((0.0068109299999999998 * fTemp342) + ((0.00503769 * fTemp343) + ((2.4375700000000001e-05 * fTemp345) + ((8.0066800000000004e-05 * fTemp346) + ((9.0816700000000014e-05 * fTemp347) + ((9.9426100000000014e-05 * fTemp348) + ((5.80835e-05 * fTemp349) + ((9.5024799999999997e-07 * fTemp350) + ((7.7452699999999998e-05 * fTemp351) + ((8.464169999999999e-06 * fTemp352) + ((5.1149400000000002e-05 * fTemp353) + ((0.00032476299999999999 * fTemp354) + ((0.0012872900000000002 * fTemp355) + ((0.0022912900000000001 * fTemp356) + ((0.0019518999999999999 * fTemp357) + ((0.00119739 * fTemp358) + ((0.0043689900000000005 * fTemp359) + ((0.00375801 * fTemp360) + ((0.0016994499999999999 * fTemp361) + ((0.0032713800000000004 * fTemp362) + ((0.0036832600000000003 * fTemp363) + ((0.00028545500000000005 * fTemp364) + ((0.0020680200000000003 * fTemp365) + ((0.00025900400000000002 * fTemp366) + ((0.00089328000000000009 * fTemp367) + ((0.0016691100000000001 * fTemp368) + ((3.3718100000000005e-05 * fTemp369) + ((0.00099548200000000001 * fTemp370) + ((0.00089519800000000015 * fTemp371) + ((0.00079125400000000002 * fTemp372) + ((0.00072158200000000002 * fTemp373) + ((0.0024358800000000001 * fTemp374) + ((0.0027909200000000001 * fTemp375) + ((0.0042173100000000002 * fTemp376) + ((0.0091871399999999999 * fTemp377) + ((0.0056765999999999995 * fTemp378) + ((0.0016214599999999999 * fTemp379) + ((0.00077908600000000012 * fTemp380) + ((0.0021427500000000001 * fTemp381) + ((0.0028589500000000003 * fTemp382) + ((0.0013077200000000001 * fTemp383) + ((0.0022329500000000005 * fTemp384) + ((0.0053105900000000004 * fTemp385) + ((0.0030150300000000001 * fTemp386) + ((0.0070971000000000003 * fTemp387) + ((0.0037660800000000002 * fTemp388) + ((0.00053429399999999994 * fTemp389) + ((0.0164669 * fTemp390) + ((0.0086483100000000011 * fTemp391) + ((0.021576300000000003 * fTemp392) + ((0.021685099999999999 * fTemp393) + ((0.0057622799999999998 * fTemp394) + ((0.0057969700000000002 * fTemp395) + ((0.0197594 * fTemp396) + ((0.0121098 * fTemp397) + ((0.032535399999999999 * fTemp398) + ((0.00050339700000000005 * fTemp399) + ((0.00086802899999999998 * fTemp400) + ((0.0016583500000000001 * fTemp401) + ((0.00031507000000000003 * fTemp402) + ((0.00049461800000000005 * fTemp403) + ((0.00015840400000000001 * fTemp404) + ((2.8519800000000004e-05 * fTemp405) + ((4.4578800000000004e-06 * fTemp344) + ((1.1796500000000001e-05 * fTemp406) + ((5.3605900000000008e-05 * fTemp407) + ((0.00047704000000000008 * fTemp408) + ((0.00043236800000000009 * fTemp409) + ((0.00046969700000000004 * fTemp410) + ((0.00092227100000000001 * fTemp411) + ((0.0013659500000000001 * fTemp412) + ((0.00108099 * fTemp413) + ((6.7984800000000007e-05 * fTemp414) + ((0.00070973900000000003 * fTemp415) + ((0.000705385 * fTemp416) + ((0.00045975200000000007 * fTemp417) + ((0.0013345100000000001 * fTemp418) + ((0.0013671599999999999 * fTemp419) + ((0.00088433700000000001 * fTemp420) + ((0.00081300600000000002 * fTemp421) + ((0.0010498400000000002 * fTemp422) + ((0.00300031 * fTemp423) + ((0.00214314 * fTemp424) + ((2.3648600000000003e-05 * fTemp425) + ((0.00058793100000000009 * fTemp426) + ((0.0017765299999999999 * fTemp427) + ((0.000264467 * fTemp428) + ((0.000623519 * fTemp429) + ((0.00033132700000000002 * fTemp430) + ((0.0016777999999999999 * fTemp431) + ((5.0813899999999995e-06 * fTemp433) + ((4.2541300000000006e-05 * fTemp434) + ((5.7126099999999992e-06 * fTemp435) + ((0.00016404399999999999 * fTemp436) + ((0.00010654600000000001 * fTemp437) + ((1.8717900000000003e-05 * fTemp438) + ((0.00016872499999999999 * fTemp439) + ((0.00067625599999999997 * fTemp440) + ((0.00053358400000000003 * fTemp441) + ((0.00083451500000000008 * fTemp442) + ((0.00098166300000000002 * fTemp443) + ((0.00050102000000000002 * fTemp444) + ((0.00054736599999999998 * fTemp445) + ((0.0009436510000000001 * fTemp446) + ((0.0014059200000000002 * fTemp447) + ((0.0012065399999999999 * fTemp448) + ((0.00154024 * fTemp449) + ((0.00185348 * fTemp450) + ((0.00058470199999999999 * fTemp451) + ((0.00050683400000000006 * fTemp452) + ((0.00087727600000000008 * fTemp453) + ((0.00054874000000000004 * fTemp454) + ((0.00272945 * fTemp455) + ((2.3955000000000004e-05 * fTemp456) + ((0.0021461499999999999 * fTemp457) + ((0.00061282500000000011 * fTemp458) + ((0.0037083100000000003 * fTemp459) + ((0.0016799500000000001 * fTemp460) + ((0.0051757600000000006 * fTemp461) + ((0.00041329900000000006 * fTemp462) + ((0.0041945800000000007 * fTemp463) + ((0.00056369199999999997 * fTemp464) + ((0.0015701700000000001 * fTemp465) + ((0.0063743100000000002 * fTemp466) + ((0.0052356299999999998 * fTemp467) + ((0.0029129100000000003 * fTemp468) + ((0.0032107500000000001 * fTemp469) + ((0.0030868900000000001 * fTemp470) + ((0.00185049 * fTemp471) + ((0.0014647 * fTemp472) + ((0.0022559300000000002 * fTemp473) + ((0.0034284599999999999 * fTemp474) + ((0.0023089200000000003 * fTemp475) + ((0.0027403499999999999 * fTemp476) + ((0.0042152999999999999 * fTemp477) + ((0.0068040700000000006 * fTemp478) + ((0.0062385100000000001 * fTemp479) + ((0.0035775299999999998 * fTemp480) + ((0.0042250600000000001 * fTemp481) + ((0.0031211899999999998 * fTemp482) + ((0.0012461600000000001 * fTemp483) + ((0.0012118500000000002 * fTemp484) + ((0.00305273 * fTemp485) + ((0.00325793 * fTemp486) + ((0.0028833999999999999 * fTemp487) + ((0.0079248200000000008 * fTemp488) + ((0.015005800000000001 * fTemp489) + ((0.0028857800000000001 * fTemp490) + ((0.0074329900000000004 * fTemp491) + ((0.0056945699999999995 * fTemp492) + ((0.0064973000000000001 * fTemp493) + ((0.011589100000000001 * fTemp494) + ((0.0069301900000000001 * fTemp495) + ((0.0087064099999999995 * fTemp496) + ((0.0266261 * fTemp497) + ((0.031746299999999998 * fTemp498) + ((0.030624600000000002 * fTemp499) + ((0.0528391 * fTemp500) + ((0.021260899999999999 * fTemp501) + ((0.096895100000000012 * fTemp502) + ((0.057809200000000005 * fTemp503) + ((0.06596840000000001 * fTemp504) + ((0.055772500000000003 * fTemp505) + ((0.034514800000000005 * fTemp506) + ((0.059606500000000007 * fTemp507) + ((0.073495100000000008 * fTemp508) + ((0.064749100000000004 * fTemp509) + ((0.0449074 * fTemp510) + ((0.0025590399999999998 * fTemp511) + ((0.00046662400000000006 * fTemp512) + ((0.00069381500000000008 * fTemp513) + ((7.7608600000000008e-05 * fTemp514) + ((0.00215198 * fTemp515) + ((0.000292148 * fTemp516) + ((0.00055458199999999997 * fTemp517) + ((0.00356967 * fTemp518) + ((0.0018462400000000001 * fTemp519) + ((0.0017431900000000001 * fTemp520) + ((0.000219724 * fTemp521) + ((0.0038023500000000003 * fTemp522) + ((3.8722400000000007e-05 * fTemp523) + ((2.7248300000000001e-05 * fTemp524) + ((0.0026238199999999998 * fTemp525) + ((8.7116700000000006e-05 * fTemp526) + ((0.0014712700000000002 * fTemp527) + ((0.000702438 * fTemp528) + ((0.0174746 * fTemp529) + ((0.021190899999999999 * fTemp530) + ((0.0025345699999999999 * fTemp531) + ((0.0025992000000000003 * fTemp532) + ((0.0061892400000000004 * fTemp533) + ((0.0020100199999999999 * fTemp534) + ((0.00148817 * fTemp535) + ((0.00053443399999999997 * fTemp536) + ((0.00069470999999999997 * fTemp537) + ((0.00013874000000000002 * fTemp538) + ((2.49699e-05 * fTemp539) + ((9.9362800000000004e-06 * fTemp265) + ((0.0027816299999999998 * fTemp540) + ((0.00038337700000000001 * fTemp541) + ((0.0016079900000000001 * fTemp542) + ((0.00046795000000000002 * fTemp543) + ((0.0016152100000000002 * fTemp544) + ((0.00010376700000000001 * fTemp545) + ((0.0024365300000000001 * fTemp546) + ((2.0625300000000001e-06 * fTemp547) + ((2.09787e-05 * fTemp548) + ((0.0041905200000000005 * fTemp549) + ((0.0024405 * fTemp550) + ((0.00082847699999999999 * fTemp551) + ((0.00306785 * fTemp552) + ((0.00175234 * fTemp553) + ((0.00250454 * fTemp554) + ((0.049342300000000006 * fTemp555) + ((0.056510400000000002 * fTemp556) + ((0.0036302599999999997 * fTemp557) + ((0.00050879500000000004 * fTemp558) + ((0.0011589199999999999 * fTemp559) + ((0.00024957099999999997 * fTemp560) + ((0.0018634200000000002 * fTemp561) + ((0.00014117900000000001 * fTemp562) + ((0.00076772799999999997 * fTemp563) + ((0.00059949000000000005 * fTemp564) + ((0.00096838400000000008 * fTemp565) + ((0.00012370799999999999 * fTemp566) + ((2.5118200000000003e-05 * fTemp432) + ((3.8827600000000008e-05 * fTemp567) + ((0.036282299999999996 * fTemp568) + ((0.000184012 * fTemp569) + ((0.0052786200000000004 * fTemp570) + ((8.8836499999999992e-06 * fTemp571) + ((8.7967399999999994e-06 * fTemp572) + ((2.4082099999999999e-06 * fTemp573) + ((0.00041981599999999999 * fTemp574) + ((0.00025855300000000002 * fTemp575) + ((0.00034160000000000001 * fTemp576) + ((0.00086377000000000014 * fTemp577) + ((0.0036652500000000001 * fTemp578) + ((0.058508199999999996 * fTemp579) + ((0.0214629 * fTemp580) + ((0.041341200000000002 * fTemp581) + ((0.050635700000000006 * fTemp582) + ((0.088954799999999987 * fTemp583) + ((0.029345699999999999 * fTemp584) + ((0.063658400000000004 * fTemp585) + ((0.078143400000000002 * fTemp586) + ((0.077131900000000003 * fTemp587) + ((0.060886200000000001 * fTemp588) + ((0.0054581200000000003 * fTemp589) + ((0.090551499999999993 * fTemp590) + ((0.0018110400000000001 * fTemp591) + ((0.00194177 * fTemp592) + ((0.00114689 * fTemp593) + ((0.00058690300000000006 * fTemp594) + ((0.0012299100000000001 * fTemp595) + ((0.00015469 * fTemp596) + ((3.3955100000000003e-05 * fTemp286) + ((0.0012923000000000001 * fTemp597) + ((0.00136699 * fTemp598) + ((0.00045382400000000002 * fTemp599) + ((0.0036129299999999999 * fTemp600) + ((0.0050028199999999998 * fTemp601) + ((0.0079812000000000008 * fTemp602) + ((0.0044680700000000002 * fTemp603) + ((0.0141227 * fTemp604) + ((0.020023599999999999 * fTemp605) + ((0.023001999999999998 * fTemp606) + ((0.0057082499999999998 * fTemp607) + ((0.011366300000000001 * fTemp608) + (((0.0070393900000000004 * fTemp609) + ((0.0048936500000000003 * fTemp610) + ((0.0095701499999999995 * fTemp611) + ((0.011886499999999999 * fTemp612) + ((0.015800600000000001 * fTemp613) + ((0.024750999999999999 * fTemp614) + ((0.0058739299999999994 * fTemp615) + ((8.8419900000000004e-05 * fTemp616) + (0.0086730599999999998 * fTemp617))))))))) + (5.2591200000000006e-05 * fTemp618))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) + (0.021392099999999997 * fTemp619)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - ((2.1103299999999999e-06 * fTemp620) + ((1.9649999999999998e-06 * fTemp621) + ((5.5217400000000003e-06 * fTemp622) + ((3.11789e-06 * fTemp623) + ((0.00016924900000000001 * fTemp624) + ((0.00014172800000000001 * (fTemp625 - fTemp626)) + ((0.00016311100000000002 * fTemp627) + ((0.000138245 * fTemp628) + ((0.000478309 * fTemp629) + ((0.00021442500000000002 * fTemp630) + ((0.00030905200000000004 * fTemp631) + ((0.00091847499999999998 * fTemp632) + ((0.0013005599999999999 * fTemp633) + ((0.0010940099999999999 * fTemp634) + ((0.00026133000000000005 * fTemp635) + ((0.0020077300000000001 * fTemp636) + ((0.0032089100000000001 * fTemp637) + ((0.0044288800000000005 * fTemp638) + ((0.0010079800000000001 * fTemp639) + ((0.00761051 * fTemp640) + ((0.0075612199999999996 * fTemp641) + ((0.00277838 * fTemp642) + ((0.0047678900000000003 * fTemp643) + ((0.0024688500000000003 * fTemp644) + ((0.00063087099999999997 * fTemp645) + ((0.0018776900000000002 * fTemp646) + ((0.0082384199999999998 * fTemp647) + ((0.0050166199999999994 * fTemp648) + ((0.0028042699999999998 * fTemp649) + ((0.0249734 * fTemp650) + ((0.0102805 * fTemp651) + ((0.0112762 * fTemp652) + ((0.0070063399999999998 * fTemp653) + ((9.6015999999999997e-06 * fTemp654) + ((0.00016569499999999999 * fTemp655) + ((0.000131304 * fTemp656) + ((7.4421400000000012e-05 * fTemp657) + ((0.0015964400000000002 * fTemp658) + ((9.0750500000000005e-05 * fTemp659) + ((0.0023870700000000003 * fTemp660) + ((0.0018691199999999999 * fTemp661) + ((0.0014690600000000001 * fTemp662) + ((0.00020293100000000003 * fTemp663) + ((0.00042256999999999999 * fTemp664) + ((4.8196899999999999e-05 * fTemp665) + ((0.00081876599999999996 * fTemp666) + ((0.0012919000000000001 * fTemp667) + ((0.00164123 * fTemp668) + ((0.0035543000000000003 * fTemp669) + ((0.0019447000000000002 * fTemp670) + ((0.0045421799999999998 * fTemp671) + ((0.0032057800000000001 * fTemp672) + ((0.0098560599999999998 * fTemp673) + ((0.0039102499999999997 * fTemp674) + ((0.0055212400000000002 * fTemp675) + ((0.0014029000000000001 * fTemp676) + ((0.015326500000000002 * fTemp677) + ((0.0039000900000000002 * fTemp678) + ((0.0107983 * fTemp679) + ((0.0115642 * fTemp680) + ((0.0016720200000000002 * fTemp681) + ((9.0368300000000007e-05 * fTemp682) + ((0.00113754 * fTemp683) + ((0.0026714199999999999 * fTemp684) + ((0.00024966300000000001 * fTemp685) + ((0.0021342599999999998 * fTemp686) + ((0.00060378299999999999 * fTemp687) + ((0.00040582000000000004 * fTemp688) + ((0.00225807 * fTemp689) + ((0.0023507699999999999 * fTemp690) + ((0.0046170200000000003 * fTemp691) + ((0.015667299999999999 * fTemp692) + ((0.0121152 * fTemp693) + ((0.0031788599999999999 * fTemp694) + ((0.014456700000000001 * fTemp695) + ((0.043969699999999994 * fTemp696) + ((0.010103500000000001 * fTemp697) + ((0.026084999999999997 * fTemp698) + ((0.040577500000000002 * fTemp699) + ((0.0703236 * fTemp700) + ((0.086424600000000004 * fTemp701) + ((0.00526349 * fTemp702) + ((0.0021171000000000002 * fTemp703) + ((0.00027211800000000001 * fTemp704) + ((0.00074305500000000006 * fTemp705) + ((0.00070165199999999998 * fTemp706) + ((7.2115300000000004e-05 * fTemp707) + ((1.68655e-05 * fTemp0) + ((9.8288800000000007e-05 * fTemp708) + ((0.00119961 * fTemp709) + ((0.0011488700000000002 * fTemp710) + ((0.0028610799999999998 * fTemp711) + ((0.0011123800000000001 * fTemp712) + ((0.00013187999999999999 * fTemp713) + ((9.0214000000000001e-05 * fTemp714) + ((0.00048376700000000002 * fTemp715) + ((0.0128167 * fTemp716) + ((0.0026388100000000001 * fTemp717) + ((8.3314900000000018e-05 * fTemp718) + ((1.03751e-05 * fTemp719) + ((0.00040982500000000005 * fTemp720) + ((0.0083424600000000012 * fTemp721) + ((0.0016058699999999999 * fTemp722) + ((0.00574575 * fTemp723) + ((0.0048227900000000004 * fTemp724) + ((0.0053663600000000006 * fTemp725) + ((0.0110708 * fTemp726) + ((0.0074311999999999998 * fTemp727) + ((0.00037238400000000002 * fTemp728) + ((0.00252045 * fTemp729) + ((0.00052853700000000004 * fTemp730) + ((2.8269799999999997e-06 * fTemp731) + ((0.00017706000000000002 * fTemp732) + ((0.00017067000000000002 * fTemp733) + ((4.1155299999999994e-06 * fTemp734) + ((2.8368800000000002e-05 * fTemp735) + ((4.5063100000000006e-05 * fTemp736) + ((8.4151000000000001e-06 * fTemp737) + ((0.00012787900000000001 * fTemp738) + ((0.00010922300000000001 * fTemp739) + ((0.00014129499999999999 * fTemp740) + ((8.4602100000000008e-05 * fTemp741) + ((0.00010810400000000001 * fTemp742) + ((6.1171800000000003e-05 * fTemp743) + ((0.00102436 * fTemp744) + ((0.00100778 * fTemp745) + ((0.00108387 * fTemp746) + ((0.00035581800000000004 * fTemp747) + ((0.00192194 * fTemp748) + ((0.00355741 * fTemp749) + ((0.00203951 * fTemp750) + ((0.0044921400000000004 * fTemp751) + ((0.00099792900000000005 * fTemp752) + ((0.0026953699999999999 * fTemp753) + ((0.00069267700000000005 * fTemp754) + ((0.0014122200000000001 * fTemp755) + ((0.00053443700000000002 * fTemp756) + ((0.00059297400000000002 * fTemp757) + ((0.0013940900000000002 * fTemp758) + ((0.00086068200000000009 * fTemp759) + ((0.0012833600000000001 * fTemp760) + ((0.0050443700000000003 * fTemp761) + ((0.0050713199999999998 * fTemp762) + ((0.0031110899999999999 * fTemp763) + ((0.0032877399999999999 * fTemp764) + ((0.00909628 * fTemp765) + ((0.00419002 * fTemp766) + ((0.0073180300000000005 * fTemp767) + ((0.0036924600000000003 * fTemp768) + ((0.0046017100000000002 * fTemp769) + ((0.0070144200000000004 * fTemp770) + ((0.0020962000000000003 * fTemp771) + ((0.0052343400000000005 * fTemp772) + ((0.0071723899999999998 * fTemp773) + ((0.0036162899999999999 * fTemp774) + ((1.70851e-05 * fTemp775) + ((3.0657300000000002e-05 * fTemp776) + ((9.1851000000000012e-05 * fTemp777) + ((2.7205700000000003e-05 * fTemp778) + ((5.3340699999999993e-07 * fTemp779) + ((0.00062551900000000005 * fTemp780) + ((0.0032921200000000004 * fTemp781) + ((0.00152143 * fTemp782) + ((0.00193753 * fTemp783) + ((0.00096127300000000012 * fTemp784) + ((0.0042903999999999998 * fTemp785) + ((0.00047510500000000003 * fTemp786) + ((0.0013881099999999999 * fTemp787) + ((0.0037726500000000002 * fTemp788) + ((0.0017495700000000002 * fTemp789) + ((0.0095376600000000016 * fTemp790) + ((0.0099954400000000013 * fTemp791) + ((0.00354222 * fTemp792) + ((0.00581921 * fTemp793) + ((0.00064315100000000001 * fTemp794) + ((0.016502200000000002 * fTemp795) + ((0.026153100000000002 * fTemp796) + ((0.015518799999999999 * fTemp797) + ((0.011748099999999999 * fTemp798) + ((0.024044800000000002 * fTemp799) + ((0.011073200000000002 * fTemp800) + ((0.00016208700000000002 * fTemp801) + ((0.00023927800000000002 * fTemp802) + ((0.00099840900000000002 * fTemp803) + ((0.00026075800000000004 * fTemp804) + ((0.0017748 * fTemp805) + ((1.9893500000000002e-05 * fTemp806) + ((3.7877500000000005e-05 * fTemp807) + ((0.00031515600000000003 * fTemp808) + ((0.00068420899999999997 * fTemp809) + ((0.00044415800000000005 * fTemp810) + ((0.00142376 * fTemp811) + ((0.00049268100000000002 * fTemp812) + ((0.00166752 * fTemp813) + ((0.00127253 * fTemp814) + ((0.00033490500000000003 * fTemp815) + ((0.0017284399999999999 * fTemp816) + ((0.0014551499999999999 * fTemp817) + ((0.0011273899999999998 * fTemp818) + ((6.2119200000000007e-05 * fTemp819) + ((0.00027007400000000003 * fTemp820) + ((0.0019003900000000001 * fTemp821) + ((0.00078290800000000002 * fTemp822) + ((5.8659000000000002e-05 * fTemp823) + ((0.00034302399999999999 * fTemp824) + ((0.0030454200000000001 * fTemp825) + ((0.0010344 * fTemp826) + ((0.0021753000000000002 * fTemp827) + ((0.00241033 * fTemp828) + ((0.0054447699999999998 * fTemp829) + ((0.00192986 * fTemp830) + ((0.0027451799999999998 * fTemp831) + ((0.0050891900000000004 * fTemp832) + ((0.0039649200000000002 * fTemp833) + ((0.00053920599999999997 * fTemp834) + ((0.00034291200000000001 * fTemp835) + ((0.00023320700000000001 * fTemp836) + ((0.00041387999999999999 * fTemp837) + ((0.0013482500000000001 * fTemp838) + ((0.000120611 * fTemp839) + ((0.0040625900000000005 * fTemp840) + ((0.011856999999999999 * fTemp841) + ((0.0091953899999999995 * fTemp842) + ((0.0037140800000000002 * fTemp843) + ((0.0061361499999999999 * fTemp844) + ((0.0077227400000000005 * fTemp845) + ((2.6161300000000003e-05 * fTemp846) + ((0.00081881900000000014 * fTemp847) + ((0.00050415000000000008 * fTemp848) + ((0.00041316100000000005 * fTemp849) + ((0.00116132 * fTemp850) + ((0.0011271300000000001 * fTemp851) + ((0.0018522 * fTemp852) + ((0.00081971100000000009 * fTemp853) + ((0.0040265300000000004 * fTemp854) + ((0.011590800000000002 * fTemp855) + ((0.0038800599999999998 * fTemp856) + ((0.022263399999999999 * fTemp857) + ((0.020153300000000002 * fTemp858) + ((0.042437800000000005 * fTemp859) + ((0.047133599999999998 * fTemp860) + ((0.00567696 * fTemp861) + ((0.00143681 * fTemp862) + ((0.00086101400000000001 * fTemp863) + ((0.00058492199999999998 * fTemp864) + ((6.7829099999999997e-06 * fTemp865) + ((0.00025529600000000002 * fTemp866) + ((2.9285600000000003e-05 * fTemp867) + ((3.8661599999999993e-06 * fTemp71) + ((9.0296599999999999e-06 * fTemp868) + ((0.0015305800000000001 * fTemp869) + ((0.0017261400000000001 * fTemp870) + ((0.00048162000000000004 * fTemp871) + ((1.14088e-05 * fTemp872) + ((0.00071563500000000006 * fTemp873) + ((0.0038506399999999998 * fTemp874) + ((0.00191281 * fTemp875) + ((0.0015042599999999999 * fTemp876) + ((0.00011532 * fTemp877) + ((4.7581900000000006e-05 * fTemp878) + ((3.0118399999999995e-06 * fTemp879) + ((0.00026214100000000002 * fTemp880) + ((0.0017591500000000001 * fTemp881) + ((0.00237535 * fTemp882) + ((0.0055445599999999996 * fTemp883) + ((6.8184199999999995e-06 * fTemp884) + ((7.66841e-06 * fTemp885) + ((3.5872199999999999e-05 * fTemp886) + ((0.0020068299999999998 * fTemp887) + ((3.5305499999999996e-06 * fTemp888) + ((4.5684500000000006e-05 * fTemp889) + ((9.9956200000000017e-05 * fTemp890) + ((0.0011713800000000001 * fTemp891) + ((0.016606200000000002 * fTemp892) + ((0.016194200000000002 * fTemp893) + ((0.0116756 * fTemp894) + ((0.008875280000000001 * fTemp895) + ((0.022184499999999999 * fTemp896) + ((0.00091979399999999993 * fTemp897) + ((0.00050699800000000004 * fTemp898) + ((0.010792999999999999 * fTemp899) + ((0.014927200000000002 * fTemp900) + ((0.008510160000000001 * fTemp901) + ((0.0223719 * fTemp902) + ((0.0123166 * fTemp903) + ((0.017947399999999999 * fTemp904) + ((0.0073694100000000007 * fTemp905) + ((0.0142655 * fTemp906) + ((0.0067548000000000009 * fTemp907) + ((0.0025108100000000005 * fTemp908) + ((0.00235191 * fTemp909) + ((6.9716599999999994e-06 * fTemp910) + ((0.010143899999999999 * fTemp911) + ((9.8485200000000004e-06 * fTemp912) + ((0.00010357900000000001 * fTemp913) + ((0.00042897299999999997 * fTemp914) + ((9.8297200000000012e-05 * fTemp915) + ((0.00056389100000000007 * fTemp916) + ((0.00051816800000000006 * fTemp917) + ((0.00088825400000000011 * fTemp918) + ((0.000446193 * fTemp919) + ((0.00071199100000000003 * fTemp920) + ((0.0012435300000000001 * fTemp921) + ((0.0012468500000000001 * fTemp922) + ((0.00170268 * fTemp923) + ((0.0020163799999999999 * fTemp924) + ((0.0013548899999999999 * fTemp925) + ((0.0010388900000000002 * fTemp926) + ((0.00126004 * fTemp927) + ((0.00065456900000000003 * fTemp928) + ((0.00054109500000000001 * fTemp929) + ((0.00083962700000000002 * fTemp930) + ((0.00142103 * fTemp931) + ((0.0030592000000000002 * fTemp932) + ((0.00082976100000000015 * fTemp933) + ((0.0020040399999999999 * fTemp934) + ((0.0019008400000000002 * fTemp935) + ((0.00032308700000000001 * fTemp936) + ((0.00083032800000000008 * fTemp937) + ((0.00146794 * fTemp938) + ((0.0029912300000000001 * fTemp939) + ((4.5241600000000004e-05 * fTemp940) + ((0.00121188 * fTemp941) + ((0.00103439 * fTemp942) + ((0.00025587599999999999 * fTemp943) + ((0.00193403 * fTemp944) + ((0.0015286800000000001 * fTemp945) + ((0.000502175 * fTemp946) + ((0.00055048599999999999 * fTemp947) + ((0.0014905299999999999 * fTemp948) + ((0.0030320900000000003 * fTemp949) + ((0.0076587399999999998 * fTemp950) + ((0.0029968600000000001 * fTemp951) + ((0.010064699999999999 * fTemp952) + ((0.030136699999999999 * fTemp953) + ((0.039170099999999999 * fTemp954) + ((0.00031563800000000003 * fTemp955) + ((0.00069887100000000011 * fTemp956) + ((0.025458500000000002 * fTemp957) + ((0.00049892100000000004 * fTemp958) + ((0.0024887899999999998 * fTemp959) + ((6.574880000000001e-05 * fTemp960) + ((7.5893800000000015e-05 * fTemp961) + ((0.00055035400000000008 * fTemp962) + ((0.00038355300000000002 * fTemp963) + ((0.00064190699999999994 * fTemp964) + ((0.00096466700000000011 * fTemp965) + ((0.0012643700000000001 * fTemp966) + ((0.0014951399999999998 * fTemp967) + ((0.0013151 * fTemp968) + ((0.00147963 * fTemp969) + ((0.0012132899999999999 * fTemp970) + ((0.0010497099999999999 * fTemp971) + ((5.4447799999999994e-06 * fTemp972) + ((0.00062200899999999997 * fTemp973) + ((0.00026040700000000004 * fTemp974) + ((0.00038862600000000004 * fTemp975) + ((0.00155276 * fTemp976) + ((0.00031511100000000003 * fTemp977) + ((0.0011385200000000001 * fTemp978) + ((4.1098800000000007e-05 * fTemp979) + ((0.00191902 * fTemp980) + ((0.00073584900000000001 * fTemp981) + ((0.0033698500000000002 * fTemp982) + ((0.0023925600000000002 * fTemp983) + ((0.00177024 * fTemp984) + ((0.0015381499999999998 * fTemp985) + ((0.0027169400000000002 * fTemp986) + ((0.0011334100000000001 * fTemp987) + ((0.0046562499999999998 * fTemp988) + ((0.0026088700000000001 * fTemp989) + ((0.0012374899999999999 * fTemp990) + ((0.00029472900000000003 * fTemp991) + ((0.00350462 * fTemp992) + ((0.00161133 * fTemp993) + ((0.0043256300000000004 * fTemp994) + ((0.0039263700000000002 * fTemp995) + ((0.0193136 * fTemp996) + ((0.0137585 * fTemp997) + ((0.016165499999999999 * fTemp998) + ((0.0200181 * fTemp999) + ((0.00436148 * fTemp1000) + ((0.0115485 * fTemp1001) + ((0.0032127699999999998 * fTemp1002) + ((0.0057804000000000006 * fTemp1003) + ((0.037111700000000004 * fTemp1004) + ((0.014907300000000002 * fTemp1005) + ((0.0092683000000000001 * fTemp1006) + ((0.0158698 * fTemp1007) + ((0.00489909 * fTemp1008) + ((0.00036272099999999999 * fTemp1009) + ((0.00043871700000000003 * fTemp1010) + ((0.00018132700000000001 * fTemp1011) + ((0.00097058900000000011 * fTemp1012) + ((0.00016036100000000001 * fTemp1013) + ((0.00019245000000000002 * fTemp1014) + ((3.8801999999999999e-05 * fTemp1015) + ((6.5230500000000005e-05 * fTemp1016) + ((4.81323e-05 * fTemp1017) + ((3.1175000000000006e-05 * fTemp1018) + ((9.139900000000001e-05 * fTemp1019) + ((0.000137362 * fTemp1020) + ((0.000272806 * fTemp1021) + ((0.00025063300000000005 * fTemp1022) + ((0.000314307 * fTemp1023) + ((8.3185099999999991e-06 * fTemp1024) + ((1.1129000000000001e-05 * fTemp1025) + ((0.00012562199999999998 * fTemp1026) + ((0.00027303400000000002 * fTemp1027) + ((8.74662e-06 * fTemp1028) + ((0.00016385400000000001 * fTemp1029) + ((0.00026935700000000002 * fTemp1030) + ((0.00035653000000000003 * fTemp1031) + ((2.5639300000000001e-06 * fTemp1032) + ((0.0011749499999999999 * fTemp1033) + ((0.000138672 * fTemp1034) + ((0.00092974400000000003 * fTemp1035) + ((0.00189912 * fTemp1036) + ((0.00157916 * fTemp1037) + ((0.0017056100000000002 * fTemp1038) + ((0.00246014 * fTemp1039) + ((0.0047484400000000005 * fTemp1040) + ((0.010441600000000001 * fTemp1041) + ((0.0044470300000000003 * fTemp1042) + ((0.0100582 * fTemp1043) + ((0.0128559 * fTemp1044) + ((0.015119400000000002 * fTemp1045) + ((0.016079200000000002 * fTemp1046) + ((0.015913200000000002 * fTemp1047) + ((0.0076609499999999997 * fTemp1048) + ((0.0068764300000000002 * fTemp1049) + ((0.0095819500000000005 * fTemp1050) + ((0.0024969700000000003 * fTemp1051) + ((0.0014838199999999998 * fTemp1052) + ((0.000311911 * fTemp1053) + ((0.00054486499999999995 * fTemp1054) + ((0.0114164 * fTemp1055) + ((0.015415000000000002 * fTemp1056) + ((0.0023363800000000003 * fTemp1057) + ((0.0013234399999999999 * fTemp1058) + ((0.0047624399999999997 * fTemp1059) + ((0.0035146700000000001 * fTemp1060) + ((0.0014325799999999999 * fTemp1061) + ((0.00035963800000000001 * fTemp1062) + ((0.00013482199999999999 * fTemp1063) + ((0.0031359700000000001 * fTemp1064) + ((0.0033774600000000001 * fTemp1065) + ((0.00043131800000000003 * fTemp1066) + ((0.0013603899999999999 * fTemp1067) + ((0.00076972400000000006 * fTemp1068) + ((0.0011577500000000001 * fTemp1069) + ((0.0011045300000000001 * fTemp1070) + ((0.0027559100000000003 * fTemp1071) + ((0.0016313200000000001 * fTemp1072) + ((0.0019843199999999999 * fTemp1073) + ((0.0031219500000000001 * fTemp1074) + ((0.0017147500000000001 * fTemp1075) + ((0.0120184 * fTemp1076) + ((0.011691100000000001 * fTemp1077) + ((0.0053095800000000004 * fTemp1078) + ((0.0072171800000000001 * fTemp1079) + ((0.0030320200000000003 * fTemp1080) + ((0.00131485 * fTemp1081) + ((0.0011081700000000001 * fTemp1082) + ((0.00036208399999999998 * fTemp1083) + ((0.00017773600000000001 * fTemp1084) + ((0.00073753600000000001 * fTemp1085) + ((0.00060830200000000002 * fTemp1086) + ((0.00102903 * fTemp1087) + ((0.0030104600000000004 * fTemp1088) + ((0.0010694400000000001 * fTemp1089) + ((0.0029673899999999999 * fTemp1090) + ((0.0023879000000000001 * fTemp1091) + ((0.00017378000000000001 * fTemp1092) + ((0.00020804999999999999 * fTemp1093) + ((0.00029024100000000006 * fTemp1094) + ((0.0010302600000000001 * fTemp1095) + ((0.017341200000000001 * fTemp1096) + ((0.00280679 * fTemp1097) + ((0.00054230400000000007 * fTemp1098) + ((0.0010789999999999999 * fTemp1099) + ((0.00127535 * fTemp1100) + ((1.8656099999999998e-06 * fTemp1101) + ((0.0188738 * fTemp1102) + ((0.0027951100000000004 * fTemp1103) + ((0.0047547600000000002 * fTemp1104) + ((0.0037710400000000002 * fTemp1105) + ((0.0045419900000000001 * fTemp1106) + ((0.00141242 * fTemp1107) + ((0.00134669 * fTemp1108) + ((0.020373700000000002 * fTemp1109) + ((0.0086227300000000003 * fTemp1110) + ((0.015368999999999999 * fTemp1111) + ((0.026966700000000003 * fTemp1112) + ((0.023967600000000002 * fTemp1113) + ((0.025263300000000002 * fTemp1114) + ((0.019380700000000001 * fTemp1115) + ((0.0052166499999999998 * fTemp1116) + ((0.012525700000000001 * fTemp1117) + ((0.039007399999999998 * fTemp1118) + ((0.039406500000000004 * fTemp1119) + ((0.0160175 * fTemp1120) + ((0.035762599999999999 * fTemp1121) + ((0.026436999999999999 * fTemp1122) + ((0.0180915 * fTemp1123) + ((0.00060328500000000006 * fTemp1124) + ((0.042794800000000008 * fTemp1125) + ((0.034687500000000003 * fTemp1126) + ((0.0095142000000000004 * fTemp1127) + ((0.0011779100000000001 * fTemp1128) + ((0.000167329 * fTemp1129) + ((0.00041459900000000003 * fTemp1130) + ((0.00031506200000000001 * fTemp1131) + ((0.0021747000000000003 * fTemp1132) + ((0.0024374800000000001 * fTemp1133) + ((0.0018498099999999999 * fTemp1134) + ((0.010498400000000001 * fTemp1135) + ((0.0021260799999999998 * fTemp1136) + ((0.0010427100000000001 * fTemp1137) + ((0.0065524800000000003 * fTemp1138) + ((0.011496599999999999 * fTemp1139) + ((0.0092546800000000012 * fTemp1140) + ((0.00041918000000000001 * fTemp1141) + (0.0032369600000000001 * fTemp1142)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))); fRec0[0] = std::max<double>((fRec0[1] - fConst0), std::min<double>(6.0, (20.0 * std::log10(std::max<double>(0.00031622776601683794, std::fabs(fTemp1143)))))); fHbargraph0 = FAUSTFLOAT(fRec0[0]); output0[i] = FAUSTFLOAT(fTemp1143); double fTemp1144 = (fRec1[0] * (((1.07578e-06 * fTemp622) + ((1.0896600000000002e-05 * fTemp623) + ((5.7825300000000005e-06 * fTemp1) + ((3.3373e-05 * fTemp628) + ((0.0044664700000000002 * fTemp5) + ((0.0013042499999999999 * fTemp6) + ((0.0025056699999999998 * fTemp7) + ((0.0014331000000000001 * fTemp653) + ((3.3066799999999999e-06 * fTemp12) + ((9.6444300000000008e-05 * fTemp17) + ((0.00063805800000000005 * fTemp19) + ((0.0011957500000000002 * fTemp20) + ((0.00034096799999999998 * fTemp659) + ((0.0010047600000000002 * fTemp22) + ((0.00095472699999999994 * fTemp23) + ((0.0011230999999999999 * fTemp24) + ((0.000103257 * fTemp26) + ((0.00171093 * fTemp665) + ((0.0024843999999999999 * fTemp27) + ((0.0013637999999999999 * fTemp666) + ((0.0020383699999999999 * fTemp28) + ((0.00292619 * fTemp667) + ((0.00074355600000000003 * fTemp30) + ((0.0039499399999999999 * fTemp32) + ((0.0064549899999999999 * fTemp672) + ((0.0094244500000000009 * fTemp676) + ((0.019293299999999999 * fTemp35) + ((0.019155500000000002 * fTemp678) + ((0.0068834500000000002 * fTemp37) + ((0.036199000000000002 * fTemp38) + ((1.0336899999999999e-06 * fTemp40) + ((0.0020205099999999997 * fTemp42) + ((0.0022768000000000003 * fTemp43) + ((0.00027500499999999999 * fTemp45) + ((0.00010999399999999999 * fTemp46) + ((1.2511200000000001e-05 * fTemp47) + ((0.0018692700000000001 * fTemp48) + ((0.000129173 * fTemp49) + ((0.0010500000000000002 * fTemp50) + ((0.0037914799999999999 * fTemp51) + ((0.0063763400000000003 * fTemp52) + ((0.0065615300000000003 * fTemp53) + ((0.00222449 * fTemp54) + ((0.049093400000000002 * fTemp56) + ((0.009442299999999999 * fTemp694) + ((0.00046772600000000007 * fTemp695) + ((0.054047100000000001 * fTemp57) + ((0.0108471 * fTemp697) + ((0.0010471900000000001 * fTemp704) + ((0.00047446700000000006 * fTemp61) + ((0.00031437800000000003 * fTemp63) + ((1.5753899999999999e-07 * fTemp64) + ((0.00036215100000000001 * fTemp65) + ((0.00023396100000000001 * fTemp66) + ((0.00052374700000000008 * fTemp67) + ((0.00092775000000000008 * fTemp68) + ((0.00122649 * fTemp69) + ((0.00050830900000000008 * fTemp709) + ((0.00015973800000000001 * fTemp72) + ((0.00065440400000000003 * fTemp73) + ((0.00025875799999999999 * fTemp75) + ((0.00049362799999999997 * fTemp76) + ((0.00016541 * fTemp77) + ((0.0010192300000000001 * fTemp78) + ((0.00032049699999999999 * fTemp716) + ((0.034925999999999999 * fTemp79) + ((3.4760399999999997e-08 * fTemp81) + ((0.020153599999999997 * fTemp82) + ((0.015254500000000001 * fTemp717) + ((4.4900900000000009e-05 * fTemp718) + ((1.2673900000000001e-05 * fTemp719) + ((0.0099207400000000008 * fTemp89) + ((0.041638400000000006 * fTemp90) + ((0.028412400000000001 * fTemp722) + ((0.016930500000000001 * fTemp725) + ((0.0106017 * fTemp93) + ((0.000263627 * fTemp726) + ((0.00025129900000000002 * fTemp94) + ((0.00047378999999999998 * fTemp728) + ((0.000359551 * fTemp96) + ((0.00050858999999999995 * fTemp98) + ((0.00025865000000000003 * fTemp730) + ((5.1984399999999995e-06 * fTemp100) + ((2.0081900000000002e-05 * fTemp731) + ((5.35095e-06 * fTemp11) + ((0.00030013000000000001 * fTemp101) + ((0.00012962100000000001 * fTemp733) + ((0.00012994100000000001 * fTemp104) + ((0.000501459 * fTemp105) + ((0.00041380000000000003 * fTemp106) + ((4.2136500000000006e-05 * fTemp108) + ((1.1025e-06 * fTemp109) + ((0.000102185 * fTemp110) + ((0.0010346200000000002 * fTemp111) + ((0.0015065 * fTemp112) + ((2.1505000000000002e-05 * fTemp741) + ((0.00061807300000000002 * fTemp113) + ((6.5997900000000001e-08 * fTemp115) + ((7.1971000000000006e-05 * fTemp744) + ((0.00051516900000000011 * fTemp119) + ((0.00076406400000000006 * fTemp120) + ((9.4944000000000018e-05 * fTemp745) + ((0.00095418100000000002 * fTemp747) + ((0.00034814200000000002 * fTemp750) + ((8.0286900000000005e-05 * fTemp125) + ((0.00159566 * fTemp126) + ((0.0016114299999999999 * fTemp127) + ((1.1146700000000001e-05 * fTemp754) + ((0.0029336900000000001 * fTemp128) + ((0.0015251900000000001 * fTemp129) + ((0.00063413500000000008 * fTemp756) + ((0.00021672300000000002 * fTemp757) + ((0.0030693399999999998 * fTemp132) + ((7.2115600000000003e-07 * fTemp133) + ((2.0505700000000003e-05 * fTemp775) + ((7.2276399999999995e-06 * fTemp776) + ((4.1691399999999999e-05 * fTemp138) + ((0.00027668200000000005 * fTemp147) + ((1.3220600000000002e-05 * fTemp779) + ((0.0002275 * fTemp780) + ((0.0020786799999999999 * fTemp781) + ((0.00280241 * fTemp782) + ((0.00091981900000000011 * fTemp783) + ((7.5101900000000007e-05 * fTemp158) + ((0.0026788099999999998 * fTemp784) + ((0.0036546199999999999 * fTemp785) + ((0.00063752100000000005 * fTemp164) + ((0.00050336900000000004 * fTemp786) + ((0.0013227800000000002 * fTemp787) + ((7.3547000000000006e-05 * fTemp788) + ((0.00076943900000000002 * fTemp165) + ((0.00033734999999999999 * fTemp166) + ((0.0013802 * fTemp167) + ((0.0050838799999999998 * fTemp168) + ((0.013509400000000001 * fTemp171) + ((0.015784800000000002 * fTemp793) + ((0.00206245 * fTemp175) + ((0.0024348900000000003 * fTemp795) + ((0.0034120499999999998 * fTemp176) + ((0.036800600000000003 * fTemp796) + ((0.016894100000000002 * fTemp798) + ((0.015907999999999999 * fTemp799) + ((0.00139284 * fTemp181) + ((0.0111489 * fTemp800) + ((0.00048254200000000003 * fTemp183) + ((0.00084440200000000006 * fTemp803) + ((0.00014837300000000001 * fTemp804) + ((2.2315100000000003e-05 * fTemp806) + ((4.6366800000000005e-05 * fTemp625) + ((0.00015426800000000002 * fTemp204) + ((2.9996500000000003e-05 * fTemp205) + ((0.00011103000000000001 * fTemp808) + ((0.00013601100000000001 * fTemp208) + ((0.00055044600000000001 * fTemp209) + ((0.00044798200000000004 * fTemp210) + ((0.00057507100000000002 * fTemp811) + ((0.00032662200000000005 * fTemp812) + ((4.4411900000000001e-05 * fTemp814) + ((0.000103707 * fTemp815) + ((0.00100478 * fTemp816) + ((0.00012959000000000001 * fTemp818) + ((0.0012166300000000002 * fTemp819) + ((0.00022863600000000002 * fTemp820) + ((0.00033440100000000001 * fTemp219) + ((0.00098071900000000012 * fTemp821) + ((0.00040021800000000004 * fTemp823) + ((0.0016816299999999999 * fTemp222) + ((0.00099638500000000002 * fTemp825) + ((0.0034718700000000002 * fTemp827) + ((0.0068587300000000004 * fTemp225) + ((0.0058219500000000002 * fTemp829) + ((0.00087088200000000001 * fTemp234) + ((0.017078900000000001 * fTemp831) + ((0.027225600000000003 * fTemp832) + ((9.9177200000000003e-05 * fTemp838) + ((0.0006416280000000001 * fTemp839) + ((0.0071496000000000007 * fTemp236) + ((0.0043624700000000002 * fTemp237) + ((0.00055969600000000004 * fTemp849) + ((0.0028104300000000005 * fTemp238) + ((0.00089791299999999997 * fTemp850) + ((0.0015055300000000001 * fTemp241) + ((0.00129704 * fTemp242) + ((0.00042873700000000005 * fTemp244) + ((0.00077501600000000001 * fTemp247) + ((0.0177702 * fTemp248) + ((0.0011423000000000002 * fTemp249) + ((0.0057435900000000007 * fTemp854) + ((0.0096359600000000007 * fTemp250) + ((0.0037277 * fTemp251) + ((0.0069752599999999996 * fTemp252) + ((0.045202099999999995 * fTemp253) + ((0.00526948 * fTemp856) + ((0.000358363 * fTemp255) + ((0.00023124899999999999 * fTemp863) + ((0.00020135900000000002 * fTemp257) + ((0.00015575000000000002 * fTemp258) + ((6.1446399999999998e-06 * fTemp259) + ((8.1741199999999999e-06 * fTemp868) + ((0.0011816700000000001 * fTemp869) + ((0.00073013500000000003 * fTemp870) + ((0.00065044300000000001 * fTemp260) + ((0.0015448500000000002 * fTemp871) + ((0.00041635900000000004 * fTemp872) + ((0.00109789 * fTemp873) + ((0.0026210900000000004 * fTemp874) + ((0.0018869100000000001 * fTemp875) + ((3.3187600000000001e-06 * fTemp266) + ((0.0024495200000000002 * fTemp268) + ((0.0022621500000000001 * fTemp876) + ((8.7600299999999995e-06 * fTemp269) + ((2.9587800000000002e-05 * fTemp270) + ((0.0047280300000000003 * fTemp272) + ((0.0056186100000000004 * fTemp273) + ((0.041430000000000002 * fTemp274) + ((0.032932100000000006 * fTemp275) + ((0.028794800000000002 * fTemp883) + ((0.024621200000000003 * fTemp276) + ((0.06345640000000001 * fTemp277) + ((0.07541260000000001 * fTemp278) + (((1.0190999999999999e-05 * fTemp280) + ((0.00125953 * fTemp886) + ((0.00019295400000000001 * fTemp887) + (((0.0020002800000000001 * fTemp288) + ((0.0121522 * fTemp892) + ((0.011685700000000002 * fTemp893) + ((0.0122635 * fTemp894) + ((0.017027300000000002 * fTemp895) + ((0.017569399999999999 * fTemp896) + ((0.00062478100000000003 * fTemp897) + ((0.00028939400000000006 * fTemp898) + ((0.0047823300000000004 * fTemp899) + ((0.048044200000000002 * fTemp900) + ((0.031593799999999998 * fTemp902) + ((0.0092093100000000001 * fTemp903) + ((0.0182515 * fTemp904) + ((0.0125871 * fTemp294) + ((0.0010793700000000001 * fTemp905) + ((0.0061485900000000007 * fTemp906) + ((0.00108131 * fTemp907) + ((0.00149292 * fTemp909) + ((5.1482899999999996e-06 * fTemp910) + ((5.530960000000001e-05 * fTemp300) + ((1.4188099999999999e-06 * fTemp301) + ((0.00946403 * fTemp911) + ((0.0038781100000000002 * fTemp303) + ((0.00011918500000000002 * fTemp304) + ((9.8678100000000013e-05 * fTemp305) + ((4.2207000000000004e-05 * fTemp912) + ((3.2490500000000003e-05 * fTemp306) + ((0.00011697900000000002 * fTemp307) + ((0.000115798 * fTemp915) + ((0.0027517499999999999 * fTemp308) + ((0.0037339199999999999 * fTemp309) + ((0.00065997500000000004 * fTemp924) + ((0.0016790700000000002 * fTemp311) + ((0.0019817300000000001 * fTemp931) + ((0.0015044699999999999 * fTemp313) + ((0.0010922900000000001 * fTemp314) + ((0.0040626200000000003 * fTemp315) + ((0.0012104800000000001 * fTemp317) + ((0.00102589 * fTemp318) + ((0.0011136799999999999 * fTemp319) + ((0.0035448200000000002 * fTemp320) + ((0.0039074399999999999 * fTemp321) + ((0.00070128400000000004 * fTemp946) + ((0.00040873600000000004 * fTemp947) + ((0.00017855099999999999 * fTemp323) + ((0.0020778099999999998 * fTemp324) + ((0.0011952499999999999 * fTemp325) + ((0.0022150400000000002 * fTemp326) + ((3.8517100000000004e-05 * fTemp327) + ((0.011077500000000001 * fTemp328) + ((0.0020168600000000001 * fTemp329) + ((0.0022290399999999998 * fTemp331) + ((0.0084232300000000003 * fTemp332) + ((0.0011997199999999998 * fTemp951) + ((0.0125606 * fTemp336) + ((0.00127378 * fTemp337) + ((0.0537481 * fTemp339) + ((0.013059400000000001 * fTemp340) + ((0.021176 * fTemp341) + ((0.0048699899999999994 * fTemp958) + ((0.0061526599999999999 * fTemp959) + ((0.0028706900000000004 * fTemp343) + ((3.4954000000000004e-05 * fTemp345) + ((9.3229500000000019e-05 * fTemp346) + ((9.5701199999999998e-05 * fTemp347) + ((0.00012240800000000001 * fTemp348) + ((5.5900900000000005e-05 * fTemp960) + ((1.0045e-05 * fTemp352) + ((1.9102600000000002e-05 * fTemp961) + ((0.0020406000000000001 * fTemp357) + ((0.000876507 * fTemp972) + ((0.0013280499999999999 * fTemp359) + ((0.0017303100000000001 * fTemp360) + ((0.0029776099999999999 * fTemp361) + ((0.0025195700000000001 * fTemp362) + ((0.00102092 * fTemp977) + ((0.00082739399999999996 * fTemp365) + ((0.00174807 * fTemp366) + ((0.00013990400000000002 * fTemp979) + ((0.0021519 * fTemp368) + ((0.00235812 * fTemp369) + ((7.6654099999999985e-06 * fTemp987) + ((0.0022741699999999998 * fTemp991) + ((0.0011889400000000001 * fTemp373) + ((0.0042530099999999998 * fTemp374) + ((0.0079603199999999999 * fTemp376) + ((0.0030812000000000001 * fTemp377) + ((0.0075640600000000001 * fTemp993) + ((0.0032282000000000001 * fTemp378) + ((0.0041592900000000004 * fTemp379) + ((0.00033097600000000002 * fTemp994) + ((0.0066906600000000002 * fTemp382) + ((0.00018497500000000001 * fTemp383) + ((0.00108066 * fTemp385) + ((0.0081795500000000007 * fTemp387) + ((0.0040393699999999996 * fTemp388) + ((0.0088403900000000001 * fTemp389) + ((0.0054466000000000002 * fTemp390) + ((0.033863999999999998 * fTemp392) + ((0.0092350000000000002 * fTemp393) + ((0.0043864799999999999 * fTemp394) + ((0.00053732699999999999 * fTemp395) + ((0.0027836500000000004 * fTemp1002) + ((0.0092729000000000006 * fTemp1003) + ((0.022299000000000003 * fTemp396) + ((0.0012059800000000002 * fTemp397) + ((0.025815500000000002 * fTemp398) + ((7.0800700000000008e-05 * fTemp1011) + ((0.00076956600000000007 * fTemp401) + ((0.000231146 * fTemp402) + ((0.00014766099999999999 * fTemp403) + ((4.1470500000000002e-05 * fTemp1015) + ((7.1901800000000003e-05 * fTemp1016) + ((3.71676e-05 * fTemp1017) + ((0.00011888700000000002 * fTemp1019) + ((0.00015893600000000001 * fTemp1020) + ((1.5261800000000004e-05 * fTemp406) + ((0.00036830800000000003 * fTemp1021) + ((0.00030627700000000004 * fTemp1022) + ((0.000251322 * fTemp1023) + ((8.5058500000000009e-06 * fTemp1024) + ((3.3982700000000002e-05 * fTemp1025) + ((2.6751600000000003e-05 * fTemp1026) + ((0.000239084 * fTemp1027) + ((9.1238799999999995e-06 * fTemp1028) + ((0.00016550199999999999 * fTemp1029) + ((0.00022708 * fTemp1030) + ((3.6973199999999999e-06 * fTemp1032) + ((0.00015429699999999999 * fTemp414) + ((0.00065994200000000006 * fTemp427) + ((0.00021972700000000002 * fTemp428) + ((0.0011643300000000001 * fTemp430) + ((0.0017905 * fTemp1035) + ((0.00164631 * fTemp1037) + ((0.00227327 * fTemp1038) + ((0.0030369999999999998 * fTemp1039) + ((0.0020450900000000003 * fTemp1040) + ((0.010980500000000001 * fTemp1041) + ((0.0023284899999999999 * fTemp1042) + ((0.0074067100000000004 * fTemp1043) + ((0.016699200000000001 * fTemp1044) + ((0.018899099999999999 * fTemp1045) + ((0.019806900000000002 * fTemp1046) + ((7.1374800000000001e-06 * fTemp433) + ((5.5996800000000006e-05 * fTemp434) + ((1.69708e-05 * fTemp435) + ((0.000195057 * fTemp436) + ((0.000117308 * fTemp437) + ((0.0143637 * fTemp1047) + ((0.0058000299999999994 * fTemp1048) + ((0.0046881500000000003 * fTemp1049) + ((0.0079024400000000002 * fTemp1050) + ((0.00020216400000000001 * fTemp439) + ((0.0010336799999999999 * fTemp440) + ((0.00042659700000000002 * fTemp441) + ((0.000779071 * fTemp442) + ((0.00070924500000000006 * fTemp443) + ((0.00050421999999999999 * fTemp444) + ((0.00050803600000000001 * fTemp445) + ((0.00095978899999999995 * fTemp446) + ((0.00100501 * fTemp447) + ((0.0012236 * fTemp448) + ((0.00147426 * fTemp449) + ((0.0018419899999999999 * fTemp450) + ((0.00094503799999999993 * fTemp452) + ((0.0013272 * fTemp453) + ((0.0025739000000000001 * fTemp454) + ((0.0033512100000000003 * fTemp455) + ((0.00059498000000000005 * fTemp458) + ((0.00365475 * fTemp459) + ((0.0017505699999999999 * fTemp460) + ((0.0026745600000000003 * fTemp461) + ((0.0010550900000000001 * fTemp1053) + ((0.0046326400000000004 * fTemp463) + ((2.5156400000000002e-05 * fTemp465) + ((0.0053821700000000004 * fTemp466) + ((0.0039087499999999999 * fTemp467) + ((0.0036032700000000004 * fTemp468) + ((0.0019828699999999999 * fTemp469) + ((0.0053022700000000004 * fTemp470) + ((0.00072404000000000001 * fTemp471) + ((0.0033726400000000001 * fTemp473) + ((0.0028127900000000003 * fTemp474) + ((0.0016933400000000002 * fTemp475) + ((0.0029381799999999999 * fTemp476) + ((0.0038801100000000004 * fTemp477) + ((0.0064815100000000002 * fTemp478) + ((0.0067297599999999996 * fTemp479) + ((0.00338193 * fTemp480) + ((0.0026122100000000002 * fTemp481) + ((0.0038020800000000002 * fTemp482) + ((0.0039973999999999999 * fTemp483) + ((4.49754e-06 * fTemp484) + ((0.0042595000000000003 * fTemp485) + ((0.0029229899999999999 * fTemp486) + ((0.00139635 * fTemp487) + ((0.00431154 * fTemp489) + ((0.0105579 * fTemp490) + ((0.014038399999999999 * fTemp491) + ((0.0049862900000000009 * fTemp492) + ((0.0014525200000000001 * fTemp493) + ((0.0072938400000000002 * fTemp494) + ((0.0060665699999999994 * fTemp495) + ((0.0216826 * fTemp496) + ((0.017730600000000003 * fTemp497) + ((0.0123141 * fTemp1055) + ((0.036801199999999999 * fTemp498) + ((0.0075229400000000005 * fTemp499) + ((0.042423700000000002 * fTemp500) + ((0.054464300000000007 * fTemp501) + ((0.111697 * fTemp502) + ((0.050380599999999998 * fTemp503) + ((0.069732299999999997 * fTemp504) + ((0.041405900000000002 * fTemp505) + ((0.047424299999999996 * fTemp506) + ((0.043948600000000004 * fTemp507) + ((0.081345899999999999 * fTemp508) + ((0.062211200000000001 * fTemp509) + ((0.046698700000000003 * fTemp510) + ((0.0034082300000000004 * fTemp1057) + ((0.0017853699999999999 * fTemp1058) + ((0.00345985 * fTemp1059) + ((0.00155444 * fTemp1061) + ((0.000148231 * fTemp517) + ((0.00053192199999999999 * fTemp518) + ((0.0072206400000000004 * fTemp1064) + ((0.0011467599999999999 * fTemp1065) + ((0.0018625499999999999 * fTemp520) + ((0.0014091100000000001 * fTemp521) + ((0.00171149 * fTemp1068) + ((0.0032145400000000001 * fTemp1069) + ((0.0009296310000000001 * fTemp525) + ((0.00017575500000000001 * fTemp526) + ((0.000234556 * fTemp1071) + ((0.0292041 * fTemp529) + ((0.015611 * fTemp530) + ((0.0131959 * fTemp532) + ((0.0033820999999999999 * fTemp533) + ((0.00065433400000000001 * fTemp534) + ((0.00012754700000000002 * fTemp1081) + ((0.00028600400000000002 * fTemp535) + ((0.00056964699999999995 * fTemp536) + ((0.00055874899999999999 * fTemp537) + ((0.000107706 * fTemp538) + ((2.3258800000000005e-05 * fTemp539) + ((1.5002200000000002e-05 * fTemp265) + ((0.000386788 * fTemp1085) + ((0.00090610300000000012 * fTemp541) + ((0.0014508500000000001 * fTemp542) + ((0.0044549899999999998 * fTemp1087) + ((0.00015571700000000001 * fTemp545) + ((0.00054205300000000002 * fTemp1088) + ((0.0015368900000000002 * fTemp1089) + ((0.0026692399999999998 * fTemp546) + ((1.74779e-06 * fTemp547) + ((7.3980599999999995e-07 * fTemp548) + ((0.00144247 * fTemp549) + ((0.0020409600000000001 * fTemp550) + ((0.0020199900000000002 * fTemp551) + ((0.00067166600000000002 * fTemp552) + ((0.0046483699999999998 * fTemp553) + ((0.0007157 * fTemp1090) + ((0.0039002500000000005 * fTemp1091) + ((0.0084629900000000001 * fTemp554) + ((0.053001199999999998 * fTemp555) + ((0.048941400000000003 * fTemp556) + ((0.0007391530000000001 * fTemp557) + ((0.0020685400000000002 * fTemp558) + ((0.00055752700000000004 * fTemp559) + ((0.00107368 * fTemp560) + ((0.00105561 * fTemp561) + ((0.00064681700000000005 * fTemp562) + ((0.00078251799999999995 * fTemp563) + ((0.00084005400000000002 * fTemp564) + ((0.00072445800000000009 * fTemp565) + ((0.00012713900000000002 * fTemp566) + ((1.96889e-05 * fTemp432) + ((5.5660599999999997e-06 * fTemp567) + ((5.6691300000000004e-05 * fTemp1094) + ((0.024367400000000001 * fTemp568) + ((0.011542200000000001 * fTemp1096) + ((0.0023261500000000004 * fTemp570) + ((1.8977800000000003e-05 * fTemp571) + ((1.9873400000000002e-05 * fTemp572) + ((0.00107755 * fTemp1097) + ((1.8648999999999999e-06 * fTemp573) + ((1.4833700000000001e-06 * fTemp1101) + ((0.00016114100000000001 * fTemp575) + ((0.017303499999999999 * fTemp1102) + ((0.0038926099999999999 * fTemp1103) + ((0.0051357799999999995 * fTemp1104) + ((0.0057548899999999995 * fTemp1105) + ((0.0110121 * fTemp1106) + ((0.00038352400000000005 * fTemp576) + ((0.00193882 * fTemp1107) + ((0.0014356600000000001 * fTemp577) + ((0.00020930100000000001 * fTemp578) + ((0.016072400000000001 * fTemp1109) + ((0.0227996 * fTemp1110) + ((0.016965000000000001 * fTemp1111) + ((0.033336499999999998 * fTemp1112) + ((0.029073099999999998 * fTemp1113) + ((0.017693 * fTemp1114) + ((0.023498000000000002 * fTemp1115) + ((0.012867100000000001 * fTemp1116) + ((0.024658199999999998 * fTemp1117) + ((0.033071500000000004 * fTemp1118) + ((0.023601800000000003 * fTemp1119) + ((0.025422899999999998 * fTemp1120) + ((0.030269900000000002 * fTemp1121) + ((0.023295900000000001 * fTemp1122) + ((0.018621700000000001 * fTemp1123) + ((0.010567 * fTemp1124) + ((0.056895100000000004 * fTemp1125) + ((0.014210199999999999 * fTemp1127) + ((0.00027516900000000002 * fTemp1131) + ((0.00128867 * fTemp1132) + ((0.0013097499999999999 * fTemp597) + ((0.0016259900000000001 * fTemp598) + ((0.00050261399999999997 * fTemp599) + ((0.00278079 * fTemp600) + ((0.0081598500000000015 * fTemp602) + ((0.0056564199999999997 * fTemp603) + ((0.010539099999999999 * fTemp604) + ((0.0272114 * fTemp605) + ((0.021074000000000002 * fTemp606) + ((0.0080194200000000011 * fTemp608) + ((0.000377902 * fTemp1133) + ((0.0015717800000000001 * fTemp1136) + ((0.0086705299999999992 * fTemp610) + ((0.00411948 * fTemp1137) + ((0.0029588800000000001 * fTemp612) + ((0.0107584 * fTemp613) + ((0.0093965200000000002 * fTemp614) + ((0.0139764 * fTemp615) + ((0.0010616200000000001 * fTemp1141) + (0.016385799999999999 * fTemp617))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) + (0.00045463200000000001 * fTemp283))))) + (0.042141200000000004 * fTemp279)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) - ((9.8664600000000001e-07 * fTemp620) + ((0.000106835 * fTemp621) + ((3.4608100000000005e-05 * fTemp624) + ((0.00011808300000000001 * fTemp627) + ((0.00015213499999999999 * fTemp629) + ((0.00018018099999999999 * fTemp630) + ((0.00022798800000000001 * fTemp631) + ((5.723480000000001e-05 * fTemp2) + ((0.0010091500000000001 * fTemp632) + ((0.0015510600000000002 * fTemp633) + ((0.00097602600000000006 * fTemp634) + ((0.000712925 * fTemp3) + ((0.00090846500000000001 * fTemp4) + ((0.000274135 * fTemp635) + ((0.0024532300000000003 * fTemp636) + ((0.00327984 * fTemp637) + ((0.00165106 * fTemp638) + ((0.0016773199999999999 * fTemp639) + ((0.00626758 * fTemp640) + ((0.0045976600000000008 * fTemp641) + ((0.0023563100000000003 * fTemp642) + ((0.0048987900000000001 * fTemp643) + ((0.0034805299999999999 * fTemp644) + ((0.0026557099999999999 * fTemp8) + ((0.00044967800000000007 * fTemp645) + ((0.0043297500000000003 * fTemp646) + ((0.009209740000000001 * fTemp647) + ((0.0029224400000000001 * fTemp648) + ((0.0105223 * fTemp9) + ((0.0026383800000000001 * fTemp649) + ((0.0080828600000000007 * fTemp650) + ((0.022465099999999998 * fTemp651) + ((0.0090530699999999999 * fTemp10) + ((0.0048908699999999994 * fTemp652) + ((1.6838600000000002e-05 * fTemp654) + ((0.00013637100000000001 * fTemp13) + ((9.7487500000000005e-05 * fTemp14) + ((2.2899500000000003e-05 * fTemp655) + ((1.3387100000000001e-05 * fTemp656) + ((1.9403399999999997e-06 * fTemp15) + ((0.00034909600000000002 * fTemp16) + ((8.3318600000000019e-05 * fTemp657) + ((0.00019838400000000002 * fTemp18) + ((0.0012272400000000001 * fTemp658) + ((0.00020233 * fTemp21) + ((0.00257691 * fTemp660) + ((0.0010732299999999999 * fTemp661) + ((0.0017717799999999999 * fTemp662) + ((0.000561862 * fTemp626) + ((0.000172719 * fTemp25) + ((0.0028482099999999999 * fTemp663) + ((0.00218125 * fTemp664) + ((0.00186575 * fTemp29) + ((0.000588187 * fTemp31) + ((0.00392757 * fTemp668) + ((0.0028865100000000001 * fTemp669) + ((0.0056144999999999997 * fTemp670) + ((0.0026402700000000001 * fTemp671) + ((0.0042838500000000005 * fTemp33) + ((0.0034927700000000001 * fTemp673) + ((0.0065811400000000009 * fTemp34) + ((0.0015727 * fTemp674) + ((0.00038527200000000003 * fTemp675) + ((0.027060000000000001 * fTemp677) + ((0.0063968899999999997 * fTemp36) + ((0.011650000000000001 * fTemp679) + ((0.0078633899999999996 * fTemp680) + ((0.0092220099999999992 * fTemp681) + ((0.029293300000000001 * fTemp39) + ((6.1935700000000003e-07 * fTemp41) + ((4.9322600000000008e-05 * fTemp682) + ((0.00028692799999999999 * fTemp683) + ((0.00133293 * fTemp44) + ((0.0028975800000000003 * fTemp684) + ((0.00187875 * fTemp685) + ((0.00088707100000000013 * fTemp686) + ((0.00020890300000000003 * fTemp687) + ((0.00237411 * fTemp688) + ((0.00112458 * fTemp689) + ((0.0031641300000000002 * fTemp690) + ((0.0018413699999999999 * fTemp691) + ((0.00090694700000000018 * fTemp55) + ((0.014119 * fTemp692) + ((0.0021459299999999999 * fTemp693) + ((0.015390200000000001 * fTemp58) + ((0.045964499999999998 * fTemp696) + ((0.028787799999999999 * fTemp698) + ((0.048319200000000007 * fTemp699) + ((0.076845299999999991 * fTemp700) + ((0.074437400000000001 * fTemp701) + ((0.0013813599999999999 * fTemp702) + ((9.4869000000000016e-05 * fTemp59) + ((0.00097653599999999996 * fTemp703) + ((0.00011001600000000001 * fTemp60) + ((0.00063438600000000002 * fTemp705) + ((0.00012589200000000001 * fTemp62) + ((0.00040925999999999999 * fTemp706) + ((6.4495100000000005e-05 * fTemp707) + ((1.3287400000000001e-05 * fTemp0) + ((0.00016574 * fTemp708) + ((0.00020847000000000004 * fTemp710) + ((0.00035920700000000001 * fTemp711) + ((0.00031580000000000003 * fTemp712) + ((0.0055766799999999997 * fTemp70) + ((1.6980200000000004e-05 * fTemp713) + ((3.2223700000000001e-05 * fTemp714) + ((0.00013887600000000002 * fTemp715) + ((0.00019982600000000001 * fTemp74) + ((0.00027277099999999999 * fTemp83) + ((0.000964846 * fTemp84) + ((0.0012146699999999999 * fTemp85) + ((0.00057145600000000003 * fTemp86) + ((0.00092367899999999995 * fTemp87) + ((0.0007145500000000001 * fTemp88) + ((0.00031649800000000002 * fTemp720) + ((0.0012203400000000001 * fTemp91) + ((0.0096560400000000012 * fTemp721) + ((0.0144406 * fTemp723) + ((0.013951100000000001 * fTemp724) + ((0.0084374500000000009 * fTemp92) + ((0.0039648399999999999 * fTemp727) + ((0.00036303800000000004 * fTemp95) + ((0.0014542699999999999 * fTemp729) + ((0.00064008700000000001 * fTemp97) + ((7.4982900000000003e-05 * fTemp99) + ((6.501340000000001e-05 * fTemp102) + ((0.00011503900000000001 * fTemp732) + ((7.9125199999999989e-06 * fTemp734) + ((1.1654000000000001e-05 * fTemp735) + ((6.8685100000000004e-05 * fTemp736) + ((8.4929499999999997e-06 * fTemp737) + ((1.41509e-05 * fTemp103) + ((0.00013697000000000001 * fTemp738) + ((0.00010523700000000001 * fTemp739) + ((3.2479200000000006e-05 * fTemp107) + ((7.9775300000000009e-05 * fTemp740) + ((0.00010184400000000001 * fTemp742) + ((5.1085100000000003e-05 * fTemp743) + ((3.2896299999999998e-06 * fTemp114) + ((0.00037059799999999998 * fTemp116) + ((0.000178013 * fTemp117) + ((0.0012454300000000001 * fTemp118) + ((0.0013326899999999999 * fTemp121) + ((0.00140716 * fTemp746) + ((0.00049063800000000005 * fTemp122) + ((0.00084652999999999996 * fTemp748) + ((0.00036433400000000001 * fTemp749) + ((0.001299 * fTemp123) + ((0.00067232300000000006 * fTemp751) + ((0.000145224 * fTemp124) + ((0.0033552399999999998 * fTemp752) + ((0.0029169900000000004 * fTemp753) + ((0.0019041500000000001 * fTemp755) + ((0.0020271300000000003 * fTemp758) + ((0.00118198 * fTemp759) + ((0.0037510500000000001 * fTemp760) + ((0.0044053800000000004 * fTemp761) + ((0.0050914999999999997 * fTemp762) + ((0.0046006600000000003 * fTemp763) + ((0.0069039700000000006 * fTemp764) + ((0.0058685200000000003 * fTemp765) + ((0.0011063700000000002 * fTemp766) + ((0.0019731900000000001 * fTemp130) + ((0.0051318099999999997 * fTemp767) + ((0.0061875000000000003 * fTemp768) + ((0.0086182900000000007 * fTemp769) + ((0.00066500800000000003 * fTemp770) + ((0.0054012200000000008 * fTemp771) + ((0.000641773 * fTemp131) + ((0.0077257100000000002 * fTemp772) + ((0.0049702700000000006 * fTemp773) + ((0.0075730000000000007 * fTemp774) + ((5.7104899999999999e-06 * fTemp134) + ((1.32724e-05 * fTemp135) + ((0.00015924 * fTemp136) + ((3.6292700000000006e-05 * fTemp137) + ((2.5843400000000004e-05 * fTemp777) + ((0.00024267500000000003 * fTemp778) + ((0.00039582199999999999 * fTemp139) + ((0.00031903100000000006 * fTemp140) + ((0.0011941500000000002 * fTemp141) + ((0.00106711 * fTemp142) + ((0.00308618 * fTemp143) + ((0.0032894199999999999 * fTemp144) + ((0.00149796 * fTemp145) + ((0.00068249900000000004 * fTemp146) + ((0.00078510099999999996 * fTemp148) + ((0.00096550100000000012 * fTemp149) + ((0.00058387599999999999 * fTemp150) + ((0.0013118799999999999 * fTemp151) + ((7.6537400000000003e-05 * fTemp152) + ((6.5009300000000008e-05 * fTemp153) + ((0.0031734000000000003 * fTemp154) + ((0.0023903100000000001 * fTemp155) + ((0.00058356200000000003 * fTemp156) + ((1.7606500000000002e-05 * fTemp157) + ((0.0027314400000000003 * fTemp159) + ((0.0017979000000000001 * fTemp160) + ((0.0013939500000000001 * fTemp161) + ((0.00191797 * fTemp162) + ((0.00034747700000000001 * fTemp163) + ((0.0011524899999999999 * fTemp789) + ((0.000320157 * fTemp169) + ((0.0075314300000000004 * fTemp170) + ((0.0020659800000000002 * fTemp172) + ((0.0049689600000000006 * fTemp790) + ((0.00801492 * fTemp791) + ((0.0022648999999999998 * fTemp792) + ((0.0110397 * fTemp173) + ((0.0010152000000000002 * fTemp174) + ((0.00287375 * fTemp794) + ((0.026332300000000003 * fTemp177) + ((0.0161706 * fTemp178) + ((0.0079993000000000009 * fTemp179) + ((0.00082163500000000003 * fTemp797) + ((0.035125400000000001 * fTemp180) + ((0.0032833199999999997 * fTemp182) + ((0.00033950300000000006 * fTemp801) + ((0.00046365600000000006 * fTemp802) + ((0.0019217200000000002 * fTemp184) + ((0.00055710700000000004 * fTemp185) + ((0.00078591400000000008 * fTemp186) + ((0.00067488200000000002 * fTemp187) + ((0.00020588500000000003 * fTemp188) + ((3.4700500000000004e-05 * fTemp189) + ((1.2413700000000001e-05 * fTemp80) + ((0.00022045699999999999 * fTemp805) + ((0.00380796 * fTemp190) + ((3.5918100000000004e-05 * fTemp192) + ((0.0026392099999999999 * fTemp193) + ((5.5551700000000006e-05 * fTemp807) + ((2.5941400000000002e-05 * fTemp194) + ((8.6548500000000007e-05 * fTemp195) + ((4.2405400000000006e-05 * fTemp196) + ((3.5255099999999998e-06 * fTemp197) + ((3.6866300000000003e-05 * fTemp198) + ((4.85157e-05 * fTemp199) + ((7.4248300000000005e-05 * fTemp200) + ((8.1096800000000013e-05 * fTemp201) + ((0.00033669 * fTemp202) + ((0.00035192300000000003 * fTemp203) + ((4.8744899999999996e-07 * fTemp206) + ((3.2621699999999995e-06 * fTemp207) + ((5.5010100000000004e-05 * fTemp809) + ((0.000181368 * fTemp810) + ((0.0012369000000000002 * fTemp211) + ((0.000181872 * fTemp212) + ((0.00084541900000000014 * fTemp813) + ((0.00030825999999999998 * fTemp213) + ((0.000991956 * fTemp214) + ((0.00076287399999999997 * fTemp215) + ((0.00098188600000000017 * fTemp817) + ((0.00039449500000000002 * fTemp216) + ((0.0012472700000000002 * fTemp217) + ((6.1852800000000005e-05 * fTemp218) + ((0.00122741 * fTemp220) + ((0.00019696800000000003 * fTemp822) + ((0.00051085000000000008 * fTemp824) + ((0.0048162999999999999 * fTemp221) + ((0.0040944599999999994 * fTemp223) + ((0.0041798500000000006 * fTemp826) + ((0.0073487099999999996 * fTemp224) + ((0.00164357 * fTemp828) + ((0.0047594300000000003 * fTemp226) + ((0.0066234300000000005 * fTemp227) + ((0.0021625699999999999 * fTemp228) + ((0.0107364 * fTemp229) + ((0.00078494800000000005 * fTemp230) + ((0.008554550000000001 * fTemp231) + ((0.0087573399999999989 * fTemp232) + ((0.0022028300000000002 * fTemp830) + ((0.026865800000000002 * fTemp233) + ((0.0066563000000000004 * fTemp833) + ((4.2778300000000003e-05 * fTemp235) + ((9.4569700000000004e-05 * fTemp834) + ((0.000158107 * fTemp835) + ((0.00048340500000000007 * fTemp836) + ((0.00023814000000000002 * fTemp837) + ((0.010395300000000001 * fTemp840) + ((0.0093701299999999991 * fTemp841) + ((0.0063169100000000002 * fTemp842) + ((0.0060908100000000003 * fTemp843) + ((0.013098200000000001 * fTemp844) + ((0.0095365099999999998 * fTemp845) + ((4.9636399999999996e-06 * fTemp846) + ((0.000168486 * fTemp847) + ((0.00017177199999999999 * fTemp848) + ((0.0011732700000000001 * fTemp851) + ((0.00090841200000000004 * fTemp239) + ((0.0016132899999999999 * fTemp240) + ((0.00080033999999999997 * fTemp243) + ((0.00113243 * fTemp245) + ((2.5690700000000001e-05 * fTemp246) + ((0.0016462200000000001 * fTemp852) + ((0.0158301 * fTemp853) + ((0.0126207 * fTemp254) + ((0.015590100000000001 * fTemp855) + ((0.027497799999999999 * fTemp857) + ((0.019302299999999998 * fTemp858) + ((0.044481599999999996 * fTemp859) + ((0.042276800000000003 * fTemp860) + ((0.0021177600000000002 * fTemp861) + ((0.00027291300000000001 * fTemp862) + ((6.1550000000000005e-05 * fTemp256) + ((0.000175224 * fTemp864) + ((0.00022650199999999998 * fTemp865) + ((5.7022700000000005e-05 * fTemp866) + ((2.0383200000000002e-05 * fTemp867) + ((4.9413399999999999e-06 * fTemp71) + ((0.00042647700000000008 * fTemp261) + ((0.0042857099999999999 * fTemp262) + ((0.0037509800000000001 * fTemp263) + ((0.000469171 * fTemp264) + ((0.0013037700000000001 * fTemp267) + ((6.2934400000000005e-05 * fTemp877) + ((0.000195522 * fTemp878) + ((0.00010142800000000001 * fTemp879) + ((0.00070563799999999997 * fTemp880) + ((0.00031068799999999999 * fTemp271) + ((0.0015255399999999999 * fTemp881) + ((0.000380057 * fTemp882) + ((0.00093046600000000002 * fTemp619) + ((7.7027e-06 * fTemp884) + ((5.28142e-05 * fTemp885) + ((0.00019374600000000001 * fTemp281) + ((0.00024288000000000001 * fTemp282) + ((0.00086436100000000012 * fTemp284) + ((5.3978799999999999e-06 * fTemp888) + ((5.8471100000000003e-05 * fTemp889) + ((0.00011763 * fTemp890) + ((0.00096584900000000007 * fTemp891) + ((0.000544179 * fTemp285) + ((0.00077855999999999997 * fTemp287) + ((0.00043610699999999998 * fTemp289) + ((0.000204336 * fTemp290) + ((2.2571e-06 * fTemp291) + ((1.2883700000000002e-05 * fTemp191) + ((0.0065755600000000003 * fTemp901) + ((0.044476699999999994 * fTemp292) + ((0.019425600000000001 * fTemp293) + ((0.0258357 * fTemp295) + ((0.00505303 * fTemp296) + ((0.00065851199999999999 * fTemp297) + ((6.4017400000000008e-05 * fTemp908) + ((0.00033249800000000003 * fTemp298) + ((0.00114682 * fTemp299) + ((0.0173968 * fTemp302) + ((0.00029377599999999999 * fTemp913) + ((0.000280439 * fTemp914) + ((0.000643591 * fTemp916) + ((0.00081294000000000006 * fTemp917) + ((0.00023107600000000004 * fTemp918) + ((0.00064061300000000005 * fTemp919) + ((0.00091664000000000003 * fTemp920) + ((0.00059890600000000007 * fTemp921) + ((0.00073955600000000005 * fTemp922) + ((0.0027768799999999998 * fTemp923) + ((0.0022861500000000002 * fTemp925) + ((0.0013073099999999999 * fTemp926) + ((0.00145302 * fTemp310) + ((0.00040949500000000001 * fTemp927) + ((0.00082950500000000002 * fTemp928) + ((0.00070229999999999999 * fTemp929) + ((0.00080632699999999991 * fTemp930) + ((0.001377 * fTemp312) + ((0.00016274 * fTemp316) + ((0.0028667500000000004 * fTemp932) + ((0.0011399600000000002 * fTemp933) + ((0.0027307400000000002 * fTemp934) + ((0.00100318 * fTemp935) + ((0.0022987899999999998 * fTemp936) + ((0.00110995 * fTemp937) + ((0.00124602 * fTemp938) + ((0.00129805 * fTemp939) + ((0.0023355800000000003 * fTemp940) + ((0.0019049100000000001 * fTemp941) + ((0.00050953999999999995 * fTemp942) + ((0.0038312400000000001 * fTemp943) + ((0.0011070699999999999 * fTemp944) + ((0.00059075000000000002 * fTemp945) + ((0.00044511000000000003 * fTemp322) + ((0.0016638 * fTemp948) + ((0.0043739400000000006 * fTemp330) + ((0.0106382 * fTemp949) + ((0.0043469900000000002 * fTemp950) + ((0.0015759000000000001 * fTemp333) + ((0.0073185999999999998 * fTemp334) + ((0.0045973800000000007 * fTemp952) + ((0.013183400000000001 * fTemp335) + ((0.028645500000000001 * fTemp953) + ((0.0092487699999999999 * fTemp338) + ((0.039121700000000002 * fTemp954) + ((0.00144425 * fTemp955) + ((0.0060285 * fTemp956) + ((0.057524800000000001 * fTemp957) + ((0.0013932899999999999 * fTemp342) + ((7.8904099999999995e-07 * fTemp349) + ((3.48346e-05 * fTemp350) + ((5.1851200000000009e-05 * fTemp351) + ((0.000263489 * fTemp962) + ((0.00072508600000000011 * fTemp963) + ((0.00110553 * fTemp964) + ((0.0018638400000000001 * fTemp965) + ((0.00082826600000000003 * fTemp966) + ((0.0013655500000000001 * fTemp967) + ((0.0013615999999999999 * fTemp968) + ((0.00103053 * fTemp969) + ((0.00040302800000000005 * fTemp353) + ((0.0012814900000000001 * fTemp354) + ((0.0015273399999999999 * fTemp970) + ((0.00046550599999999997 * fTemp971) + ((0.00038473700000000001 * fTemp355) + ((0.0010250300000000001 * fTemp356) + ((0.0011346700000000002 * fTemp358) + ((0.00043984100000000006 * fTemp363) + ((0.0016748900000000001 * fTemp973) + ((0.00097958799999999999 * fTemp974) + ((0.00066577900000000002 * fTemp975) + ((0.00120272 * fTemp976) + ((0.0010960700000000002 * fTemp364) + ((0.0013700399999999999 * fTemp978) + ((0.0019637600000000002 * fTemp980) + ((0.0018260300000000002 * fTemp981) + ((0.00238017 * fTemp982) + ((0.0030635300000000001 * fTemp983) + ((0.00021673800000000001 * fTemp367) + ((0.0025982900000000001 * fTemp984) + ((0.0016457800000000001 * fTemp985) + ((0.0013408299999999999 * fTemp986) + ((0.0031654200000000004 * fTemp988) + ((0.00275033 * fTemp989) + ((0.00152893 * fTemp370) + ((0.00068048499999999999 * fTemp371) + ((0.0022063899999999999 * fTemp990) + ((0.00122218 * fTemp372) + ((0.00078379700000000003 * fTemp992) + ((0.00022987799999999998 * fTemp375) + ((0.00078511300000000004 * fTemp380) + ((0.0012260999999999999 * fTemp381) + ((0.0026344099999999998 * fTemp384) + ((0.0038961999999999998 * fTemp386) + ((0.011467400000000001 * fTemp995) + ((0.0078678299999999993 * fTemp996) + ((0.0089890100000000004 * fTemp391) + ((0.0013363100000000001 * fTemp997) + ((0.0143689 * fTemp998) + ((0.0049334100000000001 * fTemp999) + ((0.019686699999999998 * fTemp1000) + ((0.0086390499999999988 * fTemp1001) + ((0.043355600000000001 * fTemp1004) + ((0.00249322 * fTemp1005) + ((0.0141169 * fTemp1006) + ((0.0111431 * fTemp1007) + ((0.0018486100000000001 * fTemp399) + ((0.000976993 * fTemp400) + ((0.0056459800000000001 * fTemp1008) + ((0.00021246900000000004 * fTemp1009) + ((0.00095016999999999996 * fTemp1010) + ((0.0010622000000000001 * fTemp1012) + ((0.00024919200000000002 * fTemp1013) + ((0.00027049600000000001 * fTemp1014) + ((5.1123399999999996e-06 * fTemp404) + ((3.7580000000000003e-05 * fTemp405) + ((1.0426200000000002e-05 * fTemp344) + ((2.5019199999999998e-06 * fTemp1018) + ((0.00041578400000000004 * fTemp407) + ((2.3801800000000003e-05 * fTemp1031) + ((0.00042180200000000004 * fTemp408) + ((0.00064933700000000005 * fTemp409) + ((0.00040693400000000007 * fTemp410) + ((0.00073777800000000002 * fTemp411) + ((0.0013956400000000001 * fTemp412) + ((0.0012716300000000002 * fTemp413) + ((0.0010572399999999999 * fTemp415) + ((0.00096599000000000012 * fTemp416) + ((0.00161012 * fTemp417) + ((0.0016711600000000001 * fTemp418) + ((0.00075290600000000002 * fTemp419) + ((0.00144013 * fTemp420) + ((0.00065036 * fTemp421) + ((0.0021273399999999997 * fTemp422) + ((0.00061597300000000002 * fTemp423) + ((0.0020596199999999999 * fTemp424) + ((0.00011313 * fTemp1033) + ((0.0017438199999999999 * fTemp425) + ((0.0024799100000000001 * fTemp426) + ((0.00130908 * fTemp1034) + ((0.00069698000000000004 * fTemp429) + ((0.0017169000000000002 * fTemp431) + ((0.0011552999999999999 * fTemp1036) + ((1.47262e-06 * fTemp438) + ((0.00048385000000000002 * fTemp451) + ((0.0023706000000000001 * fTemp456) + ((9.940880000000001e-05 * fTemp457) + ((0.00196204 * fTemp1051) + ((1.7742000000000001e-05 * fTemp1052) + ((0.000611186 * fTemp462) + ((0.00047365100000000001 * fTemp1054) + ((0.000687957 * fTemp464) + ((0.00036222200000000004 * fTemp472) + ((0.00092078700000000006 * fTemp488) + ((0.021295600000000001 * fTemp1056) + ((0.0025833200000000001 * fTemp511) + ((0.00054242299999999999 * fTemp512) + ((0.00061493000000000008 * fTemp513) + ((2.9137400000000003e-05 * fTemp514) + ((0.0015830800000000002 * fTemp515) + ((0.0017704200000000002 * fTemp1060) + ((0.0019330199999999999 * fTemp516) + ((0.00156606 * fTemp1062) + ((0.00266146 * fTemp1063) + ((0.0011897800000000001 * fTemp519) + ((0.00307881 * fTemp522) + ((0.0024114100000000001 * fTemp1066) + ((6.3317800000000006e-05 * fTemp523) + ((0.00026003500000000004 * fTemp1067) + ((4.06072e-05 * fTemp524) + ((0.000175864 * fTemp1070) + ((0.000162845 * fTemp527) + ((0.00103864 * fTemp1072) + ((0.0013787300000000001 * fTemp1073) + ((0.00181733 * fTemp1074) + ((0.00293582 * fTemp1075) + ((0.0014793400000000002 * fTemp528) + ((0.021570599999999999 * fTemp1076) + ((0.0043988899999999999 * fTemp1077) + ((0.0073680199999999994 * fTemp531) + ((0.00058021900000000009 * fTemp1078) + ((0.0037306700000000002 * fTemp1079) + ((0.000216524 * fTemp1080) + ((0.00050577300000000005 * fTemp1082) + ((0.00019702400000000002 * fTemp1083) + ((6.4290300000000003e-05 * fTemp1084) + ((0.00256507 * fTemp540) + ((0.000597807 * fTemp543) + ((2.74177e-05 * fTemp1086) + ((0.0018893200000000001 * fTemp544) + ((0.00016075400000000001 * fTemp1092) + ((0.00052814500000000005 * fTemp1093) + ((0.0017080400000000001 * fTemp1095) + ((7.4329200000000013e-05 * fTemp569) + ((0.00048678400000000003 * fTemp1098) + ((0.00094771800000000006 * fTemp1099) + ((0.00085589900000000003 * fTemp1100) + ((0.00015476800000000001 * fTemp574) + ((0.00087519700000000008 * fTemp1108) + ((0.00092920600000000002 * fTemp1126) + ((0.080136100000000002 * fTemp579) + ((0.0088175100000000006 * fTemp580) + ((0.042661300000000006 * fTemp581) + ((0.041393800000000001 * fTemp582) + ((0.097787600000000002 * fTemp583) + ((0.053196100000000003 * fTemp584) + ((0.040092800000000005 * fTemp585) + ((0.077296500000000004 * fTemp586) + ((0.082935599999999998 * fTemp587) + ((0.064767000000000005 * fTemp588) + ((0.00067357800000000009 * fTemp589) + ((0.078489900000000001 * fTemp590) + ((0.00149621 * fTemp1128) + ((0.00072128000000000003 * fTemp591) + ((0.00101019 * fTemp1129) + ((0.000453602 * fTemp592) + ((0.00042969900000000002 * fTemp1130) + ((0.0010723199999999999 * fTemp593) + ((0.00084950300000000004 * fTemp594) + ((0.00085153200000000001 * fTemp595) + ((0.00015027000000000001 * fTemp596) + ((2.4709800000000002e-05 * fTemp286) + ((0.00063317100000000008 * fTemp601) + ((0.0029395300000000001 * fTemp607) + ((0.00025527000000000004 * fTemp618) + ((0.00098456699999999999 * fTemp1134) + ((0.0060422599999999998 * fTemp1135) + ((0.0027149600000000002 * fTemp609) + ((5.1858400000000005e-05 * fTemp611) + ((0.00081970899999999995 * fTemp1138) + ((0.0045739400000000003 * fTemp1139) + ((0.00060354400000000002 * fTemp1140) + ((5.63033e-05 * fTemp616) + (0.0033351100000000001 * fTemp1142))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))); fRec12[0] = std::max<double>((fRec12[1] - fConst0), std::min<double>(6.0, (20.0 * std::log10(std::max<double>(0.00031622776601683794, std::fabs(fTemp1144)))))); fHbargraph1 = FAUSTFLOAT(fRec12[0]); output1[i] = FAUSTFLOAT(fTemp1144); fRec1[1] = fRec1[0]; fRec3[1] = fRec3[0]; fRec2[1] = fRec2[0]; IOTA = (IOTA + 1); fRec4[1] = fRec4[0]; fRec5[1] = fRec5[0]; fRec6[1] = fRec6[0]; fRec7[1] = fRec7[0]; fRec8[1] = fRec8[0]; fRec9[1] = fRec9[0]; fRec10[1] = fRec10[0]; fRec11[1] = fRec11[0]; fRec0[1] = fRec0[0]; fRec12[1] = fRec12[0]; } } }; #ifdef FAUST_UIMACROS #define FAUST_FILE_NAME "ue.binaural.decoder.dsp" #define FAUST_CLASS_NAME "ue_binaural_decoder" #define FAUST_INPUTS 9 #define FAUST_OUTPUTS 2 #define FAUST_ACTIVES 14 #define FAUST_PASSIVES 11 FAUST_ADDCHECKBOX("Inputs/0/ 0/Mute", fCheckbox11); FAUST_ADDVERTICALBARGRAPH("Inputs/0/ 0/", fVbargraph8, -70.0, 6.0); FAUST_ADDCHECKBOX("Inputs/0/Mute", fCheckbox10); FAUST_ADDCHECKBOX("Inputs/1/ 1/Mute", fCheckbox8); FAUST_ADDVERTICALBARGRAPH("Inputs/1/ 1/", fVbargraph6, -70.0, 6.0); FAUST_ADDCHECKBOX("Inputs/1/ 2/Mute", fCheckbox9); FAUST_ADDVERTICALBARGRAPH("Inputs/1/ 2/", fVbargraph7, -70.0, 6.0); FAUST_ADDCHECKBOX("Inputs/1/ 3/Mute", fCheckbox7); FAUST_ADDVERTICALBARGRAPH("Inputs/1/ 3/", fVbargraph5, -70.0, 6.0); FAUST_ADDCHECKBOX("Inputs/1/Mute", fCheckbox6); FAUST_ADDCHECKBOX("Inputs/2/ 4/Mute", fCheckbox5); FAUST_ADDVERTICALBARGRAPH("Inputs/2/ 4/", fVbargraph4, -70.0, 6.0); FAUST_ADDCHECKBOX("Inputs/2/ 5/Mute", fCheckbox4); FAUST_ADDVERTICALBARGRAPH("Inputs/2/ 5/", fVbargraph3, -70.0, 6.0); FAUST_ADDCHECKBOX("Inputs/2/ 6/Mute", fCheckbox3); FAUST_ADDVERTICALBARGRAPH("Inputs/2/ 6/", fVbargraph2, -70.0, 6.0); FAUST_ADDCHECKBOX("Inputs/2/ 7/Mute", fCheckbox2); FAUST_ADDVERTICALBARGRAPH("Inputs/2/ 7/", fVbargraph1, -70.0, 6.0); FAUST_ADDCHECKBOX("Inputs/2/ 8/Mute", fCheckbox1); FAUST_ADDVERTICALBARGRAPH("Inputs/2/ 8/", fVbargraph0, -70.0, 6.0); FAUST_ADDCHECKBOX("Inputs/2/Mute", fCheckbox0); FAUST_ADDVERTICALSLIDER("Inputs/Inputs Gain", fVslider1, 0.0, -10.0, 10.0, 0.10000000000000001); FAUST_ADDVERTICALSLIDER("Inputs/Outputs Gain", fVslider0, 0.0, -10.0, 10.0, 0.10000000000000001); FAUST_ADDHORIZONTALBARGRAPH("Outputs/Left/", fHbargraph0, -70.0, 6.0); FAUST_ADDHORIZONTALBARGRAPH("Outputs/Right/", fHbargraph1, -70.0, 6.0); #define FAUST_LIST_ACTIVES(p) \ p(CHECKBOX, Mute, "Inputs/0/ 0/Mute", fCheckbox11, 0.0, 0.0, 1.0, 1.0) \ p(CHECKBOX, Mute, "Inputs/0/Mute", fCheckbox10, 0.0, 0.0, 1.0, 1.0) \ p(CHECKBOX, Mute, "Inputs/1/ 1/Mute", fCheckbox8, 0.0, 0.0, 1.0, 1.0) \ p(CHECKBOX, Mute, "Inputs/1/ 2/Mute", fCheckbox9, 0.0, 0.0, 1.0, 1.0) \ p(CHECKBOX, Mute, "Inputs/1/ 3/Mute", fCheckbox7, 0.0, 0.0, 1.0, 1.0) \ p(CHECKBOX, Mute, "Inputs/1/Mute", fCheckbox6, 0.0, 0.0, 1.0, 1.0) \ p(CHECKBOX, Mute, "Inputs/2/ 4/Mute", fCheckbox5, 0.0, 0.0, 1.0, 1.0) \ p(CHECKBOX, Mute, "Inputs/2/ 5/Mute", fCheckbox4, 0.0, 0.0, 1.0, 1.0) \ p(CHECKBOX, Mute, "Inputs/2/ 6/Mute", fCheckbox3, 0.0, 0.0, 1.0, 1.0) \ p(CHECKBOX, Mute, "Inputs/2/ 7/Mute", fCheckbox2, 0.0, 0.0, 1.0, 1.0) \ p(CHECKBOX, Mute, "Inputs/2/ 8/Mute", fCheckbox1, 0.0, 0.0, 1.0, 1.0) \ p(CHECKBOX, Mute, "Inputs/2/Mute", fCheckbox0, 0.0, 0.0, 1.0, 1.0) \ p(VERTICALSLIDER, Inputs_Gain, "Inputs/Inputs Gain", fVslider1, 0.0, -10.0, 10.0, 0.10000000000000001) \ p(VERTICALSLIDER, Outputs_Gain, "Inputs/Outputs Gain", fVslider0, 0.0, -10.0, 10.0, 0.10000000000000001) \ #define FAUST_LIST_PASSIVES(p) \ p(VERTICALBARGRAPH, , "Inputs/0/ 0/", fVbargraph8, 0.0, -70.0, 6.0, 0.0) \ p(VERTICALBARGRAPH, , "Inputs/1/ 1/", fVbargraph6, 0.0, -70.0, 6.0, 0.0) \ p(VERTICALBARGRAPH, , "Inputs/1/ 2/", fVbargraph7, 0.0, -70.0, 6.0, 0.0) \ p(VERTICALBARGRAPH, , "Inputs/1/ 3/", fVbargraph5, 0.0, -70.0, 6.0, 0.0) \ p(VERTICALBARGRAPH, , "Inputs/2/ 4/", fVbargraph4, 0.0, -70.0, 6.0, 0.0) \ p(VERTICALBARGRAPH, , "Inputs/2/ 5/", fVbargraph3, 0.0, -70.0, 6.0, 0.0) \ p(VERTICALBARGRAPH, , "Inputs/2/ 6/", fVbargraph2, 0.0, -70.0, 6.0, 0.0) \ p(VERTICALBARGRAPH, , "Inputs/2/ 7/", fVbargraph1, 0.0, -70.0, 6.0, 0.0) \ p(VERTICALBARGRAPH, , "Inputs/2/ 8/", fVbargraph0, 0.0, -70.0, 6.0, 0.0) \ p(HORIZONTALBARGRAPH, , "Outputs/Left/", fHbargraph0, 0.0, -70.0, 6.0, 0.0) \ p(HORIZONTALBARGRAPH, , "Outputs/Right/", fHbargraph1, 0.0, -70.0, 6.0, 0.0) \ #endif /***************************END USER SECTION ***************************/ /*******************BEGIN ARCHITECTURE SECTION (part 2/2)***************/ /* Faust code wrapper ------- */ #include "ext.h" #include "ext_obex.h" #include "z_dsp.h" #include "jpatcher_api.h" #include <string.h> #define ASSIST_INLET 1 #define ASSIST_OUTLET 2 #define EXTERNAL_VERSION "0.77" #define STR_SIZE 512 /************************** BEGIN MidiUI.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef FAUST_MIDIUI_H #define FAUST_MIDIUI_H #include <vector> #include <string> #include <utility> #include <iostream> #include <cstdlib> #include <cmath> /************************** BEGIN MapUI.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef FAUST_MAPUI_H #define FAUST_MAPUI_H #include <vector> #include <map> #include <string> /******************************************************************************* * MapUI : Faust User Interface * This class creates a map of complete hierarchical path and zones for each UI items. ******************************************************************************/ class MapUI : public UI, public PathBuilder { protected: // Complete path map std::map<std::string, FAUSTFLOAT*> fPathZoneMap; // Label zone map std::map<std::string, FAUSTFLOAT*> fLabelZoneMap; public: MapUI() {} virtual ~MapUI() {} // -- widget's layouts void openTabBox(const char* label) { pushLabel(label); } void openHorizontalBox(const char* label) { pushLabel(label); } void openVerticalBox(const char* label) { pushLabel(label); } void closeBox() { popLabel(); } // -- active widgets void addButton(const char* label, FAUSTFLOAT* zone) { fPathZoneMap[buildPath(label)] = zone; fLabelZoneMap[label] = zone; } void addCheckButton(const char* label, FAUSTFLOAT* zone) { fPathZoneMap[buildPath(label)] = zone; fLabelZoneMap[label] = zone; } void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT fmin, FAUSTFLOAT fmax, FAUSTFLOAT step) { fPathZoneMap[buildPath(label)] = zone; fLabelZoneMap[label] = zone; } void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT fmin, FAUSTFLOAT fmax, FAUSTFLOAT step) { fPathZoneMap[buildPath(label)] = zone; fLabelZoneMap[label] = zone; } void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT fmin, FAUSTFLOAT fmax, FAUSTFLOAT step) { fPathZoneMap[buildPath(label)] = zone; fLabelZoneMap[label] = zone; } // -- passive widgets void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT fmin, FAUSTFLOAT fmax) { fPathZoneMap[buildPath(label)] = zone; fLabelZoneMap[label] = zone; } void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT fmin, FAUSTFLOAT fmax) { fPathZoneMap[buildPath(label)] = zone; fLabelZoneMap[label] = zone; } // -- soundfiles virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) {} // -- metadata declarations void declare(FAUSTFLOAT* zone, const char* key, const char* val) {} // set/get void setParamValue(const std::string& path, FAUSTFLOAT value) { if (fPathZoneMap.find(path) != fPathZoneMap.end()) { *fPathZoneMap[path] = value; } else if (fLabelZoneMap.find(path) != fLabelZoneMap.end()) { *fLabelZoneMap[path] = value; } } FAUSTFLOAT getParamValue(const std::string& path) { if (fPathZoneMap.find(path) != fPathZoneMap.end()) { return *fPathZoneMap[path]; } else if (fLabelZoneMap.find(path) != fLabelZoneMap.end()) { return *fLabelZoneMap[path]; } else { return FAUSTFLOAT(0); } } // map access std::map<std::string, FAUSTFLOAT*>& getMap() { return fPathZoneMap; } int getParamsCount() { return int(fPathZoneMap.size()); } std::string getParamAddress(int index) { std::map<std::string, FAUSTFLOAT*>::iterator it = fPathZoneMap.begin(); while (index-- > 0 && it++ != fPathZoneMap.end()) {} return (*it).first; } std::string getParamAddress(FAUSTFLOAT* zone) { std::map<std::string, FAUSTFLOAT*>::iterator it = fPathZoneMap.begin(); do { if ((*it).second == zone) return (*it).first; } while (it++ != fPathZoneMap.end()); return ""; } static bool endsWith(std::string const& str, std::string const& end) { size_t l1 = str.length(); size_t l2 = end.length(); return (l1 >= l2) && (0 == str.compare(l1 - l2, l2, end)); } }; #endif // FAUST_MAPUI_H /************************** END MapUI.h **************************/ /************************** BEGIN midi.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __midi__ #define __midi__ #include <vector> #include <string> #include <algorithm> #include <assert.h> class MapUI; /************************************* A time-stamped short MIDI message **************************************/ // Force contiguous memory layout #pragma pack (push, 1) struct MIDIMessage { uint32_t frameIndex; uint8_t byte0, byte1, byte2; }; #pragma pack (pop) /******************************************************************************* * MIDI processor definition. * * MIDI input or output handling classes will implement this interface, * so the same method names (keyOn, ctrlChange...) will be used either * when decoding MIDI input or encoding MIDI output events. *******************************************************************************/ class midi { public: midi() {} virtual ~midi() {} // Additional time-stamped API for MIDI input virtual MapUI* keyOn(double, int channel, int pitch, int velocity) { return keyOn(channel, pitch, velocity); } virtual void keyOff(double, int channel, int pitch, int velocity = 127) { keyOff(channel, pitch, velocity); } virtual void keyPress(double, int channel, int pitch, int press) { keyPress(channel, pitch, press); } virtual void chanPress(double date, int channel, int press) { chanPress(channel, press); } virtual void pitchWheel(double, int channel, int wheel) { pitchWheel(channel, wheel); } virtual void ctrlChange(double, int channel, int ctrl, int value) { ctrlChange(channel, ctrl, value); } virtual void ctrlChange14bits(double, int channel, int ctrl, int value) { ctrlChange14bits(channel, ctrl, value); } virtual void rpn(double, int channel, int ctrl, int value) { rpn(channel, ctrl, value); } virtual void progChange(double, int channel, int pgm) { progChange(channel, pgm); } virtual void sysEx(double, std::vector<unsigned char>& message) { sysEx(message); } // MIDI sync virtual void startSync(double date) {} virtual void stopSync(double date) {} virtual void clock(double date) {} // Standard MIDI API virtual MapUI* keyOn(int channel, int pitch, int velocity) { return nullptr; } virtual void keyOff(int channel, int pitch, int velocity) {} virtual void keyPress(int channel, int pitch, int press) {} virtual void chanPress(int channel, int press) {} virtual void ctrlChange(int channel, int ctrl, int value) {} virtual void ctrlChange14bits(int channel, int ctrl, int value) {} virtual void rpn(int channel, int ctrl, int value) {} virtual void pitchWheel(int channel, int wheel) {} virtual void progChange(int channel, int pgm) {} virtual void sysEx(std::vector<unsigned char>& message) {} enum MidiStatus { // channel voice messages MIDI_NOTE_OFF = 0x80, MIDI_NOTE_ON = 0x90, MIDI_CONTROL_CHANGE = 0xB0, MIDI_PROGRAM_CHANGE = 0xC0, MIDI_PITCH_BEND = 0xE0, MIDI_AFTERTOUCH = 0xD0, // aka channel pressure MIDI_POLY_AFTERTOUCH = 0xA0, // aka key pressure MIDI_CLOCK = 0xF8, MIDI_START = 0xFA, MIDI_CONT = 0xFB, MIDI_STOP = 0xFC, MIDI_SYSEX_START = 0xF0, MIDI_SYSEX_STOP = 0xF7 }; enum MidiCtrl { ALL_NOTES_OFF = 123, ALL_SOUND_OFF = 120 }; enum MidiNPN { PITCH_BEND_RANGE = 0 }; }; /* A class to decode NRPN and RPN messages, adapted from JUCE forum message: https://forum.juce.com/t/14bit-midi-controller-support/11517 */ class MidiNRPN { private: bool ctrlnew; int ctrlnum; int ctrlval; int nrpn_lsb, nrpn_msb; int data_lsb, data_msb; enum { midi_nrpn_lsb = 98, midi_nrpn_msb = 99, midi_rpn_lsb = 100, midi_rpn_msb = 101, midi_data_lsb = 38, midi_data_msb = 6 }; public: MidiNRPN(): ctrlnew(false), nrpn_lsb(-1), nrpn_msb(-1), data_lsb(-1), data_msb(-1) {} // return true if the message has been filtered bool process(int data1, int data2) { switch (data1) { case midi_nrpn_lsb: nrpn_lsb = data2; return true; case midi_nrpn_msb: nrpn_msb = data2; return true; case midi_rpn_lsb: { if (data2 == 127) { nrpn_lsb = data_lsb = -1; } else { nrpn_lsb = 0; data_lsb = -1; } return true; } case midi_rpn_msb: { if (data2 == 127) { nrpn_msb = data_msb = -1; } else { nrpn_msb = 0; data_msb = -1; } return true; } case midi_data_lsb: case midi_data_msb: { if (data1 == midi_data_msb) { if (nrpn_msb < 0) { return false; } data_msb = data2; } else { // midi_data_lsb if (nrpn_lsb < 0) { return false; } data_lsb = data2; } if (data_lsb >= 0 && data_msb >= 0) { ctrlnum = (nrpn_msb << 7) | nrpn_lsb; ctrlval = (data_msb << 7) | data_lsb; data_lsb = data_msb = -1; nrpn_msb = nrpn_lsb = -1; ctrlnew = true; } return true; } default: return false; }; } bool hasNewNRPN() { bool res = ctrlnew; ctrlnew = false; return res; } // results in [0, 16383] int getCtrl() const { return ctrlnum; } int getVal() const { return ctrlval; } }; /**************************************************** * Base class for MIDI input handling. * * Shared common code used for input handling: * - decoding Real-Time messages: handleSync * - decoding one data byte messages: handleData1 * - decoding two data byte messages: handleData2 * - getting ready messages in polling mode ****************************************************/ class midi_handler : public midi { protected: std::vector<midi*> fMidiInputs; std::string fName; MidiNRPN fNRPN; int range(int min, int max, int val) { return (val < min) ? min : ((val >= max) ? max : val); } public: midi_handler(const std::string& name = "MIDIHandler"):fName(name) {} virtual ~midi_handler() {} void addMidiIn(midi* midi_dsp) { if (midi_dsp) fMidiInputs.push_back(midi_dsp); } void removeMidiIn(midi* midi_dsp) { std::vector<midi*>::iterator it = std::find(fMidiInputs.begin(), fMidiInputs.end(), midi_dsp); if (it != fMidiInputs.end()) { fMidiInputs.erase(it); } } // Those 2 methods have to be implemented by subclasses virtual bool startMidi() { return true; } virtual void stopMidi() {} void setName(const std::string& name) { fName = name; } std::string getName() { return fName; } // To be used in polling mode virtual int recvMessages(std::vector<MIDIMessage>* message) { return 0; } virtual void sendMessages(std::vector<MIDIMessage>* message, int count) {} // MIDI Real-Time void handleClock(double time) { for (unsigned int i = 0; i < fMidiInputs.size(); i++) { fMidiInputs[i]->clock(time); } } void handleStart(double time) { for (unsigned int i = 0; i < fMidiInputs.size(); i++) { fMidiInputs[i]->startSync(time); } } void handleStop(double time) { for (unsigned int i = 0; i < fMidiInputs.size(); i++) { fMidiInputs[i]->stopSync(time); } } void handleSync(double time, int type) { if (type == MIDI_CLOCK) { handleClock(time); // We can consider start and continue as identical messages } else if ((type == MIDI_START) || (type == MIDI_CONT)) { handleStart(time); } else if (type == MIDI_STOP) { handleStop(time); } } // MIDI 1 data void handleProgChange(double time, int channel, int data1) { for (unsigned int i = 0; i < fMidiInputs.size(); i++) { fMidiInputs[i]->progChange(time, channel, data1); } } void handleAfterTouch(double time, int channel, int data1) { for (unsigned int i = 0; i < fMidiInputs.size(); i++) { fMidiInputs[i]->chanPress(time, channel, data1); } } void handleData1(double time, int type, int channel, int data1) { if (type == MIDI_PROGRAM_CHANGE) { handleProgChange(time, channel, data1); } else if (type == MIDI_AFTERTOUCH) { handleAfterTouch(time, channel, data1); } } // MIDI 2 datas void handleKeyOff(double time, int channel, int data1, int data2) { for (unsigned int i = 0; i < fMidiInputs.size(); i++) { fMidiInputs[i]->keyOff(time, channel, data1, data2); } } void handleKeyOn(double time, int channel, int data1, int data2) { if (data2 == 0) { handleKeyOff(time, channel, data1, data2); } else { for (unsigned int i = 0; i < fMidiInputs.size(); i++) { fMidiInputs[i]->keyOn(time, channel, data1, data2); } } } void handleCtrlChange(double time, int channel, int data1, int data2) { // Special processing for NRPN and RPN if (fNRPN.process(data1, data2)) { if (fNRPN.hasNewNRPN()) { for (unsigned int i = 0; i < fMidiInputs.size(); i++) { fMidiInputs[i]->rpn(time, channel, fNRPN.getCtrl(), fNRPN.getVal()); } } } else { for (unsigned int i = 0; i < fMidiInputs.size(); i++) { fMidiInputs[i]->ctrlChange(time, channel, data1, data2); } } } void handlePitchWheel(double time, int channel, int data1, int data2) { for (unsigned int i = 0; i < fMidiInputs.size(); i++) { fMidiInputs[i]->pitchWheel(time, channel, (data2 << 7) + data1); } } void handlePitchWheel(double time, int channel, int bend) { for (unsigned int i = 0; i < fMidiInputs.size(); i++) { fMidiInputs[i]->pitchWheel(time, channel, bend); } } void handlePolyAfterTouch(double time, int channel, int data1, int data2) { for (unsigned int i = 0; i < fMidiInputs.size(); i++) { fMidiInputs[i]->keyPress(time, channel, data1, data2); } } void handleData2(double time, int type, int channel, int data1, int data2) { if (type == MIDI_NOTE_OFF) { handleKeyOff(time, channel, data1, data2); } else if (type == MIDI_NOTE_ON) { handleKeyOn(time, channel, data1, data2); } else if (type == MIDI_CONTROL_CHANGE) { handleCtrlChange(time, channel, data1, data2); } else if (type == MIDI_PITCH_BEND) { handlePitchWheel(time, channel, data1, data2); } else if (type == MIDI_POLY_AFTERTOUCH) { handlePolyAfterTouch(time, channel, data1, data2); } } // SysEx void handleSysex(double time, std::vector<unsigned char>& message) { for (unsigned int i = 0; i < fMidiInputs.size(); i++) { fMidiInputs[i]->sysEx(time, message); } } void handleMessage(double time, int type, std::vector<unsigned char>& message) { if (type == MIDI_SYSEX_START) { handleSysex(time, message); } } }; //------------------------------- // For timestamped MIDI messages //------------------------------- struct DatedMessage { double fDate; unsigned char fBuffer[3]; size_t fSize; DatedMessage(double date, unsigned char* buffer, size_t size) :fDate(date), fSize(size) { assert(size <= 3); memcpy(fBuffer, buffer, size); } DatedMessage():fDate(0.0), fSize(0) {} }; #endif // __midi__ /************************** END midi.h **************************/ #ifdef _MSC_VER #define gsscanf sscanf_s #else #define gsscanf sscanf #endif /***************************************************************************** * Helper code for MIDI meta and polyphonic 'nvoices' parsing ******************************************************************************/ struct MidiMeta : public Meta, public std::map<std::string, std::string> { void declare(const char* key, const char* value) { (*this)[key] = value; } const std::string get(const char* key, const char* def) { return (this->find(key) != this->end()) ? (*this)[key] : def; } static void analyse(dsp* mono_dsp, bool& midi_sync, int& nvoices) { JSONUI jsonui; mono_dsp->buildUserInterface(&jsonui); std::string json = jsonui.JSON(); midi_sync = ((json.find("midi") != std::string::npos) && ((json.find("start") != std::string::npos) || (json.find("stop") != std::string::npos) || (json.find("clock") != std::string::npos) || (json.find("timestamp") != std::string::npos))); #if defined(NVOICES) && NVOICES!=NUM_VOICES nvoices = NVOICES; #else MidiMeta meta; mono_dsp->metadata(&meta); bool found_voices = false; // If "options" metadata is used std::string options = meta.get("options", ""); if (options != "") { std::map<std::string, std::string> metadata; std::string res; MetaDataUI::extractMetadata(options, res, metadata); if (metadata.find("nvoices") != metadata.end()) { nvoices = std::atoi(metadata["nvoices"].c_str()); found_voices = true; } } // Otherwise test for "nvoices" metadata if (!found_voices) { std::string numVoices = meta.get("nvoices", "0"); nvoices = std::atoi(numVoices.c_str()); } nvoices = std::max<int>(0, nvoices); #endif } static bool checkPolyphony(dsp* mono_dsp) { MapUI map_ui; mono_dsp->buildUserInterface(&map_ui); bool has_freq = false; bool has_gate = false; bool has_gain = false; for (int i = 0; i < map_ui.getParamsCount(); i++) { std::string path = map_ui.getParamAddress(i); has_freq |= MapUI::endsWith(path, "/freq"); has_gate |= MapUI::endsWith(path, "/gate"); has_gain |= MapUI::endsWith(path, "/gain"); } return (has_freq && has_gate && has_gain); } }; /******************************************************************************* * MidiUI : Faust User Interface * This class decodes MIDI meta data and maps incoming MIDI messages to them. * Currently ctrl, keyon/keyoff, keypress, pgm, chanpress, pitchwheel/pitchbend * start/stop/clock meta data is handled. ******************************************************************************/ class uiMidi { friend class MidiUI; protected: midi* fMidiOut; bool fInputCtrl; int fChan; // To be used when sending messages, returns the effective chan, or 0 when fChan is initialized with -1 (means 'all chans') int rangeChan() { return (((fChan < 0) || (fChan > 15)) ? 0 : fChan); } bool inRange(FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT v) { return (min <= v && v <= max); } public: uiMidi(midi* midi_out, bool input, int chan = -1):fMidiOut(midi_out), fInputCtrl(input), fChan(chan) {} virtual ~uiMidi() {} }; /***************************************************************************** * Base class for MIDI aware UI items ******************************************************************************/ class uiMidiItem : public uiMidi, public uiItem { public: uiMidiItem(midi* midi_out, GUI* ui, FAUSTFLOAT* zone, bool input = true, int chan = -1) :uiMidi(midi_out, input, chan), uiItem(ui, zone) {} virtual ~uiMidiItem() {} virtual void reflectZone() {} }; /***************************************************************************** * Base class for MIDI aware UI items with timestamp support ******************************************************************************/ class uiMidiTimedItem : public uiMidi, public uiTimedItem { public: uiMidiTimedItem(midi* midi_out, GUI* ui, FAUSTFLOAT* zone, bool input = true, int chan = -1) :uiMidi(midi_out, input, chan), uiTimedItem(ui, zone) {} virtual ~uiMidiTimedItem() {} virtual void reflectZone() {} }; //----------- // MIDI sync //----------- class uiMidiStart : public uiMidiTimedItem { public: uiMidiStart(midi* midi_out, GUI* ui, FAUSTFLOAT* zone, bool input = true) :uiMidiTimedItem(midi_out, ui, zone, input) {} virtual ~uiMidiStart() {} virtual void reflectZone() { FAUSTFLOAT v = *fZone; fCache = v; if (v != FAUSTFLOAT(0)) { fMidiOut->startSync(0); } } void modifyZone(double date, FAUSTFLOAT v) { if (fInputCtrl) { uiItem::modifyZone(FAUSTFLOAT(v)); } } }; class uiMidiStop : public uiMidiTimedItem { public: uiMidiStop(midi* midi_out, GUI* ui, FAUSTFLOAT* zone, bool input = true) :uiMidiTimedItem(midi_out, ui, zone, input) {} virtual ~uiMidiStop() {} virtual void reflectZone() { FAUSTFLOAT v = *fZone; fCache = v; if (v != FAUSTFLOAT(1)) { fMidiOut->stopSync(0); } } void modifyZone(double date, FAUSTFLOAT v) { if (fInputCtrl) { uiItem::modifyZone(FAUSTFLOAT(v)); } } }; class uiMidiClock : public uiMidiTimedItem { private: bool fState; public: uiMidiClock(midi* midi_out, GUI* ui, FAUSTFLOAT* zone, bool input = true) :uiMidiTimedItem(midi_out, ui, zone, input), fState(false) {} virtual ~uiMidiClock() {} virtual void reflectZone() { FAUSTFLOAT v = *fZone; fCache = v; fMidiOut->clock(0); } void modifyZone(double date, FAUSTFLOAT v) { if (fInputCtrl) { fState = !fState; uiMidiTimedItem::modifyZone(date, FAUSTFLOAT(fState)); } } }; //---------------------- // Standard MIDI events //---------------------- //--------------------------------------------- // uiMidiProgChange uses the [min...max] range //--------------------------------------------- class uiMidiProgChange : public uiMidiTimedItem { public: FAUSTFLOAT fMin, fMax; uiMidiProgChange(midi* midi_out, GUI* ui, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max, bool input = true, int chan = -1) :uiMidiTimedItem(midi_out, ui, zone, input, chan), fMin(min), fMax(max) {} virtual ~uiMidiProgChange() {} virtual void reflectZone() { FAUSTFLOAT v = *fZone; fCache = v; if (inRange(fMin, fMax, v)) { fMidiOut->progChange(rangeChan(), v); } } void modifyZone(FAUSTFLOAT v) { if (fInputCtrl && inRange(fMin, fMax, v)) { uiItem::modifyZone(v); } } void modifyZone(double date, FAUSTFLOAT v) { if (fInputCtrl && inRange(fMin, fMax, v)) { uiMidiTimedItem::modifyZone(date, v); } } }; class uiMidiChanPress : public uiMidiTimedItem { private: int fPress; public: uiMidiChanPress(midi* midi_out, int press, GUI* ui, FAUSTFLOAT* zone, bool input = true, int chan = -1) :uiMidiTimedItem(midi_out, ui, zone, input, chan), fPress(press) {} virtual ~uiMidiChanPress() {} virtual void reflectZone() { FAUSTFLOAT v = *fZone; fCache = v; if (v != FAUSTFLOAT(0)) { fMidiOut->chanPress(rangeChan(), fPress); } } }; //------------------------------------------------------ // uiMidiCtrlChange does scale (kLin/kLog/kExp) mapping //------------------------------------------------------ class uiMidiCtrlChange : public uiMidiTimedItem, public uiConverter { private: int fCtrl; public: uiMidiCtrlChange(midi* midi_out, int ctrl, GUI* ui, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max, bool input = true, MetaDataUI::Scale scale = MetaDataUI::kLin, int chan = -1) :uiMidiTimedItem(midi_out, ui, zone, input, chan), uiConverter(scale, 0., 127., min, max), fCtrl(ctrl) {} virtual ~uiMidiCtrlChange() {} virtual void reflectZone() { FAUSTFLOAT v = *fZone; fCache = v; fMidiOut->ctrlChange(rangeChan(), fCtrl, fConverter->faust2ui(v)); } void modifyZone(FAUSTFLOAT v) { if (fInputCtrl) { uiItem::modifyZone(FAUSTFLOAT(fConverter->ui2faust(v))); } } void modifyZone(double date, FAUSTFLOAT v) { if (fInputCtrl) { uiMidiTimedItem::modifyZone(date, FAUSTFLOAT(fConverter->ui2faust(v))); } } }; class uiMidiPitchWheel : public uiMidiTimedItem { private: LinearValueConverter2 fConverter; public: uiMidiPitchWheel(midi* midi_out, GUI* ui, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max, bool input = true, int chan = -1) :uiMidiTimedItem(midi_out, ui, zone, input, chan) { if (min <= 0 && max >= 0) { fConverter = LinearValueConverter2(0., 8191., 16383., double(min), 0., double(max)); } else { // Degenerated case... fConverter = LinearValueConverter2(0., 8191., 16383., double(min),double(min + (max - min)/FAUSTFLOAT(2)), double(max)); } } virtual ~uiMidiPitchWheel() {} virtual void reflectZone() { FAUSTFLOAT v = *fZone; fCache = v; fMidiOut->pitchWheel(rangeChan(), fConverter.faust2ui(v)); } void modifyZone(FAUSTFLOAT v) { if (fInputCtrl) { uiItem::modifyZone(FAUSTFLOAT(fConverter.ui2faust(v))); } } void modifyZone(double date, FAUSTFLOAT v) { if (fInputCtrl) { uiMidiTimedItem::modifyZone(FAUSTFLOAT(fConverter.ui2faust(v))); } } void setRange(int val) { double semi = (val / 128) + ((val % 128) / 100.); fConverter.setMappingValues(0., 8191., 16383., -semi, 0., semi); } }; //-------------------------------------------------------------- // uiMidiKeyOn does scale (kLin/kLog/kExp) mapping for velocity //-------------------------------------------------------------- class uiMidiKeyOn : public uiMidiTimedItem, public uiConverter { private: int fKeyOn; public: uiMidiKeyOn(midi* midi_out, int key, GUI* ui, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max, bool input = true, MetaDataUI::Scale scale = MetaDataUI::kLin, int chan = -1) :uiMidiTimedItem(midi_out, ui, zone, input, chan), uiConverter(scale, 0., 127., min, max), fKeyOn(key) {} virtual ~uiMidiKeyOn() {} virtual void reflectZone() { FAUSTFLOAT v = *fZone; fCache = v; fMidiOut->keyOn(rangeChan(), fKeyOn, fConverter->faust2ui(v)); } void modifyZone(FAUSTFLOAT v) { if (fInputCtrl) { uiItem::modifyZone(FAUSTFLOAT(fConverter->ui2faust(v))); } } void modifyZone(double date, FAUSTFLOAT v) { if (fInputCtrl) { uiMidiTimedItem::modifyZone(date, FAUSTFLOAT(fConverter->ui2faust(v))); } } }; //--------------------------------------------------------------- // uiMidiKeyOff does scale (kLin/kLog/kExp) mapping for velocity //--------------------------------------------------------------- class uiMidiKeyOff : public uiMidiTimedItem, public uiConverter { private: int fKeyOff; public: uiMidiKeyOff(midi* midi_out, int key, GUI* ui, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max, bool input = true, MetaDataUI::Scale scale = MetaDataUI::kLin, int chan = -1) :uiMidiTimedItem(midi_out, ui, zone, input, chan), uiConverter(scale, 0., 127., min, max), fKeyOff(key) {} virtual ~uiMidiKeyOff() {} virtual void reflectZone() { FAUSTFLOAT v = *fZone; fCache = v; fMidiOut->keyOff(rangeChan(), fKeyOff, fConverter->faust2ui(v)); } void modifyZone(FAUSTFLOAT v) { if (fInputCtrl) { uiItem::modifyZone(FAUSTFLOAT(fConverter->ui2faust(v))); } } void modifyZone(double date, FAUSTFLOAT v) { if (fInputCtrl) { uiMidiTimedItem::modifyZone(date, FAUSTFLOAT(fConverter->ui2faust(v))); } } }; //----------------------------------------------------------------- // uiMidiKeyPress does scale (kLin/kLog/kExp) mapping for velocity //----------------------------------------------------------------- class uiMidiKeyPress : public uiMidiTimedItem, public uiConverter { private: int fKey; public: uiMidiKeyPress(midi* midi_out, int key, GUI* ui, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max, bool input = true, MetaDataUI::Scale scale = MetaDataUI::kLin, int chan = -1) :uiMidiTimedItem(midi_out, ui, zone, input, chan), uiConverter(scale, 0., 127., min, max), fKey(key) {} virtual ~uiMidiKeyPress() {} virtual void reflectZone() { FAUSTFLOAT v = *fZone; fCache = v; fMidiOut->keyPress(rangeChan(), fKey, fConverter->faust2ui(v)); } void modifyZone(FAUSTFLOAT v) { if (fInputCtrl) { uiItem::modifyZone(FAUSTFLOAT(fConverter->ui2faust(v))); } } void modifyZone(double date, FAUSTFLOAT v) { if (fInputCtrl) { uiMidiTimedItem::modifyZone(date, FAUSTFLOAT(fConverter->ui2faust(v))); } } }; /****************************************************************************************** * MidiUI : Faust User Interface * This class decodes MIDI metadata and maps incoming MIDI messages to them. * Currently ctrl, keyon/keyoff, keypress, pgm, chanpress, pitchwheel/pitchbend * start/stop/clock meta data are handled. * * Maps associating MIDI event ID (like each ctrl number) with all MIDI aware UI items * are defined and progressively filled when decoding MIDI related metadata. * MIDI aware UI items are used in both directions: * - modifying their internal state when receving MIDI input events * - sending their internal state as MIDI output events *******************************************************************************************/ class MidiUI : public GUI, public midi, public MetaDataUI { // Add uiItem subclasses objects are deallocated by the inherited GUI class typedef std::map <int, std::vector<uiMidiCtrlChange*> > TCtrlChangeTable; typedef std::vector<uiMidiProgChange*> TProgChangeTable; typedef std::map <int, std::vector<uiMidiChanPress*> > TChanPressTable; typedef std::map <int, std::vector<uiMidiKeyOn*> > TKeyOnTable; typedef std::map <int, std::vector<uiMidiKeyOff*> > TKeyOffTable; typedef std::map <int, std::vector<uiMidiKeyPress*> > TKeyPressTable; typedef std::vector<uiMidiPitchWheel*> TPitchWheelTable; protected: TCtrlChangeTable fCtrlChangeTable; TProgChangeTable fProgChangeTable; TChanPressTable fChanPressTable; TKeyOnTable fKeyOnTable; TKeyOffTable fKeyOffTable; TKeyOnTable fKeyTable; TKeyPressTable fKeyPressTable; TPitchWheelTable fPitchWheelTable; std::vector<uiMidiStart*> fStartTable; std::vector<uiMidiStop*> fStopTable; std::vector<uiMidiClock*> fClockTable; std::vector<std::pair <std::string, std::string> > fMetaAux; midi_handler* fMidiHandler; bool fDelete; bool fTimeStamp; void addGenericZone(FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max, bool input = true) { if (fMetaAux.size() > 0) { for (size_t i = 0; i < fMetaAux.size(); i++) { unsigned num; unsigned chan; if (fMetaAux[i].first == "midi") { if (gsscanf(fMetaAux[i].second.c_str(), "ctrl %u %u", &num, &chan) == 2) { fCtrlChangeTable[num].push_back(new uiMidiCtrlChange(fMidiHandler, num, this, zone, min, max, input, getScale(zone), chan)); } else if (gsscanf(fMetaAux[i].second.c_str(), "ctrl %u", &num) == 1) { fCtrlChangeTable[num].push_back(new uiMidiCtrlChange(fMidiHandler, num, this, zone, min, max, input, getScale(zone))); } else if (gsscanf(fMetaAux[i].second.c_str(), "keyon %u %u", &num, &chan) == 2) { fKeyOnTable[num].push_back(new uiMidiKeyOn(fMidiHandler, num, this, zone, min, max, input, getScale(zone), chan)); } else if (gsscanf(fMetaAux[i].second.c_str(), "keyon %u", &num) == 1) { fKeyOnTable[num].push_back(new uiMidiKeyOn(fMidiHandler, num, this, zone, min, max, input, getScale(zone))); } else if (gsscanf(fMetaAux[i].second.c_str(), "keyoff %u %u", &num, &chan) == 2) { fKeyOffTable[num].push_back(new uiMidiKeyOff(fMidiHandler, num, this, zone, min, max, input, getScale(zone), chan)); } else if (gsscanf(fMetaAux[i].second.c_str(), "keyoff %u", &num) == 1) { fKeyOffTable[num].push_back(new uiMidiKeyOff(fMidiHandler, num, this, zone, min, max, input, getScale(zone))); } else if (gsscanf(fMetaAux[i].second.c_str(), "key %u %u", &num, &chan) == 2) { fKeyTable[num].push_back(new uiMidiKeyOn(fMidiHandler, num, this, zone, min, max, input, getScale(zone), chan)); } else if (gsscanf(fMetaAux[i].second.c_str(), "key %u", &num) == 1) { fKeyTable[num].push_back(new uiMidiKeyOn(fMidiHandler, num, this, zone, min, max, input, getScale(zone))); } else if (gsscanf(fMetaAux[i].second.c_str(), "keypress %u %u", &num, &chan) == 2) { fKeyPressTable[num].push_back(new uiMidiKeyPress(fMidiHandler, num, this, zone, min, max, input, getScale(zone), chan)); } else if (gsscanf(fMetaAux[i].second.c_str(), "keypress %u", &num) == 1) { fKeyPressTable[num].push_back(new uiMidiKeyPress(fMidiHandler, num, this, zone, min, max, input, getScale(zone))); } else if (gsscanf(fMetaAux[i].second.c_str(), "pgm %u", &chan) == 1) { fProgChangeTable.push_back(new uiMidiProgChange(fMidiHandler, this, zone, min, max, input, chan)); } else if (strcmp(fMetaAux[i].second.c_str(), "pgm") == 0) { fProgChangeTable.push_back(new uiMidiProgChange(fMidiHandler, this, zone, min, max, input)); } else if (gsscanf(fMetaAux[i].second.c_str(), "chanpress %u %u", &num, &chan) == 2) { fChanPressTable[num].push_back(new uiMidiChanPress(fMidiHandler, num, this, zone, input, chan)); } else if (gsscanf(fMetaAux[i].second.c_str(), "chanpress %u", &num) == 1) { fChanPressTable[num].push_back(new uiMidiChanPress(fMidiHandler, num, this, zone, input)); } else if ((gsscanf(fMetaAux[i].second.c_str(), "pitchwheel %u", &chan) == 1) || (gsscanf(fMetaAux[i].second.c_str(), "pitchbend %u", &chan) == 1)) { fPitchWheelTable.push_back(new uiMidiPitchWheel(fMidiHandler, this, zone, min, max, input, chan)); } else if ((fMetaAux[i].second == "pitchwheel") || (fMetaAux[i].second == "pitchbend")) { fPitchWheelTable.push_back(new uiMidiPitchWheel(fMidiHandler, this, zone, min, max, input)); // MIDI sync } else if (fMetaAux[i].second == "start") { fStartTable.push_back(new uiMidiStart(fMidiHandler, this, zone, input)); } else if (fMetaAux[i].second == "stop") { fStopTable.push_back(new uiMidiStop(fMidiHandler, this, zone, input)); } else if (fMetaAux[i].second == "clock") { fClockTable.push_back(new uiMidiClock(fMidiHandler, this, zone, input)); // Explicit metadata to activate 'timestamp' mode } else if (fMetaAux[i].second == "timestamp") { fTimeStamp = true; } } } } fMetaAux.clear(); } template <typename TABLE> void updateTable1(TABLE& table, double date, int channel, int val1) { for (size_t i = 0; i < table.size(); i++) { int channel_aux = table[i]->fChan; if (channel_aux == -1 || channel == channel_aux) { if (fTimeStamp) { table[i]->modifyZone(date, FAUSTFLOAT(val1)); } else { table[i]->modifyZone(FAUSTFLOAT(val1)); } } } } template <typename TABLE> void updateTable2(TABLE& table, double date, int channel, int val1, int val2) { if (table.find(val1) != table.end()) { for (size_t i = 0; i < table[val1].size(); i++) { int channel_aux = table[val1][i]->fChan; if (channel_aux == -1 || channel == channel_aux) { if (fTimeStamp) { table[val1][i]->modifyZone(date, FAUSTFLOAT(val2)); } else { table[val1][i]->modifyZone(FAUSTFLOAT(val2)); } } } } } public: MidiUI(midi_handler* midi_handler, bool delete_handler = false) { fMidiHandler = midi_handler; fMidiHandler->addMidiIn(this); fDelete = delete_handler; fTimeStamp = false; } virtual ~MidiUI() { fMidiHandler->removeMidiIn(this); if (fDelete) delete fMidiHandler; } bool run() { return fMidiHandler->startMidi(); } void stop() { fMidiHandler->stopMidi(); } void addMidiIn(midi* midi_dsp) { fMidiHandler->addMidiIn(midi_dsp); } void removeMidiIn(midi* midi_dsp) { fMidiHandler->removeMidiIn(midi_dsp); } // -- active widgets virtual void addButton(const char* label, FAUSTFLOAT* zone) { addGenericZone(zone, FAUSTFLOAT(0), FAUSTFLOAT(1)); } virtual void addCheckButton(const char* label, FAUSTFLOAT* zone) { addGenericZone(zone, FAUSTFLOAT(0), FAUSTFLOAT(1)); } virtual void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { addGenericZone(zone, min, max); } virtual void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { addGenericZone(zone, min, max); } virtual void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { addGenericZone(zone, min, max); } // -- passive widgets virtual void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { addGenericZone(zone, min, max, false); } virtual void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { addGenericZone(zone, min, max, false); } // -- metadata declarations virtual void declare(FAUSTFLOAT* zone, const char* key, const char* val) { MetaDataUI::declare(zone, key, val); fMetaAux.push_back(std::make_pair(key, val)); } // -- MIDI API void key(double date, int channel, int note, int velocity) { updateTable2<TKeyOnTable>(fKeyTable, date, channel, note, velocity); } MapUI* keyOn(double date, int channel, int note, int velocity) { updateTable2<TKeyOnTable>(fKeyOnTable, date, channel, note, velocity); // If note is in fKeyTable, handle it as a keyOn key(date, channel, note, velocity); return nullptr; } void keyOff(double date, int channel, int note, int velocity) { updateTable2<TKeyOffTable>(fKeyOffTable, date, channel, note, velocity); // If note is in fKeyTable, handle it as a keyOff with a 0 velocity key(date, channel, note, 0); } void ctrlChange(double date, int channel, int ctrl, int value) { updateTable2<TCtrlChangeTable>(fCtrlChangeTable, date, channel, ctrl, value); } void rpn(double date, int channel, int ctrl, int value) { if (ctrl == midi::PITCH_BEND_RANGE) { for (size_t i = 0; i < fPitchWheelTable.size(); i++) { int channel_aux = fPitchWheelTable[i]->fChan; if (channel_aux == -1 || channel == channel_aux) { fPitchWheelTable[i]->setRange(value); } } } } void progChange(double date, int channel, int pgm) { updateTable1<TProgChangeTable>(fProgChangeTable, date, channel, pgm); } void pitchWheel(double date, int channel, int wheel) { updateTable1<TPitchWheelTable>(fPitchWheelTable, date, channel, wheel); } void keyPress(double date, int channel, int pitch, int press) { updateTable2<TKeyPressTable>(fKeyPressTable, date, channel, pitch, press); } void chanPress(double date, int channel, int press) { updateTable2<TChanPressTable>(fChanPressTable, date, channel, press, FAUSTFLOAT(1)); } void ctrlChange14bits(double date, int channel, int ctrl, int value) {} // MIDI sync void startSync(double date) { for (size_t i = 0; i < fStartTable.size(); i++) { fStartTable[i]->modifyZone(date, FAUSTFLOAT(1)); } } void stopSync(double date) { for (size_t i = 0; i < fStopTable.size(); i++) { fStopTable[i]->modifyZone(date, FAUSTFLOAT(0)); } } void clock(double date) { for (size_t i = 0; i < fClockTable.size(); i++) { fClockTable[i]->modifyZone(date, FAUSTFLOAT(1)); } } }; #endif // FAUST_MIDIUI_H /************************** END MidiUI.h **************************/ /************************** BEGIN mspUI.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2018 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ // // mspUI.h for static Max/MSP externals and faustgen~ // // Created by Martin Di Rollo on 18/04/12. // Copyright (c) 2012-2019 Grame. All rights reserved. // #ifndef _mspUI_h #define _mspUI_h #include <math.h> #include <string> #include <map> #define STR_SIZE 512 #define MULTI_SIZE 256 #ifdef WIN32 #include <stdio.h> #define snprintf _snprintf #ifndef NAN static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff}; #define NAN (*(const float *) __nan) #endif #endif using namespace std; struct Max_Meta1 : Meta { int fCount; Max_Meta1():fCount(0) {} void declare(const char* key, const char* value) { if ((strcmp("name", key) == 0) || (strcmp("author", key) == 0)) { fCount++; } } }; struct Max_Meta2 : Meta { void declare(const char* key, const char* value) { if ((strcmp("name", key) == 0) || (strcmp("author", key) == 0)) { post("%s : %s", key, value); } } }; struct Max_Meta3 : Meta { string fName; bool endWith(const string& str, const string& suffix) { size_t i = str.rfind(suffix); return (i != string::npos) && (i == (str.length() - suffix.length())); } void declare(const char* key, const char* value) { if ((strcmp("filename", key) == 0)) { string val = value; if (endWith(value, ".dsp")) { fName = "com.grame." + val.substr(0, val.size() - 4) + "~"; } else { fName = "com.grame." + val + "~"; } } } }; class mspUIObject { protected: string fLabel; FAUSTFLOAT* fZone; FAUSTFLOAT range(FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT val) {return (val < min) ? min : (val > max) ? max : val;} public: mspUIObject(const string& label, FAUSTFLOAT* zone):fLabel(label),fZone(zone) {} virtual ~mspUIObject() {} virtual void setValue(FAUSTFLOAT f) { *fZone = range(0.0, 1.0, f); } virtual FAUSTFLOAT getValue() { return *fZone; } virtual FAUSTFLOAT getInitValue() { return FAUSTFLOAT(0); } virtual FAUSTFLOAT getMinValue() { return FAUSTFLOAT(0); } virtual FAUSTFLOAT getMaxValue() { return FAUSTFLOAT(0); } virtual void toString(char* buffer) {} virtual string getName() { return fLabel; } }; class mspCheckButton : public mspUIObject { public: mspCheckButton(const string& label, FAUSTFLOAT* zone):mspUIObject(label,zone) {} virtual ~mspCheckButton() {} void toString(char* buffer) { snprintf(buffer, STR_SIZE, "CheckButton(float): %s", fLabel.c_str()); } }; class mspButton : public mspUIObject { public: mspButton(const string& label, FAUSTFLOAT* zone):mspUIObject(label,zone) {} virtual ~mspButton() {} void toString(char* buffer) { snprintf(buffer, STR_SIZE, "Button(float): %s", fLabel.c_str()); } }; class mspSlider : public mspUIObject { private: FAUSTFLOAT fInit; FAUSTFLOAT fMin; FAUSTFLOAT fMax; FAUSTFLOAT fStep; public: mspSlider(const string& label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) :mspUIObject(label,zone),fInit(init),fMin(min),fMax(max),fStep(step) {} virtual ~mspSlider() {} void toString(char* buffer) { stringstream str; str << "Slider(float): " << fLabel << " [init=" << fInit << ":min=" << fMin << ":max=" << fMax << ":step=" << fStep << ":cur=" << *fZone << "]"; string res = str.str(); snprintf(buffer, STR_SIZE, "%s", res.c_str()); } void setValue(FAUSTFLOAT f) { *fZone = range(fMin, fMax, f); } virtual FAUSTFLOAT getInitValue() { return fInit; } virtual FAUSTFLOAT getMinValue() { return fMin; } virtual FAUSTFLOAT getMaxValue() { return fMax; } }; class mspBargraph : public mspUIObject { private: FAUSTFLOAT fMin; FAUSTFLOAT fMax; FAUSTFLOAT fCurrent; public: mspBargraph(const string& label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) :mspUIObject(label,zone), fMin(min), fMax(max), fCurrent(*zone) {} virtual ~mspBargraph() {} void toString(char* buffer) { stringstream str; str << "Bargraph(float): " << fLabel << " [min=" << fMin << ":max=" << fMax << ":cur=" << *fZone << "]"; string res = str.str(); snprintf(buffer, STR_SIZE, "%s", res.c_str()); } // special version virtual FAUSTFLOAT getValue(bool& new_val) { if (*fZone != fCurrent) { fCurrent = *fZone; new_val = true; } else { new_val = false; } return fCurrent; } virtual FAUSTFLOAT getMinValue() { return fMin; } virtual FAUSTFLOAT getMaxValue() { return fMax; } }; class mspUI : public UI, public PathBuilder { private: map<string, mspUIObject*> fInputLabelTable; // Input table using labels map<string, mspUIObject*> fInputPathTable; // Input table using paths map<string, mspUIObject*> fOutputLabelTable; // Table containing bargraph with labels map<string, mspUIObject*> fOutputPathTable; // Table containing bargraph with paths map<const char*, const char*> fDeclareTable; FAUSTFLOAT* fMultiTable[MULTI_SIZE]; int fMultiIndex; int fMultiControl; string createLabel(const char* label) { map<const char*, const char*>::reverse_iterator it; if (fDeclareTable.size() > 0) { unsigned int i = 0; string res = string(label); char sep = '['; for (it = fDeclareTable.rbegin(); it != fDeclareTable.rend(); it++, i++) { res = res + sep + (*it).first + ":" + (*it).second; sep = ','; } res += ']'; fDeclareTable.clear(); return res; } else { return string(label); } } void addSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { mspUIObject* obj = new mspSlider(createLabel(label), zone, init, min, max, step); fInputLabelTable[string(label)] = obj; fInputPathTable[buildPath(label)] = obj; fDeclareTable.clear(); } void addBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { mspUIObject* obj = new mspBargraph(createLabel(label), zone, min, max); fOutputLabelTable[string(label)] = obj; fOutputPathTable[buildPath(label)] = obj; fDeclareTable.clear(); } public: typedef map<string, mspUIObject*>::iterator iterator; mspUI() { for (int i = 0; i < MULTI_SIZE; i++) { fMultiTable[i] = 0; } fMultiIndex = fMultiControl = 0; } virtual ~mspUI() { clear(); } void addButton(const char* label, FAUSTFLOAT* zone) { mspUIObject* obj = new mspButton(createLabel(label), zone); fInputLabelTable[string(label)] = obj; fInputPathTable[buildPath(label)] = obj; } void addCheckButton(const char* label, FAUSTFLOAT* zone) { mspUIObject* obj = new mspCheckButton(createLabel(label), zone); fInputLabelTable[string(label)] = obj; fInputPathTable[buildPath(label)] = obj; } void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { addSlider(label, zone, init, min, max, step); } void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { addSlider(label, zone, init, min, max, step); } void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) { addSlider(label, zone, init, min, max, step); } void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { addBargraph(label, zone, min, max); } void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max) { addBargraph(label, zone, min, max); } void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) {} void openTabBox(const char* label) { pushLabel(label); fDeclareTable.clear(); } void openHorizontalBox(const char* label) { pushLabel(label); fDeclareTable.clear(); } void openVerticalBox(const char* label) { pushLabel(label); fDeclareTable.clear(); } void closeBox() { popLabel(); fDeclareTable.clear(); } virtual void declare(FAUSTFLOAT* zone, const char* key, const char* val) { if (strcmp(key, "multi") == 0) { int index = atoi(val); if (index >= 0 && index < MULTI_SIZE) { fMultiTable[index] = zone; fMultiControl++; } else { post("Invalid multi index = %d", index); } } fDeclareTable[key] = val; } void setMultiValues(FAUSTFLOAT* multi, int buffer_size) { for (int read = 0; read < buffer_size; read++) { int write = (fMultiIndex + read) & (MULTI_SIZE - 1); if (fMultiTable[write]) { *fMultiTable[write] = multi[read]; } } fMultiIndex += buffer_size; } bool isMulti() { return fMultiControl > 0; } bool isValue(const string& name) { return (fInputLabelTable.count(name) || fInputPathTable.count(name)); } bool isOutputValue(const string& name) { return fOutputPathTable.count(name); } bool isInputValue(const string& name) { return fInputPathTable.count(name); } bool setValue(const string& name, FAUSTFLOAT val) { if (fInputLabelTable.count(name)) { fInputLabelTable[name]->setValue(val); return true; } else if (fInputPathTable.count(name)) { fInputPathTable[name]->setValue(val); return true; } else { return false; } } FAUSTFLOAT getOutputValue(const string& name, bool& new_val) { return static_cast<mspBargraph*>(fOutputPathTable[name])->getValue(new_val); } iterator begin1() { return fInputLabelTable.begin(); } iterator end1() { return fInputLabelTable.end(); } iterator begin2() { return fInputPathTable.begin(); } iterator end2() { return fInputPathTable.end(); } iterator begin3() { return fOutputLabelTable.begin(); } iterator end3() { return fOutputLabelTable.end(); } iterator begin4() { return fOutputPathTable.begin(); } iterator end4() { return fOutputPathTable.end(); } int inputItemsCount() { return fInputLabelTable.size(); } int outputItemsCount() { return fOutputLabelTable.size(); } void clear() { for (auto& it : fInputLabelTable) { delete it.second; } fInputLabelTable.clear(); fInputPathTable.clear(); for (auto& it : fOutputLabelTable) { delete it.second; } fOutputLabelTable.clear(); fOutputPathTable.clear(); } void displayControls() { post("------- Range and path ----------"); for (auto& it : fInputPathTable) { char param[STR_SIZE]; it.second->toString(param); post(param); string path = "Complete path: " + it.first; post(path.c_str()); } post("---------------------------------"); } static bool checkDigit(const string& name) { for (int i = name.size() - 1; i >= 0; i--) { if (isdigit(name[i])) { return true; } } return false; } static int countDigit(const string& name) { int count = 0; for (int i = name.size() - 1; i >= 0; i--) { if (isdigit(name[i])) { count++; } } return count; } }; #endif /************************** END mspUI.h **************************/ /************************** BEGIN poly-dsp.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __poly_dsp__ #define __poly_dsp__ #include <stdio.h> #include <string> #include <cmath> #include <algorithm> #include <ostream> #include <sstream> #include <vector> #include <limits.h> #include <float.h> #include <assert.h> /************************** BEGIN proxy-dsp.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __proxy_dsp__ #define __proxy_dsp__ #include <vector> #include <map> /************************** BEGIN JSONUIDecoder.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2003-2020 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __JSONUIDecoder__ #define __JSONUIDecoder__ #include <vector> #include <map> #include <utility> #include <cstdlib> #include <sstream> #include <functional> /************************** BEGIN CGlue.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2018 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef CGLUE_H #define CGLUE_H /************************** BEGIN CInterface.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2018 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef CINTERFACE_H #define CINTERFACE_H #ifndef FAUSTFLOAT #define FAUSTFLOAT float #endif #include <stdlib.h> #ifdef __cplusplus extern "C" { #endif struct Soundfile; /******************************************************************************* * UI, Meta and MemoryManager structures for C code. ******************************************************************************/ // -- widget's layouts typedef void (* openTabBoxFun) (void* ui_interface, const char* label); typedef void (* openHorizontalBoxFun) (void* ui_interface, const char* label); typedef void (* openVerticalBoxFun) (void* ui_interface, const char* label); typedef void (* closeBoxFun) (void* ui_interface); // -- active widgets typedef void (* addButtonFun) (void* ui_interface, const char* label, FAUSTFLOAT* zone); typedef void (* addCheckButtonFun) (void* ui_interface, const char* label, FAUSTFLOAT* zone); typedef void (* addVerticalSliderFun) (void* ui_interface, const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step); typedef void (* addHorizontalSliderFun) (void* ui_interface, const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step); typedef void (* addNumEntryFun) (void* ui_interface, const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step); // -- passive widgets typedef void (* addHorizontalBargraphFun) (void* ui_interface, const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max); typedef void (* addVerticalBargraphFun) (void* ui_interface, const char* label, FAUSTFLOAT* zone, FAUSTFLOAT min, FAUSTFLOAT max); // -- soundfiles typedef void (* addSoundfileFun) (void* ui_interface, const char* label, const char* url, struct Soundfile** sf_zone); typedef void (* declareFun) (void* ui_interface, FAUSTFLOAT* zone, const char* key, const char* value); typedef struct { void* uiInterface; openTabBoxFun openTabBox; openHorizontalBoxFun openHorizontalBox; openVerticalBoxFun openVerticalBox; closeBoxFun closeBox; addButtonFun addButton; addCheckButtonFun addCheckButton; addVerticalSliderFun addVerticalSlider; addHorizontalSliderFun addHorizontalSlider; addNumEntryFun addNumEntry; addHorizontalBargraphFun addHorizontalBargraph; addVerticalBargraphFun addVerticalBargraph; addSoundfileFun addSoundfile; declareFun declare; } UIGlue; typedef void (* metaDeclareFun) (void* ui_interface, const char* key, const char* value); typedef struct { void* metaInterface; metaDeclareFun declare; } MetaGlue; /*************************************** * Interface for the DSP object ***************************************/ typedef char dsp_imp; typedef dsp_imp* (* newDspFun) (); typedef void (* destroyDspFun) (dsp_imp* dsp); typedef int (* getNumInputsFun) (dsp_imp* dsp); typedef int (* getNumOutputsFun) (dsp_imp* dsp); typedef void (* buildUserInterfaceFun) (dsp_imp* dsp, UIGlue* ui); typedef int (* getSampleRateFun) (dsp_imp* dsp); typedef void (* initFun) (dsp_imp* dsp, int sample_rate); typedef void (* classInitFun) (int sample_rate); typedef void (* instanceInitFun) (dsp_imp* dsp, int sample_rate); typedef void (* instanceConstantsFun) (dsp_imp* dsp, int sample_rate); typedef void (* instanceResetUserInterfaceFun) (dsp_imp* dsp); typedef void (* instanceClearFun) (dsp_imp* dsp); typedef void (* computeFun) (dsp_imp* dsp, int len, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs); typedef void (* metadataFun) (MetaGlue* meta); /*************************************** * DSP memory manager functions ***************************************/ typedef void* (* allocateFun) (void* manager_interface, size_t size); typedef void (* destroyFun) (void* manager_interface, void* ptr); typedef struct { void* managerInterface; allocateFun allocate; destroyFun destroy; } MemoryManagerGlue; #ifdef __cplusplus } #endif #endif /************************** END CInterface.h **************************/ #ifdef __cplusplus extern "C" { #endif /******************************************************************************* * UI glue code ******************************************************************************/ class UIFloat { public: UIFloat() {} virtual ~UIFloat() {} // -- widget's layouts virtual void openTabBox(const char* label) = 0; virtual void openHorizontalBox(const char* label) = 0; virtual void openVerticalBox(const char* label) = 0; virtual void closeBox() = 0; // -- active widgets virtual void addButton(const char* label, float* zone) = 0; virtual void addCheckButton(const char* label, float* zone) = 0; virtual void addVerticalSlider(const char* label, float* zone, float init, float min, float max, float step) = 0; virtual void addHorizontalSlider(const char* label, float* zone, float init, float min, float max, float step) = 0; virtual void addNumEntry(const char* label, float* zone, float init, float min, float max, float step) = 0; // -- passive widgets virtual void addHorizontalBargraph(const char* label, float* zone, float min, float max) = 0; virtual void addVerticalBargraph(const char* label, float* zone, float min, float max) = 0; // -- soundfiles virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) = 0; // -- metadata declarations virtual void declare(float* zone, const char* key, const char* val) {} }; static void openTabBoxGlueFloat(void* cpp_interface, const char* label) { UIFloat* ui_interface = static_cast<UIFloat*>(cpp_interface); ui_interface->openTabBox(label); } static void openHorizontalBoxGlueFloat(void* cpp_interface, const char* label) { UIFloat* ui_interface = static_cast<UIFloat*>(cpp_interface); ui_interface->openHorizontalBox(label); } static void openVerticalBoxGlueFloat(void* cpp_interface, const char* label) { UIFloat* ui_interface = static_cast<UIFloat*>(cpp_interface); ui_interface->openVerticalBox(label); } static void closeBoxGlueFloat(void* cpp_interface) { UIFloat* ui_interface = static_cast<UIFloat*>(cpp_interface); ui_interface->closeBox(); } static void addButtonGlueFloat(void* cpp_interface, const char* label, float* zone) { UIFloat* ui_interface = static_cast<UIFloat*>(cpp_interface); ui_interface->addButton(label, zone); } static void addCheckButtonGlueFloat(void* cpp_interface, const char* label, float* zone) { UIFloat* ui_interface = static_cast<UIFloat*>(cpp_interface); ui_interface->addCheckButton(label, zone); } static void addVerticalSliderGlueFloat(void* cpp_interface, const char* label, float* zone, float init, float min, float max, float step) { UIFloat* ui_interface = static_cast<UIFloat*>(cpp_interface); ui_interface->addVerticalSlider(label, zone, init, min, max, step); } static void addHorizontalSliderGlueFloat(void* cpp_interface, const char* label, float* zone, float init, float min, float max, float step) { UIFloat* ui_interface = static_cast<UIFloat*>(cpp_interface); ui_interface->addHorizontalSlider(label, zone, init, min, max, step); } static void addNumEntryGlueFloat(void* cpp_interface, const char* label, float* zone, float init, float min, float max, float step) { UIFloat* ui_interface = static_cast<UIFloat*>(cpp_interface); ui_interface->addNumEntry(label, zone, init, min, max, step); } static void addHorizontalBargraphGlueFloat(void* cpp_interface, const char* label, float* zone, float min, float max) { UIFloat* ui_interface = static_cast<UIFloat*>(cpp_interface); ui_interface->addHorizontalBargraph(label, zone, min, max); } static void addVerticalBargraphGlueFloat(void* cpp_interface, const char* label, float* zone, float min, float max) { UIFloat* ui_interface = static_cast<UIFloat*>(cpp_interface); ui_interface->addVerticalBargraph(label, zone, min, max); } static void addSoundfileGlueFloat(void* cpp_interface, const char* label, const char* url, Soundfile** sf_zone) { UIFloat* ui_interface = static_cast<UIFloat*>(cpp_interface); ui_interface->addSoundfile(label, url, sf_zone); } static void declareGlueFloat(void* cpp_interface, float* zone, const char* key, const char* value) { UIFloat* ui_interface = static_cast<UIFloat*>(cpp_interface); ui_interface->declare(zone, key, value); } class UIDouble { public: UIDouble() {} virtual ~UIDouble() {} // -- widget's layouts virtual void openTabBox(const char* label) = 0; virtual void openHorizontalBox(const char* label) = 0; virtual void openVerticalBox(const char* label) = 0; virtual void closeBox() = 0; // -- active widgets virtual void addButton(const char* label, double* zone) = 0; virtual void addCheckButton(const char* label, double* zone) = 0; virtual void addVerticalSlider(const char* label, double* zone, double init, double min, double max, double step) = 0; virtual void addHorizontalSlider(const char* label, double* zone, double init, double min, double max, double step) = 0; virtual void addNumEntry(const char* label, double* zone, double init, double min, double max, double step) = 0; // -- passive widgets virtual void addHorizontalBargraph(const char* label, double* zone, double min, double max) = 0; virtual void addVerticalBargraph(const char* label, double* zone, double min, double max) = 0; // -- soundfiles virtual void addSoundfile(const char* label, const char* filename, Soundfile** sf_zone) = 0; // -- metadata declarations virtual void declare(double* zone, const char* key, const char* val) {} }; static void openTabBoxGlueDouble(void* cpp_interface, const char* label) { UIDouble* ui_interface = static_cast<UIDouble*>(cpp_interface); ui_interface->openTabBox(label); } static void openHorizontalBoxGlueDouble(void* cpp_interface, const char* label) { UIDouble* ui_interface = static_cast<UIDouble*>(cpp_interface); ui_interface->openHorizontalBox(label); } static void openVerticalBoxGlueDouble(void* cpp_interface, const char* label) { UIDouble* ui_interface = static_cast<UIDouble*>(cpp_interface); ui_interface->openVerticalBox(label); } static void closeBoxGlueDouble(void* cpp_interface) { UIDouble* ui_interface = static_cast<UIDouble*>(cpp_interface); ui_interface->closeBox(); } static void addButtonGlueDouble(void* cpp_interface, const char* label, double* zone) { UIDouble* ui_interface = static_cast<UIDouble*>(cpp_interface); ui_interface->addButton(label, zone); } static void addCheckButtonGlueDouble(void* cpp_interface, const char* label, double* zone) { UIDouble* ui_interface = static_cast<UIDouble*>(cpp_interface); ui_interface->addCheckButton(label, zone); } static void addVerticalSliderGlueDouble(void* cpp_interface, const char* label, double* zone, double init, double min, double max, double step) { UIDouble* ui_interface = static_cast<UIDouble*>(cpp_interface); ui_interface->addVerticalSlider(label, zone, init, min, max, step); } static void addHorizontalSliderGlueDouble(void* cpp_interface, const char* label, double* zone, double init, double min, double max, double step) { UIDouble* ui_interface = static_cast<UIDouble*>(cpp_interface); ui_interface->addHorizontalSlider(label, zone, init, min, max, step); } static void addNumEntryGlueDouble(void* cpp_interface, const char* label, double* zone, double init, double min, double max, double step) { UIDouble* ui_interface = static_cast<UIDouble*>(cpp_interface); ui_interface->addNumEntry(label, zone, init, min, max, step); } static void addHorizontalBargraphGlueDouble(void* cpp_interface, const char* label, double* zone, double min, double max) { UIDouble* ui_interface = static_cast<UIDouble*>(cpp_interface); ui_interface->addHorizontalBargraph(label, zone, min, max); } static void addVerticalBargraphGlueDouble(void* cpp_interface, const char* label, double* zone, double min, double max) { UIDouble* ui_interface = static_cast<UIDouble*>(cpp_interface); ui_interface->addVerticalBargraph(label, zone, min, max); } static void addSoundfileGlueDouble(void* cpp_interface, const char* label, const char* url, Soundfile** sf_zone) { UIDouble* ui_interface = static_cast<UIDouble*>(cpp_interface); ui_interface->addSoundfile(label, url, sf_zone); } static void declareGlueDouble(void* cpp_interface, double* zone, const char* key, const char* value) { UIDouble* ui_interface = static_cast<UIDouble*>(cpp_interface); ui_interface->declare(zone, key, value); } static void buildUIGlue(UIGlue* glue, UI* ui_interface, bool is_double) { glue->uiInterface = ui_interface; if (is_double) { glue->openTabBox = reinterpret_cast<openTabBoxFun>(openTabBoxGlueDouble); glue->openHorizontalBox = reinterpret_cast<openHorizontalBoxFun>(openHorizontalBoxGlueDouble); glue->openVerticalBox = reinterpret_cast<openVerticalBoxFun>(openVerticalBoxGlueDouble); glue->closeBox = reinterpret_cast<closeBoxFun>(closeBoxGlueDouble); glue->addButton = reinterpret_cast<addButtonFun>(addButtonGlueDouble); glue->addCheckButton = reinterpret_cast<addCheckButtonFun>(addCheckButtonGlueDouble); glue->addVerticalSlider = reinterpret_cast<addVerticalSliderFun>(addVerticalSliderGlueDouble); glue->addHorizontalSlider = reinterpret_cast<addHorizontalSliderFun>(addHorizontalSliderGlueDouble); glue->addNumEntry = reinterpret_cast<addNumEntryFun>(addNumEntryGlueDouble); glue->addHorizontalBargraph = reinterpret_cast<addHorizontalBargraphFun>(addHorizontalBargraphGlueDouble); glue->addVerticalBargraph = reinterpret_cast<addVerticalBargraphFun>(addVerticalBargraphGlueDouble); glue->addSoundfile = reinterpret_cast<addSoundfileFun>(addSoundfileGlueDouble); glue->declare = reinterpret_cast<declareFun>(declareGlueDouble); } else { glue->openTabBox = reinterpret_cast<openTabBoxFun>(openTabBoxGlueFloat); glue->openHorizontalBox = reinterpret_cast<openHorizontalBoxFun>(openHorizontalBoxGlueFloat); glue->openVerticalBox = reinterpret_cast<openVerticalBoxFun>(openVerticalBoxGlueFloat); glue->closeBox = reinterpret_cast<closeBoxFun>(closeBoxGlueFloat); glue->addButton = reinterpret_cast<addButtonFun>(addButtonGlueFloat); glue->addCheckButton = reinterpret_cast<addCheckButtonFun>(addCheckButtonGlueFloat); glue->addVerticalSlider = reinterpret_cast<addVerticalSliderFun>(addVerticalSliderGlueFloat); glue->addHorizontalSlider = reinterpret_cast<addHorizontalSliderFun>(addHorizontalSliderGlueFloat); glue->addNumEntry = reinterpret_cast<addNumEntryFun>(addNumEntryGlueFloat); glue->addHorizontalBargraph = reinterpret_cast<addHorizontalBargraphFun>(addHorizontalBargraphGlueFloat); glue->addVerticalBargraph = reinterpret_cast<addVerticalBargraphFun>(addVerticalBargraphGlueFloat); glue->addSoundfile = reinterpret_cast<addSoundfileFun>(addSoundfileGlueFloat); glue->declare = reinterpret_cast<declareFun>(declareGlueFloat); } } class UITemplate { private: void* fCPPInterface; public: UITemplate(void* cpp_interface):fCPPInterface(cpp_interface) {} virtual ~UITemplate() {} // -- widget's layouts virtual void openTabBox(const char* label) { openTabBoxGlueFloat(fCPPInterface, label); } virtual void openHorizontalBox(const char* label) { openHorizontalBoxGlueFloat(fCPPInterface, label); } virtual void openVerticalBox(const char* label) { openVerticalBoxGlueFloat(fCPPInterface, label); } virtual void closeBox() { closeBoxGlueFloat(fCPPInterface); } // float version // -- active widgets virtual void addButton(const char* label, float* zone) { addButtonGlueFloat(fCPPInterface, label, zone); } virtual void addCheckButton(const char* label, float* zone) { addCheckButtonGlueFloat(fCPPInterface, label, zone); } virtual void addVerticalSlider(const char* label, float* zone, float init, float min, float max, float step) { addVerticalSliderGlueFloat(fCPPInterface, label, zone, init, min, max, step); } virtual void addHorizontalSlider(const char* label, float* zone, float init, float min, float max, float step) { addHorizontalSliderGlueFloat(fCPPInterface, label, zone, init, min, max, step); } virtual void addNumEntry(const char* label, float* zone, float init, float min, float max, float step) { addNumEntryGlueFloat(fCPPInterface, label, zone, init, min, max, step); } // -- passive widgets virtual void addHorizontalBargraph(const char* label, float* zone, float min, float max) { addHorizontalBargraphGlueFloat(fCPPInterface, label, zone, min, max); } virtual void addVerticalBargraph(const char* label, float* zone, float min, float max) { addVerticalBargraphGlueFloat(fCPPInterface, label, zone, min, max); } // -- metadata declarations virtual void declare(float* zone, const char* key, const char* val) { declareGlueFloat(fCPPInterface, zone, key, val); } // double version virtual void addButton(const char* label, double* zone) { addButtonGlueDouble(fCPPInterface, label, zone); } virtual void addCheckButton(const char* label, double* zone) { addCheckButtonGlueDouble(fCPPInterface, label, zone); } virtual void addVerticalSlider(const char* label, double* zone, double init, double min, double max, double step) { addVerticalSliderGlueDouble(fCPPInterface, label, zone, init, min, max, step); } virtual void addHorizontalSlider(const char* label, double* zone, double init, double min, double max, double step) { addHorizontalSliderGlueDouble(fCPPInterface, label, zone, init, min, max, step); } virtual void addNumEntry(const char* label, double* zone, double init, double min, double max, double step) { addNumEntryGlueDouble(fCPPInterface, label, zone, init, min, max, step); } // -- soundfiles virtual void addSoundfile(const char* label, const char* url, Soundfile** sf_zone) { addSoundfileGlueFloat(fCPPInterface, label, url, sf_zone); } // -- passive widgets virtual void addHorizontalBargraph(const char* label, double* zone, double min, double max) { addHorizontalBargraphGlueDouble(fCPPInterface, label, zone, min, max); } virtual void addVerticalBargraph(const char* label, double* zone, double min, double max) { addVerticalBargraphGlueDouble(fCPPInterface, label, zone, min, max); } // -- metadata declarations virtual void declare(double* zone, const char* key, const char* val) { declareGlueDouble(fCPPInterface, zone, key, val); } }; /******************************************************************************* * Meta glue code ******************************************************************************/ static void declareMetaGlue(void* cpp_interface, const char* key, const char* value) { Meta* meta_interface = static_cast<Meta*>(cpp_interface); meta_interface->declare(key, value); } static void buildMetaGlue(MetaGlue* glue, Meta* meta) { glue->metaInterface = meta; glue->declare = declareMetaGlue; } /******************************************************************************* * Memory manager glue code ******************************************************************************/ static void* allocateMemoryManagerGlue(void* cpp_interface, size_t size) { dsp_memory_manager* manager_interface = static_cast<dsp_memory_manager*>(cpp_interface); return manager_interface->allocate(size); } static void destroyMemoryManagerGlue(void* cpp_interface, void* ptr) { dsp_memory_manager* manager_interface = static_cast<dsp_memory_manager*>(cpp_interface); manager_interface->destroy(ptr); } static void buildManagerGlue(MemoryManagerGlue* glue, dsp_memory_manager* manager) { glue->managerInterface = manager; glue->allocate = allocateMemoryManagerGlue; glue->destroy = destroyMemoryManagerGlue; } #ifdef __cplusplus } #endif #endif /************************** END CGlue.h **************************/ #ifdef _WIN32 #include <windows.h> #define snprintf _snprintf #endif //------------------------------------------------------------------- // Decode a dsp JSON description and implement 'buildUserInterface' //------------------------------------------------------------------- #define REAL_UI(ui_interface) reinterpret_cast<UIReal<REAL>*>(ui_interface) #define REAL_ADR(offset) reinterpret_cast<REAL*>(&memory_block[offset]) #define REAL_EXT_ADR(offset) reinterpret_cast<FAUSTFLOAT*>(&memory_block[offset]) #define SOUNDFILE_ADR(offset) reinterpret_cast<Soundfile**>(&memory_block[offset]) typedef std::function<void(double)> ReflectFunction; typedef std::function<double()> ModifyFunction; struct ExtZoneParam { virtual void reflectZone() = 0; virtual void modifyZone() = 0; virtual void setReflectZoneFun(ReflectFunction reflect) = 0; virtual void setModifyZoneFun(ModifyFunction modify) = 0; virtual ~ExtZoneParam() {} }; template <typename REAL> struct JSONUIDecoderReal { struct ZoneParam : public ExtZoneParam { REAL fZone; int fIndex; ReflectFunction fReflect; ModifyFunction fModify; #if defined(TARGET_OS_IPHONE) || defined(WIN32) ZoneParam(int index, ReflectFunction reflect = nullptr, ModifyFunction modify = nullptr) :fIndex(index), fReflect(reflect), fModify(modify) {} void reflectZone() { if (fReflect) fReflect(fZone); } void modifyZone() { if (fModify) fZone = fModify(); } #else ZoneParam(int index, ReflectFunction reflect = [](REAL value) {}, ModifyFunction modify = []() { return REAL(-1); }) :fIndex(index), fReflect(reflect), fModify(modify) {} void reflectZone() { fReflect(fZone); } void modifyZone() { fZone = fModify(); } #endif void setReflectZoneFun(ReflectFunction reflect) { fReflect = reflect; } void setModifyZoneFun(ModifyFunction modify) { fModify = modify; } }; typedef std::vector<ExtZoneParam*> controlMap; std::string fName; std::string fFileName; std::string fJSON; std::string fVersion; std::string fCompileOptions; std::map<std::string, std::string> fMetadata; std::vector<itemInfo> fUiItems; std::vector<std::string> fLibraryList; std::vector<std::string> fIncludePathnames; Soundfile** fSoundfiles; int fNumInputs, fNumOutputs, fSRIndex; int fSoundfileItems; int fDSPSize; controlMap fPathInputTable; // [path, ZoneParam] controlMap fPathOutputTable; // [path, ZoneParam] bool isInput(const std::string& type) { return (type == "vslider" || type == "hslider" || type == "nentry" || type == "button" || type == "checkbox"); } bool isOutput(const std::string& type) { return (type == "hbargraph" || type == "vbargraph"); } bool isSoundfile(const std::string& type) { return (type == "soundfile"); } std::string getString(std::map<std::string, std::pair<std::string, double> >& map, const std::string& key) { return (map.find(key) != map.end()) ? map[key].first : ""; } int getInt(std::map<std::string, std::pair<std::string, double> >& map, const std::string& key) { return (map.find(key) != map.end()) ? int(map[key].second) : -1; } void setReflectZoneFun(int index, ReflectFunction fun) { fPathInputTable[index]->setReflectZoneFun(fun); } void setModifyZoneFun(int index, ModifyFunction fun) { fPathOutputTable[index]->setModifyZoneFun(fun); } JSONUIDecoderReal(const std::string& json) { fJSON = json; const char* p = fJSON.c_str(); std::map<std::string, std::pair<std::string, double> > meta_data1; std::map<std::string, std::vector<std::string> > meta_data2; parseJson(p, meta_data1, fMetadata, meta_data2, fUiItems); // meta_data1 contains <name : val>, <inputs : val>, <ouputs : val> pairs etc... fName = getString(meta_data1, "name"); fFileName = getString(meta_data1, "filename"); fVersion = getString(meta_data1, "version"); fCompileOptions = getString(meta_data1, "compile_options"); if (meta_data2.find("library_list") != meta_data2.end()) { fLibraryList = meta_data2["library_list"]; } if (meta_data2.find("include_pathnames") != meta_data2.end()) { fIncludePathnames = meta_data2["include_pathnames"]; } fDSPSize = getInt(meta_data1, "size"); fNumInputs = getInt(meta_data1, "inputs"); fNumOutputs = getInt(meta_data1, "outputs"); fSRIndex = getInt(meta_data1, "sr_index"); fSoundfileItems = 0; for (auto& it : fUiItems) { std::string type = it.type; if (isSoundfile(type)) { fSoundfileItems++; } } fSoundfiles = new Soundfile*[fSoundfileItems]; // Prepare the fPathTable and init zone for (auto& it : fUiItems) { std::string type = it.type; // Meta data declaration for input items if (isInput(type)) { ZoneParam* param = new ZoneParam(it.index); fPathInputTable.push_back(param); param->fZone = it.init; } // Meta data declaration for output items else if (isOutput(type)) { ZoneParam* param = new ZoneParam(it.index); fPathOutputTable.push_back(param); param->fZone = REAL(0); } } } virtual ~JSONUIDecoderReal() { delete [] fSoundfiles; for (auto& it : fPathInputTable) { delete it; } for (auto& it : fPathOutputTable) { delete it; } } void metadata(Meta* m) { for (auto& it : fMetadata) { m->declare(it.first.c_str(), it.second.c_str()); } } void metadata(MetaGlue* m) { for (auto& it : fMetadata) { m->declare(m->metaInterface, it.first.c_str(), it.second.c_str()); } } void resetUserInterface() { int item = 0; for (auto& it : fUiItems) { if (isInput(it.type)) { static_cast<ZoneParam*>(fPathInputTable[item++])->fZone = it.init; } } } void resetUserInterface(char* memory_block, Soundfile* defaultsound = nullptr) { for (auto& it : fUiItems) { int offset = it.index; if (isInput(it.type)) { *REAL_ADR(offset) = it.init; } else if (isSoundfile(it.type)) { if (*SOUNDFILE_ADR(offset) == nullptr) { *SOUNDFILE_ADR(offset) = defaultsound; } } } } int getSampleRate(char* memory_block) { return *reinterpret_cast<int*>(&memory_block[fSRIndex]); } void buildUserInterface(UI* ui_interface) { // MANDATORY: to be sure floats or double are correctly parsed char* tmp_local = setlocale(LC_ALL, nullptr); if (tmp_local != NULL) { tmp_local = strdup(tmp_local); } setlocale(LC_ALL, "C"); int countIn = 0; int countOut = 0; int countSound = 0; for (auto& it : fUiItems) { std::string type = it.type; REAL init = REAL(it.init); REAL min = REAL(it.min); REAL max = REAL(it.max); REAL step = REAL(it.step); // Meta data declaration for input items if (isInput(type)) { for (size_t i = 0; i < it.meta.size(); i++) { REAL_UI(ui_interface)->declare(&static_cast<ZoneParam*>(fPathInputTable[countIn])->fZone, it.meta[i].first.c_str(), it.meta[i].second.c_str()); } } // Meta data declaration for output items else if (isOutput(type)) { for (size_t i = 0; i < it.meta.size(); i++) { REAL_UI(ui_interface)->declare(&static_cast<ZoneParam*>(fPathOutputTable[countOut])->fZone, it.meta[i].first.c_str(), it.meta[i].second.c_str()); } } // Meta data declaration for group opening or closing else { for (size_t i = 0; i < it.meta.size(); i++) { REAL_UI(ui_interface)->declare(0, it.meta[i].first.c_str(), it.meta[i].second.c_str()); } } if (type == "hgroup") { REAL_UI(ui_interface)->openHorizontalBox(it.label.c_str()); } else if (type == "vgroup") { REAL_UI(ui_interface)->openVerticalBox(it.label.c_str()); } else if (type == "tgroup") { REAL_UI(ui_interface)->openTabBox(it.label.c_str()); } else if (type == "vslider") { REAL_UI(ui_interface)->addVerticalSlider(it.label.c_str(), &static_cast<ZoneParam*>(fPathInputTable[countIn])->fZone, init, min, max, step); } else if (type == "hslider") { REAL_UI(ui_interface)->addHorizontalSlider(it.label.c_str(), &static_cast<ZoneParam*>(fPathInputTable[countIn])->fZone, init, min, max, step); } else if (type == "checkbox") { REAL_UI(ui_interface)->addCheckButton(it.label.c_str(), &static_cast<ZoneParam*>(fPathInputTable[countIn])->fZone); } else if (type == "soundfile") { REAL_UI(ui_interface)->addSoundfile(it.label.c_str(), it.url.c_str(), &fSoundfiles[countSound]); } else if (type == "hbargraph") { REAL_UI(ui_interface)->addHorizontalBargraph(it.label.c_str(), &static_cast<ZoneParam*>(fPathOutputTable[countOut])->fZone, min, max); } else if (type == "vbargraph") { REAL_UI(ui_interface)->addVerticalBargraph(it.label.c_str(), &static_cast<ZoneParam*>(fPathOutputTable[countOut])->fZone, min, max); } else if (type == "nentry") { REAL_UI(ui_interface)->addNumEntry(it.label.c_str(), &static_cast<ZoneParam*>(fPathInputTable[countIn])->fZone, init, min, max, step); } else if (type == "button") { REAL_UI(ui_interface)->addButton(it.label.c_str(), &static_cast<ZoneParam*>(fPathInputTable[countIn])->fZone); } else if (type == "close") { REAL_UI(ui_interface)->closeBox(); } if (isInput(type)) { countIn++; } else if (isOutput(type)) { countOut++; } else if (isSoundfile(type)) { countSound++; } } if (tmp_local != NULL) { setlocale(LC_ALL, tmp_local); free(tmp_local); } } void buildUserInterface(UI* ui_interface, char* memory_block) { // MANDATORY: to be sure floats or double are correctly parsed char* tmp_local = setlocale(LC_ALL, nullptr); if (tmp_local != NULL) { tmp_local = strdup(tmp_local); } setlocale(LC_ALL, "C"); for (auto& it : fUiItems) { std::string type = it.type; int offset = it.index; REAL init = REAL(it.init); REAL min = REAL(it.min); REAL max = REAL(it.max); REAL step = REAL(it.step); // Meta data declaration for input items if (isInput(type)) { for (size_t i = 0; i < it.meta.size(); i++) { REAL_UI(ui_interface)->declare(REAL_ADR(offset), it.meta[i].first.c_str(), it.meta[i].second.c_str()); } } // Meta data declaration for output items else if (isOutput(type)) { for (size_t i = 0; i < it.meta.size(); i++) { REAL_UI(ui_interface)->declare(REAL_ADR(offset), it.meta[i].first.c_str(), it.meta[i].second.c_str()); } } // Meta data declaration for group opening or closing else { for (size_t i = 0; i < it.meta.size(); i++) { REAL_UI(ui_interface)->declare(0, it.meta[i].first.c_str(), it.meta[i].second.c_str()); } } if (type == "hgroup") { REAL_UI(ui_interface)->openHorizontalBox(it.label.c_str()); } else if (type == "vgroup") { REAL_UI(ui_interface)->openVerticalBox(it.label.c_str()); } else if (type == "tgroup") { REAL_UI(ui_interface)->openTabBox(it.label.c_str()); } else if (type == "vslider") { REAL_UI(ui_interface)->addVerticalSlider(it.label.c_str(), REAL_ADR(offset), init, min, max, step); } else if (type == "hslider") { REAL_UI(ui_interface)->addHorizontalSlider(it.label.c_str(), REAL_ADR(offset), init, min, max, step); } else if (type == "checkbox") { REAL_UI(ui_interface)->addCheckButton(it.label.c_str(), REAL_ADR(offset)); } else if (type == "soundfile") { REAL_UI(ui_interface)->addSoundfile(it.label.c_str(), it.url.c_str(), SOUNDFILE_ADR(offset)); } else if (type == "hbargraph") { REAL_UI(ui_interface)->addHorizontalBargraph(it.label.c_str(), REAL_ADR(offset), min, max); } else if (type == "vbargraph") { REAL_UI(ui_interface)->addVerticalBargraph(it.label.c_str(), REAL_ADR(offset), min, max); } else if (type == "nentry") { REAL_UI(ui_interface)->addNumEntry(it.label.c_str(), REAL_ADR(offset), init, min, max, step); } else if (type == "button") { REAL_UI(ui_interface)->addButton(it.label.c_str(), REAL_ADR(offset)); } else if (type == "close") { REAL_UI(ui_interface)->closeBox(); } } if (tmp_local != NULL) { setlocale(LC_ALL, tmp_local); free(tmp_local); } } void buildUserInterface(UIGlue* ui_interface, char* memory_block) { // MANDATORY: to be sure floats or double are correctly parsed char* tmp_local = setlocale(LC_ALL, nullptr); if (tmp_local != NULL) { tmp_local = strdup(tmp_local); } setlocale(LC_ALL, "C"); for (auto& it : fUiItems) { std::string type = it.type; int offset = it.index; REAL init = REAL(it.init); REAL min = REAL(it.min); REAL max = REAL(it.max); REAL step = REAL(it.step); // Meta data declaration for input items if (isInput(type)) { for (size_t i = 0; i < it.meta.size(); i++) { ui_interface->declare(ui_interface->uiInterface, REAL_EXT_ADR(offset), it.meta[i].first.c_str(), it.meta[i].second.c_str()); } } // Meta data declaration for output items else if (isOutput(type)) { for (size_t i = 0; i < it.meta.size(); i++) { ui_interface->declare(ui_interface->uiInterface, REAL_EXT_ADR(offset), it.meta[i].first.c_str(), it.meta[i].second.c_str()); } } // Meta data declaration for group opening or closing else { for (size_t i = 0; i < it.meta.size(); i++) { ui_interface->declare(ui_interface->uiInterface, 0, it.meta[i].first.c_str(), it.meta[i].second.c_str()); } } if (type == "hgroup") { ui_interface->openHorizontalBox(ui_interface->uiInterface, it.label.c_str()); } else if (type == "vgroup") { ui_interface->openVerticalBox(ui_interface->uiInterface, it.label.c_str()); } else if (type == "tgroup") { ui_interface->openTabBox(ui_interface->uiInterface, it.label.c_str()); } else if (type == "vslider") { ui_interface->addVerticalSlider(ui_interface->uiInterface, it.label.c_str(), REAL_EXT_ADR(offset), init, min, max, step); } else if (type == "hslider") { ui_interface->addHorizontalSlider(ui_interface->uiInterface, it.label.c_str(), REAL_EXT_ADR(offset), init, min, max, step); } else if (type == "checkbox") { ui_interface->addCheckButton(ui_interface->uiInterface, it.label.c_str(), REAL_EXT_ADR(offset)); } else if (type == "soundfile") { ui_interface->addSoundfile(ui_interface->uiInterface, it.label.c_str(), it.url.c_str(), SOUNDFILE_ADR(offset)); } else if (type == "hbargraph") { ui_interface->addHorizontalBargraph(ui_interface->uiInterface, it.label.c_str(), REAL_EXT_ADR(offset), min, max); } else if (type == "vbargraph") { ui_interface->addVerticalBargraph(ui_interface->uiInterface, it.label.c_str(), REAL_EXT_ADR(offset), min, max); } else if (type == "nentry") { ui_interface->addNumEntry(ui_interface->uiInterface, it.label.c_str(), REAL_EXT_ADR(offset), init, min, max, step); } else if (type == "button") { ui_interface->addButton(ui_interface->uiInterface, it.label.c_str(), REAL_EXT_ADR(offset)); } else if (type == "close") { ui_interface->closeBox(ui_interface->uiInterface); } } if (tmp_local != NULL) { setlocale(LC_ALL, tmp_local); free(tmp_local); } } bool hasCompileOption(const std::string& option) { std::istringstream iss(fCompileOptions); std::string token; while (std::getline(iss, token, ' ')) { if (token == option) return true; } return false; } }; // Templated decoder struct JSONUITemplatedDecoder { virtual ~JSONUITemplatedDecoder() {} virtual void metadata(Meta* m) = 0; virtual void metadata(MetaGlue* glue) = 0; virtual int getDSPSize() = 0; virtual std::string getName() = 0; virtual std::string getLibVersion() = 0; virtual std::string getCompileOptions() = 0; virtual std::vector<std::string> getLibraryList() = 0; virtual std::vector<std::string> getIncludePathnames() = 0; virtual int getNumInputs() = 0; virtual int getNumOutputs() = 0; virtual int getSampleRate(char* memory_block) = 0; virtual void setReflectZoneFun(int index, ReflectFunction fun) = 0; virtual void setModifyZoneFun(int index, ModifyFunction fun) = 0; virtual std::vector<ExtZoneParam*>& getInputControls() = 0; virtual std::vector<ExtZoneParam*>& getOutputControls() = 0; virtual void resetUserInterface(char* memory_block, Soundfile* defaultsound = nullptr) = 0; virtual void buildUserInterface(UI* ui_interface) = 0; virtual void buildUserInterface(UI* ui_interface, char* memory_block) = 0; virtual void buildUserInterface(UIGlue* ui_interface, char* memory_block) = 0; virtual bool hasCompileOption(const std::string& option) = 0; }; // Float templated decoder struct JSONUIFloatDecoder : public JSONUIDecoderReal<float>, public JSONUITemplatedDecoder { JSONUIFloatDecoder(const std::string& json):JSONUIDecoderReal<float>(json) {} void metadata(Meta* m) { JSONUIDecoderReal<float>::metadata(m); } void metadata(MetaGlue* glue) { JSONUIDecoderReal<float>::metadata(glue); } int getDSPSize() { return fDSPSize; } std::string getName() { return fName; } std::string getLibVersion() { return fVersion; } std::string getCompileOptions() { return fCompileOptions; } std::vector<std::string> getLibraryList() { return fLibraryList; } std::vector<std::string> getIncludePathnames() { return fIncludePathnames; } int getNumInputs() { return fNumInputs; } int getNumOutputs() { return fNumOutputs; } int getSampleRate(char* memory_block) { return JSONUIDecoderReal<float>::getSampleRate(memory_block); } void setReflectZoneFun(int index, ReflectFunction fun) { JSONUIDecoderReal<float>::setReflectZoneFun(index, fun); } void setModifyZoneFun(int index, ModifyFunction fun) { JSONUIDecoderReal<float>::setModifyZoneFun(index, fun); } std::vector<ExtZoneParam*>& getInputControls() { return fPathInputTable; } std::vector<ExtZoneParam*>& getOutputControls() { return fPathOutputTable; } void resetUserInterface(char* memory_block, Soundfile* defaultsound = nullptr) { JSONUIDecoderReal<float>::resetUserInterface(memory_block, defaultsound); } void buildUserInterface(UI* ui_interface) { JSONUIDecoderReal<float>::buildUserInterface(ui_interface); } void buildUserInterface(UI* ui_interface, char* memory_block) { JSONUIDecoderReal<float>::buildUserInterface(ui_interface, memory_block); } void buildUserInterface(UIGlue* ui_interface, char* memory_block) { JSONUIDecoderReal<float>::buildUserInterface(ui_interface, memory_block); } bool hasCompileOption(const std::string& option) { return JSONUIDecoderReal<float>::hasCompileOption(option); } }; // Double templated decoder struct JSONUIDoubleDecoder : public JSONUIDecoderReal<double>, public JSONUITemplatedDecoder { JSONUIDoubleDecoder(const std::string& json):JSONUIDecoderReal<double>(json) {} void metadata(Meta* m) { JSONUIDecoderReal<double>::metadata(m); } void metadata(MetaGlue* glue) { JSONUIDecoderReal<double>::metadata(glue); } int getDSPSize() { return fDSPSize; } std::string getName() { return fName; } std::string getLibVersion() { return fVersion; } std::string getCompileOptions() { return fCompileOptions; } std::vector<std::string> getLibraryList() { return fLibraryList; } std::vector<std::string> getIncludePathnames() { return fIncludePathnames; } int getNumInputs() { return fNumInputs; } int getNumOutputs() { return fNumOutputs; } int getSampleRate(char* memory_block) { return JSONUIDecoderReal<double>::getSampleRate(memory_block); } void setReflectZoneFun(int index, ReflectFunction fun) { JSONUIDecoderReal<double>::setReflectZoneFun(index, fun); } void setModifyZoneFun(int index, ModifyFunction fun) { JSONUIDecoderReal<double>::setModifyZoneFun(index, fun); } std::vector<ExtZoneParam*>& getInputControls() { return fPathInputTable; } std::vector<ExtZoneParam*>& getOutputControls() { return fPathOutputTable; } void resetUserInterface(char* memory_block, Soundfile* defaultsound = nullptr) { JSONUIDecoderReal<double>::resetUserInterface(memory_block, defaultsound); } void buildUserInterface(UI* ui_interface) { JSONUIDecoderReal<double>::buildUserInterface(ui_interface); } void buildUserInterface(UI* ui_interface, char* memory_block) { JSONUIDecoderReal<double>::buildUserInterface(ui_interface, memory_block); } void buildUserInterface(UIGlue* ui_interface, char* memory_block) { JSONUIDecoderReal<double>::buildUserInterface(ui_interface, memory_block); } bool hasCompileOption(const std::string& option) { return JSONUIDecoderReal<double>::hasCompileOption(option); } }; // FAUSTFLOAT templated decoder struct JSONUIDecoder : public JSONUIDecoderReal<FAUSTFLOAT> { JSONUIDecoder(const std::string& json):JSONUIDecoderReal<FAUSTFLOAT>(json) {} }; // Generic factory static JSONUITemplatedDecoder* createJSONUIDecoder(const std::string& json) { JSONUIDecoder decoder(json); if (decoder.hasCompileOption("-double")) { return new JSONUIDoubleDecoder(json); } else { return new JSONUIFloatDecoder(json); } } #endif /************************** END JSONUIDecoder.h **************************/ //---------------------------------------------------------------- // Proxy dsp definition created from the DSP JSON description // This class allows a 'proxy' dsp to control a real dsp // possibly running somewhere else. //---------------------------------------------------------------- class proxy_dsp : public dsp { private: JSONUIDecoder* fDecoder; int fSampleRate; public: proxy_dsp():fDecoder(nullptr), fSampleRate(-1) {} proxy_dsp(const std::string& json) { init(json); } void init(const std::string& json) { fDecoder = new JSONUIDecoder(json); fSampleRate = -1; } proxy_dsp(dsp* dsp) { JSONUI builder(dsp->getNumInputs(), dsp->getNumOutputs()); dsp->metadata(&builder); dsp->buildUserInterface(&builder); fSampleRate = dsp->getSampleRate(); fDecoder = new JSONUIDecoder(builder.JSON()); } virtual ~proxy_dsp() { delete fDecoder; } virtual int getNumInputs() { return fDecoder->fNumInputs; } virtual int getNumOutputs() { return fDecoder->fNumOutputs; } virtual void buildUserInterface(UI* ui) { fDecoder->buildUserInterface(ui); } // To possibly implement in a concrete proxy dsp virtual void init(int sample_rate) { instanceInit(sample_rate); } virtual void instanceInit(int sample_rate) { instanceConstants(sample_rate); instanceResetUserInterface(); instanceClear(); } virtual void instanceConstants(int sample_rate) { fSampleRate = sample_rate; } virtual void instanceResetUserInterface() { fDecoder->resetUserInterface(); } virtual void instanceClear() {} virtual int getSampleRate() { return fSampleRate; } virtual proxy_dsp* clone() { return new proxy_dsp(fDecoder->fJSON); } virtual void metadata(Meta* m) { fDecoder->metadata(m); } virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) {} virtual void compute(double date_usec, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) {} }; #endif /************************** END proxy-dsp.h **************************/ /************************** BEGIN JSONControl.h **************************/ /************************************************************************ FAUST Architecture File Copyright (C) 2019 GRAME, Centre National de Creation Musicale --------------------------------------------------------------------- This Architecture section is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see <http://www.gnu.org/licenses/>. EXCEPTION : As a special exception, you may create a larger work that contains this FAUST architecture section and distribute that work under terms of your choice, so long as this FAUST architecture section is not modified. ************************************************************************/ #ifndef __JSON_CONTROL__ #define __JSON_CONTROL__ #include <string> #ifndef FAUSTFLOAT #define FAUSTFLOAT float #endif struct JSONControl { virtual std::string getJSON() { return ""; } virtual void setParamValue(const std::string& path, FAUSTFLOAT value) {} virtual FAUSTFLOAT getParamValue(const std::string& path) { return 0; } virtual ~JSONControl() {} }; #endif /************************** END JSONControl.h **************************/ #define kActiveVoice 0 #define kFreeVoice -1 #define kReleaseVoice -2 #define kNoVoice -3 #define VOICE_STOP_LEVEL 0.0005 // -70 db #define MIX_BUFFER_SIZE 4096 // endsWith(<str>,<end>) : returns true if <str> ends with <end> static double midiToFreq(double note) { return 440.0 * std::pow(2.0, (note-69.0)/12.0); } /** * Allows to control zones in a grouped manner. */ class GroupUI : public GUI, public PathBuilder { private: std::map<std::string, uiGroupItem*> fLabelZoneMap; void insertMap(std::string label, FAUSTFLOAT* zone) { if (!MapUI::endsWith(label, "/gate") && !MapUI::endsWith(label, "/freq") && !MapUI::endsWith(label, "/gain")) { // Groups all controller except 'freq', 'gate', and 'gain' if (fLabelZoneMap.find(label) != fLabelZoneMap.end()) { fLabelZoneMap[label]->addZone(zone); } else { fLabelZoneMap[label] = new uiGroupItem(this, zone); } } } uiCallbackItem* fPanic; public: GroupUI(FAUSTFLOAT* zone, uiCallback cb, void* arg) { fPanic = new uiCallbackItem(this, zone, cb, arg); } virtual ~GroupUI() { // 'fPanic' is kept and deleted in GUI, so do not delete here } // -- widget's layouts void openTabBox(const char* label) { pushLabel(label); } void openHorizontalBox(const char* label) { pushLabel(label); } void openVerticalBox(const char* label) { pushLabel(label); } void closeBox() { popLabel(); } // -- active widgets void addButton(const char* label, FAUSTFLOAT* zone) { insertMap(buildPath(label), zone); } void addCheckButton(const char* label, FAUSTFLOAT* zone) { insertMap(buildPath(label), zone); } void addVerticalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT fmin, FAUSTFLOAT fmax, FAUSTFLOAT step) { insertMap(buildPath(label), zone); } void addHorizontalSlider(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT fmin, FAUSTFLOAT fmax, FAUSTFLOAT step) { insertMap(buildPath(label), zone); } void addNumEntry(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT init, FAUSTFLOAT fmin, FAUSTFLOAT fmax, FAUSTFLOAT step) { insertMap(buildPath(label), zone); } // -- passive widgets void addHorizontalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT fmin, FAUSTFLOAT fmax) { insertMap(buildPath(label), zone); } void addVerticalBargraph(const char* label, FAUSTFLOAT* zone, FAUSTFLOAT fmin, FAUSTFLOAT fmax) { insertMap(buildPath(label), zone); } }; /** * One voice of polyphony. */ struct dsp_voice : public MapUI, public decorator_dsp { int fNote; // Playing note actual pitch int fDate; // KeyOn date int fRelease; // Current number of samples used in release mode to detect end of note int fMinRelease; // Max of samples used in release mode to detect end of note FAUSTFLOAT fLevel; // Last audio block level std::vector<std::string> fGatePath; // Paths of 'gate' control std::vector<std::string> fGainPath; // Paths of 'gain' control std::vector<std::string> fFreqPath; // Paths of 'freq' control dsp_voice(dsp* dsp):decorator_dsp(dsp) { dsp->buildUserInterface(this); fNote = kFreeVoice; fLevel = FAUSTFLOAT(0); fDate = 0; fMinRelease = dsp->getSampleRate()/2; // One 1/2 sec used in release mode to detect end of note extractPaths(fGatePath, fFreqPath, fGainPath); } virtual ~dsp_voice() {} void extractPaths(std::vector<std::string>& gate, std::vector<std::string>& freq, std::vector<std::string>& gain) { // Keep gain, freq and gate labels std::map<std::string, FAUSTFLOAT*>::iterator it; for (it = getMap().begin(); it != getMap().end(); it++) { std::string path = (*it).first; if (endsWith(path, "/gate")) { gate.push_back(path); } else if (endsWith(path, "/freq")) { freq.push_back(path); } else if (endsWith(path, "/gain")) { gain.push_back(path); } } } // MIDI velocity [0..127] void keyOn(int pitch, int velocity, bool trigger) { keyOn(pitch, float(velocity)/127.f, trigger); } // Normalized MIDI velocity [0..1] void keyOn(int pitch, float velocity, bool trigger) { // So that DSP state is always re-initialized fDSP->instanceClear(); for (size_t i = 0; i < fFreqPath.size(); i++) { setParamValue(fFreqPath[i], midiToFreq(pitch)); } for (size_t i = 0; i < fGatePath.size(); i++) { setParamValue(fGatePath[i], FAUSTFLOAT(1)); } for (size_t i = 0; i < fGainPath.size(); i++) { setParamValue(fGainPath[i], velocity); } fNote = pitch; } void keyOff(bool hard = false) { // No use of velocity for now... for (size_t i = 0; i < fGatePath.size(); i++) { setParamValue(fGatePath[i], FAUSTFLOAT(0)); } if (hard) { // Immediately stop voice fNote = kFreeVoice; } else { // Release voice fRelease = fMinRelease; fNote = kReleaseVoice; } } }; /** * A group of voices. */ struct dsp_voice_group { GroupUI fGroups; std::vector<dsp_voice*> fVoiceTable; // Individual voices dsp* fVoiceGroup; // Voices group to be used for GUI grouped control FAUSTFLOAT fPanic; bool fVoiceControl; bool fGroupControl; dsp_voice_group(uiCallback cb, void* arg, bool control, bool group) :fGroups(&fPanic, cb, arg), fVoiceGroup(0), fPanic(FAUSTFLOAT(0)), fVoiceControl(control), fGroupControl(group) {} virtual ~dsp_voice_group() { for (size_t i = 0; i < fVoiceTable.size(); i++) { delete fVoiceTable[i]; } delete fVoiceGroup; } void addVoice(dsp_voice* voice) { fVoiceTable.push_back(voice); } void clearVoices() { fVoiceTable.clear(); } void init() { // Groups all uiItem for a given path fVoiceGroup = new proxy_dsp(fVoiceTable[0]); fVoiceGroup->buildUserInterface(&fGroups); for (size_t i = 0; i < fVoiceTable.size(); i++) { fVoiceTable[i]->buildUserInterface(&fGroups); } } void instanceResetUserInterface() { for (size_t i = 0; i < fVoiceTable.size(); i++) { fVoiceTable[i]->instanceResetUserInterface(); } } void buildUserInterface(UI* ui_interface) { if (fVoiceTable.size() > 1) { ui_interface->openTabBox("Polyphonic"); // Grouped voices UI ui_interface->openVerticalBox("Voices"); ui_interface->addButton("Panic", &fPanic); fVoiceGroup->buildUserInterface(ui_interface); ui_interface->closeBox(); // If not grouped, also add individual voices UI if (!fGroupControl) { for (size_t i = 0; i < fVoiceTable.size(); i++) { char buffer[32]; snprintf(buffer, 32, ((fVoiceTable.size() < 8) ? "Voice%ld" : "V%ld"), long(i+1)); ui_interface->openHorizontalBox(buffer); fVoiceTable[i]->buildUserInterface(ui_interface); ui_interface->closeBox(); } } ui_interface->closeBox(); } else { fVoiceTable[0]->buildUserInterface(ui_interface); } } }; /** * Base class for MIDI controllable DSP. */ #ifdef EMCC #endif class dsp_poly : public decorator_dsp, public midi, public JSONControl { protected: #ifdef EMCC MapUI fMapUI; std::string fJSON; midi_handler fMIDIHandler; MidiUI fMIDIUI; #endif public: #ifdef EMCC dsp_poly(dsp* dsp):decorator_dsp(dsp), fMIDIUI(&fMIDIHandler) { JSONUI jsonui(getNumInputs(), getNumOutputs()); buildUserInterface(&jsonui); fJSON = jsonui.JSON(true); buildUserInterface(&fMapUI); buildUserInterface(&fMIDIUI); } #else dsp_poly(dsp* dsp):decorator_dsp(dsp) {} #endif virtual ~dsp_poly() {} // Reimplemented for EMCC #ifdef EMCC virtual int getNumInputs() { return decorator_dsp::getNumInputs(); } virtual int getNumOutputs() { return decorator_dsp::getNumOutputs(); } virtual void buildUserInterface(UI* ui_interface) { decorator_dsp::buildUserInterface(ui_interface); } virtual int getSampleRate() { return decorator_dsp::getSampleRate(); } virtual void init(int sample_rate) { decorator_dsp::init(sample_rate); } virtual void instanceInit(int sample_rate) { decorator_dsp::instanceInit(sample_rate); } virtual void instanceConstants(int sample_rate) { decorator_dsp::instanceConstants(sample_rate); } virtual void instanceResetUserInterface() { decorator_dsp::instanceResetUserInterface(); } virtual void instanceClear() { decorator_dsp::instanceClear(); } virtual dsp_poly* clone() { return new dsp_poly(fDSP->clone()); } virtual void metadata(Meta* m) { decorator_dsp::metadata(m); } // Additional API std::string getJSON() { return fJSON; } virtual void setParamValue(const std::string& path, FAUSTFLOAT value) { fMapUI.setParamValue(path, value); GUI::updateAllGuis(); } virtual FAUSTFLOAT getParamValue(const std::string& path) { return fMapUI.getParamValue(path); } virtual void computeJS(int count, uintptr_t inputs, uintptr_t outputs) { decorator_dsp::compute(count, reinterpret_cast<FAUSTFLOAT**>(inputs),reinterpret_cast<FAUSTFLOAT**>(outputs)); } #endif virtual MapUI* keyOn(int channel, int pitch, int velocity) { return midi::keyOn(channel, pitch, velocity); } virtual void keyOff(int channel, int pitch, int velocity) { midi::keyOff(channel, pitch, velocity); } virtual void keyPress(int channel, int pitch, int press) { midi::keyPress(channel, pitch, press); } virtual void chanPress(int channel, int press) { midi::chanPress(channel, press); } virtual void ctrlChange(int channel, int ctrl, int value) { midi::ctrlChange(channel, ctrl, value); } virtual void ctrlChange14bits(int channel, int ctrl, int value) { midi::ctrlChange14bits(channel, ctrl, value); } virtual void pitchWheel(int channel, int wheel) { #ifdef EMCC fMIDIUI.pitchWheel(0., channel, wheel); GUI::updateAllGuis(); #else midi::pitchWheel(channel, wheel); #endif } virtual void progChange(int channel, int pgm) { midi::progChange(channel, pgm); } // Group API virtual void setGroup(bool group) {} virtual bool getGroup() { return false; } }; /** * Polyphonic DSP: groups a set of DSP to be played together or triggered by MIDI. * * All voices are preallocated by cloning the single DSP voice given at creation time. * Dynamic voice allocation is done in 'getFreeVoice' */ class ue_binaural_decoder_poly : public dsp_voice_group, public dsp_poly { private: FAUSTFLOAT** fMixBuffer; int fDate; FAUSTFLOAT mixCheckVoice(int count, FAUSTFLOAT** outputBuffer, FAUSTFLOAT** mixBuffer) { FAUSTFLOAT level = 0; for (int i = 0; i < getNumOutputs(); i++) { FAUSTFLOAT* mixChannel = mixBuffer[i]; FAUSTFLOAT* outChannel = outputBuffer[i]; for (int j = 0; j < count; j++) { level = std::max<FAUSTFLOAT>(level, (FAUSTFLOAT)fabs(outChannel[j])); mixChannel[j] += outChannel[j]; } } return level; } void mixVoice(int count, FAUSTFLOAT** outputBuffer, FAUSTFLOAT** mixBuffer) { for (int i = 0; i < getNumOutputs(); i++) { FAUSTFLOAT* mixChannel = mixBuffer[i]; FAUSTFLOAT* outChannel = outputBuffer[i]; for (int j = 0; j < count; j++) { mixChannel[j] += outChannel[j]; } } } void clearOutput(int count, FAUSTFLOAT** mixBuffer) { for (int i = 0; i < getNumOutputs(); i++) { memset(mixBuffer[i], 0, count * sizeof(FAUSTFLOAT)); } } int getPlayingVoice(int pitch) { int voice_playing = kNoVoice; int oldest_date_playing = INT_MAX; for (size_t i = 0; i < fVoiceTable.size(); i++) { if (fVoiceTable[i]->fNote == pitch) { // Keeps oldest playing voice if (fVoiceTable[i]->fDate < oldest_date_playing) { oldest_date_playing = fVoiceTable[i]->fDate; voice_playing = int(i); } } } return voice_playing; } // Always returns a voice int getFreeVoice() { int voice = kNoVoice; // Looks for the first available voice for (size_t i = 0; i < fVoiceTable.size(); i++) { if (fVoiceTable[i]->fNote == kFreeVoice) { voice = int(i); goto result; } } { // Otherwise steal one int voice_release = kNoVoice; int voice_playing = kNoVoice; int oldest_date_release = INT_MAX; int oldest_date_playing = INT_MAX; // Scan all voices for (size_t i = 0; i < fVoiceTable.size(); i++) { if (fVoiceTable[i]->fNote == kReleaseVoice) { // Keeps oldest release voice if (fVoiceTable[i]->fDate < oldest_date_release) { oldest_date_release = fVoiceTable[i]->fDate; voice_release = int(i); } } else { // Otherwise keeps oldest playing voice if (fVoiceTable[i]->fDate < oldest_date_playing) { oldest_date_playing = fVoiceTable[i]->fDate; voice_playing = int(i); } } } // Then decide which one to steal if (oldest_date_release != INT_MAX) { std::cout << "Steal release voice : voice_date " << fVoiceTable[voice_release]->fDate << " cur_date = " << fDate << " voice = " << voice_release << std::endl; voice = voice_release; goto result; } else if (oldest_date_playing != INT_MAX) { std::cout << "Steal playing voice : voice_date " << fVoiceTable[voice_playing]->fDate << " cur_date = " << fDate << " voice = " << voice_playing << std::endl; voice = voice_playing; goto result; } else { assert(false); return kNoVoice; } } result: fVoiceTable[voice]->fDate = fDate++; fVoiceTable[voice]->fNote = kActiveVoice; return voice; } static void panic(FAUSTFLOAT val, void* arg) { if (val == FAUSTFLOAT(1)) { static_cast<ue_binaural_decoder_poly*>(arg)->allNotesOff(true); } } bool checkPolyphony() { if (fVoiceTable.size() > 0) { return true; } else { std::cout << "DSP is not polyphonic...\n"; return false; } } public: /** * Constructor. * * @param dsp - the dsp to be used for one voice. Beware: ue_binaural_decoder_poly will use and finally delete the pointer. * @param nvoices - number of polyphony voices, should be at least 1 * @param control - whether voices will be dynamically allocated and controlled (typically by a MIDI controler). * If false all voices are always running. * @param group - if true, voices are not individually accessible, a global "Voices" tab will automatically dispatch * a given control on all voices, assuming GUI::updateAllGuis() is called. * If false, all voices can be individually controlled. * setGroup/getGroup methods can be used to set/get the group state. * */ ue_binaural_decoder_poly(dsp* dsp, int nvoices, bool control = false, bool group = true) : dsp_voice_group(panic, this, control, group), dsp_poly(dsp) // dsp parameter is deallocated by ~dsp_poly { fDate = 0; // Create voices assert(nvoices > 0); for (int i = 0; i < nvoices; i++) { addVoice(new dsp_voice(dsp->clone())); } // Init audio output buffers fMixBuffer = new FAUSTFLOAT*[getNumOutputs()]; for (int i = 0; i < getNumOutputs(); i++) { fMixBuffer[i] = new FAUSTFLOAT[MIX_BUFFER_SIZE]; } dsp_voice_group::init(); } virtual ~ue_binaural_decoder_poly() { for (int i = 0; i < getNumOutputs(); i++) { delete[] fMixBuffer[i]; } delete[] fMixBuffer; } // DSP API void buildUserInterface(UI* ui_interface) { dsp_voice_group::buildUserInterface(ui_interface); } void init(int sample_rate) { decorator_dsp::init(sample_rate); fVoiceGroup->init(sample_rate); fPanic = FAUSTFLOAT(0); // Init voices for (size_t i = 0; i < fVoiceTable.size(); i++) { fVoiceTable[i]->init(sample_rate); } } void instanceInit(int samplingFreq) { instanceConstants(samplingFreq); instanceResetUserInterface(); instanceClear(); } void instanceConstants(int sample_rate) { decorator_dsp::instanceConstants(sample_rate); fVoiceGroup->instanceConstants(sample_rate); // Init voices for (size_t i = 0; i < fVoiceTable.size(); i++) { fVoiceTable[i]->instanceConstants(sample_rate); } } void instanceResetUserInterface() { decorator_dsp::instanceResetUserInterface(); fVoiceGroup->instanceResetUserInterface(); fPanic = FAUSTFLOAT(0); for (size_t i = 0; i < fVoiceTable.size(); i++) { fVoiceTable[i]->instanceResetUserInterface(); } } void instanceClear() { decorator_dsp::instanceClear(); fVoiceGroup->instanceClear(); for (size_t i = 0; i < fVoiceTable.size(); i++) { fVoiceTable[i]->instanceClear(); } } virtual ue_binaural_decoder_poly* clone() { return new ue_binaural_decoder_poly(fDSP->clone(), int(fVoiceTable.size()), fVoiceControl, fGroupControl); } void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { assert(count <= MIX_BUFFER_SIZE); // First clear the outputs clearOutput(count, outputs); if (fVoiceControl) { // Mix all playing voices for (size_t i = 0; i < fVoiceTable.size(); i++) { dsp_voice* voice = fVoiceTable[i]; if (voice->fNote != kFreeVoice) { voice->compute(count, inputs, fMixBuffer); // Mix it in result voice->fLevel = mixCheckVoice(count, fMixBuffer, outputs); // Check the level to possibly set the voice in kFreeVoice again voice->fRelease -= count; if ((voice->fNote == kReleaseVoice) && (voice->fRelease < 0) && (voice->fLevel < VOICE_STOP_LEVEL)) { voice->fNote = kFreeVoice; } } } } else { // Mix all voices for (size_t i = 0; i < fVoiceTable.size(); i++) { fVoiceTable[i]->compute(count, inputs, fMixBuffer); mixVoice(count, fMixBuffer, outputs); } } } void compute(double date_usec, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) { compute(count, inputs, outputs); } // Terminate all active voices, gently or immediately (depending of 'hard' value) void allNotesOff(bool hard = false) { for (size_t i = 0; i < fVoiceTable.size(); i++) { fVoiceTable[i]->keyOff(hard); } } // Additional polyphonic API MapUI* newVoice() { int voice = getFreeVoice(); // So that DSP state is always re-initialized fVoiceTable[voice]->instanceClear(); return fVoiceTable[voice]; } void deleteVoice(MapUI* voice) { std::vector<dsp_voice*>::iterator it = find(fVoiceTable.begin(), fVoiceTable.end(), reinterpret_cast<dsp_voice*>(voice)); if (it != fVoiceTable.end()) { (*it)->keyOff(); } else { std::cout << "Voice not found\n"; } } // Group API void setGroup(bool group) { fGroupControl = group; } bool getGroup() { return fGroupControl; } // MIDI API MapUI* keyOn(int channel, int pitch, int velocity) { if (checkPolyphony()) { int voice = getFreeVoice(); fVoiceTable[voice]->keyOn(pitch, velocity, true); return fVoiceTable[voice]; } else { return 0; } } void keyOff(int channel, int pitch, int velocity = 127) { if (checkPolyphony()) { int voice = getPlayingVoice(pitch); if (voice != kNoVoice) { fVoiceTable[voice]->keyOff(); } else { std::cout << "Playing pitch = " << pitch << " not found\n"; } } } void ctrlChange(int channel, int ctrl, int value) { if (ctrl == ALL_NOTES_OFF || ctrl == ALL_SOUND_OFF) { allNotesOff(); } } }; /** * Polyphonic DSP with an integrated effect. fPolyDSP will respond to MIDI messages. */ class dsp_poly_effect : public dsp_poly { private: dsp_poly* fPolyDSP; public: dsp_poly_effect(dsp_poly* dsp1, dsp* dsp2) :dsp_poly(dsp2), fPolyDSP(dsp1) {} virtual ~dsp_poly_effect() { // dsp_poly_effect is also a decorator_dsp, which will free fPolyDSP } // MIDI API MapUI* keyOn(int channel, int pitch, int velocity) { return fPolyDSP->keyOn(channel, pitch, velocity); } void keyOff(int channel, int pitch, int velocity) { fPolyDSP->keyOff(channel, pitch, velocity); } void keyPress(int channel, int pitch, int press) { fPolyDSP->keyPress(channel, pitch, press); } void chanPress(int channel, int press) { fPolyDSP->chanPress(channel, press); } void ctrlChange(int channel, int ctrl, int value) { fPolyDSP->ctrlChange(channel, ctrl, value); } void ctrlChange14bits(int channel, int ctrl, int value) { fPolyDSP->ctrlChange14bits(channel, ctrl, value); } void pitchWheel(int channel, int wheel) { fPolyDSP->pitchWheel(channel, wheel); } void progChange(int channel, int pgm) { fPolyDSP->progChange(channel, pgm); } // Group API void setGroup(bool group) { fPolyDSP->setGroup(group); } bool getGroup() { return fPolyDSP->getGroup(); } }; /** * Polyphonic DSP factory class. Helper code to support polyphonic DSP source with an integrated effect. */ struct dsp_poly_factory : public dsp_factory { dsp_factory* fProcessFactory; dsp_factory* fEffectFactory; std::string getEffectCode(const std::string& dsp_content) { std::stringstream effect_code; effect_code << "adapt(1,1) = _; adapt(2,2) = _,_; adapt(1,2) = _ <: _,_; adapt(2,1) = _,_ :> _;"; effect_code << "adaptor(F,G) = adapt(outputs(F),inputs(G)); dsp_code = environment{ " << dsp_content << " };"; effect_code << "process = adaptor(dsp_code.process, dsp_code.effect) : dsp_code.effect;"; return effect_code.str(); } dsp_poly_factory(dsp_factory* process_factory = NULL, dsp_factory* effect_factory = NULL): fProcessFactory(process_factory) ,fEffectFactory(effect_factory) {} virtual ~dsp_poly_factory() {} virtual std::string getName() { return fProcessFactory->getName(); } virtual std::string getSHAKey() { return fProcessFactory->getSHAKey(); } virtual std::string getDSPCode() { return fProcessFactory->getDSPCode(); } virtual std::string getCompileOptions() { return fProcessFactory->getCompileOptions(); } virtual std::vector<std::string> getLibraryList() { return fProcessFactory->getLibraryList(); } virtual std::vector<std::string> getIncludePathnames() { return fProcessFactory->getIncludePathnames(); } virtual void setMemoryManager(dsp_memory_manager* manager) { fProcessFactory->setMemoryManager(manager); if (fEffectFactory) { fEffectFactory->setMemoryManager(manager); } } virtual dsp_memory_manager* getMemoryManager() { return fProcessFactory->getMemoryManager(); } /* Create a new polyphonic DSP instance with global effect, to be deleted with C++ 'delete' * * @param nvoices - number of polyphony voices, should be at least 1 * @param control - whether voices will be dynamically allocated and controlled (typically by a MIDI controler). * If false all voices are always running. * @param group - if true, voices are not individually accessible, a global "Voices" tab will automatically dispatch * a given control on all voices, assuming GUI::updateAllGuis() is called. * If false, all voices can be individually controlled. */ dsp_poly* createPolyDSPInstance(int nvoices, bool control, bool group) { dsp_poly* dsp_poly = new ue_binaural_decoder_poly(fProcessFactory->createDSPInstance(), nvoices, control, group); if (fEffectFactory) { // the 'dsp_poly' object has to be controlled with MIDI, so kept separated from new dsp_sequencer(...) object return new dsp_poly_effect(dsp_poly, new dsp_sequencer(dsp_poly, fEffectFactory->createDSPInstance())); } else { return new dsp_poly_effect(dsp_poly, dsp_poly); } } /* Create a new DSP instance, to be deleted with C++ 'delete' */ dsp* createDSPInstance() { return fProcessFactory->createDSPInstance(); } }; #endif // __poly_dsp__ /************************** END poly-dsp.h **************************/ std::list<GUI*> GUI::fGuiList; ztimedmap GUI::gTimedZoneMap; static t_class* faust_class; /*--------------------------------------------------------------------------*/ static const char* getCodeSize() { int tmp; return (sizeof(&tmp) == 8) ? "64 bits" : "32 bits"; } /*--------------------------------------------------------------------------*/ typedef struct faust { t_pxobject m_ob; t_atom *m_seen, *m_want; map<string, vector<t_object*> > m_output_table; short m_where; bool m_mute; void** m_args; mspUI* m_dspUI; dsp* m_dsp; ue_binaural_decoder_poly* m_dsp_poly; void* m_control_outlet; char* m_json; t_systhread_mutex m_mutex; int m_Inputs; int m_Outputs; SaveUI* m_savedUI; #ifdef MIDICTRL MidiUI* m_midiUI; midi_handler* m_midiHandler; #endif #ifdef SOUNDFILE SoundUI* m_soundInterface; #endif #ifdef OSCCTRL OSCUI* m_oscInterface; #endif } t_faust; void faust_create_jsui(t_faust* x); void faust_make_json(t_faust* x); /*--------------------------------------------------------------------------*/ void faust_allocate(t_faust* x, int nvoices) { // Delete old delete x->m_dsp; x->m_dspUI->clear(); if (nvoices > 0) { #ifdef POST post("polyphonic DSP voices = %d", nvoices); #endif x->m_dsp_poly = new ue_binaural_decoder_poly(new ue_binaural_decoder(), nvoices, true, true); #ifdef POLY2 x->m_dsp = new dsp_sequencer(x->m_dsp_poly, new effect()); #else x->m_dsp = x->m_dsp_poly; #endif #ifdef MIDICTRL x->m_midiHandler->addMidiIn(x->m_dsp_poly); #endif } else { #ifdef POST post("monophonic DSP"); #endif #if (DOWN_SAMPLING > 0) #if (FILTER_TYPE == 0) x->m_dsp = new dsp_down_sampler<Identity<Double<1,1>, DOWN_SAMPLING>>(new ue_binaural_decoder()); #elif (FILTER_TYPE == 1) x->m_dsp = new dsp_down_sampler<LowPass3<Double<45,100>, DOWN_SAMPLING, double>>(new ue_binaural_decoder()); #elif (FILTER_TYPE == 2) x->m_dsp = new dsp_down_sampler<LowPass4<Double<45,100>, DOWN_SAMPLING, double>>(new ue_binaural_decoder()); #elif (FILTER_TYPE == 3) x->m_dsp = new dsp_down_sampler<LowPass3e<Double<45,100>, DOWN_SAMPLING, double>>(new ue_binaural_decoder()); #elif (FILTER_TYPE == 4) x->m_dsp = new dsp_down_sampler<LowPass6eé<Double<45,100>, DOWN_SAMPLING, double>>(new ue_binaural_decoder()); #else #error "ERROR : Filter type must be in [0..4] range" #endif #elif (UP_SAMPLING > 0) #if (FILTER_TYPE == 0) x->m_dsp = new dsp_up_sampler<Identity<Double<1,1>, UP_SAMPLING>>(new ue_binaural_decoder()); #elif (FILTER_TYPE == 1) x->m_dsp = new dsp_up_sampler<LowPass3<Double<45,100>, UP_SAMPLING, double>>(new ue_binaural_decoder()); #elif (FILTER_TYPE == 2) x->m_dsp = new dsp_up_sampler<LowPass4<Double<45,100>, UP_SAMPLING, double>>(new ue_binaural_decoder()); #elif (FILTER_TYPE == 3) x->m_dsp = new dsp_up_sampler<LowPass3e<Double<45,100>, UP_SAMPLING, double>>(new ue_binaural_decoder()); #elif (FILTER_TYPE == 4) x->m_dsp = new dsp_up_sampler<LowPass6e<Double<45,100>, UP_SAMPLING, double>>(new ue_binaural_decoder()); #else #error "ERROR : Filter type must be in [0..4] range" #endif #else x->m_dsp = new ue_binaural_decoder(); #endif } #ifdef MIDICTRL x->m_dsp->buildUserInterface(x->m_midiUI); #endif // Possible sample adaptation if (sizeof(FAUSTFLOAT) == 4) { x->m_dsp = new dsp_sample_adapter<FAUSTFLOAT, double>(x->m_dsp); } } /*--------------------------------------------------------------------------*/ void faust_anything(t_faust* obj, t_symbol* s, short ac, t_atom* av) { bool res = false; string name = string((s)->s_name); // If no argument is there, consider it as a toggle message for a button if (ac == 0 && obj->m_dspUI->isValue(name)) { FAUSTFLOAT off = FAUSTFLOAT(0.0); FAUSTFLOAT on = FAUSTFLOAT(1.0); obj->m_dspUI->setValue(name, off); obj->m_dspUI->setValue(name, on); av[0].a_type = A_FLOAT; av[0].a_w.w_float = off; faust_anything(obj, s, 1, av); } else if (mspUI::checkDigit(name)) { // List of values int pos, ndigit = 0; for (pos = name.size() - 1; pos >= 0; pos--) { if (isdigit(name[pos]) || name[pos] == ' ') { ndigit++; } else { break; } } pos++; string prefix = name.substr(0, pos); string num_base = name.substr(pos); int num = atoi(num_base.c_str()); int i; t_atom* ap; // Increment ap each time to get to the next atom for (i = 0, ap = av; i < ac; i++, ap++) { FAUSTFLOAT value; switch (atom_gettype(ap)) { case A_LONG: value = FAUSTFLOAT(ap[0].a_w.w_long); break; case A_FLOAT: value = FAUSTFLOAT(ap[0].a_w.w_float); break; default: post("Invalid argument in parameter setting"); return; } string num_val = to_string(num + i); stringstream param_name; param_name << prefix; for (int i = 0; i < ndigit - mspUI::countDigit(num_val); i++) { param_name << ' '; } param_name << num_val; // Try special naming scheme for list of parameters res = obj->m_dspUI->setValue(param_name.str(), value); // Otherwise try standard name if (!res) { res = obj->m_dspUI->setValue(name, value); } if (!res) { post("Unknown parameter : %s", (s)->s_name); } } } else { // Standard parameter name FAUSTFLOAT value = (av[0].a_type == A_LONG) ? FAUSTFLOAT(av[0].a_w.w_long) : FAUSTFLOAT(av[0].a_w.w_float); res = obj->m_dspUI->setValue(name, value); if (!res) { post("Unknown parameter : %s", (s)->s_name); } } } /*--------------------------------------------------------------------------*/ void faust_polyphony(t_faust* x, t_symbol* s, short ac, t_atom* av) { if (systhread_mutex_lock(x->m_mutex) == MAX_ERR_NONE) { #ifdef MIDICTRL if (x->m_dsp_poly) { x->m_midiHandler->removeMidiIn(x->m_dsp_poly); } #endif faust_allocate(x, av[0].a_w.w_long); // Initialize at the system's sampling rate x->m_dsp->init(long(sys_getsr())); // Initialize User Interface (here connnection with controls) x->m_dsp->buildUserInterface(x->m_dspUI); // Prepare JSON faust_make_json(x); // Send JSON to JS script faust_create_jsui(x); // Load old controller state x->m_dsp->buildUserInterface(x->m_savedUI); systhread_mutex_unlock(x->m_mutex); } else { post("Mutex lock cannot be taken..."); } } /*--------------------------------------------------------------------------*/ #ifdef MIDICTRL void faust_midievent(t_faust* x, t_symbol* s, short ac, t_atom* av) { if (ac > 0) { int type = (int)av[0].a_w.w_long & 0xf0; int channel = (int)av[0].a_w.w_long & 0x0f; if (ac == 1) { x->m_midiHandler->handleSync(0.0, av[0].a_w.w_long); } else if (ac == 2) { x->m_midiHandler->handleData1(0.0, type, channel, av[1].a_w.w_long); } else if (ac == 3) { x->m_midiHandler->handleData2(0.0, type, channel, av[1].a_w.w_long, av[2].a_w.w_long); } } } #endif /*--------------------------------------------------------------------------*/ void faust_create_jsui(t_faust* x) { t_object *patcher, *box, *obj; object_obex_lookup((t_object*)x, gensym("#P"), &patcher); for (box = jpatcher_get_firstobject(patcher); box; box = jbox_get_nextobject(box)) { obj = jbox_get_object(box); // Notify JSON if (obj && strcmp(object_classname(obj)->s_name, "js") == 0) { t_atom json; atom_setsym(&json, gensym(x->m_json)); object_method_typed(obj, gensym("anything"), 1, &json, 0); } } // Keep all outputs to be notified in update_outputs x->m_output_table.clear(); for (box = jpatcher_get_firstobject(patcher); box; box = jbox_get_nextobject(box)) { obj = jbox_get_object(box); t_symbol* scriptingname = jbox_get_varname(obj); // scripting name // Keep control outputs if (scriptingname && x->m_dspUI->isOutputValue(scriptingname->s_name)) { x->m_output_table[scriptingname->s_name].push_back(obj); } } } /*--------------------------------------------------------------------------*/ void faust_update_outputs(t_faust* x) { for (auto& it1 : x->m_output_table) { bool new_val = false; FAUSTFLOAT value = x->m_dspUI->getOutputValue(it1.first, new_val); if (new_val) { t_atom at_value; atom_setfloat(&at_value, value); for (auto& it2 : it1.second) { object_method_typed(it2, gensym("float"), 1, &at_value, 0); } } } } /*--------------------------------------------------------------------------*/ void faust_make_json(t_faust* x) { // Prepare JSON if (x->m_json) free(x->m_json); JSONUI builder(x->m_dsp->getNumInputs(), x->m_dsp->getNumOutputs()); x->m_dsp->metadata(&builder); x->m_dsp->buildUserInterface(&builder); x->m_json = strdup(builder.JSON().c_str()); } /*--------------------------------------------------------------------------*/ void* faust_new(t_symbol* s, short ac, t_atom* av) { bool midi_sync = false; int nvoices = 0; ue_binaural_decoder* tmp_dsp = new ue_binaural_decoder(); MidiMeta::analyse(tmp_dsp, midi_sync, nvoices); delete tmp_dsp; t_faust* x = (t_faust*)object_alloc(faust_class); x->m_savedUI = new SaveLabelUI(); x->m_dspUI = NULL; x->m_dsp = NULL; x->m_dsp_poly = NULL; x->m_json = NULL; x->m_mute = false; #ifdef MIDICTRL x->m_midiHandler = new midi_handler(); x->m_midiUI = new MidiUI(x->m_midiHandler); #endif x->m_dspUI = new mspUI(); faust_allocate(x, nvoices); x->m_Inputs = x->m_dsp->getNumInputs(); x->m_Outputs = x->m_dsp->getNumOutputs(); x->m_control_outlet = outlet_new((t_pxobject*)x, (char*)"list"); // Initialize at the system's sampling rate x->m_dsp->init(long(sys_getsr())); // Initialize User Interface (here connnection with controls) x->m_dsp->buildUserInterface(x->m_dspUI); t_max_err err = systhread_mutex_new(&x->m_mutex, SYSTHREAD_MUTEX_NORMAL); if (err != MAX_ERR_NONE) { post("Cannot allocate mutex..."); } // Prepare JSON faust_make_json(x); int num_input; if (x->m_dspUI->isMulti()) { num_input = x->m_dsp->getNumInputs() + 1; } else { num_input = x->m_dsp->getNumInputs(); } x->m_args = (void**)calloc((num_input + x->m_dsp->getNumOutputs()) + 2, sizeof(void*)); /* Multi in */ dsp_setup((t_pxobject*)x, num_input); /* Multi out */ for (int i = 0; i < x->m_dsp->getNumOutputs(); i++) { outlet_new((t_pxobject*)x, (char*)"signal"); } ((t_pxobject*)x)->z_misc = Z_NO_INPLACE; // To assure input and output buffers are actually different #ifdef SOUNDFILE Max_Meta3 meta3; x->m_dsp->metadata(&meta3); string bundle_path_str = SoundUI::getBinaryPathFrom(meta3.fName); if (bundle_path_str == "") { post("Bundle_path '%s' cannot be found!", meta3.fName.c_str()); } x->m_soundInterface = new SoundUI(bundle_path_str); // SoundUI has to be dispatched on all internal voices if (x->m_dsp_poly) x->m_dsp_poly->setGroup(false); x->m_dsp->buildUserInterface(x->m_soundInterface); if (x->m_dsp_poly) x->m_dsp_poly->setGroup(true); #endif #ifdef OSCCTRL x->m_oscInterface = NULL; #endif // Send JSON to JS script faust_create_jsui(x); // Load old controller state x->m_dsp->buildUserInterface(x->m_savedUI); // Display controls #ifdef POST x->m_dspUI->displayControls(); #endif // Get attributes values attr_args_process(x, ac, av); return x; } #ifdef OSCCTRL // osc 'IP inport outport xmit bundle' /*--------------------------------------------------------------------------*/ void faust_osc(t_faust* x, t_symbol* s, short ac, t_atom* av) { if (ac == 5) { if (systhread_mutex_lock(x->m_mutex) == MAX_ERR_NONE) { delete x->m_oscInterface; const char* argv1[32]; int argc1 = 0; argv1[argc1++] = "Faust"; argv1[argc1++] = "-desthost"; argv1[argc1++] = atom_getsym(&av[0])->s_name; char inport[32]; snprintf(inport, 32, "%ld", long(av[1].a_w.w_long)); argv1[argc1++] = "-port"; argv1[argc1++] = inport; char outport[32]; snprintf(outport, 32, "%ld", long(av[2].a_w.w_long)); argv1[argc1++] = "-outport"; argv1[argc1++] = outport; char xmit[32]; snprintf(xmit, 32, "%ld", long(av[3].a_w.w_long)); argv1[argc1++] = "-xmit"; argv1[argc1++] = xmit; char bundle[32]; snprintf(bundle, 32, "%ld", long(av[4].a_w.w_long)); argv1[argc1++] = "-bundle"; argv1[argc1++] = bundle; x->m_oscInterface = new OSCUI("Faust", argc1, (char**)argv1); x->m_dsp->buildUserInterface(x->m_oscInterface); x->m_oscInterface->run(); post(x->m_oscInterface->getInfos().c_str()); systhread_mutex_unlock(x->m_mutex); } else { post("Mutex lock cannot be taken..."); } } else { post("Should be : osc 'IP inport outport xmit(0|1|2) bundle(0|1)'"); } } #endif /*--------------------------------------------------------------------------*/ // Reset controllers to init value and send [path, init, min, max] void faust_init(t_faust* x, t_symbol* s, short ac, t_atom* av) { // Reset internal state x->m_savedUI->reset(); // Input controllers for (mspUI::iterator it = x->m_dspUI->begin2(); it != x->m_dspUI->end2(); it++) { t_atom myList[4]; atom_setsym(&myList[0], gensym((*it).first.c_str())); atom_setfloat(&myList[1], (*it).second->getInitValue()); // init value atom_setfloat(&myList[2], (*it).second->getMinValue()); atom_setfloat(&myList[3], (*it).second->getMaxValue()); outlet_list(x->m_control_outlet, 0, 4, myList); } // Output controllers for (mspUI::iterator it = x->m_dspUI->begin4(); it != x->m_dspUI->end4(); it++) { t_atom myList[4]; atom_setsym(&myList[0], gensym((*it).first.c_str())); atom_setfloat(&myList[1], (*it).second->getInitValue()); // init value atom_setfloat(&myList[2], (*it).second->getMinValue()); atom_setfloat(&myList[3], (*it).second->getMaxValue()); outlet_list(x->m_control_outlet, 0, 4, myList); } } /*--------------------------------------------------------------------------*/ // Dump controllers as list of: [path, cur, init, min, max] void faust_dump(t_faust* x, t_symbol* s, short ac, t_atom* av) { // Input controllers for (mspUI::iterator it = x->m_dspUI->begin2(); it != x->m_dspUI->end2(); it++) { t_atom myList[4]; atom_setsym(&myList[0], gensym((*it).first.c_str())); atom_setfloat(&myList[1], (*it).second->getValue()); // cur value atom_setfloat(&myList[2], (*it).second->getMinValue()); atom_setfloat(&myList[3], (*it).second->getMaxValue()); outlet_list(x->m_control_outlet, 0, 4, myList); } // Output controllers for (mspUI::iterator it = x->m_dspUI->begin4(); it != x->m_dspUI->end4(); it++) { t_atom myList[4]; atom_setsym(&myList[0], gensym((*it).first.c_str())); atom_setfloat(&myList[1], (*it).second->getValue()); // cur value atom_setfloat(&myList[2], (*it).second->getMinValue()); atom_setfloat(&myList[3], (*it).second->getMaxValue()); outlet_list(x->m_control_outlet, 0, 4, myList); } } /*--------------------------------------------------------------------------*/ void faust_dblclick(t_faust* x, long inlet) { x->m_dspUI->displayControls(); } /*--------------------------------------------------------------------------*/ //11/13/2015 : faust_assist is actually called at each click in the patcher, so we now use 'faust_dblclick' to display the parameters... void faust_assist(t_faust* x, void* b, long msg, long a, char* dst) { if (msg == ASSIST_INLET) { if (a == 0) { if (x->m_dsp->getNumInputs() == 0) { sprintf(dst, "(message) : Unused Input"); } else { sprintf(dst, "(signal) : Audio Input %ld", (a+1)); } } else if (a < x->m_dsp->getNumInputs()) { sprintf(dst, "(signal) : Audio Input %ld", (a+1)); } } else if (msg == ASSIST_OUTLET) { if (a < x->m_dsp->getNumOutputs()) { sprintf(dst, "(signal) : Audio Output %ld", (a+1)); } else { sprintf(dst, "(list) : [path, cur|init, min, max]*"); } } } /*--------------------------------------------------------------------------*/ void faust_mute(t_faust* obj, t_symbol* s, short ac, t_atom* at) { if (atom_gettype(at) == A_LONG) { obj->m_mute = atom_getlong(at); } } /*--------------------------------------------------------------------------*/ void faust_free(t_faust* x) { dsp_free((t_pxobject*)x); delete x->m_dsp; delete x->m_dspUI; delete x->m_savedUI; if (x->m_args) free(x->m_args); if (x->m_json) free(x->m_json); systhread_mutex_free(x->m_mutex); #ifdef MIDICTRL // m_midiUI *must* be deleted before m_midiHandler delete x->m_midiUI; delete x->m_midiHandler; #endif #ifdef SOUNDFILE delete x->m_soundInterface; #endif #ifdef OSCCTRL delete x->m_oscInterface; #endif } /*--------------------------------------------------------------------------*/ void faust_perform64(t_faust* x, t_object* dsp64, double** ins, long numins, double** outs, long numouts, long sampleframes, long flags, void* userparam) { AVOIDDENORMALS; if (!x->m_mute && systhread_mutex_trylock(x->m_mutex) == MAX_ERR_NONE) { if (x->m_dsp) { if (x->m_dspUI->isMulti()) { x->m_dspUI->setMultiValues(reinterpret_cast<FAUSTFLOAT*>(ins[0]), sampleframes); x->m_dsp->compute(sampleframes, reinterpret_cast<FAUSTFLOAT**>(++ins), reinterpret_cast<FAUSTFLOAT**>(outs)); } else { x->m_dsp->compute(sampleframes, reinterpret_cast<FAUSTFLOAT**>(ins), reinterpret_cast<FAUSTFLOAT**>(outs)); } #ifdef OSCCTRL if (x->m_oscInterface) x->m_oscInterface->endBundle(); #endif faust_update_outputs(x); } #if defined(MIDICTRL) || defined(OSCCTRL) GUI::updateAllGuis(); #endif systhread_mutex_unlock(x->m_mutex); } else { // Write null buffers to outs for (int i = 0; i < numouts; i++) { memset(outs[i], 0, sizeof(double) * sampleframes); } } } /*--------------------------------------------------------------------------*/ void faust_dsp64(t_faust* x, t_object* dsp64, short* count, double samplerate, long maxvectorsize, long flags) { object_method(dsp64, gensym("dsp_add64"), x, faust_perform64, 0, NULL); } /*--------------------------------------------------------------------------*/ t_max_err faust_attr_set(t_faust* x, t_object* attr, long ac, t_atom* av) { if (ac && av) { t_symbol* attrname = (t_symbol*)object_method(attr, gensym("getname")); // Redirect on the generic message handling method faust_anything(x, attrname, ac, av); } return MAX_ERR_NONE; } /*--------------------------------------------------------------------------*/ #ifdef _WIN32 extern "C" int main(void) #else void ext_main(void* r) #endif { string file_name = string(FAUST_FILE_NAME); // Remove ".dsp" ending string class_name = file_name.erase(file_name.size()-4) + "~"; t_class* c = class_new(class_name.c_str(), (method)faust_new, (method)faust_free, sizeof(t_faust), 0L, A_GIMME, 0); class_addmethod(c, (method)faust_anything, "anything", A_GIMME, 0); class_addmethod(c, (method)faust_polyphony, "polyphony", A_GIMME, 0); #ifdef OSCCTRL class_addmethod(c, (method)faust_osc, "osc", A_GIMME, 0); #endif class_addmethod(c, (method)faust_init, "init", A_GIMME, 0); class_addmethod(c, (method)faust_dump, "dump", A_GIMME, 0); #ifdef MIDICTRL class_addmethod(c, (method)faust_midievent, "midievent", A_GIMME, 0); #endif class_addmethod(c, (method)faust_dsp64, "dsp64", A_CANT, 0); class_addmethod(c, (method)faust_dblclick, "dblclick", A_CANT, 0); class_addmethod(c, (method)faust_assist, "assist", A_CANT, 0); class_addmethod(c, (method)faust_mute, "mute", A_GIMME, 0); dsp* tmp_dsp = new ue_binaural_decoder(); mspUI tmp_UI; tmp_dsp->buildUserInterface(&tmp_UI); // Setup attributes int i = 0; if (sizeof(FAUSTFLOAT) == 4) { for (mspUI::iterator it = tmp_UI.begin1(); it != tmp_UI.end1(); it++, i++) { CLASS_ATTR_FLOAT(c, (*it).first.c_str(), 0, t_faust, m_ob); CLASS_ATTR_ACCESSORS(c, (*it).first.c_str(), NULL, (method)faust_attr_set); } } else { for (mspUI::iterator it = tmp_UI.begin1(); it != tmp_UI.end1(); it++, i++) { CLASS_ATTR_DOUBLE(c, (*it).first.c_str(), 0, t_faust, m_ob); CLASS_ATTR_ACCESSORS(c, (*it).first.c_str(), NULL, (method)faust_attr_set); } } class_dspinit(c); class_register(CLASS_BOX, c); faust_class = c; #ifdef POST post((char*)"Faust DSP object v%s (sample = %s bits code = %s)", EXTERNAL_VERSION, ((sizeof(FAUSTFLOAT) == 4) ? "32" : "64"), getCodeSize()); post((char*)"Copyright (c) 2012-2020 Grame"); #endif Max_Meta1 meta1; tmp_dsp->metadata(&meta1); if (meta1.fCount > 0) { #ifdef POST Max_Meta2 meta2; post("------------------------------"); tmp_dsp->metadata(&meta2); post("------------------------------"); #endif } delete(tmp_dsp); #ifdef _WIN32 return 0; #endif } /********************END ARCHITECTURE SECTION (part 2/2)****************/ #endif
aa5ec7f975cd1cd5c5bf2cbc627d2989d7a33d36
a51f2693e411771dc089fe2fffe5656c92166f6b
/gui/actions/kalenderviewcontroler.h
ee5a3a7289634e47153c7674bff65ff37a0ded3e
[]
no_license
mdirks/stundenplaner
d4921b70772aee85f0ce84e9b8cbf1ca2f8620f1
ef8bd04d15941672669ee9732817e2cbe0d112f9
refs/heads/master
2021-09-11T14:36:57.387004
2021-09-05T12:49:56
2021-09-05T12:49:56
82,451,937
0
0
null
null
null
null
UTF-8
C++
false
false
1,954
h
/*************************************************************************** * Copyright (C) 2008 by Marcus Dirks * * [email protected] * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef KALENDERVIEWCONTROLER_H #define KALENDERVIEWCONTROLER_H #include "gui/forms/kalenderview.h" #include "weekmapviewcontroler.h" /** @author Marcus Dirks <[email protected]> */ class KalenderViewControler : public WeekMapViewControler { Q_OBJECT public: KalenderViewControler(KalenderView *kview); ~KalenderViewControler(); protected: virtual QMenu* getPopupMenu(); /* public slots: setPlanning(); */ private: bool isPlanning; public slots: void togglePlanning(); virtual void activateSelected(PObjectGraphicsItemNP *selectedItem); }; #endif
961224f0fca0d8138cf22a6201953efa9d9c333f
64d40840ef8f99455534f501b00cc13943ec6787
/testcheck.cc
c008a3adcb461db8b3b9b4782658eea0f1f9304c
[]
no_license
jb548319/CS2401_Project_1
34f4383ea614e96a4a3fe21764375bbf8547f228
ccde86a944d691f7bf93a86dcfb3fc0bf5882e00
refs/heads/main
2023-07-31T04:49:17.930098
2021-09-14T22:54:23
2021-09-14T22:54:23
402,238,887
0
0
null
null
null
null
UTF-8
C++
false
false
1,213
cc
/************************************************************************* The purpose of this little program is allow you to test the input and output functions and operators that you have written for the Check class. You should write these BEFORE you start developing the Checkbook class, and you should test your functions by compiling and running this little main. John Dolan Ohio University EECS September 2019 Patricia Lindner Ohio University EECS August 2021 *************************************************************************/ #include<fstream> #include <string> #include "check.h" using namespace std; int main(){ Check c1, c2; ifstream ifs; ofstream ofs; string file_name; string output_file; cout<<"Enter file name: "; cin >> file_name; ifs.open(file_name); if (ifs.fail()){ cout << "error"; exit(0); } ifs>>c2; ifs.close(); output_file = file_name.insert(file_name.find("."), "output"); ofs.open(output_file); ofs<<c2; ofs.close(); cout << "File " << output_file << " was created." << endl; cout<<"Write a check.\n"; cin>>c1; cout<<c1; return 0; }
63552cb703f5ac6fa59d03f7a704abe26259e9ef
2a0799c18d6e31398c6e0a3aaf614b33762b81b5
/Wheels.cpp
493d98d4bc2048086319ba6a037a513a7b887fa1
[]
no_license
dntAtMe/embedded-2018-2019
eb1d1e41a3a330c7a17c8a1daf41f03413b5e979
e74f6b03da5e50fc4cddfbcb7430f29f6bf4c48f
refs/heads/master
2020-05-30T18:06:50.643721
2019-06-02T20:12:34
2019-06-02T20:12:34
189,890,394
0
0
null
null
null
null
UTF-8
C++
false
false
4,216
cpp
#include <Arduino.h> #include "Wheels.h" #define SET_MOVEMENT(side,f,b) digitalWrite( side[0], f);\ digitalWrite( side[1], b) #define INTINPUT0 A0 #define INTINPUT1 A1 #define BEEPING_PIN 13 volatile int cnt0, cnt1; long int beepingFreq = 250000; void doBeep() { digitalWrite(BEEPING_PIN, digitalRead(BEEPING_PIN) ^ 1); } Wheels::Wheels() { // pinMode(BEEPING_PIN, OUTPUT); // cnt0=0; // cnt1=0; // speedLeft = 255; // speedRight = 255; // PCICR = 0x02; // PCMSK1 = 0x03; } void Wheels::attachRight(int pF, int pB, int pS) { pinMode(pF, OUTPUT); pinMode(pB, OUTPUT); pinMode(pS, OUTPUT); this->pinsRight[0] = pF; this->pinsRight[1] = pB; this->pinsRight[2] = pS; } void Wheels::attachLeft(int pF, int pB, int pS) { pinMode(pF, OUTPUT); pinMode(pB, OUTPUT); pinMode(pS, OUTPUT); this->pinsLeft[0] = pF; this->pinsLeft[1] = pB; this->pinsLeft[2] = pS; } void Wheels::setSpeedRight(uint8_t s) { analogWrite(this->pinsRight[2], s); } void Wheels::setSpeedLeft(uint8_t s) { analogWrite(this->pinsLeft[2], s); } void Wheels::changeSpeedLeft(uint8_t s) { analogWrite(this->pinsLeft[2], (analogRead(this->pinsLeft[2]) + s) % 255); } void Wheels::changeSpeedRight(uint8_t s) { analogWrite(this->pinsRight[2], (analogRead(this->pinsRight[2]) + s) % 255); } void Wheels::setSpeed(uint8_t s) { setSpeedLeft(s); setSpeedRight(s); } void Wheels::attach(int pRF, int pRB, int pRS, int pLF, int pLB, int pLS) { this->attachRight(pRF, pRB, pRS); this->attachLeft(pLF, pLB, pLS); } void Wheels::forwardLeft() { SET_MOVEMENT(pinsLeft, HIGH, LOW); } void Wheels::forwardRight() { SET_MOVEMENT(pinsRight, HIGH, LOW); } void Wheels::backLeft() { SET_MOVEMENT(pinsLeft, LOW, HIGH); } void Wheels::backRight() { SET_MOVEMENT(pinsRight, LOW, HIGH); } void Wheels::forward() { //digitalWrite(BEEPING_PIN, LOW); //Timer1.detachInterrupt(); this->forwardLeft(); this->forwardRight(); } void Wheels::back() { //Timer1.detachInterrupt(); //Timer1.attachInterrupt(doBeep, beepingFreq); this->backLeft(); this->backRight(); } void Wheels::stopLeft() { SET_MOVEMENT(pinsLeft, LOW, LOW); } void Wheels::stopRight() { SET_MOVEMENT(pinsRight, LOW, LOW); } void Wheels::stop() { //digitalWrite(BEEPING_PIN, LOW); //Timer1.detachInterrupt(); this->stopLeft(); this->stopRight(); } void delayCnt(int cnt) { while (cnt0 < cnt && cnt1 < cnt) { } cnt0 = cnt1 = 0; } void Wheels::moveForwardCnt(int cnt) { this->forward(); delayCnt(cnt); } void Wheels::moveBackCnt(int cnt) { this->back(); delayCnt(cnt); } void Wheels::moveForward(int d) { this->forward(); delay(d); } void Wheels::moveBack(int d) { this->back(); delay(d); } void Wheels::turnRightCnt(int cnt) { if (digitalRead(pinsRight[1]) == HIGH && digitalRead(pinsLeft[1]) == HIGH) { this->forwardLeft(); } if (digitalRead(pinsRight[0]) == HIGH && digitalRead(pinsLeft[0]) == HIGH) { this->backLeft(); } delayCnt(cnt); } void Wheels::turnLeftCnt(int cnt) { if (digitalRead(pinsRight[1]) == HIGH && digitalRead(pinsLeft[1]) == HIGH) { this->forwardRight(); } if (digitalRead(pinsRight[0]) == HIGH && digitalRead(pinsLeft[0]) == HIGH) { this->backRight(); } delayCnt(cnt); } void Wheels::test() { Serial.println(cnt0); Serial.println(cnt1); int c = 75; this->forward(); delay(1000); if (cnt0 > c) { cnt0 = 0; this->setSpeedLeft(this->speedLeft - 10); this->speedLeft -= 10; } else if (cnt0 < c) { cnt0 = 0; this->setSpeedLeft(this->speedLeft + 10); this->speedLeft += 10; } if (cnt1 > c) { cnt1 = 0; this->setSpeedRight(this->speedRight - 10); this->speedRight -= 10; } else if (cnt1 < c) { cnt1 = 0; this->setSpeedRight(this->speedRight + 10); this->speedRight += 10; } if ( this->speedRight > 255) this->speedRight = 255; if ( this->speedLeft > 255) this->speedLeft = 255; } //ISR(PCINT1_vect) //{ // if( (PINC & (1 << PC0)) ) // cnt0++; // if( (PINC & (1 << PC1)) ) // cnt1++; //}
cd89826a08896a4e070e25e6ca747031fc0984c2
818df5a6b667055f9c472e72ee0fc823f86de819
/628.cpp
fd3f0f9aca8f3f5448e2d232baa6e559ecbedf3f
[]
no_license
kalex1994/UVA
0a495e971fdcf92a785421a5c741bda915c21fca
cf45c6174cd299df14e8b52637c29ea7c3ec0f20
refs/heads/master
2021-01-01T19:47:13.630295
2016-10-15T19:14:46
2016-10-15T19:14:46
12,342,624
0
0
null
null
null
null
UTF-8
C++
false
false
874
cpp
#include <iostream> #include <cstdio> #include <string> #include <vector> #include <cstring> #include <algorithm> #include <sstream> #include <cmath> #include <map> #include <set> using namespace std; int n, m; string words[100]; string rule; void make_passwords(string password, size_t index) { if (index >= rule.length()) { cout << password << "\n"; return; } if (rule[index] == '0') { for(int i = 0; i <= 9; ++i) make_passwords(password + string(1, i + '0'), index + 1); } else { for(int i = 0; i < n; ++i) make_passwords(password + words[i], index + 1); } } int main() { #ifndef ONLINE_JUDGE freopen("E:\\IN.txt", "r", stdin); freopen("E:\\OUT.txt", "w", stdout); #endif while(cin >> n) { for(int i = 0; i < n; ++i) cin >> words[i]; cin >> m; while(m--) { cin >> rule; cout << "--\n"; make_passwords("", 0); } } }
bf740e82c4741a12601505416dc7413a2a228665
1a218c67ad04f99e52c37425fdb933b053af6244
/Ch09/exercise9.49.cpp
5cb899cb17a689aeb2b3a014a43cdfdb11e04bb1
[]
no_license
xiaonengmiao/Cpp_Primer
5a91cd223c9b0870f4ab9a45c6f679333a98fa20
be20a29b49be19f6959b7873077ea698da940bf6
refs/heads/master
2020-12-25T14:23:58.976008
2020-06-18T07:54:43
2020-06-18T07:54:43
66,343,361
1
1
null
null
null
null
UTF-8
C++
false
false
523
cpp
#include<iostream> #include<string> #include<fstream> using namespace std; int main() { string ascdes{"tdhfklbqypgj"}; ifstream ifs("../data/letter.txt"); if (!ifs) return -1; string word; string longword; unsigned len = 0; while (ifs >> word) { if (word.find_first_of(ascdes) == string::npos && word.size() > len) { len = word.size(); longword = word; } } cout << "The Longest word contains neigher ascenders nor descenders is " << longword; cout << endl; return 0; }
cb8530ce9488d87560491483ce3e980948394be2
c22c9454f6e31d94c24f8ee914a4985dd2836a05
/Vuforia HoloLens Sample (1)/test1/Il2CppOutputProject/Source/il2cppOutput/Bulk_UnityEngine.UnityWebRequestModule_0.cpp
b340d6f48793d55194540981b4e6b3df68592677
[]
no_license
carlosfelipetorres/GuitarAR
e3f4ae2b557700cb1e673fe694305d275c1ff027
e284d22a1e129ee4595e42359a7da513942ee1a6
refs/heads/master
2020-03-20T02:56:08.339018
2018-06-12T21:33:48
2018-06-12T21:34:13
137,125,726
0
0
null
null
null
null
UTF-8
C++
false
false
57,106
cpp
#include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <cstring> #include <string.h> #include <stdio.h> #include <cmath> #include <limits> #include <assert.h> #include <stdint.h> #include "class-internals.h" #include "codegen/il2cpp-codegen.h" #include "object-internals.h" // UnityEngine.Networking.DownloadHandler struct DownloadHandler_t1216180266; // System.String struct String_t; // System.Uri struct Uri_t19570940; // System.Text.RegularExpressions.Regex struct Regex_t1803876613; // System.Char[] struct CharU5BU5D_t1328083999; // System.Void struct Void_t1841601450; // System.Byte[] struct ByteU5BU5D_t3397334013; // System.UriParser struct UriParser_t1012511323; // System.Uri/UriInfo struct UriInfo_t4047916940; // System.Text.RegularExpressions.RegexRunnerFactory struct RegexRunnerFactory_t3902733837; // System.Collections.Hashtable struct Hashtable_t909839986; // System.String[] struct StringU5BU5D_t1642385972; // System.Text.RegularExpressions.ExclusiveReference struct ExclusiveReference_t708182869; // System.Text.RegularExpressions.SharedReference struct SharedReference_t2137668360; // System.Text.RegularExpressions.RegexCode struct RegexCode_t2469392150; // System.Collections.Generic.LinkedList`1<System.Text.RegularExpressions.CachedCodeEntry> struct LinkedList_1_t3858529280; extern RuntimeClass* GC_t2902933594_il2cpp_TypeInfo_var; extern const uint32_t DownloadHandler_Dispose_m918842992_MetadataUsageId; extern RuntimeClass* Uri_t19570940_il2cpp_TypeInfo_var; extern const uint32_t WebRequestUtils_RedirectTo_m675215376_MetadataUsageId; extern RuntimeClass* Regex_t1803876613_il2cpp_TypeInfo_var; extern RuntimeClass* WebRequestUtils_t4100941042_il2cpp_TypeInfo_var; extern Il2CppCodeGenString* _stringLiteral4071228867; extern const uint32_t WebRequestUtils__cctor_m4149625601_MetadataUsageId; #ifndef U3CMODULEU3E_T3783534225_H #define U3CMODULEU3E_T3783534225_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // <Module> struct U3CModuleU3E_t3783534225 { public: public: }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // U3CMODULEU3E_T3783534225_H #ifndef RUNTIMEOBJECT_H #define RUNTIMEOBJECT_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Object #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // RUNTIMEOBJECT_H #ifndef WEBREQUESTUTILS_T4100941042_H #define WEBREQUESTUTILS_T4100941042_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // UnityEngineInternal.WebRequestUtils struct WebRequestUtils_t4100941042 : public RuntimeObject { public: public: }; struct WebRequestUtils_t4100941042_StaticFields { public: // System.Text.RegularExpressions.Regex UnityEngineInternal.WebRequestUtils::domainRegex Regex_t1803876613 * ___domainRegex_0; public: inline static int32_t get_offset_of_domainRegex_0() { return static_cast<int32_t>(offsetof(WebRequestUtils_t4100941042_StaticFields, ___domainRegex_0)); } inline Regex_t1803876613 * get_domainRegex_0() const { return ___domainRegex_0; } inline Regex_t1803876613 ** get_address_of_domainRegex_0() { return &___domainRegex_0; } inline void set_domainRegex_0(Regex_t1803876613 * value) { ___domainRegex_0 = value; Il2CppCodeGenWriteBarrier((&___domainRegex_0), value); } }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // WEBREQUESTUTILS_T4100941042_H #ifndef STRING_T_H #define STRING_T_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.String struct String_t : public RuntimeObject { public: // System.Int32 System.String::m_stringLength int32_t ___m_stringLength_0; // System.Char System.String::m_firstChar Il2CppChar ___m_firstChar_1; public: inline static int32_t get_offset_of_m_stringLength_0() { return static_cast<int32_t>(offsetof(String_t, ___m_stringLength_0)); } inline int32_t get_m_stringLength_0() const { return ___m_stringLength_0; } inline int32_t* get_address_of_m_stringLength_0() { return &___m_stringLength_0; } inline void set_m_stringLength_0(int32_t value) { ___m_stringLength_0 = value; } inline static int32_t get_offset_of_m_firstChar_1() { return static_cast<int32_t>(offsetof(String_t, ___m_firstChar_1)); } inline Il2CppChar get_m_firstChar_1() const { return ___m_firstChar_1; } inline Il2CppChar* get_address_of_m_firstChar_1() { return &___m_firstChar_1; } inline void set_m_firstChar_1(Il2CppChar value) { ___m_firstChar_1 = value; } }; struct String_t_StaticFields { public: // System.String System.String::Empty String_t* ___Empty_5; public: inline static int32_t get_offset_of_Empty_5() { return static_cast<int32_t>(offsetof(String_t_StaticFields, ___Empty_5)); } inline String_t* get_Empty_5() const { return ___Empty_5; } inline String_t** get_address_of_Empty_5() { return &___Empty_5; } inline void set_Empty_5(String_t* value) { ___Empty_5 = value; Il2CppCodeGenWriteBarrier((&___Empty_5), value); } }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // STRING_T_H struct Il2CppArrayBounds; #ifndef RUNTIMEARRAY_H #define RUNTIMEARRAY_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Array #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // RUNTIMEARRAY_H #ifndef VALUETYPE_T3507792607_H #define VALUETYPE_T3507792607_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.ValueType struct ValueType_t3507792607 : public RuntimeObject { public: public: }; #ifdef __clang__ #pragma clang diagnostic pop #endif // Native definition for P/Invoke marshalling of System.ValueType struct ValueType_t3507792607_marshaled_pinvoke { }; // Native definition for COM marshalling of System.ValueType struct ValueType_t3507792607_marshaled_com { }; #endif // VALUETYPE_T3507792607_H #ifndef BOOLEAN_T3825574718_H #define BOOLEAN_T3825574718_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Boolean struct Boolean_t3825574718 { public: // System.Boolean System.Boolean::m_value bool ___m_value_0; public: inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(Boolean_t3825574718, ___m_value_0)); } inline bool get_m_value_0() const { return ___m_value_0; } inline bool* get_address_of_m_value_0() { return &___m_value_0; } inline void set_m_value_0(bool value) { ___m_value_0 = value; } }; struct Boolean_t3825574718_StaticFields { public: // System.String System.Boolean::TrueString String_t* ___TrueString_5; // System.String System.Boolean::FalseString String_t* ___FalseString_6; public: inline static int32_t get_offset_of_TrueString_5() { return static_cast<int32_t>(offsetof(Boolean_t3825574718_StaticFields, ___TrueString_5)); } inline String_t* get_TrueString_5() const { return ___TrueString_5; } inline String_t** get_address_of_TrueString_5() { return &___TrueString_5; } inline void set_TrueString_5(String_t* value) { ___TrueString_5 = value; Il2CppCodeGenWriteBarrier((&___TrueString_5), value); } inline static int32_t get_offset_of_FalseString_6() { return static_cast<int32_t>(offsetof(Boolean_t3825574718_StaticFields, ___FalseString_6)); } inline String_t* get_FalseString_6() const { return ___FalseString_6; } inline String_t** get_address_of_FalseString_6() { return &___FalseString_6; } inline void set_FalseString_6(String_t* value) { ___FalseString_6 = value; Il2CppCodeGenWriteBarrier((&___FalseString_6), value); } }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // BOOLEAN_T3825574718_H #ifndef INT32_T2071877448_H #define INT32_T2071877448_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Int32 struct Int32_t2071877448 { public: // System.Int32 System.Int32::m_value int32_t ___m_value_0; public: inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(Int32_t2071877448, ___m_value_0)); } inline int32_t get_m_value_0() const { return ___m_value_0; } inline int32_t* get_address_of_m_value_0() { return &___m_value_0; } inline void set_m_value_0(int32_t value) { ___m_value_0 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // INT32_T2071877448_H #ifndef ENUM_T2459695545_H #define ENUM_T2459695545_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Enum struct Enum_t2459695545 : public ValueType_t3507792607 { public: public: }; struct Enum_t2459695545_StaticFields { public: // System.Char[] System.Enum::enumSeperatorCharArray CharU5BU5D_t1328083999* ___enumSeperatorCharArray_0; public: inline static int32_t get_offset_of_enumSeperatorCharArray_0() { return static_cast<int32_t>(offsetof(Enum_t2459695545_StaticFields, ___enumSeperatorCharArray_0)); } inline CharU5BU5D_t1328083999* get_enumSeperatorCharArray_0() const { return ___enumSeperatorCharArray_0; } inline CharU5BU5D_t1328083999** get_address_of_enumSeperatorCharArray_0() { return &___enumSeperatorCharArray_0; } inline void set_enumSeperatorCharArray_0(CharU5BU5D_t1328083999* value) { ___enumSeperatorCharArray_0 = value; Il2CppCodeGenWriteBarrier((&___enumSeperatorCharArray_0), value); } }; #ifdef __clang__ #pragma clang diagnostic pop #endif // Native definition for P/Invoke marshalling of System.Enum struct Enum_t2459695545_marshaled_pinvoke { }; // Native definition for COM marshalling of System.Enum struct Enum_t2459695545_marshaled_com { }; #endif // ENUM_T2459695545_H #ifndef INTPTR_T_H #define INTPTR_T_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.IntPtr struct IntPtr_t { public: // System.Void* System.IntPtr::m_value void* ___m_value_0; public: inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(IntPtr_t, ___m_value_0)); } inline void* get_m_value_0() const { return ___m_value_0; } inline void** get_address_of_m_value_0() { return &___m_value_0; } inline void set_m_value_0(void* value) { ___m_value_0 = value; } }; struct IntPtr_t_StaticFields { public: // System.IntPtr System.IntPtr::Zero intptr_t ___Zero_1; public: inline static int32_t get_offset_of_Zero_1() { return static_cast<int32_t>(offsetof(IntPtr_t_StaticFields, ___Zero_1)); } inline intptr_t get_Zero_1() const { return ___Zero_1; } inline intptr_t* get_address_of_Zero_1() { return &___Zero_1; } inline void set_Zero_1(intptr_t value) { ___Zero_1 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // INTPTR_T_H #ifndef VOID_T1841601450_H #define VOID_T1841601450_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Void struct Void_t1841601450 { public: union { struct { }; uint8_t Void_t1841601450__padding[1]; }; public: }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // VOID_T1841601450_H #ifndef CHAR_T3454481338_H #define CHAR_T3454481338_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Char struct Char_t3454481338 { public: // System.Char System.Char::m_value Il2CppChar ___m_value_0; public: inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(Char_t3454481338, ___m_value_0)); } inline Il2CppChar get_m_value_0() const { return ___m_value_0; } inline Il2CppChar* get_address_of_m_value_0() { return &___m_value_0; } inline void set_m_value_0(Il2CppChar value) { ___m_value_0 = value; } }; struct Char_t3454481338_StaticFields { public: // System.Byte[] System.Char::categoryForLatin1 ByteU5BU5D_t3397334013* ___categoryForLatin1_3; public: inline static int32_t get_offset_of_categoryForLatin1_3() { return static_cast<int32_t>(offsetof(Char_t3454481338_StaticFields, ___categoryForLatin1_3)); } inline ByteU5BU5D_t3397334013* get_categoryForLatin1_3() const { return ___categoryForLatin1_3; } inline ByteU5BU5D_t3397334013** get_address_of_categoryForLatin1_3() { return &___categoryForLatin1_3; } inline void set_categoryForLatin1_3(ByteU5BU5D_t3397334013* value) { ___categoryForLatin1_3 = value; Il2CppCodeGenWriteBarrier((&___categoryForLatin1_3), value); } }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // CHAR_T3454481338_H #ifndef REGEXOPTIONS_T2418259727_H #define REGEXOPTIONS_T2418259727_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Text.RegularExpressions.RegexOptions struct RegexOptions_t2418259727 { public: // System.Int32 System.Text.RegularExpressions.RegexOptions::value__ int32_t ___value___2; public: inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(RegexOptions_t2418259727, ___value___2)); } inline int32_t get_value___2() const { return ___value___2; } inline int32_t* get_address_of_value___2() { return &___value___2; } inline void set_value___2(int32_t value) { ___value___2 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // REGEXOPTIONS_T2418259727_H #ifndef FLAGS_T455382755_H #define FLAGS_T455382755_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Uri/Flags struct Flags_t455382755 { public: // System.UInt64 System.Uri/Flags::value__ uint64_t ___value___2; public: inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(Flags_t455382755, ___value___2)); } inline uint64_t get_value___2() const { return ___value___2; } inline uint64_t* get_address_of_value___2() { return &___value___2; } inline void set_value___2(uint64_t value) { ___value___2 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // FLAGS_T455382755_H #ifndef URIIDNSCOPE_T761062207_H #define URIIDNSCOPE_T761062207_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.UriIdnScope struct UriIdnScope_t761062207 { public: // System.Int32 System.UriIdnScope::value__ int32_t ___value___2; public: inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(UriIdnScope_t761062207, ___value___2)); } inline int32_t get_value___2() const { return ___value___2; } inline int32_t* get_address_of_value___2() { return &___value___2; } inline void set_value___2(int32_t value) { ___value___2 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // URIIDNSCOPE_T761062207_H #ifndef TIMESPAN_T3430258949_H #define TIMESPAN_T3430258949_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.TimeSpan struct TimeSpan_t3430258949 { public: // System.Int64 System.TimeSpan::_ticks int64_t ____ticks_3; public: inline static int32_t get_offset_of__ticks_3() { return static_cast<int32_t>(offsetof(TimeSpan_t3430258949, ____ticks_3)); } inline int64_t get__ticks_3() const { return ____ticks_3; } inline int64_t* get_address_of__ticks_3() { return &____ticks_3; } inline void set__ticks_3(int64_t value) { ____ticks_3 = value; } }; struct TimeSpan_t3430258949_StaticFields { public: // System.TimeSpan System.TimeSpan::Zero TimeSpan_t3430258949 ___Zero_0; // System.TimeSpan System.TimeSpan::MaxValue TimeSpan_t3430258949 ___MaxValue_1; // System.TimeSpan System.TimeSpan::MinValue TimeSpan_t3430258949 ___MinValue_2; // System.Boolean modreq(System.Runtime.CompilerServices.IsVolatile) System.TimeSpan::_legacyConfigChecked bool ____legacyConfigChecked_4; // System.Boolean modreq(System.Runtime.CompilerServices.IsVolatile) System.TimeSpan::_legacyMode bool ____legacyMode_5; public: inline static int32_t get_offset_of_Zero_0() { return static_cast<int32_t>(offsetof(TimeSpan_t3430258949_StaticFields, ___Zero_0)); } inline TimeSpan_t3430258949 get_Zero_0() const { return ___Zero_0; } inline TimeSpan_t3430258949 * get_address_of_Zero_0() { return &___Zero_0; } inline void set_Zero_0(TimeSpan_t3430258949 value) { ___Zero_0 = value; } inline static int32_t get_offset_of_MaxValue_1() { return static_cast<int32_t>(offsetof(TimeSpan_t3430258949_StaticFields, ___MaxValue_1)); } inline TimeSpan_t3430258949 get_MaxValue_1() const { return ___MaxValue_1; } inline TimeSpan_t3430258949 * get_address_of_MaxValue_1() { return &___MaxValue_1; } inline void set_MaxValue_1(TimeSpan_t3430258949 value) { ___MaxValue_1 = value; } inline static int32_t get_offset_of_MinValue_2() { return static_cast<int32_t>(offsetof(TimeSpan_t3430258949_StaticFields, ___MinValue_2)); } inline TimeSpan_t3430258949 get_MinValue_2() const { return ___MinValue_2; } inline TimeSpan_t3430258949 * get_address_of_MinValue_2() { return &___MinValue_2; } inline void set_MinValue_2(TimeSpan_t3430258949 value) { ___MinValue_2 = value; } inline static int32_t get_offset_of__legacyConfigChecked_4() { return static_cast<int32_t>(offsetof(TimeSpan_t3430258949_StaticFields, ____legacyConfigChecked_4)); } inline bool get__legacyConfigChecked_4() const { return ____legacyConfigChecked_4; } inline bool* get_address_of__legacyConfigChecked_4() { return &____legacyConfigChecked_4; } inline void set__legacyConfigChecked_4(bool value) { ____legacyConfigChecked_4 = value; } inline static int32_t get_offset_of__legacyMode_5() { return static_cast<int32_t>(offsetof(TimeSpan_t3430258949_StaticFields, ____legacyMode_5)); } inline bool get__legacyMode_5() const { return ____legacyMode_5; } inline bool* get_address_of__legacyMode_5() { return &____legacyMode_5; } inline void set__legacyMode_5(bool value) { ____legacyMode_5 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // TIMESPAN_T3430258949_H #ifndef DOWNLOADHANDLER_T1216180266_H #define DOWNLOADHANDLER_T1216180266_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // UnityEngine.Networking.DownloadHandler struct DownloadHandler_t1216180266 : public RuntimeObject { public: // System.IntPtr UnityEngine.Networking.DownloadHandler::m_Ptr intptr_t ___m_Ptr_0; public: inline static int32_t get_offset_of_m_Ptr_0() { return static_cast<int32_t>(offsetof(DownloadHandler_t1216180266, ___m_Ptr_0)); } inline intptr_t get_m_Ptr_0() const { return ___m_Ptr_0; } inline intptr_t* get_address_of_m_Ptr_0() { return &___m_Ptr_0; } inline void set_m_Ptr_0(intptr_t value) { ___m_Ptr_0 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif // Native definition for P/Invoke marshalling of UnityEngine.Networking.DownloadHandler struct DownloadHandler_t1216180266_marshaled_pinvoke { intptr_t ___m_Ptr_0; }; // Native definition for COM marshalling of UnityEngine.Networking.DownloadHandler struct DownloadHandler_t1216180266_marshaled_com { intptr_t ___m_Ptr_0; }; #endif // DOWNLOADHANDLER_T1216180266_H #ifndef URIKIND_T1128731744_H #define URIKIND_T1128731744_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.UriKind struct UriKind_t1128731744 { public: // System.Int32 System.UriKind::value__ int32_t ___value___2; public: inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(UriKind_t1128731744, ___value___2)); } inline int32_t get_value___2() const { return ___value___2; } inline int32_t* get_address_of_value___2() { return &___value___2; } inline void set_value___2(int32_t value) { ___value___2 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // URIKIND_T1128731744_H #ifndef URI_T19570940_H #define URI_T19570940_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Uri struct Uri_t19570940 : public RuntimeObject { public: // System.String System.Uri::m_String String_t* ___m_String_13; // System.String System.Uri::m_originalUnicodeString String_t* ___m_originalUnicodeString_14; // System.UriParser System.Uri::m_Syntax UriParser_t1012511323 * ___m_Syntax_15; // System.String System.Uri::m_DnsSafeHost String_t* ___m_DnsSafeHost_16; // System.Uri/Flags System.Uri::m_Flags uint64_t ___m_Flags_17; // System.Uri/UriInfo System.Uri::m_Info UriInfo_t4047916940 * ___m_Info_18; // System.Boolean System.Uri::m_iriParsing bool ___m_iriParsing_19; public: inline static int32_t get_offset_of_m_String_13() { return static_cast<int32_t>(offsetof(Uri_t19570940, ___m_String_13)); } inline String_t* get_m_String_13() const { return ___m_String_13; } inline String_t** get_address_of_m_String_13() { return &___m_String_13; } inline void set_m_String_13(String_t* value) { ___m_String_13 = value; Il2CppCodeGenWriteBarrier((&___m_String_13), value); } inline static int32_t get_offset_of_m_originalUnicodeString_14() { return static_cast<int32_t>(offsetof(Uri_t19570940, ___m_originalUnicodeString_14)); } inline String_t* get_m_originalUnicodeString_14() const { return ___m_originalUnicodeString_14; } inline String_t** get_address_of_m_originalUnicodeString_14() { return &___m_originalUnicodeString_14; } inline void set_m_originalUnicodeString_14(String_t* value) { ___m_originalUnicodeString_14 = value; Il2CppCodeGenWriteBarrier((&___m_originalUnicodeString_14), value); } inline static int32_t get_offset_of_m_Syntax_15() { return static_cast<int32_t>(offsetof(Uri_t19570940, ___m_Syntax_15)); } inline UriParser_t1012511323 * get_m_Syntax_15() const { return ___m_Syntax_15; } inline UriParser_t1012511323 ** get_address_of_m_Syntax_15() { return &___m_Syntax_15; } inline void set_m_Syntax_15(UriParser_t1012511323 * value) { ___m_Syntax_15 = value; Il2CppCodeGenWriteBarrier((&___m_Syntax_15), value); } inline static int32_t get_offset_of_m_DnsSafeHost_16() { return static_cast<int32_t>(offsetof(Uri_t19570940, ___m_DnsSafeHost_16)); } inline String_t* get_m_DnsSafeHost_16() const { return ___m_DnsSafeHost_16; } inline String_t** get_address_of_m_DnsSafeHost_16() { return &___m_DnsSafeHost_16; } inline void set_m_DnsSafeHost_16(String_t* value) { ___m_DnsSafeHost_16 = value; Il2CppCodeGenWriteBarrier((&___m_DnsSafeHost_16), value); } inline static int32_t get_offset_of_m_Flags_17() { return static_cast<int32_t>(offsetof(Uri_t19570940, ___m_Flags_17)); } inline uint64_t get_m_Flags_17() const { return ___m_Flags_17; } inline uint64_t* get_address_of_m_Flags_17() { return &___m_Flags_17; } inline void set_m_Flags_17(uint64_t value) { ___m_Flags_17 = value; } inline static int32_t get_offset_of_m_Info_18() { return static_cast<int32_t>(offsetof(Uri_t19570940, ___m_Info_18)); } inline UriInfo_t4047916940 * get_m_Info_18() const { return ___m_Info_18; } inline UriInfo_t4047916940 ** get_address_of_m_Info_18() { return &___m_Info_18; } inline void set_m_Info_18(UriInfo_t4047916940 * value) { ___m_Info_18 = value; Il2CppCodeGenWriteBarrier((&___m_Info_18), value); } inline static int32_t get_offset_of_m_iriParsing_19() { return static_cast<int32_t>(offsetof(Uri_t19570940, ___m_iriParsing_19)); } inline bool get_m_iriParsing_19() const { return ___m_iriParsing_19; } inline bool* get_address_of_m_iriParsing_19() { return &___m_iriParsing_19; } inline void set_m_iriParsing_19(bool value) { ___m_iriParsing_19 = value; } }; struct Uri_t19570940_StaticFields { public: // System.String System.Uri::UriSchemeFile String_t* ___UriSchemeFile_0; // System.String System.Uri::UriSchemeFtp String_t* ___UriSchemeFtp_1; // System.String System.Uri::UriSchemeGopher String_t* ___UriSchemeGopher_2; // System.String System.Uri::UriSchemeHttp String_t* ___UriSchemeHttp_3; // System.String System.Uri::UriSchemeHttps String_t* ___UriSchemeHttps_4; // System.String System.Uri::UriSchemeWs String_t* ___UriSchemeWs_5; // System.String System.Uri::UriSchemeWss String_t* ___UriSchemeWss_6; // System.String System.Uri::UriSchemeMailto String_t* ___UriSchemeMailto_7; // System.String System.Uri::UriSchemeNews String_t* ___UriSchemeNews_8; // System.String System.Uri::UriSchemeNntp String_t* ___UriSchemeNntp_9; // System.String System.Uri::UriSchemeNetTcp String_t* ___UriSchemeNetTcp_10; // System.String System.Uri::UriSchemeNetPipe String_t* ___UriSchemeNetPipe_11; // System.String System.Uri::SchemeDelimiter String_t* ___SchemeDelimiter_12; // System.Boolean modreq(System.Runtime.CompilerServices.IsVolatile) System.Uri::s_ConfigInitialized bool ___s_ConfigInitialized_20; // System.Boolean modreq(System.Runtime.CompilerServices.IsVolatile) System.Uri::s_ConfigInitializing bool ___s_ConfigInitializing_21; // System.UriIdnScope modreq(System.Runtime.CompilerServices.IsVolatile) System.Uri::s_IdnScope int32_t ___s_IdnScope_22; // System.Boolean modreq(System.Runtime.CompilerServices.IsVolatile) System.Uri::s_IriParsing bool ___s_IriParsing_23; // System.Boolean System.Uri::useDotNetRelativeOrAbsolute bool ___useDotNetRelativeOrAbsolute_24; // System.Boolean System.Uri::IsWindowsFileSystem bool ___IsWindowsFileSystem_25; // System.Object System.Uri::s_initLock RuntimeObject * ___s_initLock_26; // System.Char[] System.Uri::HexLowerChars CharU5BU5D_t1328083999* ___HexLowerChars_27; // System.Char[] System.Uri::_WSchars CharU5BU5D_t1328083999* ____WSchars_28; public: inline static int32_t get_offset_of_UriSchemeFile_0() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___UriSchemeFile_0)); } inline String_t* get_UriSchemeFile_0() const { return ___UriSchemeFile_0; } inline String_t** get_address_of_UriSchemeFile_0() { return &___UriSchemeFile_0; } inline void set_UriSchemeFile_0(String_t* value) { ___UriSchemeFile_0 = value; Il2CppCodeGenWriteBarrier((&___UriSchemeFile_0), value); } inline static int32_t get_offset_of_UriSchemeFtp_1() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___UriSchemeFtp_1)); } inline String_t* get_UriSchemeFtp_1() const { return ___UriSchemeFtp_1; } inline String_t** get_address_of_UriSchemeFtp_1() { return &___UriSchemeFtp_1; } inline void set_UriSchemeFtp_1(String_t* value) { ___UriSchemeFtp_1 = value; Il2CppCodeGenWriteBarrier((&___UriSchemeFtp_1), value); } inline static int32_t get_offset_of_UriSchemeGopher_2() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___UriSchemeGopher_2)); } inline String_t* get_UriSchemeGopher_2() const { return ___UriSchemeGopher_2; } inline String_t** get_address_of_UriSchemeGopher_2() { return &___UriSchemeGopher_2; } inline void set_UriSchemeGopher_2(String_t* value) { ___UriSchemeGopher_2 = value; Il2CppCodeGenWriteBarrier((&___UriSchemeGopher_2), value); } inline static int32_t get_offset_of_UriSchemeHttp_3() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___UriSchemeHttp_3)); } inline String_t* get_UriSchemeHttp_3() const { return ___UriSchemeHttp_3; } inline String_t** get_address_of_UriSchemeHttp_3() { return &___UriSchemeHttp_3; } inline void set_UriSchemeHttp_3(String_t* value) { ___UriSchemeHttp_3 = value; Il2CppCodeGenWriteBarrier((&___UriSchemeHttp_3), value); } inline static int32_t get_offset_of_UriSchemeHttps_4() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___UriSchemeHttps_4)); } inline String_t* get_UriSchemeHttps_4() const { return ___UriSchemeHttps_4; } inline String_t** get_address_of_UriSchemeHttps_4() { return &___UriSchemeHttps_4; } inline void set_UriSchemeHttps_4(String_t* value) { ___UriSchemeHttps_4 = value; Il2CppCodeGenWriteBarrier((&___UriSchemeHttps_4), value); } inline static int32_t get_offset_of_UriSchemeWs_5() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___UriSchemeWs_5)); } inline String_t* get_UriSchemeWs_5() const { return ___UriSchemeWs_5; } inline String_t** get_address_of_UriSchemeWs_5() { return &___UriSchemeWs_5; } inline void set_UriSchemeWs_5(String_t* value) { ___UriSchemeWs_5 = value; Il2CppCodeGenWriteBarrier((&___UriSchemeWs_5), value); } inline static int32_t get_offset_of_UriSchemeWss_6() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___UriSchemeWss_6)); } inline String_t* get_UriSchemeWss_6() const { return ___UriSchemeWss_6; } inline String_t** get_address_of_UriSchemeWss_6() { return &___UriSchemeWss_6; } inline void set_UriSchemeWss_6(String_t* value) { ___UriSchemeWss_6 = value; Il2CppCodeGenWriteBarrier((&___UriSchemeWss_6), value); } inline static int32_t get_offset_of_UriSchemeMailto_7() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___UriSchemeMailto_7)); } inline String_t* get_UriSchemeMailto_7() const { return ___UriSchemeMailto_7; } inline String_t** get_address_of_UriSchemeMailto_7() { return &___UriSchemeMailto_7; } inline void set_UriSchemeMailto_7(String_t* value) { ___UriSchemeMailto_7 = value; Il2CppCodeGenWriteBarrier((&___UriSchemeMailto_7), value); } inline static int32_t get_offset_of_UriSchemeNews_8() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___UriSchemeNews_8)); } inline String_t* get_UriSchemeNews_8() const { return ___UriSchemeNews_8; } inline String_t** get_address_of_UriSchemeNews_8() { return &___UriSchemeNews_8; } inline void set_UriSchemeNews_8(String_t* value) { ___UriSchemeNews_8 = value; Il2CppCodeGenWriteBarrier((&___UriSchemeNews_8), value); } inline static int32_t get_offset_of_UriSchemeNntp_9() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___UriSchemeNntp_9)); } inline String_t* get_UriSchemeNntp_9() const { return ___UriSchemeNntp_9; } inline String_t** get_address_of_UriSchemeNntp_9() { return &___UriSchemeNntp_9; } inline void set_UriSchemeNntp_9(String_t* value) { ___UriSchemeNntp_9 = value; Il2CppCodeGenWriteBarrier((&___UriSchemeNntp_9), value); } inline static int32_t get_offset_of_UriSchemeNetTcp_10() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___UriSchemeNetTcp_10)); } inline String_t* get_UriSchemeNetTcp_10() const { return ___UriSchemeNetTcp_10; } inline String_t** get_address_of_UriSchemeNetTcp_10() { return &___UriSchemeNetTcp_10; } inline void set_UriSchemeNetTcp_10(String_t* value) { ___UriSchemeNetTcp_10 = value; Il2CppCodeGenWriteBarrier((&___UriSchemeNetTcp_10), value); } inline static int32_t get_offset_of_UriSchemeNetPipe_11() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___UriSchemeNetPipe_11)); } inline String_t* get_UriSchemeNetPipe_11() const { return ___UriSchemeNetPipe_11; } inline String_t** get_address_of_UriSchemeNetPipe_11() { return &___UriSchemeNetPipe_11; } inline void set_UriSchemeNetPipe_11(String_t* value) { ___UriSchemeNetPipe_11 = value; Il2CppCodeGenWriteBarrier((&___UriSchemeNetPipe_11), value); } inline static int32_t get_offset_of_SchemeDelimiter_12() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___SchemeDelimiter_12)); } inline String_t* get_SchemeDelimiter_12() const { return ___SchemeDelimiter_12; } inline String_t** get_address_of_SchemeDelimiter_12() { return &___SchemeDelimiter_12; } inline void set_SchemeDelimiter_12(String_t* value) { ___SchemeDelimiter_12 = value; Il2CppCodeGenWriteBarrier((&___SchemeDelimiter_12), value); } inline static int32_t get_offset_of_s_ConfigInitialized_20() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___s_ConfigInitialized_20)); } inline bool get_s_ConfigInitialized_20() const { return ___s_ConfigInitialized_20; } inline bool* get_address_of_s_ConfigInitialized_20() { return &___s_ConfigInitialized_20; } inline void set_s_ConfigInitialized_20(bool value) { ___s_ConfigInitialized_20 = value; } inline static int32_t get_offset_of_s_ConfigInitializing_21() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___s_ConfigInitializing_21)); } inline bool get_s_ConfigInitializing_21() const { return ___s_ConfigInitializing_21; } inline bool* get_address_of_s_ConfigInitializing_21() { return &___s_ConfigInitializing_21; } inline void set_s_ConfigInitializing_21(bool value) { ___s_ConfigInitializing_21 = value; } inline static int32_t get_offset_of_s_IdnScope_22() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___s_IdnScope_22)); } inline int32_t get_s_IdnScope_22() const { return ___s_IdnScope_22; } inline int32_t* get_address_of_s_IdnScope_22() { return &___s_IdnScope_22; } inline void set_s_IdnScope_22(int32_t value) { ___s_IdnScope_22 = value; } inline static int32_t get_offset_of_s_IriParsing_23() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___s_IriParsing_23)); } inline bool get_s_IriParsing_23() const { return ___s_IriParsing_23; } inline bool* get_address_of_s_IriParsing_23() { return &___s_IriParsing_23; } inline void set_s_IriParsing_23(bool value) { ___s_IriParsing_23 = value; } inline static int32_t get_offset_of_useDotNetRelativeOrAbsolute_24() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___useDotNetRelativeOrAbsolute_24)); } inline bool get_useDotNetRelativeOrAbsolute_24() const { return ___useDotNetRelativeOrAbsolute_24; } inline bool* get_address_of_useDotNetRelativeOrAbsolute_24() { return &___useDotNetRelativeOrAbsolute_24; } inline void set_useDotNetRelativeOrAbsolute_24(bool value) { ___useDotNetRelativeOrAbsolute_24 = value; } inline static int32_t get_offset_of_IsWindowsFileSystem_25() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___IsWindowsFileSystem_25)); } inline bool get_IsWindowsFileSystem_25() const { return ___IsWindowsFileSystem_25; } inline bool* get_address_of_IsWindowsFileSystem_25() { return &___IsWindowsFileSystem_25; } inline void set_IsWindowsFileSystem_25(bool value) { ___IsWindowsFileSystem_25 = value; } inline static int32_t get_offset_of_s_initLock_26() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___s_initLock_26)); } inline RuntimeObject * get_s_initLock_26() const { return ___s_initLock_26; } inline RuntimeObject ** get_address_of_s_initLock_26() { return &___s_initLock_26; } inline void set_s_initLock_26(RuntimeObject * value) { ___s_initLock_26 = value; Il2CppCodeGenWriteBarrier((&___s_initLock_26), value); } inline static int32_t get_offset_of_HexLowerChars_27() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ___HexLowerChars_27)); } inline CharU5BU5D_t1328083999* get_HexLowerChars_27() const { return ___HexLowerChars_27; } inline CharU5BU5D_t1328083999** get_address_of_HexLowerChars_27() { return &___HexLowerChars_27; } inline void set_HexLowerChars_27(CharU5BU5D_t1328083999* value) { ___HexLowerChars_27 = value; Il2CppCodeGenWriteBarrier((&___HexLowerChars_27), value); } inline static int32_t get_offset_of__WSchars_28() { return static_cast<int32_t>(offsetof(Uri_t19570940_StaticFields, ____WSchars_28)); } inline CharU5BU5D_t1328083999* get__WSchars_28() const { return ____WSchars_28; } inline CharU5BU5D_t1328083999** get_address_of__WSchars_28() { return &____WSchars_28; } inline void set__WSchars_28(CharU5BU5D_t1328083999* value) { ____WSchars_28 = value; Il2CppCodeGenWriteBarrier((&____WSchars_28), value); } }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // URI_T19570940_H #ifndef REGEX_T1803876613_H #define REGEX_T1803876613_H #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Text.RegularExpressions.Regex struct Regex_t1803876613 : public RuntimeObject { public: // System.String System.Text.RegularExpressions.Regex::pattern String_t* ___pattern_0; // System.Text.RegularExpressions.RegexRunnerFactory System.Text.RegularExpressions.Regex::factory RegexRunnerFactory_t3902733837 * ___factory_1; // System.Text.RegularExpressions.RegexOptions System.Text.RegularExpressions.Regex::roptions int32_t ___roptions_2; // System.TimeSpan System.Text.RegularExpressions.Regex::internalMatchTimeout TimeSpan_t3430258949 ___internalMatchTimeout_5; // System.Collections.Hashtable System.Text.RegularExpressions.Regex::caps Hashtable_t909839986 * ___caps_8; // System.Collections.Hashtable System.Text.RegularExpressions.Regex::capnames Hashtable_t909839986 * ___capnames_9; // System.String[] System.Text.RegularExpressions.Regex::capslist StringU5BU5D_t1642385972* ___capslist_10; // System.Int32 System.Text.RegularExpressions.Regex::capsize int32_t ___capsize_11; // System.Text.RegularExpressions.ExclusiveReference System.Text.RegularExpressions.Regex::runnerref ExclusiveReference_t708182869 * ___runnerref_12; // System.Text.RegularExpressions.SharedReference System.Text.RegularExpressions.Regex::replref SharedReference_t2137668360 * ___replref_13; // System.Text.RegularExpressions.RegexCode System.Text.RegularExpressions.Regex::code RegexCode_t2469392150 * ___code_14; // System.Boolean System.Text.RegularExpressions.Regex::refsInitialized bool ___refsInitialized_15; public: inline static int32_t get_offset_of_pattern_0() { return static_cast<int32_t>(offsetof(Regex_t1803876613, ___pattern_0)); } inline String_t* get_pattern_0() const { return ___pattern_0; } inline String_t** get_address_of_pattern_0() { return &___pattern_0; } inline void set_pattern_0(String_t* value) { ___pattern_0 = value; Il2CppCodeGenWriteBarrier((&___pattern_0), value); } inline static int32_t get_offset_of_factory_1() { return static_cast<int32_t>(offsetof(Regex_t1803876613, ___factory_1)); } inline RegexRunnerFactory_t3902733837 * get_factory_1() const { return ___factory_1; } inline RegexRunnerFactory_t3902733837 ** get_address_of_factory_1() { return &___factory_1; } inline void set_factory_1(RegexRunnerFactory_t3902733837 * value) { ___factory_1 = value; Il2CppCodeGenWriteBarrier((&___factory_1), value); } inline static int32_t get_offset_of_roptions_2() { return static_cast<int32_t>(offsetof(Regex_t1803876613, ___roptions_2)); } inline int32_t get_roptions_2() const { return ___roptions_2; } inline int32_t* get_address_of_roptions_2() { return &___roptions_2; } inline void set_roptions_2(int32_t value) { ___roptions_2 = value; } inline static int32_t get_offset_of_internalMatchTimeout_5() { return static_cast<int32_t>(offsetof(Regex_t1803876613, ___internalMatchTimeout_5)); } inline TimeSpan_t3430258949 get_internalMatchTimeout_5() const { return ___internalMatchTimeout_5; } inline TimeSpan_t3430258949 * get_address_of_internalMatchTimeout_5() { return &___internalMatchTimeout_5; } inline void set_internalMatchTimeout_5(TimeSpan_t3430258949 value) { ___internalMatchTimeout_5 = value; } inline static int32_t get_offset_of_caps_8() { return static_cast<int32_t>(offsetof(Regex_t1803876613, ___caps_8)); } inline Hashtable_t909839986 * get_caps_8() const { return ___caps_8; } inline Hashtable_t909839986 ** get_address_of_caps_8() { return &___caps_8; } inline void set_caps_8(Hashtable_t909839986 * value) { ___caps_8 = value; Il2CppCodeGenWriteBarrier((&___caps_8), value); } inline static int32_t get_offset_of_capnames_9() { return static_cast<int32_t>(offsetof(Regex_t1803876613, ___capnames_9)); } inline Hashtable_t909839986 * get_capnames_9() const { return ___capnames_9; } inline Hashtable_t909839986 ** get_address_of_capnames_9() { return &___capnames_9; } inline void set_capnames_9(Hashtable_t909839986 * value) { ___capnames_9 = value; Il2CppCodeGenWriteBarrier((&___capnames_9), value); } inline static int32_t get_offset_of_capslist_10() { return static_cast<int32_t>(offsetof(Regex_t1803876613, ___capslist_10)); } inline StringU5BU5D_t1642385972* get_capslist_10() const { return ___capslist_10; } inline StringU5BU5D_t1642385972** get_address_of_capslist_10() { return &___capslist_10; } inline void set_capslist_10(StringU5BU5D_t1642385972* value) { ___capslist_10 = value; Il2CppCodeGenWriteBarrier((&___capslist_10), value); } inline static int32_t get_offset_of_capsize_11() { return static_cast<int32_t>(offsetof(Regex_t1803876613, ___capsize_11)); } inline int32_t get_capsize_11() const { return ___capsize_11; } inline int32_t* get_address_of_capsize_11() { return &___capsize_11; } inline void set_capsize_11(int32_t value) { ___capsize_11 = value; } inline static int32_t get_offset_of_runnerref_12() { return static_cast<int32_t>(offsetof(Regex_t1803876613, ___runnerref_12)); } inline ExclusiveReference_t708182869 * get_runnerref_12() const { return ___runnerref_12; } inline ExclusiveReference_t708182869 ** get_address_of_runnerref_12() { return &___runnerref_12; } inline void set_runnerref_12(ExclusiveReference_t708182869 * value) { ___runnerref_12 = value; Il2CppCodeGenWriteBarrier((&___runnerref_12), value); } inline static int32_t get_offset_of_replref_13() { return static_cast<int32_t>(offsetof(Regex_t1803876613, ___replref_13)); } inline SharedReference_t2137668360 * get_replref_13() const { return ___replref_13; } inline SharedReference_t2137668360 ** get_address_of_replref_13() { return &___replref_13; } inline void set_replref_13(SharedReference_t2137668360 * value) { ___replref_13 = value; Il2CppCodeGenWriteBarrier((&___replref_13), value); } inline static int32_t get_offset_of_code_14() { return static_cast<int32_t>(offsetof(Regex_t1803876613, ___code_14)); } inline RegexCode_t2469392150 * get_code_14() const { return ___code_14; } inline RegexCode_t2469392150 ** get_address_of_code_14() { return &___code_14; } inline void set_code_14(RegexCode_t2469392150 * value) { ___code_14 = value; Il2CppCodeGenWriteBarrier((&___code_14), value); } inline static int32_t get_offset_of_refsInitialized_15() { return static_cast<int32_t>(offsetof(Regex_t1803876613, ___refsInitialized_15)); } inline bool get_refsInitialized_15() const { return ___refsInitialized_15; } inline bool* get_address_of_refsInitialized_15() { return &___refsInitialized_15; } inline void set_refsInitialized_15(bool value) { ___refsInitialized_15 = value; } }; struct Regex_t1803876613_StaticFields { public: // System.TimeSpan System.Text.RegularExpressions.Regex::MaximumMatchTimeout TimeSpan_t3430258949 ___MaximumMatchTimeout_3; // System.TimeSpan System.Text.RegularExpressions.Regex::InfiniteMatchTimeout TimeSpan_t3430258949 ___InfiniteMatchTimeout_4; // System.TimeSpan System.Text.RegularExpressions.Regex::FallbackDefaultMatchTimeout TimeSpan_t3430258949 ___FallbackDefaultMatchTimeout_6; // System.TimeSpan System.Text.RegularExpressions.Regex::DefaultMatchTimeout TimeSpan_t3430258949 ___DefaultMatchTimeout_7; // System.Collections.Generic.LinkedList`1<System.Text.RegularExpressions.CachedCodeEntry> System.Text.RegularExpressions.Regex::livecode LinkedList_1_t3858529280 * ___livecode_16; // System.Int32 System.Text.RegularExpressions.Regex::cacheSize int32_t ___cacheSize_17; public: inline static int32_t get_offset_of_MaximumMatchTimeout_3() { return static_cast<int32_t>(offsetof(Regex_t1803876613_StaticFields, ___MaximumMatchTimeout_3)); } inline TimeSpan_t3430258949 get_MaximumMatchTimeout_3() const { return ___MaximumMatchTimeout_3; } inline TimeSpan_t3430258949 * get_address_of_MaximumMatchTimeout_3() { return &___MaximumMatchTimeout_3; } inline void set_MaximumMatchTimeout_3(TimeSpan_t3430258949 value) { ___MaximumMatchTimeout_3 = value; } inline static int32_t get_offset_of_InfiniteMatchTimeout_4() { return static_cast<int32_t>(offsetof(Regex_t1803876613_StaticFields, ___InfiniteMatchTimeout_4)); } inline TimeSpan_t3430258949 get_InfiniteMatchTimeout_4() const { return ___InfiniteMatchTimeout_4; } inline TimeSpan_t3430258949 * get_address_of_InfiniteMatchTimeout_4() { return &___InfiniteMatchTimeout_4; } inline void set_InfiniteMatchTimeout_4(TimeSpan_t3430258949 value) { ___InfiniteMatchTimeout_4 = value; } inline static int32_t get_offset_of_FallbackDefaultMatchTimeout_6() { return static_cast<int32_t>(offsetof(Regex_t1803876613_StaticFields, ___FallbackDefaultMatchTimeout_6)); } inline TimeSpan_t3430258949 get_FallbackDefaultMatchTimeout_6() const { return ___FallbackDefaultMatchTimeout_6; } inline TimeSpan_t3430258949 * get_address_of_FallbackDefaultMatchTimeout_6() { return &___FallbackDefaultMatchTimeout_6; } inline void set_FallbackDefaultMatchTimeout_6(TimeSpan_t3430258949 value) { ___FallbackDefaultMatchTimeout_6 = value; } inline static int32_t get_offset_of_DefaultMatchTimeout_7() { return static_cast<int32_t>(offsetof(Regex_t1803876613_StaticFields, ___DefaultMatchTimeout_7)); } inline TimeSpan_t3430258949 get_DefaultMatchTimeout_7() const { return ___DefaultMatchTimeout_7; } inline TimeSpan_t3430258949 * get_address_of_DefaultMatchTimeout_7() { return &___DefaultMatchTimeout_7; } inline void set_DefaultMatchTimeout_7(TimeSpan_t3430258949 value) { ___DefaultMatchTimeout_7 = value; } inline static int32_t get_offset_of_livecode_16() { return static_cast<int32_t>(offsetof(Regex_t1803876613_StaticFields, ___livecode_16)); } inline LinkedList_1_t3858529280 * get_livecode_16() const { return ___livecode_16; } inline LinkedList_1_t3858529280 ** get_address_of_livecode_16() { return &___livecode_16; } inline void set_livecode_16(LinkedList_1_t3858529280 * value) { ___livecode_16 = value; Il2CppCodeGenWriteBarrier((&___livecode_16), value); } inline static int32_t get_offset_of_cacheSize_17() { return static_cast<int32_t>(offsetof(Regex_t1803876613_StaticFields, ___cacheSize_17)); } inline int32_t get_cacheSize_17() const { return ___cacheSize_17; } inline int32_t* get_address_of_cacheSize_17() { return &___cacheSize_17; } inline void set_cacheSize_17(int32_t value) { ___cacheSize_17 = value; } }; #ifdef __clang__ #pragma clang diagnostic pop #endif #endif // REGEX_T1803876613_H // System.Void System.Object::.ctor() extern "C" void Object__ctor_m2551263788 (RuntimeObject * __this, const RuntimeMethod* method) IL2CPP_METHOD_ATTR; // System.Void UnityEngine.Networking.DownloadHandler::InternalDestroy() extern "C" void DownloadHandler_InternalDestroy_m1591990468 (DownloadHandler_t1216180266 * __this, const RuntimeMethod* method) IL2CPP_METHOD_ATTR; // System.Void System.Object::Finalize() extern "C" void Object_Finalize_m4087144328 (RuntimeObject * __this, const RuntimeMethod* method) IL2CPP_METHOD_ATTR; // System.Void System.GC::SuppressFinalize(System.Object) extern "C" void GC_SuppressFinalize_m953228702 (RuntimeObject * __this /* static, unused */, RuntimeObject * p0, const RuntimeMethod* method) IL2CPP_METHOD_ATTR; // System.Char System.String::get_Chars(System.Int32) extern "C" Il2CppChar String_get_Chars_m4230566705 (String_t* __this, int32_t p0, const RuntimeMethod* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::.ctor(System.String,System.UriKind) extern "C" void Uri__ctor_m1528033823 (Uri_t19570940 * __this, String_t* p0, int32_t p1, const RuntimeMethod* method) IL2CPP_METHOD_ATTR; // System.Boolean System.Uri::get_IsAbsoluteUri() extern "C" bool Uri_get_IsAbsoluteUri_m615473366 (Uri_t19570940 * __this, const RuntimeMethod* method) IL2CPP_METHOD_ATTR; // System.String System.Uri::get_AbsoluteUri() extern "C" String_t* Uri_get_AbsoluteUri_m656589005 (Uri_t19570940 * __this, const RuntimeMethod* method) IL2CPP_METHOD_ATTR; // System.Void System.Uri::.ctor(System.Uri,System.Uri) extern "C" void Uri__ctor_m371762263 (Uri_t19570940 * __this, Uri_t19570940 * p0, Uri_t19570940 * p1, const RuntimeMethod* method) IL2CPP_METHOD_ATTR; // System.Void System.Text.RegularExpressions.Regex::.ctor(System.String) extern "C" void Regex__ctor_m1229307206 (Regex_t1803876613 * __this, String_t* p0, const RuntimeMethod* method) IL2CPP_METHOD_ATTR; #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // Conversion methods for marshalling of: UnityEngine.Networking.DownloadHandler extern "C" void DownloadHandler_t1216180266_marshal_pinvoke(const DownloadHandler_t1216180266& unmarshaled, DownloadHandler_t1216180266_marshaled_pinvoke& marshaled) { marshaled.___m_Ptr_0 = unmarshaled.get_m_Ptr_0(); } extern "C" void DownloadHandler_t1216180266_marshal_pinvoke_back(const DownloadHandler_t1216180266_marshaled_pinvoke& marshaled, DownloadHandler_t1216180266& unmarshaled) { intptr_t unmarshaled_m_Ptr_temp_0; memset(&unmarshaled_m_Ptr_temp_0, 0, sizeof(unmarshaled_m_Ptr_temp_0)); unmarshaled_m_Ptr_temp_0 = marshaled.___m_Ptr_0; unmarshaled.set_m_Ptr_0(unmarshaled_m_Ptr_temp_0); } // Conversion method for clean up from marshalling of: UnityEngine.Networking.DownloadHandler extern "C" void DownloadHandler_t1216180266_marshal_pinvoke_cleanup(DownloadHandler_t1216180266_marshaled_pinvoke& marshaled) { } // Conversion methods for marshalling of: UnityEngine.Networking.DownloadHandler extern "C" void DownloadHandler_t1216180266_marshal_com(const DownloadHandler_t1216180266& unmarshaled, DownloadHandler_t1216180266_marshaled_com& marshaled) { marshaled.___m_Ptr_0 = unmarshaled.get_m_Ptr_0(); } extern "C" void DownloadHandler_t1216180266_marshal_com_back(const DownloadHandler_t1216180266_marshaled_com& marshaled, DownloadHandler_t1216180266& unmarshaled) { intptr_t unmarshaled_m_Ptr_temp_0; memset(&unmarshaled_m_Ptr_temp_0, 0, sizeof(unmarshaled_m_Ptr_temp_0)); unmarshaled_m_Ptr_temp_0 = marshaled.___m_Ptr_0; unmarshaled.set_m_Ptr_0(unmarshaled_m_Ptr_temp_0); } // Conversion method for clean up from marshalling of: UnityEngine.Networking.DownloadHandler extern "C" void DownloadHandler_t1216180266_marshal_com_cleanup(DownloadHandler_t1216180266_marshaled_com& marshaled) { } // System.Void UnityEngine.Networking.DownloadHandler::.ctor() extern "C" void DownloadHandler__ctor_m1584617735 (DownloadHandler_t1216180266 * __this, const RuntimeMethod* method) { { Object__ctor_m2551263788(__this, /*hidden argument*/NULL); return; } } // System.Void UnityEngine.Networking.DownloadHandler::InternalDestroy() extern "C" void DownloadHandler_InternalDestroy_m1591990468 (DownloadHandler_t1216180266 * __this, const RuntimeMethod* method) { typedef void (*DownloadHandler_InternalDestroy_m1591990468_ftn) (DownloadHandler_t1216180266 *); static DownloadHandler_InternalDestroy_m1591990468_ftn _il2cpp_icall_func; if (!_il2cpp_icall_func) _il2cpp_icall_func = (DownloadHandler_InternalDestroy_m1591990468_ftn)il2cpp_codegen_resolve_icall ("UnityEngine.Networking.DownloadHandler::InternalDestroy()"); _il2cpp_icall_func(__this); } // System.Void UnityEngine.Networking.DownloadHandler::Finalize() extern "C" void DownloadHandler_Finalize_m1928784109 (DownloadHandler_t1216180266 * __this, const RuntimeMethod* method) { Exception_t1927440687 * __last_unhandled_exception = 0; NO_UNUSED_WARNING (__last_unhandled_exception); Exception_t1927440687 * __exception_local = 0; NO_UNUSED_WARNING (__exception_local); int32_t __leave_target = 0; NO_UNUSED_WARNING (__leave_target); { } IL_0001: try { // begin try (depth: 1) DownloadHandler_InternalDestroy_m1591990468(__this, /*hidden argument*/NULL); IL2CPP_LEAVE(0x13, FINALLY_000c); } // end try (depth: 1) catch(Il2CppExceptionWrapper& e) { __last_unhandled_exception = (Exception_t1927440687 *)e.ex; goto FINALLY_000c; } FINALLY_000c: { // begin finally (depth: 1) Object_Finalize_m4087144328(__this, /*hidden argument*/NULL); IL2CPP_END_FINALLY(12) } // end finally (depth: 1) IL2CPP_CLEANUP(12) { IL2CPP_JUMP_TBL(0x13, IL_0013) IL2CPP_RETHROW_IF_UNHANDLED(Exception_t1927440687 *) } IL_0013: { return; } } // System.Void UnityEngine.Networking.DownloadHandler::Dispose() extern "C" void DownloadHandler_Dispose_m918842992 (DownloadHandler_t1216180266 * __this, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_method (DownloadHandler_Dispose_m918842992_MetadataUsageId); s_Il2CppMethodInitialized = true; } { DownloadHandler_InternalDestroy_m1591990468(__this, /*hidden argument*/NULL); IL2CPP_RUNTIME_CLASS_INIT(GC_t2902933594_il2cpp_TypeInfo_var); GC_SuppressFinalize_m953228702(NULL /*static, unused*/, __this, /*hidden argument*/NULL); return; } } // System.String UnityEngineInternal.WebRequestUtils::RedirectTo(System.String,System.String) extern "C" String_t* WebRequestUtils_RedirectTo_m675215376 (RuntimeObject * __this /* static, unused */, String_t* ___baseUri0, String_t* ___redirectUri1, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_method (WebRequestUtils_RedirectTo_m675215376_MetadataUsageId); s_Il2CppMethodInitialized = true; } Uri_t19570940 * V_0 = NULL; String_t* V_1 = NULL; Uri_t19570940 * V_2 = NULL; Uri_t19570940 * V_3 = NULL; { String_t* L_0 = ___redirectUri1; NullCheck(L_0); Il2CppChar L_1 = String_get_Chars_m4230566705(L_0, 0, /*hidden argument*/NULL); if ((!(((uint32_t)L_1) == ((uint32_t)((int32_t)47))))) { goto IL_001c; } } { String_t* L_2 = ___redirectUri1; Uri_t19570940 * L_3 = (Uri_t19570940 *)il2cpp_codegen_object_new(Uri_t19570940_il2cpp_TypeInfo_var); Uri__ctor_m1528033823(L_3, L_2, 2, /*hidden argument*/NULL); V_0 = L_3; goto IL_0024; } IL_001c: { String_t* L_4 = ___redirectUri1; Uri_t19570940 * L_5 = (Uri_t19570940 *)il2cpp_codegen_object_new(Uri_t19570940_il2cpp_TypeInfo_var); Uri__ctor_m1528033823(L_5, L_4, 0, /*hidden argument*/NULL); V_0 = L_5; } IL_0024: { Uri_t19570940 * L_6 = V_0; NullCheck(L_6); bool L_7 = Uri_get_IsAbsoluteUri_m615473366(L_6, /*hidden argument*/NULL); if (!L_7) { goto IL_003b; } } { Uri_t19570940 * L_8 = V_0; NullCheck(L_8); String_t* L_9 = Uri_get_AbsoluteUri_m656589005(L_8, /*hidden argument*/NULL); V_1 = L_9; goto IL_0057; } IL_003b: { String_t* L_10 = ___baseUri0; Uri_t19570940 * L_11 = (Uri_t19570940 *)il2cpp_codegen_object_new(Uri_t19570940_il2cpp_TypeInfo_var); Uri__ctor_m1528033823(L_11, L_10, 1, /*hidden argument*/NULL); V_2 = L_11; Uri_t19570940 * L_12 = V_2; Uri_t19570940 * L_13 = V_0; Uri_t19570940 * L_14 = (Uri_t19570940 *)il2cpp_codegen_object_new(Uri_t19570940_il2cpp_TypeInfo_var); Uri__ctor_m371762263(L_14, L_12, L_13, /*hidden argument*/NULL); V_3 = L_14; Uri_t19570940 * L_15 = V_3; NullCheck(L_15); String_t* L_16 = Uri_get_AbsoluteUri_m656589005(L_15, /*hidden argument*/NULL); V_1 = L_16; goto IL_0057; } IL_0057: { String_t* L_17 = V_1; return L_17; } } // System.Void UnityEngineInternal.WebRequestUtils::.cctor() extern "C" void WebRequestUtils__cctor_m4149625601 (RuntimeObject * __this /* static, unused */, const RuntimeMethod* method) { static bool s_Il2CppMethodInitialized; if (!s_Il2CppMethodInitialized) { il2cpp_codegen_initialize_method (WebRequestUtils__cctor_m4149625601_MetadataUsageId); s_Il2CppMethodInitialized = true; } { Regex_t1803876613 * L_0 = (Regex_t1803876613 *)il2cpp_codegen_object_new(Regex_t1803876613_il2cpp_TypeInfo_var); Regex__ctor_m1229307206(L_0, _stringLiteral4071228867, /*hidden argument*/NULL); ((WebRequestUtils_t4100941042_StaticFields*)il2cpp_codegen_static_fields_for(WebRequestUtils_t4100941042_il2cpp_TypeInfo_var))->set_domainRegex_0(L_0); return; } } #ifdef __clang__ #pragma clang diagnostic pop #endif
c317898e7bde47d63eb3e2b8eed6c459abfb2608
4b19135464a032c1d5271cd1ae58afb21df38584
/Samples/C++/DirectShow/Filters/DSNetwork/Receiver/mspool.h
2022e5302f29bb5c4da419bc1cb0ed77c4a79ae7
[]
no_license
sjk7/DX90SDK
f47cebbba53133923880004bc6e3a33cff1fe895
dd155425badb2cd3993c27f869efc007764e599b
refs/heads/master
2021-08-26T07:47:03.826451
2021-08-12T05:03:03
2021-08-12T05:03:03
253,911,891
3
1
null
null
null
null
UTF-8
C++
false
false
9,735
h
/*++ Copyright (c) Microsoft Corporation. All Rights Reserved. Module Name: mspool.h Abstract: Notes: --*/ #ifndef __mspool_h #define __mspool_h class CTSMediaSamplePool ; class CTSMediaSample ; class CNetworkReceiverFilter ; // media sample flags #define SAMPLE_SYNCPOINT 0x00000001 #define SAMPLE_PREROLL 0x00000002 #define SAMPLE_DISCONTINUITY 0x00000004 #define SAMPLE_TYPECHANGED 0x00000008 #define SAMPLE_TIMEVALID 0x00000010 #define SAMPLE_MEDIATIMEVALID 0x00000020 #define SAMPLE_TIMEDISCONTINUITY 0x00000040 #define SAMPLE_STOPVALID 0x00000080 #define SAMPLE_VALIDFLAGS 0x000000ff class CTSMediaSample : public IMediaSample2 { CTSMediaSamplePool * m_pMSPool ; LONG m_lRef ; DWORD m_dwFlags ; // ORed SAMPLE_* values DWORD m_dwTypeSpecificFlags ; BYTE * m_pbPayload ; LONG m_lActual ; REFERENCE_TIME m_rtStart ; REFERENCE_TIME m_rtEnd ; LONGLONG m_llMediaStart ; LONGLONG m_llMediaEnd ; AM_MEDIA_TYPE * m_pMediaType ; DWORD m_dwStreamId ; // // this media sample always wraps something // CBuffer * m_pBuffer ; // we're wrapping an IO block void ResetMS_ ( ) ; public : LIST_ENTRY m_ListEntry ; CTSMediaSample ( IN CTSMediaSamplePool * ) ; ~CTSMediaSample ( ) ; // ------------------------------------------------------------------- // init HRESULT Init ( IN CBuffer * pBuffer, IN BYTE * pbPayload, IN int iPayloadLength, IN LONGLONG * pllMediaStart, IN LONGLONG * pllMediaEnd, IN REFERENCE_TIME * prtStart, IN REFERENCE_TIME * prtEnd, IN DWORD dwMediaSampleFlags ) ; // ------------------------------------------------------------------- // IUnknown methods STDMETHODIMP QueryInterface ( IN REFIID riid, OUT void ** ppv ) ; STDMETHODIMP_(ULONG) AddRef ( ) ; STDMETHODIMP_(ULONG) Release ( ) ; // ------------------------------------------------------------------- // IMediaSample methods // get me a read/write pointer to this buffer's memory. I will actually // want to use sizeUsed bytes. STDMETHODIMP GetPointer ( OUT BYTE ** ppBuffer ) ; // return the size in bytes of the buffer data area STDMETHODIMP_(LONG) GetSize ( ) ; // get the stream time at which this sample should start and finish. STDMETHODIMP GetTime ( OUT REFERENCE_TIME * pTimeStart, // put time here OUT REFERENCE_TIME * pTimeEnd ) ; // Set the stream time at which this sample should start and finish. // pTimeStart==pTimeEnd==NULL will invalidate the time stamps in // this sample STDMETHODIMP SetTime ( IN REFERENCE_TIME * pTimeStart, // put time here IN REFERENCE_TIME * pTimeEnd ) ; // sync-point property. If true, then the beginning of this // sample is a sync-point. (note that if AM_MEDIA_TYPE.bTemporalCompression // is false then all samples are sync points). A filter can start // a stream at any sync point. S_FALSE if not sync-point, S_OK if true. STDMETHODIMP IsSyncPoint ( ) ; STDMETHODIMP SetSyncPoint ( IN BOOL bIsSyncPoint ) ; // preroll property. If true, this sample is for preroll only and // shouldn't be displayed. STDMETHODIMP IsPreroll ( ) ; STDMETHODIMP SetPreroll ( BOOL bIsPreroll ) ; STDMETHODIMP_(LONG) GetActualDataLength ( ) ; STDMETHODIMP SetActualDataLength ( IN long ) ; // these allow for limited format changes in band - if no format change // has been made when you receive a sample GetMediaType will return S_FALSE STDMETHODIMP GetMediaType ( AM_MEDIA_TYPE ** ppMediaType ) ; STDMETHODIMP SetMediaType( AM_MEDIA_TYPE * pMediaType ) ; // returns S_OK if there is a discontinuity in the data (this frame is // not a continuation of the previous stream of data // - there has been a seek or some dropped samples). STDMETHODIMP IsDiscontinuity ( ) ; // set the discontinuity property - TRUE if this sample is not a // continuation, but a new sample after a seek or a dropped sample. STDMETHODIMP SetDiscontinuity ( BOOL bDiscontinuity ) ; // get the media times for this sample STDMETHODIMP GetMediaTime ( OUT LONGLONG * pTimeStart, OUT LONGLONG * pTimeEnd ) ; // Set the media times for this sample // pTimeStart==pTimeEnd==NULL will invalidate the media time stamps in // this sample STDMETHODIMP SetMediaTime ( IN LONGLONG * pTimeStart, IN LONGLONG * pTimeEnd ) ; // ------------------------------------------------------------------- // IMediaSample methods // Set and get properties (IMediaSample2) STDMETHODIMP GetProperties ( IN DWORD cbProperties, OUT BYTE * pbProperties ) ; STDMETHODIMP SetProperties ( IN DWORD cbProperties, IN const BYTE * pbProperties ) ; } ; class CTSMediaSamplePool { LIST_ENTRY m_leMSPool ; CNetworkReceiverFilter * m_pHostingFilter ; DWORD m_dwPoolSize ; CRITICAL_SECTION m_crt ; HANDLE m_hEvent ; void Lock_ () { EnterCriticalSection (& m_crt) ; } void Unlock_ () { LeaveCriticalSection (& m_crt) ; } HRESULT GetMediaSample_ ( IN CBuffer * pBuffer, IN BYTE * pbPayload, IN int iPayloadLength, IN LONGLONG * pllMediaStart, IN LONGLONG * pllMediaEnd, IN REFERENCE_TIME * prtStart, IN REFERENCE_TIME * prtEnd, IN DWORD dwMediaSampleFlags, OUT IMediaSample2 ** ppMS ) ; public : CTSMediaSamplePool ( IN DWORD dwPoolSize, IN CNetworkReceiverFilter * pHostingFilter, OUT HRESULT * phr ) ; ~CTSMediaSamplePool ( ) ; DWORD GetPoolSize ( ) { return m_dwPoolSize ; } void RecycleMS ( IN CTSMediaSample * ) ; // synchronous HRESULT GetMediaSampleSynchronous ( IN CBuffer * pBuffer, IN BYTE * pbPayload, IN int iPayloadLength, IN LONGLONG * pllMediaStart, IN LONGLONG * pllMediaEnd, IN REFERENCE_TIME * prtStart, IN REFERENCE_TIME * prtEnd, IN DWORD dwMediaSampleFlags, OUT IMediaSample2 ** ppMS ) { return GetMediaSample_ ( pBuffer, pbPayload, iPayloadLength, pllMediaStart, pllMediaEnd, prtStart, prtEnd, dwMediaSampleFlags, ppMS ) ; } HRESULT GetMediaSampleSynchronous ( IN CBuffer * pBuffer, IN BYTE * pbPayload, IN int iPayloadLength, OUT IMediaSample2 ** ppMS ) { LONGLONG llMediaStart ; LONGLONG llMediaEnd ; REFERENCE_TIME rtStart ; REFERENCE_TIME rtEnd ; return GetMediaSample_ ( pBuffer, pbPayload, iPayloadLength, & llMediaStart, // dummy & llMediaEnd, // dummy & rtStart, // dummy & rtEnd, // dummy 0, // no flags (no dummy param gets used) ppMS ) ; } } ; #endif // __mspool_h
ad2ae659704b93ab8f922e750cbcb20314bbfc32
91a882547e393d4c4946a6c2c99186b5f72122dd
/Source/XPSP1/NT/printscan/faxsrv/src/com/whistler/faxarchiveinner.h
6eb6ac7d7ae679af79b5f936bcca59e5a49c4d5a
[]
no_license
IAmAnubhavSaini/cryptoAlgorithm-nt5src
94f9b46f101b983954ac6e453d0cf8d02aa76fc7
d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2
refs/heads/master
2023-09-02T10:14:14.795579
2021-11-20T13:47:06
2021-11-20T13:47:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
25,673
h
/*++ Copyright (c) 2000 Microsoft Corporation Module Name: faxarchiveinner.h Abstract: Declaration and Implementation of Fax Archive Inner Template Class. Author: Iv Garber (IvG) May, 2000 Revision History: --*/ #ifndef __FAXARCHIVEINNER_H_ #define __FAXARCHIVEINNER_H_ #include "resource.h" // main symbols #include "FaxCommon.h" // //================ FAX ARCHIVE INNER ========================================= // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> class CFaxArchiveInner : public IDispatchImpl<T, piid, &LIBID_FAXCOMEXLib>, public CFaxInitInner { public: CFaxArchiveInner() : CFaxInitInner(_T("FAX ARCHIVE INNER")) { m_bInitialized = FALSE; } virtual ~CFaxArchiveInner() {}; STDMETHOD(get_SizeLow)(/*[out, retval]*/ long *plSizeLow); STDMETHOD(get_SizeHigh)(/*[out, retval]*/ long *plSizeHigh); STDMETHOD(get_UseArchive)(/*[out, retval]*/ VARIANT_BOOL *pbUseArchive); STDMETHOD(put_UseArchive)(/*[in]*/ VARIANT_BOOL bUseArchive); STDMETHOD(get_ArchiveFolder)(BSTR *pbstrArchiveFolder); STDMETHOD(put_ArchiveFolder)(BSTR bstrArchiveFolder); STDMETHOD(get_SizeQuotaWarning)(VARIANT_BOOL *pbSizeQuotaWarning); STDMETHOD(put_SizeQuotaWarning)(VARIANT_BOOL bSizeQuotaWarning); STDMETHOD(get_HighQuotaWaterMark)(long *plHighQuotaWaterMark); STDMETHOD(put_HighQuotaWaterMark)(long lHighQuotaWaterMark); STDMETHOD(get_LowQuotaWaterMark)(long *plLowQuotaWaterMark); STDMETHOD(put_LowQuotaWaterMark)(long lLowQuotaWaterMark); STDMETHOD(get_AgeLimit)(long *plAgeLimit); STDMETHOD(put_AgeLimit)(long lAgeLimit); STDMETHOD(Refresh)(); STDMETHOD(Save)(); STDMETHOD(GetMessage)(BSTR bstrMessageId, MsgIfc **ppFaxMessage); STDMETHOD(GetMessages)(long lPrefetchSize, IteratorIfc **ppFaxMessageIterator); private: bool m_bInitialized; VARIANT_BOOL m_bUseArchive; CComBSTR m_bstrArchiveFolder; VARIANT_BOOL m_bSizeQuotaWarning; long m_lHighQuotaWaterMark; long m_lLowQuotaWaterMark; long m_lAgeLimit; ULARGE_INTEGER m_uliSize; }; // //========================= REFRESH ==================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::Refresh( ) /*++ Routine name : CFaxArchiveInner::Refresh Routine description: Retrieve Current Configuration of the Incoming / Outgoing Archive on Fax Server Author: Iv Garber (IvG), Apr, 2000 Arguments: Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::Refresh"), hr); // // Get Fax Server Handle // HANDLE hFaxHandle = NULL; hr = GetFaxHandle(&hFaxHandle); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } CFaxPtr<FAX_ARCHIVE_CONFIG> pFaxArchiveConfig; if ( 0 == ::FaxGetArchiveConfiguration(hFaxHandle, ArchiveType, &pFaxArchiveConfig)) { // // Failed to Get Archive Configuration // hr = Fax_HRESULT_FROM_WIN32(GetLastError()); AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("::FaxGetArchiveConfiguration()"), hr); return hr; } if (!pFaxArchiveConfig || pFaxArchiveConfig->dwSizeOfStruct != sizeof(FAX_ARCHIVE_CONFIG)) { // // Failed to Get Archive Configuration // hr = E_FAIL; AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("Invalid pFaxArchiveConfig"), hr); return hr; } m_bUseArchive = bool2VARIANT_BOOL(pFaxArchiveConfig->bUseArchive); m_bSizeQuotaWarning = bool2VARIANT_BOOL(pFaxArchiveConfig->bSizeQuotaWarning); m_lHighQuotaWaterMark = pFaxArchiveConfig->dwSizeQuotaHighWatermark; m_lLowQuotaWaterMark = pFaxArchiveConfig->dwSizeQuotaLowWatermark; m_lAgeLimit = pFaxArchiveConfig->dwAgeLimit; m_uliSize.QuadPart = pFaxArchiveConfig->dwlArchiveSize; m_bstrArchiveFolder = pFaxArchiveConfig->lpcstrFolder; if (!m_bstrArchiveFolder && pFaxArchiveConfig->lpcstrFolder) { hr = E_OUTOFMEMORY; AtlReportError(*pcid, IDS_ERROR_OUTOFMEMORY, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(MEM_ERR, _T("CComBSTR& operator=()"), hr); return hr; } m_bInitialized = TRUE; return hr; } // //==================== USE ARCHIVE ==================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_UseArchive( VARIANT_BOOL *pbUseArchive ) /*++ Routine name : CFaxArchiveInner::get_UseArchive Routine description: Return Flag indicating whether or not to Archive the Fax Messages Author: Iv Garber (IvG), Apr, 2000 Arguments: pbUseArchive [out] - Ptr to the Place to put Current value of the Flag Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_UseArchive"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetVariantBool(pbUseArchive, m_bUseArchive); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType>:: put_UseArchive( VARIANT_BOOL bUseArchive ) /*++ Routine name : CFaxArchiveInner::put_UseArchive Routine description: Set new Use Archive Flag Author: Iv Garber (IvG), Apr, 2000 Arguments: bUseArchive [in] - the new Value for the Use Archive Flag Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::put_UseArchive"), hr, _T("%ld"), bUseArchive); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } m_bUseArchive = bUseArchive; return hr; } // //==================== ARCHIVE FOLDER ==================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_ArchiveFolder( BSTR *pbstrArchiveFolder ) /*++ Routine name : CFaxArchiveInner::get_ArchiveFolder Routine description: return Archive Folder on Server Author: Iv Garber (IvG), Apr, 2000 Arguments: pbstrArchiveFolder [out] - the Archive Folder Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_ArchiveFolder"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetBstr(pbstrArchiveFolder, m_bstrArchiveFolder); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::put_ArchiveFolder ( BSTR bstrArchiveFolder ) /*++ Routine name : CFaxArchiveInner::put_ArchiveFolder Routine description: Set Archive Folder Author: Iv Garber (IvG), Apr, 2000 Arguments: bstrArchiveFolder [in] - new Archive Folder on Server Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::put_ArchiveFolder"), hr, _T("%s"), bstrArchiveFolder); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } m_bstrArchiveFolder = bstrArchiveFolder; if (bstrArchiveFolder && !m_bstrArchiveFolder) { // // Not enough memory // hr = E_OUTOFMEMORY; AtlReportError(*pcid, IDS_ERROR_OUTOFMEMORY, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(MEM_ERR, _T("CComBSTR::operator="), hr); return hr; } return hr; } // //==================== SIZE QUOTA WARNING ================================ // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_SizeQuotaWarning( VARIANT_BOOL *pbSizeQuotaWarning ) /*++ Routine name : CFaxArchiveInner::get_SizeQuotaWarning Routine description: Return Flag indicating whether or not to issue event log warning when watermarks are crossed Author: Iv Garber (IvG), Apr, 2000 Arguments: pbSizeQuotaWarning [out] - ptr to place where to put the Current value of the Flag Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_SizeQuotaWarning"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetVariantBool(pbSizeQuotaWarning, m_bSizeQuotaWarning); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::put_SizeQuotaWarning( VARIANT_BOOL bSizeQuotaWarning ) /*++ Routine name : CFaxArchiveInner::put_SizeQuotaWarning Routine description: Set new SizeQuotaWarning Flag Author: Iv Garber (IvG), Apr, 2000 Arguments: bSizeQuotaWarning [in] - the new Value for the SizeQuotaWarning Flag Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::put_SizeQuotaWarning"), hr, _T("%ld"), bSizeQuotaWarning); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } m_bSizeQuotaWarning = bSizeQuotaWarning; return hr; } // //================= QUOTA WATER MARKS =============================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_HighQuotaWaterMark( long *plHighQuotaWaterMark ) /*++ Routine name : CFaxArchiveInner::get_HighQuotaWaterMark Routine description: Return HighQuotaWaterMark Author: Iv Garber (IvG), Apr, 2000 Arguments: plHighQuotaWaterMark [out] - HighQuotaWaterMark Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_HighQuotaWaterMark"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetLong(plHighQuotaWaterMark , m_lHighQuotaWaterMark); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::put_HighQuotaWaterMark( long lHighQuotaWaterMark ) /*++ Routine name : CFaxArchiveInner::put_HighQuotaWaterMark Routine description: Set HighQuotaWaterMark Author: Iv Garber (IvG), Apr, 2000 Arguments: lHighQuotaWaterMark [in] - HighQuotaWaterMark to Set Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::put_HighQuotaWaterMark"), hr, _T("%ld"), lHighQuotaWaterMark); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } m_lHighQuotaWaterMark = lHighQuotaWaterMark; return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_LowQuotaWaterMark( long *plLowQuotaWaterMark ) /*++ Routine name : CFaxArchiveInner::get_LowQuotaWaterMark Routine description: Return LowQuotaWaterMark Author: Iv Garber (IvG), Apr, 2000 Arguments: plLowQuotaWaterMark [out] - LowQuotaWaterMark Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_LowQuotaWaterMark"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetLong(plLowQuotaWaterMark , m_lLowQuotaWaterMark); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::put_LowQuotaWaterMark( long lLowQuotaWaterMark ) /*++ Routine name : CFaxArchiveInner::put_LowQuotaWaterMark Routine description: Set LowQuotaWaterMark Author: Iv Garber (IvG), Apr, 2000 Arguments: lLowQuotaWaterMark [in] - LowQuotaWaterMark to Set Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::put_LowQuotaWaterMark"), hr, _T("%ld"), lLowQuotaWaterMark); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } m_lLowQuotaWaterMark = lLowQuotaWaterMark; return hr; } // //================= AGE LIMIT =============================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_AgeLimit( long *plAgeLimit ) /*++ Routine name : CFaxArchiveInner::get_AgeLimit Routine description: Return how long in days Fax Message is stored at Fax Server Author: Iv Garber (IvG), Apr, 2000 Arguments: plAgeLimit [out] - AgeLimit Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_AgeLimit"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetLong(plAgeLimit, m_lAgeLimit); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::put_AgeLimit( long lAgeLimit ) /*++ Routine name : CFaxArchiveInner::put_AgeLimit Routine description: Set AgeLimit Author: Iv Garber (IvG), Apr, 2000 Arguments: lAgeLimit [in] - AgeLimit to Set Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::put_AgeLimit"), hr, _T("%ld"), lAgeLimit); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } m_lAgeLimit = lAgeLimit; return hr; } // //================= SIZE ============================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_SizeLow( long *plSizeLow ) /*++ Routine name : CFaxArchiveInner::get_SizeLow Routine description: Return Size in Bytes of the Archive Author: Iv Garber (IvG), May, 2000 Arguments: plSizeLow [out] - Ptr to the place to put the Size in Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_SizeLow"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetLong(plSizeLow, long(m_uliSize.LowPart)); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_SizeHigh( long *plSizeHigh ) /*++ Routine name : CFaxArchiveInner::get_SizeHigh Routine description: Return Size in Bytes of the Archive Author: Iv Garber (IvG), May, 2000 Arguments: plSizeHigh [out] - Ptr to the place to put the Size in Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_SizeHigh"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetLong(plSizeHigh, long(m_uliSize.HighPart)); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } // //========================= SAVE ==================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::Save( ) /*++ Routine name : CFaxArchiveInner::Save Routine description: Save the Archive's Configuration Author: Iv Garber (IvG), Apr, 2000 Arguments: Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; HANDLE hFaxHandle = NULL; FAX_ARCHIVE_CONFIG FaxArchiveConfig; DBG_ENTER (_T("CFaxArchiveInner::Save"), hr); // // Get Fax Server Handle // hr = GetFaxHandle(&hFaxHandle); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } if (hFaxHandle == NULL) { // // Fax Server Is Not Connected // hr = E_HANDLE; AtlReportError(*pcid, IDS_ERROR_SERVER_NOT_CONNECTED, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("hFaxHandle == NULL"), hr); return hr; } // // FaxArchiveConfig.dwlArchiveSize is ignored for SetConfiguration() // FaxArchiveConfig.dwSizeOfStruct = sizeof(FAX_ARCHIVE_CONFIG); FaxArchiveConfig.bUseArchive = VARIANT_BOOL2bool(m_bUseArchive); FaxArchiveConfig.bSizeQuotaWarning = VARIANT_BOOL2bool(m_bSizeQuotaWarning); FaxArchiveConfig.dwSizeQuotaHighWatermark = m_lHighQuotaWaterMark; FaxArchiveConfig.dwSizeQuotaLowWatermark = m_lLowQuotaWaterMark; FaxArchiveConfig.dwAgeLimit = m_lAgeLimit; FaxArchiveConfig.lpcstrFolder = m_bstrArchiveFolder; if ( 0 == ::FaxSetArchiveConfiguration(hFaxHandle, ArchiveType, &FaxArchiveConfig)) { // // Failed to Set Archive Configuration // hr = Fax_HRESULT_FROM_WIN32(GetLastError()); AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("::FaxSetArchiveConfiguration()"), hr); return hr; } return hr; } // //=============== GET MESSAGE ======================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::GetMessage( BSTR bstrMessageId, MsgIfc **ppFaxMessage ) /*++ Routine name : CFaxArchiveInner::GetMessage Routine description: Return Message by given Id Author: Iv Garber (IvG), May, 2000 Arguments: bstrMessageId [in] - Id of the Message to return ppFaxMessage [out] - Ptr to the place to put the Message Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::GetMessage"), hr, _T("%s"), bstrMessageId); // // Check that we can write to the given pointer // if (::IsBadWritePtr(ppFaxMessage, sizeof(MsgIfc *))) { // // Got Bad Return Pointer // hr = E_POINTER; AtlReportError(*pcid, IDS_ERROR_INVALID_ARGUMENT, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr"), hr); return hr; } // // Get Fax Server Handle // HANDLE hFaxHandle = NULL; hr = GetFaxHandle(&hFaxHandle); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } // // convert Message Id that we've got to hexadecimal DWORDLONG // DWORDLONG dwlMsgId; int iParsed = _stscanf (bstrMessageId, _T("%I64x"), &dwlMsgId); if ( iParsed != 1) { // // Failed to conver the number // hr = E_INVALIDARG; CALL_FAIL(GENERAL_ERR, _T("_stscanf()"), hr); AtlReportError(*pcid, IDS_ERROR_INVALIDMSGID, *piid, hr, _Module.GetResourceInstance()); return hr; } CFaxPtr<FAX_MESSAGE> pFaxPtrMessage; if (!FaxGetMessage(hFaxHandle, dwlMsgId, ArchiveType, &pFaxPtrMessage)) { // // Failed to retrieve the Message // hr = Fax_HRESULT_FROM_WIN32(GetLastError()); AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("FaxGetMessage()"), hr); return hr; } // // Check that pFaxPtrMessage is valid // if (!pFaxPtrMessage || pFaxPtrMessage->dwSizeOfStruct != sizeof(FAX_MESSAGE)) { // // Failed to Get Message // hr = E_FAIL; AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("Invalid pFaxMessage"), hr); return hr; } // // Create Message Object // CComPtr<MsgIfc> pTmpMessage; hr = MsgType::Create(&pTmpMessage); if (FAILED(hr)) { // // Failed to create the Message object // AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("MsgType::Create()"), hr); return hr; } // // Initialize the Message Object // hr = ((MsgType *)((MsgIfc *)pTmpMessage))->Init(pFaxPtrMessage, m_pIFaxServerInner); if (FAILED(hr)) { // // Failed to Init the Message Object // AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("<casted>pTmpMessage->Init(pFaxMessage, m_pIFaxServerInner)"), hr); return hr; } // // Return Message Object to the Caller // hr = pTmpMessage.CopyTo(ppFaxMessage); if (FAILED(hr)) { // // Failed to Copy Interface // AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("CComPtr::CopyTo"), hr); return hr; } return hr; } // //========================= GET MESSAGES ============================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::GetMessages( long lPrefetchSize, IteratorIfc **ppFaxMessageIterator ) /*++ Routine name : CFaxArchiveInner::GetMessages Routine description: Return Iterator on Archive's Messages. Author: Iv Garber (IvG), May, 2000 Arguments: lPrefetchSize [in] - Size of Prefetch Buffer for Messages. ppFaxMessageIterator [out] - Ptr to place to put Iterator Object Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::GetMessages"), hr); CObjectHandler<IteratorType, IteratorIfc> objectCreator; hr = objectCreator.GetObject(ppFaxMessageIterator, m_pIFaxServerInner); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } #endif //__FAXARCHIVEINNER_H_
5f6a7547818f9630d254dd4e5e1a57d6a7e963ab
367fba5df552aef1ee9aa6add6bb512b781bc6d4
/plugins/jsAPI/nodeJsExtension/wrappers/ApeIndexedLineSetGeometryJsBind.h
1e9b9c71a432a5da2fee8f2437daa8d41eac1e8a
[ "LicenseRef-scancode-free-unknown", "MIT" ]
permissive
hamoriakos/ApertusVR
2d3e5736b26404198b222d24388bb3c1c162ee69
14303ab54963e52409ed376cdafae5c43004074b
refs/heads/master
2021-09-16T00:13:48.980732
2017-06-28T18:23:14
2017-06-28T18:23:14
105,749,913
0
1
MIT
2018-06-13T13:54:38
2017-10-04T09:11:13
C++
UTF-8
C++
false
false
4,023
h
/*MIT License Copyright (c) 2016 MTA SZTAKI 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 APE_INDEXEDLINESETGEOMETRYJSBIND_H #define APE_INDEXEDLINESETGEOMETRYJSBIND_H #include "nbind/nbind.h" #include "nbind/api.h" #include "Ape.h" #include "ApeIIndexedLineSetGeometry.h" #include "ApeJsBindNodeImpl.h" #ifdef NBIND_CLASS class IndexedLineSetJsPtr { private: Ape::IndexedLineSetGeometryWeakPtr mPtr; public: IndexedLineSetJsPtr(Ape::IndexedLineSetGeometryWeakPtr ptr) { mPtr = ptr; } IndexedLineSetJsPtr(Ape::EntityWeakPtr ptr) { mPtr = std::static_pointer_cast<Ape::IIndexedLineSetGeometry>(ptr.lock()); } // Pointers const Ape::EntityWeakPtr getEntityWeakPtr() { return std::static_pointer_cast<Ape::Entity>(mPtr.lock()); } const Ape::EntitySharedPtr getEntitySharedPtr() { return this->getEntityWeakPtr().lock(); } Ape::GeometryWeakPtr getGeometryWeakPtr() { return std::static_pointer_cast<Ape::Geometry>(mPtr.lock()); } Ape::GeometrySharedPtr getGeometrySharedPtr() { return this->getGeometryWeakPtr().lock(); } Ape::IndexedLineSetGeometrySharedPtr getIndexedLineSetGeometrySharedPtr() { return std::static_pointer_cast<Ape::IIndexedLineSetGeometry>(mPtr.lock()); } Ape::IndexedLineSetGeometryWeakPtr getIndexedLineSetGeometryWeakPtr() { return mPtr; } // ParentNode Ape::NodeWeakPtr getParentNodeWeakPtr() { return mPtr.lock()->getParentNode(); } void setParentNodeWeakPtr(Ape::NodeWeakPtr parentNode) { mPtr.lock()->setParentNode(parentNode); } NodeJsPtr getParentNodeJsPtr() { return NodeJsPtr(getParentNodeWeakPtr()); } void setParentNodeJsPtr(NodeJsPtr parentNode) { mPtr.lock()->setParentNode(parentNode.getNodeWeakPtr()); } // Entity const std::string getName() { return mPtr.lock()->getName(); } const Ape::Entity::Type getType() { return mPtr.lock()->getType(); } // IIndexedLineSetGeometry Ape::GeometryIndexedLineSetParameters getParameters() { return mPtr.lock()->getParameters(); } void setParameters(Ape::GeometryCoordinates coordinates, Ape::GeometryIndices indices, Ape::Color color) { mPtr.lock()->setParameters(coordinates, indices, color); } }; using namespace Ape; NBIND_CLASS(GeometryIndexedLineSetParameters) { construct<>(); construct<GeometryCoordinates, GeometryIndices, Color>(); method(getCoordinates); method(getIndices); method(getColor); method(toString); } NBIND_CLASS(IndexedLineSetJsPtr) { construct<Ape::IndexedLineSetGeometryWeakPtr>(); construct<Ape::EntityWeakPtr>(); // Pointers method(getEntityWeakPtr); method(getEntitySharedPtr); method(getGeometryWeakPtr); method(getGeometrySharedPtr); method(getIndexedLineSetGeometryWeakPtr); method(getIndexedLineSetGeometrySharedPtr); // ParentNode method(getParentNodeWeakPtr); method(setParentNodeWeakPtr); method(getParentNodeJsPtr); method(setParentNodeJsPtr); // Entity method(getName); method(getType); // IIndexedLineSetGeometry method(getParameters); method(setParameters); } #endif #endif
4bd2d3863e213b995ce4c797f69651b760fb6ceb
be0db8bf2276da4b71a67723bbe8fb75e689bacb
/Src/App/init.cpp
d888c01b5df8390fb58162ef1efbd36db997300d
[]
no_license
jy02140486/cellwarfare
21a8eb793b94b8472905d793f4b806041baf57bb
85f026efd03f12dd828817159b9821eff4e4aff0
refs/heads/master
2020-12-24T15:22:58.595707
2011-07-24T12:36:45
2011-07-24T12:36:45
32,970,508
0
0
null
null
null
null
UTF-8
C++
false
false
6,030
cpp
#include "app.h" #include "event.h" #include <time.h> bool T_App::init() { try { //initail window description mWinDesc.set_title("CellWarfare"); mWinDesc.set_allow_resize(true); mWinDesc.set_size(CL_Size (800, 600), false); CL_String resource("../Res/GUITheme/resources.xml"); CL_String theme("../Res/GUITheme/theme.css"); //initail resource manager mResManager.load(resource); ////initail gui theme mGUITheme.set_resources(mResManager); //initail gui mpDisplayWindow = new CL_DisplayWindow(mWinDesc); mpWinManager = new CL_GUIWindowManagerTexture(*mpDisplayWindow); mGui.set_window_manager(*mpWinManager); mGui.set_theme(mGUITheme); mGui.set_css_document(theme); mpWinManager->func_repaint().set(this, &T_App::render); //initail GUIComponet window CL_DisplayWindowDescription comWindowDesc; comWindowDesc.show_border(false); comWindowDesc.set_allow_resize(true); comWindowDesc.set_title("settings"); comWindowDesc.set_size(CL_Size(300, 570),false); comWindowDesc.set_allow_resize(true); comWindowDesc.set_layered(true); mpComWindow = new CL_Window(&mGui, comWindowDesc); mpComWindow->set_draggable(false); //initail events mInput = mpDisplayWindow->get_ic(); mKeyboard = mInput.get_keyboard(); mMouse = mInput.get_mouse(); //mJoystick = mInput.get_joystick(); mpConsole = new CL_ConsoleWindow("Console", 80, 100); entites=new EM(); entites->iniLVs(); words=new CL_Font(mpComWindow->get_gc(),"Tahoma",20); offset.x=320; offset.y=420; entites->initScrObjs(); body=new CL_Image(mpDisplayWindow->get_gc(),"../res/body.png"); stage_clear=new CL_Image(mpDisplayWindow->get_gc(),"../res/stage clear.png"); if(RandomVal::randombool()) gameover=new CL_Image(mpDisplayWindow->get_gc(),"../res/gameover2.png"); else gameover=new CL_Image(mpDisplayWindow->get_gc(),"../res/gameover.png"); all_clear=new CL_Image(mpDisplayWindow->get_gc(),"../res/allclear.png"); //init menu items mx=new CL_LineEdit(mpComWindow); mx->set_geometry(CL_Rect(40,40, CL_Size(80, 20))); my=new CL_LineEdit(mpComWindow); my->set_geometry(CL_Rect(40,80, CL_Size(80, 20))); cirfirm=new CL_PushButton(mpComWindow); cirfirm->set_text("enter"); cirfirm->set_geometry(CL_Rect(40,500, CL_Size(150, 30))); cirfirm->func_clicked().set(this,&T_App::ButtonClick); PainKiller=new CL_PushButton(mpComWindow); PainKiller->set_text("PainKiller"); PainKiller->set_geometry(CL_Rect(40,540, CL_Size(100, 20))); PainKiller->func_clicked().set(this,&T_App::takePill); CL_Point lboffset(10,10); CL_Size sspin(80,20); CL_Size slb(80,20); infoBF=new CL_Label(mpComWindow); infoBF->set_geometry(CL_Rect(10,110, CL_Size(290, 300))); infoBF->set_text("infobf"); infoBF->set_visible(false); lbcellsdeployed=new CL_Label(infoBF); lbcellsdeployed->set_geometry(CL_Rect(lboffset.x,lboffset.y+5, slb)); lbcellsdeployed->set_text("Cells deployed"); cellsdeployed=new CL_Spin(infoBF); cellsdeployed->set_geometry(CL_Rect(lboffset.x+80,lboffset.y, sspin)); cellsdeployed->set_step_size(1); cellsdeployed->set_ranges(0,100); cellsdeployed->set_value(entites->curLV->defbfs[0].ImmunityPoints); lbintruders=new CL_Label(infoBF); lbintruders->set_geometry(CL_Rect(lboffset.x,lboffset.y+35, slb)); lbintruders->set_text("Intruders"); intruders=new CL_Spin(infoBF); intruders->set_geometry(CL_Rect(lboffset.x+80,lboffset.y+30, sspin)); lbtimeleft=new CL_Label(infoBF); lbtimeleft->set_geometry(CL_Rect(lboffset.x,lboffset.y+65, slb)); lbtimeleft->set_text("Time left"); timeleft=new CL_ProgressBar(infoBF); timeleft->set_geometry(CL_Rect(lboffset.x+80,lboffset.y+65, slb)); timeleft->set_min(0); timeleft->set_max(40); timeleft->set_position(20); SendingCirfirm=new CL_PushButton(infoBF); SendingCirfirm->set_geometry(CL_Rect(lboffset.x,lboffset.y+95, slb)); SendingCirfirm->set_text("Send"); SendingCirfirm->func_clicked().set(this,&T_App::OnSendingCirfirmClick); //tatical layer TaticalBoard=new CL_Label(mpComWindow); TaticalBoard->set_geometry(CL_Rect(10,310, CL_Size(290, 200))); TaticalBoard->set_text("TaticalBoard"); TaticalBoard->set_visible(true); // TaticalBoard->set_constant_repaint(true); lbTcellsdeployed=new CL_Label(TaticalBoard); lbTcellsdeployed->set_geometry(CL_Rect(lboffset.x,lboffset.y+5, slb)); lbTcellsdeployed->set_text("Cells deployed"); lbTcellsdeployed->set_visible(true); Tcellsdeployed=new CL_Label(TaticalBoard); Tcellsdeployed->set_geometry(CL_Rect(lboffset.x+100,lboffset.y+5, slb)); Tcellsdeployed->set_text("Cells deployed"); Tcellsdeployed->set_visible(true); lbTintruders=new CL_Label(TaticalBoard); lbTintruders->set_geometry(CL_Rect(lboffset.x,lboffset.y+15, slb)); lbTintruders->set_text("Itruders"); lbTintruders->set_visible(true); Tintruders=new CL_Label(TaticalBoard); Tintruders->set_geometry(CL_Rect(lboffset.x+100,lboffset.y+15, slb)); Tintruders->set_text("Itruders"); Tintruders->set_visible(true); entites->hero->eventTimer->func_expired().set(this,&T_App::invading_LogicLayer_Failure); entites->hero->eventTimer->begin(true); //LibDebugOnConsole(); time(&Atime); } catch (CL_Exception &exception) { CL_Console::write_line("Exception:Init error", exception.get_message_and_stack_trace()); // mpConsole->display_close_message(); CL_Console::write_line(exception.get_message_and_stack_trace()); return true; } running=true; T_Event::eventInit(); T_App::eventInit(); // slotMouseDown = mMouse.sig_key_down().connect(this, // &T_App::onMouseDown); return true; } void T_App::OnSendingCirfirmClick() { if (entites->SOselected!=NULL) { entites->SOselected->datas->ImmunityPoints+=cellsdeployed->get_value(); if (entites->hero->ImmunityPoints->minusable(cellsdeployed->get_value())) { entites->hero->ImmunityPoints->minus(cellsdeployed->get_value()); } } }
[ "[email protected]@7e182df5-b8f1-272d-db4e-b61a9d634eb1" ]
[email protected]@7e182df5-b8f1-272d-db4e-b61a9d634eb1
7353c3ed56ed21b0b9df018981759d6e716ec9b1
e9ba75ae30fd8af7cb00dc330bae6e5ea9f04043
/src/physicsentity.h
41c416e3bfb5fe60f9d30fce48b35607573d0d47
[ "MIT", "BSD-3-Clause" ]
permissive
adderly/Bacon2D
a4fad8084c75e3dc62e627c382aee969c97ba354
4875cddc1301cae0212ee4e32192bb17821b36f2
refs/heads/master
2021-01-24T23:11:43.345455
2016-10-29T23:06:19
2016-10-29T23:06:19
49,147,938
0
1
null
2016-01-06T16:44:24
2016-01-06T16:44:24
null
UTF-8
C++
false
false
1,193
h
#ifndef PHYSICSENTITY_H #define PHYSICSENTITY_H #include <QObject> #include <entity.h> class QPointF; class Box2DBody; typedef Box2DBody Body; /** * @brief */ class PhysicsEntity : public Entity { Q_OBJECT Q_PROPERTY(Body* body READ body WRITE setBody NOTIFY bodyChanged) public: PhysicsEntity(QQuickItem* parent = nullptr); void setBody(Body* body); Body* body() { return mBody; } public slots: void applyForce(QPointF force,QPointF point); void applyForceToCenter(QPointF force); void applyTorque(qreal torque); void applyLinearImpulse(QPointF impulse, QPointF point); void applyAngularImpulse(qreal torque); QPointF getWorldCenter(); QPointF getLocalCenter(); float getMass(); void resetMassData(); float getInertia(); QPointF toWorldPoint(QPointF localPoint); QPointF toWorldVector(QPointF localVector); QPointF toLocalPoint(QPointF worlPoint); QPointF toLocalVector(QPointF worldVector); QPointF getLinearVelocityFromWorldPoint(QPointF point); QPointF getLinearVelocityFromLocalPoint(QPointF point); signals: void bodyChanged(Body* body); private: Body* mBody; }; #endif // PHYSICSENTITY_H
853274b10388c9a87dae29e7c593aad1b110beb8
948f4e13af6b3014582909cc6d762606f2a43365
/testcases/juliet_test_suite/testcases/CWE36_Absolute_Path_Traversal/s04/testcases.h
2053b3349e375c5c71ecdc93ffbe03e9d64f9086
[]
no_license
junxzm1990/ASAN--
0056a341b8537142e10373c8417f27d7825ad89b
ca96e46422407a55bed4aa551a6ad28ec1eeef4e
refs/heads/master
2022-08-02T15:38:56.286555
2022-06-16T22:19:54
2022-06-16T22:19:54
408,238,453
74
13
null
2022-06-16T22:19:55
2021-09-19T21:14:59
null
UTF-8
C++
false
false
108,786
h
// NOTE - eventually this file will be automatically updated using a Perl script that understand // the naming of test case files, functions, and namespaces. #ifndef _TESTCASES_H #define _TESTCASES_H #ifdef __cplusplus extern "C" { #endif // declare C good and bad functions #ifndef OMITGOOD /* BEGIN-AUTOGENERATED-C-GOOD-FUNCTION-DECLARATIONS */ /* END-AUTOGENERATED-C-GOOD-FUNCTION-DECLARATIONS */ #endif // OMITGOOD #ifndef OMITBAD /* BEGIN-AUTOGENERATED-C-BAD-FUNCTION-DECLARATIONS */ /* END-AUTOGENERATED-C-BAD-FUNCTION-DECLARATIONS */ #endif // OMITBAD #ifdef __cplusplus } // end extern "C" #endif #ifdef __cplusplus // declare C++ namespaces and good and bad functions #ifndef OMITGOOD /* BEGIN-AUTOGENERATED-CPP-GOOD-FUNCTION-DECLARATIONS */ namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_84 { void good();} /* END-AUTOGENERATED-CPP-GOOD-FUNCTION-DECLARATIONS */ #endif // OMITGOOD #ifndef OMITBAD /* BEGIN-AUTOGENERATED-CPP-BAD-FUNCTION-DECLARATIONS */ namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_84 { void bad();} /* END-AUTOGENERATED-CPP-BAD-FUNCTION-DECLARATIONS */ #endif // OMITBAD #endif // __cplusplus #endif // _TESTCASES_H
e8bd887270f09fd87c7f50e74d880fa70a6f1c04
ab6937915ca4a3a8b95d3021177a752c54157d21
/C/LatihanBahasaC.cpp
f23c0a39c8628d9156c973c9ce96d6839cee6efe
[]
no_license
fitrailyasa/Latihan-Coding
b953ecb8c6f7624d260576c18d8813b9291963f2
f3a211585f8635c2c68b21c41701ee07f5e55d74
refs/heads/main
2023-06-17T01:00:35.471920
2021-07-13T21:47:48
2021-07-13T21:47:48
385,743,161
0
0
null
null
null
null
UTF-8
C++
false
false
241
cpp
#include <stdio.h> //manggil library (Perpustakaan bahasa C) int main(){ // Pintu masuk program int a; // tipe data int = integer (bilangan bulat), float = bilangan pecahan printf("Halo, Dunia"); //output = Halo, Dunia scanf("%d", a); }
025ef13ba6732d96f2c7663e14cf94f9be060684
04c66673a7f8ebdca37e1a28bfdfa9af56716ddc
/02_auto/main.cpp
fd8a935abb472b0f85b2aa94a41b34487084cf94
[]
no_license
mkargi/modern_effective_cpp
14b2e5daaf3811ec657a47ee62f56d45746d90b8
003a586c0c326020ca12eae1d07937eda7142924
refs/heads/master
2023-01-23T04:11:42.522368
2020-12-02T16:38:27
2020-12-02T16:38:27
315,421,352
0
0
null
null
null
null
UTF-8
C++
false
false
249
cpp
#include <iostream> int main() { auto x = 27; // int const auto cx = x; // const int const auto& rx = x; // const int& auto&& uref1 = x; // int& auto&& uref2 = cx; // const int& auto&& uref3 = 27; // int&& return 0; }
21e557b437cb374995727fd2939cf2330f321082
72d44d01083aeb66606cecd9d84dbb0eb17b0acb
/leetcode/leetcode173/leetcode173/main.cpp
481a449b8e4c57cca58be4c5dc3365ebe5602e19
[]
no_license
danache/coding
e3d704b6302acb913d3f58ea1dfe9e126d1b0f39
ef798534e8412eb81f31318244305e1a6110ea72
refs/heads/master
2020-04-19T15:12:56.562307
2018-06-03T06:24:37
2018-06-03T06:24:37
66,996,085
2
0
null
null
null
null
UTF-8
C++
false
false
1,217
cpp
// // main.cpp // leetcode173 // // Created by 萧天牧 on 17/4/23. // Copyright © 2017年 萧天牧. All rights reserved. // #include <iostream> #include <stack> #include <vector> using namespace std; /** * Definition for binary tree */ struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; class BSTIterator { stack<TreeNode *> myStack; public: BSTIterator(TreeNode *root) { pushAll(root); } /** @return whether we have a next smallest number */ bool hasNext() { return !myStack.empty(); } /** @return the next smallest number */ int next() { TreeNode *tmpNode = myStack.top(); myStack.pop(); pushAll(tmpNode->right); return tmpNode->val; } private: void pushAll(TreeNode *node) { for(; node!= NULL; myStack.push(node), node = node -> left); } }; /** * Your BSTIterator will be called like this: * BSTIterator i = BSTIterator(root); * while (i.hasNext()) cout << i.next(); */ int main(int argc, const char * argv[]) { // insert code here... std::cout << "Hello, World!\n"; return 0; }
053b8cc331fbaeaeb235e57d0d6a4c7f9797d3f3
a37c5c59364f16db8475db8a3bf237abcb12702f
/Part3/Chap07/07.QuadTree+FixCrack/Dib.cpp
9f6c76a68c872ce88357d58ef19013228d7f565b
[]
no_license
blastingzone/ComputerGraphicsAdvenced
915d3cab0375b4beb6cfad347fb5746f848eb77c
95c4b33c316a60e58754dfb4e873f49397aadbd1
refs/heads/master
2021-01-18T16:13:07.001810
2014-06-22T17:13:39
2014-06-22T17:13:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
19,426
cpp
// DIB module #include <windows.h> #include <stdio.h> #include <math.h> #include "dib.h" #define DEFAULT_XPIXELSPERMETER 3000 #define DEFAULT_YPIXELSPERMETER 3000 //////////////////////////////////////////////////////////////////////////////// // file io LPBYTE DibLoadHandle( LPSTR lpFileName ) { FILE *fp; BITMAPFILEHEADER bmfh; HGLOBAL hDib; LPBYTE lpDib; int nSize; fopen_s( &fp, lpFileName, "rb" ); if ( !fp ) return NULL; fread( &bmfh, sizeof(BITMAPFILEHEADER), 1, fp ); nSize = bmfh.bfSize - sizeof(BITMAPFILEHEADER); hDib = (HGLOBAL) GlobalAlloc( GMEM_FIXED, nSize ); lpDib = (LPBYTE) GlobalLock( hDib ); if ( !lpDib ) { fclose( fp ); return NULL; } fread( lpDib, nSize, 1, fp ); fclose( fp ); return lpDib; } bool DibSave( LPBYTE lpDib, LPSTR lpFileName ) { FILE *fp; BITMAPFILEHEADER bmfh; if ( !lpDib || !lpFileName ) return false; fopen_s( &fp, lpFileName, "wb" ); if ( !fp ) return false; bmfh.bfType = 0x4d42; bmfh.bfSize = sizeof(BITMAPFILEHEADER) + DIB_SIZE( lpDib ); bmfh.bfReserved1 = 0; bmfh.bfReserved2 = 0; bmfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + DIB_PALSIZE( lpDib ); fwrite( &bmfh, sizeof(BITMAPFILEHEADER), 1, fp ); fwrite( lpDib, DIB_SIZE( lpDib ), 1, fp ); fclose( fp ); return true; } //////////////////////////////////////////////////////////////////////////////// // creation LPBYTE DibCreateEmpty( int nBitsPerPixel, int nWidth, int nHeight ) { LPBITMAPINFOHEADER lpBMIH; LPBYTE lpDib; int nPal = nBitsPerPixel == 24 ? 0 : 1 << nBitsPerPixel; int nPalSize = sizeof(RGBQUAD) * nPal; int nLineSize = ALIGN_4B(nWidth * nBitsPerPixel / 8); DWORD dwSize = sizeof(BITMAPINFOHEADER) + nPalSize + nLineSize * nHeight; lpDib = new BYTE [dwSize]; memset( lpDib, 0xff, dwSize ); lpBMIH = DIB_HEADER(lpDib); lpBMIH->biSize = sizeof(BITMAPINFOHEADER); lpBMIH->biWidth = nWidth; lpBMIH->biHeight = nHeight; lpBMIH->biPlanes = 1; lpBMIH->biBitCount = nBitsPerPixel; lpBMIH->biCompression = BI_RGB; lpBMIH->biSizeImage = 0; lpBMIH->biXPelsPerMeter = DEFAULT_XPIXELSPERMETER; lpBMIH->biYPelsPerMeter = DEFAULT_YPIXELSPERMETER; lpBMIH->biClrUsed = nPal; lpBMIH->biClrImportant = nPal; RGBQUAD rgbQuad; int i; for ( i = 0; i < nPal; i++ ) { rgbQuad.rgbBlue = i; rgbQuad.rgbGreen = i; rgbQuad.rgbRed = i; rgbQuad.rgbReserved = 0; DIB_BMI( lpDib )->bmiColors[i] = rgbQuad; } return lpDib; } // WIN 16 버젼 라이브러리들과의 호환으로 준비. LPBYTE DibCreateEmptyHandle( int nBitsPerPixel, int nWidth, int nHeight ) { LPBITMAPINFOHEADER lpBMIH; HGLOBAL hDib; LPBYTE lpDib; int nPal = nBitsPerPixel == 24 ? 0 : 1 << nBitsPerPixel; int nPalSize = sizeof(RGBQUAD) * nPal; int nLineSize = ALIGN_4B(nWidth * nBitsPerPixel / 8); DWORD dwSize = sizeof(BITMAPINFOHEADER) + nPalSize + nLineSize * nHeight; hDib = (HGLOBAL) GlobalAlloc( GMEM_FIXED, dwSize ); lpDib = (LPBYTE) GlobalLock( hDib ); memset( lpDib, 0xff, dwSize ); lpBMIH = (LPBITMAPINFOHEADER) lpDib; lpBMIH->biSize = sizeof(BITMAPINFOHEADER); lpBMIH->biWidth = nWidth; lpBMIH->biHeight = nHeight; lpBMIH->biPlanes = 1; lpBMIH->biBitCount = nBitsPerPixel; lpBMIH->biCompression = BI_RGB; lpBMIH->biSizeImage = 0; lpBMIH->biXPelsPerMeter = DEFAULT_XPIXELSPERMETER; lpBMIH->biYPelsPerMeter = DEFAULT_YPIXELSPERMETER; lpBMIH->biClrUsed = nPal; lpBMIH->biClrImportant = nPal; RGBQUAD rgbQuad; int i; for ( i = 0; i < nPal; i++ ) { rgbQuad.rgbBlue = i; rgbQuad.rgbGreen = i; rgbQuad.rgbRed = i; rgbQuad.rgbReserved = 0; DIB_BMI( lpDib )->bmiColors[i] = rgbQuad; } return lpDib; } void DibDeleteHandle( LPBYTE lpSrc ) { if ( lpSrc ) { GlobalUnlock( lpSrc ); GlobalFree( lpSrc ); } } //////////////////////////////////////////////////////////////////////////////// // copy LPBYTE DibDuplicate( LPBYTE lpSrc ) { if ( !lpSrc ) return NULL; LPBYTE lpDib; DWORD dwSize = DIB_SIZE( lpSrc ); lpDib = new BYTE [dwSize]; if ( lpDib ) memcpy( lpDib, lpSrc, dwSize ); return lpDib; } LPBYTE DibDuplicateHandle( LPBYTE lpSrc ) { if ( !lpSrc ) return NULL; HGLOBAL hDib; LPBYTE lpDib; DWORD dwSize = DIB_SIZE( lpSrc ); hDib = (HGLOBAL) GlobalAlloc( GMEM_FIXED, dwSize ); lpDib = (LPBYTE) GlobalLock( hDib ); if ( lpDib ) memcpy( lpDib, lpSrc, dwSize ); return lpDib; } bool DibCopyRect( LPBYTE lpDstDib, int dstx, int dsty, LPBYTE lpSrcDib, LPRECT prSrc1 ) { if ( !lpDstDib || !lpSrcDib || DIB_BPP( lpDstDib ) != DIB_BPP( lpSrcDib ) ) return false; RECT rDst, rDst1, rDst2, rSrc2, rSrc; SetRect( &rSrc2, 0, 0, DIB_CX( lpSrcDib ), DIB_CY( lpSrcDib ) ); IntersectRect( &rSrc, prSrc1, &rSrc2 ); SetRect( &rDst1, 0, 0, rSrc.right - rSrc.left, rSrc.bottom - rSrc.top ); OffsetRect( &rDst1, dstx, dsty ); SetRect( &rDst2, 0, 0, DIB_CX( lpDstDib ), DIB_CY( lpDstDib ) ); IntersectRect( &rDst, &rDst1, &rDst2 ); LPBYTE lpSrc, lpDst; int y, nWidth = (rDst.right - rDst.left) * DIB_BPP( lpSrcDib ) / 8; for ( y = rDst.top; y < rDst.bottom; y++ ) { lpSrc = DIB_DATAXY_INV( lpSrcDib, rSrc.left, rSrc.top + y - rDst.top ); lpDst = DIB_DATAXY_INV( lpDstDib, rDst.left, y ); memcpy( lpDst, lpSrc, nWidth ); } return true; } bool DibCopyRectROP( LPBYTE lpDstDib, int dstx, int dsty, LPBYTE lpSrcDib, LPRECT prSrc1, DWORD dwROP ) { if ( !lpDstDib || !lpSrcDib || DIB_BPP( lpDstDib ) != DIB_BPP( lpSrcDib ) ) return false; RECT rDst, rDst1, rDst2, rSrc2, rSrc; SetRect( &rSrc2, 0, 0, DIB_CX( lpSrcDib ), DIB_CY( lpSrcDib ) ); IntersectRect( &rSrc, prSrc1, &rSrc2 ); SetRect( &rDst1, 0, 0, rSrc.right - rSrc.left, rSrc.bottom - rSrc.top ); OffsetRect( &rDst1, dstx, dsty ); SetRect( &rDst2, 0, 0, DIB_CX( lpDstDib ), DIB_CY( lpDstDib ) ); IntersectRect( &rDst, &rDst1, &rDst2 ); LPBYTE lpSrc, lpDst; int y, i, nWidth = (rDst.right - rDst.left) * DIB_BPP( lpSrcDib ) / 8; for ( y = rDst.top; y < rDst.bottom; y++ ) { lpSrc = DIB_DATAXY_INV( lpSrcDib, rSrc.left, rSrc.top + y - rDst.top ); lpDst = DIB_DATAXY_INV( lpDstDib, rDst.left, y ); switch ( dwROP ) { case SRCAND: for ( i = 0; i < nWidth; i++ ) { *lpDst = *lpDst & *lpSrc; lpDst++; lpSrc++; } break; case SRCPAINT: for ( i = 0; i < nWidth; i++ ) { *lpDst = *lpDst | *lpSrc; lpDst++; lpSrc++; } break; case SRCCOPY: memcpy( lpDst, lpSrc, nWidth ); break; default: break; } } return true; } bool DibCopy( LPBYTE lpDst, LPBYTE lpSrc ) { if ( !lpSrc || !lpDst || DIB_BPP( lpSrc ) != DIB_BPP( lpDst ) ) return false; if ( DIB_CX( lpSrc ) != DIB_CX( lpDst ) || DIB_CY( lpSrc ) != DIB_CY( lpDst ) ) return false; memcpy( DIB_DATA( lpDst ), DIB_DATA( lpSrc ), DIB_DATASIZE( lpSrc ) ); return true; } bool DibTile( LPBYTE lpSrcDib, LPBYTE lpTileDib ) { LPBYTE lpSrc, lpTile; int y, cx, cy, tcx, tcy, n, i, bytesps; if ( !lpSrcDib || !lpTileDib || DIB_BPP( lpSrcDib ) != DIB_BPP( lpTileDib ) ) return false; bytesps = DIB_BPP( lpSrcDib ) / 8; cx = DIB_CX( lpSrcDib ); cy = DIB_CY( lpSrcDib ); tcx = DIB_CX( lpTileDib ); tcy = DIB_CY( lpTileDib ); for ( y = 0; y < cy; y++ ) { lpTile = DIB_DATAXY_INV( lpTileDib, 0, y % tcy ); if ( cx > tcx ) { n = cx / tcx + (cx % tcx ? 1 : 0); for ( i = 0; i < n; i++ ) { lpSrc = DIB_DATAXY_INV( lpSrcDib, i * tcx, y ); memcpy( lpSrc, lpTile, min(cx - (i * tcx), tcx) * bytesps ); } } else { lpSrc = DIB_DATAXY_INV( lpSrcDib, 0, y ); memcpy( lpSrc, lpTile, cx * bytesps ); } } return true; } //////////////////////////////////////////////////////////////////////////////// // geometry LPBYTE DibFlipHandle( LPBYTE lpDib ) { if ( !lpDib ) return NULL; LPBYTE lpNewDib; int y; lpNewDib = (LPBYTE) GlobalLock( DibCreateEmptyHandle( DIB_BPP( lpDib ), DIB_CX( lpDib ), DIB_CY( lpDib ) ) ); if ( lpNewDib ) { for ( y = 0; y < DIB_CY( lpDib ); y++ ) { memcpy( DIB_DATAXY( lpNewDib, 0, y ), DIB_DATAXY_INV( lpDib, 0, y ), DIB_LINESIZE( lpDib ) ); } } return lpNewDib; } LPBYTE DibReverseHandle( LPBYTE lpDib ) { if ( !lpDib ) return NULL; LPBYTE lpNewDib, lpNewData, lpData; int x, y; lpNewDib = (LPBYTE) GlobalLock( DibCreateEmptyHandle( DIB_BPP( lpDib ), DIB_CX( lpDib ), DIB_CY( lpDib ) ) ); if ( lpNewDib ) { for ( y = 0; y < DIB_CY( lpDib ); y++ ) { lpData = DIB_DATAXY( lpDib, 0, y ); lpNewData = DIB_DATAXY( lpNewDib, DIB_CX( lpNewDib ) - 1, y ); if ( DIB_BPP( lpDib ) == 8 ) { for ( x = 0; x < DIB_CX( lpDib ); x++ ) *lpNewData-- = *lpData++; } else if ( DIB_BPP( lpDib ) == 24 ) { for ( x = 0; x < DIB_CX( lpDib ); x++ ) { *lpNewData = *lpData++; *(lpNewData + 1) = *lpData++; *(lpNewData + 2) = *lpData++; lpNewData -= 3; } } } } return lpNewDib; } LPBYTE DibRotateHandle( LPBYTE lpDib, float fDegree ) { if ( !lpDib ) return NULL; LPBYTE lpNewDib = NULL, lpNewData, lpData; int x, y, cx, cy; cx = DIB_CX( lpDib ); cy = DIB_CY( lpDib ); if ( fDegree == 90.0f ) { if ( !(lpNewDib = (LPBYTE) GlobalLock( DibCreateEmptyHandle( DIB_BPP( lpDib ), cy, cx ) )) ) return NULL; for ( y = 0; y < cy; y++ ) { lpData = DIB_DATAXY( lpDib, 0, y ); lpNewData = DIB_DATAXY( lpNewDib, y, cx - 1 ); if ( DIB_BPP( lpDib ) == 8 ) { for ( x = 0; x < cx; x++, lpNewData -= ALIGN_4B( cy ) ) *lpNewData = *lpData++; } else if ( DIB_BPP( lpDib ) == 24 ) { for ( x = 0; x < cx; x++, lpNewData -= ALIGN_4B( cy * 3 ) ) { *lpNewData = *lpData++; *(lpNewData + 1) = *lpData++; *(lpNewData + 2) = *lpData++; } } } } else if ( fDegree == 180.0f ) { if ( !(lpNewDib = (LPBYTE) GlobalLock( DibCreateEmptyHandle( DIB_BPP( lpDib ), cx, cy ) )) ) return NULL; for ( y = 0; y < cy; y++ ) { lpData = DIB_DATAXY( lpDib, 0, y ); lpNewData = DIB_DATAXY( lpNewDib, cx - 1, cy - 1 - y ); if ( DIB_BPP( lpDib ) == 8 ) { for ( x = 0; x < cx; x++, lpNewData-- ) *lpNewData = *lpData++; } else if ( DIB_BPP( lpDib ) == 24 ) { for ( x = 0; x < cx; x++, lpNewData -= 3 ) { *lpNewData = *lpData++; *(lpNewData + 1) = *lpData++; *(lpNewData + 2) = *lpData++; } } } } else if ( fDegree == 270.0f ) { if ( !(lpNewDib = (LPBYTE) GlobalLock( DibCreateEmptyHandle( DIB_BPP( lpDib ), cy, cx ) )) ) return NULL; for ( y = 0; y < cy; y++ ) { lpData = DIB_DATAXY( lpDib, 0, y ); lpNewData = DIB_DATAXY( lpNewDib, cy - 1 - y, 0 ); if ( DIB_BPP( lpDib ) == 8 ) { for ( x = 0; x < cx; x++, lpNewData += ALIGN_4B( cy ) ) *lpNewData = *lpData++; } else if ( DIB_BPP( lpDib ) == 24 ) { for ( x = 0; x < cx; x++, lpNewData += ALIGN_4B( cy * 3 ) ) { *lpNewData = *lpData++; *(lpNewData + 1) = *lpData++; *(lpNewData + 2) = *lpData++; } } } } else // free angle { /* CLeadBitmap lBitmap; lBitmap.ConvertFromDIB( (LPBITMAPINFO)lpDib, lpDib ); lBitmap.Rotate( nNewWidth, nNewHeight ); lpNewDib = (LPBYTE) GlobalLock( lBitmap.ConvertToDIB() ); */ } return lpNewDib; } LPBYTE DibResizeHandle( LPBYTE lpDib, int nNewWidth, int nNewHeight ) { if ( !lpDib || nNewWidth <= 0 || nNewHeight <= 0 ) return NULL; return NULL; } LPBYTE DibReduce( LPBYTE lpSrcDib, int newCx, int newCy ) { LPBYTE lpDstDib, lpSrc, lpDst, lpTemp; float fXratio, fYratio; int x, y, cx, cy, nBps; if ( !lpSrcDib || newCx <= 0 || newCy <= 0 ) return NULL; cx = DIB_CX( lpSrcDib ); cy = DIB_CY( lpSrcDib ); nBps = DIB_BPP( lpSrcDib ); if ( nBps != 24 && nBps != 8 ) return NULL; fXratio = (float)cx / newCx; fYratio = (float)cy / newCy; if ( (lpDstDib = DibCreateEmpty( nBps, newCx, newCy )) == NULL ) return NULL; if ( nBps == 8 ) { for ( y = 0; y < newCy; y++ ) { lpSrc = DIB_ALPHAXY( lpSrcDib, 0, ((int)(y * fYratio)) ); lpDst = DIB_ALPHAXY( lpDstDib, 0, y ); for ( x = 0; x < newCx; x++ ) *lpDst++ = *(lpSrc + (int)(x * fXratio)); } } else if ( nBps == 24 ) { for ( y = 0; y < newCy; y++ ) { lpSrc = DIB_IMAGEXY( lpSrcDib, 0, ((int)(y * fYratio)) ); lpDst = DIB_IMAGEXY( lpDstDib, 0, y ); for ( x = 0; x < newCx; x++ ) { lpTemp = lpSrc + (int)(x * fXratio) * 3; *lpDst++ = *lpTemp++; *lpDst++ = *lpTemp++; *lpDst++ = *lpTemp++; } } } return lpDstDib; } //////////////////////////////////////////////////////////////////////////////// // convert format LPBYTE DibRGB2GRAYHandle( LPBYTE lpRgbDib ) { LPBYTE lpGrayDib, lpSrc, lpDst; int x, y, cx, cy; if ( !lpRgbDib || DIB_BPP( lpRgbDib ) != 24 ) return NULL; cx = DIB_CX( lpRgbDib ); cy = DIB_CY( lpRgbDib ); if ( !(lpGrayDib = DibCreateEmptyHandle( 8, cx, cy )) ) return NULL; for ( y = 0; y < cy; y++ ) { lpSrc = DIB_DATA24XY( lpRgbDib, 0, y ); lpDst = DIB_DATA8XY( lpGrayDib, 0, y ); for ( x = 0; x < cx; x++ ) { *lpDst++ = (*lpSrc + *(lpSrc+1) + *(lpSrc+2))/3; lpSrc += 3; } } return lpGrayDib; } LPBYTE DibGRAY2RGBHandle( LPBYTE lpGrayDib ) { LPBYTE lpRgbDib, lpSrc, lpDst; int x, y, cx, cy; if ( !lpGrayDib || DIB_BPP( lpGrayDib ) != 8 ) return NULL; cx = DIB_CX( lpGrayDib ); cy = DIB_CY( lpGrayDib ); if ( !(lpRgbDib = DibCreateEmptyHandle( 24, cx, cy )) ) return NULL; for ( y = 0; y < cy; y++ ) { lpSrc = DIB_DATA8XY( lpGrayDib, 0, y ); lpDst = DIB_DATA24XY( lpRgbDib, 0, y ); for ( x = 0; x < cx; x++ ) { *lpDst++ = *lpSrc; *lpDst++ = *lpSrc; *lpDst++ = *lpSrc; lpSrc ++; } } return lpRgbDib; } //////////////////////////////////////////////////////////////////////////////// // etc bool DibPrint( HWND hwnd, LPBYTE lpDib, LPSTR lpszDevice, int nDevide ) { /* BITMAPHANDLE LBitmap; // Bitmap handle for the image HDC PrinterDC; // DC for the printer int nWidthAllowed, nHeightAllowed, nWidthFactor, nHeightFactor; // For size calculations int nWidthPrint, nHeightPrint; // nWidth and height of the printed image DOCINFO DocInfo; // Document information structure if ( !lpDib ) return false; PrinterDC = CreateDC( NULL, lpszDevice, NULL, NULL ); if ( !PrinterDC ) return false; L_InitBitmap( &LBitmap, 0, 0, DIB_BPP( lpDib ) ); L_ConvertFromDIB( &LBitmap, (LPBITMAPINFO)lpDib, DIB_DATA( lpDib ) ); // Initialize the document to be printed memset( &DocInfo, 0, sizeof(DocInfo) ); DocInfo.cbSize = sizeof(DocInfo); DocInfo.lpszDocName = "Portrait or Caricature"; // Initialize variables for fitting the image on half a page nWidthAllowed = GetDeviceCaps( PrinterDC, HORZRES ); nHeightAllowed = GetDeviceCaps( PrinterDC, VERTRES ); nHeightFactor = BITMAPHEIGHT( &LBitmap ); nWidthFactor = BITMAPWIDTH( &LBitmap ); // See if using the maximum width will make the image too tall if ( ((nWidthAllowed * nHeightFactor) / nWidthFactor) < nHeightAllowed ) { // Use the maximum width, and calculate the height value nWidthPrint = nWidthAllowed; nHeightPrint = nWidthPrint * nHeightFactor / nWidthFactor; } else { // Use the maximum height, and calculate the width value nHeightPrint = nHeightAllowed; nWidthPrint = nHeightPrint * nWidthFactor / nHeightFactor; } // Start the print job if ( StartDoc( PrinterDC, &DocInfo ) <= 0 ) { DeleteDC( PrinterDC ); return false; } StartPage( PrinterDC ); // Print image switch ( nDevide ) { case 4: case 9: case 16: { int n, x, y, cx, cy, m; n = (int)sqrt( (double)nDevide ); // devide number m = nWidthPrint/40; // margin cx = (nWidthPrint - m * 2)/n; cy = (nHeightPrint - m * 2)/n; for ( y = 0; y < n; y++ ) { for ( x = 0; x < n; x++ ) { L_PrintBitmapFast( PrinterDC, &LBitmap, x * cx + m, y * cy + m, cx, cy, FALSE ); } } // 재단선 그리기 HPEN hOldPen; hOldPen = (HPEN)SelectObject( PrinterDC, GetStockObject( BLACK_PEN ) ); for ( x = 0; x <= n; x++ ) { MoveToEx( PrinterDC, x * cx + m, 0, NULL ); // LineTo( PrinterDC, x * cx + m, m ); // MoveToEx( PrinterDC, x * cx + m, nHeightPrint - m, NULL ); LineTo( PrinterDC, x * cx + m, nHeightPrint ); } for ( y = 0; y <= n; y++ ) { MoveToEx( PrinterDC, 0, y * cy + m, NULL ); // LineTo( PrinterDC, m, y * cy + m ); // MoveToEx( PrinterDC, nWidthPrint - m, y * cy + m, NULL ); LineTo( PrinterDC, nWidthPrint, y * cy + m ); } SelectObject( PrinterDC, hOldPen ); } break; default: L_PrintBitmapFast( PrinterDC, &LBitmap, 1, 1, nWidthPrint, nHeightPrint, FALSE ); break; } L_FreeBitmap( &LBitmap ); // Flush the page and finish the print job EndPage( PrinterDC ); EndDoc( PrinterDC ); DeleteDC( PrinterDC ); return true; */ return false; } HRGN DibCreateRegion( LPBYTE lpDib, BYTE byColor ) { LPBYTE lpData; int x, y, cx, cy; DWORD dwMaxRect; RECT r; RGNDATA *pRd; HGLOBAL hMem; HRGN hRgn; if ( !lpDib || DIB_BPP( lpDib ) != 8 ) return NULL; cx = DIB_CX( lpDib ); cy = DIB_CY( lpDib ); dwMaxRect = 3000; hMem = GlobalAlloc( GMEM_FIXED, sizeof(RGNDATAHEADER) + sizeof(RECT) * dwMaxRect ); pRd = (RGNDATA *)GlobalLock( hMem ); pRd->rdh.dwSize = sizeof(RGNDATAHEADER); pRd->rdh.iType = RDH_RECTANGLES; pRd->rdh.nCount = 0; pRd->rdh.nRgnSize = 0; SetRect( &(pRd->rdh.rcBound), cx, cy, 0, 0 ); for ( y = 0; y < cy; y++ ) { lpData = DIB_DATA8XY_INV( lpDib, 0, y ); for ( x = 0; x < cx; x++ ) { if ( *lpData == byColor ) { // get run length rect r.left = x; r.top = r.bottom = y; while ( *lpData == byColor && x < cx ) { x++; lpData++; } r.right = x; // update bound rect if ( r.left < pRd->rdh.rcBound.left ) pRd->rdh.rcBound.left = r.left; if ( r.top < pRd->rdh.rcBound.top ) pRd->rdh.rcBound.top = r.top; if ( r.right > pRd->rdh.rcBound.right ) pRd->rdh.rcBound.right = r.right; if ( r.bottom > pRd->rdh.rcBound.bottom ) pRd->rdh.rcBound.bottom = r.bottom; memcpy( &pRd->Buffer[pRd->rdh.nCount++], &r, sizeof(RECT) ); if ( pRd->rdh.nCount >= dwMaxRect ) goto exitLoop; } lpData++; } } exitLoop: pRd->rdh.nRgnSize = sizeof(RECT) * pRd->rdh.nCount; hRgn = ExtCreateRegion( NULL, sizeof(RGNDATAHEADER) + sizeof(RECT) * pRd->rdh.nCount, pRd ); GlobalUnlock( hMem ); GlobalFree( hMem ); return hRgn; } bool DibAlphaMasking( LPBYTE lpDstDib, LPBYTE lpSrcDib, LPBYTE lpMaskDib ) { if ( !lpDstDib || !lpSrcDib || !lpMaskDib || DIB_BPP( lpSrcDib ) != DIB_BPP( lpMaskDib ) || DIB_BPP( lpDstDib ) != DIB_BPP( lpMaskDib ) || DIB_BPP( lpMaskDib ) != 8 ) return false; LPBYTE lpSrc, lpDst, lpMask; int x, y, cx, cy; cx = DIB_CX( lpMaskDib ); cy = DIB_CY( lpMaskDib ); if ( cx != DIB_CX( lpSrcDib ) || cy != DIB_CY( lpSrcDib ) || cx != DIB_CX( lpDstDib ) || cy != DIB_CY( lpDstDib ) ) return false; for ( y = 0; y < cy; y++ ) { lpSrc = DIB_DATAXY( lpSrcDib, 0, y ); lpDst = DIB_DATAXY( lpDstDib, 0, y ); lpMask = DIB_DATAXY( lpMaskDib, 0, y ); for ( x = 0; x < cx; x++ ) { *lpDst += (255 - *lpSrc) * *lpMask / 255; lpSrc++; lpDst++; lpMask++; } } return true; } //////////////////////////////////////////////////////////////////////////////// // filter bool DibInvert( LPBYTE lpSrcDib ) { LPBYTE lpSrc; int nSize, i; if ( !lpSrcDib ) return false; nSize = DIB_DATASIZE( lpSrcDib ); lpSrc = DIB_DATA( lpSrcDib ); for ( i = 0; i < nSize; i++, lpSrc++ ) *lpSrc = 0xff - *lpSrc; return true; }
8df1f80cbf39d16c93339251558049793177ad65
733da9a1460ea0fbddcfb2723ef5737ed5157796
/01/test1.cpp
7aff96da34f0aa4f0f7fce95a98dd707ccc569ee
[]
no_license
RuslanNarziev/msu_cpp_spring_2020
6d6d71e57b8e27a365f02e52071290f853e1abea
848d742d536e41a9b1280ebc0931a6e7bfbd5d86
refs/heads/master
2022-10-23T20:00:39.960559
2020-06-11T16:48:00
2020-06-11T16:48:00
246,590,206
0
0
null
null
null
null
UTF-8
C++
false
false
232
cpp
#include "task1.h" int main() { Allocator al; al.MakeAllocator(1000); if(al.Get_startptr() != NULL) std::cout << "Memory has allocated"; else std::cout << "Memory has not allocated"; return 0; }
7c27560a0c49fa5c6b919193f4ded9873816fd49
3a17418505f5c68564100f03caa789db2e214477
/testCases/Cavity/Hanhoun/non-ideality-comparison/cavity_stoich_MAPST_Gamma/435860/NH4
9b3012f38ec8ca2b420df5925a97c6d00771b868
[]
no_license
BJankauskas/mapFoam
2554798c7a4435c90e3f269e84c1c6e6109bb1e7
06200cf3a51da3e9a8d284d9df18f8634964dc1a
refs/heads/master
2020-05-24T16:31:26.833077
2019-05-21T18:40:15
2019-05-21T18:40:15
187,356,603
1
0
null
null
null
null
UTF-8
C++
false
false
1,139
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 4.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "435860"; object NH4; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; internalField uniform 1.24819e-05; boundaryField { fixedWalls { type zeroGradient; } frontAndBack { type empty; } movingWall { type zeroGradient; } } // ************************************************************************* //
04ed465116ac0efb1d47a98946432b12767dc9b7
d62df1592c497496d776c09b7394bc1a430d8f29
/src/client/TcpUser.cpp
af0ece6e23fa117697306f60809f69f9168fe9be
[ "MIT" ]
permissive
silent1603/boost-asio-udp-holepunching
0c9d23adf292fac9a4abc2151efbcdb37fd2dced
10acfa70ee23c0b9468ced7ceed935edf7c51aaf
refs/heads/main
2023-03-18T11:11:10.705038
2021-01-30T13:38:50
2021-01-30T13:38:50
null
0
0
null
null
null
null
ISO-8859-7
C++
false
false
2,023
cpp
/*****************************************************************//** * \file TcpUser.cpp * \brief * * \author wjden * \date January 2021 *********************************************************************/ #include "TcpUser.h" #include "network/UdpSocket.h" #include "server/SignalServerProtocol.h" static std::string GetIPString( UInt32 ip ) { unsigned char bytes[ 4 ]; bytes[ 0 ] = ip & 0xFF; bytes[ 1 ] = ( ip >> 8 ) & 0xFF; bytes[ 2 ] = ( ip >> 16 ) & 0xFF; bytes[ 3 ] = ( ip >> 24 ) & 0xFF; int ipString[ 4 ] = { bytes[ 3 ], bytes[ 2 ], bytes[ 1 ], bytes[ 0 ] }; return std::to_string( ipString[ 0 ] ) + "." + std::to_string( ipString[ 1 ] ) + "." + std::to_string( ipString[ 2 ] ) + "." + std::to_string( ipString[ 3 ] ); } TcpUser::TcpUser( boost::asio::io_context& ioContext, const tcp::resolver::results_type& endpoints ) : m_ioContext( ioContext ), m_tcpClient( std::make_shared< TcpClient >( ioContext, endpoints ) ) { m_tcpClient->SetReadCallback( std::bind( &TcpUser::OnRead, this, std::placeholders::_1 ) ); } void TcpUser::Write( const NetworkMessage& msg ) { m_tcpClient->Write( msg ); } void TcpUser::Close() { m_tcpClient->Close(); } void TcpUser::OnRead( NetworkMessage& networkMessage ) { networkMessage.ReadyToRead(); ProtocolId protocol = networkMessage.Read< ProtocolId >(); switch ( protocol ) { case ProtocolId::ProtocolUserAddressNotify: { UInt32 ip = networkMessage.Read< UInt32 >(); UInt32 port = networkMessage.Read< UInt16 >(); //ip port Γί°‘ std::string ipString = GetIPString( ip ); std::string portString = std::to_string( port ); UdpSocket udpSocket( m_ioContext, ipString, portString ); m_othersMutex.lock(); m_others.push_back( std::move( udpSocket ) ); m_othersMutex.unlock(); } break; default: break; } } void TcpUser::Broadcast( std::string msg ) { m_othersMutex.lock(); for ( auto& other : m_others ) { other.SendTo( msg.c_str(), msg.size() ); } m_othersMutex.unlock(); }
321c839042a0dd04e458296cbfd67dae77592e5f
81522472404dea65d77488778fa7e89990bf3453
/moveit_control/src/arm_moveit.cpp
b5bf9ba635d2c24f82da692ed033d643aac6d0dc
[ "MIT" ]
permissive
I-Quotient-Robotics/iqr_dual_jaco
b8a27a72943b4a3b179f2e90d2b30ecc70f4f90f
60e9d2de9eeb2f87b73c0eb6169b521b8d5bfc82
refs/heads/main
2023-08-22T23:58:29.452996
2021-03-24T06:14:04
2021-03-24T06:14:04
319,181,820
3
0
null
null
null
null
UTF-8
C++
false
false
5,052
cpp
#include <ros/ros.h> #include <string> #include <thread> #include <geometry_msgs/PoseStamped.h> #include <kinova_msgs/ArmPoseAction.h> #include <actionlib/client/simple_action_client.h> #include <std_msgs/Float64.h> #include <sensor_msgs/JointState.h> #include <geometry_msgs/Pose.h> #include <geometry_msgs/Twist.h> #include <geometry_msgs/PoseStamped.h> #include <geometry_msgs/TransformStamped.h> #include <kinova_msgs/ArmPoseAction.h> #include <actionlib/client/simple_action_client.h> #include <tf2/LinearMath/Quaternion.h> #include <tf2_ros/transform_listener.h> #include <tf2_ros/transform_broadcaster.h> #include <tf2_geometry_msgs/tf2_geometry_msgs.h> #include <moveit/move_group_interface/move_group_interface.h> #include <moveit/planning_scene_interface/planning_scene_interface.h> typedef actionlib::SimpleActionClient<kinova_msgs::ArmPoseAction> PoseClient; class PickTaskAction { public: ros::NodeHandle nh_; PoseClient pc_left_, pc_right_; moveit::planning_interface::PlanningSceneInterface planning_scene_interface; moveit::planning_interface::MoveGroupInterface robot_group; PickTaskAction(std::string name) : robot_group("robot_group"), pc_left_("left_arm_driver/pose_action/tool_pose", true), pc_right_("right_arm_driver/pose_action/tool_pose", true) { robot_group.setPlanningTime(5.0); } ~PickTaskAction(void) { } void ExcuteThread() { ros::AsyncSpinner spinner(3); spinner.start(); kinova_msgs::ArmPoseGoal eff_pose; // 末端沿z轴方向前移3cm eff_pose.pose.header.frame_id = "right_arm_end_effector"; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = 0.03; eff_pose.pose.pose.position.z = 0.05; eff_pose.pose.pose.position.z = 0.05; eff_pose.pose.pose.orientation.w = 1.0; pc_right_.sendGoal(eff_pose); pc_right_.waitForResult(ros::Duration(0.0)); ros::WallDuration(1.0).sleep(); // 末端沿z轴方向后移5cm eff_pose.pose.header.frame_id = "right_arm_end_effector"; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = -0.03; eff_pose.pose.pose.position.z = -0.05; eff_pose.pose.pose.position.z = -0.05; eff_pose.pose.pose.orientation.w = 1.0; pc_right_.sendGoal(eff_pose); pc_right_.waitForResult(ros::Duration(0.0)); ros::WallDuration(1.0).sleep(); return; } void SetArmPose(moveit::planning_interface::MoveGroupInterface& move_group, std::vector<double>& joint_value) { move_group.setJointValueTarget(joint_value); move_group.move(); } void SetGripper(moveit::planning_interface::MoveGroupInterface& move_group, double value) { std::vector<double> gripper_pose(2); gripper_pose[0] = value; gripper_pose[1] = value; // gripper_pose[2] = value; move_group.setJointValueTarget(gripper_pose); move_group.move(); } void moveit() { ros::AsyncSpinner spinner(3); spinner.start(); // 从config.yaml参数表中读取预设关节位置 std::vector<double> arm_standby_pose_right(12); nh_.getParam("arm_pose/home", arm_standby_pose_right); std::vector<double> arm_place_pose_right(12); nh_.getParam("arm_pose/pick", arm_place_pose_right); // 收回到standby位置 ROS_INFO("joint control standby"); robot_group.setJointValueTarget(arm_standby_pose_right); robot_group.move(); ros::WallDuration(1.0).sleep(); // 抓取位置 ROS_INFO("joint control pick"); robot_group.setJointValueTarget(arm_place_pose_right); robot_group.move(); ros::WallDuration(1.0).sleep(); // 开启新线程,独立完成右臂的位置控制 std::thread thread(&PickTaskAction::ExcuteThread, this); thread.detach(); kinova_msgs::ArmPoseGoal eff_pose; // 末端沿z轴方向前移3cm eff_pose.pose.header.frame_id = "left_arm_end_effector"; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = 0.03; eff_pose.pose.pose.orientation.w = 1.0; pc_left_.sendGoal(eff_pose); pc_left_.waitForResult(ros::Duration(0.0)); ros::WallDuration(1.0).sleep(); // 末端沿z轴方向后移3cm eff_pose.pose.header.frame_id = "left_arm_end_effector"; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = -0.03; eff_pose.pose.pose.orientation.w = 1.0; pc_left_.sendGoal(eff_pose); pc_left_.waitForResult(ros::Duration(0.0)); ros::WallDuration(1.0).sleep(); // 收回到standby位置 ROS_INFO("joint control standby"); robot_group.setJointValueTarget(arm_standby_pose_right); robot_group.move(); ros::WallDuration(1.0).sleep(); return; } }; int main(int argc, char** argv) { ros::init(argc, argv, "arm_control_node"); ros::NodeHandle nh; PickTaskAction pick("pick_task"); pick.moveit(); ros::waitForShutdown(); return 0; }
b2aa285f9351f27e8cee2375644727e7394f201e
c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64
/Engine/Plugins/Experimental/AlembicImporter/Source/ThirdParty/Alembic/openexr/OpenEXR/IlmImfTest/testNativeFormat.h
19c9ba673b5774baf1afb9c33174e9b323b70ed3
[ "BSD-3-Clause", "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
windystrife/UnrealEngine_NVIDIAGameWorks
c3c7863083653caf1bc67d3ef104fb4b9f302e2a
b50e6338a7c5b26374d66306ebc7807541ff815e
refs/heads/4.18-GameWorks
2023-03-11T02:50:08.471040
2022-01-13T20:50:29
2022-01-13T20:50:29
124,100,479
262
179
MIT
2022-12-16T05:36:38
2018-03-06T15:44:09
C++
UTF-8
C++
false
false
1,874
h
/////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2003-2012, Industrial Light & Magic, a division of Lucas // Digital Ltd. LLC // // 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 Industrial Light & Magic nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // /////////////////////////////////////////////////////////////////////////// #include <string> void testNativeFormat (const std::string &tempDir);
2d851542da8912c2371ab40a785173ed3b026ac8
6831e4284e70cd4c05c6fb5c7c6ff64352a4b674
/kopt/swap/SimpleSegment.h
85f3fa5f176f63b3629dac49ac703155aff7142d
[]
no_license
wangshgeo/2opt
7b0e8b8d4ed95123b637ad2cc0573d3200cb6150
bb9199f669a0ed427c23d83d9935c0715ef9bd24
refs/heads/master
2020-12-27T23:49:29.703294
2020-02-04T19:57:46
2020-02-04T19:57:46
238,109,691
0
0
null
2020-02-04T02:52:32
2020-02-04T02:52:31
null
UTF-8
C++
false
false
187
h
#pragma once // The two ints represent city IDs that make up a segment. // The IDs are in no particular order. #include <array> using SimpleSegment = std::array<std::size_t, 2>;
c3d3b121b6bf6728a4e2a66a38b6931eb7ba741e
afa181dce5c4f77a4f7bbc2740fc5063a018f694
/main.cpp
81e31978b7bf261a51fd73a18b95448d3abcf082
[]
no_license
romkas/UniRank
e9058d1a9ae60226a4bb032664ff5be6f1c81eea
4243bdf6317633904d618bf581a07a621df0502e
refs/heads/master
2021-01-10T04:22:58.599093
2018-02-04T12:51:37
2018-02-04T12:51:37
46,122,121
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
2,617
cpp
#include "Interface.h" #define DEBUG 0 using namespace std; int main() { setlocale(LC_ALL, "Russian"); list<VUZ> vList; const char* source = "C:\\Users\\ROM\\Desktop\\practise-2\\Source list.txt", * res = "C:\\Users\\ROM\\Desktop\\practise-2\\07-07-unite\\results_07-07-unite.txt", * res_baas = "C:\\Users\\ROM\\Desktop\\practise-2\\07-07-unite\\results_baas_07-07-unite.txt"; char c; cout<<"Reading file\n"; Readfile(source, vList); cout<<"Reading completed\n"; cout<<"Preparing\n"; Prepare(vList); cout<<"Prepared\n"; #if DEBUG == 1 const char filename[NUMSPECS + 1][STRLENG] = {"C:\\Users\\ROM\\Desktop\\practise-2\\07-04\\testhist_common_07-04.txt", "C:\\Users\\ROM\\Desktop\\practise-2\\07-04\\testhist_econom_07-04.txt", "C:\\Users\\ROM\\Desktop\\practise-2\\07-04\\testhist_manag_07-04.txt", "C:\\Users\\ROM\\Desktop\\practise-2\\07-04\\testhist_controls_07-04.txt", "C:\\Users\\ROM\\Desktop\\practise-2\\07-04\\testhist_inform_07-04.txt"}; cout<<"Recording histograms\n"; for(int k = 0;k < NUMSPECS + 1;k ++) for(Iter it = vList.begin(); it != vList.end(); it ++) if(it->h[k].numstudents > STUD_LIMIT) PrintHistogram(filename[k], *it, k); cout<<"Recorded\nEnd of debugging\n"; cin.get(); return 0; #else int histnum, indexnum; int mode,& m = mode; float** matrix = 0,**& mtx = matrix; PrintMenu(); while(true) { cout<<"<SELECT> "; cin>>c; cin.ignore(100, '\n'); switch( int(c)-int('0') ) { case(1): histnum = OnCountingJager(vList); indexnum = 0; SortJager(vList, histnum); PrintIndex(res, vList, histnum, indexnum); break; case(2): histnum = OnCountingCentroid(vList); indexnum = 1; SortCentr(vList, histnum); PrintIndex(res, vList, histnum, indexnum); break; case(3): histnum = OnCountingKerre(vList, m); // m = 2 или m = 3 SortmaxKerre(vList, histnum); PrintIndex(res, vList, histnum, mode); break; case(4): histnum = OnCountingBaas(vList, mtx); RangingBaas(vList, histnum, mtx); indexnum = 4; SortBaas(vList, histnum); PrintMatrix(res_baas, mtx, vList.size(), histnum); PrintIndex(res, vList, histnum, indexnum); DeleteBaasMatrix(mtx, vList.size()); break; case(5): histnum = OnCountingAvGrade(vList); indexnum = 5; SortAvGrade(vList, histnum); PrintIndex(res, vList, histnum, indexnum); break; case(6): histnum = OnCountingNumStud(vList); SortNumStud(vList, histnum); PrintNumStud(res, vList, histnum); break; case( int('q')-int('0') ): return 0; default: cout<<"Unknown option\n"; } } #endif }
fac73cb7690518efa4dd0364f40d6fe5daa3fb19
667786dd8dacdf6828ff329419f377f9a2112c0b
/Problems/HackerRank/Algorithms/Implementation/Kangaroo.cpp
c7d2d203ddd445ca8b9ae3ccf8f44fec2001d201
[]
no_license
BedirT/Algorithms_and_DS
50de96c8e707422f51510eda0e155880d76eed0e
083a6325b8be70108832eda1bf43eb9f3b9eb011
refs/heads/master
2022-09-09T22:29:55.090031
2022-09-06T22:04:06
2022-09-06T22:04:06
51,181,386
45
27
null
2020-03-06T10:36:26
2016-02-05T23:46:56
C++
UTF-8
C++
false
false
556
cpp
//https://www.hackerrank.com/challenges/kangaroo #include <iostream> using namespace std; int main(){ int x1; int v1; int x2; int v2; cin >> x1 >> v1 >> x2 >> v2; set<int> st; int count = 0; bool did = false; if((v1 >= v2 && x1 > x2) || (v1 <= v2 && x1 < x2)); else{ for(int i = 1; i <= 10000 ; ++i){ if(x1 + v1*i == x2 + v2*i){ did = true; break; } } } if(did) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
4e1d0c0f373ee0028f2f7971539ab7acdf83d84c
077700c6755d112f7d22559eaec319ec049bb8ba
/Practise/Basic C++/Ch 6/Overloaded Constructures.cpp
93b1099e3dc1863e1d5c57febaebe924877fce2c
[]
no_license
vaibhavdangayachvd/CPP-Programming
ce106daec0380c64edc101dc5c21b31ea708e75f
1882814699c62f89ceee2826d15fa51a8410db6c
refs/heads/master
2020-04-07T16:25:54.854692
2019-05-28T00:06:18
2019-05-28T00:06:18
158,522,795
0
0
null
null
null
null
UTF-8
C++
false
false
624
cpp
#include<iostream> using namespace std; class complex_ { float x,y; public: complex_(){} complex_(float a){x=y=a;} complex_(float rear,float imag){x=rear,y=imag;} friend complex_ sum(complex_,complex_); friend void show(complex_); }; complex_ sum(complex_ c1,complex_ c2) { complex_ c3; c3.x=c1.x+c2.x; c3.y=c1.y+c3.y; return c3; } inline void show(complex_ c) { cout<<c.x<<" + j"<<c.y<<endl; } int main() { complex_ a(3.7,3.5); complex_ b(1.6); complex_ c; c=sum(a,b); cout<<"A = ";show(a); cout<<"B = ";show(b); cout<<"C = ";show(c); return 0; }
3ac1a8c5d1c21ca940a0c014311ea5ce09865c82
1af49694004c6fbc31deada5618dae37255ce978
/chrome/browser/signin/e2e_tests/test_accounts_util.cc
c533ea0fb3cebc945a426009d85557f095096d58
[ "BSD-3-Clause" ]
permissive
sadrulhc/chromium
59682b173a00269ed036eee5ebfa317ba3a770cc
a4b950c23db47a0fdd63549cccf9ac8acd8e2c41
refs/heads/master
2023-02-02T07:59:20.295144
2020-12-01T21:32:32
2020-12-01T21:32:32
317,678,056
3
0
BSD-3-Clause
2020-12-01T21:56:26
2020-12-01T21:56:25
null
UTF-8
C++
false
false
2,396
cc
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/signin/e2e_tests/test_accounts_util.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/json/json_file_value_serializer.h" #include "base/json/json_reader.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" using base::Value; namespace signin { namespace test { #if defined(OS_WIN) std::string kPlatform = "win"; #elif defined(OS_MAC) std::string kPlatform = "mac"; #elif BUILDFLAG(IS_CHROMEOS_ASH) std::string kPlatform = "chromeos"; #elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) std::string kPlatform = "linux"; #elif defined(OS_ANDROID) std::string kPlatform = "android"; #else std::string kPlatform = "all_platform"; #endif TestAccountsUtil::TestAccountsUtil() = default; TestAccountsUtil::~TestAccountsUtil() = default; bool TestAccountsUtil::Init(const base::FilePath& config_path) { int error_code = 0; std::string error_str; JSONFileValueDeserializer deserializer(config_path); std::unique_ptr<Value> content_json = deserializer.Deserialize(&error_code, &error_str); CHECK(error_code == 0) << "Error reading json file. Error code: " << error_code << " " << error_str; CHECK(content_json); // Only store platform specific users. If an account does not have // platform specific user, try to use all_platform user. for (auto account : content_json->DictItems()) { const Value* platform_account = account.second.FindDictKey(kPlatform); if (platform_account == nullptr) { platform_account = account.second.FindDictKey("all_platform"); if (platform_account == nullptr) { continue; } } TestAccount ta(*(platform_account->FindStringKey("user")), *(platform_account->FindStringKey("password"))); all_accounts_.insert( std::pair<std::string, TestAccount>(account.first, ta)); } return true; } bool TestAccountsUtil::GetAccount(const std::string& name, TestAccount& out_account) const { auto it = all_accounts_.find(name); if (it == all_accounts_.end()) { return false; } out_account = it->second; return true; } } // namespace test } // namespace signin
68464369f577cad7d0a68a563fd62aa5c208355b
8a75a84761d998fccb34f2d3b182c221ba01dbd5
/Other leetCode codes/4Sum/main.cpp
35b659d35cdeaa5ae2626f8c91bb76b7082e209f
[]
no_license
danqiuBear/Cplusplus-Demo
18eeda35585f4f6216605699043460f11ad941a6
37ffebbfbb231aca56753bbf78a9ecad506c63a2
refs/heads/master
2020-06-13T19:45:26.454893
2019-08-23T08:59:29
2019-08-23T08:59:29
194,769,443
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
4,210
cpp
#include"iostream" #include"vector" #include"algorithm" #include"unordered_map" using namespace std; class Solution{ public: vector<vector<int>> fourSum(vector<int> &nums, int target){ vector < vector<int>> result; if (nums.size() < 4) return result; sort(nums.begin(), nums.end()); unordered_map<int, vector<pair<int, int>>> cache; for (size_t a = 0; a < nums.size(); ++a){ for (size_t b = a + 1; b < nums.size(); ++b){ cache[nums[a] + nums[b]].push_back(pair<int, int>(a, b)); } } for (int c = 0; c < nums.size(); ++c){ for (size_t d = c + 1; d < nums.size(); ++d){ const int key = target - nums[c] - nums[d]; if (cache.find(key) == cache.end()) continue; const auto&vec = cache[key]; for (size_t k = 0; k < vec.size(); ++k){ if (c <= vec[k].second) continue;//ÓÐÖØµþ result.push_back({ nums[vec[k].first], nums[vec[k].second], nums[c], nums[d] }); } } } sort(result.begin(), result.end()); result.erase(unique(result.begin(), result.end()), result.end()); return result; } public: vector<vector<int>> fourSum2(vector<int> &nums, int target){ vector < vector<int>> result; if (nums.size() < 4) return result; sort(nums.begin(), nums.end()); unordered_multimap<int, pair<int, int>> cache; for (size_t i = 0; i < nums.size() - 1; ++i){ for (size_t j = i + 1; j < nums.size(); ++j){ cache.insert(make_pair(nums[i] + nums[j], make_pair(i, j))); } } for (unordered_multimap<int, pair<int, int>>::iterator i = cache.begin(); i != cache.end(); ++i){ int x = target - i->first; /* _Pairii equal_range(const key_type& _Keyval) { // find range equivalent to _Keyval in mutable hash table size_type _Bucket = _Hashval(_Keyval); for (_Unchecked_iterator _Where = _Begin(_Bucket); _Where != _End(_Bucket); ++_Where) if (!((_Traits&)*this)(this->_Kfn(*_Where), _Keyval)) { // found _First, look for end of range _Unchecked_iterator _First = _Where; for (; _Where != _End(_Bucket); ++_Where) if (((_Traits&)*this)(_Keyval, this->_Kfn(*_Where))) break; if (_First == _Where) break; return (_Pairii(_Make_iter(_First), _Make_iter(_Where))); } return (_Pairii(end(), end())); } */ //typedef pair<iterator, iterator> _Pairii; pair<unordered_multimap<int, pair<int, int>>::iterator, unordered_multimap<int, pair<int, int>>::iterator> range = cache.equal_range(x); for (auto j = range.first; j != range.second; ++j){ auto a = i->second.first; auto b = i->second.second; auto c = j->second.first; auto d = j->second.second; if (a != c && a != d && b != c && b != d){ vector<int> vec = { nums[a], nums[b], nums[c], nums[d] }; sort(vec.begin(), vec.end()); result.push_back(vec); } } } sort(result.begin(), result.end()); result.erase(unique(result.begin(), result.end()), result.end()); return result; } }; int main01() { Solution s; vector<int> v; v.push_back(1); v.push_back(0); v.push_back(-1); v.push_back(0); v.push_back(-2); v.push_back(2); int target = 0; vector<vector<int>> result = s.fourSum2(v, target); for (vector<vector<int>>::iterator i = result.begin(); i != result.end(); ++i){ for (int j = 0; j < (*i).size();++j){ cout << (*i)[j] << " "; } cout << endl; } system("pause"); return 1; } int main() { Solution s; vector<int> v; v.push_back(1); v.push_back(2); v.push_back(2); v.push_back(3); v.push_back(4); v.push_back(4); v.push_back(4); v.push_back(4); v.push_back(5); v.push_back(6); v.push_back(7); v.push_back(9); v.push_back(9); v.push_back(10); vector<int>::iterator i = prev(v.end()); cout <<"prev(v.end()) equals to :"<<(*i) << " "<< endl; vector<int>::iterator j = prev(v.end(),4); cout << "prev(v.end(),4) equals to :" << (*j) << " "<< endl; vector<int>::iterator k = lower_bound(v.begin(), v.end(), 4); cout << "lower_bound(v.begin(), v.end(), 4) equals to :" << (*k) << " "<< endl; cout << *(k + 4)<<endl; vector<int>::iterator m = upper_bound(v.begin(), v.end(), 4); cout << "upper_bound(v.begin(), v.end(), 4) equals to :" << (*m) << " " << endl; system("pause"); return 1; }
e9787321b56bcf364d58477b4f13ba8a4ac71ac0
6e3e4f6b43d308ca742d40acfec84e9985e75355
/动规/拆分问题/343_Integer Break.cpp
5016b1ce79410ea7680a5bcefad6439c3a8b135b
[]
no_license
HannahTin/Leetcode
a4a32700125333a10209f4401eec38d372aff1d4
6febfc026bf9b584e7b482b435dac7689fa2aa33
refs/heads/master
2022-05-28T16:04:51.393960
2022-03-20T08:22:57
2022-03-20T08:22:57
205,310,250
0
0
null
null
null
null
UTF-8
C++
false
false
1,338
cpp
/* 343. 整数拆分 给定一个正整数 n ,将其拆分为 k 个 正整数 的和( k >= 2 ),并使这些整数的乘积最大化。 返回 你可以获得的最大乘积 。 示例 1: 输入: n = 2 输出: 1 解释: 2 = 1 + 1, 1 × 1 = 1。 示例 2: 输入: n = 10 输出: 36 解释: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36。 */ using namespace std; #include <vector> class Solution { public: // 其实可以从1遍历j,然后有两种渠道得到dp[i]. // 一个是j * (i - j) 直接相乘。 // 一个是j * dp[i - j],相当于是拆分(i - j),对这个拆分不理解的话,可以回想dp数组的定义。 int integerBreak(int n) { vector<int> dp(n+1); dp[2]=1; for(int i=3;i<=n;i++){ for(int j=1;j<i-1;j++){ dp[i]=max(dp[i],max(dp[i-j]*j,j*(i-j))); } } return dp[n]; } }; class Solution { public: // 本题也可以用贪心,每次拆成n个3,如果剩下是4,则保留4,然后相乘,但是这个结论需要数学证明其合理性! int integerBreak(int n) { if (n == 2) return 1; if (n == 3) return 2; if (n == 4) return 4; int result = 1; while (n > 4) { result *= 3; n -= 3; } result *= n; return result; } };
4430eaf28a36cd2a2d4428597d0db2484ca95e01
cb6b7e15efd75a696f5144701e584f734ff1b713
/chapter 1/1.8.3 买房子.cpp
c2b3eb4e1d7473e138cd14730f0ea27831433e19
[]
no_license
Zhulinjiuying/C-Plus-homework
7d9d523eb282c996b7a176f0c8ca7d44997114d2
74aaef369e280c028f7bdc86528c6eb30e23c9e3
refs/heads/master
2021-08-07T05:02:48.054957
2017-11-07T15:58:07
2017-11-07T15:58:07
109,857,223
0
0
null
null
null
null
UTF-8
C++
false
false
778
cpp
#include <iostream> using namespace std; int main() { int m, flag, a[100], b[100]; int i = 0; double sum = 200.0; flag = 0; m = 1; while (cin >> a[i] >> b[i]) i++; for (int j = 0; j < i; j++) { if (a[j] < 10 || a[j] > 50 || b[j] < 1 || b[j] > 20) { return -1; } if (a[j] == sum) { cout << m << endl; return 0; } m = 2; while (m <= 20) { if (a[j] * m >= sum * (1 + b[j] * 0.01)) { flag = 1; break; } sum *= (1 + b[j] * 0.01); m++; } if (flag == 1) cout << m << endl; else cout << "Impossible" << endl; flag = 0; sum = 200.0; } return 0; }
c29d28ea6df51822aba67f69dd0959d578eeee7f
bb3d0592b9cdc7821b37ff3db2db764e8d15f83a
/Src/VkWrapper/Fence.cpp
f75a6626444f358e63150bf4c2f2d4f184a7bea9
[]
no_license
Vismar/Conure2D
7a464a24407d301f76fcd7ddfc1f7de8c30e4b54
e7f4a311a1096a10d465755b176ffc336c4d9f15
refs/heads/master
2022-05-01T22:42:32.973420
2021-02-27T20:17:13
2021-02-27T20:17:13
114,643,545
4
0
null
2019-03-12T12:20:29
2017-12-18T13:20:04
C++
UTF-8
C++
false
false
1,092
cpp
#include "Fence.hpp" #include <Utility/Assert.hpp> #include <Tracer/TraceScopeTimer.hpp> using namespace VkWrapper; // --------------------------------------------------------------------------------------------------------------------- Fence::Fence(VkDevice lDevice) : _lDevice(lDevice) , _fence(nullptr) { TraceIt; VkFenceCreateInfo createInfo = { .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, .flags = VK_FENCE_CREATE_SIGNALED_BIT }; Assert(vkCreateFence(_lDevice, &createInfo, nullptr, &_fence) == VK_SUCCESS, "Failed to create fence"); } // --------------------------------------------------------------------------------------------------------------------- Fence::~Fence() { vkDestroyFence(_lDevice, _fence, nullptr); } // --------------------------------------------------------------------------------------------------------------------- const VkFence& Fence::GetHandle() const { return _fence; } // ---------------------------------------------------------------------------------------------------------------------
38eab113c40502febb90a0b732cd993ab9ac75cf
640e4a63662602237df205f403f469819b960b3e
/ykt/src/upayposvr/ecardmain.pc
2fe2529d1f7805397009bf6950111f21d9de6da0
[]
no_license
paipeng/bank_interface
9663972170ca3340326e7a65bf8f2406532515b2
060faf778bbb084a5aa921b2b1d9d165968f1703
refs/heads/master
2023-03-20T10:36:46.112213
2014-04-14T10:03:59
2014-04-14T10:03:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,410
pc
#include <stdio.h> #include <iostream> #include <fstream> #include "logger_imp.h" #include "config_imp.h" #include "unitfunc.h" #include "unitprocess.h" #include<iostream> #include<string> #include<sstream> #include "ks_8583_reader.h" using namespace std; int main(int argc, char* argv[]) { char szVersion[64]; sprintf(szVersion, "ecardsvr %s (%s %s)", YKT_VERSION, __DATE__, __TIME__); const char short_opts[] = "vs"; int option; while((option = getopt(argc, argv, short_opts)) != -1) { switch(option) { case 'v': cout << szVersion << endl; return 0; case 's': break; default: cout << "invalid option" << endl; return -1; } } string conf = argv[0]; conf = conf + ".conf"; if(!init_config(conf)) { cout << "init config file "<<conf<<" faild" << endl; return -1; } if(!init_logger(config_obj.log_conf)) { cout << "log config file "<<config_obj.log_conf <<" "<< endl; return -2; } LOG(DEBUG, "init log OK"); char parserName[128]={0}; int ret=Ks8583Parser::Load8583Define("unionpaypos.dat",parserName); if(ret) { LOG(ERROR,"load unionpaypos.dat configfile failed! ret="<<ret); return ret; } LOG(DEBUG,"load "<<parserName<<" 8583 configfile OK"); LOG(INFO, "version:" << szVersion); UnitProcess Process; LOG(DEBUG, "start service"); Process.run(); return 0; } // vim: ts=2 et ft=cpp
488ceaa61531dd92df1624e573d3e2a6bf248e97
98f10c77b9932915eb9f37d9cf79a83094342444
/URI/2018.cpp
b4171ffab5649ef7291300def7340fa6a5611583
[]
no_license
lucianovr/competitive-programming
b5ba55a5055e486862c0c8b62e61c86e41b8f2b8
bd95492bb8a14563603a5a2d74e3c1676a4a61e6
refs/heads/master
2022-09-10T04:54:07.417831
2020-05-28T00:33:36
2020-05-28T00:33:36
267,455,557
0
0
null
null
null
null
UTF-8
C++
false
false
3,081
cpp
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i < (b); i++) #define all(c) c.begin(), c.end() #define UNIQUE(c) \ { sort(ALL(c); (c).resize( unique(ALL(c))-c.begin() ); \ } #define pb push_back #define D(x) \ if (1) \ cout << __LINE__ << " " << #x " = " << (x) << endl; #define DVEC(v, n) \ { \ cout << #v << "[] ={ "; \ rep(i, 0, n) cout << v[i] << " "; \ cout << "}\n"; \ } #define mp make_pair #define fst first #define snd second typedef pair<int, int> ii; typedef long long ll; typedef vector<int> vi; typedef vector<ii> vii; const int INF = 0x3f3f3f3f; const double EPS = 1e-9; struct pais { string nome; int o, p, b; pais(){}; pais(string _nome, int _o, int _p, int _b) { nome = _nome; o = _o; p = _p; b = _b; } }; vector<pais> R; // ranking dos paises bool comp(pais A, pais B) { if (A.o > B.o) return true; if (A.o < B.o) return false; if (A.p > B.p) return true; if (A.p < B.p) return false; if (A.b > B.b) return true; if (A.b < B.b) return false; if (A.nome < B.nome) return true; if (A.nome > B.nome) return false; } int main() { string tipo, A, B, C; map<string, int> mapa; int id = 0; while (getline(cin, tipo)) { getline(cin, A); if (mapa.count(A) == 0) { mapa[A] = id; R.pb(pais(A, 1, 0, 0)); id++; } else R[mapa[A]].o++; getline(cin, B); if (mapa.count(B) == 0) { mapa[B] = id; R.pb(pais(B, 0, 1, 0)); id++; } else R[mapa[B]].p++; getline(cin, C); if (mapa.count(C) == 0) { mapa[C] = id; R.pb(pais(C, 0, 0, 1)); id++; } else R[mapa[C]].b++; } sort(R.begin(), R.end(), comp); cout << "Quadro de Medalhas\n"; rep(i, 0, R.size()) { cout << R[i].nome << " " << R[i].o << " " << R[i].p << " " << R[i].b << "\n"; } return 0; }
7a39a64cfa11459597063a213dfe00b18e43e368
cdab2ef737a481a92fee3e08bbdb7227adbb4259
/typecd/udev_monitor.h
d1fed9c3a1672dbfdea9c20fe92d36f64934efe8
[ "BSD-3-Clause" ]
permissive
manduSry/platform2
a2c1c829e45356b920e6c7ba546324e6d6decfdf
58ede23d2f4cd5651b7afaae5c78893cc836f01d
refs/heads/main
2023-04-06T19:06:50.384147
2020-12-30T04:41:55
2021-01-20T04:53:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,366
h
// Copyright 2020 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef TYPECD_UDEV_MONITOR_H_ #define TYPECD_UDEV_MONITOR_H_ #include <libudev.h> #include <map> #include <memory> #include <string> #include <utility> #include <base/files/file_descriptor_watcher_posix.h> #include <base/files/file_path.h> #include <base/observer_list.h> #include <base/observer_list_types.h> #include <brillo/udev/mock_udev.h> #include <gtest/gtest_prod.h> namespace typecd { constexpr char kTypeCSubsystem[] = "typec"; constexpr char kUdevMonitorName[] = "udev"; // Class to monitor udev events on the Type C subsystem and inform other // objects / classes of these events. class UdevMonitor { public: UdevMonitor() = default; // Create a Udev device for enumeration and monitoring. bool InitUdev(); // Enumerate all existing events/devices, and send the appropriate // notifications to other classes. bool ScanDevices(); // Start monitoring udev for typec events. bool BeginMonitoring(); class Observer : public base::CheckedObserver { public: virtual ~Observer() {} // Callback that is executed when a port is connected or disconnected. // // The |path| argument refers to the sysfs device path of the port. // The |port_num| argmnet refers to the port's index number. // The |added| argument is set to true if the port was added, and false // otherwise. virtual void OnPortAddedOrRemoved(const base::FilePath& path, int port_num, bool added) = 0; // Callback that is executed when a port partner is connected or // disconnected. // // The |path| argument refers to the sysfs device path of the port partner. // The |port_num| argument refers to the port's index number. // The |added| argument is set to true if the partner was added, and false // otherwise. virtual void OnPartnerAddedOrRemoved(const base::FilePath& path, int port_num, bool added) = 0; // Callback that is executed when a port partner alt mode is registered or // removed. // // The |path| argument refers to the sysfs device path of the partner alt // mode. The |port_num| argmnet refers to the port's index number. The // |added| argument is set to true if the alt mode was added, and false // otherwise. virtual void OnPartnerAltModeAddedOrRemoved(const base::FilePath& path, int port_num, bool added) = 0; // Callback that is executed when a port cable is connected or // disconnected. // // The |path| argument refers to the sysfs device path of the port cable. // The |port_num| argument refers to the port's index number. // The |added| argument is set to true if the cable was added, and false // otherwise. virtual void OnCableAddedOrRemoved(const base::FilePath& path, int port_num, bool added) = 0; // Callback that is executed when a cable plug (SOP') device is registered. // // The |path| argument refers to the sysfs device path of the cable plug // (SOP'). The |port_num| argument refers to the port's index number. virtual void OnCablePlugAdded(const base::FilePath& path, int port_num) = 0; // Callback that is executed when a cable (SOP') alternate mode is // registered. // // The |path| argument refers to the sysfs device path of the cable (SOP') // alternate mode. The |port_num| argument refers to the port's index // number. virtual void OnCableAltModeAdded(const base::FilePath& path, int port_num) = 0; // Callback that is executed when a partner "change" event is received. // // The |port_num| argument refers to the port's index number. virtual void OnPartnerChanged(int port_num) = 0; }; void AddObserver(Observer* obs); void RemoveObserver(Observer* obs); private: friend class UdevMonitorTest; FRIEND_TEST(UdevMonitorTest, TestBasic); FRIEND_TEST(UdevMonitorTest, TestHotplug); FRIEND_TEST(UdevMonitorTest, TestInvalidPortSyspath); FRIEND_TEST(UdevMonitorTest, TestCableAndAltModeAddition); FRIEND_TEST(UdevMonitorTest, TestPartnerChanged); // Set the |udev_| pointer to a MockUdev device. *Only* used by unit tests. void SetUdev(std::unique_ptr<brillo::MockUdev> udev) { udev_ = std::move(udev); } // Handle a udev event which causes a Type C device to be added/removed. bool HandleDeviceAddedRemoved(const base::FilePath& path, bool added); // Handle a udev "change" event for a Type C device. void HandleDeviceChange(const base::FilePath& path); // Handle Udev events emanating from |udev_monitor_watcher_|. void HandleUdevEvent(); std::unique_ptr<brillo::Udev> udev_; std::unique_ptr<brillo::UdevMonitor> udev_monitor_; std::unique_ptr<base::FileDescriptorWatcher::Controller> udev_monitor_watcher_; base::ObserverList<Observer> observer_list_; }; } // namespace typecd #endif // TYPECD_UDEV_MONITOR_H_
1be66b82af907107c2e41e4c6fa213ec8220eeaa
f0cd5d5b2e4eeedb40003aeab11bd96ed6230c3d
/GeometricFormGL/triangle.cpp
6b164486f857ce8e40cdd2ef2134034fde2c7fff
[]
no_license
ELezov/OpenGL-glut
3e322b0dac4e26a78dcd9e492abbe5662e1aec4d
1095a4499f5f3b171caca800c7db23e7569b87d0
refs/heads/master
2020-04-06T04:05:02.624739
2016-06-15T23:59:18
2016-06-15T23:59:18
58,453,787
0
0
null
null
null
null
UTF-8
C++
false
false
621
cpp
#include "triangle.h" Triangle::Triangle(QGLWidget *parent) : x0(-200.0f), y0(0.0f), t(10.1f) { } void Triangle::setX0() { if(x0>201) { t=-t; } if(x0<-201) { t=-t; } x0=x0+t+100; // qDebug() << x0 ; a++; } void Triangle::setY0() { y0=cos(x0/5)*5; } void Triangle::slotMove() { setX0(); setY0(); glBegin(GL_TRIANGLES); glColor3d(0,0,1); glVertex3d(x0,y0,0); glColor3d(0,1,0); glVertex3d(x0+15.5,y0+15.5,0); glColor3d(1,0,0); glVertex3d(x0,y0+15.5,0); glEnd(); //updateGL(); }
957ab7501e88b40aec241ffa33b02c33875aa3e0
293902682d7ee13be81ada6c28ef6b840983ac33
/Tests/Integration_ConnectionService_ConnectionPool/src/main.cpp
836c84dfe574722e1164e418681f45eb61ffddb9
[]
no_license
cms-externals/coral
d17cba45fff7f34d7a1ba13ab3bb371e0696c1af
a879b41c994fa956ff0ae78e3410bb409582ad20
refs/heads/cms/CORAL_2_3_21py3
2022-02-26T18:51:25.258362
2022-02-23T13:19:11
2022-02-23T13:19:11
91,173,895
0
4
null
2022-02-14T13:20:11
2017-05-13T12:47:54
C++
UTF-8
C++
false
false
389
cpp
#include "TestApp.h" #include "CoralBase/Exception.h" #include <iostream> #include <exception> #include <cstdlib> int main(int argc, char *argv[]) { TestApp app("CS_CPOOL"); if(app.check(argc, argv)) { app.addServiceName(TEST_CORE_SCHEME_ADMIN); app.addServiceName(TEST_CORE_SERVICE_2); try { app.run(); } TESTCORE_FETCHERRORS } return 1; }
35d5e9313b6bad6f757846d58b00f4db7d3b06d2
d66dcbaa2d13697d67f750fd28b48a020ea66cc8
/sql_functions.cpp
92df7b9346d53974cb8058e99f06fb4b1b2955c3
[]
no_license
huhongbo/ospfscan
f61726bd34914ec2f6294b61adbda85484991160
10ca7c28033a40796f43dfdb7eac219da47db93f
refs/heads/master
2020-07-10T06:34:13.025195
2012-10-11T00:02:21
2012-10-11T00:02:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,908
cpp
#include "591.h" int insert_router(sqlite3 *db, ospf_t *ospf, ospf_lsa_t *lsa) { char sql[1024]; snprintf(sql, sizeof(sql), "INSERT OR REPLACE INTO routers (router_id, area) VALUES ('%s',%i)", inet_ntoa(lsa->ospf_lsa_adv_router),ospf->ospf_area.s_addr); char *error; int res = sqlite3_exec(db, sql, NULL, NULL, &error); if(error != NULL) { printf("ERROR: %s\n", error); } sqlite3_free(error); return res; } int check_router_interface(sqlite3 *db, in_addr id, list<in_addr> links) { char query[1024] = "("; list<in_addr>::iterator it; char adv_router[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &id, adv_router, INET_ADDRSTRLEN); char lsa_ls_id[INET_ADDRSTRLEN]; for(it=links.begin(); it != links.end(); it++) { if(it != links.begin()) { strcat(query, ","); } inet_ntop(AF_INET, &(*it), lsa_ls_id, INET_ADDRSTRLEN); strcat(query, "'"); strcat(query, lsa_ls_id); strcat(query, "'"); } strcat(query, ")"); char sql[2048] = ""; snprintf(sql, sizeof(sql), "UPDATE interfaces SET valid = '0' WHERE router_id='%s' AND interface_id NOT IN %s", adv_router, query); printf("SQL: %s\n", sql); char *error; int res = sqlite3_exec(db, sql, NULL, NULL, &error); if(error != NULL) { printf("ERROR: %s\n", error); } sqlite3_free(error); return res; } int insert_external_route(sqlite3 *db, ospf_lsa_t *lsa, ospf_as_external_lsa_t *external) { char sql[1024] = ""; char adv_router[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(lsa->ospf_lsa_adv_router), adv_router, INET_ADDRSTRLEN); char lsa_ls_id[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(lsa->ospf_lsa_ls_id), lsa_ls_id, INET_ADDRSTRLEN); char network[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(external->ospf_as_external_network), network, INET_ADDRSTRLEN); snprintf(sql, sizeof(sql), "SELECT count(*) FROM external WHERE router_id='%s' AND prefix='%s' AND prefix_mask='%s'", adv_router, lsa_ls_id, network); printf("%s\n", sql); char **results; int rows; int cols; char *err; //printf("%s\n", sql); int res = sqlite3_get_table(db, sql, &results, &rows, &cols, &err); if(atoi(results[1]) == 0) { snprintf(sql, sizeof(sql), "INSERT OR REPLACE INTO external (router_id, prefix, prefix_mask) VALUES ('%s','%s','%s')", adv_router, lsa_ls_id, network); char *error; res = sqlite3_exec(db, sql, NULL, NULL, &error); if(error != NULL) { printf("ERROR: %s\n", error); } sqlite3_free(error); } sqlite3_free_table(results); return res; } int update_external_route(sqlite3 *db, ospf_lsa_t *lsa, ospf_as_external_lsa_t *external) { char sql[1024] = ""; char adv_router[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(lsa->ospf_lsa_adv_router), adv_router, INET_ADDRSTRLEN); char lsa_ls_id[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(lsa->ospf_lsa_ls_id), lsa_ls_id, INET_ADDRSTRLEN); char network[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(external->ospf_as_external_network), network, INET_ADDRSTRLEN); snprintf(sql, sizeof(sql), "UPDATE external SET expiry = '%i' WHERE router_id = '%s' AND prefix = '%s' AND prefix_mask = '%s'", (int)(time(NULL) + htons(lsa->ospf_lsa_age)), adv_router, lsa_ls_id, network); printf("SQL: %s\n", sql); printf("Current Time: %i \t Expiry Time: %i\n", (int)time(NULL), (int)(time(NULL) + htons(lsa->ospf_lsa_age))); char *error; int res = sqlite3_exec(db, sql, NULL, NULL, &error); if(error != NULL) { printf("ERROR: %s\n", error); } sqlite3_free(error); return res; } int invalidateRoutes(sqlite3 *db, ospf_lsa_t *lsa, list<in_addr> routes) { return 0; } int numberOfResults(sqlite3 *db, char *zSQL) { int rows; sqlite3_get_table(db, zSQL, NULL, &rows, NULL, NULL); return rows; } int insert_router_interface(sqlite3 *db, ospf_lsa_t *lsa, ospf_link_t *link) { char sql[1024] = ""; char adv_router[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(lsa->ospf_lsa_adv_router), adv_router, INET_ADDRSTRLEN); char lsa_link_id[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(link->ospf_router_lsa_link_id), lsa_link_id, INET_ADDRSTRLEN); snprintf(sql, sizeof(sql), "SELECT count(*) FROM interfaces WHERE router_id='%s' AND interface_id='%s'", adv_router, lsa_link_id); char **results; int rows; int cols; char *err; //printf("%s\n", sql); int res = sqlite3_get_table(db, sql, &results, &rows, &cols, &err); if(atoi(results[1]) == 0) { snprintf(sql, sizeof(sql), "INSERT OR REPLACE INTO interfaces (router_id, interface_id, valid) VALUES ('%s','%s',1)", adv_router, lsa_link_id); char *error; res = sqlite3_exec(db, sql, NULL, NULL, &error); if(error != NULL) { printf("ERROR: %s\n", error); } printf("%s\n", sql); sqlite3_free(error); } sqlite3_free_table(results); return res; }
8d9276b8322f20927a57d9a6545c83b05e40f2ac
2a89e46324a6e0dfa5cad89801379d593a12a4c1
/lua/models/onnx/lua_onnx_runtime_builder_factory.cc
d4654f6c7649227204da2a0a874c5cce0a337726
[ "Apache-2.0" ]
permissive
fzhsbc/ppl.nn
16ca2a4991316cfee2eb40a48a3003caf5dfac70
370a3ff5296b3c2d8768bb2f5220eaa5e65a94a7
refs/heads/master
2023-09-03T18:40:29.524548
2021-11-09T07:59:04
2021-11-09T08:45:10
426,165,992
0
0
Apache-2.0
2021-11-09T09:26:13
2021-11-09T09:26:13
null
UTF-8
C++
false
false
2,262
cc
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you 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 "../../engines/lua_engine.h" #include "ppl/nn/models/onnx/onnx_runtime_builder_factory.h" #include "../../runtime/lua_runtime_builder.h" #include "luacpp.h" using namespace std; using namespace luacpp; namespace ppl { namespace nn { namespace lua { void RegisterOnnxRuntimeBuilderFactory(const shared_ptr<LuaState>& lstate, const shared_ptr<LuaTable>& lmodule) { auto builder_class = LuaClass<LuaRuntimeBuilder>(lmodule->Get("RuntimeBuilder")); auto lclass = lstate->CreateClass<OnnxRuntimeBuilderFactory>() .DefStatic("CreateFromFile", [builder_class, lstate](const char* model_file, const LuaTable& engines) -> LuaObject { vector<shared_ptr<Engine>> engine_list; engines.ForEach([&engine_list](uint32_t, const LuaObject& value) -> bool { engine_list.push_back(LuaUserData(value).Get<LuaEngine>()->ptr); return true; }); vector<Engine*> engine_ptrs(engine_list.size()); for (uint32_t i = 0; i < engine_list.size(); ++i) { engine_ptrs[i] = engine_list[i].get(); } auto builder = OnnxRuntimeBuilderFactory::Create(model_file, engine_ptrs.data(), engine_ptrs.size()); if (!builder) { return lstate->CreateNil(); } return builder_class.CreateUserData(engine_list, builder); }); lmodule->Set("OnnxRuntimeBuilderFactory", lclass); } }}}
407e620acc78923922702020f0c47acb9b165fc4
6d03fbf380c7c501e448cd3df7747b311f599c26
/Lab04/Timer.h
cac9d0225a4e76dd7ba95a09e456945bb0235322
[]
no_license
ashlimosiman/EECS_560
cb3e2ac4acead16e304896fb29c2cce02c7b0302
00f292096785495e21907a8279e25c067f36b59a
refs/heads/master
2021-01-11T16:10:20.560114
2017-04-19T04:16:42
2017-04-19T04:16:42
80,026,482
0
0
null
null
null
null
UTF-8
C++
false
false
560
h
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> using namespace std; class Timer { private: timeval startTime; timeval endTime; public: void start(){ gettimeofday(&startTime, NULL); } double stop(){ long seconds, nseconds; double duration; gettimeofday(&endTime, NULL); seconds = endTime.tv_sec - startTime.tv_sec; nseconds = endTime.tv_usec - startTime.tv_usec; duration = seconds + nseconds/1000000.0; return duration; } void printTime(double duration){ printf("%5.6f seconds\n", duration); } };
572281e44ec6cf8712204058a049758592c9c54f
d1f5cbc5b9a9c9d9aa8a9d8e34c6c4857f893d9e
/src/libtid/sdl_tid_client.h
7d68f723eb0ca9828f6a947309f02501d4ccdd43
[]
no_license
tools4BCI/core
fcdc3abd57c49281247c5801a7c092fdda3d4447
2aee8c29334e6e00a375b86235bf27cbbc284dc5
refs/heads/master
2020-09-26T07:59:55.079724
2017-04-24T17:18:18
2017-04-24T17:18:18
66,266,070
1
1
null
null
null
null
UTF-8
C++
false
false
1,760
h
/* This file is part of TOBI Interface D (TiD). TOBI Interface D (TiD) is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. TOBI Interface D (TiD) is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with TOBI Interface D (TiD). If not, see <http://www.gnu.org/licenses/>. Copyright 2012 Christian Breitwieser Contact: [email protected] */ #ifndef SDL_TID_CLIENT_H #define SDL_TID_CLIENT_H #include "tid_client_base.h" #include <SDL/SDL_thread.h> //----------------------------------------------------------------------------- namespace TiD { class SDLTiDClient : public TiDClientBase { public: SDLTiDClient(); virtual ~SDLTiDClient(); virtual void startReceiving( bool throw_on_error = 0 ); virtual void stopReceiving(); private: static int run_io_service(void* instance); //static int SDLreceive(void *instance); private: SDL_Thread* receive_thread_; SDL_Thread* io_service_thread_; SDL_Thread* io_service_thread_2_; }; //----------------------------------------------------------------------------- } //TiD #endif // SDL_TID_CLIENT_H
64a0862b5a50f5574ecd519f2a445e884f3aa0ba
fe39e4d1bca62d7bff7b6713b8b596d88f8aa354
/src/plugins/3rdparty/LLVM/include/llvm/Intrinsics.h
3f56bbdae24c5c632f92e975464bbb4b308d100a
[]
no_license
panpanSun/opencor
a29a806475f43adb0f64047631d4dc044f05e030
71449e1ecaa988ea8b6cfea7875d9f3593a8dc26
refs/heads/master
2020-12-24T11:53:33.902565
2013-04-20T18:59:29
2013-04-20T18:59:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,094
h
//===-- llvm/Instrinsics.h - LLVM Intrinsic Function Handling ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file defines a set of enums which allow processing of intrinsic // functions. Values of these enum types are returned by // Function::getIntrinsicID. // //===----------------------------------------------------------------------===// #ifndef LLVM_INTRINSICS_H #define LLVM_INTRINSICS_H #include "llvm/ADT/ArrayRef.h" #include <string> namespace llvm { class Type; class FunctionType; class Function; class LLVMContext; class Module; class AttrListPtr; /// Intrinsic Namespace - This namespace contains an enum with a value for /// every intrinsic/builtin function known by LLVM. These enum values are /// returned by Function::getIntrinsicID(). /// namespace Intrinsic { enum ID { not_intrinsic = 0, // Must be zero // Get the intrinsic enums generated from Intrinsics.td #define GET_INTRINSIC_ENUM_VALUES #include "llvm/Intrinsics.gen" #undef GET_INTRINSIC_ENUM_VALUES , num_intrinsics }; /// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as /// "llvm.ppc.altivec.lvx". std::string getName(ID id, ArrayRef<Type*> Tys = ArrayRef<Type*>()); /// Intrinsic::getType(ID) - Return the function type for an intrinsic. /// FunctionType *getType(LLVMContext &Context, ID id, ArrayRef<Type*> Tys = ArrayRef<Type*>()); /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be /// overloaded. bool isOverloaded(ID id); /// Intrinsic::getAttributes(ID) - Return the attributes for an intrinsic. /// AttrListPtr getAttributes(LLVMContext &C, ID id); /// Intrinsic::getDeclaration(M, ID) - Create or insert an LLVM Function /// declaration for an intrinsic, and return it. /// /// The Tys and numTys parameters are for intrinsics with overloaded types /// (e.g., those using iAny, fAny, vAny, or iPTRAny). For a declaration for an /// overloaded intrinsic, Tys should point to an array of numTys pointers to /// Type, and must provide exactly one type for each overloaded type in the /// intrinsic. Function *getDeclaration(Module *M, ID id, ArrayRef<Type*> Tys = ArrayRef<Type*>()); /// Map a GCC builtin name to an intrinsic ID. ID getIntrinsicForGCCBuiltin(const char *Prefix, const char *BuiltinName); /// IITDescriptor - This is a type descriptor which explains the type /// requirements of an intrinsic. This is returned by /// getIntrinsicInfoTableEntries. struct IITDescriptor { enum IITDescriptorKind { Void, MMX, Metadata, Float, Double, Integer, Vector, Pointer, Struct, Argument, ExtendVecArgument, TruncVecArgument } Kind; union { unsigned Integer_Width; unsigned Float_Width; unsigned Vector_Width; unsigned Pointer_AddressSpace; unsigned Struct_NumElements; unsigned Argument_Info; }; enum ArgKind { AK_AnyInteger, AK_AnyFloat, AK_AnyVector, AK_AnyPointer }; unsigned getArgumentNumber() const { assert(Kind == Argument || Kind == ExtendVecArgument || Kind == TruncVecArgument); return Argument_Info >> 2; } ArgKind getArgumentKind() const { assert(Kind == Argument || Kind == ExtendVecArgument || Kind == TruncVecArgument); return (ArgKind)(Argument_Info&3); } static IITDescriptor get(IITDescriptorKind K, unsigned Field) { IITDescriptor Result = { K, { Field } }; return Result; } }; /// getIntrinsicInfoTableEntries - Return the IIT table descriptor for the /// specified intrinsic into an array of IITDescriptors. /// void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl<IITDescriptor> &T); } // End Intrinsic namespace } // End llvm namespace #endif
53f7fb763db9343529a6fe628fedc13011357353
e6063f71497be719a76f0ae9f1f7dbcfda1988c6
/tree/173_BST_iterator/work.cc
72b33d1ebac40f7adae1fea49feb95be7abe252f
[]
no_license
uangyy/leetcode
f308672a662fa1e881230b31b7674160d45c2494
912b683db040a9efbe5b58c329e2978097207ab0
refs/heads/master
2021-01-09T21:57:21.758043
2017-08-04T08:21:09
2017-08-04T08:21:09
36,731,293
1
0
null
null
null
null
UTF-8
C++
false
false
1,319
cc
#include <iostream> #include <vector> using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; class BSTIterator { public: vector<TreeNode *> stack; TreeNode *current; BSTIterator(TreeNode *root) { current = root; while (current) { stack.push_back(current); current = current->left; } } /** @return whether we have a next smallest number */ bool hasNext() { return !stack.empty() || current; } /** @return the next smallest number */ int next() { current = *stack.rbegin(); stack.pop_back(); int res = current->val; current = current->right; while (current) { stack.push_back(current); current = current->left; } return res; } }; /* * Your BSTIterator will be called like this: * BSTIterator i = BSTIterator(root); * while (i.hasNext()) cout << i.next(); */ int main(int argc, char **argv) { TreeNode n1(1), n2(2), n3(3), n4(4); n2.left = &n1; n2.right = &n3; n3.right = &n4; BSTIterator i = BSTIterator(&n2); while (i.hasNext()) cout << i.next() << " "; cout << endl; return 0; }
cd4fd92f7bf50f60a6009a036cd4dca724277b73
1851d92ec009599f979ff68440cea9a220d263d4
/src/qt/bitcoingui.h
0fe986d7b388f058d012efab18fd74f298ebbb1a
[ "MIT" ]
permissive
stintcoin/StintCoin
f7e8d3411f2de38bda93f1bbfdb551616fb3ca78
75b9fc740ed1929bde1f142502f9adbbb630d812
refs/heads/master
2020-04-09T01:21:18.148125
2018-12-13T22:08:30
2018-12-13T22:08:30
159,900,937
3
0
null
null
null
null
UTF-8
C++
false
false
8,987
h
// Copyright (c) 2011-2014 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_QT_BITCOINGUI_H #define BITCOIN_QT_BITCOINGUI_H #if defined(HAVE_CONFIG_H) #include "config/stintcoin-config.h" #endif #include "amount.h" #include <QLabel> #include <QMainWindow> #include <QMap> #include <QMenu> #include <QPoint> #include <QPushButton> #include <QSystemTrayIcon> // class ClientModel; class NetworkStyle; class Notificator; class OptionsModel; class BlockExplorer; class RPCConsole; class SendCoinsRecipient; class UnitDisplayStatusBarControl; class WalletFrame; class WalletModel; class MasternodeList; class CWallet; QT_BEGIN_NAMESPACE class QAction; class QProgressBar; class QProgressDialog; QT_END_NAMESPACE /** Bitcoin GUI main class. This class represents the main window of the Bitcoin UI. It communicates with both the client and wallet models to give the user an up-to-date view of the current core state. */ class BitcoinGUI : public QMainWindow { Q_OBJECT public: static const QString DEFAULT_WALLET; explicit BitcoinGUI(const NetworkStyle* networkStyle, QWidget* parent = 0); ~BitcoinGUI(); /** Set the client model. The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic. */ void setClientModel(ClientModel* clientModel); #ifdef ENABLE_WALLET /** Set the wallet model. The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending functionality. */ bool addWallet(const QString& name, WalletModel* walletModel); bool setCurrentWallet(const QString& name); void removeAllWallets(); #endif // ENABLE_WALLET bool enableWallet; bool fMultiSend = false; protected: void changeEvent(QEvent* e); void closeEvent(QCloseEvent* event); void dragEnterEvent(QDragEnterEvent* event); void dropEvent(QDropEvent* event); bool eventFilter(QObject* object, QEvent* event); private: ClientModel* clientModel; WalletFrame* walletFrame; UnitDisplayStatusBarControl* unitDisplayControl; QLabel* labelStakingIcon; QLabel* labelEncryptionIcon; QPushButton* labelConnectionsIcon; QLabel* labelBlocksIcon; QLabel* progressBarLabel; QProgressBar* progressBar; QProgressDialog* progressDialog; QMenuBar* appMenuBar; QAction* overviewAction; QAction* historyAction; QAction* masternodeAction; QAction* quitAction; QAction* sendCoinsAction; QAction* usedSendingAddressesAction; QAction* usedReceivingAddressesAction; QAction* signMessageAction; QAction* verifyMessageAction; QAction* bip38ToolAction; QAction* aboutAction; QAction* receiveCoinsAction; QAction* optionsAction; QAction* toggleHideAction; QAction* encryptWalletAction; QAction* backupWalletAction; QAction* changePassphraseAction; QAction* unlockWalletAction; QAction* lockWalletAction; QAction* lockWalletAction2; QAction* aboutQtAction; QAction* openInfoAction; QAction* openRPCConsoleAction; QAction* openNetworkAction; QAction* openPeersAction; QAction* openRepairAction; QAction* openConfEditorAction; QAction* openMNConfEditorAction; QAction* showBackupsAction; QAction* openAction; QAction* openBlockExplorerAction; QAction* showHelpMessageAction; QAction* multiSendAction; QSystemTrayIcon* trayIcon; QMenu* trayIconMenu; Notificator* notificator; RPCConsole* rpcConsole; BlockExplorer* explorerWindow; /** Keep track of previous number of blocks, to detect progress */ int prevBlocks; int spinnerFrame; /** Create the main UI actions. */ void createActions(const NetworkStyle* networkStyle); /** Create the menu bar and sub-menus. */ void createMenuBar(); /** Create the toolbars */ void createToolBars(); /** Create system tray icon and notification */ void createTrayIcon(const NetworkStyle* networkStyle); /** Create system tray menu (or setup the dock menu) */ void createTrayIconMenu(); /** Enable or disable all wallet-related actions */ void setWalletActionsEnabled(bool enabled); /** Connect core signals to GUI client */ void subscribeToCoreSignals(); /** Disconnect core signals from GUI client */ void unsubscribeFromCoreSignals(); signals: /** Signal raised when a URI was entered or dragged to the GUI */ void receivedURI(const QString& uri); /** Restart handling */ void requestedRestart(QStringList args); public slots: /** Set number of connections shown in the UI */ void setNumConnections(int count); /** Set number of blocks shown in the UI */ void setNumBlocks(int count); /** Get restart command-line parameters and request restart */ void handleRestart(QStringList args); /** Notify the user of an event from the core network or transaction handling code. @param[in] title the message box / notification title @param[in] message the displayed text @param[in] style modality and style definitions (icon and used buttons - buttons only for message boxes) @see CClientUIInterface::MessageBoxFlags @param[in] ret pointer to a bool that will be modified to whether Ok was clicked (modal only) */ void message(const QString& title, const QString& message, unsigned int style, bool* ret = NULL); void setStakingStatus(); #ifdef ENABLE_WALLET /** Set the encryption status as shown in the UI. @param[in] status current encryption status @see WalletModel::EncryptionStatus */ void setEncryptionStatus(int status); bool handlePaymentRequest(const SendCoinsRecipient& recipient); /** Show incoming transaction notification for new transactions. */ void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address); #endif // ENABLE_WALLET private slots: #ifdef ENABLE_WALLET /** Switch to overview (home) page */ void gotoOverviewPage(); /** Switch to history (transactions) page */ void gotoHistoryPage(); /** Switch to Explorer Page */ void gotoBlockExplorerPage(); /** Switch to masternode page */ void gotoMasternodePage(); /** Switch to receive coins page */ void gotoReceiveCoinsPage(); /** Switch to send coins page */ void gotoSendCoinsPage(QString addr = ""); /** Show Sign/Verify Message dialog and switch to sign message tab */ void gotoSignMessageTab(QString addr = ""); /** Show Sign/Verify Message dialog and switch to verify message tab */ void gotoVerifyMessageTab(QString addr = ""); /** Show MultiSend Dialog */ void gotoMultiSendDialog(); /** Show BIP 38 tool - default to Encryption tab */ void gotoBip38Tool(); /** Show open dialog */ void openClicked(); #endif // ENABLE_WALLET /** Show configuration dialog */ void optionsClicked(); /** Show about dialog */ void aboutClicked(); /** Show help message dialog */ void showHelpMessageClicked(); #ifndef Q_OS_MAC /** Handle tray icon clicked */ void trayIconActivated(QSystemTrayIcon::ActivationReason reason); #endif /** Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHidden is true */ void showNormalIfMinimized(bool fToggleHidden = false); /** Simply calls showNormalIfMinimized(true) for use in SLOT() macro */ void toggleHidden(); /** called by a timer to check if fRequestShutdown has been set **/ void detectShutdown(); /** Show progress dialog e.g. for verifychain */ void showProgress(const QString& title, int nProgress); }; class UnitDisplayStatusBarControl : public QLabel { Q_OBJECT public: explicit UnitDisplayStatusBarControl(); /** Lets the control know about the Options Model (and its signals) */ void setOptionsModel(OptionsModel* optionsModel); protected: /** So that it responds to left-button clicks */ void mousePressEvent(QMouseEvent* event); private: OptionsModel* optionsModel; QMenu* menu; /** Shows context menu with Display Unit options by the mouse coordinates */ void onDisplayUnitsClicked(const QPoint& point); /** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */ void createContextMenu(); private slots: /** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */ void updateDisplayUnit(int newUnits); /** Tells underlying optionsModel to update its current display unit. */ void onMenuSelection(QAction* action); }; #endif // BITCOIN_QT_BITCOINGUI_H
1d4219028925a2f80c41055005c6ffcdb6762f48
147d96bfb1b03af681db9ae1dd44d495e57b5b45
/samples/strsvsample08/strsvsample08.cpp
747377eb687c0ed5ba9022eda9e0f7962753ef2b
[ "Apache-2.0" ]
permissive
tlk00/BitMagic
fe40d4344895303767aa3a1f3b260b0eaff0e6d4
fa1afb29fefa6a886980b90f72af71f530d5cb5d
refs/heads/master
2023-07-22T04:06:38.272848
2023-07-08T01:13:21
2023-07-08T01:13:21
101,114,435
389
49
NOASSERTION
2023-02-10T19:14:47
2017-08-22T22:54:04
C++
UTF-8
C++
false
false
6,094
cpp
/* Copyright(c) 2002-2022 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com) 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. For more information please visit: http://bitmagic.io */ /** \example strsvsample08.cpp Succinct container binary search \sa bm::str_sparse_vector \sa bm::sparse_vector_scanner \sa bm::sparse_vector_scanner::bind \sa bm::sparse_vector_scanner::bfind_eq_str \sa bm::str_sparse_vector::freeze \sa bm::str_sparse_vector::remap \sa bm::str_sparse_vector::optimize */ /*! \file strsvsample06.cpp \brief Example: Succinct container binary search */ #include <iostream> #include <string> #include <vector> #include <algorithm> #include <random> #include <cassert> #include "bm.h" #include "bmstrsparsevec.h" #include "bmsparsevec_algo.h" #include "bmtimer.h" #include "bmundef.h" /* clear the pre-proc defines from BM */ using namespace std; typedef bm::bvector<> bvector_type; typedef bm::str_sparse_vector<char, bvector_type, 16> str_sv_type; static void GenerateTestStrCollection(std::vector<string>& str_coll, unsigned max_coll) { string prefix = "az"; string str; for (unsigned i = 0; i < max_coll; ++i) { str = prefix; str.append(to_string(i)); str_coll.emplace_back(str); if (i % 1024 == 0) // generate new prefix { prefix.clear(); unsigned prefix_len = (unsigned)rand() % 5; for (unsigned j = 0; j < prefix_len; ++j) { char cch = char('a' + (unsigned)rand() % 26); prefix.push_back(cch); } // for j } } // for i } int main(void) { const unsigned max_coll = 30000000; try { std::vector<string> str_coll; str_sv_type str_sv; cout << "Prepare test data" << endl; cout << " generation ..." << endl; GenerateTestStrCollection(str_coll, max_coll); cout << " sort..." << endl; std::sort(str_coll.begin(), str_coll.end()); str_sv_type str_sv_srt; // sorted succinct vector // fill in using back-insert iterator (fastest mathod to fill in) { auto bi = str_sv_srt.get_back_inserter(); for (auto str : str_coll) bi = str; // important to explicitly flush // ( because destruction flush is not exception safe ) bi.flush(); } cout << " remap-optimize-freeze..." << endl; str_sv_srt.remap(); // apply remapping compression str_sv_srt.optimize(); // RLE compression str_sv_srt.freeze(); // turn into read-only mode // pick the test sets std::vector<string> str_coll_test1; { const unsigned pick_factor = 5; for (size_t i = 0; i < size_t(str_coll.size()); i+=pick_factor) { const string& s = str_coll[i]; str_coll_test1.push_back(s); } // for i std::random_device rd; std::mt19937 g(rd()); std::shuffle(str_coll_test1.begin(), str_coll_test1.end(), g); } cout << "Run test" << endl; size_t sum_pos4=0, sum_pos32=0; // code below illustrates bm::sparse_vector_scanner<> search sampling // parameters: 4 and 32 where 32 offers better performance. // // the use case here is to create a vector-scanner pair, bind then // and repeat multiple searches to vector using its scanner // (scanner maintains the sampled search index (for sorted searches). // // Sampling approach works well, because BM uses hybrid binary search // first narrowing down the seach using uncomprssed samples O(Nlog(N)) // then at the end running a vector search using logical ops with // search space prunning. // // all of the above implements fast search in sorted-compressed array // without decompression // { str_sv_type::size_type pos; bm::sparse_vector_scanner<str_sv_type, 4> scanner; scanner.bind(str_sv_srt, true); // bind sorted vector bm::chrono_taker tt(cout, "bm::sparse_vector_scanner<>::bfind_eq_str() [4] ", 1); for (unsigned i = 0; i < unsigned(str_coll_test1.size()); ++i) { const string& s = str_coll_test1[i]; bool found = scanner.bfind_eq_str(s.c_str(), pos); if (!found) { cerr << "String bfind_eq_str() failure!" << endl; assert(0); exit(1); } sum_pos4 += pos; } // for } { str_sv_type::size_type pos; bm::sparse_vector_scanner<str_sv_type, 32> scanner; scanner.bind(str_sv_srt, true); // bind sorted vector bm::chrono_taker tt(cout, "bm::sparse_vector_scanner<>::bfind_eq_str() [32] ", 1); for (unsigned i = 0; i < unsigned(str_coll_test1.size()); ++i) { const string& s = str_coll_test1[i]; bool found = scanner.bfind_eq_str(s.c_str(), pos); if (!found) { cerr << "String bfind_eq_str() failure!" << endl; assert(0); exit(1); } sum_pos32 += pos; } // for } assert(sum_pos4 == sum_pos32); } catch(std::exception& ex) { std::cerr << ex.what() << std::endl; return 1; } return 0; }
31118192114c0b455970a9a836d6bc77ff6b3cb3
b126a8248240fd71653159beeccc732ca49f49c2
/OpenCascade/BRepPrimAPI_MakeOneAxis.hxx
fdb2829030d532c08ce3299c9399884c9c10e270
[]
no_license
jicc/3rdpartyincludes
90fd194a37082027482043c56e66cfdafa386d2b
f790f816dc2c4ef5868189b87cb6edb65a755538
refs/heads/master
2021-01-14T13:39:24.774980
2013-07-26T08:15:01
2013-07-26T08:15:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,075
hxx
// This file is generated by WOK (CPPExt). // Please do not edit this file; modify original file instead. // The copyright and license terms as defined for the original file apply to // this header file considered to be the "object code" form of the original source. #ifndef _BRepPrimAPI_MakeOneAxis_HeaderFile #define _BRepPrimAPI_MakeOneAxis_HeaderFile #ifndef _Standard_HeaderFile #include <Standard.hxx> #endif #ifndef _Standard_Macro_HeaderFile #include <Standard_Macro.hxx> #endif #ifndef _BRepBuilderAPI_MakeShape_HeaderFile #include <BRepBuilderAPI_MakeShape.hxx> #endif #ifndef _Standard_Address_HeaderFile #include <Standard_Address.hxx> #endif class StdFail_NotDone; class TopoDS_Face; class TopoDS_Shell; class TopoDS_Solid; //! The abstract class MakeOneAxis is the root class of <br> //! algorithms used to construct rotational primitives. <br> class BRepPrimAPI_MakeOneAxis : public BRepBuilderAPI_MakeShape { public: void* operator new(size_t,void* anAddress) { return anAddress; } void* operator new(size_t size) { return Standard::Allocate(size); } void operator delete(void *anAddress) { if (anAddress) Standard::Free((Standard_Address&)anAddress); } //! The inherited commands should provide the algorithm. <br> //! Returned as a pointer. <br> Standard_EXPORT virtual Standard_Address OneAxis() = 0; //! Stores the solid in myShape. <br> Standard_EXPORT virtual void Build() ; //! Returns the lateral face of the rotational primitive. <br> //! <br> Standard_EXPORT const TopoDS_Face& Face() ; Standard_EXPORT operator TopoDS_Face(); //! Returns the constructed rotational primitive as a shell. <br> Standard_EXPORT const TopoDS_Shell& Shell() ; Standard_EXPORT operator TopoDS_Shell(); //! Returns the constructed rotational primitive as a solid. <br> Standard_EXPORT const TopoDS_Solid& Solid() ; Standard_EXPORT operator TopoDS_Solid(); protected: private: }; // other Inline functions and methods (like "C++: function call" methods) #endif
2053f82eae2982ae0df5fc7e240259c0a24f7576
9168a725fa2682e533d4d5aa66453b4322926c32
/src/includes/Head.h
a37759cb43b5682ddecb065f68ca0afb51e6443c
[]
no_license
Technohacker/lpmln
01a8999dd4c2073cea56141f9d00d44a041046d2
0008244e23d49860d09f2e3077cbbb3b6e85b39b
refs/heads/master
2023-08-23T16:35:50.494206
2017-01-18T23:27:33
2017-01-18T23:27:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,993
h
#pragma once #include "Predicate.h" class Head { public: Head(Predicate _p){ predList.push_back(_p); } ~Head(); Head(std::vector<Predicate> _predList):predList(_predList){} inline Predicate getPredicate() { return predList.at(0); } inline std::vector<Predicate> getPredicateList() { return predList; } void addPredicate(Predicate _p) { predList.push_back(_p); } inline std::string toString() const{ // return predList.at(0).toString(); return headStr; } std::string toString(const std::set<std::string>& domainList) const{ std::string str; for (unsigned int i = 0; i < predList.size(); ++i){ str += predList.at(i).toString(domainList); str += " ; "; } str = str.substr(0,str.size()-3); return str; } inline std::string getExtra(const std::set<Variable>& variable){ std::string str; for (std::vector<Predicate>::iterator i = predList.begin(); i != predList.end(); ++i){ std::string s = i->getExtra(variable); if(s.length() != 0){ str += s; str += " , "; } } if(str.length() > 3) str = str.substr(0,str.size()-3); return str; } void appendStr(std::string, bool, bool, bool); inline void setDisjunction(bool val){ isDisjunction = val; } inline bool getDisjunction(){ return isDisjunction; } std::set<std::string> getConstantSet(){ std::set<std::string> intermediateSet; for (unsigned int i = 0; i < predList.size(); ++i){ if(!predList.at(i).getConstants().empty()){ for(auto it : predList.at(i).getConstants()){ intermediateSet.insert(it); } } } return intermediateSet; } std::string toNNFString(const std::set<std::string>& domainList){ std::string str; for (unsigned int i = 0; i < predList.size(); ++i){ str += "not "; str += predList.at(i).toString(domainList); str += " , "; } str = str.substr(0,str.size()-3); return str; } private: std::vector<Predicate> predList; bool isDisjunction = false; Predicate p; std::string headStr; };
842d4df2c4e0d18721f5aae7b135fa3f1d3afe1d
fae551eb54ab3a907ba13cf38aba1db288708d92
/android_webview/browser/page_load_metrics/aw_page_load_metrics_memory_tracker_factory.cc
f6fa46af4978e76325c494c6b713bceee6af1973
[ "BSD-3-Clause" ]
permissive
xtblock/chromium
d4506722fc6e4c9bc04b54921a4382165d875f9a
5fe0705b86e692c65684cdb067d9b452cc5f063f
refs/heads/main
2023-04-26T18:34:42.207215
2021-05-27T04:45:24
2021-05-27T04:45:24
371,258,442
2
1
BSD-3-Clause
2021-05-27T05:36:28
2021-05-27T05:36:28
null
UTF-8
C++
false
false
1,815
cc
// Copyright 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. #include "android_webview/browser/page_load_metrics/aw_page_load_metrics_memory_tracker_factory.h" #include "base/memory/singleton.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "components/page_load_metrics/browser/page_load_metrics_memory_tracker.h" namespace android_webview { page_load_metrics::PageLoadMetricsMemoryTracker* AwPageLoadMetricsMemoryTrackerFactory::GetForBrowserContext( content::BrowserContext* context) { return static_cast<page_load_metrics::PageLoadMetricsMemoryTracker*>( GetInstance()->GetServiceForBrowserContext(context, true)); } AwPageLoadMetricsMemoryTrackerFactory* AwPageLoadMetricsMemoryTrackerFactory::GetInstance() { return base::Singleton<AwPageLoadMetricsMemoryTrackerFactory>::get(); } AwPageLoadMetricsMemoryTrackerFactory::AwPageLoadMetricsMemoryTrackerFactory() : BrowserContextKeyedServiceFactory( "PageLoadMetricsMemoryTracker", BrowserContextDependencyManager::GetInstance()) {} bool AwPageLoadMetricsMemoryTrackerFactory::ServiceIsCreatedWithBrowserContext() const { return base::FeatureList::IsEnabled(features::kV8PerFrameMemoryMonitoring); } KeyedService* AwPageLoadMetricsMemoryTrackerFactory::BuildServiceInstanceFor( content::BrowserContext* context) const { return new page_load_metrics::PageLoadMetricsMemoryTracker(); } content::BrowserContext* AwPageLoadMetricsMemoryTrackerFactory::GetBrowserContextToUse( content::BrowserContext* context) const { return context; } } // namespace android_webview
6ee5ffab95f62ad749fc33d154e757c38f35be6d
dc38c8a3b0e9b13afb83fbe78269638c60bd32cd
/91. Decode Ways/main.cpp
0bdeb3b2070f7851522f168ecc93d3ef9b85a4cb
[]
no_license
TG-yang/LeetCode
603da8e8121ad2ed7d05bac0d4ee6d61378eeff3
1749b35170636830b3f91777ac57d049278b2b2e
refs/heads/master
2020-04-09T09:20:13.129761
2019-08-16T17:10:42
2019-08-16T17:10:42
160,229,673
0
1
null
null
null
null
UTF-8
C++
false
false
718
cpp
#include <iostream> #include <string> #include <vector> using namespace std; class Solution { public: int numDecodings(string s) { if(s.size() == 0 || s[0] == '0') return 0; vector<int>dp(s.size() + 1, 0); dp[0] = 1; dp[1] = 1; for(int i = 1; i < s.size(); ++i){ int tmp = (int)atoi(s.substr(i - 1, 2).c_str()); //c_str()函数返回一个指向正规C字符串的指针常量 if(tmp >= 10 && tmp <= 26) dp[i + 1] += dp[i - 1]; if(tmp % 10 != 0) dp[i + 1] += dp[i]; } return dp[s.size()]; } }; int main() { std::cout << "Hello, World!" << std::endl; return 0; }
a661ea609463490b04edd08dddcfb5af33834a8d
5a2349399fa9d57c6e8cc6e0f7226d683391a362
/src/qt/qtbase/src/plugins/platforms/android/qandroidplatformmenu.cpp
1ecabb25e2c0f41e14c3f1587793a4d5744e9fec
[ "LGPL-2.1-only", "GPL-3.0-only", "LicenseRef-scancode-digia-qt-commercial", "Qt-LGPL-exception-1.1", "LicenseRef-scancode-digia-qt-preview", "LGPL-2.0-or-later", "GFDL-1.3-only", "BSD-3-Clause" ]
permissive
aharthcock/phantomjs
e70f3c379dcada720ec8abde3f7c09a24808154c
7d7f2c862347fbc7215c849e790290b2e07bab7c
refs/heads/master
2023-03-18T04:58:32.428562
2023-03-14T05:52:52
2023-03-14T05:52:52
24,828,890
0
0
BSD-3-Clause
2023-03-14T05:52:53
2014-10-05T23:38:56
C++
UTF-8
C++
false
false
5,172
cpp
/**************************************************************************** ** ** Copyright (C) 2012 BogDan Vatra <[email protected]> ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qandroidplatformmenu.h" #include "qandroidplatformmenuitem.h" #include "androidjnimenu.h" QAndroidPlatformMenu::QAndroidPlatformMenu() { m_tag = reinterpret_cast<quintptr>(this); // QMenu will overwrite this later, but we need a unique ID for QtQuick m_enabled = true; m_isVisible = true; } QAndroidPlatformMenu::~QAndroidPlatformMenu() { QtAndroidMenu::androidPlatformMenuDestroyed(this); } void QAndroidPlatformMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before) { QMutexLocker lock(&m_menuItemsMutex); m_menuItems.insert(qFind(m_menuItems.begin(), m_menuItems.end(), static_cast<QAndroidPlatformMenuItem *>(before)), static_cast<QAndroidPlatformMenuItem *>(menuItem)); } void QAndroidPlatformMenu::removeMenuItem(QPlatformMenuItem *menuItem) { QMutexLocker lock(&m_menuItemsMutex); PlatformMenuItemsType::iterator it = qFind(m_menuItems.begin(), m_menuItems.end(), static_cast<QAndroidPlatformMenuItem *>(menuItem)); if (it != m_menuItems.end()) m_menuItems.erase(it); } void QAndroidPlatformMenu::syncMenuItem(QPlatformMenuItem *menuItem) { PlatformMenuItemsType::iterator it; for (it = m_menuItems.begin(); it != m_menuItems.end(); ++it) { if ((*it)->tag() == menuItem->tag()) break; } if (it != m_menuItems.end()) QtAndroidMenu::syncMenu(this); } void QAndroidPlatformMenu::syncSeparatorsCollapsible(bool enable) { Q_UNUSED(enable) } void QAndroidPlatformMenu::setTag(quintptr tag) { m_tag = tag; } quintptr QAndroidPlatformMenu::tag() const { return m_tag; } void QAndroidPlatformMenu::setText(const QString &text) { m_text = text; } QString QAndroidPlatformMenu::text() const { return m_text; } void QAndroidPlatformMenu::setIcon(const QIcon &icon) { m_icon = icon; } QIcon QAndroidPlatformMenu::icon() const { return m_icon; } void QAndroidPlatformMenu::setEnabled(bool enabled) { m_enabled = enabled; } bool QAndroidPlatformMenu::isEnabled() const { return m_enabled; } void QAndroidPlatformMenu::setVisible(bool visible) { m_isVisible = visible; } bool QAndroidPlatformMenu::isVisible() const { return m_isVisible; } void QAndroidPlatformMenu::showPopup(const QWindow *parentWindow, QPoint pos, const QPlatformMenuItem *item) { Q_UNUSED(parentWindow); Q_UNUSED(pos); Q_UNUSED(item); setVisible(true); QtAndroidMenu::showContextMenu(this); } QPlatformMenuItem *QAndroidPlatformMenu::menuItemAt(int position) const { if (position < m_menuItems.size()) return m_menuItems[position]; return 0; } QPlatformMenuItem *QAndroidPlatformMenu::menuItemForTag(quintptr tag) const { foreach (QPlatformMenuItem *menuItem, m_menuItems) { if (menuItem->tag() == tag) return menuItem; } return 0; } QAndroidPlatformMenu::PlatformMenuItemsType QAndroidPlatformMenu::menuItems() const { return m_menuItems; } QMutex *QAndroidPlatformMenu::menuItemsMutex() { return &m_menuItemsMutex; }
7b49be857fc0a0d279f1daa26b81aec28da0ce35
b6a885754d36f6d7507433536090d54ee9890e52
/ch13/No.4/No.4/main.cpp
481308358cedf0e606e345e62fc20ce824149760
[]
no_license
szw-20731/CPrimerPlus
841bdfa5d04080e8ffdba1db6baac07a13456725
9cb038164feda21389501329652028b17caae63b
refs/heads/master
2022-12-09T18:27:21.683546
2020-09-07T02:08:28
2020-09-07T02:08:28
286,395,009
1
0
null
null
null
null
UTF-8
C++
false
false
303
cpp
#include "port.h" int main() { port *list[2]; list[0] = new port("Brand", "ruby", 10); list[1] = new vintageport("VBrand", 10, "szw", 2020); list[0]->show(); cout << *list[0] << endl; list[1]->show(); cout << *list[1] << endl; list[0] = list[1]; list[0]->show(); system("pause"); return 0; }
b64e6c627c1549955cf70a36441289321168540a
bc407d25aa3da4babdb9762f53a201a7ea84b976
/ArquitecturaDeComputadoras/7segments/sys/module.h
e5f750f7d665130624d7a499f5e6227b1ca7fe46
[]
no_license
YurleySolimer/ULA
e91344815d32175a13b7cd7ee153f16a1b237580
57c2caa895e0635f215d9f98e9fad05227bf5f90
refs/heads/master
2020-04-14T19:30:26.932376
2019-01-04T05:07:30
2019-01-04T05:07:30
164,060,266
0
0
null
null
null
null
UTF-8
C++
false
false
1,798
h
# ifndef MODULE_H_ # define MODULE_H_ # include<systemc.h> # include<string> class SevenSegments:public sc_module{ public: sc_in<sc_uint<4> > x_in; sc_out<bool > z_out[7]; SC_CTOR(SevenSegments){ SC_METHOD(operation); sensitive<<x_in; } ~SevenSegments(){} private: void operation(){ if(x_in.read()==0){ for(int i=0;i<7;i++){ if(i!=5) z_out[i].write(1); else z_out[i].write(0); } return; } else if(x_in.read()==1){ for(int i=0;i<7;i++){ if(i==1 or i==2) z_out[i].write(1); else z_out[i].write(0); } return; } else if(x_in.read()==2){ for(int i=0;i<7;i++){ if(i==2 or i==6) z_out[i].write(0); else z_out[i].write(1); } return; } else if(x_in.read()==3){ for(int i=0;i<7;i++){ if(i==4 or i==6) z_out[i].write(0); else z_out[i].write(1); } return; } else if(x_in.read()==4){ for(int i=0;i<7;i++){ if(i==0 or i==3 or i==4) z_out[i].write(0); else z_out[i].write(1); } return; } else if(x_in.read()==5){ for(int i=0;i<7;i++){ if(i==1 or i==4) z_out[i].write(0); else z_out[i].write(1); } return; } else if(x_in.read()==6){ for(int i=0;i<7;i++){ if(i==1) z_out[i].write(0); else z_out[i].write(1); } return; } else if(x_in.read()==7){ for(int i=0;i<7;i++){ if(i==3 or i==4 or i==6) z_out[i].write(0); else z_out[i].write(1); } return; } else if(x_in.read()==8){ for(int i=0;i<7;i++) z_out[i].write(1); return; } else if(x_in.read()==9){ for(int i=0;i<7;i++){ if(i==3 or i==4) z_out[i].write(0); else z_out[i].write(1); } return; } } };/*end of class SevenSegments*/ #endif/*end of SEVENSEGMENTS_H*/
4fc3a19787a2d9eaaaab824a82e7d3902df045be
69ed1447b867b11b3ff841aeb10550fe138a2246
/SDK/Headers/CppDynamic/libamcf_dynamic - Copy.hpp
ff5328d7ff63bf5b5a68da62fa8e615058e13059
[ "BSD-3-Clause" ]
permissive
jakeread/AutodeskMachineControlFramework
926d492390773b57b64aee910412ee29db13a055
288b07db3df7b72b67f98040ccf6da9889123469
refs/heads/master
2023-08-23T03:07:07.311759
2021-08-06T17:35:16
2021-08-06T17:35:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
58,900
hpp
/*++ Copyright (C) 2021 Autodesk Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Autodesk Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. Abstract: This is an autogenerated C++-Header file in order to allow an easy use of Autodesk Machine Control Framework SDK Interface version: 1.0.0 */ #ifndef __LIBAMCF_CPPHEADER_DYNAMIC_CPP #define __LIBAMCF_CPPHEADER_DYNAMIC_CPP #include "libamcf_types.hpp" #include "libamcf_dynamic.h" #ifdef _WIN32 #include <windows.h> #else // _WIN32 #include <dlfcn.h> #endif // _WIN32 #include <string> #include <memory> #include <vector> #include <exception> #include <future> #include <mutex> namespace LibAMCF { /************************************************************************************************************************* Forward Declaration of all classes **************************************************************************************************************************/ class CWrapper; class CBase; class COperationResult; class CDataStream; class CStreamUpload; class CConnection; /************************************************************************************************************************* Declaration of deprecated class types **************************************************************************************************************************/ typedef CWrapper CLibAMCFWrapper; typedef CBase CLibAMCFBase; typedef COperationResult CLibAMCFOperationResult; typedef CDataStream CLibAMCFDataStream; typedef CStreamUpload CLibAMCFStreamUpload; typedef CConnection CLibAMCFConnection; /************************************************************************************************************************* Declaration of shared pointer types **************************************************************************************************************************/ typedef std::shared_ptr<CWrapper> PWrapper; typedef std::shared_ptr<CBase> PBase; typedef std::shared_ptr<COperationResult> POperationResult; typedef std::shared_ptr<CDataStream> PDataStream; typedef std::shared_ptr<CStreamUpload> PStreamUpload; typedef std::shared_ptr<CConnection> PConnection; /************************************************************************************************************************* Declaration of deprecated shared pointer types **************************************************************************************************************************/ typedef PWrapper PLibAMCFWrapper; typedef PBase PLibAMCFBase; typedef POperationResult PLibAMCFOperationResult; typedef PDataStream PLibAMCFDataStream; typedef PStreamUpload PLibAMCFStreamUpload; typedef PConnection PLibAMCFConnection; /************************************************************************************************************************* classParam Definition **************************************************************************************************************************/ template<class T> class classParam { private: const T* m_ptr; public: classParam(const T* ptr) : m_ptr (ptr) { } classParam(std::shared_ptr <T> sharedPtr) : m_ptr (sharedPtr.get()) { } LibAMCFHandle GetHandle() { if (m_ptr != nullptr) return m_ptr->handle(); return nullptr; } }; /************************************************************************************************************************* Class ELibAMCFException **************************************************************************************************************************/ class ELibAMCFException : public std::exception { protected: /** * Error code for the Exception. */ LibAMCFResult m_errorCode; /** * Error message for the Exception. */ std::string m_errorMessage; public: /** * Exception Constructor. */ ELibAMCFException(LibAMCFResult errorCode, const std::string & sErrorMessage) : m_errorMessage("LibAMCF Error " + std::to_string(errorCode) + " (" + sErrorMessage + ")") { m_errorCode = errorCode; } /** * Returns error code */ LibAMCFResult getErrorCode() const noexcept { return m_errorCode; } /** * Returns error message */ const char* what() const noexcept { return m_errorMessage.c_str(); } }; /************************************************************************************************************************* Class CInputVector **************************************************************************************************************************/ template <typename T> class CInputVector { private: const T* m_data; size_t m_size; public: CInputVector( const std::vector<T>& vec) : m_data( vec.data() ), m_size( vec.size() ) { } CInputVector( const T* in_data, size_t in_size) : m_data( in_data ), m_size(in_size ) { } const T* data() const { return m_data; } size_t size() const { return m_size; } }; // declare deprecated class name template<typename T> using CLibAMCFInputVector = CInputVector<T>; /************************************************************************************************************************* Class CWrapper **************************************************************************************************************************/ class CWrapper { public: CWrapper(void* pSymbolLookupMethod) { CheckError(nullptr, initWrapperTable(&m_WrapperTable)); CheckError(nullptr, loadWrapperTableFromSymbolLookupMethod(&m_WrapperTable, pSymbolLookupMethod)); CheckError(nullptr, checkBinaryVersion()); } CWrapper(const std::string &sFileName) { CheckError(nullptr, initWrapperTable(&m_WrapperTable)); CheckError(nullptr, loadWrapperTable(&m_WrapperTable, sFileName.c_str())); CheckError(nullptr, checkBinaryVersion()); } static PWrapper loadLibrary(const std::string &sFileName) { return std::make_shared<CWrapper>(sFileName); } static PWrapper loadLibraryFromSymbolLookupMethod(void* pSymbolLookupMethod) { return std::make_shared<CWrapper>(pSymbolLookupMethod); } ~CWrapper() { releaseWrapperTable(&m_WrapperTable); } inline void CheckError(CBase * pBaseClass, LibAMCFResult nResult); inline void GetVersion(LibAMCF_uint32 & nMajor, LibAMCF_uint32 & nMinor, LibAMCF_uint32 & nMicro); inline bool GetLastError(classParam<CBase> pInstance, std::string & sErrorMessage); inline void ReleaseInstance(classParam<CBase> pInstance); inline void AcquireInstance(classParam<CBase> pInstance); inline void InjectComponent(const std::string & sNameSpace, const LibAMCF_pvoid pSymbolAddressMethod); inline LibAMCF_pvoid GetSymbolLookupMethod(); inline PConnection CreateConnection(const std::string & sBaseURL); private: sLibAMCFDynamicWrapperTable m_WrapperTable; LibAMCFResult checkBinaryVersion() { LibAMCF_uint32 nMajor, nMinor, nMicro; GetVersion(nMajor, nMinor, nMicro); if ( (nMajor != LIBAMCF_VERSION_MAJOR) || (nMinor < LIBAMCF_VERSION_MINOR) ) { return LIBAMCF_ERROR_INCOMPATIBLEBINARYVERSION; } return LIBAMCF_SUCCESS; } LibAMCFResult initWrapperTable(sLibAMCFDynamicWrapperTable * pWrapperTable); LibAMCFResult releaseWrapperTable(sLibAMCFDynamicWrapperTable * pWrapperTable); LibAMCFResult loadWrapperTable(sLibAMCFDynamicWrapperTable * pWrapperTable, const char * pLibraryFileName); LibAMCFResult loadWrapperTableFromSymbolLookupMethod(sLibAMCFDynamicWrapperTable * pWrapperTable, void* pSymbolLookupMethod); friend class CBase; friend class COperationResult; friend class CDataStream; friend class CStreamUpload; friend class CConnection; }; /************************************************************************************************************************* Class CBase **************************************************************************************************************************/ class CBase { public: protected: /* Wrapper Object that created the class. */ CWrapper * m_pWrapper; /* Handle to Instance in library*/ LibAMCFHandle m_pHandle; std::mutex m_InstanceMutex; /* Checks for an Error code and raises Exceptions */ void CheckError(LibAMCFResult nResult) { if (m_pWrapper != nullptr) m_pWrapper->CheckError(this, nResult); } public: /** * CBase::CBase - Constructor for Base class. */ CBase(CWrapper * pWrapper, LibAMCFHandle pHandle) : m_pWrapper(pWrapper), m_pHandle(pHandle) { } /** * CBase::~CBase - Destructor for Base class. */ virtual ~CBase() { if (m_pWrapper != nullptr) m_pWrapper->ReleaseInstance(this); m_pWrapper = nullptr; } /** * CBase::handle - Returns handle to instance. */ LibAMCFHandle handle() const { return m_pHandle; } /** * CBase::wrapper - Returns wrapper instance. */ CWrapper * wrapper() const { return m_pWrapper; } friend class CWrapper; }; /************************************************************************************************************************* Class COperationResult **************************************************************************************************************************/ class COperationResult : public CBase { public: /** * COperationResult::COperationResult - Constructor for OperationResult class. */ COperationResult(CWrapper* pWrapper, LibAMCFHandle pHandle) : CBase(pWrapper, pHandle) { } inline bool WaitFor(const LibAMCF_uint32 nTimeOut); inline bool InProgress(); inline bool Success(); inline std::string GetErrorMessage(); }; /************************************************************************************************************************* Class CDataStream **************************************************************************************************************************/ class CDataStream : public CBase { public: /** * CDataStream::CDataStream - Constructor for DataStream class. */ CDataStream(CWrapper* pWrapper, LibAMCFHandle pHandle) : CBase(pWrapper, pHandle) { } inline std::string GetUUID(); inline std::string GetContextUUID(); inline std::string GetName(); inline std::string GetMimeType(); inline LibAMCF_uint64 GetSize(); }; /************************************************************************************************************************* Class CStreamUpload **************************************************************************************************************************/ class CStreamUpload : public CBase { public: /** * CStreamUpload::CStreamUpload - Constructor for StreamUpload class. */ CStreamUpload(CWrapper* pWrapper, LibAMCFHandle pHandle) : CBase(pWrapper, pHandle) { } inline POperationResult UploadData(const CInputVector<LibAMCF_uint8> & DataBuffer, const LibAMCF_uint32 nChunkSize); inline POperationResult UploadFile(const std::string & sFileName, const LibAMCF_uint32 nChunkSize); inline void BeginChunking(const LibAMCF_uint64 nDataSize); inline POperationResult UploadChunk(const CInputVector<LibAMCF_uint8> & DataBuffer); inline POperationResult FinishChunking(const CInputVector<LibAMCF_uint8> & DataBuffer); inline void GetStatus(LibAMCF_uint64 & nUploadSize, LibAMCF_uint64 & nUploadedBytes, bool & bFinished); inline PDataStream GetDataStream(); }; /************************************************************************************************************************* Class CConnection **************************************************************************************************************************/ class CConnection : public CBase { public: /** * CConnection::CConnection - Constructor for Connection class. */ CConnection(CWrapper* pWrapper, LibAMCFHandle pHandle) : CBase(pWrapper, pHandle) { } inline std::string GetBaseURL(); inline void SetTimeouts(const LibAMCF_uint32 nTimeout, const LibAMCF_uint32 nRetryCount); inline LibAMCF_uint32 GetTimeout(); inline LibAMCF_uint32 GetRetryCount(); inline POperationResult AuthenticateWithPassword(const std::string & sUserName, const std::string & sPassword); std::future<bool> asyncAuthenticateWithPassword(const std::string& sUserName, const std::string& sPassword); inline bool IsAuthenticated(); inline POperationResult RefreshAuthentication(); inline POperationResult Ping(); inline std::string GetAuthToken(); inline PStreamUpload CreateUpload(const std::string & sName, const std::string & sMimeType, const std::string & sUsageContext); }; /** * CWrapper::GetVersion - retrieves the binary version of this library. * @param[out] nMajor - returns the major version of this library * @param[out] nMinor - returns the minor version of this library * @param[out] nMicro - returns the micro version of this library */ inline void CWrapper::GetVersion(LibAMCF_uint32 & nMajor, LibAMCF_uint32 & nMinor, LibAMCF_uint32 & nMicro) { CheckError(nullptr,m_WrapperTable.m_GetVersion(&nMajor, &nMinor, &nMicro)); } /** * CWrapper::GetLastError - Returns the last error recorded on this object * @param[in] pInstance - Instance Handle * @param[out] sErrorMessage - Message of the last error * @return Is there a last error to query */ inline bool CWrapper::GetLastError(classParam<CBase> pInstance, std::string & sErrorMessage) { LibAMCFHandle hInstance = pInstance.GetHandle(); LibAMCF_uint32 bytesNeededErrorMessage = 0; LibAMCF_uint32 bytesWrittenErrorMessage = 0; bool resultHasError = 0; CheckError(nullptr,m_WrapperTable.m_GetLastError(hInstance, 0, &bytesNeededErrorMessage, nullptr, &resultHasError)); std::vector<char> bufferErrorMessage(bytesNeededErrorMessage); CheckError(nullptr,m_WrapperTable.m_GetLastError(hInstance, bytesNeededErrorMessage, &bytesWrittenErrorMessage, &bufferErrorMessage[0], &resultHasError)); sErrorMessage = std::string(&bufferErrorMessage[0]); return resultHasError; } /** * CWrapper::ReleaseInstance - Releases shared ownership of an Instance * @param[in] pInstance - Instance Handle */ inline void CWrapper::ReleaseInstance(classParam<CBase> pInstance) { LibAMCFHandle hInstance = pInstance.GetHandle(); CheckError(nullptr,m_WrapperTable.m_ReleaseInstance(hInstance)); } /** * CWrapper::AcquireInstance - Acquires shared ownership of an Instance * @param[in] pInstance - Instance Handle */ inline void CWrapper::AcquireInstance(classParam<CBase> pInstance) { LibAMCFHandle hInstance = pInstance.GetHandle(); CheckError(nullptr,m_WrapperTable.m_AcquireInstance(hInstance)); } /** * CWrapper::InjectComponent - Injects an imported component for usage within this component * @param[in] sNameSpace - NameSpace of the injected component * @param[in] pSymbolAddressMethod - Address of the SymbolAddressMethod of the injected component */ inline void CWrapper::InjectComponent(const std::string & sNameSpace, const LibAMCF_pvoid pSymbolAddressMethod) { CheckError(nullptr,m_WrapperTable.m_InjectComponent(sNameSpace.c_str(), pSymbolAddressMethod)); bool bNameSpaceFound = false; if (!bNameSpaceFound) throw ELibAMCFException(LIBAMCF_ERROR_COULDNOTLOADLIBRARY, "Unknown namespace " + sNameSpace); } /** * CWrapper::GetSymbolLookupMethod - Returns the address of the SymbolLookupMethod * @return Address of the SymbolAddressMethod */ inline LibAMCF_pvoid CWrapper::GetSymbolLookupMethod() { LibAMCF_pvoid resultSymbolLookupMethod = 0; CheckError(nullptr,m_WrapperTable.m_GetSymbolLookupMethod(&resultSymbolLookupMethod)); return resultSymbolLookupMethod; } /** * CWrapper::CreateConnection - Creates a AMCF connection instance. * @param[in] sBaseURL - Base URL of the AMCF Instance. * @return New Connection instance */ inline PConnection CWrapper::CreateConnection(const std::string & sBaseURL) { LibAMCFHandle hInstance = nullptr; CheckError(nullptr,m_WrapperTable.m_CreateConnection(sBaseURL.c_str(), &hInstance)); if (!hInstance) { CheckError(nullptr,LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<CConnection>(this, hInstance); } inline void CWrapper::CheckError(CBase * pBaseClass, LibAMCFResult nResult) { if (nResult != 0) { std::string sErrorMessage; if (pBaseClass != nullptr) { GetLastError(pBaseClass, sErrorMessage); } throw ELibAMCFException(nResult, sErrorMessage); } } inline LibAMCFResult CWrapper::initWrapperTable(sLibAMCFDynamicWrapperTable * pWrapperTable) { if (pWrapperTable == nullptr) return LIBAMCF_ERROR_INVALIDPARAM; pWrapperTable->m_LibraryHandle = nullptr; pWrapperTable->m_OperationResult_WaitFor = nullptr; pWrapperTable->m_OperationResult_InProgress = nullptr; pWrapperTable->m_OperationResult_Success = nullptr; pWrapperTable->m_OperationResult_GetErrorMessage = nullptr; pWrapperTable->m_DataStream_GetUUID = nullptr; pWrapperTable->m_DataStream_GetContextUUID = nullptr; pWrapperTable->m_DataStream_GetName = nullptr; pWrapperTable->m_DataStream_GetMimeType = nullptr; pWrapperTable->m_DataStream_GetSize = nullptr; pWrapperTable->m_StreamUpload_UploadData = nullptr; pWrapperTable->m_StreamUpload_UploadFile = nullptr; pWrapperTable->m_StreamUpload_BeginChunking = nullptr; pWrapperTable->m_StreamUpload_UploadChunk = nullptr; pWrapperTable->m_StreamUpload_FinishChunking = nullptr; pWrapperTable->m_StreamUpload_GetStatus = nullptr; pWrapperTable->m_StreamUpload_GetDataStream = nullptr; pWrapperTable->m_Connection_GetBaseURL = nullptr; pWrapperTable->m_Connection_SetTimeouts = nullptr; pWrapperTable->m_Connection_GetTimeout = nullptr; pWrapperTable->m_Connection_GetRetryCount = nullptr; pWrapperTable->m_Connection_AuthenticateWithPassword = nullptr; pWrapperTable->m_Connection_IsAuthenticated = nullptr; pWrapperTable->m_Connection_RefreshAuthentication = nullptr; pWrapperTable->m_Connection_Ping = nullptr; pWrapperTable->m_Connection_GetAuthToken = nullptr; pWrapperTable->m_Connection_CreateUpload = nullptr; pWrapperTable->m_GetVersion = nullptr; pWrapperTable->m_GetLastError = nullptr; pWrapperTable->m_ReleaseInstance = nullptr; pWrapperTable->m_AcquireInstance = nullptr; pWrapperTable->m_InjectComponent = nullptr; pWrapperTable->m_GetSymbolLookupMethod = nullptr; pWrapperTable->m_CreateConnection = nullptr; return LIBAMCF_SUCCESS; } inline LibAMCFResult CWrapper::releaseWrapperTable(sLibAMCFDynamicWrapperTable * pWrapperTable) { if (pWrapperTable == nullptr) return LIBAMCF_ERROR_INVALIDPARAM; if (pWrapperTable->m_LibraryHandle != nullptr) { #ifdef _WIN32 HMODULE hModule = (HMODULE) pWrapperTable->m_LibraryHandle; FreeLibrary(hModule); #else // _WIN32 dlclose(pWrapperTable->m_LibraryHandle); #endif // _WIN32 return initWrapperTable(pWrapperTable); } return LIBAMCF_SUCCESS; } inline LibAMCFResult CWrapper::loadWrapperTable(sLibAMCFDynamicWrapperTable * pWrapperTable, const char * pLibraryFileName) { if (pWrapperTable == nullptr) return LIBAMCF_ERROR_INVALIDPARAM; if (pLibraryFileName == nullptr) return LIBAMCF_ERROR_INVALIDPARAM; #ifdef _WIN32 // Convert filename to UTF16-string int nLength = (int)strlen(pLibraryFileName); int nBufferSize = nLength * 2 + 2; std::vector<wchar_t> wsLibraryFileName(nBufferSize); int nResult = MultiByteToWideChar(CP_UTF8, 0, pLibraryFileName, nLength, &wsLibraryFileName[0], nBufferSize); if (nResult == 0) return LIBAMCF_ERROR_COULDNOTLOADLIBRARY; HMODULE hLibrary = LoadLibraryW(wsLibraryFileName.data()); if (hLibrary == 0) return LIBAMCF_ERROR_COULDNOTLOADLIBRARY; #else // _WIN32 void* hLibrary = dlopen(pLibraryFileName, RTLD_LAZY); if (hLibrary == 0) return LIBAMCF_ERROR_COULDNOTLOADLIBRARY; dlerror(); #endif // _WIN32 #ifdef _WIN32 pWrapperTable->m_OperationResult_WaitFor = (PLibAMCFOperationResult_WaitForPtr) GetProcAddress(hLibrary, "libamcf_operationresult_waitfor"); #else // _WIN32 pWrapperTable->m_OperationResult_WaitFor = (PLibAMCFOperationResult_WaitForPtr) dlsym(hLibrary, "libamcf_operationresult_waitfor"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_OperationResult_WaitFor == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_OperationResult_InProgress = (PLibAMCFOperationResult_InProgressPtr) GetProcAddress(hLibrary, "libamcf_operationresult_inprogress"); #else // _WIN32 pWrapperTable->m_OperationResult_InProgress = (PLibAMCFOperationResult_InProgressPtr) dlsym(hLibrary, "libamcf_operationresult_inprogress"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_OperationResult_InProgress == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_OperationResult_Success = (PLibAMCFOperationResult_SuccessPtr) GetProcAddress(hLibrary, "libamcf_operationresult_success"); #else // _WIN32 pWrapperTable->m_OperationResult_Success = (PLibAMCFOperationResult_SuccessPtr) dlsym(hLibrary, "libamcf_operationresult_success"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_OperationResult_Success == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_OperationResult_GetErrorMessage = (PLibAMCFOperationResult_GetErrorMessagePtr) GetProcAddress(hLibrary, "libamcf_operationresult_geterrormessage"); #else // _WIN32 pWrapperTable->m_OperationResult_GetErrorMessage = (PLibAMCFOperationResult_GetErrorMessagePtr) dlsym(hLibrary, "libamcf_operationresult_geterrormessage"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_OperationResult_GetErrorMessage == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_DataStream_GetUUID = (PLibAMCFDataStream_GetUUIDPtr) GetProcAddress(hLibrary, "libamcf_datastream_getuuid"); #else // _WIN32 pWrapperTable->m_DataStream_GetUUID = (PLibAMCFDataStream_GetUUIDPtr) dlsym(hLibrary, "libamcf_datastream_getuuid"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_DataStream_GetUUID == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_DataStream_GetContextUUID = (PLibAMCFDataStream_GetContextUUIDPtr) GetProcAddress(hLibrary, "libamcf_datastream_getcontextuuid"); #else // _WIN32 pWrapperTable->m_DataStream_GetContextUUID = (PLibAMCFDataStream_GetContextUUIDPtr) dlsym(hLibrary, "libamcf_datastream_getcontextuuid"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_DataStream_GetContextUUID == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_DataStream_GetName = (PLibAMCFDataStream_GetNamePtr) GetProcAddress(hLibrary, "libamcf_datastream_getname"); #else // _WIN32 pWrapperTable->m_DataStream_GetName = (PLibAMCFDataStream_GetNamePtr) dlsym(hLibrary, "libamcf_datastream_getname"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_DataStream_GetName == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_DataStream_GetMimeType = (PLibAMCFDataStream_GetMimeTypePtr) GetProcAddress(hLibrary, "libamcf_datastream_getmimetype"); #else // _WIN32 pWrapperTable->m_DataStream_GetMimeType = (PLibAMCFDataStream_GetMimeTypePtr) dlsym(hLibrary, "libamcf_datastream_getmimetype"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_DataStream_GetMimeType == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_DataStream_GetSize = (PLibAMCFDataStream_GetSizePtr) GetProcAddress(hLibrary, "libamcf_datastream_getsize"); #else // _WIN32 pWrapperTable->m_DataStream_GetSize = (PLibAMCFDataStream_GetSizePtr) dlsym(hLibrary, "libamcf_datastream_getsize"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_DataStream_GetSize == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_UploadData = (PLibAMCFStreamUpload_UploadDataPtr) GetProcAddress(hLibrary, "libamcf_streamupload_uploaddata"); #else // _WIN32 pWrapperTable->m_StreamUpload_UploadData = (PLibAMCFStreamUpload_UploadDataPtr) dlsym(hLibrary, "libamcf_streamupload_uploaddata"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_UploadData == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_UploadFile = (PLibAMCFStreamUpload_UploadFilePtr) GetProcAddress(hLibrary, "libamcf_streamupload_uploadfile"); #else // _WIN32 pWrapperTable->m_StreamUpload_UploadFile = (PLibAMCFStreamUpload_UploadFilePtr) dlsym(hLibrary, "libamcf_streamupload_uploadfile"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_UploadFile == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_BeginChunking = (PLibAMCFStreamUpload_BeginChunkingPtr) GetProcAddress(hLibrary, "libamcf_streamupload_beginchunking"); #else // _WIN32 pWrapperTable->m_StreamUpload_BeginChunking = (PLibAMCFStreamUpload_BeginChunkingPtr) dlsym(hLibrary, "libamcf_streamupload_beginchunking"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_BeginChunking == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_UploadChunk = (PLibAMCFStreamUpload_UploadChunkPtr) GetProcAddress(hLibrary, "libamcf_streamupload_uploadchunk"); #else // _WIN32 pWrapperTable->m_StreamUpload_UploadChunk = (PLibAMCFStreamUpload_UploadChunkPtr) dlsym(hLibrary, "libamcf_streamupload_uploadchunk"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_UploadChunk == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_FinishChunking = (PLibAMCFStreamUpload_FinishChunkingPtr) GetProcAddress(hLibrary, "libamcf_streamupload_finishchunking"); #else // _WIN32 pWrapperTable->m_StreamUpload_FinishChunking = (PLibAMCFStreamUpload_FinishChunkingPtr) dlsym(hLibrary, "libamcf_streamupload_finishchunking"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_FinishChunking == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_GetStatus = (PLibAMCFStreamUpload_GetStatusPtr) GetProcAddress(hLibrary, "libamcf_streamupload_getstatus"); #else // _WIN32 pWrapperTable->m_StreamUpload_GetStatus = (PLibAMCFStreamUpload_GetStatusPtr) dlsym(hLibrary, "libamcf_streamupload_getstatus"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_GetStatus == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_GetDataStream = (PLibAMCFStreamUpload_GetDataStreamPtr) GetProcAddress(hLibrary, "libamcf_streamupload_getdatastream"); #else // _WIN32 pWrapperTable->m_StreamUpload_GetDataStream = (PLibAMCFStreamUpload_GetDataStreamPtr) dlsym(hLibrary, "libamcf_streamupload_getdatastream"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_GetDataStream == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_GetBaseURL = (PLibAMCFConnection_GetBaseURLPtr) GetProcAddress(hLibrary, "libamcf_connection_getbaseurl"); #else // _WIN32 pWrapperTable->m_Connection_GetBaseURL = (PLibAMCFConnection_GetBaseURLPtr) dlsym(hLibrary, "libamcf_connection_getbaseurl"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_GetBaseURL == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_SetTimeouts = (PLibAMCFConnection_SetTimeoutsPtr) GetProcAddress(hLibrary, "libamcf_connection_settimeouts"); #else // _WIN32 pWrapperTable->m_Connection_SetTimeouts = (PLibAMCFConnection_SetTimeoutsPtr) dlsym(hLibrary, "libamcf_connection_settimeouts"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_SetTimeouts == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_GetTimeout = (PLibAMCFConnection_GetTimeoutPtr) GetProcAddress(hLibrary, "libamcf_connection_gettimeout"); #else // _WIN32 pWrapperTable->m_Connection_GetTimeout = (PLibAMCFConnection_GetTimeoutPtr) dlsym(hLibrary, "libamcf_connection_gettimeout"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_GetTimeout == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_GetRetryCount = (PLibAMCFConnection_GetRetryCountPtr) GetProcAddress(hLibrary, "libamcf_connection_getretrycount"); #else // _WIN32 pWrapperTable->m_Connection_GetRetryCount = (PLibAMCFConnection_GetRetryCountPtr) dlsym(hLibrary, "libamcf_connection_getretrycount"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_GetRetryCount == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_AuthenticateWithPassword = (PLibAMCFConnection_AuthenticateWithPasswordPtr) GetProcAddress(hLibrary, "libamcf_connection_authenticatewithpassword"); #else // _WIN32 pWrapperTable->m_Connection_AuthenticateWithPassword = (PLibAMCFConnection_AuthenticateWithPasswordPtr) dlsym(hLibrary, "libamcf_connection_authenticatewithpassword"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_AuthenticateWithPassword == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_IsAuthenticated = (PLibAMCFConnection_IsAuthenticatedPtr) GetProcAddress(hLibrary, "libamcf_connection_isauthenticated"); #else // _WIN32 pWrapperTable->m_Connection_IsAuthenticated = (PLibAMCFConnection_IsAuthenticatedPtr) dlsym(hLibrary, "libamcf_connection_isauthenticated"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_IsAuthenticated == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_RefreshAuthentication = (PLibAMCFConnection_RefreshAuthenticationPtr) GetProcAddress(hLibrary, "libamcf_connection_refreshauthentication"); #else // _WIN32 pWrapperTable->m_Connection_RefreshAuthentication = (PLibAMCFConnection_RefreshAuthenticationPtr) dlsym(hLibrary, "libamcf_connection_refreshauthentication"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_RefreshAuthentication == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_Ping = (PLibAMCFConnection_PingPtr) GetProcAddress(hLibrary, "libamcf_connection_ping"); #else // _WIN32 pWrapperTable->m_Connection_Ping = (PLibAMCFConnection_PingPtr) dlsym(hLibrary, "libamcf_connection_ping"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_Ping == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_GetAuthToken = (PLibAMCFConnection_GetAuthTokenPtr) GetProcAddress(hLibrary, "libamcf_connection_getauthtoken"); #else // _WIN32 pWrapperTable->m_Connection_GetAuthToken = (PLibAMCFConnection_GetAuthTokenPtr) dlsym(hLibrary, "libamcf_connection_getauthtoken"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_GetAuthToken == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_CreateUpload = (PLibAMCFConnection_CreateUploadPtr) GetProcAddress(hLibrary, "libamcf_connection_createupload"); #else // _WIN32 pWrapperTable->m_Connection_CreateUpload = (PLibAMCFConnection_CreateUploadPtr) dlsym(hLibrary, "libamcf_connection_createupload"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_CreateUpload == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_GetVersion = (PLibAMCFGetVersionPtr) GetProcAddress(hLibrary, "libamcf_getversion"); #else // _WIN32 pWrapperTable->m_GetVersion = (PLibAMCFGetVersionPtr) dlsym(hLibrary, "libamcf_getversion"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_GetVersion == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_GetLastError = (PLibAMCFGetLastErrorPtr) GetProcAddress(hLibrary, "libamcf_getlasterror"); #else // _WIN32 pWrapperTable->m_GetLastError = (PLibAMCFGetLastErrorPtr) dlsym(hLibrary, "libamcf_getlasterror"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_GetLastError == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_ReleaseInstance = (PLibAMCFReleaseInstancePtr) GetProcAddress(hLibrary, "libamcf_releaseinstance"); #else // _WIN32 pWrapperTable->m_ReleaseInstance = (PLibAMCFReleaseInstancePtr) dlsym(hLibrary, "libamcf_releaseinstance"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_ReleaseInstance == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_AcquireInstance = (PLibAMCFAcquireInstancePtr) GetProcAddress(hLibrary, "libamcf_acquireinstance"); #else // _WIN32 pWrapperTable->m_AcquireInstance = (PLibAMCFAcquireInstancePtr) dlsym(hLibrary, "libamcf_acquireinstance"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_AcquireInstance == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_InjectComponent = (PLibAMCFInjectComponentPtr) GetProcAddress(hLibrary, "libamcf_injectcomponent"); #else // _WIN32 pWrapperTable->m_InjectComponent = (PLibAMCFInjectComponentPtr) dlsym(hLibrary, "libamcf_injectcomponent"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_InjectComponent == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_GetSymbolLookupMethod = (PLibAMCFGetSymbolLookupMethodPtr) GetProcAddress(hLibrary, "libamcf_getsymbollookupmethod"); #else // _WIN32 pWrapperTable->m_GetSymbolLookupMethod = (PLibAMCFGetSymbolLookupMethodPtr) dlsym(hLibrary, "libamcf_getsymbollookupmethod"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_GetSymbolLookupMethod == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_CreateConnection = (PLibAMCFCreateConnectionPtr) GetProcAddress(hLibrary, "libamcf_createconnection"); #else // _WIN32 pWrapperTable->m_CreateConnection = (PLibAMCFCreateConnectionPtr) dlsym(hLibrary, "libamcf_createconnection"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_CreateConnection == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; pWrapperTable->m_LibraryHandle = hLibrary; return LIBAMCF_SUCCESS; } inline LibAMCFResult CWrapper::loadWrapperTableFromSymbolLookupMethod(sLibAMCFDynamicWrapperTable * pWrapperTable, void* pSymbolLookupMethod) { if (pWrapperTable == nullptr) return LIBAMCF_ERROR_INVALIDPARAM; if (pSymbolLookupMethod == nullptr) return LIBAMCF_ERROR_INVALIDPARAM; typedef LibAMCFResult(*SymbolLookupType)(const char*, void**); SymbolLookupType pLookup = (SymbolLookupType)pSymbolLookupMethod; LibAMCFResult eLookupError = LIBAMCF_SUCCESS; eLookupError = (*pLookup)("libamcf_operationresult_waitfor", (void**)&(pWrapperTable->m_OperationResult_WaitFor)); if ( (eLookupError != 0) || (pWrapperTable->m_OperationResult_WaitFor == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_operationresult_inprogress", (void**)&(pWrapperTable->m_OperationResult_InProgress)); if ( (eLookupError != 0) || (pWrapperTable->m_OperationResult_InProgress == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_operationresult_success", (void**)&(pWrapperTable->m_OperationResult_Success)); if ( (eLookupError != 0) || (pWrapperTable->m_OperationResult_Success == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_operationresult_geterrormessage", (void**)&(pWrapperTable->m_OperationResult_GetErrorMessage)); if ( (eLookupError != 0) || (pWrapperTable->m_OperationResult_GetErrorMessage == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_datastream_getuuid", (void**)&(pWrapperTable->m_DataStream_GetUUID)); if ( (eLookupError != 0) || (pWrapperTable->m_DataStream_GetUUID == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_datastream_getcontextuuid", (void**)&(pWrapperTable->m_DataStream_GetContextUUID)); if ( (eLookupError != 0) || (pWrapperTable->m_DataStream_GetContextUUID == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_datastream_getname", (void**)&(pWrapperTable->m_DataStream_GetName)); if ( (eLookupError != 0) || (pWrapperTable->m_DataStream_GetName == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_datastream_getmimetype", (void**)&(pWrapperTable->m_DataStream_GetMimeType)); if ( (eLookupError != 0) || (pWrapperTable->m_DataStream_GetMimeType == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_datastream_getsize", (void**)&(pWrapperTable->m_DataStream_GetSize)); if ( (eLookupError != 0) || (pWrapperTable->m_DataStream_GetSize == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_uploaddata", (void**)&(pWrapperTable->m_StreamUpload_UploadData)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_UploadData == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_uploadfile", (void**)&(pWrapperTable->m_StreamUpload_UploadFile)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_UploadFile == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_beginchunking", (void**)&(pWrapperTable->m_StreamUpload_BeginChunking)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_BeginChunking == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_uploadchunk", (void**)&(pWrapperTable->m_StreamUpload_UploadChunk)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_UploadChunk == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_finishchunking", (void**)&(pWrapperTable->m_StreamUpload_FinishChunking)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_FinishChunking == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_getstatus", (void**)&(pWrapperTable->m_StreamUpload_GetStatus)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_GetStatus == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_getdatastream", (void**)&(pWrapperTable->m_StreamUpload_GetDataStream)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_GetDataStream == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_getbaseurl", (void**)&(pWrapperTable->m_Connection_GetBaseURL)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_GetBaseURL == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_settimeouts", (void**)&(pWrapperTable->m_Connection_SetTimeouts)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_SetTimeouts == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_gettimeout", (void**)&(pWrapperTable->m_Connection_GetTimeout)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_GetTimeout == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_getretrycount", (void**)&(pWrapperTable->m_Connection_GetRetryCount)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_GetRetryCount == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_authenticatewithpassword", (void**)&(pWrapperTable->m_Connection_AuthenticateWithPassword)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_AuthenticateWithPassword == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_isauthenticated", (void**)&(pWrapperTable->m_Connection_IsAuthenticated)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_IsAuthenticated == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_refreshauthentication", (void**)&(pWrapperTable->m_Connection_RefreshAuthentication)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_RefreshAuthentication == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_ping", (void**)&(pWrapperTable->m_Connection_Ping)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_Ping == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_getauthtoken", (void**)&(pWrapperTable->m_Connection_GetAuthToken)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_GetAuthToken == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_createupload", (void**)&(pWrapperTable->m_Connection_CreateUpload)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_CreateUpload == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_getversion", (void**)&(pWrapperTable->m_GetVersion)); if ( (eLookupError != 0) || (pWrapperTable->m_GetVersion == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_getlasterror", (void**)&(pWrapperTable->m_GetLastError)); if ( (eLookupError != 0) || (pWrapperTable->m_GetLastError == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_releaseinstance", (void**)&(pWrapperTable->m_ReleaseInstance)); if ( (eLookupError != 0) || (pWrapperTable->m_ReleaseInstance == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_acquireinstance", (void**)&(pWrapperTable->m_AcquireInstance)); if ( (eLookupError != 0) || (pWrapperTable->m_AcquireInstance == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_injectcomponent", (void**)&(pWrapperTable->m_InjectComponent)); if ( (eLookupError != 0) || (pWrapperTable->m_InjectComponent == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_getsymbollookupmethod", (void**)&(pWrapperTable->m_GetSymbolLookupMethod)); if ( (eLookupError != 0) || (pWrapperTable->m_GetSymbolLookupMethod == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_createconnection", (void**)&(pWrapperTable->m_CreateConnection)); if ( (eLookupError != 0) || (pWrapperTable->m_CreateConnection == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; return LIBAMCF_SUCCESS; } /** * Method definitions for class CBase */ /** * Method definitions for class COperationResult */ /** * COperationResult::WaitFor - Waits for operation to be finished. * @param[in] nTimeOut - Timeout value in Milliseconds. 0 means forever. * @return Returns if operation has been finished. */ bool COperationResult::WaitFor(const LibAMCF_uint32 nTimeOut) { bool resultOperationFinished = 0; CheckError(m_pWrapper->m_WrapperTable.m_OperationResult_WaitFor(m_pHandle, nTimeOut, &resultOperationFinished)); return resultOperationFinished; } /** * COperationResult::InProgress - Checks if operation is in progress. * @return Flag if operation is in progress. */ bool COperationResult::InProgress() { bool resultOperationIsInProgress = 0; CheckError(m_pWrapper->m_WrapperTable.m_OperationResult_InProgress(m_pHandle, &resultOperationIsInProgress)); return resultOperationIsInProgress; } /** * COperationResult::Success - Checks if operation has been finished successfully. Waits for operation to finish. * @return Flag if operation has been finished successful. */ bool COperationResult::Success() { bool resultOperationSuccess = 0; CheckError(m_pWrapper->m_WrapperTable.m_OperationResult_Success(m_pHandle, &resultOperationSuccess)); return resultOperationSuccess; } /** * COperationResult::GetErrorMessage - Returns the error message, if the operation has not been successful. Fails if operation is in progress. * @return Returns error message of failed operation. */ std::string COperationResult::GetErrorMessage() { LibAMCF_uint32 bytesNeededErrorMessage = 0; LibAMCF_uint32 bytesWrittenErrorMessage = 0; CheckError(m_pWrapper->m_WrapperTable.m_OperationResult_GetErrorMessage(m_pHandle, 0, &bytesNeededErrorMessage, nullptr)); std::vector<char> bufferErrorMessage(bytesNeededErrorMessage); CheckError(m_pWrapper->m_WrapperTable.m_OperationResult_GetErrorMessage(m_pHandle, bytesNeededErrorMessage, &bytesWrittenErrorMessage, &bufferErrorMessage[0])); return std::string(&bufferErrorMessage[0]); } /** * Method definitions for class CDataStream */ /** * CDataStream::GetUUID - Returns the stream UUID. * @return Stream UUID String. */ std::string CDataStream::GetUUID() { LibAMCF_uint32 bytesNeededUUID = 0; LibAMCF_uint32 bytesWrittenUUID = 0; CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetUUID(m_pHandle, 0, &bytesNeededUUID, nullptr)); std::vector<char> bufferUUID(bytesNeededUUID); CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetUUID(m_pHandle, bytesNeededUUID, &bytesWrittenUUID, &bufferUUID[0])); return std::string(&bufferUUID[0]); } /** * CDataStream::GetContextUUID - Returns the stream's context UUID. * @return Stream Context UUID String. */ std::string CDataStream::GetContextUUID() { LibAMCF_uint32 bytesNeededContextUUID = 0; LibAMCF_uint32 bytesWrittenContextUUID = 0; CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetContextUUID(m_pHandle, 0, &bytesNeededContextUUID, nullptr)); std::vector<char> bufferContextUUID(bytesNeededContextUUID); CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetContextUUID(m_pHandle, bytesNeededContextUUID, &bytesWrittenContextUUID, &bufferContextUUID[0])); return std::string(&bufferContextUUID[0]); } /** * CDataStream::GetName - Returns the stream name. * @return Stream Name. */ std::string CDataStream::GetName() { LibAMCF_uint32 bytesNeededName = 0; LibAMCF_uint32 bytesWrittenName = 0; CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetName(m_pHandle, 0, &bytesNeededName, nullptr)); std::vector<char> bufferName(bytesNeededName); CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetName(m_pHandle, bytesNeededName, &bytesWrittenName, &bufferName[0])); return std::string(&bufferName[0]); } /** * CDataStream::GetMimeType - Returns the stream's mime type. * @return Mime Type string. */ std::string CDataStream::GetMimeType() { LibAMCF_uint32 bytesNeededMimeType = 0; LibAMCF_uint32 bytesWrittenMimeType = 0; CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetMimeType(m_pHandle, 0, &bytesNeededMimeType, nullptr)); std::vector<char> bufferMimeType(bytesNeededMimeType); CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetMimeType(m_pHandle, bytesNeededMimeType, &bytesWrittenMimeType, &bufferMimeType[0])); return std::string(&bufferMimeType[0]); } /** * CDataStream::GetSize - Returns the stream size. * @return Stream size. */ LibAMCF_uint64 CDataStream::GetSize() { LibAMCF_uint64 resultStreamSize = 0; CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetSize(m_pHandle, &resultStreamSize)); return resultStreamSize; } /** * Method definitions for class CStreamUpload */ /** * CStreamUpload::UploadData - uploads the passed data to the server. MUST only be called once. * @param[in] DataBuffer - Data to be uploaded. * @param[in] nChunkSize - Chunk size to use in bytes. MUST be at least 64kB. * @return Returns if upload was successful. */ POperationResult CStreamUpload::UploadData(const CInputVector<LibAMCF_uint8> & DataBuffer, const LibAMCF_uint32 nChunkSize) { LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_UploadData(m_pHandle, (LibAMCF_uint64)DataBuffer.size(), DataBuffer.data(), nChunkSize, &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CStreamUpload::UploadFile - uploads a file to the server. MUST only be called once. * @param[in] sFileName - File to be uploaded. * @param[in] nChunkSize - Chunk size to use in bytes. MUST be at least 64kB. * @return Returns if upload was successful. */ POperationResult CStreamUpload::UploadFile(const std::string & sFileName, const LibAMCF_uint32 nChunkSize) { LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_UploadFile(m_pHandle, sFileName.c_str(), nChunkSize, &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CStreamUpload::BeginChunking - Starts a chunked upload. MUST not be used together with uploadData or uploadFile * @param[in] nDataSize - Full data size to be uploaded. */ void CStreamUpload::BeginChunking(const LibAMCF_uint64 nDataSize) { CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_BeginChunking(m_pHandle, nDataSize)); } /** * CStreamUpload::UploadChunk - Uploads another chunk to the server. Chunks are added sequentially together. * @param[in] DataBuffer - Data to be uploaded. * @return Returns if upload was successful. */ POperationResult CStreamUpload::UploadChunk(const CInputVector<LibAMCF_uint8> & DataBuffer) { LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_UploadChunk(m_pHandle, (LibAMCF_uint64)DataBuffer.size(), DataBuffer.data(), &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CStreamUpload::FinishChunking - MUST only be called after all chunks have been uploaded. * @param[in] DataBuffer - Data to be uploaded. * @return Returns if upload was successful. */ POperationResult CStreamUpload::FinishChunking(const CInputVector<LibAMCF_uint8> & DataBuffer) { LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_FinishChunking(m_pHandle, (LibAMCF_uint64)DataBuffer.size(), DataBuffer.data(), &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CStreamUpload::GetStatus - Retrieves current upload status. * @param[out] nUploadSize - Total size of the upload. * @param[out] nUploadedBytes - Current uploaded data. * @param[out] bFinished - Upload has been finished. */ void CStreamUpload::GetStatus(LibAMCF_uint64 & nUploadSize, LibAMCF_uint64 & nUploadedBytes, bool & bFinished) { CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_GetStatus(m_pHandle, &nUploadSize, &nUploadedBytes, &bFinished)); } /** * CStreamUpload::GetDataStream - Retrieves the uploaded data stream object. Upload must have finished successfully. * @return Data stream instance. */ PDataStream CStreamUpload::GetDataStream() { LibAMCFHandle hDataStream = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_GetDataStream(m_pHandle, &hDataStream)); if (!hDataStream) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<CDataStream>(m_pWrapper, hDataStream); } /** * Method definitions for class CConnection */ /** * CConnection::GetBaseURL - returns the base url of the AMCF instance * @return Base URL of the AMCF instance. */ std::string CConnection::GetBaseURL() { LibAMCF_uint32 bytesNeededBaseURL = 0; LibAMCF_uint32 bytesWrittenBaseURL = 0; CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetBaseURL(m_pHandle, 0, &bytesNeededBaseURL, nullptr)); std::vector<char> bufferBaseURL(bytesNeededBaseURL); CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetBaseURL(m_pHandle, bytesNeededBaseURL, &bytesWrittenBaseURL, &bufferBaseURL[0])); return std::string(&bufferBaseURL[0]); } /** * CConnection::SetTimeouts - sets the timeout behaviour of the connection. * @param[in] nTimeout - Request timeout in milliseconds. Default is 1000. * @param[in] nRetryCount - How many retries should be done in an error case. Default is 3. */ void CConnection::SetTimeouts(const LibAMCF_uint32 nTimeout, const LibAMCF_uint32 nRetryCount) { CheckError(m_pWrapper->m_WrapperTable.m_Connection_SetTimeouts(m_pHandle, nTimeout, nRetryCount)); } /** * CConnection::GetTimeout - gets the timeout behaviour of the connection. * @return Request timeout in milliseconds */ LibAMCF_uint32 CConnection::GetTimeout() { LibAMCF_uint32 resultTimeout = 0; CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetTimeout(m_pHandle, &resultTimeout)); return resultTimeout; } /** * CConnection::GetRetryCount - gets the timeout behaviour of the connection. * @return How many retries should be done in an error case. */ LibAMCF_uint32 CConnection::GetRetryCount() { LibAMCF_uint32 resultRetryCount = 0; CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetRetryCount(m_pHandle, &resultRetryCount)); return resultRetryCount; } /** * CConnection::AuthenticateWithPassword - Authenticates with the remote instance with username and password. * @param[in] sUserName - User name for authentication. * @param[in] sPassword - Password for authentication. * @return Returns if authentication was successful. */ POperationResult CConnection::AuthenticateWithPassword(const std::string & sUserName, const std::string & sPassword) { std::lock_guard<std::mutex> lockGuard(m_InstanceMutex); LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_Connection_AuthenticateWithPassword(m_pHandle, sUserName.c_str(), sPassword.c_str(), &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CConnection::IsAuthenticated - Authenticates with the remote instance with username and password * @return Returns if connection is authenticated. */ bool CConnection::IsAuthenticated() { bool resultIsAuthenticated = 0; CheckError(m_pWrapper->m_WrapperTable.m_Connection_IsAuthenticated(m_pHandle, &resultIsAuthenticated)); return resultIsAuthenticated; } /** * CConnection::RefreshAuthentication - Refreshes authentication with server. * @return Returns if authentication refresh was successful. */ POperationResult CConnection::RefreshAuthentication() { LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_Connection_RefreshAuthentication(m_pHandle, &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CConnection::Ping - Detects if server is still reachable. Non-Blocking. * @return Returns if server is still reachable. */ POperationResult CConnection::Ping() { LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_Connection_Ping(m_pHandle, &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CConnection::GetAuthToken - Returns the authentication token of the current connection. * @return Token string. */ std::string CConnection::GetAuthToken() { LibAMCF_uint32 bytesNeededToken = 0; LibAMCF_uint32 bytesWrittenToken = 0; CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetAuthToken(m_pHandle, 0, &bytesNeededToken, nullptr)); std::vector<char> bufferToken(bytesNeededToken); CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetAuthToken(m_pHandle, bytesNeededToken, &bytesWrittenToken, &bufferToken[0])); return std::string(&bufferToken[0]); } /** * CConnection::CreateUpload - Creates a file upload instance. Must be authenticated to make it work. * @param[in] sName - Name of the file to be uploaded. * @param[in] sMimeType - Mimetype of the file to be uploaded. * @param[in] sUsageContext - Context string for the usage type of the file. * @return File upload instance. */ PStreamUpload CConnection::CreateUpload(const std::string & sName, const std::string & sMimeType, const std::string & sUsageContext) { LibAMCFHandle hInstance = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_Connection_CreateUpload(m_pHandle, sName.c_str(), sMimeType.c_str(), sUsageContext.c_str(), &hInstance)); if (!hInstance) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<CStreamUpload>(m_pWrapper, hInstance); } } // namespace LibAMCF #endif // __LIBAMCF_CPPHEADER_DYNAMIC_CPP
ff8ea931404a23537871eee18d88d7c6b8afe0de
0c7e20a002108d636517b2f0cde6de9019fdf8c4
/Sources/Elastos/External/conscrypt/src/org/conscrypt/COpenSSLServerSocketFactoryImpl.cpp
82c1ce7df4bc5066f977763f52c104c8bfa7f239
[ "Apache-2.0" ]
permissive
kernal88/Elastos5
022774d8c42aea597e6f8ee14e80e8e31758f950
871044110de52fcccfbd6fd0d9c24feefeb6dea0
refs/heads/master
2021-01-12T15:23:52.242654
2016-10-24T08:20:15
2016-10-24T08:20:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
194
cpp
#include "org/conscrypt/COpenSSLServerSocketFactoryImpl.h" namespace Org { namespace Conscrypt { CAR_OBJECT_IMPL(COpenSSLServerSocketFactoryImpl) } // namespace Conscrypt } // namespace Org
80b2e30aca84e8387c6fe493989e0629d9681e18
7fcef731b4054ca365062b19f90840c69ed35071
/mainwindow.cpp
8b2adf9ac753dac3e325e8100cb2e973e9f74b82
[]
no_license
kacpwoja/EGUI_Calendar_Qt
b40f49de5b44d4b4ef9f6f37ba951dbcfb4347af
45d4942c0c9a3232cfe192de0c86cd093f3137ff
refs/heads/master
2022-04-11T00:20:20.457625
2020-04-09T18:06:32
2020-04-09T18:06:32
249,783,068
0
0
null
null
null
null
UTF-8
C++
false
false
3,279
cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QCalendarWidget> #include <QTextCharFormat> #include <QVector> #include <QFile> #include <QJsonDocument> #include "daywindow.h" #include "eventwindow.h" #include "eventbase.h" #define FILENAME "events.json" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); //READ FROM FILE QFile loadFile(QStringLiteral(FILENAME)); if(!loadFile.open(QIODevice::ReadOnly)) { qWarning("File was not read."); EventDB.clear(); } else { QJsonDocument doc = QJsonDocument::fromJson(loadFile.readAll()); EventDB.read(doc.object()); } loadFile.close(); formatCalendar(); connect(ui->todayButton, &QPushButton::released, this, &MainWindow::selectToday); connect(ui->newEventButton, &QPushButton::released, this, &MainWindow::newEvent); connect(ui->calendar, &QCalendarWidget::selectionChanged, this, &MainWindow::updateTopText); connect(ui->calendar, &QCalendarWidget::activated, this, &MainWindow::viewDay); connect(&EventDB, &EventBase::baseUpdated, this, &MainWindow::formatCalendar); connect(ui->calendar, &QCalendarWidget::currentPageChanged, this, &MainWindow::formatCalendar); } MainWindow::~MainWindow() { //SAVE TO FILE QFile saveFile(QStringLiteral(FILENAME)); if(!saveFile.open(QIODevice::WriteOnly)) qWarning("File was not saved."); QJsonObject obj; EventDB.write(obj); QJsonDocument doc(obj); saveFile.write(doc.toJson()); saveFile.close(); delete ui; } void MainWindow::selectToday() { ui->calendar->setSelectedDate(QDate::currentDate()); } void MainWindow::formatCalendar() { updateTopText(); // Reset format for all days ui->calendar->setDateTextFormat(QDate(), QTextCharFormat()); // Format for event days QTextCharFormat eventFormat; auto palette = qApp->palette(); eventFormat.setBackground(palette.brush(QPalette::Mid)); // Setting format for all event days QDate it = QDate(ui->calendar->yearShown(), ui->calendar->monthShown(), 1); while(it.month() == ui->calendar->monthShown()) { if(EventDB.count(it) > 0) { ui->calendar->setDateTextFormat(it, eventFormat); } it = it.addDays(1); } } void MainWindow::updateTopText() { QString dateText; QString pluralSuffix = ""; QString eventText; // Getting date if(ui->calendar->selectedDate() == QDate::currentDate()) dateText = "today"; else dateText = "on " + ui->calendar->selectedDate().toString("d MMMM yyyy"); // Getting event count int events = EventDB.count(ui->calendar->selectedDate()); if(events != 1) pluralSuffix = "s"; if(events == 0) eventText = "no"; else eventText = QString::number(events); ui->dayEventsLabel->setText("You have " + eventText + " event" + pluralSuffix + " " + dateText + "."); } void MainWindow::viewDay(const QDate& date) { DayWindow* dayWin = new DayWindow(date, this); dayWin->exec(); } void MainWindow::newEvent() { EventWindow* eventWin = new EventWindow(ui->calendar->selectedDate(), this); eventWin->exec(); }
bc11c519dbd8362cbcd4ada4658dc411d186c86d
ef9c90197796606ee5d3d800d9823f2b332070a6
/hw04/src/mygl.cpp
49c4d8755316f7e412c3807e8df8a5e5a1e4d315
[]
no_license
hehehaha12139/CIS-460-560
d5af73f7091389040e3e0c962af55052a026679c
b76be1eb5c5f7085e6669059399520576a69e07b
refs/heads/master
2020-09-06T08:58:13.030233
2017-02-21T17:40:48
2017-02-21T17:40:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,952
cpp
#include "mygl.h" #include <la.h> #include <iostream> #include <QApplication> #include <QKeyEvent> MyGL::MyGL(QWidget *parent) : GLWidget277(parent), geom_cylinder(this), geom_sphere(this), geom_cube(this), geom_cone(this), geom_pipe(this), //TODO: When you make your Cube instance, add it to this init list prog_lambert(this), prog_flat(this) { } MyGL::~MyGL() { makeCurrent(); glDeleteVertexArrays(1, &vao); geom_cylinder.destroy(); geom_sphere.destroy(); geom_cube.destroy(); geom_cone.destroy(); geom_pipe.destroy(); } void MyGL::initializeGL() { // Create an OpenGL context using Qt's QOpenGLFunctions_3_2_Core class // If you were programming in a non-Qt context you might use GLEW (GL Extension Wrangler)instead initializeOpenGLFunctions(); // Print out some information about the current OpenGL context debugContextVersion(); // Set a few settings/modes in OpenGL rendering glEnable(GL_DEPTH_TEST); glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); // Set the size with which points should be rendered glPointSize(5); // Set the color with which the screen is filled at the start of each render call. glClearColor(0.5, 0.5, 0.5, 1); printGLErrorLog(); // Create a Vertex Attribute Object glGenVertexArrays(1, &vao); //Create the instances of Cylinder Sphere and cube. geom_cylinder.create(); geom_sphere.create(); geom_cube.create(); geom_cone.create(); geom_pipe.create(); Root = new Node(); // lower limb should rotate around its joint // this step is to move the rotation pivot from its geometry center to its edge center. TranslateNode LowerLimbTranslate_1(0,0.5f,0); // We need to rotate 180 degrees so that the vertex part should be facing downwards. // FOR TAs: make changes to the degree and you can rotate this part, e.c 150 degrees. RotateNode LowerLimbRotate(180,1,0,0); ScaleNode LowerLimbScale(1.0f,2.0f,1.0f); // move this geometry back to the position it should be, which connects with upper limb. TranslateNode LowerLimbTranslate_2(0.0f,1.0f,0.0f); LowerLimb = new Node(LowerLimbTranslate_1.MatrixStored() * LowerLimbRotate.MatrixStored() * \ LowerLimbScale.MatrixStored() * LowerLimbTranslate_2.MatrixStored(), \ QString("LowerLimb")); LowerLimb->setGeomColor(glm::vec4(0,1,0,1)); LowerLimb->setGeometry(&geom_cone); TranslateNode UpperLimbTranslate(0,-1.0f,0); RotateNode UpperLimbRotate(0,0,0,0); ScaleNode UpperLimbScale(1.0f,1.0f,0.5f); UpperLimb = new Node(UpperLimbTranslate.MatrixStored() * UpperLimbRotate.MatrixStored() * UpperLimbScale.MatrixStored(), \ QString("UpperLimb")); UpperLimb->setGeomColor(glm::vec4(1,1,0,1)); UpperLimb->setGeometry(&geom_cylinder); UpperLimb->addChild(LowerLimb); TranslateNode HeadTranslate(0,1.0f,0); RotateNode HeadRotate(0,0,0,0); ScaleNode HeadScale(1,1,0.5f); Head = new Node(HeadTranslate.MatrixStored() * HeadRotate.MatrixStored() * HeadScale.MatrixStored(), \ QString("Head")); Head->setGeomColor(glm::vec4(0,0,1,1)); Head->setGeometry(&geom_sphere); TranslateNode BodyTranslate(0,0,0); RotateNode BodyRotate(0,0,0,0); ScaleNode BodyScale(1,1,2); Body = new Node(BodyTranslate.MatrixStored() * BodyRotate.MatrixStored() * BodyScale.MatrixStored(), \ QString("Body")); Body->setGeometry(&geom_cube); Body->setGeomColor(glm::vec4(0.5,0.5,0.5,1)); Body->addChild(Head); Body->addChild(UpperLimb); TranslateNode RootTranslate(0,0,0); RotateNode RootRotate(0,0,0,0); ScaleNode RootScale(1,1,1); Root = new Node(RootTranslate.MatrixStored() * RootRotate.MatrixStored() * RootScale.MatrixStored(), \ QString("Root")); Root->addChild(Body); // Create and set up the diffuse shader prog_lambert.create(":/glsl/lambert.vert.glsl", ":/glsl/lambert.frag.glsl"); // Create and set up the flat lighting shader prog_flat.create(":/glsl/flat.vert.glsl", ":/glsl/flat.frag.glsl"); // Set a color with which to draw geometry since you won't have one // defined until you implement the Node classes. // This makes your geometry render green. // prog_lambert.setGeometryColor(glm::vec4(0,1,0,1)); // We have to have a VAO bound in OpenGL 3.2 Core. But if we're not // using multiple VAOs, we can just bind one once. // vao.bind(); glBindVertexArray(vao); emit sig_scenegraph(this->Root); } void MyGL::resizeGL(int w, int h) { //This code sets the concatenated view and perspective projection matrices used for //our scene's camera view. glm::vec4 c1(1.1933f, 0, 1.1933f, 0); glm::vec4 c2(0.9856f, 1.9712f, -0.9856f, 0); glm::vec4 c3(0.5785f, -0.5785f, -0.5785f, 11.9484f); glm::vec4 c4(0.5774f, -0.5774f, -0.5774f, 12.1244f); glm::mat4 viewproj(c1, c2, c3, c4); //Transpose since GLM is column major and I wrote out the rows of the matrix viewproj = glm::transpose(viewproj); // Upload the view-projection matrix to our shaders (i.e. onto the graphics card) prog_lambert.setViewProjMatrix(viewproj); prog_flat.setViewProjMatrix(viewproj); printGLErrorLog(); } //This function is called by Qt any time your GL window is supposed to update //For example, when the function updateGL is called, paintGL is called implicitly. //DO NOT CONSTRUCT YOUR SCENE GRAPH IN THIS FUNCTION! void MyGL::paintGL() { // Clear the screen so that we only see newly drawn images glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //VVV CLEAR THIS CODE WHEN YOU IMPLEMENT SCENE GRAPH TRAVERSAL VVV/////////////////// #define NOPE #ifdef NOPE //Create a model matrix. This one scales the sphere uniformly by 3, then translates it by <-2,0,0>. //Note that we have to transpose the model matrix before passing it to the shader //This is because OpenGL expects column-major matrices, but you've //implemented row-major matrices. // glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(-2,0,0)) * glm::scale(glm::mat4(1.0f), glm::vec3(3,3,3)); // //Send the geometry's transformation matrix to the shader // prog_lambert.setModelMatrix(model); // //Draw the example sphere using our lambert shader // prog_lambert.draw(geom_sphere); //Now do the same to render the cylinder //We've rotated it -45 degrees on the Z axis, then translated it to the point <2,2,0> // model = glm::translate(glm::mat4(1.0f), glm::vec3(2,2,0)) * glm::rotate(glm::mat4(1.0f), glm::radians(-45.0f), glm::vec3(0,0,1)); // prog_lambert.setModelMatrix(model); // prog_lambert.draw(geom_cylinder); // model = glm::translate(glm::mat4(1.0f), glm::vec3(0,0,0)) * glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(0,0,1)) \ // * glm::scale(glm::mat4(1.0f), glm::vec3(2,2,2));; // prog_lambert.setModelMatrix(model); // prog_lambert.draw(geom_cube); // glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(0,0,0)) * glm::scale(glm::mat4(1.0f), glm::vec3(2,2,2)); // prog_lambert.setModelMatrix(model); // prog_lambert.draw(geom_cone); // glm::mat4 model = glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(0,0,1)) * glm::scale(glm::mat4(1.0f), glm::vec3(2,2,2)); // prog_lambert.setModelMatrix(model); // prog_lambert.draw(geom_pipe); #endif //^^^ CLEAR THIS CODE WHEN YOU IMPLEMENT SCENE GRAPH TRAVERSAL ^^^///////////////// //Here is a good spot to call your scene graph traversal function. traverse(Root, Root->MatrixStored(), prog_lambert); } void MyGL::keyPressEvent(QKeyEvent *e) { // http://doc.qt.io/qt-5/qt.html#Key-enum if (e->key() == Qt::Key_Escape) { QApplication::quit(); } } void MyGL::traverse(Node* N, glm::mat4 T, ShaderProgram p) { T = T * N->MatrixStored(); for (int i = 0; i < (int)N->children.size(); i++) { traverse(N->children[i], T, p); } if (N->geometry != NULL) { p.setModelMatrix(T); prog_lambert.setGeometryColor(N->color); p.draw(*(N->geometry)); } } // ItemClicked's slot void MyGL::slot_changeGeometry(QTreeWidgetItem* p, int n) { Head->setGeomColor(Head_color); Body->setGeomColor(Body_color); UpperLimb->setGeomColor(UpperLimb_color); LowerLimb->setGeomColor(LowerLimb_color); if (p->text(n) == "Head") Head->setGeomColor(glm::vec4(1,1,1,1)); else if (p->text(n) == "Body") Body->setGeomColor(glm::vec4(1,1,1,1)); else if (p->text(n) == "UpperLimb") UpperLimb->setGeomColor(glm::vec4(1,1,1,1)); else if (p->text(n) == "LowerLimb") LowerLimb->setGeomColor(glm::vec4(1,1,1,1)); else; }
d09ae779e09674942523ba814ed0a332983437ca
16288c0fb3a712150c715ddd0c9843e75f69034b
/cpp01/ex06/main.cpp
b049b16b7a1e231cc0b15c7d1914d65ab59c2b08
[]
no_license
brian-xu-vlt/42_CPP_PISCINE
3c6cb8ce224e53335b3e53cd24c97dc867c2d9f0
bda1f5834649e50012d0153c3cdd28769280fc9d
refs/heads/main
2023-02-25T23:17:43.176521
2021-02-03T07:12:22
2021-02-03T07:12:22
323,266,501
1
0
null
null
null
null
UTF-8
C++
false
false
419
cpp
#include "Weapon.hpp" #include "HumanA.hpp" #include "HumanB.hpp" int main( void ) { { Weapon club = Weapon("crude spiked club"); HumanA bob("Bob", club); bob.attack(); club.setType("some other type of club"); bob.attack(); } { Weapon club = Weapon("crude spiked club"); HumanB jim("Jim"); jim.setWeapon(club); jim.attack(); club.setType("some other type of club"); jim.attack(); } }
1eff4e3abd4126b813d4243ed6f25383478e094a
a369b0b66c01c9db9768bf94c685a70f14256761
/examples/B_charsets/B_charsets.ino
b09064021d513aa60b60008eab8dfa078d64fad8
[ "MIT" ]
permissive
gdsports/USBPrinter_uhls
7ff7156bb3dae68d80b57f5344b171394238454e
5ca7cb94486dc9eff85d1dd19442145a0b3f7e86
refs/heads/master
2020-06-12T22:49:15.681202
2019-07-11T08:09:45
2019-07-11T08:09:45
194,451,706
2
1
null
null
null
null
UTF-8
C++
false
false
2,342
ino
/*------------------------------------------------------------------------ Demoonstrate different character sets on ESC POS printers connecting to SAMD USB host port Based on Adafruit Thermal printer library. ------------------------------------------------------------------------*/ #include "ESC_POS_Printer.h" #include "USBPrinter.h" class PrinterOper : public USBPrinterAsyncOper { public: uint8_t OnInit(USBPrinter *pPrinter); }; uint8_t PrinterOper::OnInit(USBPrinter *pPrinter) { Serial.println(F("USB Printer OnInit")); Serial.print(F("Bidirectional=")); Serial.println(pPrinter->isBidirectional()); return 0; } USBHost myusb; PrinterOper AsyncOper; USBPrinter uprinter(&myusb, &AsyncOper); ESC_POS_Printer printer(&uprinter); // ----------------------------------------------------------------------- void setup() { Serial.begin(115200); while (!Serial && millis() < 3000) delay(1); Serial.println(F("Character set demo")); } // Print charset map to printer void dump() { uint8_t major, minor, c; printer.println(F(" 01234567 89ABCDEF")); for(major=0; major<16; major++) { printer.print(F(" ")); printer.print(major, HEX); printer.print(F("- ")); for(minor=0; minor<16; minor++) { c = (major << 4) | minor; if(c < 32) c = ' '; // Skip control codes! printer.write(c); if(minor == 7) printer.print(F(" ")); } printer.println(); } } void print_character_set() { printer.underlineOn(); printer.println(F("Character set demo\n")); printer.underlineOff(); printer.println(F("Default")); printer.setCharset(0); printer.setCodePage(0); dump(); printer.println(F("\nFrench char set with")); printer.println(F("Multilingual CP850 code page")); // Charset selection alters a few chars in ASCII 0x23-0x7E range. printer.setCharset(CHARSET_FRANCE); // Code page selects alt symbols for 'upper' ASCII 0x80-0xFF. printer.setCodePage(CODEPAGE_CP850); dump(); printer.feed(2); printer.setDefault(); // Restore printer to defaults } void loop() { myusb.Task(); // Make sure USB printer found and ready if (uprinter.isReady()) { printer.begin(); Serial.println(F("Init ESC POS printer")); print_character_set(); // Do this one time to avoid wasting paper while (1) delay(1); } }
6faf68ca1aeedfe57ef226b324b6ba48fc0c21fb
14d143bdce06a43565034aa6e6cf072ee6648f31
/include/orwell/proxy/SimpleTeam.hpp
e77c91d4c421778817a610ddc5ecbf48e53c6fde
[ "BSD-3-Clause" ]
permissive
orwell-int/server-game
599a5c86330947ba830efe33bec5489f81b28c25
d3c410ff734a6f32de0303b25d816ae392df8a18
refs/heads/master
2021-01-18T22:44:47.807869
2020-11-16T13:00:31
2020-11-16T13:00:31
9,554,529
0
2
BSD-3-Clause
2020-11-16T13:00:32
2013-04-19T21:01:01
C++
UTF-8
C++
false
false
444
hpp
#pragma once #include <memory> #include <string> #include <vector> #include <nlohmann/json_fwd.hpp> namespace orwell { namespace game { class Team; } namespace proxy { struct SimpleTeam { SimpleTeam(game::Team const & iTeam); SimpleTeam(SimpleTeam const & iOther); std::string const m_name; uint32_t const m_score; std::vector< std::string > const m_robots; }; void to_json(nlohmann::json & oJson, SimpleTeam const & iTeam); } }
e41ab484fe8f8aa1953fd6c598bff43dcd510596
70441dcb7a8917a5574dd74c5afdeeaed3672a7a
/AtCoder Beginner Contest 161/D - Lunlun Number/main.cpp
54aa3c04c2882a7ee90d0491604ca2470406434d
[]
no_license
tmyksj/atcoder
f12ecf6255b668792d83621369194195f06c10f6
419165e85d8a9a0614e5544232da371d8a2f2f85
refs/heads/master
2023-03-05T12:14:14.945257
2023-02-26T10:10:20
2023-02-26T10:10:20
195,034,198
0
0
null
null
null
null
UTF-8
C++
false
false
834
cpp
#include <algorithm> #include <iostream> #include <set> using namespace std; int main() { int k; cin >> k; set<long long> cur; for (int i = 1; i <= 9; i++) { cur.insert(i); } set<long long> s; while (static_cast<int>(s.size()) < k) { for (set<long long>::iterator j = cur.begin(); j != cur.end(); j++) { s.insert(*j); } set<long long> next; for (set<long long>::iterator j = cur.begin(); j != cur.end(); j++) { next.insert(10 * *j + max((*j % 10) - 1, 0LL)); next.insert(10 * *j + (*j % 10)); next.insert(10 * *j + min((*j % 10) + 1, 9LL)); } cur = next; } set<long long>::iterator res = s.begin(); for (int i = 0; i < k - 1; i++) { res++; } cout << *res << endl; }
ee000adcae59a066742ef168b15e402d1a0254f8
ee7c00a7a90e89e2984a6c922a8704390e680c06
/cs103_hws/PA/PA5/network1_redo/user.cpp
3cd3779f3b5c7a8772481114b49c83e4674144a2
[]
no_license
summerys/cs103
8630506e77f8b878f57b5c9bfdd0e4c2d0551d9e
2b16fe82c5cb0140f2db675fb63a67b91c6693d5
refs/heads/master
2021-01-12T08:46:01.770785
2016-12-21T03:28:06
2016-12-21T03:28:06
76,682,366
0
0
null
null
null
null
UTF-8
C++
false
false
869
cpp
#include "user.h" #include <string> using namespace std; User::User(string name_full, int id_num, int year_born, int zipcode){ name = name_full; id = id_num; year = year_born; zip = zipcode; } User::~User(){}; void User::add_friend(int other_user){ for (int i = 0; i < friends.size(); ++i){ if (friends[i] == other_user) { return; } }//for friends.push_back(other_user); }//add_friend void User::delete_friend(int other_user_d){ for(int i=0; i < friends.size(); i++){ if(friends[i] == other_user_d){ friends.erase ( friends.begin() + i ); }//if }//for }//void int User::id_num(){ return id; } string User::name_full(){ return name; } int User::year_born(){ return year;; } int User::zipcode(){ return zip; } //accessor vector<int> User::getFriends(){ return friends; }
50b596d4d47010c4c5b5d1ee29e273ac47faf9b3
ed1624411040501c67c2f6c5c626348d9806d968
/Ocean/network/server.h
f364b76665ff1e021a7ca2b5a544c010a8671d5e
[]
no_license
bogdyname/Ocean
a1e7364d2142dfac8907aac9319a6133305ad279
ca8cba4c1472ca46945a9dda4550f39065551b3e
refs/heads/master
2023-02-06T13:45:13.806885
2020-10-25T18:14:57
2020-10-25T18:14:57
174,801,662
0
0
null
2020-12-14T19:25:17
2019-03-10T09:18:34
C++
UTF-8
C++
false
false
677
h
/* ***Copyleft (C) 2020 Softwater, Inc ***Contact: [email protected] ***Contact: [email protected] ***Created by bogdyname */ #ifndef SERVER_H #define SERVER_H #include <QTcpServer> #include <QTcpSocket> #include <QByteArray> #include <QDataStream> class Server : public QTcpServer { Q_OBJECT Q_CLASSINFO("Version", "0.5") public: explicit Server(QObject *parent = nullptr); ~Server(); /* 1) Read client data 2) Send response to client about receiving */ private slots: void Receiver(); void Sender(); private: qint64 nextBlockSize; QTcpServer *server = nullptr; QTcpSocket *socket = nullptr; }; #endif
a1a9d822c2575811f5e9e25eb492c9194cb1a987
a4ebc4a5f5d25480b875bba7e288bda9686ee0e3
/WorldMT/main.cpp
fb23afe815d6791fd0fa5fd501d3b03164d0def9
[]
no_license
shikazu/AthenaMT
e82f6860b8e002e581a4fe46f1b412e366a6e867
b04c97afe2267c27e99fe2f2ffc284f81773ad61
refs/heads/master
2021-01-10T04:18:35.534972
2015-10-28T11:03:11
2015-10-28T11:03:11
44,395,864
6
0
null
null
null
null
UTF-8
C++
false
false
223
cpp
#include <iostream> #include <thread> #include "World\WorldMain.h" int main(int argc, char **argv) { World::WorldMain world_main; while (true) { std::this_thread::sleep_for(std::chrono::seconds(1)); } return 0; }
4c2fcdeb53c97a09f5d903151180a82fd9592574
95e7e2c5fab1fb70729f98ecc3def2134c2d3e38
/src/interpreter/visitor/expr/BooleanExprVisitor.cpp
97a6407d56fa19c2a580436d12f24989025a96be
[ "MIT" ]
permissive
CrackerCat/kaprino
f9f697c7cfda148b2f840a311fab3b5f3529aea9
06dcf193a6d3b496708775b763b8684612851556
refs/heads/master
2022-09-27T11:53:56.788665
2020-06-08T00:59:29
2020-06-08T00:59:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
865
cpp
#include <stdlib.h> #include "../../../parser/KaprinoParserBaseVisitor.h" #include "../../abstructs/ExprObject.h" #include "../../KaprinoAccelerator.h" #include "../../StatementVisitor.h" class BooleanExprObject : ExprObject { public: bool value; virtual llvm::Value* codegen(llvm::IRBuilder<>* builder, llvm::Module* module) override { auto boolVal = llvm::ConstantInt::get(KAPRINO_BOOL_TY(module), value); return boolVal; } }; antlrcpp::Any StatementVisitor::visitBooleanExpr(KaprinoParser::BooleanExprContext* ctx) { auto exprObj = new BooleanExprObject(); auto boolean = ctx->getText(); std::transform(boolean.begin(), boolean.end(), boolean.begin(), (int (*)(int))std::tolower); exprObj->value = boolean == "true"; KAPRINO_LOG("Static value ditected: " << boolean); return (ExprObject*)exprObj; }
14b37f3398520580ea80bf0fb8ee0e3d84b39168
63a22dd17235ee7a5289665cf3678c5f53492f68
/ServerCore/ServerLibrary/Net/Packet/PacketFactory.h
ac04ca8ae9176f4e2602599eaf0c64252a59ff3e
[]
no_license
githubzon/RoseServer
00df2d0f3a5d1c332b5e957d51ce0afd9ea3bfe7
6c0d2d54de7607d8cc822cac5e0e4d0009170a9a
refs/heads/master
2021-01-16T23:21:49.677968
2017-06-17T11:26:44
2017-06-17T11:26:44
95,739,207
1
0
null
2017-06-29T04:41:32
2017-06-29T04:41:32
null
UTF-8
C++
false
false
1,467
h
#pragma once #include "stdafx.h" #include "packetHeader.h" #include "packetClass.h" class PacketFactory : public Singleton<PacketFactory> { public: Packet* getPacket(Int64 packetType) { switch (packetType) { case E_C_REQ_EXIT: return new PK_C_REQ_EXIT(); case E_S_ANS_EXIT: return new PK_S_ANS_EXIT(); case E_I_NOTIFY_TERMINAL: return new PK_I_NOTIFY_TERMINAL(); case E_C_NOTIFY_HEARTBEAT: return new PK_C_NOTIFY_HEARTBEAT(); case E_C_REQ_ID_PW: return new PK_C_REQ_ID_PW(); case E_S_ANS_ID_PW_FAIL: return new PK_S_ANS_ID_PW_FAIL(); case E_S_ANS_ID_PW_SUCCESS: return new PK_S_ANS_ID_PW_SUCCESS(); case E_I_DB_REQ_ID_PW: return new PK_I_DB_REQ_ID_PW(); case E_I_DB_ANS_ID_PW: return new PK_I_DB_ANS_ID_PW(); case E_I_CHTTING_NOTIFY_ID: return new PK_I_CHTTING_NOTIFY_ID(); case E_I_DB_REQ_LOAD_DATA: return new PK_I_DB_REQ_LOAD_DATA(); case E_I_DB_ANS_PARSE_DATA: return new PK_I_DB_ANS_PARSE_DATA(); case E_I_LOGIN_NOTIFY_ID_LOADED: return new PK_I_LOGIN_NOTIFY_ID_LOADED(); case E_C_REQ_REGIST_CHATTING_NAME: return new PK_C_REQ_REGIST_CHATTING_NAME(); case E_C_REQ_CHATTING: return new PK_C_REQ_CHATTING(); case E_S_ANS_CHATTING: return new PK_S_ANS_CHATTING(); } return nullptr; } };
36bf98ae9b02ba605dc64c6e4f89d4686a39185e
c7d2b58db791dc900250a613b1d93dd84c9cd87b
/PopcornTorrent/Source/torrent/crc32c.cpp
9c558b0fb996dfabe37d08fc57ac89e49a6d9f77
[ "MIT" ]
permissive
tommy071/PopcornTorrent
3f0e4232a9b28cfc39b790129467f6b7b5c2feea
88a1a4371d58e9d81839754d2eae079197dee5c5
refs/heads/master
2020-07-30T03:36:05.567943
2020-02-07T09:30:55
2020-02-07T09:30:55
238,165,009
0
0
MIT
2020-02-04T09:10:23
2020-02-04T09:10:22
null
UTF-8
C++
false
false
4,479
cpp
/* Copyright (c) 2014-2018, Arvid Norberg All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libtorrent/config.hpp" #include "libtorrent/crc32c.hpp" #include "libtorrent/aux_/cpuid.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" #include <boost/crc.hpp> #if (defined _MSC_VER && _MSC_VER >= 1600 && (defined _M_IX86 || defined _M_X64)) #include <nmmintrin.h> #endif #include "libtorrent/aux_/disable_warnings_pop.hpp" #if TORRENT_HAS_ARM_CRC32 #include <arm_acle.h> #endif namespace libtorrent { std::uint32_t crc32c_32(std::uint32_t v) { #if TORRENT_HAS_SSE if (aux::sse42_support) { std::uint32_t ret = 0xffffffff; #ifdef __GNUC__ // we can't use these because then we'd have to tell // -msse4.2 to gcc on the command line // return __builtin_ia32_crc32si(ret, v) ^ 0xffffffff; asm ("crc32l\t" "(%1), %0" : "=r"(ret) : "r"(&v), "0"(ret)); return ret ^ 0xffffffff; #else return _mm_crc32_u32(ret, v) ^ 0xffffffff; #endif } #endif #if TORRENT_HAS_ARM_CRC32 if (aux::arm_crc32c_support) { std::uint32_t ret = 0xffffffff; return __crc32cw(ret, v) ^ 0xffffffff; } #endif boost::crc_optimal<32, 0x1EDC6F41, 0xFFFFFFFF, 0xFFFFFFFF, true, true> crc; crc.process_bytes(&v, 4); return crc.checksum(); } std::uint32_t crc32c(std::uint64_t const* buf, int num_words) { #if TORRENT_HAS_SSE if (aux::sse42_support) { #if defined _M_AMD64 || defined __x86_64__ \ || defined __x86_64 || defined _M_X64 || defined __amd64__ std::uint64_t ret = 0xffffffff; for (int i = 0; i < num_words; ++i) { #ifdef __GNUC__ // we can't use these because then we'd have to tell // -msse4.2 to gcc on the command line // ret = __builtin_ia32_crc32di(ret, buf[i]); __asm__("crc32q\t" "(%1), %0" : "=r"(ret) : "r"(buf+i), "0"(ret)); #else ret = _mm_crc32_u64(ret, buf[i]); #endif } return std::uint32_t(ret) ^ 0xffffffff; #else std::uint32_t ret = 0xffffffff; std::uint32_t const* buf0 = reinterpret_cast<std::uint32_t const*>(buf); for (int i = 0; i < num_words; ++i) { #ifdef __GNUC__ // we can't use these because then we'd have to tell // -msse4.2 to gcc on the command line // ret = __builtin_ia32_crc32si(ret, buf0[i*2]); // ret = __builtin_ia32_crc32si(ret, buf0[i*2+1]); asm ("crc32l\t" "(%1), %0" : "=r"(ret) : "r"(buf0+i*2), "0"(ret)); asm ("crc32l\t" "(%1), %0" : "=r"(ret) : "r"(buf0+i*2+1), "0"(ret)); #else ret = _mm_crc32_u32(ret, buf0[i*2]); ret = _mm_crc32_u32(ret, buf0[i*2+1]); #endif } return ret ^ 0xffffffff; #endif // amd64 or x86 } #endif // x86 or amd64 and gcc or msvc #if TORRENT_HAS_ARM_CRC32 if (aux::arm_crc32c_support) { std::uint32_t ret = 0xffffffff; for (int i = 0; i < num_words; ++i) { ret = __crc32cd(ret, buf[i]); } return ret ^ 0xffffffff; } #endif boost::crc_optimal<32, 0x1EDC6F41, 0xFFFFFFFF, 0xFFFFFFFF, true, true> crc; crc.process_bytes(buf, std::size_t(num_words) * 8); return crc.checksum(); } }
f7e67f2e788acef2f14a20c8c500f978583069ae
af8ed09e1e0186a09c0328b8cb2b1f0a04d488d5
/wav_recorder.h
24b7cab2f614a50e1022280877c2aaecb3a1d143
[]
no_license
FeZar97/DK
b5c5b325881f13c3ad55f6a709fdd54b88413d9b
52708c6fb80a8b4dd61f4002611c133c137e0dcf
refs/heads/master
2020-04-01T18:18:35.750852
2019-07-28T23:11:40
2019-07-28T23:11:40
153,484,100
2
1
null
null
null
null
UTF-8
C++
false
false
1,331
h
/* This file is part of DigitalKalmar(Кальмар-SDR) DigitalKalmar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. DigitalKalmar 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 DigitalKalmar. If not, see <https://www.gnu.org/licenses/>. */ #ifndef WAV_RECORDER_H #define WAV_RECORDER_H #include <definitions.h> class WAV_RECORDER : public QObject { Q_OBJECT public: WAV_params *params; WAV_RECORDER(); ~WAV_RECORDER(); void prepair_memory(size_t cell_size); void make_wav_header(int sample_rate, int channel_number); bool open_file(); void close_file(int sample_rate, int chan_num); QString size_to_str(); public slots: void get_write_step_32f(Ipp32f *cell, int cell_size); void get_write_step_16s(Ipp16s *cell, int cell_size); signals: void update_size_label(); }; #endif // WAV_RECORDER_H
d76eef8a29762e993b9c7c3146e4424e74d5473e
a33aac97878b2cb15677be26e308cbc46e2862d2
/program_data/PKU_raw/84/1170.c
1d0ecc79aaf109cb5c875fb1d566dbf8bb8d61dc
[]
no_license
GabeOchieng/ggnn.tensorflow
f5d7d0bca52258336fc12c9de6ae38223f28f786
7c62c0e8427bea6c8bec2cebf157b6f1ea70a213
refs/heads/master
2022-05-30T11:17:42.278048
2020-05-02T11:33:31
2020-05-02T11:33:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
276
c
int main() { int n,i,a,max=0,max2=0; scanf("%d",&n); scanf("%d",&a); max=a,max2=a; for(i=2;i<=n;i++) { scanf("%d",&a); if(a>max) { max=a; } else { if(a>max2) { max2=a; } } } printf("%d\n%d",max,max2); return 0; }
03f86b0c1bd02799b8f29207e99bd3cd8ddf3d99
85b690ce5b5952b6d886946e0bae43b975004a11
/Application/Input/openfoam-org/processor1/0.75/k
832730ed5b0151cd14532c068fbcf97a582bdc1b
[]
no_license
pace-gt/PACE-ProvBench
c89820cf160c0577e05447d553a70b0e90d54d45
4c55dda0e9edb4a381712a50656855732af3e51a
refs/heads/master
2023-03-12T06:56:30.228126
2021-02-25T22:49:07
2021-02-25T22:49:07
257,307,245
1
0
null
null
null
null
UTF-8
C++
false
false
20,014
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 5.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.75"; object k; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField nonuniform List<scalar> 1915 ( 0.0103557 0.00632709 0.0216763 0.0112849 0.0300745 0.0151149 0.0379233 0.0186765 0.045495 0.0221578 0.0530902 0.0258093 0.0612001 0.0301585 0.0708027 0.0361357 0.0831663 0.0465169 0.0995633 0.0694583 0.211428 0.356731 0.41958 0.438639 0.417181 0.369517 0.317492 0.27603 0.24728 0.228002 0.215589 0.208046 0.204055 0.202742 0.203518 0.205813 0.209366 0.214176 0.220306 0.227834 0.236926 0.246429 0.254912 0.261076 0.263392 0.260784 0.253197 0.241492 0.22694 0.210798 0.194072 0.17743 0.161202 0.145426 0.129872 0.113976 0.0962727 0.0748654 0.0492487 0.0297688 0.516816 0.897343 1.07553 1.19951 1.20759 1.09146 0.90779 0.730031 0.594242 0.503379 0.446494 0.412466 0.393629 0.384789 0.382252 0.383621 0.387531 0.393485 0.401411 0.411314 0.422672 0.435062 0.448787 0.46212 0.471456 0.473059 0.465315 0.44902 0.426249 0.399318 0.370209 0.340317 0.310404 0.280661 0.250753 0.219739 0.185819 0.145895 0.097219 0.0390926 0.691262 1.31029 1.74377 2.12531 2.30593 2.20342 1.86383 1.44576 1.08577 0.8352 0.680457 0.589174 0.537175 0.510282 0.499353 0.49729 0.499374 0.503164 0.508014 0.51377 0.520197 0.52829 0.539151 0.551868 0.562259 0.564988 0.557137 0.539043 0.512858 0.481198 0.446412 0.410207 0.373548 0.336747 0.299579 0.261265 0.220274 0.174129 0.119713 0.043787 0.750019 1.56373 2.34022 3.21141 3.87787 4.05302 3.64304 2.86366 2.03581 1.4124 1.03042 0.814176 0.691827 0.62587 0.596424 0.586249 0.584585 0.585654 0.586539 0.586901 0.587041 0.588206 0.593301 0.602454 0.61148 0.614031 0.60608 0.587372 0.559837 0.526069 0.488539 0.449114 0.408866 0.368198 0.327054 0.28498 0.240919 0.192679 0.135438 0.0511079 0.700055 1.54016 2.2403 3.28272 4.11451 4.79307 5.09164 4.60925 3.4146 2.2524 1.49843 1.08965 0.872603 0.751369 0.692103 0.668811 0.661356 0.658619 0.653577 0.648923 0.64175 0.633115 0.630537 0.634503 0.640525 0.641703 0.633238 0.614268 0.586359 0.551884 0.513297 0.472536 0.430697 0.388188 0.345051 0.301105 0.255755 0.20718 0.149419 0.0586114 0.64177 1.47557 1.99806 2.35284 2.66428 3.27069 3.87595 4.2404 3.87219 2.73758 1.77812 1.24126 0.967862 0.828194 0.755326 0.723668 0.710963 0.708233 0.708557 0.708706 0.692858 0.668812 0.65757 0.655912 0.658128 0.657131 0.647786 0.628663 0.600894 0.566527 0.52793 0.48708 0.445024 0.40206 0.358198 0.313335 0.267072 0.21794 0.159835 0.0644549 0.589793 1.45743 1.48004 1.36247 1.55618 2.13101 2.84058 3.41797 3.60491 2.95283 1.92639 1.29895 0.977147 0.822837 0.752944 0.723608 0.712389 0.711265 0.71765 0.722734 0.714964 0.693677 0.677649 0.671476 0.669604 0.665913 0.655421 0.63614 0.608736 0.574869 0.536823 0.496615 0.45519 0.412645 0.368848 0.323618 0.276462 0.225845 0.166172 0.068227 0.518247 1.26888 1.02119 0.904895 1.04115 1.50529 2.18515 2.81628 3.19494 2.89433 1.9874 1.32139 0.969118 0.800902 0.726934 0.698464 0.690795 0.691902 0.696498 0.700792 0.703181 0.700809 0.692953 0.684728 0.679017 0.672304 0.660387 0.640814 0.613733 0.580417 0.543091 0.503814 0.463395 0.421684 0.378374 0.333176 0.28543 0.233197 0.170434 0.0716986 0.410701 0.770002 0.645292 0.66547 0.834434 1.21448 1.80715 2.42586 2.85212 2.702 1.94749 1.31196 0.952409 0.776393 0.698832 0.670413 0.665422 0.670347 0.67917 0.689265 0.699255 0.708335 0.709308 0.698412 0.689181 0.679543 0.666007 0.645889 0.618852 0.585871 0.549148 0.510732 0.47126 0.430362 0.387601 0.342621 0.294681 0.241645 0.176944 0.0760098 0.268957 0.409231 0.465767 0.607675 0.804608 1.11584 1.61795 2.17751 2.5677 2.46461 1.84569 1.27449 0.926806 0.750756 0.67248 0.64517 0.643307 0.653071 0.667827 0.684964 0.702986 0.721948 0.727611 0.713189 0.701457 0.689696 0.674673 0.653755 0.626333 0.593305 0.556878 0.51896 0.47999 0.439491 0.397001 0.352118 0.304068 0.250715 0.185315 0.0806179 0.118308 0.110038 0.135843 0.13676 0.151931 0.157327 0.167169 0.175666 0.182326 0.193768 0.198095 0.212773 0.214838 0.23297 0.232689 0.254176 0.251576 0.275977 0.271228 0.297828 0.319269 0.340139 0.360489 0.380324 0.399431 0.417472 0.434313 0.450274 0.46411 0.47108 0.468526 0.462006 0.453804 0.445718 0.439673 0.436758 0.437579 0.442307 0.450774 0.462529 0.476882 0.492977 0.509867 0.078188 0.074275 0.0778668 0.0955165 0.138338 0.146963 0.165219 0.201498 0.167207 0.184351 0.214153 0.264027 0.190375 0.214944 0.255573 0.317421 0.213261 0.245193 0.295917 0.366918 0.237445 0.276991 0.336531 0.414272 0.263127 0.31035 0.378583 0.463446 0.289611 0.344024 0.420272 0.511185 0.315967 0.376679 0.459371 0.5551 0.341106 0.406244 0.493153 0.592751 0.36426 0.431241 0.520695 0.622628 0.385358 0.452181 0.542437 0.644779 0.404455 0.469332 0.558706 0.660716 0.421456 0.482312 0.569361 0.67062 0.436589 0.491654 0.573862 0.67196 0.449857 0.497308 0.56841 0.662931 0.462019 0.501918 0.560333 0.645275 0.473722 0.506972 0.553767 0.61935 0.485294 0.513349 0.551279 0.601242 0.497814 0.521977 0.553535 0.593266 0.505722 0.53317 0.560523 0.594032 0.504048 0.541226 0.571504 0.601854 0.497679 0.540238 0.580283 0.614333 0.489514 0.534563 0.580093 0.624262 0.482488 0.527711 0.575662 0.625064 0.478668 0.523479 0.572042 0.623691 0.479155 0.523848 0.572778 0.625708 0.484284 0.529563 0.579384 0.633736 0.493865 0.540466 0.591901 0.648268 0.507319 0.55583 0.609459 0.668349 0.523763 0.574543 0.63067 0.692275 0.542118 0.595267 0.653894 0.71807 0.561215 0.616592 0.677458 0.743785 0.207081 0.329582 0.477024 0.691649 0.878488 1.1203 1.53918 2.01357 2.31979 2.2212 1.71912 1.21689 0.893077 0.723742 0.647929 0.623098 0.624982 0.639911 0.660596 0.683994 0.70864 0.735297 0.743068 0.728314 0.716456 0.703989 0.687935 0.666064 0.637836 0.604345 0.567734 0.529648 0.490402 0.449616 0.406898 0.361746 0.31333 0.259559 0.193531 0.0849362 0.266347 0.384464 0.577153 0.80264 0.954661 1.16907 1.52915 1.88753 2.09137 1.99542 1.58166 1.14696 0.853489 0.695845 0.625248 0.604134 0.61017 0.630131 0.656328 0.685047 0.714814 0.74587 0.75467 0.744548 0.735074 0.723263 0.706701 0.683816 0.654449 0.620039 0.582601 0.543425 0.502894 0.461042 0.417521 0.371637 0.322437 0.267925 0.201151 0.0886923 0.339439 0.458457 0.660907 0.851634 1.02396 1.22352 1.50358 1.76287 1.88458 1.78939 1.44429 1.07206 0.810968 0.66816 0.605018 0.588755 0.59933 0.624238 0.655659 0.689293 0.723584 0.755527 0.766228 0.76388 0.758194 0.747757 0.730983 0.707017 0.6762 0.640272 0.601252 0.560087 0.51743 0.473822 0.428958 0.381905 0.331498 0.275807 0.20796 0.091766 0.400958 0.521825 0.707847 0.914312 1.0995 1.26442 1.44454 1.62762 1.69613 1.6032 1.3146 0.997528 0.768023 0.641828 0.587995 0.577737 0.593438 0.623529 0.660272 0.698949 0.737473 0.768967 0.783585 0.788368 0.786465 0.777379 0.760324 0.73506 0.702419 0.664436 0.623045 0.579202 0.533947 0.488049 0.441352 0.392788 0.340874 0.283533 0.213932 0.0941611 0.4569 0.584161 0.76287 0.974412 1.15082 1.26858 1.37713 1.48955 1.52649 1.43802 1.19562 0.925517 0.726084 0.617797 0.574908 0.571888 0.593547 0.629375 0.671846 0.715859 0.757923 0.790255 0.809327 0.819105 0.82 0.811698 0.793983 0.767083 0.732268 0.691855 0.647578 0.6007 0.552467 0.50379 0.45484 0.404609 0.351161 0.291793 0.21929 0.0960331 0.511703 0.645764 0.822041 1.0155 1.15872 1.23707 1.29802 1.35902 1.37523 1.29086 1.08462 0.854346 0.684322 0.596329 0.566158 0.571757 0.600401 0.642698 0.691371 0.74091 0.786048 0.820104 0.84303 0.855939 0.858354 0.850039 0.831132 0.802226 0.765043 0.721967 0.674653 0.624546 0.573 0.521129 0.469547 0.41776 0.363267 0.301817 0.224998 0.0979138 0.568269 0.708594 0.871976 1.03216 1.13459 1.17741 1.20599 1.23664 1.23778 1.15588 0.977566 0.78001 0.641511 0.577373 0.56196 0.577593 0.614349 0.663869 0.71908 0.774009 0.821892 0.857865 0.883483 0.898002 0.90072 0.891582 0.870957 0.839742 0.800125 0.754305 0.703926 0.650511 0.595519 0.540217 0.485619 0.432244 0.377946 0.315306 0.23339 0.100956 0.624067 0.765242 0.905488 1.02395 1.08638 1.10152 1.10955 1.12149 1.10967 1.02684 0.866693 0.70254 0.601438 0.562324 0.562534 0.589542 0.635479 0.692847 0.754683 0.814098 0.864565 0.902372 0.929323 0.94417 0.946159 0.935479 0.912671 0.879017 0.836927 0.788371 0.734961 0.678304 0.619938 0.5612 0.503266 0.447311 0.393413 0.332713 0.247174 0.106489 0.675022 0.810307 0.919704 0.99417 1.02185 1.01842 1.01477 1.01398 0.990098 0.900398 0.754753 0.631952 0.568779 0.552867 0.56859 0.607973 0.663822 0.729331 0.797598 0.860724 0.913182 0.952027 0.979216 0.993306 0.993745 0.980941 0.955589 0.91948 0.874909 0.823644 0.767307 0.707584 0.646046 0.584011 0.522569 0.462727 0.405374 0.347685 0.262274 0.115206 0.717372 0.841554 0.917662 0.950847 0.950095 0.935379 0.925225 0.9145 0.878003 0.782958 0.659729 0.575741 0.545101 0.55008 0.581402 0.633507 0.699414 0.772841 0.846867 0.913245 0.966467 1.0054 1.03193 1.0444 1.04264 1.02726 0.999189 0.9606 0.913533 0.859609 0.800503 0.737965 0.673548 0.608443 0.54349 0.479184 0.415578 0.351484 0.275022 0.123374 0.748423 0.859158 0.902897 0.901637 0.880401 0.858673 0.844477 0.825765 0.777561 0.683174 0.587692 0.53565 0.531046 0.555649 0.602386 0.666782 0.742216 0.822743 0.901246 0.970815 1.02315 1.06136 1.0864 1.09658 1.09211 1.07378 1.04297 1.00186 0.952266 0.895755 0.834076 0.769049 0.702144 0.634325 0.566093 0.497482 0.427912 0.356119 0.280317 0.128887 0.766585 0.860334 0.877136 0.854191 0.821035 0.793789 0.776541 0.752172 0.694745 0.607452 0.538664 0.512948 0.528884 0.571357 0.632618 0.708182 0.792057 0.878403 0.959745 1.03095 1.08135 1.11882 1.14171 1.14911 1.14157 1.12005 1.08642 1.0427 0.990573 0.931565 0.867548 0.800441 0.731557 0.661523 0.590449 0.518005 0.443256 0.363733 0.271292 0.121857 0.773107 0.84782 0.850041 0.817546 0.776473 0.744021 0.723911 0.695803 0.631516 0.557465 0.512259 0.508535 0.541614 0.599068 0.672668 0.757645 0.848495 0.939378 1.02299 1.09315 1.14128 1.17692 1.19711 1.20139 1.19046 1.16559 1.12901 1.08257 1.02793 0.96657 0.90048 0.831795 0.761562 0.689925 0.616521 0.540715 0.46157 0.376272 0.275558 0.122401 0.770888 0.83715 0.834077 0.79601 0.749064 0.71243 0.689712 0.657325 0.589931 0.531709 0.507876 0.522663 0.569682 0.638593 0.721904 0.814395 0.910623 1.00495 1.09122 1.15617 1.20209 1.23502 1.25199 1.25283 1.23816 1.20989 1.17018 1.12089 1.06384 1.00037 0.932513 0.862871 0.792041 0.71952 0.644287 0.565343 0.482194 0.392582 0.287471 0.127502 0.763621 0.834788 0.831772 0.791095 0.740227 0.699928 0.674775 0.634797 0.571711 0.53013 0.52393 0.553339 0.611353 0.689061 0.779512 0.877294 0.976936 1.0736 1.1587 1.21703 1.26228 1.29233 1.30575 1.3028 1.28424 1.25239 1.20932 1.1571 1.09769 1.03225 0.963289 0.893525 0.822995 0.750481 0.673927 0.591637 0.504151 0.410403 0.3015 0.135492 0.752384 0.831739 0.840168 0.801082 0.749182 0.705383 0.672503 0.624383 0.574581 0.54886 0.557397 0.598461 0.664871 0.74865 0.843654 0.944717 1.0469 1.14552 1.22446 1.27884 1.32164 1.34829 1.35795 1.35079 1.32821 1.29254 1.24589 1.19065 1.12871 1.0616 0.992521 0.923466 0.854302 0.783105 0.706044 0.61963 0.526656 0.428073 0.314566 0.143114 0.737517 0.813676 0.847674 0.820246 0.771684 0.724545 0.676573 0.626986 0.592469 0.583287 0.605363 0.655943 0.727922 0.81489 0.91214 1.01523 1.12112 1.21791 1.28518 1.33935 1.37943 1.40244 1.40807 1.39648 1.36959 1.32975 1.27938 1.22111 1.15691 1.0886 1.01963 0.951958 0.885443 0.817616 0.741956 0.649544 0.549048 0.444695 0.326122 0.14936 0.710121 0.790409 0.834791 0.832333 0.793738 0.742368 0.68716 0.645671 0.626006 0.632234 0.666105 0.723233 0.797705 0.885332 0.982785 1.08684 1.19498 1.28419 1.34573 1.39819 1.43527 1.45463 1.45581 1.43954 1.40799 1.36365 1.30931 1.24791 1.18174 1.11242 1.04379 0.978102 0.915727 0.854218 0.783875 0.680201 0.570097 0.459273 0.335487 0.15409 0.66856 0.754735 0.819432 0.82987 0.802251 0.755038 0.710642 0.683096 0.677064 0.695252 0.737019 0.797349 0.872078 0.958678 1.0553 1.16152 1.26654 1.34087 1.40402 1.455 1.48914 1.50475 1.50111 1.47973 1.44314 1.39404 1.33557 1.27073 1.20211 1.13188 1.06392 1.00079 0.944185 0.89255 0.826671 0.708643 0.587886 0.470826 0.342448 0.157638 0.643611 0.70673 0.776457 0.817854 0.814146 0.782298 0.753636 0.738869 0.743057 0.768844 0.814674 0.875767 0.949612 1.03447 1.12938 1.23429 1.32904 1.39877 1.46142 1.51035 1.54157 1.55293 1.54395 1.51698 1.4749 1.4208 1.35802 1.28956 1.21804 1.14652 1.0791 1.01891 0.96952 0.92916 0.840651 0.730668 0.600872 0.479261 0.347838 0.160674 0.634797 0.682704 0.732225 0.776314 0.798931 0.802003 0.799923 0.801973 0.816468 0.847258 0.894606 0.95509 1.02813 1.11187 1.20592 1.30348 1.38406 1.45682 1.51871 1.56522 1.59332 1.5995 1.58432 1.55116 1.50315 1.44379 1.37655 1.30438 1.22964 1.15601 1.0883 1.02991 0.980598 0.923996 0.827732 0.737628 0.60767 0.485313 0.352772 0.163786 0.637957 0.679104 0.720308 0.757533 0.786316 0.809844 0.829948 0.85058 0.879771 0.920177 0.971466 1.03315 1.10607 1.18841 1.27704 1.36435 1.44571 1.51813 1.57761 1.62084 1.64494 1.6447 1.62242 1.58218 1.52765 1.4627 1.39097 1.31533 1.23723 1.16017 1.08924 1.0254 0.961751 0.888811 0.808506 0.725872 0.609561 0.490281 0.357645 0.167279 0.649644 0.689056 0.728728 0.766591 0.800682 0.83226 0.863638 0.89798 0.939559 0.990509 1.04645 1.11086 1.1842 1.26524 1.35083 1.43573 1.51497 1.58426 1.63974 1.67828 1.69699 1.68884 1.65832 1.60986 1.548 1.47699 1.40072 1.32154 1.23941 1.15741 1.0802 1.00835 0.936858 0.861571 0.786497 0.709677 0.608539 0.495283 0.363215 0.171558 0.665304 0.708327 0.749534 0.790962 0.831214 0.871002 0.91197 0.955979 1.00553 1.06175 1.12407 1.19333 1.26946 1.35083 1.4345 1.51633 1.59176 1.65642 1.70643 1.73799 1.74803 1.73298 1.69223 1.63375 1.56343 1.48568 1.40436 1.3186 1.22961 1.14318 1.06208 0.985922 0.911609 0.837593 0.766504 0.693753 0.604571 0.499754 0.371305 0.177232 0.676243 0.727431 0.777803 0.824609 0.871599 0.919673 0.969259 1.02196 1.07944 1.14246 1.21103 1.28508 1.36378 1.44533 1.52705 1.60555 1.67671 1.73596 1.77906 1.80037 1.79856 1.77535 1.72396 1.65273 1.57267 1.48745 1.39727 1.30053 1.20713 1.11872 1.03631 0.95938 0.885946 0.815476 0.748699 0.681909 0.60257 0.508239 0.385321 0.18511 0.680286 0.740119 0.799599 0.858786 0.918137 0.975075 1.0325 1.09385 1.15986 1.2306 1.30583 1.38503 1.46666 1.54865 1.62858 1.70379 1.77077 1.82439 1.85777 1.86259 1.8485 1.8116 1.74774 1.66349 1.57117 1.47371 1.37063 1.26966 1.17489 1.08682 1.00561 0.930625 0.860556 0.794711 0.732909 0.672193 0.603724 0.521426 0.404092 0.195571 0.685317 0.750965 0.817706 0.884695 0.954155 1.0248 1.0954 1.16849 1.24479 1.32448 1.40726 1.49276 1.5784 1.66141 1.73945 1.81057 1.87032 1.91084 1.92343 1.91399 1.88357 1.82846 1.74783 1.64989 1.54169 1.43348 1.32775 1.22788 1.13536 1.05031 0.972586 0.901535 0.836046 0.775161 0.717987 0.662014 0.60127 0.531371 0.408015 0.200363 0.695765 0.76544 0.838329 0.913412 0.990371 1.06834 1.14861 1.23178 1.31755 1.40595 1.49636 1.58736 1.67551 1.75733 1.82913 1.89011 1.93428 1.95331 1.95185 1.92828 1.88103 1.80938 1.71299 1.60131 1.4865 1.3769 1.27418 1.17903 1.09163 1.01182 0.939287 0.873317 0.812817 0.756618 0.703489 0.651228 0.595142 0.52651 0.406341 0.202971 0.713022 0.786483 0.864473 0.94596 1.03 1.11554 1.20248 1.29116 1.38134 1.47256 1.5637 1.65234 1.73459 1.8067 1.86502 1.90912 1.93547 1.9417 1.92768 1.89045 1.8304 1.74797 1.64317 1.52858 1.41606 1.31117 1.2149 1.12685 1.04652 0.973431 0.907067 0.84662 0.790978 0.738919 0.689259 0.640497 0.589123 0.52373 0.403056 0.200707 0.736193 0.813509 0.896067 0.982731 1.07218 1.163 1.25433 1.34556 1.43579 1.52387 1.60851 1.68698 1.75556 1.81221 1.85552 1.88395 1.8954 1.8883 1.86157 1.814 1.74529 1.6556 1.55034 1.44148 1.33729 1.2412 1.15366 1.07423 1.00213 0.936581 0.876802 0.821765 0.770494 0.721793 0.67463 0.628173 0.580092 0.519096 0.396293 0.194154 0.763217 0.844088 0.930452 1.02102 1.11415 1.20804 1.30108 1.39137 1.47762 1.55858 1.63262 1.69724 1.7507 1.79183 1.82008 1.83373 1.83147 1.81166 1.77398 1.71786 1.64243 1.55089 1.45128 1.35141 1.25712 1.17121 1.09364 1.02349 0.959972 0.902058 0.848754 0.798975 0.7515 0.705377 0.65962 0.613606 0.565939 0.506144 0.386982 0.187155 0.791736 0.875434 0.964441 1.0573 1.15214 1.24681 1.33849 1.42514 1.50515 1.57711 1.63935 1.69036 1.72964 1.75654 1.77055 1.77075 1.75599 1.7252 1.67849 1.61539 1.53692 1.44812 1.3558 1.26558 1.18155 1.10558 1.03769 0.976712 0.921435 0.870712 0.823414 0.778415 0.734536 0.690636 0.64598 0.599823 0.551295 0.492733 0.379779 0.186001 0.819519 0.905056 0.995363 1.08882 1.18338 1.27613 1.36421 1.44551 1.51822 1.58069 1.63168 1.67079 1.69759 1.71184 1.71324 1.7015 1.67586 1.63609 1.58261 1.51585 1.43805 1.35389 1.26924 1.18841 1.11414 1.04745 0.98823 0.935513 0.887688 0.84336 0.801395 0.760664 0.720084 0.678618 0.635481 0.590155 0.541435 0.482039 0.384129 0.19292 ) ; boundaryField { leftWall { type kqRWallFunction; value nonuniform 0(); } rightWall { type kqRWallFunction; value nonuniform List<scalar> 43 ( 0.0297688 0.0390926 0.043787 0.0511079 0.0586114 0.0644549 0.068227 0.0716986 0.0760098 0.0806179 0.0849362 0.0886923 0.091766 0.0941611 0.0960331 0.0979138 0.100956 0.106489 0.115206 0.123374 0.128887 0.121857 0.122401 0.127502 0.135492 0.143114 0.14936 0.15409 0.157638 0.160674 0.163786 0.167279 0.171558 0.177232 0.18511 0.195571 0.200363 0.202971 0.200707 0.194154 0.187155 0.186001 0.19292 ) ; } lowerWall { type kqRWallFunction; value nonuniform List<scalar> 66 ( 0.0103557 0.00632709 0.00632709 0.0112849 0.0151149 0.0186765 0.0221578 0.0258093 0.0301585 0.0361357 0.0465169 0.0694583 0.078188 0.074275 0.0778668 0.0955165 0.211428 0.516816 0.691262 0.750019 0.700055 0.64177 0.589793 0.518247 0.410701 0.268957 0.211428 0.356731 0.41958 0.438639 0.417181 0.369517 0.317492 0.27603 0.24728 0.228002 0.215589 0.208046 0.204055 0.202742 0.203518 0.205813 0.209366 0.214176 0.220306 0.227834 0.236926 0.246429 0.254912 0.261076 0.263392 0.260784 0.253197 0.241492 0.22694 0.210798 0.194072 0.17743 0.161202 0.145426 0.129872 0.113976 0.0962727 0.0748654 0.0492487 0.0297688 ) ; } atmosphere { type inletOutlet; inletValue nonuniform 0(); value nonuniform 0(); } defaultFaces { type empty; } procBoundary1to0 { type processor; value nonuniform List<scalar> 44 ( 0.0130339 0.0282347 0.0385723 0.0477944 0.0565887 0.0653398 0.0744607 0.084425 0.0956676 0.108329 0.121887 0.135576 0.148973 0.162142 0.175417 0.189207 0.20388 0.21973 0.236899 0.255283 0.291326 0.291326 0.311732 0.332555 0.354039 0.375576 0.396756 0.416487 0.430189 0.435842 0.432552 0.426464 0.41906 0.411258 0.404582 0.399966 0.398086 0.399317 0.403765 0.411295 0.421559 0.434024 0.448018 0.46279 ) ; } procBoundary1to3 { type processor; value nonuniform List<scalar> 45 ( 0.526587 0.579901 0.637167 0.699809 0.767683 0.844668 0.930957 1.02123 1.11373 1.20605 1.29496 1.37803 1.45304 1.51811 1.57166 1.61293 1.64181 1.65794 1.66121 1.65192 1.63009 1.5956 1.54899 1.49119 1.42354 1.34882 1.27083 1.19404 1.122 1.05658 0.998264 0.946715 0.901035 0.859544 0.820695 0.783327 0.746332 0.708706 0.669565 0.628163 0.584094 0.536405 0.477777 0.377226 0.190981 ) ; } } // ************************************************************************* //
0002e2b03df56b4e01b4444b08719633c0bbbcca
92533544158e118276103d99be5ec1388d12737e
/app/src/main/cpp/context/RenderContext.h
f3b39ef98e96760f89aa1448bc7bdebbc33da645
[ "Apache-2.0" ]
permissive
githubhaohao/OpenGLCamera2
49efaf2dd09853000c11ad2eb20d6a17bf333721
82bea3e6fbce76f597d75a66456bbbda8d1a7191
refs/heads/master
2022-08-03T18:13:39.884775
2022-06-29T10:18:29
2022-06-29T10:18:29
216,771,928
884
195
null
2022-01-24T02:31:50
2019-10-22T09:15:28
C++
UTF-8
C++
false
false
1,990
h
/** * * Created by 公众号:字节流动 on 2021/3/16. * https://github.com/githubhaohao/OpenGLCamera2 * 最新文章首发于公众号:字节流动,有疑问或者技术交流可以添加微信 Byte-Flow ,领取视频教程, 拉你进技术交流群 * * */ #ifndef OPENGLCAMERA2_BYTEFLOWRENDERCONTEXT_H #define OPENGLCAMERA2_BYTEFLOWRENDERCONTEXT_H #include <cstdint> #include <jni.h> #include <ByteFlowRender.h> #include <vec2.hpp> #include "GLExampleBase.h" #define GL_RENDER_TYPE 0 #define CL_RENDER_TYPE 1 #define PARAM_TYPE_SET_SHADER_INDEX 201 #define PARAM_TYPE_SET_EXAMPLE 202 using namespace glm; class ByteFlowRenderContext { public: ByteFlowRenderContext(int renderType); ~ByteFlowRenderContext(); static void CreateRenderContext(JNIEnv *env, jobject instance, jint renderType); static void StoreRenderContext(JNIEnv *env, jobject instance, ByteFlowRenderContext *pContext); static void DeleteRenderContext(JNIEnv *env, jobject instance); static ByteFlowRenderContext* GetRenderContext(JNIEnv *env, jobject instance); int Init(int initType); int UnInit(); void UpdateFrame(int format, uint8_t *pBuffer, int width, int height); void LoadLutImageData(int index, int format, int width, int height, uint8_t *pData); void LoadFragShaderScript(int shaderIndex, char *pShaderStr, int strLen); void SetTransformMatrix(float translateX, float translateY, float scaleX, float scaleY, int degree, int mirror); void SetParamsInt(int paramType, int param); int GetParamsInt(int paramType); void OnSurfaceCreated(); void OnSurfaceChanged(int width, int height); void OnDrawFrame(); private: void CreateExample(int exampleIndex); static jfieldID s_ContextHandle; ByteFlowRender *m_pByteFlowRender; GLExampleBase *m_pCurGlFilter; GLExampleBase *m_pBeforeGlFilter; volatile bool m_bIsExampleMode; vec2 m_ViewPort; TransformMatrix m_TransformMatrix; }; #endif //OPENGLCAMERA2_BYTEFLOWRENDERCONTEXT_H