hexsha stringlengths 40 40 | size int64 19 11.4M | ext stringclasses 13
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 270 | max_stars_repo_name stringlengths 5 110 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 3 270 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 9 | max_issues_count float64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 270 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 9 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 19 11.4M | avg_line_length float64 1.93 229k | max_line_length int64 12 688k | alphanum_fraction float64 0.07 0.99 | matches listlengths 1 10 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
712664cb0f7a4ccf7a74b52f494b69f983f72174 | 3,577 | cpp | C++ | src/rule/RuleBlock.cpp | Fishwaldo/Fuzzylite | d2eecb7e8a342eec0b0c067456d0833cc8d50636 | [
"MIT"
] | null | null | null | src/rule/RuleBlock.cpp | Fishwaldo/Fuzzylite | d2eecb7e8a342eec0b0c067456d0833cc8d50636 | [
"MIT"
] | null | null | null | src/rule/RuleBlock.cpp | Fishwaldo/Fuzzylite | d2eecb7e8a342eec0b0c067456d0833cc8d50636 | [
"MIT"
] | null | null | null | /* Copyright 2013 Juan Rada-Vilela
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.
*/
/*
* RuleBlock.cpp
*
* Created on: 2/12/2012
* Author: jcrada
*/
#include "fl/rule/RuleBlock.h"
#include "fl/rule/Rule.h"
#include "fl/norm/TNorm.h"
#include "fl/norm/SNorm.h"
#include "fl/imex/FllExporter.h"
#include <sstream>
namespace fl {
RuleBlock::RuleBlock(const std::string& name)
: _name(name), _conjunction(NULL), _disjunction(NULL), _activation(NULL), _enabled(true) {
}
RuleBlock::~RuleBlock() {
for (std::size_t i = 0; i < _rules.size(); ++i) {
delete _rules.at(i);
}
}
void RuleBlock::activate() {
FL_DBG("===================");
FL_DBG("ACTIVATING RULEBLOCK " << _name);
for (std::size_t i = 0; i < _rules.size(); ++i) {
scalar activationDegree = _rules.at(i)->activationDegree(_conjunction, _disjunction);
FL_DBG(_rules.at(i)->toString() << " [activationDegree=" << activationDegree << "]");
if (Op::isGt(activationDegree, 0.0)) {
_rules.at(i)->activate(activationDegree, _activation);
}
}
}
void RuleBlock::setName(std::string name) {
this->_name = name;
}
std::string RuleBlock::getName() const {
return this->_name;
}
void RuleBlock::setConjunction(const TNorm* tnorm) {
if (this->_conjunction) delete this->_conjunction;
this->_conjunction = tnorm;
}
const TNorm* RuleBlock::getConjunction() const {
return this->_conjunction;
}
void RuleBlock::setDisjunction(const SNorm* snorm) {
if (this->_disjunction) delete this->_disjunction;
this->_disjunction = snorm;
}
const SNorm* RuleBlock::getDisjunction() const {
return this->_disjunction;
}
void RuleBlock::setActivation(const TNorm* activation) {
if (this->_activation) delete this->_activation;
this->_activation = activation;
}
const TNorm* RuleBlock::getActivation() const {
return this->_activation;
}
void RuleBlock::setEnabled(bool enabled) {
this->_enabled = enabled;
}
bool RuleBlock::isEnabled() const {
return this->_enabled;
}
std::string RuleBlock::toString() const {
return FllExporter("", "; ").toString(this);
}
/**
* Operations for datatype _rules
*/
void RuleBlock::addRule(Rule* rule) {
this->_rules.push_back(rule);
}
void RuleBlock::insertRule(Rule* rule, int index) {
this->_rules.insert(this->_rules.begin() + index, rule);
}
Rule* RuleBlock::getRule(int index) const {
return this->_rules.at(index);
}
Rule* RuleBlock::removeRule(int index) {
Rule* result = this->_rules.at(index);
this->_rules.erase(this->_rules.begin() + index);
return result;
}
int RuleBlock::numberOfRules() const {
return this->_rules.size();
}
const std::vector<Rule*>& RuleBlock::rules() const {
return this->_rules;
}
}
| 26.496296 | 97 | 0.619793 | [
"vector"
] |
713aa57a0f505786e3b6f088cdc72ea809539c01 | 766 | cpp | C++ | test/Geometric_convex_hull.test.cpp | yuruhi/library | fecbd92ec6c6997d50bf954c472ac4bfeff74de5 | [
"Apache-2.0"
] | null | null | null | test/Geometric_convex_hull.test.cpp | yuruhi/library | fecbd92ec6c6997d50bf954c472ac4bfeff74de5 | [
"Apache-2.0"
] | 6 | 2021-01-05T07:39:05.000Z | 2021-01-05T07:44:31.000Z | test/Geometric_convex_hull.test.cpp | yuruhi/library | fecbd92ec6c6997d50bf954c472ac4bfeff74de5 | [
"Apache-2.0"
] | null | null | null | #define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/library/4/CGL/all/CGL_4_A"
#include "./../Geometry/Polygon.hpp"
#include "./../Geometry/Geometric.cpp"
#include <iostream>
#include <utility>
using namespace std;
int main() {
int n;
cin >> n;
Geometric::Polygon p(n);
for (int i = 0; i < n; ++i) {
cin >> p[i];
}
Geometric::Polygon ans = p.convex_hull();
size_t min_index = 0;
pair<Geometric::LD, Geometric::LD> min_val(10001, 10001);
for (size_t i = 0; i < ans.size(); ++i) {
if (auto val = make_pair(ans[i].y, ans[i].x); min_val > val) {
min_val = val;
min_index = i;
}
}
cout << ans.size() << '\n';
for (size_t i = 0; i < ans.size(); ++i) {
auto v = ans[(i + min_index) % ans.size()];
cout << v.x << ' ' << v.y << '\n';
}
} | 24.709677 | 84 | 0.583551 | [
"geometry"
] |
7145e51f5ad4663391479a4da62a7e053b92a94b | 1,412 | cpp | C++ | acmp/graph-theory/algorithm.cpp | nvxden/olp | 780e125ffcf430fdc79bb6c07ddddca28f4f042e | [
"MIT"
] | null | null | null | acmp/graph-theory/algorithm.cpp | nvxden/olp | 780e125ffcf430fdc79bb6c07ddddca28f4f042e | [
"MIT"
] | null | null | null | acmp/graph-theory/algorithm.cpp | nvxden/olp | 780e125ffcf430fdc79bb6c07ddddca28f4f042e | [
"MIT"
] | null | null | null | /*
* autor: eraeg
* date: Jan 27 15:17:46 2020
*/
#include <queue>
#include <stack>
#include <vector>
int bfs_length(AdjacList const &adjl, int beg, int end)
{
if(beg == end)
return 0;
queue<int> que;
que.push(beg);
vector<char> marks(adjl.n(), 0);
marks[beg] = 1;
int cur;
while(!que.empty())
{
cur = que.front();
for(auto b = adjl[cur].begin(), e = adjl[cur].end(); b != e; ++b)
{
if(*b == end)
return marks[cur];
if(!marks[*b])
{
marks[*b] = marks[cur] + 1;
que.push(*b);
}
}
que.pop();
}
return -1;
}
vector<int> dfs_components(AdjacList const &adjl)
{
stack<int> vers;
vector<int> marks(adjl.n(), 0);
vector<int> comps;
int c = 0;
int v;
for(int i = 0; i < adjl.n(); ++i)
{
if(marks[i])
continue;
marks[i] = ++c;
comps.push_back(i);
vers.push(i);
while(!vers.empty())
{
v = vers.top();
vers.pop();
for(auto b = adjl[v].begin(), e = adjl[v].end(); b != e; ++b)
{
vers.push(*b);
marks[*b] = c;
}
}
}
return comps;
}
void dfs(AdjacList const &adjl, int beg)
{
vector<bool> marks(adjl.n(), false);
stack<int> vers;
marks[beg] = true;
vers.push(beg);
int v;
while(!vers.empty())
{
v = vers.top();
vers.pop();
for(auto b = adjl[v].begin(), e = adjl[v].end(); b != e; ++b)
{
if(marks[*b])
continue;
marks[*b] = true;
vers.push(*b);
}
}
return;
}
// end
| 12.954128 | 67 | 0.52762 | [
"vector"
] |
71542131642cde63111cfeb3018519698381f825 | 1,976 | hpp | C++ | RedWolf/include/RedWolf/gl/Shader.hpp | DavidePistilli173/RedWolf | 1ca752c8e4c6becfb9de942d6059f6076384f3af | [
"Apache-2.0"
] | null | null | null | RedWolf/include/RedWolf/gl/Shader.hpp | DavidePistilli173/RedWolf | 1ca752c8e4c6becfb9de942d6059f6076384f3af | [
"Apache-2.0"
] | null | null | null | RedWolf/include/RedWolf/gl/Shader.hpp | DavidePistilli173/RedWolf | 1ca752c8e4c6becfb9de942d6059f6076384f3af | [
"Apache-2.0"
] | null | null | null | #ifndef RW_GL_SHADER_HPP
#define RW_GL_SHADER_HPP
#include "RedWolf/core.hpp"
#include <glad/glad.h>
#include <string_view>
#include <utility>
#include <vector>
namespace rw::gl
{
/**< \brief Wrapper class for an OpenGL shader. */
class RW_API Shader
{
public:
/** \brief Positions of all different shader attributes. */
enum class Attrib
{
vtx_coords, // Vertex coordinates.
tex_coords // Texture coordinates.
};
/** \brief Size of the error log for shader compilation and linking. */
static constexpr size_t log_size{ 2048 };
/** \brief Token for uniform parsing in shader code. */
static constexpr std::string_view uniform_token{ "uniform" };
/** \brief Create an empty shader. */
Shader();
/** \brief Create a shader from two source files. */
explicit Shader(std::pair<std::string_view, std::string_view> code);
/** \brief A shader cannot be copied. */
Shader(const Shader&) = delete;
/** \brief Move constructor. */
Shader(Shader&& oldShader) noexcept;
/** \brief A shader cannot be copied. */
Shader& operator=(const Shader&) = delete;
/** \brief Move assignment operator. */
Shader& operator=(Shader&& oldShader) noexcept;
/** \brief Destructor. */
~Shader();
/** \brief Set the value of an int uniform. Requires that the shader is in use. */
void setUniform(size_t idx, int i);
/** \brief Set the value of a Mat4 uniform. Requires that the shader is in use. */
void setUniform(size_t idx, const GLfloat* mat);
/** \brief Use the shader for rendering. */
void use() const;
private:
/** \brief Check if idx is a valid uniform index. */
bool checkUniformIndex_(size_t idx);
GLuint id_{ 0 }; /**< OpenGL ID of the shader. */
std::vector<GLint> uniforms_; /**< Uniform locations. */
};
} // namespace rw::gl
#endif | 29.058824 | 88 | 0.618927 | [
"vector"
] |
715f5f08b620ad5cb0919230997ce53b77f7387b | 639 | cpp | C++ | source/jz58_1.cpp | loganautomata/leetcode | 5a626c91f271bae231328c92a3be23eba227f66e | [
"MIT"
] | null | null | null | source/jz58_1.cpp | loganautomata/leetcode | 5a626c91f271bae231328c92a3be23eba227f66e | [
"MIT"
] | null | null | null | source/jz58_1.cpp | loganautomata/leetcode | 5a626c91f271bae231328c92a3be23eba227f66e | [
"MIT"
] | null | null | null | #include "jz58_1.h"
using namespace std;
string Jz58_1::reverseWords(string s)
{
s += ' '; // 字符串后加入空格, 避免最后一个单词被遗漏.
vector<string> words; // 存储字符串中所有的单词.
string word; // 暂存单词
string res; // 逆序句子
// 将所有单词存储于动态数组中.
for (char &ch : s)
{
if (ch == ' ')
{
if (!word.empty()) words.push_back(word);
word.clear();
}
else if (ch != ' ') word += ch;
}
// 将动态数组中的单词逆序输出.
for (vector<string>::reverse_iterator i = words.rbegin(); i < words.rend(); i++)
{
res += *i;
if (i < words.rend() - 1) res += ' ';
}
return res;
}
| 19.96875 | 84 | 0.488263 | [
"vector"
] |
7162c400af17aa0fe40efb46226c5528467a8a61 | 13,579 | cpp | C++ | Planet/main.cpp | marcosdanix/cgj-planet | 8e04246b76e37b16be5d2da1435b903ba7bd2aed | [
"MIT"
] | null | null | null | Planet/main.cpp | marcosdanix/cgj-planet | 8e04246b76e37b16be5d2da1435b903ba7bd2aed | [
"MIT"
] | null | null | null | Planet/main.cpp | marcosdanix/cgj-planet | 8e04246b76e37b16be5d2da1435b903ba7bd2aed | [
"MIT"
] | null | null | null | #include <iostream>
#include <sstream>
#include <string>
#include "GL/glew.h"
#include "GL/freeglut.h"
#include "IL/il.h"
#include "../Engine/Engine.h"
#include <glm/mat4x4.hpp>
#include <glm/gtc/matrix_transform.hpp>
using namespace cgj;
#define CAPTION "Terrestrial Planet by Group 11"
//Shader input attributes
#define VERTICES 0
#define TEXCOORDS 1
#define NORMALS 2
#define TANGENT 3
int WinX = 800, WinY = 600;
int WindowHandle = 0;
unsigned int FrameCount = 0;
float zoom = 1.5;
float aspect;
float time = 0.0f;
const float zNear = -100.0f;
const float zFar = 100.0f;
//STUFF
Camera camera;
OrbitControl orbit;
/////////////////////////////////////////////////////////////////////// CALLBACKS
//glutCloseFunc
void cleanup()
{
}
//glutDisplayFunc
void display()
{
++FrameCount;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Draw something
Scene* scene = Storage<Scene>::instance().get("example");
scene->draw();
glutSwapBuffers();
}
//glutIdleFunc
void idle()
{
//glutPostRedisplay();
}
void recalculateProjection()
{
mat4 projection = glm::ortho(-aspect*zoom, aspect*zoom, -zoom, zoom, zNear, zFar);
//A bit of a mouthful
Storage<Scene>::instance().get("example")->camera().projection(projection);
}
//glutReshapeFunc
void reshape(int w, int h)
{
WinX = w;
WinY = h;
glViewport(0, 0, WinX, WinY);
aspect = float(w) / float(h);
recalculateProjection();
}
void timer(int value);
void timerRefreshWindow()
{
std::ostringstream oss;
oss << CAPTION << ": " << FrameCount << " FPS @ (" << WinX << "x" << WinY << ")";
std::string s = oss.str();
glutSetWindow(WindowHandle);
glutSetWindowTitle(s.c_str());
FrameCount = 0;
glutTimerFunc(1000, timer, 0);
}
void updateShaderTimeUniform() {
Storage<ShaderProgram>& storage = Storage<ShaderProgram>::instance();
for (auto it = storage.cbegin(); it != storage.cend(); ++it) {
it->second->use();
it->second->uniform("Time", time);
it->second->stop();
}
}
void update()
{
Storage<Scene>::instance().get("example")->update();
updateShaderTimeUniform();
time += 0.016f;
}
void timerFPS()
{
update();
glutPostRedisplay();
glutTimerFunc(16, timer, 1);
}
//glutTimerFunc
void timer(int value)
{
switch (value) {
case 0:
timerRefreshWindow();
break;
case 1:
timerFPS();
break;
}
}
//glutKeyboardFunc
void keyboard(unsigned char key, int x, int y)
{
// glutGetModifiers for SHIFT, CTRL, ALT
}
//glutKeyboardUpFunc
void keyboardUp(unsigned char key, int x, int y)
{
// glutGetModifiers for SHIFT, CTRL, ALT
if (key >= '0' && key <= '9') {
int digit = key - '0';
Storage<ShaderProgram>& storage = Storage<ShaderProgram>::instance();
for (auto it = storage.cbegin(); it != storage.cend(); ++it) {
it->second->use();
it->second->uniform("Mode", digit);
}
}
else if (key == 'r' || key == 'R') {
//Reload Shaders
Storage<ShaderProgram>& storage = Storage<ShaderProgram>::instance();
for (auto it = storage.cbegin(); it != storage.cend(); ++it) {
it->second->reload();
}
}
else if (key == 's' || key == 'S') {
GLubyte *pixels = new GLubyte[3 * WinX * WinY];
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadBuffer(GL_FRONT);
glReadPixels(0, 0, WinX, WinY, GL_RGB, GL_UNSIGNED_BYTE, pixels);
ILuint image;
ilGenImages(1, &image);
ilBindImage(image);
ilSetPixels(0, 0, 0, WinX, WinY, 1, IL_RGB, IL_UNSIGNED_BYTE, pixels);
ilSave(IL_BMP, "screenshot.bmp");
ilDeleteImage(image);
delete[] pixels;
}
}
//glutSpecialFunc
void special(int key, int x, int y)
{
}
//glutSpecialUpFunc
void specialUp(int key, int x, int y)
{
}
//glutMouseFunc
void mouse(int button, int state, int x, int y)
{
// glutGetModifiers for SHIFT, CTRL, ALT
// button GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, GLUT_RIGHT_BUTTON
// state for GLUT_UP, GLUT_DOWN
}
//glutMouseWheelFunc
void mouseWheel(int wheel, int direction, int x, int y)
{
//wheel is wheel number (useless)
//direction is +/- 1
zoom -= 0.05*direction;
recalculateProjection();
}
//glutMotionFunc
//mouse motion WHILE pressing a mouse button
void motion(int x, int y)
{
}
//glutPassiveMotionFunc
//mouse motion WHILE NOT pressing a mouse button
void passiveMotion(int x, int y)
{
static int centerX = glutGet(GLUT_WINDOW_WIDTH) / 2;
static int centerY = glutGet(GLUT_WINDOW_HEIGHT) / 2;
if (x != centerX || y != centerY) glutWarpPointer(centerX, centerY);
float rotx = x - centerX;
float roty = y - centerY;
orbit.rotate(rotx, roty);
}
//glutWindowStatusFunc
void windowStatus(int state)
{
switch (state) {
case GLUT_FULLY_RETAINED:
case GLUT_PARTIALLY_RETAINED:
glutDisplayFunc(display);
break;
case GLUT_FULLY_COVERED:
case GLUT_HIDDEN:
glutDisplayFunc(nullptr);
break;
}
}
/////////////////////////////////////////////////////////////////////// SETUP
void setupGLUT(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitContextVersion(3, 3);
glutInitContextProfile(GLUT_CORE_PROFILE);
//glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE);
glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);
//glutInitContextFlags(GLUT_DEBUG);
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
glutInitWindowSize(WinX, WinY);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
WindowHandle = glutCreateWindow(CAPTION);
if (WindowHandle < 1) {
std::cerr << "ERROR: Could not create a new rendering window." << std::endl;
exit(EXIT_FAILURE);
}
}
void setupGLEW()
{
glewExperimental = GL_TRUE;
// Allow extension entry points to be loaded even if the extension isn't
// present in the driver's extensions string.
GLenum result = glewInit();
if (result != GLEW_OK) {
std::cerr << "ERROR glewInit: " << glewGetString(result) << std::endl;
exit(EXIT_FAILURE);
}
GLenum err_code = glGetError();
// You might get GL_INVALID_ENUM when loading GLEW.
}
void checkOpenGLInfo()
{
const GLubyte *renderer = glGetString(GL_RENDERER);
const GLubyte *vendor = glGetString(GL_VENDOR);
const GLubyte *version = glGetString(GL_VERSION);
const GLubyte *glslVersion = glGetString(GL_SHADING_LANGUAGE_VERSION);
std::cerr << "OpenGL Renderer: " << renderer << " (" << vendor << ")" << std::endl;
std::cerr << "OpenGL version " << version << std::endl;
std::cerr << "GLSL version " << glslVersion << std::endl;
}
void setupOpenGL()
{
checkOpenGLInfo();
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glDepthMask(GL_TRUE);
glDepthRange(0.0, 1.0);
glClearDepth(1.0);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glFrontFace(GL_CCW);
}
void setupDevIL() {
ilInit();
}
void setupCallbacks()
{
glutCloseFunc(cleanup);
glutDisplayFunc(display);
//glutIdleFunc(idle);
glutReshapeFunc(reshape);
glutTimerFunc(0, timer, 0);
glutTimerFunc(16, timer, 1);
glutKeyboardFunc(keyboard);
glutKeyboardUpFunc(keyboardUp);
glutSpecialFunc(special);
glutSpecialUpFunc(specialUp);
glutMouseFunc(mouse);
glutMouseWheelFunc(mouseWheel);
glutMotionFunc(motion);
glutPassiveMotionFunc(passiveMotion);
glutWindowStatusFunc(windowStatus);
}
/////////////////////////////////////////////////////////////////////// ENGINE SETUP
//#define VERT_LAND_FILE "assets/basic_shader.vert"
//#define FRAG_LAND_FILE "assets/basic_shader.frag"
//#define VERT_WATER_FILE "assets/basic_shader.vert"
//#define FRAG_WATER_FILE "assets/basic_shader.frag"
//#define VERT_LAND_FILE "assets/blinn_phong.vert"
//#define FRAG_LAND_FILE "assets/blinn_phong.frag"
//#define FRAG_LAND_FILE "assets/height_shader.frag"
//#define VERT_WATER_FILE "assets/blinn_phong.vert"
//#define FRAG_WATER_FILE "assets/water_bp.frag"
#define VERT_WATER_FILE "assets/water_bump.vert"
#define FRAG_WATER_FILE "assets/water_bump.frag"
#define VERT_LAND_FILE "assets/water_bump.vert"
#define FRAG_LAND_FILE "assets/land_bump.frag"
#define VERT_CUBEMAP "assets/cubemap.vert"
#define FRAG_CUBEMAP "assets/cubemap.frag"
//#define FRAG_CUBEMAP "assets/texcoord.frag"
#define VERT_MOON_FILE "assets/water_bump.vert"
#define FRAG_MOON_FILE "assets/moon_bump.frag"
#define LAND_FILE "assets/icosphere2.obj"
#define MOON_FILE "assets/icosphere.obj"
//#define LAND_FILE "assets/icosphere.obj"
#define WATER_FILE "assets/icosphere.obj"
#define CUBEMAP_FILE "assets/cubemap.obj"
ShaderProgram shaderProgram;
VertexShader vertexShader;
FragmentShader fragmentShader;
ShaderProgram waterShaderProgram;
VertexShader waterVertexShader;
FragmentShader waterFragmentShader;
ShaderProgram cubemapProgram;
VertexShader cubemapVert;
FragmentShader cubemapFrag;
ShaderProgram moonShaderProgram;
VertexShader moonVertexShader;
FragmentShader moonFragmentShader;
void createShaderProgram()
{
vertexShader.load(VERT_LAND_FILE);
fragmentShader.load(FRAG_LAND_FILE);
shaderProgram.create()
.attach(&vertexShader) //if it's not compiled, it compiles the shader
.attach(&fragmentShader)
.bindAttribute(VERTICES, "in_Position")
.bindAttribute(NORMALS, "in_Normal")
.bindAttribute(TANGENT, "in_Tangent")
.link();
//Add to the storage so it can be accessed by the rest of the engine
//It's not necessary, but it's being used to test this feature
Storage<ShaderProgram>::instance().add("land", &shaderProgram);
waterVertexShader.load(VERT_WATER_FILE);
waterFragmentShader.load(FRAG_WATER_FILE);
waterShaderProgram.create()
.attach(&waterVertexShader) //if it's not compiled, it compiles the shader
.attach(&waterFragmentShader)
.bindAttribute(VERTICES, "in_Position")
.bindAttribute(NORMALS, "in_Normal")
.bindAttribute(TANGENT, "in_Tangent")
.link();
//Add to the storage so it can be accessed by the rest of the engine
//It's not necessary, but it's being used to test this feature
Storage<ShaderProgram>::instance().add("water", &waterShaderProgram);
cubemapVert.load(VERT_CUBEMAP);
cubemapFrag.load(FRAG_CUBEMAP);
cubemapProgram.create()
.attach(&cubemapVert) //if it's not compiled, it compiles the shader
.attach(&cubemapFrag)
.bindAttribute(VERTICES, "in_Position")
.link();
//Add to the storage so it can be accessed by the rest of the engine
//It's not necessary, but it's being used to test this feature
Storage<ShaderProgram>::instance().add("cubemap", &cubemapProgram);
moonVertexShader.load(VERT_MOON_FILE);
moonFragmentShader.load(FRAG_MOON_FILE);
moonShaderProgram.create()
.attach(&moonVertexShader) //if it's not compiled, it compiles the shader
.attach(&moonFragmentShader)
.bindAttribute(VERTICES, "in_Position")
.bindAttribute(NORMALS, "in_Normal")
.bindAttribute(TANGENT, "in_Tangent")
.link();
//Add to the storage so it can be accessed by the rest of the engine
//It's not necessary, but it's being used to test this feature
Storage<ShaderProgram>::instance().add("moon", &moonShaderProgram);
}
Mesh land_mesh;
Mesh water_mesh;
Mesh cubemap_mesh;
Mesh moon_mesh;
void createMeshes()
{
PerlinFilter perlin(1.5f, 0.15f, -0.02f, 8, 1.8);
PerlinFilter perlinMoon(1.5f, 0.09f, -0.02f, 8, 1.8);
SphericalTangentFilter sphere;
land_mesh.load(LAND_FILE, perlin);
water_mesh.load(WATER_FILE, sphere);
cubemap_mesh.load(CUBEMAP_FILE);
moon_mesh.load(MOON_FILE, perlinMoon);
Storage<Mesh>::instance().add("land", &land_mesh);
Storage<Mesh>::instance().add("water", &water_mesh);
Storage<Mesh>::instance().add("cubemap", &cubemap_mesh);
Storage<Mesh>::instance().add("moon", &moon_mesh);
}
TextureCubemap cubemap_texture;
void createTextures()
{
StarmapGenerator gen;
//cubemap_texture.create(gen.generate(1024), 1024, 1024, 10);
//Storage<Texture>::instance().add("cubemap", &cubemap_texture);
}
void setupCamera()
{
aspect = float(WinX) / float(WinY);
mat4 projection = glm::ortho(-aspect*zoom, aspect*zoom, -zoom, zoom, zNear, zFar);
orbit = OrbitControl(10.0f, 0.5f, 0.0f);
camera = Camera(&orbit, projection);
}
Scene scene;
Node land;
Node water;
Node cubemap;
Node moon;
Node moonAnchor;
void planetRotate(Node& node)
{
node.transform().rotateY(0.1f / 60.0f);
}
void moonOrbit(Node& node) {
node.transform().rotateY(0.05f / 60.0f);
}
void moonRotate(Node& node)
{
node.transform().rotateY(0.2f / 60.0f);
}
void createScene()
{
scene = Scene(camera);
scene.root()->addChild(&cubemap);
scene.root()->addChild(&land);
scene.root()->addChild(&moonAnchor);
land.mesh(*Storage<Mesh>::instance().get("land"));
land.shader(*Storage<ShaderProgram>::instance().get("land"));
land.updateFunc(planetRotate);
land.addChild(&water);
water.mesh(*Storage<Mesh>::instance().get("water"));
water.shader(*Storage<ShaderProgram>::instance().get("water"));
cubemap.mesh(*Storage<Mesh>::instance().get("cubemap"));
cubemap.shader(*Storage<ShaderProgram>::instance().get("cubemap"));
cubemap.beforeDraw([]() {glFrontFace(GL_CW); });
cubemap.afterDraw([]() {glFrontFace(GL_CCW); });
//cubemap.texture(Storage<Texture>::instance().get("cubemap"));
moonAnchor.addChild(&moon);
moonAnchor.updateFunc(moonOrbit);
moon.mesh(*Storage<Mesh>::instance().get("moon"));
moon.shader(*Storage<ShaderProgram>::instance().get("moon"));
moon.updateFunc(moonRotate);
moon.transform().translation(vec3(0.0f, 0.0f, 5.0f));
moon.transform().scale(vec3(0.5f));
Storage<Scene>::instance().add("example", &scene);
}
void init(int argc, char* argv[])
{
setupGLUT(argc, argv);
setupGLEW();
setupOpenGL();
setupDevIL();
createShaderProgram();
createMeshes();
//createTextures();
setupCamera();
createScene();
setupCallbacks();
}
int main(int argc, char* argv[])
{
init(argc, argv);
glutMainLoop();
exit(EXIT_SUCCESS);
}
/////////////////////////////////////////////////////////////////////// | 24.689091 | 84 | 0.708741 | [
"mesh",
"transform"
] |
7179b51639098fc664621939166357250630f808 | 601 | cpp | C++ | Sourse/Main/sourse/Main.cpp | IlyaShurupov/Ma | 1342695419ade75531324a92a71ef9233f13300d | [
"MIT"
] | null | null | null | Sourse/Main/sourse/Main.cpp | IlyaShurupov/Ma | 1342695419ade75531324a92a71ef9233f13300d | [
"MIT"
] | null | null | null | Sourse/Main/sourse/Main.cpp | IlyaShurupov/Ma | 1342695419ade75531324a92a71ef9233f13300d | [
"MIT"
] | null | null | null |
#include "AppManager.h"
#include "WM.h"
#include "Render.h"
#include "Data.h"
#include "Math.h"
#include "Operator.h"
#include <windows.h>
/*
keymap
rotate
move
gizmo
fbuffer
outline
matrices
*/
int main()
{
_Data DATA;
APM_OnStart(&DATA.APM);
printf("Fuuuuuck here ");
{
OPS_init(&DATA);
WM_Init(&DATA);
RND_init(&DATA);
ResetCamera();
OPSAddcoords();
while (!WM_close_command())
{
APM_LoopIn();
if (WM_input() || !DATA.RND_cycle.cycle_complete)
{
//RND_Render();
WM_output();
}
APM_LoopOut();
}
WM_CloseWindow();
}
APM_OnEnd();
} | 10.927273 | 52 | 0.617304 | [
"render"
] |
717b69f6a094983dc492704a2183fb52b49dd995 | 341 | cpp | C++ | April30DayChallenge/Week1/4:MoveZeros.cpp | thepushkarp/leetcode | 6812c68d7c49b9e5b0698feb3203346f5fe8adbf | [
"MIT"
] | 1 | 2022-02-10T15:19:02.000Z | 2022-02-10T15:19:02.000Z | April30DayChallenge/Week1/4:MoveZeros.cpp | thepushkarp/leetcode | 6812c68d7c49b9e5b0698feb3203346f5fe8adbf | [
"MIT"
] | null | null | null | April30DayChallenge/Week1/4:MoveZeros.cpp | thepushkarp/leetcode | 6812c68d7c49b9e5b0698feb3203346f5fe8adbf | [
"MIT"
] | null | null | null | class Solution {
public:
void moveZeroes(vector<int>& nums) {
int zeroCount = 0;
int n = nums.size();
for (int i = 0; i < n; i++) {
if (nums[i]) {
nums[zeroCount++] = nums[i];
}
}
while(zeroCount < n) {
nums[zeroCount++] = 0;
}
}
};
| 21.3125 | 44 | 0.398827 | [
"vector"
] |
71850d18e98dab7d7efb49afdbfd8a875bce0f0a | 2,802 | cpp | C++ | utilities/Model.cpp | yitbarek123/IntelligentAgent-WumpusWorld | 9e090c8d224f57ca7319cab997d26faddd168969 | [
"MIT"
] | 2 | 2019-09-21T07:38:33.000Z | 2019-09-29T09:59:42.000Z | utilities/Model.cpp | yitbarek123/IntelligentAgent-WumpusWorld | 9e090c8d224f57ca7319cab997d26faddd168969 | [
"MIT"
] | 1 | 2019-10-26T08:38:51.000Z | 2019-10-26T08:38:51.000Z | utilities/Model.cpp | yitbarek123/IntelligentAgent-WumpusWorld | 9e090c8d224f57ca7319cab997d26faddd168969 | [
"MIT"
] | 1 | 2019-10-26T06:17:44.000Z | 2019-10-26T06:17:44.000Z | #include "Model.h"
namespace DataStructures{
/**
* Validates whether a given position is valid or not.
* @param i row of a given position
* @param j column of a given position
* @return bool
*/
bool is_valid_position(int i, int j)
{
// this function is not generic enough to handle a grid that's not 4X4, needs improvement
if((i >= 0 && i <= 3) && (j >= 0 && j <= 3)) return true;
else return false;
}
/**
* @brief Generates an inference model for the inference. Generates the constraints based on specified rule.
*
* @param room Room that model will be generated for.
* @param rule The rule whose constraints will be defined in the model
* @return model
*/
model Model::generate_model(Room room, Rule rule){
model required_model;
Room left = std::make_pair(room.first-1, room.second);
Room right = std::make_pair(room.first+1, room.second);
Room top = std::make_pair(room.first, room.second+1);
Room bottom = std::make_pair(room.first, room.second-1);
if(rule == Rule::Wumpus){
if (is_valid_position(left.first, left.second)) required_model[left].stench = true;
if (is_valid_position(right.first, right.second)) required_model[right].stench = true;
if (is_valid_position(top.first, top.second)) required_model[top].stench = true;
if (is_valid_position(bottom.first, bottom.second)) required_model[bottom].stench = true;
}
else if(rule == Rule::Pit){
if (is_valid_position(left.first, left.second)) required_model[left].breeze = true;
if (is_valid_position(right.first, right.second)) required_model[right].breeze = true;
if (is_valid_position(top.first, top.second)) required_model[top].breeze = true;
if (is_valid_position(bottom.first, bottom.second)) required_model[bottom].breeze = true;
}
return required_model;
}
bool Model::get_specific_constraint_info(std::pair<int, int> room, DataStructures::constraint specified_constraint, DataStructures::model specified_model){
if(specified_constraint == DataStructures::constraint::breeze) return specified_model[room].breeze;
else if(specified_constraint == DataStructures::constraint::bump) return specified_model[room].bump;
else if(specified_constraint == DataStructures::constraint::glitter) return specified_model[room].glitter;
// else if(specified_constraint == DataStructures::constraint::pit) return specified_model[room].scream;
else if(specified_constraint == DataStructures::constraint::scream) return specified_model[room].scream;
else if(specified_constraint == DataStructures::constraint::stench) return specified_model[room].stench;
else if(specified_constraint == DataStructures::constraint::wumpus) return specified_model[room].wumpus;
else return false;
}
}
| 45.193548 | 155 | 0.724483 | [
"model"
] |
718668c4152e44596d9e0ac04cc3ecf7a71320aa | 2,419 | cpp | C++ | 2021/day09.cpp | mly32/advent-of-code | 8c07ac69b3933403357688efc02f6d4adf1d0592 | [
"BSD-3-Clause"
] | null | null | null | 2021/day09.cpp | mly32/advent-of-code | 8c07ac69b3933403357688efc02f6d4adf1d0592 | [
"BSD-3-Clause"
] | null | null | null | 2021/day09.cpp | mly32/advent-of-code | 8c07ac69b3933403357688efc02f6d4adf1d0592 | [
"BSD-3-Clause"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
struct solution {
vector<int> values;
vector<vector<int>> grid;
solution(const string& filename) {
string line;
ifstream input_file(filename);
if (!input_file.is_open()) {
cerr << "Could not open the file - '" << filename << "'" << endl;
return;
}
while (getline(input_file, line)) {
if (line != "") {
grid.push_back({});
for (const char c : line) {
grid.back().push_back(c - '0');
}
}
}
input_file.close();
}
vector<vector<int>> get_adj() {
int m = grid.size(), n = grid[0].size();
vector<vector<int>> adj;
pair<int, int> dirs[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
values.resize(m * n);
adj.resize(m * n);
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
values[n * i + j] = grid[i][j];
for (auto [dx, dy] : dirs) {
int x = i + dx, y = j + dy;
if (x >= 0 && x < m && y >= 0 && y < n) {
adj[n * i + j].push_back(n * x + y);
}
}
}
}
cout << "size: " << m << " " << n << endl;
return adj;
}
int solve() {
vector<vector<int>> adj = get_adj();
const int sz = adj.size();
vector<int> low_points;
int low_score = 0;
for (int u = 0; u < sz; ++u) {
bool is_lower = true;
for (const int v : adj[u]) {
is_lower &= values[u] < values[v];
}
if (is_lower) {
low_points.push_back(u);
low_score += values[u] + 1;
}
}
vector<int> areas;
for (const int p : low_points) {
vector<bool> seen(sz);
queue<int> q;
int area = 1;
q.push(p);
seen[p] = true;
while (!q.empty()) {
int u = q.front();
q.pop();
for (const int v : adj[u]) {
if (!seen[v] && values[v] != 9) {
seen[v] = true;
++area;
q.push(v);
}
}
}
areas.push_back(area);
}
sort(areas.begin(), areas.end(), greater<int>());
unsigned long long area = 1ull * areas[0] * areas[1] * areas[2];
printf("res: %d, %llu\n", low_score, area);
return low_score;
}
};
int main() {
const bool final = 1;
const string filename =
"./input/" + string(final ? "final" : "practice") + "/day09.txt";
solution(filename).solve();
}
// TODO learn dense dijkstra
| 23.038095 | 71 | 0.467962 | [
"vector"
] |
718c44b20a818af85166a767781903dc9d297a0a | 3,653 | cpp | C++ | libfma/src/fma/core/Range.cpp | BenjaminSchulte/fma | df2aa5b0644c75dd34a92defeff9beaa4a32ffea | [
"MIT"
] | 14 | 2018-01-25T10:31:05.000Z | 2022-02-19T13:08:11.000Z | libfma/src/fma/core/Range.cpp | BenjaminSchulte/fma | df2aa5b0644c75dd34a92defeff9beaa4a32ffea | [
"MIT"
] | 1 | 2020-12-24T10:10:28.000Z | 2020-12-24T10:10:28.000Z | libfma/src/fma/core/Range.cpp | BenjaminSchulte/fma | df2aa5b0644c75dd34a92defeff9beaa4a32ffea | [
"MIT"
] | null | null | null | #include <fma/core/Class.hpp>
#include <fma/core/Boolean.hpp>
#include <fma/core/Range.hpp>
#include <fma/core/String.hpp>
#include <fma/core/Number.hpp>
#include <fma/types/InternalValue.hpp>
#include <fma/types/Object.hpp>
#include <fma/types/ClassPrototype.hpp>
#include <fma/interpret/BaseContext.hpp>
#include <fma/interpret/Result.hpp>
#include <fma/interpret/Parameter.hpp>
#include <fma/interpret/ParameterList.hpp>
#include <fma/serialize/SerializeTypes.hpp>
#include <fma/Project.hpp>
using namespace FMA;
using namespace FMA::core;
using namespace FMA::types;
using namespace FMA::interpret;
#include <iostream>
#include <sstream>
#include <cmath>
// ----------------------------------------------------------------------------
ClassPtr RangeClass::create(const RootModulePtr &root, const ClassPtr &ClassObject) {
ClassPtr klass = ClassPtr(new Class("Range", "Range"));
klass->extends(ClassObject);
klass->setMember("@FMA_TYPE_ID", TypePtr(new InternalNumberValue(serialize::TYPE_RANGE)));
ClassPrototypePtr proto(klass->getPrototype());
proto->setMember("first", TypePtr(new InternalFunctionValue("first", RangeClass::first)));
proto->setMember("initialize", TypePtr(new InternalFunctionValue("initialize", RangeClass::initialize)));
proto->setMember("last", TypePtr(new InternalFunctionValue("last", RangeClass::last)));
proto->setMember("to_s", TypePtr(new InternalFunctionValue("to_s", RangeClass::to_s)));
root->setMember("Range", klass);
return klass;
}
// ----------------------------------------------------------------------------
ResultPtr RangeClass::createInstance(const ContextPtr &context, const int64_t &first, const int64_t &last) {
// Resolve a
ClassPtr number = context->getRootLevelContext()->resolve("Range")->asClass();
if (!number) {
return ResultPtr(new Result());
}
GroupedParameterList parameters;
parameters.push_back(TypePtr(new InternalNumberValue(first)));
parameters.push_back(TypePtr(new InternalNumberValue(last)));
return Result::executed(context, number->createInstance(context, parameters));
}
// ----------------------------------------------------------------------------
ResultPtr RangeClass::initialize(const ContextPtr &context, const GroupedParameterList ¶meter) {
const TypeList &args = parameter.only_args();
switch (args.size()) {
case 0:
case 1:
context->self()->setMember("__first", TypePtr(new InternalNumberValue(0)));
context->self()->setMember("__last", TypePtr(new InternalNumberValue(0)));
break;
case 2:
default:
context->self()->setMember("__first", args.front());
context->self()->setMember("__last", args.back());
break;
}
return Result::executed(context, context->self());
}
// ----------------------------------------------------------------------------
ResultPtr RangeClass::first(const ContextPtr &context, const GroupedParameterList &) {
return NumberClass::createInstance(context, context->self()->convertToRange(context).first);
}
// ----------------------------------------------------------------------------
ResultPtr RangeClass::last(const ContextPtr &context, const GroupedParameterList &) {
return NumberClass::createInstance(context, context->self()->convertToRange(context).last);
}
// ----------------------------------------------------------------------------
ResultPtr RangeClass::to_s(const ContextPtr &context, const GroupedParameterList &) {
const auto &range = context->self()->convertToRange(context);
std::ostringstream os;
os << range.first << ".." << range.last;
return StringClass::createInstance(context, os.str());
} | 38.452632 | 108 | 0.640296 | [
"object"
] |
718ebce4ce1962966ebac3a8fcd7ab901712bf45 | 1,625 | cpp | C++ | icp/src/icp_align.cpp | tum-vision/articulation | 3bb714fcde14b8d47977bd3b3da2c2cd13ebe685 | [
"BSD-2-Clause"
] | 3 | 2017-03-15T16:50:05.000Z | 2021-02-28T05:27:24.000Z | icp/src/icp_align.cpp | AbdelrahmanElsaid/articulation | 3bb714fcde14b8d47977bd3b3da2c2cd13ebe685 | [
"BSD-2-Clause"
] | null | null | null | icp/src/icp_align.cpp | AbdelrahmanElsaid/articulation | 3bb714fcde14b8d47977bd3b3da2c2cd13ebe685 | [
"BSD-2-Clause"
] | 7 | 2015-07-14T14:47:51.000Z | 2018-04-02T16:22:23.000Z | /*
* icp_test.cpp
*
* Created on: Oct 21, 2009
* Author: sturm
*/
#include <ros/ros.h>
#include "articulation_msgs/TrackMsg.h"
#include "articulation_msgs/AlignModelSrv.h"
#include "geometry_msgs/Pose.h"
#include "LinearMath/btTransform.h"
#include "icp/icp_utils.h"
using namespace std;
using namespace articulation_msgs;
using namespace icp;
bool icp_align(articulation_msgs::AlignModelSrv::Request &request,
articulation_msgs::AlignModelSrv::Response &response
)
{
ROS_INFO("aligning model with data, poses=%lu, poses=%lu", request.model.track.pose.size(),request.data.track.pose.size());
IcpAlign alignment(request.model.track, request.data.track);
response.data_aligned = request.data;
alignment.TransformData(response.data_aligned.track);
response.model_aligned = request.model;
alignment.TransformModel(response.model_aligned.track);
for(int i=0;i<9;i++)
response.R[i] = alignment.TR[i];
for(int i=0;i<3;i++)
response.T[i] = alignment.TT[i];
btMatrix3x3 rot(
alignment.TR[0],alignment.TR[1],alignment.TR[2],
alignment.TR[3],alignment.TR[4],alignment.TR[5],
alignment.TR[6],alignment.TR[7],alignment.TR[8]);
btVector3 trans(alignment.TT[0],alignment.TT[1],alignment.TT[2]);
btTransform diff(rot,trans);
response.dist_trans = trans.length();
response.dist_rot = diff.getRotation().getAngle();
return true;
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "icp_test");
ros::NodeHandle n;
ros::ServiceServer icp_align_service= n.advertiseService("icp_align", icp_align);
ROS_INFO("icp_align running, service ready");
ros::spin();
}
| 28.017241 | 125 | 0.724923 | [
"model"
] |
7190cf1521c42e030ca5507031c795df6f8fb5a6 | 650 | cpp | C++ | Day1/part2.cpp | bandzaw/AdventOfCode2018 | d1e98d677c1173ad5e797e3fab42200d8ade6ab9 | [
"MIT"
] | null | null | null | Day1/part2.cpp | bandzaw/AdventOfCode2018 | d1e98d677c1173ad5e797e3fab42200d8ade6ab9 | [
"MIT"
] | null | null | null | Day1/part2.cpp | bandzaw/AdventOfCode2018 | d1e98d677c1173ad5e797e3fab42200d8ade6ab9 | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
#include <unordered_set>
#include <range/v3/numeric/accumulate.hpp>
#include <range/v3/istream_range.hpp>
#include <range/v3/view/cycle.hpp>
#include <range/v3/view/partial_sum.hpp>
int main()
{
std::cout << "Day1 part2:\n";
using namespace ranges;
std::unordered_set<int> vals;
auto input = istream_range<int>(std::cin) | to_vector;
auto cyclic_input = input | ranges::view::cycle;
auto acc_cyc_inp = cyclic_input | view::partial_sum(std::plus<>());
for (const auto& v : acc_cyc_inp)
{
if (!vals.insert(v).second)
{
std::cout << "Frequency " << v << " appeared twice!\n";
break;
}
}
} | 24.074074 | 68 | 0.678462 | [
"vector"
] |
719152d7587b397fb3b14297b7cea5b0620bcfd3 | 3,061 | cpp | C++ | Antiplagiat/Antiplagiat/bin/Debug/u703_518_E_9999584.cpp | DmitryTheFirst/AntiplagiatVkCup | 556d3fe2e5a630d06a7aa49f2af5dcb28667275a | [
"Apache-2.0"
] | 1 | 2015-07-04T14:45:32.000Z | 2015-07-04T14:45:32.000Z | Antiplagiat/Antiplagiat/bin/Debug/u703_518_E_9999584.cpp | DmitryTheFirst/AntiplagiatVkCup | 556d3fe2e5a630d06a7aa49f2af5dcb28667275a | [
"Apache-2.0"
] | null | null | null | Antiplagiat/Antiplagiat/bin/Debug/u703_518_E_9999584.cpp | DmitryTheFirst/AntiplagiatVkCup | 556d3fe2e5a630d06a7aa49f2af5dcb28667275a | [
"Apache-2.0"
] | null | null | null | #include <algorithm>
#include <iomanip>
#include <istream>
#include <limits>
#include <map>
#include <ostream>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// Solution template generated by caide
class Solution {
public:
const int UNKNOWN = numeric_limits<int>::min();
void solve(std::istream& in, std::ostream& out) {
int n, k;
in >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
string s;
in >> s;
if (s[0] == '?')
a[i] = UNKNOWN;
else {
istringstream is(s);
is >> a[i];
}
}
for (int i = 0; i < k; ++i) {
vector<int> u;
for (int j = i; j < n; j += k)
u.push_back(a[j]);
if (!solve(u)) {
out << "Incorrect sequence" << endl;
return;
}
for (int j = i, t = 0; t < u.size(); j += k, ++t) {
a[j] = u[t];
}
}
for (int i : a)
out << i << " ";
out << endl;
}
bool solve(vector<int>& a) {
const int n = a.size();
int first = 0;
while (first < n && a[first] == UNKNOWN)
++first;
if (first == n) {
first = -(n / 2);
for (int i = 0; i < n; ++i)
a[i] = first++;
return true;
}
vector<int> prefix = solveOneSide(first, a[first]);
if (prefix.size() != first)
return false;
for (int i = 0; i < first; ++i)
a[i] = prefix[i];
while (true) {
int next = first + 1;
while (next < n && a[next] == UNKNOWN) {
++next;
}
if (next == n) {
vector<int> suffix = solveOneSide(n - first - 1, -a[first]);
if (suffix.size() != n - first - 1)
return false;
for (int i = 0; i < n - first - 1; ++i) {
a[n - i - 1] = -suffix[i];
}
return true;
}
if (a[first] >= a[next])
return false;
vector<int> infix = solveTwoSide(a[first], next - first - 1, a[next]);
if (infix.size() != next - first - 1)
return false;
for (int i = 0; i < next - first - 1; ++i)
a[first + i + 1] = infix[i];
first = next;
}
}
vector<int> solveOneSide(int sz, int last) {
vector<int> res(sz);
if (sz == 0)
return res;
last = min(last - 1, sz / 2);
for (int i = sz - 1; i >= 0; --i)
res[i] = last--;
return res;
}
vector<int> solveTwoSide(int first, int sz, int last) {
vector<int> res(sz);
if (sz == 0 || last - first < sz + 1)
return vector<int>();
if (last <= 0) {
for (int i = sz - 1; i >= 0; --i)
res[i] = --last;
return res;
}
if (first >= 0) {
for (int i = 0; i < sz; ++i)
res[i] = ++first;
return res;
}
set<int> nums;
nums.insert(0);
for (int i = 1; nums.size() < sz; ++i) {
if (i < last)
nums.insert(i);
if (-i > first)
nums.insert(-i);
}
std::copy(nums.begin(), nums.end(), res.begin());
return res;
}
};
void solve(std::istream& in, std::ostream& out)
{
out << std::setprecision(12);
Solution solution;
solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
istream& in = cin;
ostream& out = cout;
solve(in, out);
return 0;
}
| 19.876623 | 73 | 0.516498 | [
"vector"
] |
719796ee3e9dd02b6b8127a57e89544afbfdb97c | 13,261 | cpp | C++ | ms-utils/simulation/hs/TsHsSqlitePlugin.cpp | nasa/gunns | 248323939a476abe5178538cd7a3512b5f42675c | [
"NASA-1.3"
] | 18 | 2020-01-23T12:14:09.000Z | 2022-02-27T22:11:35.000Z | ms-utils/simulation/hs/TsHsSqlitePlugin.cpp | nasa/gunns | 248323939a476abe5178538cd7a3512b5f42675c | [
"NASA-1.3"
] | 39 | 2020-11-20T12:19:35.000Z | 2022-02-22T18:45:55.000Z | ms-utils/simulation/hs/TsHsSqlitePlugin.cpp | nasa/gunns | 248323939a476abe5178538cd7a3512b5f42675c | [
"NASA-1.3"
] | 7 | 2020-02-10T19:25:43.000Z | 2022-03-16T01:10:00.000Z | /****************************************** TRICK HEADER ******************************************
@copyright Copyright 2019 United States Government as represented by the Administrator of the
National Aeronautics and Space Administration. All Rights Reserved.
PURPOSE:
(Sqlite output plugin for health & status message framework - code)
REQUIREMENTS:
()
REFERENCE:
()
ASSUMPTIONS AND LIMITATIONS:
()
LIBRARY DEPENDENCY:
((TsHsOutputPlugin.o))
PROGRAMMERS:
(
((Jeffrey Middleton) (L3) (January 2010) (Initial version))
((Wesley A. White) (Tietronix Software) (August 2011))
)
**************************************************************************************************/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <sqlite3.h>
#include "sim_services/Message/include/message_proto.h"
#include "simulation/timer/TS_timer.h"
#include "TS_hs_msg_types.h"
#include "TsHsSqlitePlugin.hh"
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Constructs a SQLite plugin object given the name of a database file to generate.
///
////////////////////////////////////////////////////////////////////////////////////////////////////
TsHsSqlitePlugin::TsHsSqlitePlugin(int id) :
TsHsOutputPlugin(id),
mFilename(""),
mFirstpass(true),
mOverwrite(true),
mTransactionOpen(false),
mDatabaseHandle(0),
mTryLockFailures(0),
mResourceLock(),
mBlocking(false)
{
pthread_mutex_init(&mResourceLock, NULL);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Destructor
////////////////////////////////////////////////////////////////////////////////////////////////////
TsHsSqlitePlugin::~TsHsSqlitePlugin()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Configure the plugin.
///
/// @return configData - contains the plugin configuration data.
////////////////////////////////////////////////////////////////////////////////////////////////////
void TsHsSqlitePlugin::configure(const TsHsPluginConfig& configData)
{
mEnabled = configData.mEnabled;
mFilename = configData.mPath;
mOverwrite = configData.mOverwrite;
mBlocking = configData.mBlocking;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Display database errors message to the console (standard error device) and close the
/// database if the error is considered fatal.
///
/// @param[in] file (--) The file where the error occurred (unused).
/// @param[in] line (--) The line number within the file mentioned above (unused).
/// @param[in] sql_error (--) The SQLite error message.
/// @param[in] fatal (--) A flag used to determine if the database should be closed.
////////////////////////////////////////////////////////////////////////////////////////////////////
void TsHsSqlitePlugin::handleSqlError(const std::string& file __attribute__((unused)), int line __attribute__((unused)), char** sql_error, bool fatal)
{
if (*sql_error != 0)
{
message_publish(MSG_ERROR, "TsHsSqlitePlugin sqlite error: %s\n", *sql_error);
sqlite3_free(*sql_error);
if (fatal)
{
sqlite3_close(mDatabaseHandle);
mTransactionOpen = false;
mDatabaseHandle = 0;
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Opens the SQLite database used for logging health and status messages. If the
/// database does not already exists, it will be created.
///
/// @return True if the open succeeds, otherwise false.
////////////////////////////////////////////////////////////////////////////////////////////////////
bool TsHsSqlitePlugin::openDatabase()
{
const int open_flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX;
if (sqlite3_open_v2(mFilename.c_str(), &mDatabaseHandle, open_flags, NULL) != SQLITE_OK)
{
message_publish(MSG_ERROR, "TsHsSqlitePlugin error opening database '%s': %s\n", mFilename.c_str(), sqlite3_errmsg(mDatabaseHandle));
sqlite3_close(mDatabaseHandle);
mDatabaseHandle = 0;
return false;
}
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Opens the SQLite database and creates the database tables used for logging
/// Health and Status messages.
///
/// @return True if the initialization succeeds, else false.
////////////////////////////////////////////////////////////////////////////////////////////////////
bool TsHsSqlitePlugin::init(void)
{
// If not enabled don't create the log file.
if (!mEnabled)
{
return true;
}
// On the first pass, remove database from previous runs
if (mFirstpass)
{
// If the system has been configured to use file_timestamped file names then create a new
// file, otherwise overwrite the existing one.
if (mOverwrite)
{
remove(mFilename.c_str());
}
else
{
mFilename += tsHsFileTimestamp();
}
mFirstpass = false;
}
// Initialize database file and create tables
if (!openDatabase())
{
return false;
}
// Create the tables and indices
// Check for NULL in case the mFirstpass block failed
if (mDatabaseHandle)
{
char* sql_error;
const char* creation_command =
"CREATE TABLE IF NOT EXISTS timestamps(id INTEGER, met INTEGER, timestamp INTEGER);"
"CREATE TABLE IF NOT EXISTS messages("
"id INTEGER PRIMARY KEY, file TEXT, line INTEGER, "
"type INTEGER, subsys TEXT, message TEXT, count INTEGER, last_time INTEGER);"
"CREATE INDEX IF NOT EXISTS time_ids ON timestamps(id);";
sqlite3_exec(mDatabaseHandle, creation_command, NULL, NULL, &sql_error);
handleSqlError(__FILE__, __LINE__, &sql_error, true);
}
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Restarts a plugin.
///
/// @return True if successful, or false if initialization failed.
////////////////////////////////////////////////////////////////////////////////////////////////////
bool TsHsSqlitePlugin::restart(void)
{
// OBCS has requested that H&S not clear the log during restarts. They put emulator health info
// in the log and they need continuity over restarts. They also continue to run during freeze.
//mFirstpass = true;
//mTryLockFailures = 0;
//mTransactionOpen = false;
//shutdown();
//return init();
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Updates the plugin
///
/// @return True if the update succeeds, else false.
////////////////////////////////////////////////////////////////////////////////////////////////////
bool TsHsSqlitePlugin::update(void)
{
if (!mEnabled)
{
return true;
}
if (!mDatabaseHandle)
{
return false;
}
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Commits any pending transactions and closes the database.
////////////////////////////////////////////////////////////////////////////////////////////////////
void TsHsSqlitePlugin::shutdown(void)
{
if (!mEnabled)
{
return;
}
if (!mDatabaseHandle)
{
return;
}
// Wait on any threads that may still be logging messages
if (pthread_mutex_lock(&mResourceLock) == 0) // 0 means lock granted
{
sqlite3_close(mDatabaseHandle);
pthread_mutex_unlock(&mResourceLock);
}
mDatabaseHandle = 0;
if (mTryLockFailures > 0)
{
message_publish(MSG_WARNING, "TsHsSqlitePlugin skipped %d messages due to mutex conflicts\n", mTryLockFailures);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Hash function used to generate database key values.
///
/// @param[in] salt (--) (unused).
/// @param[in] str (--) The characters of this string are used to calculate the hash value.
///
/// @return The hash value.
////////////////////////////////////////////////////////////////////////////////////////////////////
long long int TsHsSqlitePlugin::hashString(long long int salt __attribute__((unused)), const std::string& str)
{
long long int hh = 0;
const char* str_ptr = str.c_str();
while (*str_ptr)
{
hh = hh * 101 + static_cast<long long int>(static_cast<unsigned char>(*str_ptr));
str_ptr++;
}
return hh;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Log a health and status message to a SQLite database file.
///
/// @param[in] file (--) name of file which initiated logging the message.
/// @param[in] line (--) line of file which initiated logging the message.
/// @param[in] function (--) The name of the function logging the message (unused).
/// @param[in] type (--) the type of message (e.g. info, warning, etc.).
/// @param[in] subsys (--) the subsystem from which the message originated.
/// @param[in] met (--) the mission-elapsed time that the message was sent.
/// @param[in] timestamp (--) the unix timestamp that the message was sent.
/// @param[in] mtext (--) the message text.
///
/// @return True if successful, or false on failure.
////////////////////////////////////////////////////////////////////////////////////////////////////
bool TsHsSqlitePlugin::msg(
const std::string& file,
int line,
const std::string& function __attribute__((unused)),
TS_HS_MSG_TYPE type,
const std::string& subsys,
const TS_TIMER_TYPE& met,
unsigned long timestamp,
const std::string& mtext)
{
if (!mEnabled)
{
return true;
}
if (!mDatabaseHandle)
{
return false;
}
// Use a hash function to generate a unique database key value.
long long int msg_hash;
msg_hash = hashString(0, file);
msg_hash = 101 * msg_hash + line;
msg_hash = hashString(msg_hash, subsys);
msg_hash = hashString(msg_hash, mtext);
// This is not optimal - for new entries, we should just insert (skip the update)
const char* insert_command_template =
// insert the hash-message entry (if it's already there, carry on)
"INSERT OR IGNORE INTO messages VALUES (%lld, '%q', %d, %d, '%q', '%q', 0, %d);"
// increment the count
"UPDATE messages SET count = count + 1, last_time = %d WHERE id = %lld;"
// insert the timestamp entry
"INSERT INTO timestamps VALUES (%lld, %d, %d);";
// Fill-in the command template to produce a complete SQL command
int met_seconds = static_cast<int> (floor(met.seconds));
char* insert_command = sqlite3_mprintf(insert_command_template,
msg_hash, file.c_str(), line, type, subsys.c_str(), mtext.c_str(), met_seconds, // INSERT
met_seconds, msg_hash, // UPDATE
msg_hash, met_seconds, timestamp); // INSERT
if (mBlocking)
{
// We will wait if necessary, no messages will be lost.
if (pthread_mutex_lock(&mResourceLock) == 0) // 0 means lock granted
{
insertMessage(insert_command);
pthread_mutex_unlock(&mResourceLock);
}
}
else
{
// Don't wait. Discard message if resource conflict.
if (pthread_mutex_trylock(&mResourceLock) == 0) // 0 means lock granted
{
insertMessage(insert_command);
pthread_mutex_unlock(&mResourceLock);
sqlite3_free(insert_command);
}
else
{
mTryLockFailures++;
}
}
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Log a health and status message to a SQLite database file.
///
/// @param[in] insertCommand (--) sql command to insert message into database.
////////////////////////////////////////////////////////////////////////////////////////////////////
bool TsHsSqlitePlugin::insertMessage(char* insertCommand)
{
// todo: try catch here to ensure resource unlocks if exception
char* sql_error;
// Execute the SQL command to insert the new message into the database
sqlite3_exec(mDatabaseHandle, "BEGIN TRANSACTION;", NULL, NULL, &sql_error);
sqlite3_exec(mDatabaseHandle, insertCommand, NULL, NULL, &sql_error);
sqlite3_exec(mDatabaseHandle, "COMMIT;", NULL, NULL, &sql_error);
handleSqlError(__FILE__, __LINE__, &sql_error, false);
return true;
}
| 35.268617 | 150 | 0.517759 | [
"object"
] |
719917363cc1ba12f87671217c8af3edac3d08da | 1,536 | cpp | C++ | HeapSort.cpp | zamansabbir/DataStructure | 4df8961b2726dfdff835c111fa48b45ff2c82831 | [
"MIT"
] | 1 | 2020-08-24T19:38:10.000Z | 2020-08-24T19:38:10.000Z | HeapSort.cpp | zamansabbir/DataStructure | 4df8961b2726dfdff835c111fa48b45ff2c82831 | [
"MIT"
] | null | null | null | HeapSort.cpp | zamansabbir/DataStructure | 4df8961b2726dfdff835c111fa48b45ff2c82831 | [
"MIT"
] | null | null | null | #include <iostream>
#include<vector>
#include<climits>
int size=INT_MAX; //just a number, later initialized
int getParentIndex(int childIndex){
return (childIndex-1)/2;
}
int getLeftChildIndex(int parentIndex){
return 2*parentIndex+1;
}
int getRightChildIndex(int parentIndex){
return 2*parentIndex+2;
}
bool hasParent(int index){
return getParentIndex(index)<=0;
}
bool hasLeftChild(int index){
return getLeftChildIndex(index)<size;
}
bool hasRightChild(int index){
return getRightChildIndex(index)<size;
}
void swap(std::vector <int> &s,int index1,int index2){
int temp=s[index1];
s[index1]=s[index2];
s[index2]=temp;
}
void heapifyDown(std::vector<int> &h,int index){
//int index=0;
int smallerChildIndex=0;
while(hasLeftChild(index)){
smallerChildIndex=getLeftChildIndex(index);
if(hasRightChild(index)&& h[getRightChildIndex(index)]<h[getLeftChildIndex(index)]){
smallerChildIndex=getRightChildIndex(index);
}
if(h[index]<h[smallerChildIndex]){
break;
}
swap(h,index,smallerChildIndex);
index=smallerChildIndex;
}
}
void createMinHeap(std::vector<int> &h){
for(int i=(h.size()/2-1);i>=0;--i){
heapifyDown(h,i);
}
}
int main(){
//int a[]={12, 11, 13, 5, 6, 7};
std::vector<int> a={12, 11, 13, 5, 6, 7};
size=a.size();
createMinHeap(a);
for(auto i=a.begin();i!=a.end();++i){
std::cout<<*i<<" ";
}
std::cout<<std::endl;
return 0;
} | 23.630769 | 92 | 0.628255 | [
"vector"
] |
71a45a92cc8c171503cbd8c71d3e4c14fe3e8d38 | 24,302 | hpp | C++ | apps/openmw/mwbase/world.hpp | Bodillium/openmw | 5fdd264d0704e33b44b1ccf17ab4fb721f362e34 | [
"Unlicense"
] | null | null | null | apps/openmw/mwbase/world.hpp | Bodillium/openmw | 5fdd264d0704e33b44b1ccf17ab4fb721f362e34 | [
"Unlicense"
] | null | null | null | apps/openmw/mwbase/world.hpp | Bodillium/openmw | 5fdd264d0704e33b44b1ccf17ab4fb721f362e34 | [
"Unlicense"
] | null | null | null | #ifndef GAME_MWBASE_WORLD_H
#define GAME_MWBASE_WORLD_H
#include <vector>
#include <map>
#include <components/settings/settings.hpp>
#include "../mwworld/globals.hpp"
#include "../mwworld/ptr.hpp"
namespace Ogre
{
class Vector2;
class Vector3;
}
namespace OEngine
{
namespace Physic
{
class PhysicEngine;
}
}
namespace ESM
{
class ESMReader;
class ESMWriter;
struct Position;
struct Cell;
struct Class;
struct Potion;
struct Spell;
struct NPC;
struct CellId;
struct Armor;
struct Weapon;
struct Clothing;
struct Enchantment;
struct Book;
struct EffectList;
}
namespace MWRender
{
class Animation;
}
namespace MWMechanics
{
class Movement;
}
namespace MWWorld
{
class Fallback;
class CellStore;
class Player;
class LocalScripts;
class TimeStamp;
class ESMStore;
class RefData;
typedef std::vector<std::pair<MWWorld::Ptr,MWMechanics::Movement> > PtrMovementList;
}
namespace MWBase
{
/// \brief Interface for the World (implemented in MWWorld)
class World
{
World (const World&);
///< not implemented
World& operator= (const World&);
///< not implemented
public:
enum RenderMode
{
Render_CollisionDebug,
Render_Wireframe,
Render_Pathgrid,
Render_BoundingBoxes
};
struct DoorMarker
{
std::string name;
float x, y; // world position
};
World() {}
virtual ~World() {}
virtual void startNewGame (bool bypass) = 0;
///< \param bypass Bypass regular game start.
virtual void clear() = 0;
virtual int countSavedGameRecords() const = 0;
virtual void write (ESM::ESMWriter& writer, Loading::Listener& listener) const = 0;
virtual void readRecord (ESM::ESMReader& reader, int32_t type,
const std::map<int, int>& contentFileMap) = 0;
virtual MWWorld::CellStore *getExterior (int x, int y) = 0;
virtual MWWorld::CellStore *getInterior (const std::string& name) = 0;
virtual MWWorld::CellStore *getCell (const ESM::CellId& id) = 0;
virtual void useDeathCamera() = 0;
virtual void setWaterHeight(const float height) = 0;
virtual bool toggleWater() = 0;
virtual bool toggleWorld() = 0;
virtual void adjustSky() = 0;
virtual void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches) = 0;
virtual const MWWorld::Fallback *getFallback () const = 0;
virtual MWWorld::Player& getPlayer() = 0;
virtual MWWorld::Ptr getPlayerPtr() = 0;
virtual const MWWorld::ESMStore& getStore() const = 0;
virtual std::vector<ESM::ESMReader>& getEsmReader() = 0;
virtual MWWorld::LocalScripts& getLocalScripts() = 0;
virtual bool hasCellChanged() const = 0;
///< Has the set of active cells changed, since the last frame?
virtual bool isCellExterior() const = 0;
virtual bool isCellQuasiExterior() const = 0;
virtual Ogre::Vector2 getNorthVector (MWWorld::CellStore* cell) = 0;
///< get north vector for given interior cell
virtual void getDoorMarkers (MWWorld::CellStore* cell, std::vector<DoorMarker>& out) = 0;
///< get a list of teleport door markers for a given cell, to be displayed on the local map
virtual void worldToInteriorMapPosition (Ogre::Vector2 position, float& nX, float& nY, int &x, int& y) = 0;
///< see MWRender::LocalMap::worldToInteriorMapPosition
virtual Ogre::Vector2 interiorMapToWorldPosition (float nX, float nY, int x, int y) = 0;
///< see MWRender::LocalMap::interiorMapToWorldPosition
virtual bool isPositionExplored (float nX, float nY, int x, int y, bool interior) = 0;
///< see MWRender::LocalMap::isPositionExplored
virtual void setGlobalInt (const std::string& name, int value) = 0;
///< Set value independently from real type.
virtual void setGlobalFloat (const std::string& name, float value) = 0;
///< Set value independently from real type.
virtual int getGlobalInt (const std::string& name) const = 0;
///< Get value independently from real type.
virtual float getGlobalFloat (const std::string& name) const = 0;
///< Get value independently from real type.
virtual char getGlobalVariableType (const std::string& name) const = 0;
///< Return ' ', if there is no global variable with this name.
virtual std::string getCellName (const MWWorld::CellStore *cell = 0) const = 0;
///< Return name of the cell.
///
/// \note If cell==0, the cell the player is currently in will be used instead to
/// generate a name.
virtual void removeRefScript (MWWorld::RefData *ref) = 0;
//< Remove the script attached to ref from mLocalScripts
virtual MWWorld::Ptr getPtr (const std::string& name, bool activeOnly) = 0;
///< Return a pointer to a liveCellRef with the given name.
/// \param activeOnly do non search inactive cells.
virtual MWWorld::Ptr searchPtr (const std::string& name, bool activeOnly) = 0;
///< Return a pointer to a liveCellRef with the given name.
/// \param activeOnly do non search inactive cells.
virtual MWWorld::Ptr getPtrViaHandle (const std::string& handle) = 0;
///< Return a pointer to a liveCellRef with the given Ogre handle.
virtual MWWorld::Ptr searchPtrViaHandle (const std::string& handle) = 0;
///< Return a pointer to a liveCellRef with the given Ogre handle or Ptr() if not found
virtual MWWorld::Ptr searchPtrViaActorId (int actorId) = 0;
///< Search is limited to the active cells.
/// \todo enable reference in the OGRE scene
virtual void enable (const MWWorld::Ptr& ptr) = 0;
/// \todo disable reference in the OGRE scene
virtual void disable (const MWWorld::Ptr& ptr) = 0;
virtual void advanceTime (double hours) = 0;
///< Advance in-game time.
virtual void setHour (double hour) = 0;
///< Set in-game time hour.
virtual void setMonth (int month) = 0;
///< Set in-game time month.
virtual void setDay (int day) = 0;
///< Set in-game time day.
virtual int getDay() const = 0;
virtual int getMonth() const = 0;
virtual int getYear() const = 0;
virtual std::string getMonthName (int month = -1) const = 0;
///< Return name of month (-1: current month)
virtual MWWorld::TimeStamp getTimeStamp() const = 0;
///< Return current in-game time stamp.
virtual bool toggleSky() = 0;
///< \return Resulting mode
virtual void changeWeather(const std::string& region, unsigned int id) = 0;
virtual int getCurrentWeather() const = 0;
virtual int getMasserPhase() const = 0;
virtual int getSecundaPhase() const = 0;
virtual void setMoonColour (bool red) = 0;
virtual void modRegion(const std::string ®ionid, const std::vector<char> &chances) = 0;
virtual float getTimeScaleFactor() const = 0;
virtual void changeToInteriorCell (const std::string& cellName,
const ESM::Position& position) = 0;
///< Move to interior cell.
virtual void changeToExteriorCell (const ESM::Position& position) = 0;
///< Move to exterior cell.
virtual void changeToCell (const ESM::CellId& cellId, const ESM::Position& position, bool detectWorldSpaceChange=true) = 0;
///< @param detectWorldSpaceChange if true, clean up worldspace-specific data when the world space changes
virtual const ESM::Cell *getExterior (const std::string& cellName) const = 0;
///< Return a cell matching the given name or a 0-pointer, if there is no such cell.
virtual void markCellAsUnchanged() = 0;
virtual MWWorld::Ptr getFacedObject() = 0;
///< Return pointer to the object the player is looking at, if it is within activation range
/// Returns a pointer to the object the provided object would hit (if within the
/// specified distance), and the point where the hit occurs. This will attempt to
/// use the "Head" node, or alternatively the "Bip01 Head" node as a basis.
virtual std::pair<MWWorld::Ptr,Ogre::Vector3> getHitContact(const MWWorld::Ptr &ptr, float distance) = 0;
virtual void adjustPosition (const MWWorld::Ptr& ptr, bool force) = 0;
///< Adjust position after load to be on ground. Must be called after model load.
/// @param force do this even if the ptr is flying
virtual void fixPosition (const MWWorld::Ptr& actor) = 0;
///< Attempt to fix position so that the Ptr is no longer inside collision geometry.
virtual void deleteObject (const MWWorld::Ptr& ptr) = 0;
virtual void moveObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0;
virtual void
moveObject(const MWWorld::Ptr &ptr, MWWorld::CellStore* newCell, float x, float y, float z) = 0;
virtual void scaleObject (const MWWorld::Ptr& ptr, float scale) = 0;
virtual void rotateObject(const MWWorld::Ptr& ptr,float x,float y,float z, bool adjust = false) = 0;
virtual void localRotateObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0;
virtual MWWorld::Ptr safePlaceObject(const MWWorld::Ptr& ptr, MWWorld::CellStore* cell, ESM::Position pos) = 0;
///< place an object in a "safe" location (ie not in the void, etc).
virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false)
const = 0;
///< Convert cell numbers to position.
virtual void positionToIndex (float x, float y, int &cellX, int &cellY) const = 0;
///< Convert position to cell numbers
virtual void queueMovement(const MWWorld::Ptr &ptr, const Ogre::Vector3 &velocity) = 0;
///< Queues movement for \a ptr (in local space), to be applied in the next call to
/// doPhysics.
virtual bool castRay (float x1, float y1, float z1, float x2, float y2, float z2) = 0;
///< cast a Ray and return true if there is an object in the ray path.
virtual bool toggleCollisionMode() = 0;
///< Toggle collision mode for player. If disabled player object should ignore
/// collisions and gravity.
/// \return Resulting mode
virtual bool toggleRenderMode (RenderMode mode) = 0;
///< Toggle a render mode.
///< \return Resulting mode
virtual const ESM::Potion *createRecord (const ESM::Potion& record) = 0;
///< Create a new record (of type potion) in the ESM store.
/// \return pointer to created record
virtual const ESM::Spell *createRecord (const ESM::Spell& record) = 0;
///< Create a new record (of type spell) in the ESM store.
/// \return pointer to created record
virtual const ESM::Class *createRecord (const ESM::Class& record) = 0;
///< Create a new record (of type class) in the ESM store.
/// \return pointer to created record
virtual const ESM::Cell *createRecord (const ESM::Cell& record) = 0;
///< Create a new record (of type cell) in the ESM store.
/// \return pointer to created record
virtual const ESM::NPC *createRecord(const ESM::NPC &record) = 0;
///< Create a new record (of type npc) in the ESM store.
/// \return pointer to created record
virtual const ESM::Armor *createRecord (const ESM::Armor& record) = 0;
///< Create a new record (of type armor) in the ESM store.
/// \return pointer to created record
virtual const ESM::Weapon *createRecord (const ESM::Weapon& record) = 0;
///< Create a new record (of type weapon) in the ESM store.
/// \return pointer to created record
virtual const ESM::Clothing *createRecord (const ESM::Clothing& record) = 0;
///< Create a new record (of type clothing) in the ESM store.
/// \return pointer to created record
virtual const ESM::Enchantment *createRecord (const ESM::Enchantment& record) = 0;
///< Create a new record (of type enchantment) in the ESM store.
/// \return pointer to created record
virtual const ESM::Book *createRecord (const ESM::Book& record) = 0;
///< Create a new record (of type book) in the ESM store.
/// \return pointer to created record
virtual void update (float duration, bool paused) = 0;
virtual MWWorld::Ptr placeObject (const MWWorld::Ptr& object, float cursorX, float cursorY, int amount) = 0;
///< copy and place an object into the gameworld at the specified cursor position
/// @param object
/// @param cursor X (relative 0-1)
/// @param cursor Y (relative 0-1)
/// @param number of objects to place
virtual MWWorld::Ptr dropObjectOnGround (const MWWorld::Ptr& actor, const MWWorld::Ptr& object, int amount) = 0;
///< copy and place an object into the gameworld at the given actor's position
/// @param actor giving the dropped object position
/// @param object
/// @param number of objects to place
virtual bool canPlaceObject (float cursorX, float cursorY) = 0;
///< @return true if it is possible to place on object at specified cursor location
virtual void processChangedSettings (const Settings::CategorySettingVector& settings) = 0;
virtual bool isFlying(const MWWorld::Ptr &ptr) const = 0;
virtual bool isSlowFalling(const MWWorld::Ptr &ptr) const = 0;
virtual bool isSwimming(const MWWorld::Ptr &object) const = 0;
///Is the head of the creature underwater?
virtual bool isSubmerged(const MWWorld::Ptr &object) const = 0;
virtual bool isUnderwater(const MWWorld::CellStore* cell, const Ogre::Vector3 &pos) const = 0;
virtual bool isOnGround(const MWWorld::Ptr &ptr) const = 0;
virtual void togglePOV() = 0;
virtual void togglePreviewMode(bool enable) = 0;
virtual bool toggleVanityMode(bool enable) = 0;
virtual void allowVanityMode(bool allow) = 0;
virtual void togglePlayerLooking(bool enable) = 0;
virtual void changeVanityModeScale(float factor) = 0;
virtual bool vanityRotateCamera(float * rot) = 0;
virtual void setCameraDistance(float dist, bool adjust = false, bool override = true)=0;
virtual void setupPlayer() = 0;
virtual void renderPlayer() = 0;
/// open or close a non-teleport door (depending on current state)
virtual void activateDoor(const MWWorld::Ptr& door) = 0;
/// update movement state of a non-teleport door as specified
/// @param state see MWClass::setDoorState
/// @note throws an exception when invoked on a teleport door
virtual void activateDoor(const MWWorld::Ptr& door, int state) = 0;
virtual bool getPlayerStandingOn (const MWWorld::Ptr& object) = 0; ///< @return true if the player is standing on \a object
virtual bool getActorStandingOn (const MWWorld::Ptr& object) = 0; ///< @return true if any actor is standing on \a object
virtual bool getPlayerCollidingWith(const MWWorld::Ptr& object) = 0; ///< @return true if the player is colliding with \a object
virtual bool getActorCollidingWith (const MWWorld::Ptr& object) = 0; ///< @return true if any actor is colliding with \a object
virtual void hurtStandingActors (const MWWorld::Ptr& object, float dmgPerSecond) = 0;
///< Apply a health difference to any actors standing on \a object.
/// To hurt actors, healthPerSecond should be a positive value. For a negative value, actors will be healed.
virtual void hurtCollidingActors (const MWWorld::Ptr& object, float dmgPerSecond) = 0;
///< Apply a health difference to any actors colliding with \a object.
/// To hurt actors, healthPerSecond should be a positive value. For a negative value, actors will be healed.
virtual float getWindSpeed() = 0;
virtual void getContainersOwnedBy (const MWWorld::Ptr& npc, std::vector<MWWorld::Ptr>& out) = 0;
///< get all containers in active cells owned by this Npc
virtual void getItemsOwnedBy (const MWWorld::Ptr& npc, std::vector<MWWorld::Ptr>& out) = 0;
///< get all items in active cells owned by this Npc
virtual bool getLOS(const MWWorld::Ptr& actor,const MWWorld::Ptr& targetActor) = 0;
///< get Line of Sight (morrowind stupid implementation)
virtual float getDistToNearestRayHit(const Ogre::Vector3& from, const Ogre::Vector3& dir, float maxDist) = 0;
virtual void enableActorCollision(const MWWorld::Ptr& actor, bool enable) = 0;
virtual int canRest() = 0;
///< check if the player is allowed to rest \n
/// 0 - yes \n
/// 1 - only waiting \n
/// 2 - player is underwater \n
/// 3 - enemies are nearby (not implemented)
/// \todo Probably shouldn't be here
virtual MWRender::Animation* getAnimation(const MWWorld::Ptr &ptr) = 0;
/// \todo this does not belong here
virtual void frameStarted (float dt, bool paused) = 0;
virtual void screenshot (Ogre::Image& image, int w, int h) = 0;
/// Find default position inside exterior cell specified by name
/// \return false if exterior with given name not exists, true otherwise
virtual bool findExteriorPosition(const std::string &name, ESM::Position &pos) = 0;
/// Find default position inside interior cell specified by name
/// \return false if interior with given name not exists, true otherwise
virtual bool findInteriorPosition(const std::string &name, ESM::Position &pos) = 0;
/// Enables or disables use of teleport spell effects (recall, intervention, etc).
virtual void enableTeleporting(bool enable) = 0;
/// Returns true if teleport spell effects are allowed.
virtual bool isTeleportingEnabled() const = 0;
/// Enables or disables use of levitation spell effect.
virtual void enableLevitation(bool enable) = 0;
/// Returns true if levitation spell effect is allowed.
virtual bool isLevitationEnabled() const = 0;
/// Turn actor into werewolf or normal form.
virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf) = 0;
/// Sets the NPC's Acrobatics skill to match the fWerewolfAcrobatics GMST.
/// It only applies to the current form the NPC is in.
virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor) = 0;
virtual bool getGodModeState() = 0;
virtual bool toggleGodMode() = 0;
/**
* @brief startSpellCast attempt to start casting a spell. Might fail immediately if conditions are not met.
* @param actor
* @return true if the spell can be casted (i.e. the animation should start)
*/
virtual bool startSpellCast (const MWWorld::Ptr& actor) = 0;
virtual void castSpell (const MWWorld::Ptr& actor) = 0;
virtual void launchMagicBolt (const std::string& model, const std::string& sound, const std::string& spellId,
float speed, bool stack, const ESM::EffectList& effects,
const MWWorld::Ptr& caster, const std::string& sourceName, const Ogre::Vector3& fallbackDirection) = 0;
virtual void launchProjectile (MWWorld::Ptr actor, MWWorld::Ptr projectile,
const Ogre::Vector3& worldPos, const Ogre::Quaternion& orient, MWWorld::Ptr bow, float speed) = 0;
virtual const std::vector<std::string>& getContentFiles() const = 0;
virtual void breakInvisibility (const MWWorld::Ptr& actor) = 0;
// Are we in an exterior or pseudo-exterior cell and it's night?
virtual bool isDark() const = 0;
virtual bool findInteriorPositionInWorldSpace(MWWorld::CellStore* cell, Ogre::Vector3& result) = 0;
/// Teleports \a ptr to the closest reference of \a id (e.g. DivineMarker, PrisonMarker, TempleMarker)
/// @note id must be lower case
virtual void teleportToClosestMarker (const MWWorld::Ptr& ptr,
const std::string& id) = 0;
enum DetectionType
{
Detect_Enchantment,
Detect_Key,
Detect_Creature
};
/// List all references (filtered by \a type) detected by \a ptr. The range
/// is determined by the current magnitude of the "Detect X" magic effect belonging to \a type.
/// @note This also works for references in containers.
virtual void listDetectedReferences (const MWWorld::Ptr& ptr, std::vector<MWWorld::Ptr>& out,
DetectionType type) = 0;
/// Update the value of some globals according to the world state, which may be used by dialogue entries.
/// This should be called when initiating a dialogue.
virtual void updateDialogueGlobals() = 0;
/// Moves all stolen items from \a ptr to the closest evidence chest.
virtual void confiscateStolenItems(const MWWorld::Ptr& ptr) = 0;
virtual void goToJail () = 0;
/// Spawn a random creature from a levelled list next to the player
virtual void spawnRandomCreature(const std::string& creatureList) = 0;
/// Spawn a blood effect for \a ptr at \a worldPosition
virtual void spawnBloodEffect (const MWWorld::Ptr& ptr, const Ogre::Vector3& worldPosition) = 0;
virtual void spawnEffect (const std::string& model, const std::string& textureOverride, const Ogre::Vector3& worldPos) = 0;
virtual void explodeSpell (const Ogre::Vector3& origin, const ESM::EffectList& effects,
const MWWorld::Ptr& caster, const std::string& id, const std::string& sourceName) = 0;
virtual void activate (const MWWorld::Ptr& object, const MWWorld::Ptr& actor) = 0;
/// @see MWWorld::WeatherManager::isInStorm
virtual bool isInStorm() const = 0;
/// @see MWWorld::WeatherManager::getStormDirection
virtual Ogre::Vector3 getStormDirection() const = 0;
/// Resets all actors in the current active cells to their original location within that cell.
virtual void resetActors() = 0;
virtual bool isWalkingOnWater (const MWWorld::Ptr& actor) = 0;
};
}
#endif
| 44.185455 | 146 | 0.607728 | [
"geometry",
"render",
"object",
"vector",
"model"
] |
71ca477b416835f86b1ea7fe4ed41a5dc623bcd6 | 3,652 | hpp | C++ | src/Domain/DomainCreators/Sphere.hpp | marissawalker/spectre | afc8205e2f697de5e8e4f05e881499e05c9fd8a0 | [
"MIT"
] | null | null | null | src/Domain/DomainCreators/Sphere.hpp | marissawalker/spectre | afc8205e2f697de5e8e4f05e881499e05c9fd8a0 | [
"MIT"
] | null | null | null | src/Domain/DomainCreators/Sphere.hpp | marissawalker/spectre | afc8205e2f697de5e8e4f05e881499e05c9fd8a0 | [
"MIT"
] | null | null | null | // Distributed under the MIT License.
// See LICENSE.txt for details.
#pragma once
#include <array>
#include <cstddef>
#include <vector>
#include "Domain/Domain.hpp"
#include "Options/Options.hpp"
#include "Utilities/TMPL.hpp"
// IWYU wants to include things we definitely don't need...
// IWYU pragma: no_include <pup.h> // Not needed
// IWYU pragma: no_include <memory> // Needed in cpp file
// IWYU pragma: no_include "DataStructures/Tensor/Tensor.hpp" // Not needed
/// \cond
template <size_t Dim, typename Frame>
class DomainCreator; // IWYU pragma: keep
/// \endcond
namespace DomainCreators {
/// \ingroup DomainCreatorsGroup
/// Create a 3D Domain in the shape of a sphere consisting of six wedges
/// and a central cube. For an image showing how the wedges are aligned in
/// this Domain, see the documentation for Shell.
template <typename TargetFrame>
class Sphere : public DomainCreator<3, TargetFrame> {
public:
struct InnerRadius {
using type = double;
static constexpr OptionString help = {
"Radius of the sphere circumscribing the inner cube."};
};
struct OuterRadius {
using type = double;
static constexpr OptionString help = {"Radius of the Sphere."};
};
struct InitialRefinement {
using type = size_t;
static constexpr OptionString help = {
"Initial refinement level in each dimension."};
};
struct InitialGridPoints {
using type = std::array<size_t, 2>;
static constexpr OptionString help = {
"Initial number of grid points in [r,angular]."};
};
struct UseEquiangularMap {
using type = bool;
static constexpr OptionString help = {
"Use equiangular instead of equidistant coordinates."};
};
using options = tmpl::list<InnerRadius, OuterRadius, InitialRefinement,
InitialGridPoints, UseEquiangularMap>;
static constexpr OptionString help{
"Creates a 3D Sphere with seven Blocks.\n"
"Only one refinement level for all dimensions is currently supported.\n"
"The number of gridpoints in the radial direction can be set\n"
"independently of the number of gridpoints in the angular directions.\n"
"The number of gridpoints along the dimensions of the cube is equal\n"
"to the number of gridpoints along the angular dimensions of the "
"wedges.\n"
"Equiangular coordinates give better gridpoint spacings in the angular\n"
"directions, while equidistant coordinates give better gridpoint\n"
"spacings in the center block."};
Sphere(typename InnerRadius::type inner_radius,
typename OuterRadius::type outer_radius,
typename InitialRefinement::type initial_refinement,
typename InitialGridPoints::type initial_number_of_grid_points,
typename UseEquiangularMap::type use_equiangular_map) noexcept;
Sphere() = default;
Sphere(const Sphere&) = delete;
Sphere(Sphere&&) noexcept = default;
Sphere& operator=(const Sphere&) = delete;
Sphere& operator=(Sphere&&) noexcept = default;
~Sphere() noexcept override = default;
Domain<3, TargetFrame> create_domain() const noexcept override;
std::vector<std::array<size_t, 3>> initial_extents() const noexcept override;
std::vector<std::array<size_t, 3>> initial_refinement_levels() const
noexcept override;
private:
typename InnerRadius::type inner_radius_{};
typename OuterRadius::type outer_radius_{};
typename InitialRefinement::type initial_refinement_{};
typename InitialGridPoints::type initial_number_of_grid_points_{};
typename UseEquiangularMap::type use_equiangular_map_ = false;
};
} // namespace DomainCreators
| 35.115385 | 79 | 0.720427 | [
"shape",
"vector",
"3d"
] |
71dd6732d6ed2cd894a54c93d834b91bf9a0fae4 | 3,074 | cpp | C++ | torrentR/src/correctCafie.cpp | konradotto/TS | bf088bd8432b1e3f4b8c8c083650a30d9ef2ae2e | [
"Apache-2.0"
] | 125 | 2015-01-22T05:43:23.000Z | 2022-03-22T17:15:59.000Z | torrentR/src/correctCafie.cpp | konradotto/TS | bf088bd8432b1e3f4b8c8c083650a30d9ef2ae2e | [
"Apache-2.0"
] | 59 | 2015-02-10T09:13:06.000Z | 2021-11-11T02:32:38.000Z | torrentR/src/correctCafie.cpp | konradotto/TS | bf088bd8432b1e3f4b8c8c083650a30d9ef2ae2e | [
"Apache-2.0"
] | 98 | 2015-01-17T01:25:10.000Z | 2022-03-18T17:29:42.000Z | /* Copyright (C) 2010 Ion Torrent Systems, Inc. All Rights Reserved */
#include <Rcpp.h>
#include "RawWells.h"
#include "CafieSolver.h"
RcppExport SEXP correctCafie(
SEXP measured_in,
SEXP flowOrder_in,
SEXP keyFlow_in,
SEXP nKeyFlow_in,
SEXP cafEst_in,
SEXP ieEst_in,
SEXP droopEst_in
) {
SEXP rl = R_NilValue; // Use this when there is nothing to be returned.
char *exceptionMesg = NULL;
try {
// First do some annoying but necessary type casting on the input parameters.
// measured & nFlow
Rcpp::NumericMatrix measured_temp(measured_in);
int nWell = measured_temp.rows();
int nFlow = measured_temp.cols();
// flowOrder
Rcpp::StringVector flowOrder_temp(flowOrder_in);
char *flowOrder = strdup(flowOrder_temp(0));
int flowOrderLen = strlen(flowOrder);
// keyFlow
Rcpp::IntegerVector keyFlow_temp(keyFlow_in);
int *keyFlow = new int[keyFlow_temp.size()];
for(int i=0; i<keyFlow_temp.size(); i++) {
keyFlow[i] = keyFlow_temp(i);
}
// nKeyFlow
Rcpp::IntegerVector nKeyFlow_temp(nKeyFlow_in);
int nKeyFlow = nKeyFlow_temp(0);
// cafEst, ieEst, droopEst
Rcpp::NumericVector cafEst_temp(cafEst_in);
double cafEst = cafEst_temp(0);
Rcpp::NumericVector ieEst_temp(ieEst_in);
double ieEst = ieEst_temp(0);
Rcpp::NumericVector droopEst_temp(droopEst_in);
double droopEst = droopEst_temp(0);
if(flowOrderLen != nFlow) {
exceptionMesg = strdup("Flow order and signal should be of same length");
} else if(nKeyFlow <= 0) {
exceptionMesg = strdup("keyFlow must have length > 0");
} else {
double *measured = new double[nFlow];
Rcpp::NumericMatrix predicted(nWell,nFlow);
Rcpp::NumericMatrix corrected(nWell,nFlow);
CafieSolver solver;
solver.SetFlowOrder(flowOrder);
solver.SetCAFIE(cafEst, ieEst);
for(int well=0; well < nWell; well++) {
// Set up the input signal for the well
for(int flow=0; flow<nFlow; flow++) {
measured[flow] = measured_temp(well,flow);
}
// Initialize the sovler object and find the best CAFIE
solver.SetMeasured(nFlow, measured);
solver.Normalize(keyFlow, nKeyFlow, droopEst, false);
solver.Solve(3, true);
// Store the predicted & corrected signals
for(int flow=0; flow<nFlow; flow++) {
predicted(well,flow) = solver.GetPredictedResult(flow);
corrected(well,flow) = solver.GetCorrectedResult(flow);
}
// Store the estimated sequence
//const double *normalized_ptr = solver.GetMeasured();
//const char *seqEstimate_ptr = solver.GetSequence();
//int seqEstimateLen = strlen(seqEstimate_ptr);
}
// Build result set to be returned as a list to R.
rl = Rcpp::List::create(Rcpp::Named("predicted") = predicted,
Rcpp::Named("corrected") = corrected);
delete [] measured;
}
free(flowOrder);
delete [] keyFlow;
} catch(std::exception& ex) {
forward_exception_to_r(ex);
} catch(...) {
::Rf_error("c++ exception (unknown reason)");
}
if(exceptionMesg != NULL)
Rf_error(exceptionMesg);
return rl;
}
| 30.74 | 78 | 0.683474 | [
"object"
] |
71de2ca494cdaf88edf1c75336db9b83bc6df16f | 2,491 | cpp | C++ | libmov/test/mov-writer-subtitle.cpp | Dw9/media-server | 7de725b2e57e6c3faa9a4131b05221efd06b96a8 | [
"MIT"
] | 2,053 | 2015-01-01T12:52:12.000Z | 2022-03-31T05:02:31.000Z | libmov/test/mov-writer-subtitle.cpp | Dw9/media-server | 7de725b2e57e6c3faa9a4131b05221efd06b96a8 | [
"MIT"
] | 183 | 2017-02-25T23:08:33.000Z | 2022-03-31T04:31:22.000Z | libmov/test/mov-writer-subtitle.cpp | Dw9/media-server | 7de725b2e57e6c3faa9a4131b05221efd06b96a8 | [
"MIT"
] | 826 | 2015-02-27T06:23:28.000Z | 2022-03-31T08:11:23.000Z | #include "mov-writer.h"
#include "mov-format.h"
#include "mov-reader.h"
#include "mpeg4-aac.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
extern "C" const struct mov_buffer_t* mov_file_buffer(void);
static uint8_t s_buffer[2 * 1024 * 1024];
static int s_audio_track = -1;
static int s_video_track = -1;
static int s_pts_last = 0;
static void mov_onread(void* param, uint32_t track, const void* buffer, size_t bytes, int64_t pts, int64_t dts, int flags)
{
s_pts_last = pts;
mov_writer_t* mov = (mov_writer_t*)param;
int r = mov_writer_write(mov, track - 1, buffer, bytes, pts, dts, flags);
assert(0 == r);
}
static void mov_video_info(void* param, uint32_t track, uint8_t object, int width, int height, const void* extra, size_t bytes)
{
mov_writer_t* mov = (mov_writer_t*)param;
s_video_track = mov_writer_add_video(mov, object, width, height, extra, bytes);
}
static void mov_audio_info(void* param, uint32_t track, uint8_t object, int channel_count, int bit_per_sample, int sample_rate, const void* extra, size_t bytes)
{
mov_writer_t* mov = (mov_writer_t*)param;
s_audio_track = mov_writer_add_audio(mov, object, channel_count, bit_per_sample, sample_rate, extra, bytes);
}
void mov_writer_subtitle(const char* mp4, const char* outmp4)
{
char sbuf[128];
static const char* s_subtitles[] = {
"line 1",
"message 1",
"line 2",
"message 2",
};
FILE* rfp = fopen(mp4, "rb");
FILE* wfp = fopen(outmp4, "wb");
mov_reader_t* rmov = mov_reader_create(mov_file_buffer(), rfp);
mov_writer_t* wmov = mov_writer_create(mov_file_buffer(), wfp, 0);
struct mov_reader_trackinfo_t info = { mov_video_info, mov_audio_info };
mov_reader_getinfo(rmov, &info, wmov);
int i = 0;
int track = mov_writer_add_subtitle(wmov, MOV_OBJECT_TEXT, NULL, 0);
while (mov_reader_read(rmov, s_buffer, sizeof(s_buffer), mov_onread, wmov) > 0)
{
if (0 == (++i % 100))
{
const char* t = s_subtitles[(i / 100) % (sizeof(s_subtitles)/sizeof(s_subtitles[0]))];
assert(strlen(t) < 0xFFFF);
size_t n = strlen(t);
sbuf[0] = (n >> 8) & 0xFF;
sbuf[1] = n & 0xFF;
memcpy(sbuf + 2, t, n);
mov_writer_write(wmov, track, sbuf, n+2, s_pts_last, s_pts_last, 0);
}
}
mov_writer_destroy(wmov);
mov_reader_destroy(rmov);
fclose(rfp);
fclose(wfp);
}
| 32.350649 | 160 | 0.653553 | [
"object"
] |
71e34a66f19ae087e0bffa7656c734a70f6f8ac7 | 947 | cpp | C++ | collection/cp/Algorithm_Collection-master/test.cpp | daemonslayer/Notebook | a9880be9bd86955afd6b8f7352822bc18673eda3 | [
"Apache-2.0"
] | 1 | 2019-03-24T13:12:01.000Z | 2019-03-24T13:12:01.000Z | collection/cp/Algorithm_Collection-master/test.cpp | daemonslayer/Notebook | a9880be9bd86955afd6b8f7352822bc18673eda3 | [
"Apache-2.0"
] | null | null | null | collection/cp/Algorithm_Collection-master/test.cpp | daemonslayer/Notebook | a9880be9bd86955afd6b8f7352822bc18673eda3 | [
"Apache-2.0"
] | null | null | null | void CombinationPar(vector<string>& result, string& sample, int deep,
int n, int leftNum, int rightNum)
{
if(deep == 2*n)
{
result.push_back(sample);
return;
}
if(leftNum<n)
{
sample.push_back('(');
CombinationPar(result, sample, deep+1, n, leftNum+1, rightNum);
sample.resize(sample.size()-1);
}
if(rightNum<leftNum)
{
sample.push_back(')');
CombinationPar(result, sample, deep+1, n, leftNum, rightNum+1);
sample.resize(sample.size()-1);
}
}
vector<string> generateParenthesis(int n) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
vector<string> result;
string sample;
if(n!= 0)
CombinationPar(result, sample, 0, n, 0, 0);
return result;
}
| 30.548387 | 76 | 0.506864 | [
"vector"
] |
71e5dac5efc542b47c98e1145fad09a5deff943d | 6,569 | cpp | C++ | suite/cts/deviceTests/opengl/jni/reference/scene/flocking/FlockingScene.cpp | HelixOS/cts | 1956c3f1525d6b7bf668f1671e7c29cb6fbb9c9a | [
"Apache-2.0"
] | 3 | 2017-07-23T11:08:39.000Z | 2019-12-27T05:57:11.000Z | suite/cts/deviceTests/opengl/jni/reference/scene/flocking/FlockingScene.cpp | HelixOS/cts | 1956c3f1525d6b7bf668f1671e7c29cb6fbb9c9a | [
"Apache-2.0"
] | null | null | null | suite/cts/deviceTests/opengl/jni/reference/scene/flocking/FlockingScene.cpp | HelixOS/cts | 1956c3f1525d6b7bf668f1671e7c29cb6fbb9c9a | [
"Apache-2.0"
] | 2 | 2019-05-20T07:45:47.000Z | 2019-12-27T05:57:15.000Z | /*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
#include "FlockingScene.h"
#include "WaterMeshNode.h"
#include <cstdlib>
#include <cmath>
#include <Trace.h>
#include <graphics/PerspectiveMeshNode.h>
#include <graphics/PerspectiveProgram.h>
#include <graphics/GLUtils.h>
#include <graphics/Matrix.h>
#include <graphics/Mesh.h>
#include <graphics/ProgramNode.h>
#include <graphics/TransformationNode.h>
FlockingScene::FlockingScene(int width, int height) :
Scene(width, height), mMainProgram(NULL), mWaterProgram(NULL) {
for (int i = 0; i < NUM_BOIDS; i++) {
// Generate a boid with a random position. (-50, 50)
float x = (rand() % 101) - 50.0f;
float y = (rand() % 101) - 50.0f;
mBoids[i] = new Boid(x, y);
}
}
bool FlockingScene::setUpPrograms() {
// Main Program
const char* vertex = GLUtils::openTextFile("vertex/perspective");
const char* fragment = GLUtils::openTextFile("fragment/perspective");
if (vertex == NULL || fragment == NULL) {
return false;
}
GLuint programId = GLUtils::createProgram(&vertex, &fragment);
delete[] vertex;
delete[] fragment;
if (programId == 0) {
return false;
}
mMainProgram = new PerspectiveProgram(programId);
// Water Program
vertex = GLUtils::openTextFile("vertex/water");
fragment = GLUtils::openTextFile("fragment/water");
if (vertex == NULL || fragment == NULL) {
return false;
}
programId = GLUtils::createProgram(&vertex, &fragment);
delete[] vertex;
delete[] fragment;
if (programId == 0) {
return false;
}
mWaterProgram = new PerspectiveProgram(programId);
return true;
}
Matrix* FlockingScene::setUpModelMatrix() {
return new Matrix();
}
Matrix* FlockingScene::setUpViewMatrix() {
// Position the eye in front of the origin.
float eyeX = 0.0f;
float eyeY = 0.0f;
float eyeZ = 10.0f;
// We are looking at the origin
float centerX = 0.0f;
float centerY = 0.0f;
float centerZ = 0.0f;
// Set our up vector.
float upX = 0.0f;
float upY = 1.0f;
float upZ = 0.0f;
// Set the view matrix.
return Matrix::newLookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);
}
Matrix* FlockingScene::setUpProjectionMatrix(float width, float height) {
// Create a new perspective projection matrix. The height will stay the same
// while the width will vary as per aspect ratio.
mDisplayRatio = width / height;
// Set board dimensions
mBoardHeight = 1000.0f;
mBoardWidth = mDisplayRatio * mBoardHeight;
float left = -mDisplayRatio;
float right = mDisplayRatio;
float bottom = -1.0f;
float top = 1.0f;
float near = 8.0f;
float far = 12.0f;
return Matrix::newFrustum(left, right, bottom, top, near, far);
}
bool FlockingScene::setUpTextures() {
SCOPED_TRACE();
mTextureIds.add(GLUtils::loadTexture("texture/fish_dark.png"));
mTextureIds.add(GLUtils::loadTexture("texture/background.png"));
mTextureIds.add(GLUtils::loadTexture("texture/water1.png"));
mTextureIds.add(GLUtils::loadTexture("texture/water2.png"));
return true;
}
bool FlockingScene::setUpMeshes() {
SCOPED_TRACE();
mMeshes.add(GLUtils::loadMesh("mesh/fish.cob"));
mMeshes.add(GLUtils::loadMesh("mesh/plane.cob"));
return true;
}
bool FlockingScene::tearDown() {
SCOPED_TRACE();
for (int i = 0; i < NUM_BOIDS; i++) {
delete mBoids[i];
}
delete mMainProgram;
delete mWaterProgram;
return Scene::tearDown();
}
bool FlockingScene::updateSceneGraphs(int frame) {
const float MAIN_SCALE = 1.25f; // Scale up as the camera is far away.
const float LIMIT_X = mBoardWidth / 2.0f;
const float LIMIT_Y = mBoardHeight / 2.0f;
ProgramNode* mainSceneGraph = new ProgramNode(*mMainProgram);
mSceneGraphs.add(mainSceneGraph);
// Bottom
Matrix* transformMatrix = Matrix::newScale(MAIN_SCALE * mDisplayRatio, MAIN_SCALE, 0.0f);
TransformationNode* transformNode = new TransformationNode(transformMatrix);
mainSceneGraph->addChild(transformNode);
MeshNode* meshNode = new PerspectiveMeshNode(mMeshes[1], mTextureIds[1]);
transformNode->addChild(meshNode);
// Boids
const float MARGIN = 30.0f; // So the fish dont disappear and appear at the edges.
for (int i = 0; i < NUM_BOIDS; i++) {
Boid* b = mBoids[i];
b->flock((const Boid**) &mBoids, NUM_BOIDS, i, LIMIT_X + MARGIN, LIMIT_Y + MARGIN);
Vector2D* pos = &(b->mPosition);
Vector2D* vel = &(b->mVelocity);
// Normalize to (-1,1)
float x = pos->mX / (LIMIT_X * BOID_SCALE) * mDisplayRatio;
float y = pos->mY / (LIMIT_Y * BOID_SCALE);
const float SCALE = BOID_SCALE * MAIN_SCALE;
transformMatrix = Matrix::newScale(SCALE, SCALE, SCALE);
transformMatrix->translate(x, y, 1.0f);
transformMatrix->rotate(atan2(vel->mY, vel->mX) + M_PI, 0, 0, 1);
transformNode = new TransformationNode(transformMatrix);
mainSceneGraph->addChild(transformNode);
meshNode = new PerspectiveMeshNode(mMeshes[0], mTextureIds[0]);
transformNode->addChild(meshNode);
}
ProgramNode* waterSceneGraph = new ProgramNode(*mWaterProgram);
mSceneGraphs.add(waterSceneGraph);
// Top
transformMatrix = Matrix::newScale(MAIN_SCALE * mDisplayRatio, MAIN_SCALE, 1.0f);
transformMatrix->translate(0, 0, 0.1f);
transformNode = new TransformationNode(transformMatrix);
waterSceneGraph->addChild(transformNode);
meshNode = new WaterMeshNode(mMeshes[1], frame, mTextureIds[2], mTextureIds[3]);
transformNode->addChild(meshNode);
return true;
}
bool FlockingScene::draw() {
SCOPED_TRACE();
drawSceneGraph(0); // Draw fish and pond bottom
// Use blending.
glEnable (GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
drawSceneGraph(1); // Draw water
glDisable(GL_BLEND);
return true;
}
| 33.860825 | 100 | 0.671792 | [
"mesh",
"vector"
] |
71f0137ee955f3e7498546d4b1855099cda038f0 | 474 | cpp | C++ | profiler.cpp | KerryL/utilities | f5052e86a8c017fa0a0d9f5932d0e5118b5dc1ab | [
"MIT"
] | null | null | null | profiler.cpp | KerryL/utilities | f5052e86a8c017fa0a0d9f5932d0e5118b5dc1ab | [
"MIT"
] | null | null | null | profiler.cpp | KerryL/utilities | f5052e86a8c017fa0a0d9f5932d0e5118b5dc1ab | [
"MIT"
] | null | null | null | // File: profiler.cpp
// Date: 4/17/2013
// Auth: K. Loux
// Desc: Profiler object for analyzing applications. Note: This is NOT thread-safe!
// Local headers
#include "profiler.h"
#ifdef PROFILE
uint64_t Profiler::startTime;
Profiler::NameTimeMap Profiler::frequencies;
std::unordered_map<std::thread::id, std::stack<Profiler::FunctionTimePair>> Profiler::entryTimes;
std::mutex Profiler::entryTimesMutex;
std::mutex Profiler::frequenciesMutex;
#endif// PROFILE
| 24.947368 | 97 | 0.748945 | [
"object"
] |
71f1f605f946671d169427a4bba39fb019371c59 | 3,807 | cpp | C++ | egonet.cpp | fyabc/SubgraphQuery | d60b92d7773f8316ee15d94b8f3c47b528875257 | [
"MIT"
] | 3 | 2016-07-16T04:08:44.000Z | 2018-05-11T01:31:47.000Z | egonet.cpp | fyabc/SubgraphQuery | d60b92d7773f8316ee15d94b8f3c47b528875257 | [
"MIT"
] | null | null | null | egonet.cpp | fyabc/SubgraphQuery | d60b92d7773f8316ee15d94b8f3c47b528875257 | [
"MIT"
] | 1 | 2019-03-18T11:40:43.000Z | 2019-03-18T11:40:43.000Z | //
// Created by fanyang on 7/20/2016.
//
#include "graph.h"
#include "utils.h"
#include <random>
using namespace std;
unique_ptr<Graph> Graph::extractEgonet(std::size_t ego, double chooseRate, bool containEgo) const {
size_t k = degree(ego) + 1;
unique_ptr<Graph> result(new Graph(containEgo ? k : k - 1));
uniform_real_distribution<double> distribution(0.0, 1.0);
default_random_engine engine;
const auto& egoAdj = getAdj(ego);
unordered_map<size_t, size_t> verticesMap;
size_t currentIndex;
if (containEgo) {
verticesMap[ego] = 0;
currentIndex = 1;
}
else {
currentIndex = 0;
}
for (auto u: egoAdj) {
verticesMap[u] = currentIndex;
if (containEgo)
result->addEdge(0, currentIndex);
++currentIndex;
}
for (auto u: egoAdj) {
for (auto v: getAdj(u)) {
if (u > v)
continue;
if (egoAdj.find(v) != egoAdj.end()) {
if (distribution(engine) <= chooseRate)
result->addEdge(verticesMap[u], verticesMap[v]);
}
}
}
return result;
}
void helpSplit(size_t u, Graph& Q, vector<Graph::DecomposeTree2Node> &decompose, vector<bool>& visited, bool first = false) {
visited[u] = true;
Graph::DecomposeTree2Node node;
auto nextIndex = decompose.size();
if (Q.degree(u) == 0) {
node.vertices = {0, u};
node.children = {};
node.annotatedVertices = {-1, -1};
node.annotatedEdges = {-1, -1};
node.bNodeIndexes = {0};
// it annotate previous root node.
for (auto it = decompose.rbegin(); it != decompose.rend(); ++it) {
if (it->bNodeIndexes.size() == 1) {
it->children.push_back(nextIndex);
it->annotatedVertices[0] = nextIndex;
break;
}
}
decompose.push_back(std::move(node));
return;
}
auto v = *(Q.getAdj(u).begin());
Q.removeEdge(u, v);
node.vertices = {0, u, v};
node.children = {};
node.annotatedVertices = {-1, -1, -1};
node.annotatedEdges = {-1, -1, -1};
node.bNodeIndexes = {0, 1};
if (first) {
node.bNodeIndexes = {0};
// it annotates previous root node.
for (auto it = decompose.rbegin(); it != decompose.rend(); ++it) {
if (it->bNodeIndexes.size() == 1) {
it->children.push_back(nextIndex);
it->annotatedVertices[0] = nextIndex;
break;
}
}
}
else {
node.bNodeIndexes = {0, 1};
// it annotates previous node which contains (0, u).
for (auto it = decompose.rbegin(); it != decompose.rend(); ++it) {
if (it->vertices.size() == 3 && (it->vertices[1] == u || it->vertices[2] == u)) {
it->children.push_back(nextIndex);
if (it->vertices[1] == u)
it->annotatedEdges[0] = nextIndex;
else
it->annotatedEdges[2] = nextIndex;
break;
}
}
}
decompose.push_back(node);
if (Q.degree(u) > 0)
helpSplit(u, Q, decompose, visited);
if (Q.degree(v) > 0)
helpSplit(v, Q, decompose, visited);
else
visited[v] = true;
}
bool Graph::decomposeEgonet(std::vector<Graph::DecomposeTree2Node> &decompose) const {
if (haveK4())
return false;
decompose.clear();
auto copy = *this;
for (size_t i = 1; i < N; ++i)
copy.removeEdge(0, i);
vector<bool> visited(N, false);
for (size_t u = 1; u < N; ++u) {
if (visited[u])
continue;
helpSplit(u, copy, decompose, visited, true);
}
return true;
}
| 24.882353 | 125 | 0.525348 | [
"vector"
] |
71f621e181302f1f3e4f069bfc2681413c961f66 | 25,943 | cpp | C++ | src/OptimizeProblem.cpp | efocht/hpcg-ve-open | 73dfcef70ad3dea32329264e035a602523ca1cf7 | [
"BSD-3-Clause"
] | 1 | 2022-02-12T03:22:50.000Z | 2022-02-12T03:22:50.000Z | src/OptimizeProblem.cpp | efocht/hpcg-ve-open | 73dfcef70ad3dea32329264e035a602523ca1cf7 | [
"BSD-3-Clause"
] | null | null | null | src/OptimizeProblem.cpp | efocht/hpcg-ve-open | 73dfcef70ad3dea32329264e035a602523ca1cf7 | [
"BSD-3-Clause"
] | null | null | null |
//@HEADER
// ***************************************************
//
// HPCG: High Performance Conjugate Gradient Benchmark
//
// Contact:
// Michael A. Heroux ( maherou@sandia.gov)
// Jack Dongarra (dongarra@eecs.utk.edu)
// Piotr Luszczek (luszczek@eecs.utk.edu)
//
// Erich Focht : Version optimized for SX-Aurora
//
// ***************************************************
//@HEADER
/*!
@file OptimizeProblem.cpp
HPCG routine
*/
#include "OptimizeProblem.hpp"
#include <stdio.h>
#include <cstdlib>
#ifndef HPCG_NO_MPI
#include <mpi.h>
#endif
#if defined(HPCG_DEBUG) || defined(HPCG_DETAILED_DEBUG)
//EF//#include <iostream>
//EF//#include <mpi.h>
#include <fstream>
using namespace std;
using std::endl;
#include "hpcg.hpp"
#endif
#include <iostream>
#include <iomanip>
using namespace std;
#ifdef HPCG_DEBUG
#include <fstream>
static int first_call = 1;
#endif
static int mpi_rank;
extern "C"{
void dgthr_(const local_int_t* n, const double* x, double* px, const local_int_t* p);
void ssctr_(local_int_t* n, local_int_t* x, local_int_t* indx, local_int_t* y);
void vhcallVE_Hyperplane(local_int_t nrows, int maxNonzerosInRow, local_int_t *mtxIndL_, local_int_t *nonzerosInRow,
int *icolor);
void vhcallVE_GetPerm(local_int_t n, int maxcolor, int *icolor, local_int_t *perm, local_int_t *icptr);
#ifdef FTRACE
int ftrace_region_begin(const char *id);
int ftrace_region_end(const char *id);
#endif
}
static void Optimize_Hyperplane(SparseMatrix & A)
{
OPT* opt = (OPT *)A.optimizationData;
ELL* ell = opt->ell;
local_int_t n = A.localNumberOfRows;
local_int_t maxNonzerosInRow = ell->m + 1;
local_int_t *icolor = opt->icolor;
///////////////////////////////////////////////////////
// Hyperplane method
///////////////////////////////////////////////////////
#ifdef VHCALL
vhcallVE_Hyperplane(n, maxNonzerosInRow, A.mtxIndL[0], A.nonzerosInRow, icolor);
#else
for(local_int_t i=0; i<n; i++) icolor[i] = 0; // initialization
for(local_int_t i=0; i<n; i++){
local_int_t m=0;
#pragma _NEC novector
for(local_int_t jj=0; jj<A.nonzerosInRow[i]; jj++){
local_int_t j = *(A.mtxIndL[i]+jj);
if (j<i && m<icolor[j]) m=icolor[j];
}
icolor[i]=m+1;
}
// Hyperplanes lead to colors starting with 1.
// Make color numbers start with 0.
for(local_int_t i=0; i<n;i++)
icolor[i]--;
#endif /* VHCALL */
}
//-------------------------------------------------
//-------------------------------------------------
//-------------------------------------------------
static void Optimize_Store_ELL_L_U_halo(SparseMatrix & A)
{
OPT* opt = (OPT *)A.optimizationData;
ELL* ell = opt->ell;
local_int_t n = A.localNumberOfRows;
local_int_t maxNonzerosInRow = ell->m + 1;
local_int_t *icolor = opt->icolor;
local_int_t m = ell->m;
local_int_t maxcolor = opt->maxcolor;
local_int_t *icptr = opt->icptr;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
// Store the sparse matrix A in ELL format and the HALO matrix //
// (The sparse matrix A is permuted.) //
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
local_int_t lda = ell->lda = n;
HALO* halo = opt->halo;
#ifndef HPCG_NO_MPI
local_int_t nh = halo->nh = A.numberOfExternalValues;
#else
local_int_t nh = halo->nh = 0;
#endif
local_int_t *rows = halo->rows = new local_int_t[nh + maxcolor+1 + 2*maxcolor];
local_int_t *hcptr = halo->hcptr = rows + nh;
local_int_t *color_mL = opt->color_mL = hcptr + maxcolor + 1;
local_int_t *color_mU = opt->color_mU = color_mL + maxcolor;
//local_int_t *itmp = new local_int_t[3*n+2*nh]; // array for temporary data
local_int_t itmp[3*n+2*nh];
local_int_t* colIndL = itmp; // colindex full or lower matrix
local_int_t* colIndU = colIndL + n; // coll index upper matrix
local_int_t* hrows = colIndU + n; // flag marking halo rows
local_int_t *hcolor = hrows + n; // length: nh
local_int_t* colIndH = hcolor + nh; // coll index halo matrix, length nh
#ifdef FTRACE
ftrace_region_begin("LUH_1");
#endif
/*
Count L,U and Halo column widths the new matrix after reordering.
The maximum values are used to set the dimensions of the matrices.
*/
for(local_int_t i=0; i<n; i++) {
colIndL[i]=0;
colIndU[i]=0;
hrows[i]=0;
}
if (m < 254 && n < (1<<24)) { // for small m we know we can fold the value
for(local_int_t jj=0; jj<maxNonzerosInRow; jj++){
#pragma _NEC ivdep
for(local_int_t i=0; i<n; i++){
local_int_t ijj = i*maxNonzerosInRow+jj; // Get the index of the NNZ element in A. Require contiguous arrays HPCG option.
local_int_t j = A.mtxIndL[0][ijj]; // Get the column of that NNZ element
if (j < 0) continue;
local_int_t inew = opt->perm0[i]; // inew = destination row index in ELL of the current row in A.
if (j >= n) { // if j>=n, then j points to elem in Halo region.
A.mtxIndL[0][ijj] |= (hrows[inew]<<24);
hrows[inew]++;
} else if ( opt->perm0[j] > inew ){ // if jnew > inew (after reorder), then j points to elem in Upper region.
A.mtxIndL[0][ijj] |= (colIndU[i]<<24);
colIndU[i]++;
} else if ( opt->perm0[j] < inew ) { // if jnew < inew (after reorder), then j points to elem in Lower region
A.mtxIndL[0][ijj] |= (colIndL[i]<<24);
colIndL[i]++;
}
}
}
} else {
for(local_int_t jj=0; jj<maxNonzerosInRow; jj++){
#pragma _NEC ivdep
for(local_int_t i=0; i<n; i++){
local_int_t ijj = i*maxNonzerosInRow+jj;
local_int_t j = A.mtxIndL[0][ijj];
if (j < 0) continue;
local_int_t inew = opt->perm0[i];
if (j >= n) { // if j>=n then j points to neighbor region.
hrows[inew]++;
} else if ( opt->perm0[j] > inew ){ // jnew > inew
colIndU[i]++;
} else if ( opt->perm0[j] < inew ) { // jnew < inew
colIndL[i]++;
}
}
}
}
//assert(A.localNumberOfNonzeros == anonzeros + hnonzeros);
#ifdef FTRACE
ftrace_region_end("LUH_1");
ftrace_region_begin("LUH_2");
#endif
/* Count rows in halo matrix that have at least 1 element.
Post: max_indH is the maximum column width of the halo.
nhrows is the number of halo matrix rows with at least 1 element. Confusing this with nh leads to wrong hcptr[]
rows[i] contains the 'source' index corresponds to in the already reordered ELL matrix of the ith row in the ELL halo matrix.
*/
local_int_t nhrows = 0, max_indH = 0;
for (local_int_t inew=0; inew<n; inew++) {
if (hrows[inew] > 0) {
rows[nhrows] = inew;
nhrows++;
if (hrows[inew] > max_indH)
max_indH = hrows[inew];
}
}
// this is the number of halo matrix rows!
// confusing this with nh leads to wrong hcptr[]
local_int_t nah = halo->nah = nhrows;
/*
Post
hrows: the ith value of hrows contains the index of rows.
Note: rows and hrows work like perm and iperm.
*/
for(local_int_t ih=0; ih<nah; ih++){
local_int_t inew = rows[ih];
hrows[inew] = ih;
hcolor[ih] = icolor[opt->iperm0[inew]]; // Rows in the halo have the same color as the original.
}
for (local_int_t ic=0; ic<=maxcolor; ic++)
hcptr[ic] = 0;
/* Determine the width of Upper and Lower part of the matrix for each color.
Post:
color_mL: contains the max width of each color of the ELL_L
color_mU: contains the max width of each color of the ELL_U
max_indL: is the max width of ELL_L
max_indU: is the max width of ELL_U
*/
int max_indL = 0, max_indU = 0;
for (local_int_t ic=0; ic<maxcolor; ic++) {
local_int_t ics = icptr[ic];
local_int_t ice = icptr[ic+1];
int maxL = 0, maxU = 0;
for (local_int_t i=ics; i<ice; i++) {
int wL = colIndL[opt->iperm0[i]];
int wU = colIndU[opt->iperm0[i]];
if (wL > maxL) maxL = wL;
if (wU > maxU) maxU = wU;
}
color_mL[ic] = maxL;
color_mU[ic] = maxU;
if (color_mL[ic] > max_indL)
max_indL = color_mL[ic];
if (color_mU[ic] > max_indU)
max_indU = color_mU[ic];
}
local_int_t mL = ell->mL = max_indL;
local_int_t mU = ell->mU = max_indU;
local_int_t mh = halo->mh = max_indH;
local_int_t ldah = halo->ldah = nah;
m = ell->m = mL + mU;
//if (mpi_rank == 0) {
// cout<<" color_mU (n="<<n<<")"<<endl;
// for (local_int_t ic=0; ic<maxcolor; ic++)
// cout<<fixed<<setw(5)<<ic<<" color_mL="<<setw(4)<<opt->color_mL[ic]
// <<" color_mU="<<opt->color_mU[ic]<<" nc="<<icptr[ic+1]-icptr[ic]
// << endl;
//}
#ifdef FTRACE
ftrace_region_end("LUH_2");
ftrace_region_begin("LUH_3");
#endif
if (nah > 5000) {
int hhtmp[256*(maxcolor)];
for (int i=0; i<256*maxcolor; i++)
hhtmp[i] = 0;
#pragma _NEC ivdep
for (local_int_t ih=0; ih<nah; ih++) {
int bin = ih % 256;
int col = hcolor[ih];
hhtmp[bin*maxcolor+col]++;
}
for (int i=0; i<256; i++)
for (int ic=0; ic<maxcolor;ic++)
#pragma _NEC ivdep
hcptr[ic+1] += hhtmp[i*maxcolor+ic];
} else {
for (local_int_t ih=0; ih<nah; ih++)
hcptr[hcolor[ih]+1]++;
}
/* Post
hcptr: contains the index of the first row to each color in the halo matrix. */
for (local_int_t ic=1; ic<=maxcolor; ic++)
hcptr[ic] += hcptr[ic-1];
#ifdef FTRACE
ftrace_region_end("LUH_3");
ftrace_region_begin("LUH_4");
#endif
if (m != mL + mU) {
cout<<"!!! m != mL + mU"<<endl<<flush;
m = ell->m = mL+mU;
}
// we don't need icolor any more
delete [] icolor;
ell->a = new double[lda*(mL+mU) + nah*mh + nah]; // allocate multiple arrays in one step
double *ah = halo->ah = ell->a + lda*(mL+mU);
halo->v = ah + nah*mh;
ell->ja = new local_int_t[lda*(mL+mU) + nah*mh]; // allocate multiple arrays in one step
local_int_t *jah = halo->jah = ell->ja + lda*(mL+mU);
// Initialization start: values and col. index of Lower, Upper and Halo
for(local_int_t j=0; j<mL+mU; j++){
for(local_int_t i=0; i<n; i++){
ell->a[i+lda*j] = 0;
ell->ja[i+lda*j] = i; // 0 origin
}
}
#pragma omp parallel for
for(local_int_t jh=0; jh<mh; jh++){
for(local_int_t ih=0; ih<nah; ih++){
halo->ah[ih+ldah*jh] = 0;
halo->jah[ih+ldah*jh] = ih; // 0 origin
}
}
#ifdef FTRACE
ftrace_region_end("LUH_4");
ftrace_region_begin("LUH_5");
#endif
for(local_int_t i=0; i<n; i++) {
colIndL[i]=0;
colIndU[i]=0;
}
for(local_int_t ih=0; ih<nah; ih++)
colIndH[ih] = 0;
// Initialization end
if (maxNonzerosInRow >= 254 || n > (1<<24)) {
for(local_int_t jj=0; jj<maxNonzerosInRow; jj++){
#pragma _NEC ivdep
for(local_int_t i=0; i<n; i++){
local_int_t ijj = i*maxNonzerosInRow+jj;
if ( jj<A.nonzerosInRow[i] ){
//local_int_t j = *(A.mtxIndL[i]+jj);
//double aval = *(A.matrixValues[i]+jj);
local_int_t j = A.mtxIndL[0][ijj];
double aval = A.matrixValues[0][ijj];
local_int_t inew = opt->perm0[i];
local_int_t jnew;
if (j<n) { // only local elements
jnew = opt->perm0[j];
if ( jnew>inew ){
// upper non-diagonal part of the sparse matrix A
local_int_t kU = colIndU[i] + mL;
colIndU[i]++;
ell->ja[inew+lda*kU] = jnew; // 0 origin
ell->a[inew+lda*kU] = aval;
} else if( jnew<inew ) {
// lower non-diagonal part of the sparse matrix A
local_int_t kL = colIndL[i];
colIndL[i]++;
ell->ja[inew+lda*kL] = jnew; // 0 origin
ell->a[inew+lda*kL] = aval;
} else { // diagonal part of the sparse matrix A
opt->diag[inew] = aval;
opt->idiag[inew] = 1/aval;
}
} else { // if j>=n then j points neighbor region.
jnew = j;
local_int_t ih = hrows[inew];
local_int_t kh = colIndH[ih];
colIndH[ih]++;
halo->jah[ih+ldah*kh] = j - n; // 0 origin
halo->ah[ih+ldah*kh] = aval;
}
}
}
}
} else { // m < 254
#pragma _NEC ivdep
for(local_int_t ijj=0; ijj<n*maxNonzerosInRow; ijj++){ // ijj = 'nnz' / element of the matrix
local_int_t i = ijj / maxNonzerosInRow; // i = row index.
local_int_t jj = ijj % maxNonzerosInRow; // jj = ELL column
local_int_t j = A.mtxIndL[0][ijj]; // j = colum_index of ijj
if (j >= 0) {
local_int_t k = (j >> 24);
j = j & 0xffffff;
A.mtxIndL[0][ijj] = j;
double aval = A.matrixValues[0][ijj];
local_int_t inew = opt->perm0[i];
local_int_t jnew;
if (j<n) { // only local elements
jnew = opt->perm0[j];
if ( jnew>inew ){
// upper non-diagonal part of the sparse matrix A
local_int_t kU = k + mL;
ell->ja[inew+lda*kU] = jnew; // 0 origin
ell->a[inew+lda*kU] = aval;
} else if( jnew<inew ) {
// lower non-diagonal part of the sparse matrix A
local_int_t kL = k;
ell->ja[inew+lda*kL] = jnew; // 0 origin
ell->a[inew+lda*kL] = aval;
} else { // diagonal part of the sparse matrix A
opt->diag[inew] = aval;
opt->idiag[inew] = 1/aval;
}
} else { // if j>=n then j points neighbor region.
jnew = j;
local_int_t ih = hrows[inew];
local_int_t kh = k;
halo->jah[ih+ldah*kh] = j - n; // 0 origin
halo->ah[ih+ldah*kh] = aval;
}
}
}
}
#ifdef FTRACE
ftrace_region_end("LUH_5");
#endif
#if HPCG_DEBUG
if (mpi_rank==0 && n<520) {
cout<<"Matrix A (n="<<n<<", mU="<<mU<<", mL="<<mL<<")"<<endl;
for(int i=0; i<n; i++) {
cout<<" i="<<fixed<<setw(3)<<i<<" ";
for(int j=0; j<mL+mU; j++) {
int jj=ell->ja[i+lda*j];
cout<<fixed<<setw(8);
if (jj>n) cout<<"["<<jj<<"]";
else cout<<jj<<" ";
}
cout<<endl<<" ";
for(int j=0; j<m; j++)
cout<<setprecision(1)<<scientific<<ell->a[i+lda*j]<<" ";
cout<<endl<<endl;
}
}
if (mpi_rank==0 && n<520) {
cout<<"Matrix AH (n="<<n<<", nh="<<nh<<")"<<endl;
for(int ih=0; ih<nah; ih++) {
cout<<" ih="<<fixed<<setw(3)<<ih<<" ";
for(int jh=0; jh<mh; jh++)
cout<<fixed<<setw(7)<<halo->jah[ih+ldah*jh]<<" ";
cout<<endl<<"r="<<fixed<<setw(3)<<rows[ih]<<" c="<<hcolor[ih]<<" ";
for(int jh=0; jh<mh; jh++)
cout<<setprecision(1)<<scientific<<halo->ah[ih+ldah*jh]<<" ";
cout<<endl<<endl;
}
}
if (mpi_rank==0 && n<520) {
cout<<"hcptr: (n="<<n<<")"<<endl;
for(int ic=0; ic<maxcolor+1; ic++) {
cout<<" ic="<<fixed<<setw(3)<<ic<<" hcptr="<<fixed<<setw(5)<<hcptr[ic]<<endl;
}
}
if (mpi_rank==0 && n<520) {
cout<<"elementsToSend (n="<<n<<", num="<<A.totalToBeSent<<")"<<endl;
for(int ih=0; ih<A.totalToBeSent; ih++) {
cout<<" ih="<<fixed<<setw(3)<<ih<<" row="<<fixed<<setw(5)<<A.elementsToSend[ih]<<endl;
}
}
#endif
}
int _CheckDone(SparseMatrix &A)
{
OPT* opt = (OPT*)(A.optimizationData);
ELL* ell = opt->ell;
if (ell->a == nullptr) {
Optimize_Store_ELL_L_U_halo(A);
}
return 0;
}
void Optimize_CheckDone(SparseMatrix &A)
{
vcycle(_CheckDone, A);
}
void Optimize_ReplaceMatrixDiagonal(SparseMatrix &A, double *dv)
{
OPT* opt = (OPT*)(A.optimizationData);
ELL* ell = opt->ell;
if (ell->a == nullptr) {
cout<<"checkdone in ReplaceMatrixDiagonal for n=" << ell->n << endl;
Optimize_CheckDone(A);
}
for (local_int_t i=0; i<A.localNumberOfRows; ++i) {
local_int_t inew = opt->perm0[i];
double d = dv[i];
opt->diag[inew] = d;
opt->idiag[inew] = 1.0/d;
}
}
/*!
Optimizes the data structures used for CG iteration to increase the
performance of the benchmark version of the preconditioned CG algorithm.
@param[inout] A The known system matrix, also contains the MG hierarchy in attributes Ac and mgData.
@param[inout] data The data structure with all necessary CG vectors preallocated
@param[inout] b The known right hand side vector
@param[inout] x The solution vector to be computed in future CG iteration
@param[inout] xexact The exact solution vector
@return returns 0 upon success and non-zero otherwise
@see GenerateGeometry
@see GenerateProblem
*/
int OptimizeProblem(SparseMatrix & A, CGData & data, Vector & b, Vector & x, Vector & xexact) {
// This function can be used to completely transform any part of the data structures.
// Right now it does nothing, so compiling with a check for unused variables results in complaints
//EF////EF Test
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
//EF//if (mpi_rank == 0) matfile.open("matrix.dat");
#ifdef FTRACE
ftrace_region_begin("vcycle_GenerateOPT");
#endif
vcycle(GenerateOPT_STRUCT, A);
#ifdef FTRACE
ftrace_region_end("vcycle_GenerateOPT");
#endif
//EF Test
//EF//vcycle(Optimize_CheckDone, A);
// Set the pointers of diagonal elements
vcycle(SetDiagonalPointer, A);
// Set the permuted f2cOperator
vcycle(SetF2cOperator, A);
// Set communication table corresponding to the permuted matrix
vcycle(SetCommTable, A);
// Set the permuted vector b
OPT* opt = (OPT*)(A.optimizationData);
Vector* perm_b = new Vector;
InitializeVector(*perm_b, b.localLength);
PermVector(opt->iperm0, b, *perm_b); // perm_b <-- P^(-1) b
CopyVector(*perm_b, b); // perm_b <-- P^(-1) b
}
// Helper function (see OptimizeProblem.hpp for details)
double OptimizeProblemMemoryUse(const SparseMatrix & A) {
// Size of the following 2 arrays!
// ell->a = new double[lda*m]; // value
// ell->ja = new local_int_t[lda*m]; // column index
int numberOfMgLevels = 4; // Number of levels including first
const SparseMatrix * curLevelMatrix = &A;
double sizea, sizeja, retval;
retval = 0.0;
for(int level = 0; level< numberOfMgLevels; ++level){
int lda = ((OPT*)((*curLevelMatrix).optimizationData))->ell->lda;
int m = ((OPT*)((*curLevelMatrix).optimizationData))->ell->m;
// fprintf(stderr, "### level %d\n", level);
// fprintf(stderr, "lda: %d\n", lda);
// fprintf(stderr, "m: %d\n", m);
double sizea = ((double) lda)*((double) m)*((double) sizeof(double));
double sizeja = ((double) lda)*((double) m)*((double) sizeof(local_int_t));
retval += sizea + sizeja;
// add diag, idiag, the 2 perm vectors
double size_diag = (double)lda * sizeof(double);
double size_perm = (double)lda * sizeof(local_int_t);
retval += size_diag * 2 + size_perm * 2;
// add space for work1, work2
retval += size_diag * 2;
// TODO: add halo matrix info, if proper matrix format
curLevelMatrix = curLevelMatrix->Ac; // Make the just-constructed coarse grid the next level
}
//fprintf(stderr, "Memory Size[MB]: %e\n", retval/1.0e9);
retval *= ((double) A.geom->size);
//fprintf(stderr, "Memory Size[MB]: %e\n", retval/1.0e9);
return retval;
}
//#########################################################
// Driver for matrix optimization
//#########################################################
int GenerateOPT_STRUCT(SparseMatrix & A)
{
OPT *opt = new OPT;
ELL *ell = new ELL;
HALO *halo = new HALO;
opt->ell = ell;
local_int_t n = ell->n = A.localNumberOfRows;
opt->halo = halo;
// EF: TryFreeMemory
delete [] A.mtxIndG[0];
delete [] A.mtxIndG; A.mtxIndG = 0;
A.optimizationData = opt;
if (n <= 0) return(0);
opt->diag = new double[n*4]; // allocate multiple arrays in one step
opt->idiag = opt->diag + n;
opt->work1 = opt->idiag + n;
opt->work2 = opt->work1 + n;
local_int_t *icolor = opt->icolor = new local_int_t[n]; // color of each row
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
// Make the permutation matrix for Level scheduling or Multicolor ordering //
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
// Find the maximum degree of each node
local_int_t maxNonzerosInRow = 0;
for(local_int_t i=0; i<n; i++) {
if (A.nonzerosInRow[i] > maxNonzerosInRow)
maxNonzerosInRow = A.nonzerosInRow[i];
}
ell->m = maxNonzerosInRow - 1;
Optimize_Hyperplane(A);
//##########################################################
// Search the maximum number of colors
local_int_t maxcolor = 0, numcolors = 0;
for(local_int_t i=0; i<n; i++) {
if (icolor[i] > maxcolor)
maxcolor = icolor[i];
}
maxcolor++;
#ifdef HPCG_DEBUG
HPCG_fout << "maxcolor = " << maxcolor << std::endl;
#endif
////////////////////////////////////////////
// Create permutations according to coloring
////////////////////////////////////////////
opt->perm0 = new local_int_t[n+n+maxcolor+1]; // multiple allocs in one
opt->iperm0 = opt->perm0 + n;
opt->icptr = opt->iperm0 + n;
#ifdef VHCALLxx
vhcallVE_GetPerm(n, maxcolor, icolor, opt->perm0, opt->icptr);
#else
local_int_t icacc[maxcolor][VLEN];
for (local_int_t i=0; i<maxcolor+1; i++)
opt->icptr[i]=0;
//for (local_int_t i=0; i<n; i++)
// ++opt->icptr[icolor[i]+1]; // Count up for each color
for (int i = 0; i < maxcolor * VLEN; i++)
icacc[0][i] = 0;
for (local_int_t i_=0; i_<n; i_+=VLEN) {
if (i_ == 0) {
#pragma _NEC shortloop
#pragma _NEC ivdep
for (int i = i_; i < MIN(i_ + VLEN, n); i++)
icacc[icolor[i]][i - i_] = 1;
} else {
#pragma _NEC shortloop
#pragma _NEC ivdep
for (int i = i_; i < MIN(i_ + VLEN, n); i++)
++icacc[icolor[i]][i - i_];
}
}
for (int i = 0; i < VLEN; i++)
for (local_int_t ic=0; ic<maxcolor; ic++)
opt->icptr[ic+1] += icacc[ic][i];
for (local_int_t ic=1; ic<maxcolor+1; ic++)
opt->icptr[ic] += opt->icptr[ic-1];
//
// Make the permutation matrices perm0[] and iperm0[]
//
local_int_t itmp[maxcolor];
for (local_int_t ic=0; ic<maxcolor; ic++)
itmp[ic] = opt->icptr[ic];
for (local_int_t i=0; i<n; i++) {
local_int_t ic = icolor[i];
opt->perm0[i]= itmp[ic]; // 0 origin
itmp[ic]++;
}
#endif // ! VHCALL
#ifndef HPCG_NO_OPENMP
#pragma omp parallel for
#endif
for (local_int_t i=0; i<n; i++) {
opt->iperm0[opt->perm0[i]]=i; // 0 origin
}
opt->maxcolor = maxcolor;
const char* env_p = std::getenv("HPCG_ASYOPT");
if (env_p != nullptr && strcmp(env_p, "YES") == 0) {
ell->a = nullptr;
} else {
Optimize_Store_ELL_L_U_halo(A);
}
// EF: try free some matrix stuff
//-------------------------------
delete [] A.matrixValues[0];
delete [] A.matrixValues; A.matrixValues = 0;
delete [] A.mtxIndL[0];
delete [] A.mtxIndL; A.mtxIndL = 0;
//-------------------------------
#ifdef HPCG_DEBUG_MATRIX
if (first_call) {
auto file = std::fstream("matrix.bin", std::ios::out | std::ios::binary);
file.write((char *)&n, sizeof(local_int_t));
file.write((char *)&m, sizeof(local_int_t));
file.write((char *)&ell->ja[0], sizeof(local_int_t)*n*m);
file.write((char *)&maxcolor, sizeof(int));
file.write((char *)&opt->icptr[0], sizeof(int)*(maxcolor+1));
file.close();
first_call = 0;
}
if(n<100) {
cout<<"permuted matrix indices ell->ja\n";
for(int i=0; i<n;i++) {
cout<<fixed<<setw(5)<<i;
for(int j=0; j<m;j++)
cout<<fixed<<setw(5)<<ell->ja[i+lda*j];
cout<<"\n"<<flush;
}
}
#endif
return 0;
}
int SetDiagonalPointer(SparseMatrix & A)
{
OPT* opt = (OPT*)(A.optimizationData);
#ifndef HPCG_NO_OPENMP
#pragma omp parallel for
#endif
for(local_int_t i=0; i<A.localNumberOfRows; i++){
local_int_t inew = opt->perm0[i];
A.matrixDiagonal[i] = &opt->diag[inew];
}
return(0);
}
int SetF2cOperator(SparseMatrix & A) {
OPT* optf = (OPT*)(A.optimizationData);
if(A.Ac){
OPT* optc = (OPT*)(A.Ac->optimizationData);
local_int_t* f2c = new local_int_t[A.mgData->rc->localLength];
//call sblas routine
//ssctr_( &A.mgData->rc->localLength, A.mgData->f2cOperator, optc->perm, f2c); // 1 origin
for (local_int_t i = 0; i < A.mgData->rc->localLength; i++)
f2c[optc->perm0[i]] = A.mgData->f2cOperator[i];
#ifndef HPCG_NO_OPENMP
#pragma omp parallel for
#endif
for (local_int_t i=0; i<A.mgData->rc->localLength; i++)
A.mgData->f2cOperator[i] = optf->perm0[f2c[i]];
delete [] f2c;
}
return 0;
}
int SetCommTable(SparseMatrix & A) {
#ifndef HPCG_NO_MPI
OPT* opt = (OPT*)(A.optimizationData);
local_int_t totalToBeSent = A.totalToBeSent;
local_int_t * iw = new local_int_t[A.totalToBeSent];
#ifndef HPCG_NO_OPENMP
#pragma omp parallel for
#endif
for (local_int_t i=0; i<totalToBeSent; i++) iw[i] = A.elementsToSend[i];
#ifndef HPCG_NO_OPENMP
#pragma omp parallel for
#endif
for (local_int_t i=0; i<totalToBeSent; i++) A.elementsToSend[i] = opt->perm0[iw[i]];
delete [] iw;
#endif
return 0;
}
int PermVector(const local_int_t * p, const Vector & x, Vector & px) {
local_int_t localLength = x.localLength;
// call sblas routine
//dgthr_( &localLength, x.values, px.values, p);
for (local_int_t i = 0; i < localLength; i++)
px.values[i] = x.values[p[i]];
return 0;
}
| 31.792892 | 137 | 0.565548 | [
"vector",
"transform"
] |
71fcdc99c459d7212a9595a6eeaf9b46ce313bec | 3,000 | cc | C++ | Tools/Matlab/mex/field_spots.cc | ToyotaResearchInstitute/rad-robot | 9a47e4d88382719ab9bf142932fbcc83dcbcd665 | [
"MIT"
] | null | null | null | Tools/Matlab/mex/field_spots.cc | ToyotaResearchInstitute/rad-robot | 9a47e4d88382719ab9bf142932fbcc83dcbcd665 | [
"MIT"
] | null | null | null | Tools/Matlab/mex/field_spots.cc | ToyotaResearchInstitute/rad-robot | 9a47e4d88382719ab9bf142932fbcc83dcbcd665 | [
"MIT"
] | 2 | 2018-06-04T12:38:54.000Z | 2018-09-22T10:31:27.000Z | /*
x = field_spots(im);
Matlab 7.4 MEX file to locate field penalty kick spots.
Compile with:
mex -O field_spots.cc ConnectRegions.cc
Author: Daniel D. Lee <ddlee@seas.upenn.edu>, 6/09
*/
#include <vector>
#include "ConnectRegions.h"
#include "mex.h"
typedef unsigned char uint8;
uint8 colorSpot = 0x10;
uint8 colorField = 0x08;
bool CheckBoundary(RegionProps &prop, uint8 *im_ptr,
int m, int n, uint8 color)
{
int i0 = prop.minI - 1;
if (i0 < 0) i0 = 0;
int i1 = prop.maxI + 1;
if (i1 > m-1) i1 = m-1;
int j0 = prop.minJ - 1;
if (j0 < 0) j0 = 0;
int j1 = prop.maxJ + 1;
if (j1 > n-1) j1 = n-1;
// Check top and bottom boundary:
uint8 *im_top = im_ptr + m*j0 + i0;
uint8 *im_bottom = im_ptr + m*j1 + i0;
for (int i = 0; i <= i1-i0; i++) {
if ((*im_top != color) || (*im_bottom != color))
return false;
im_top++;
im_bottom++;
}
// Check side boundaries:
uint8 *im_left = im_ptr + m*(j0+1) + i0;
uint8 *im_right = im_ptr + m*(j0+1) + i1;
for (int j = 0; j < j1-j0-1; j++) {
if ((*im_left != color) || (*im_right != color))
return false;
im_left += m;
im_right += m;
}
return true;
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
static std::vector<RegionProps> props;
// Check arguments
if ((nrhs < 1) || !mxIsUint8(prhs[0]))
mexErrMsgTxt("Need uint8 input image.");
uint8 *im_ptr = (uint8 *)mxGetData(prhs[0]);
int m = mxGetM(prhs[0]);
int n = mxGetN(prhs[0]);
int nlabel = ConnectRegions(props, im_ptr, m, n, colorSpot);
if (nlabel < 0)
mexErrMsgTxt("Could not run ConnectRegions()");
// printf("nlabel = %d\n", nlabel);
std::vector<int> valid;
for (int i = 0; i < nlabel; i++) {
if (CheckBoundary(props[i], im_ptr, m, n, colorField)) {
valid.push_back(i);
}
}
int nvalid = valid.size();
const char *fields[] = {"area", "centroid", "boundingBox"};
const int nfields = sizeof(fields)/sizeof(*fields);
plhs[0] = mxCreateStructMatrix(nvalid, 1, nfields, fields);
for (int i = 0; i < nvalid; i++) {
mxSetField(plhs[0], i, "area", mxCreateDoubleScalar(props[valid[i]].area));
double centroidI = (double)props[valid[i]].sumI/props[valid[i]].area;
double centroidJ = (double)props[valid[i]].sumJ/props[valid[i]].area;
mxArray *centroid = mxCreateDoubleMatrix(1, 2, mxREAL);
// Flipping order of 0-indexed coordinates to go with order of dimensions
// This is different from Matlab regionprops!
mxGetPr(centroid)[0] = centroidI;
mxGetPr(centroid)[1] = centroidJ;
mxSetField(plhs[0], i, "centroid", centroid);
mxArray *bbox = mxCreateDoubleMatrix(2, 2, mxREAL);
// This definition is also quite different from Matlab regionprops!
mxGetPr(bbox)[0] = props[valid[i]].minI;
mxGetPr(bbox)[1] = props[valid[i]].maxI;
mxGetPr(bbox)[2] = props[valid[i]].minJ;
mxGetPr(bbox)[3] = props[valid[i]].maxJ;
mxSetField(plhs[0], i, "boundingBox", bbox);
}
}
| 28.301887 | 79 | 0.620667 | [
"vector"
] |
71fd3f0805e212e7e08c560d3ec6863f79a98a7a | 5,667 | cpp | C++ | src/simulation/Simulation/src/io/LaunchCache.cpp | ncl-ROVers/surface-2019-20 | 209c06008803971d0430fd3993ef36f9a4686646 | [
"MIT"
] | 3 | 2021-01-21T07:18:30.000Z | 2021-12-20T11:09:29.000Z | src/simulation/Simulation/src/io/LaunchCache.cpp | ncl-ROVers/surface-2019-20 | 209c06008803971d0430fd3993ef36f9a4686646 | [
"MIT"
] | null | null | null | src/simulation/Simulation/src/io/LaunchCache.cpp | ncl-ROVers/surface-2019-20 | 209c06008803971d0430fd3993ef36f9a4686646 | [
"MIT"
] | 3 | 2020-11-24T11:46:23.000Z | 2021-08-05T18:02:07.000Z | #include "LaunchCache.h"
#include <iostream>
void LaunchCache::saveMeshData(const std::string& saveName, const Mesh& mesh)
{
size_t cacheSize = sizeof(uint64_t) + mesh.getVertexCount() * sizeof(glm::vec3) +
sizeof(uint64_t) + mesh.getTexCoordCount() * sizeof(glm::vec2) +
sizeof(uint64_t) + mesh.getNormalCount() * sizeof(glm::vec3) +
sizeof(uint64_t) + mesh.getIndexCount() * sizeof(unsigned int);
namespace fs = std::filesystem;
std::string path = resolvePath(fs::path(m_cacheDir).append(saveName));
std::string cacheDirPath = resolvePath(m_cacheDir);
if (!fs::exists(cacheDirPath))
{
LOG_VERBOSE("Create cache directory");
if (!fs::create_directory(cacheDirPath))
{
LOG_ERROR("Unable to create cache directory at: ", m_cacheDir);
LOG_PAUSE();
exit(4);
}
}
FILE* file = NULL;
errno_t err = 0;
if ((err = fopen_s(&file, path.c_str(), "wb")) != 0)
{
char message[2048];
strerror_s(message, err);
fprintf(stderr, "Cannot open file %s: %s\n", path.c_str(), message);
return;
}
//Write vertex data
uint64_t tempCount = mesh.getVertexCount();
fwrite(&tempCount, sizeof(uint64_t), 1, file);
void* writeSrc = mesh.mapMeshData(0, (long int)(tempCount * sizeof(glm::vec3)), GL_MAP_READ_BIT, MeshDataType::DATA_VERTICES);
fwrite(writeSrc, sizeof(glm::vec3), (size_t)tempCount, file);
mesh.unmapMeshData(MeshDataType::DATA_VERTICES);
//Write texcoord data
tempCount = mesh.getTexCoordCount();
fwrite(&tempCount, sizeof(uint64_t), 1, file);
writeSrc = mesh.mapMeshData(0, (long int)(tempCount * sizeof(glm::vec2)), GL_MAP_READ_BIT, MeshDataType::DATA_TEXCOORDS);
fwrite(writeSrc, sizeof(glm::vec2), (size_t)tempCount, file);
mesh.unmapMeshData(MeshDataType::DATA_TEXCOORDS);
//Write normal data
tempCount = mesh.getNormalCount();
fwrite(&tempCount, sizeof(uint64_t), 1, file);
writeSrc = mesh.mapMeshData(0, (long int)(tempCount * sizeof(glm::vec3)), GL_MAP_READ_BIT, MeshDataType::DATA_NORMALS);
fwrite(writeSrc, sizeof(glm::vec3), (size_t)tempCount, file);
mesh.unmapMeshData(MeshDataType::DATA_NORMALS);
//Write index data
tempCount = mesh.getIndexCount();
fwrite(&tempCount, sizeof(uint64_t), 1, file);
writeSrc = mesh.mapMeshData(0, (long int)(tempCount * sizeof(unsigned int)), GL_MAP_READ_BIT, MeshDataType::DATA_INDICES);
fwrite(writeSrc, sizeof(unsigned int), (size_t)tempCount, file);
mesh.unmapMeshData(MeshDataType::DATA_INDICES);
/*
//Write physics datas
bool hasRigidBody = mesh.hasRigidBodyData();
fwrite(&hasRigidBody, sizeof(bool), 1, file);
if (hasRigidBody)
{
const RigidBodyData& rbData = mesh.getPhysicsData();
fwrite(&rbData.mass, sizeof(double), 1, file);
fwrite(&rbData.bodyI, sizeof(glm::mat3), 1, file);
fwrite(&rbData.centerOfMassOffset, sizeof(glm::vec3), 1, file);
}*/
fclose(file);
}
bool LaunchCache::isMeshCached(const std::string& saveName)
{
namespace fs = std::filesystem;
return fs::exists(resolvePath(fs::path(m_cacheDir).append(saveName)));
}
bool LaunchCache::isMeshOutdated(const std::string& saveName, const std::string& modelPath)
{
if (!isMeshCached(saveName))
{
return true;
}
namespace fs = std::filesystem;
fs::file_time_type cacheTime = fs::last_write_time(resolvePath(fs::path(m_cacheDir).append(saveName)));
fs::file_time_type originalTime = fs::last_write_time(resolvePath(modelPath));
return originalTime > cacheTime;
}
int throwError()
{
LOG_ERROR("Error parsing cache file! File too short.");
LOG_PAUSE();
exit(5);
return 0;
}
#define CHK_PTR(ptr, offset, len) ((ptr < len) ? ((ptr += offset) - offset) : throwError())
void LaunchCache::loadMeshData(const std::string& saveName, Mesh& mesh)
{
if (!isMeshCached(saveName))
{
return;
}
long int fileSize = 0;
byte* meshData = readFileContent(resolvePath(std::filesystem::path(m_cacheDir).append(saveName)), fileSize);
uint64_t ptr = 0;
uint64_t vertexCount = *((uint64_t*)&meshData[CHK_PTR(ptr, sizeof(uint64_t), fileSize)]);
glm::vec3* vertices = (glm::vec3*)&meshData[CHK_PTR(ptr, (vertexCount * sizeof(glm::vec3)), fileSize)];
uint64_t texCoordCount = *((uint64_t*)&meshData[CHK_PTR(ptr, sizeof(uint64_t), fileSize)]);
glm::vec2* texCoords = (glm::vec2*)&meshData[CHK_PTR(ptr, (texCoordCount * sizeof(glm::vec2)), fileSize)];
uint64_t normalCount = *((uint64_t*)&meshData[CHK_PTR(ptr, sizeof(uint64_t), fileSize)]);
glm::vec3* normals = (glm::vec3*)&meshData[CHK_PTR(ptr, (normalCount * sizeof(glm::vec3)), fileSize)];
uint64_t indexCount = *((uint64_t*)&meshData[CHK_PTR(ptr, sizeof(uint64_t), fileSize)]);
unsigned int* indices = (unsigned int*)&meshData[CHK_PTR(ptr, (indexCount * sizeof(unsigned int)), fileSize)];
/*
bool hasRigidBody = *((bool*)&meshData[CHK_PTR(ptr, sizeof(bool), fileSize)]);
if (hasRigidBody)
{
RigidBodyData data;
data.mass = *((double *)&meshData[CHK_PTR(ptr, sizeof(double), fileSize)]);
data.bodyI = *((glm::mat3*)&meshData[CHK_PTR(ptr, sizeof(glm::mat3), fileSize)]);
data.invBodyI = glm::inverse(data.bodyI);
data.centerOfMassOffset = *((glm::vec3*)&meshData[CHK_PTR(ptr, sizeof(glm::vec3), fileSize)]);
data.linearMomentum = glm::zero<glm::vec3>();
data.angularMomentum = glm::zero<glm::vec3>();
data.invMomentOfInteria = glm::identity<glm::mat3>();
data.linearVelocity = glm::zero<glm::vec3>();
data.angularVelocity = glm::zero<glm::vec3>();
data.totalForce = glm::zero<glm::vec3>();
data.totalTorque = glm::zero<glm::vec3>();
mesh.setPhysicsData(data);
}*/
mesh.loadDirect(vertices, (size_t)vertexCount, texCoords, (size_t)texCoordCount, normals, (size_t)normalCount, indices, (size_t)indexCount);
delete[] meshData;
} | 31.309392 | 141 | 0.709723 | [
"mesh"
] |
9f9f1bebfc0580c1db48a80001a1ffe83e218b3c | 605 | cpp | C++ | atcoder/abc150d.cpp | sogapalag/problems | 0ea7d65448e1177f8b3f81124a82d187980d659c | [
"MIT"
] | 1 | 2020-04-04T14:56:12.000Z | 2020-04-04T14:56:12.000Z | atcoder/abc150d.cpp | sogapalag/problems | 0ea7d65448e1177f8b3f81124a82d187980d659c | [
"MIT"
] | null | null | null | atcoder/abc150d.cpp | sogapalag/problems | 0ea7d65448e1177f8b3f81124a82d187980d659c | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
void solve() {
int n; ll m;
cin >> n >> m;
vector<ll> a(n);
ll lcm = 1;
for (auto& x: a) {
cin >> x;
ll g = __gcd(lcm, x);
lcm = lcm * x / g;
if (lcm > 2*m) {
cout << 0; return;
}
}
ll z = lcm/2;
// ck
for (ll x: a) {
if (z%x != x/2) {
cout << 0; return;
}
}
ll res = m/lcm + (m%lcm >= z);
cout << res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
cout << endl;
}
| 16.805556 | 37 | 0.409917 | [
"vector"
] |
9fa01bcd443562ba303f7cb0f21df3077c4dde93 | 1,911 | cc | C++ | src/q_1_50/q0043.cc | vNaonLu/daily-leetcode | 2830c2cd413d950abe7c6d9b833c771f784443b0 | [
"MIT"
] | 2 | 2021-09-28T18:41:03.000Z | 2021-09-28T18:42:57.000Z | src/q_1_50/q0043.cc | vNaonLu/Daily_LeetCode | 30024b561611d390931cef1b22afd6a5060cf586 | [
"MIT"
] | 16 | 2021-09-26T11:44:20.000Z | 2021-11-28T06:44:02.000Z | src/q_1_50/q0043.cc | vNaonLu/daily-leetcode | 2830c2cd413d950abe7c6d9b833c771f784443b0 | [
"MIT"
] | 1 | 2021-11-22T09:11:36.000Z | 2021-11-22T09:11:36.000Z | #include <gtest/gtest.h>
#include <iostream>
#include <string>
using namespace std;
/**
* This file is generated by leetcode_add.py v1.0
*
* 43.
* Multiply Strings
*
* ––––––––––––––––––––––––––––– Description –––––––––––––––––––––––––––––
*
* Given two non-negative integers ‘num1’ and ‘num2’ represented as
* strings, return the product of ‘num1’ and ‘num2’ , also represented as
* a
* “Note:” You must not use any built-in BigInteger library or convert
* the inputs to integer directly.
*
* ––––––––––––––––––––––––––––– Constraints –––––––––––––––––––––––––––––
*
* • ‘1 ≤ num1.length, num2.length ≤ 200’
* • ‘num1’ and ‘num2’ consist of digits only.
* • Both ‘num1’ and ‘num2’ do not contain any leading zero, except the number ‘0’ itself.
*
*/
struct q43 : public ::testing::Test {
// Leetcode answer here
class Solution {
public:
string multiply(string num1, string num2) {
vector<int> ans(num1.size() + num2.size(), 0);
int j = num2.size();
while (--j >= 0) {
int i = num1.size();
while (--i >= 0) {
int piv = i + j + 1;
int val = (num2[j] - '0') * (num1[i] - '0');
ans[piv] += val;
ans[piv - 1] += ans[piv] / 10;
ans[piv] %= 10;
}
}
string res;
for (const auto &n : ans) {
if (!res.empty() || n != 0) {
res.push_back(n + '0');
}
}
return res.empty() ? "0" : res;
}
};
class Solution *solution;
};
TEST_F(q43, sample_input01) {
solution = new Solution();
string num1 = "2";
string num2 = "3";
string exp = "6";
EXPECT_EQ(solution->multiply(num1, num2), exp);
delete solution;
}
TEST_F(q43, sample_input02) {
solution = new Solution();
string num1 = "123";
string num2 = "456";
string exp = "56088";
EXPECT_EQ(solution->multiply(num1, num2), exp);
delete solution;
} | 25.48 | 92 | 0.528519 | [
"vector"
] |
9faa653b6d65822c66024fe1c689bedad19ff542 | 4,661 | cpp | C++ | generator/src/generator.cpp | nalevi/CppUmlClassGen | 3bee7ca2e97cabbccc082aeac417985962da3976 | [
"MIT"
] | 1 | 2021-03-16T20:42:52.000Z | 2021-03-16T20:42:52.000Z | generator/src/generator.cpp | nalevi/CppUmlClassGen | 3bee7ca2e97cabbccc082aeac417985962da3976 | [
"MIT"
] | null | null | null | generator/src/generator.cpp | nalevi/CppUmlClassGen | 3bee7ca2e97cabbccc082aeac417985962da3976 | [
"MIT"
] | null | null | null | #include <boost/program_options/options_description.hpp>
#include <clang/Frontend/FrontendAction.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <memory>
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <clang/AST/ASTConsumer.h>
#include <clang/Tooling/CommonOptionsParser.h>
#include <clang/Tooling/Tooling.h>
#include <llvm/Support/CommandLine.h>
#include <generator/dbsession.h>
#include "clangastvisitor.h"
namespace fs = boost::filesystem;
namespace po = boost::program_options;
class ClangASTConsumer : public clang::ASTConsumer
{
public:
explicit ClangASTConsumer(
clang::ASTContext* ctx_,
std::shared_ptr<Wt::Dbo::Session> dbsession_)
: _visitor(ctx_, dbsession_), _dbsession(dbsession_) {}
virtual void HandleTranslationUnit(clang::ASTContext& ctx_)
{
_visitor.TraverseDecl(ctx_.getTranslationUnitDecl());
}
private:
umlgen::generator::ClangASTVisitor _visitor;
std::shared_ptr<Wt::Dbo::Session> _dbsession;
};
class GeneratorActionFactory : public clang::tooling::FrontendActionFactory
{
public:
GeneratorActionFactory(std::shared_ptr<Wt::Dbo::Session> dbsession_)
{
_dbsession = dbsession_;
}
std::unique_ptr<clang::FrontendAction> create() override
{
return std::make_unique<MyGenFrontendAction>(_dbsession);
}
private:
class MyGenFrontendAction : public clang::ASTFrontendAction
{
friend class GeneratorActionFactory;
public:
MyGenFrontendAction(std::shared_ptr<Wt::Dbo::Session> dbsession_)
{
_dbsession = dbsession_;
}
virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(
clang::CompilerInstance& Compiler, llvm::StringRef InFile)
{
return std::unique_ptr<clang::ASTConsumer>(
new ClangASTConsumer(&Compiler.getASTContext(), _dbsession));
}
private:
std::shared_ptr<Wt::Dbo::Session> _dbsession;
};
std::shared_ptr<Wt::Dbo::Session> _dbsession;
};
static llvm::cl::OptionCategory GenToolCategory("generator options");
static llvm::cl::extrahelp CommonHelp(
clang::tooling::CommonOptionsParser::HelpMessage);
static llvm::cl::extrahelp MoreHelp("\nMore help text...\n");
po::options_description commandLineArgs()
{
po::options_description desc("Generator options");
desc.add_options()
("help,h",
"Prints help message.")
("object,c", po::value<std::string>()->required(),
"The name of the object to generate uml class diagramm for.")
("workspace,w", po::value<std::string>()->required(),
"The path to the project root library.")
("fileformat,f",
"The output file format: SVG,TXT, DOT")
("database,d",po::value<std::string>()->required(),
"The database used to store the AST informations,"
"valid options are PostgreSQL or SQLite. For PostgreSQl"
"a connection string is needed, for example: "
"'host=127.0.0.1 user=test password=1234 port5432 dbname=umlgen_test'");
return desc;
}
/**
* This function checks the existence of the workspace and project directory
* based on the given command line arguments.
* @return Whether the project directory exists or not.
*/
bool checkProjectDir(const po::variables_map& vm_)
{
const std::string projDir
= vm_["workspace"].as<std::string>() + '/';
return fs::is_directory(projDir);
}
int main(int argc, const char** argv)
{
// Proecessing command line arguments
po::options_description desc = commandLineArgs();
po::variables_map vm;
po::store(po::command_line_parser(argc, argv)
.options(desc).allow_unregistered().run(), vm);
std::string CONNECTION_STRING("");
std::string UML_CLASS("");
if(vm.count("workspace"))
{
if(!checkProjectDir(vm))
{
std::cerr << "Error: workspace doesn't exist!" << std::endl;
}
}
if(vm.count("database"))
{
CONNECTION_STRING = vm["database"].as<std::string>();
}
if(vm.count("object"))
{
UML_CLASS = vm["object"].as<std::string>();
}
std::shared_ptr<Wt::Dbo::Session> session_ptr(new Wt::Dbo::Session);
bool dbSession = umlgen::generator::startDbSession(
//"host=127.0.0.1 user=test password=1234 port=5432 dbname=umlgen_test",
//CONNECTION_STRING,
"umlgen.db",
session_ptr);
if(dbSession)
{
GeneratorActionFactory factory(session_ptr);
clang::tooling::CommonOptionsParser OptionParser(argc, argv, GenToolCategory);
clang::tooling::ClangTool genTool(OptionParser.getCompilations(),
OptionParser.getSourcePathList());
bool res = genTool.run(&factory);
return res;
}
else {
return 1;
}
}
| 26.185393 | 82 | 0.691053 | [
"object",
"vector"
] |
9fb6c6cb9232af50b17ab4cdb8decd0251ffcc65 | 7,300 | cpp | C++ | cpp/Database.cpp | azbe/readlit | 9988759b148de7c9974bfdcd2481c866d2a33aad | [
"Apache-2.0"
] | null | null | null | cpp/Database.cpp | azbe/readlit | 9988759b148de7c9974bfdcd2481c866d2a33aad | [
"Apache-2.0"
] | null | null | null | cpp/Database.cpp | azbe/readlit | 9988759b148de7c9974bfdcd2481c866d2a33aad | [
"Apache-2.0"
] | null | null | null | #include "src/Database.h"
DataBase::DataBase()
{
}
bool DataBase::addBook(const Book& NewBook)
{
if(books.count(NewBook.getFilePath()) != 0)
{
error("The book: " + NewBook.getFilePath() + "is not in data base: deleteBook(const QString &)");
return false;
}
books.insert(std::pair<QString, Book>(NewBook.getFilePath(), NewBook));
if (!findAuthor(NewBook.getAuthor()))
addAuthor(Author(NewBook.getAuthor()));
addBookToAuthor(NewBook.getTitle(), NewBook.getAuthor());
return true;
}
bool DataBase::deleteBook(const QString &pathID)
{
if(books.count(pathID) == 0)
{
return false;
error("The book: " + pathID + "is not in data base: deleteBook(const QString &)");
}
books.erase(pathID);
return true;
}
bool DataBase::addAuthor(Author _author)
{
if(authors.count(_author.getName()) != 0)
{
error("The author " + _author.getName() + "is already in database !addAuthor(Author)");
return false;
}
authors.insert(std::pair<QString, Author>(_author.getName(), _author));
return true;
}
bool DataBase::deleteAuthor(const QString &name)
{
if(authors.count(name) == 0)
{
error("The author " + name + " is not data base: getBook()");
return false;
}
authors.erase(name);
return true;
}
bool DataBase::findBook(const QString &PathID)
{
if (books.count(PathID) == 0)
{
return false;
error("The book: " + PathID + "is not in data base: findBook(const QString &)");
}
return true;
}
Book DataBase::getBook(const QString &PathID)
{
if(books.count(PathID) == 0)
{
error("The book: " + PathID + "is not in data base: getBook(const QString &)");
return Book();
}
return books[PathID];
}
Book DataBase::getBookByTitle(const QString &title)
{
for (auto const &book : books)
if (book.second.getTitle() == title)
return book.second;
return Book();
error("The book: " + title + "is not in data base: getBookByTitle(const QString &)");
}
QStringList DataBase::getBookTitles()
{
QStringList bookTitles;
for (auto const &book : books)
bookTitles.append(book.second.getTitle());
return bookTitles;
}
bool DataBase::findAuthor(const QString& name)
{
if(authors.count(name) == 0)
{
//error("The author: " + name + " is not in database: findAuthor(const QString&)");
return false;
}
return true;
}
Author DataBase::getAuthor(const QString &name)
{
if(authors.count(name) == 0)
{
error("The author: " + name + " isn't in database: getAuthor()");
return Author();
}
return authors[name];
}
QStringList DataBase::getAuthorNames()
{
QStringList authorNames;
for (auto const &author : authors)
authorNames.append(author.second.getName());
return authorNames;
}
bool DataBase::addBookToAuthor(const QString &title, const QString &name)
{
return authors[name].addBook(title);
}
bool DataBase::removeBookFromAuthor(const QString &title, const QString &name)
{
bool check = false;
std::vector<QString> authorBooks = authors[name].getVector();
for (unsigned index = 0; index < authorBooks.size(); index++)
{
if (authorBooks[index] == title)
{
check = true;
authorBooks.erase(authorBooks.begin() + index);
break;
}
}
Author newAuthor(authors[name].getName(), authorBooks, authors[name].getYearBirth(), authors[name].getYearDeath(), authors[name].getBio());
deleteAuthor(name);
if (authorBooks.size() > 0) addAuthor(newAuthor);
return check;
}
bool DataBase::editBook(const Book &newBook)
{
bool check = false;
QString oldTitle = books[newBook.getFilePath()].getTitle();
QString oldAuthor = books[newBook.getFilePath()].getAuthor();
removeBookFromAuthor(oldTitle, oldAuthor);
if (!findAuthor(newBook.getAuthor()))
{
addAuthor(Author(newBook.getAuthor()));
check = true;
}
check = deleteBook(newBook.getFilePath());
check = addBook(newBook);
return check;
}
bool DataBase::editAuthor(const QString& oldName, const Author &newAuthor)
{
bool check = false;
std::vector<QString> authorBooks = newAuthor.getVector();
for (QString title : authorBooks)
books[title].setAuthor(newAuthor.getName());
if (oldName == newAuthor.getName())
check = deleteAuthor(newAuthor.getName());
else
check = deleteAuthor(oldName);
check = addAuthor(newAuthor);
return check;
}
void DataBase::write(QJsonObject &json)
{
QJsonArray booksArray;
for(std::map<QString, Book>::iterator it = books.begin(); it != books.end(); it++)
{
Book temp = it->second;
QJsonObject bookObject;
temp.write(bookObject);
booksArray.append(bookObject);
}
json["books"] = booksArray;
QJsonArray authorsArray;
for(std::map<QString, Author>::iterator it = authors.begin(); it != authors.end(); it++)
{
Author temp = it->second;
QJsonObject authorObject;
temp.write(authorObject);
authorsArray.append(authorObject);
}
json["authors"] = authorsArray;
}
void DataBase::read(const QJsonObject &JsonObj)
{
authors.clear();
QJsonArray authorsArray = JsonObj["authors"].toArray();
for(int index = 0; index < authorsArray.size(); index++)
{
QJsonObject authorObject = authorsArray[index].toObject();
Author _author;
_author.read(authorObject);
authors.insert(std::pair<QString, Author>(_author.getName(), _author));
}
books.clear();
QJsonArray booksArray = JsonObj["books"].toArray();
for(int index = 0; index < booksArray.size(); index++)
{
QJsonObject bookObject = booksArray[index].toObject();
Book book;
book.read(bookObject);
books.insert(std::pair<QString, Book>(book.getFilePath(), book));
}
}
void DataBase::save(const QString &fileName)
{
QFile saveFile(fileName);
if(!saveFile.open(QIODevice::WriteOnly))
{
QMessageBox messageBox;
messageBox.critical(0,"ERROR","Couldn't open database file for saving. Check if the file is still there and if it's writable.\nChanges to the database have NOT been saved.\nGiven path: " + fileName);
error("Couldn't save file because is not writeable!");
return;
}
QJsonObject booksObject;
write(booksObject);
QJsonDocument saveDoc(booksObject);
saveFile.write(saveDoc.toJson());
saveFile.close();
}
void DataBase::load(const QString &fileName)
{
QFile savedFile(fileName);
if(!savedFile.exists() || !savedFile.open(QIODevice::ReadOnly))
{
QMessageBox messageBox;
messageBox.critical(0,"ERROR","Couldn't open database file for loading. Check if the file exists and if it's readable.\nGiven path: " + fileName);
error("Couldn't open load file because it is not readable!");
return;
}
QByteArray savedData = savedFile.readAll();
QJsonDocument loadDoc(QJsonDocument::fromJson(savedData));
read(loadDoc.object());
savedFile.close();
}
void DataBase::error(const QString error)
{
qDebug() << error + "\nClass name: Database";
}
| 27.756654 | 207 | 0.638767 | [
"object",
"vector"
] |
9fb81909838112d884a19c41e733b1f579fd0500 | 9,858 | cpp | C++ | TopTestWidgets/privateSource/scatterchartitem.cpp | cy15196/xxxxRsmTest | 36577173ef2cdfc3c3d4cadd3933849d29d5b3d9 | [
"MIT"
] | 1 | 2020-02-12T03:20:37.000Z | 2020-02-12T03:20:37.000Z | TopTestWidgets/privateSource/scatterchartitem.cpp | cy15196/xxxxRsmTest | 36577173ef2cdfc3c3d4cadd3933849d29d5b3d9 | [
"MIT"
] | null | null | null | TopTestWidgets/privateSource/scatterchartitem.cpp | cy15196/xxxxRsmTest | 36577173ef2cdfc3c3d4cadd3933849d29d5b3d9 | [
"MIT"
] | 1 | 2019-04-14T09:58:50.000Z | 2019-04-14T09:58:50.000Z | /****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Charts module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL$
** 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 The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <private/scatterchartitem_p.h>
#include <QtCharts/QScatterSeries>
#include <private/qscatterseries_p.h>
#include <private/chartpresenter_p.h>
#include <private/abstractdomain_p.h>
#include <QtCharts/QChart>
#include <QtGui/QPainter>
#include <QtWidgets/QGraphicsScene>
#include <QtCore/QDebug>
#include <QtWidgets/QGraphicsSceneMouseEvent>
QT_CHARTS_BEGIN_NAMESPACE
ScatterChartItem::ScatterChartItem(QScatterSeries *series, QGraphicsItem *item)
: XYChart(series,item),
m_series(series),
m_items(this),
m_visible(true),
m_shape(QScatterSeries::MarkerShapeRectangle),
m_size(15),
m_pointLabelsVisible(false),
m_pointLabelsFormat(series->pointLabelsFormat()),
m_pointLabelsFont(series->pointLabelsFont()),
m_pointLabelsColor(series->pointLabelsColor()),
m_pointLabelsClipping(true),
m_mousePressed(false)
{
QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(handleUpdated()));
QObject::connect(m_series, SIGNAL(visibleChanged()), this, SLOT(handleUpdated()));
QObject::connect(m_series, SIGNAL(opacityChanged()), this, SLOT(handleUpdated()));
QObject::connect(series, SIGNAL(pointLabelsFormatChanged(QString)),
this, SLOT(handleUpdated()));
QObject::connect(series, SIGNAL(pointLabelsVisibilityChanged(bool)),
this, SLOT(handleUpdated()));
QObject::connect(series, SIGNAL(pointLabelsFontChanged(QFont)), this, SLOT(handleUpdated()));
QObject::connect(series, SIGNAL(pointLabelsColorChanged(QColor)), this, SLOT(handleUpdated()));
QObject::connect(series, SIGNAL(pointLabelsClippingChanged(bool)), this, SLOT(handleUpdated()));
setZValue(ChartPresenter::ScatterSeriesZValue);
setFlags(QGraphicsItem::ItemClipsChildrenToShape);
handleUpdated();
m_items.setHandlesChildEvents(false);
}
QRectF ScatterChartItem::boundingRect() const
{
return m_rect;
}
void ScatterChartItem::createPoints(int count)
{
for (int i = 0; i < count; ++i) {
QGraphicsItem *item = 0;
switch (m_shape) {
case QScatterSeries::MarkerShapeCircle: {
item = new CircleMarker(0, 0, m_size, m_size, this);
const QRectF &rect = item->boundingRect();
item->setPos(-rect.width() / 2, -rect.height() / 2);
break;
}
case QScatterSeries::MarkerShapeRectangle:
item = new RectangleMarker(0, 0, m_size, m_size, this);
item->setPos(-m_size / 2, -m_size / 2);
break;
default:
qWarning() << "Unsupported marker type";
break;
}
m_items.addToGroup(item);
}
}
void ScatterChartItem::deletePoints(int count)
{
QList<QGraphicsItem *> items = m_items.childItems();
for (int i = 0; i < count; ++i) {
QGraphicsItem *item = items.takeLast();
m_markerMap.remove(item);
delete(item);
}
}
void ScatterChartItem::markerSelected(QGraphicsItem *marker)
{
emit XYChart::clicked(m_markerMap[marker]);
}
void ScatterChartItem::markerHovered(QGraphicsItem *marker, bool state)
{
emit XYChart::hovered(m_markerMap[marker], state);
}
void ScatterChartItem::markerPressed(QGraphicsItem *marker)
{
emit XYChart::pressed(m_markerMap[marker]);
}
void ScatterChartItem::markerReleased(QGraphicsItem *marker)
{
emit XYChart::released(m_markerMap[marker]);
}
void ScatterChartItem::markerDoubleClicked(QGraphicsItem *marker)
{
emit XYChart::doubleClicked(m_markerMap[marker]);
}
void ScatterChartItem::updateGeometry()
{
if (m_series->useOpenGL()) {
if (m_items.childItems().count())
deletePoints(m_items.childItems().count());
if (!m_rect.isEmpty()) {
prepareGeometryChange();
// Changed signal seems to trigger even with empty region
m_rect = QRectF();
}
update();
return;
}
const QVector<QPointF>& points = geometryPoints();
if (points.size() == 0) {
deletePoints(m_items.childItems().count());
return;
}
int diff = m_items.childItems().size() - points.size();
if (diff > 0)
deletePoints(diff);
else if (diff < 0)
createPoints(-diff);
if (diff != 0)
handleUpdated();
QList<QGraphicsItem *> items = m_items.childItems();
QRectF clipRect(QPointF(0,0),domain()->size());
// Only zoom in if the clipRect fits inside int limits. QWidget::update() uses
// a region that has to be compatible with QRect.
if (clipRect.height() <= INT_MAX
&& clipRect.width() <= INT_MAX) {
QVector<bool> offGridStatus = offGridStatusVector();
const int seriesLastIndex = m_series->count() - 1;
for (int i = 0; i < points.size(); i++) {
QGraphicsItem *item = items.at(i);
const QPointF &point = points.at(i);
const QRectF &rect = item->boundingRect();
// During remove animation series may have different number of points,
// so ensure we don't go over the index. Animation handling itself ensures that
// if there is actually no points in the series, then it won't generate a fake point,
// so we can be assured there is always at least one point in m_series here.
// Note that marker map values can be technically incorrect during the animation,
// if it was caused by an insert, but this shouldn't be a problem as the points are
// fake anyway. After remove animation stops, geometry is updated to correct one.
m_markerMap[item] = m_series->at(qMin(seriesLastIndex, i));
QPointF position;
position.setX(point.x() - rect.width() / 2);
position.setY(point.y() - rect.height() / 2);
item->setPos(position);
if (!m_visible || offGridStatus.at(i))
item->setVisible(false);
else
item->setVisible(true);
}
prepareGeometryChange();
m_rect = clipRect;
}
}
void ScatterChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option)
Q_UNUSED(widget)
if (m_series->useOpenGL())
return;
QRectF clipRect = QRectF(QPointF(0, 0), domain()->size());
painter->save();
painter->setClipRect(clipRect);
if (m_pointLabelsVisible) {
if (m_pointLabelsClipping)
painter->setClipping(true);
else
painter->setClipping(false);
m_series->d_func()->drawSeriesPointLabels(painter, m_points,
m_series->markerSize() / 2
+ m_series->pen().width());
}
painter->restore();
}
void ScatterChartItem::setPen(const QPen &pen)
{
foreach (QGraphicsItem *item , m_items.childItems())
static_cast<QAbstractGraphicsShapeItem*>(item)->setPen(pen);
}
void ScatterChartItem::setBrush(const QBrush &brush)
{
foreach (QGraphicsItem *item , m_items.childItems())
static_cast<QAbstractGraphicsShapeItem*>(item)->setBrush(brush);
}
void ScatterChartItem::handleUpdated()
{
if (m_series->useOpenGL()) {
if ((m_series->isVisible() != m_visible)) {
m_visible = m_series->isVisible();
refreshGlChart();
}
return;
}
int count = m_items.childItems().count();
if (count == 0)
return;
bool recreate = m_visible != m_series->isVisible()
|| m_size != m_series->markerSize()
|| m_shape != m_series->markerShape();
m_visible = m_series->isVisible();
m_size = m_series->markerSize();
m_shape = m_series->markerShape();
setVisible(m_visible);
setOpacity(m_series->opacity());
m_pointLabelsFormat = m_series->pointLabelsFormat();
m_pointLabelsVisible = m_series->pointLabelsVisible();
m_pointLabelsFont = m_series->pointLabelsFont();
m_pointLabelsColor = m_series->pointLabelsColor();
m_pointLabelsClipping = m_series->pointLabelsClipping();
if (recreate) {
deletePoints(count);
createPoints(count);
// Updating geometry is now safe, because it won't call handleUpdated unless it creates/deletes points
updateGeometry();
}
setPen(m_series->pen());
setBrush(m_series->brush());
update();
}
#include "moc_scatterchartitem_p.cpp"
QT_CHARTS_END_NAMESPACE
| 33.530612 | 110 | 0.643132 | [
"geometry"
] |
9fb86f6414870684ca26d0985d9dd2346df444ff | 2,224 | cc | C++ | svm/svm.cc | FBergeron/knp | 0209a5ef559efdba550c3727efe0c6481f8bafde | [
"BSD-3-Clause"
] | 20 | 2020-04-19T07:45:52.000Z | 2022-03-20T00:41:33.000Z | svm/svm.cc | FBergeron/knp | 0209a5ef559efdba550c3727efe0c6481f8bafde | [
"BSD-3-Clause"
] | 7 | 2020-09-09T07:40:50.000Z | 2021-11-25T04:11:10.000Z | svm/svm.cc | FBergeron/knp | 0209a5ef559efdba550c3727efe0c6481f8bafde | [
"BSD-3-Clause"
] | 4 | 2020-04-22T04:16:13.000Z | 2022-02-20T05:01:41.000Z | #ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef STDC_HEADERS
#include <stdio.h>
#endif
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef HAVE_SETJMP_H
#include <setjmp.h>
#endif
#ifdef HAVE_MATH_H
#include <math.h>
#endif
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#include <tinysvm.h>
#include "svm.h"
#define PP_NUMBER 44
#define NE_MODEL_NUMBER 33
char *SVMFile[PP_NUMBER]; /* modelファイルの指定 */
char *SVMFileNE[NE_MODEL_NUMBER]; /* ne解析用modelファイルの指定 */
TinySVM::Model *model[PP_NUMBER];
TinySVM::Model *modelNE[NE_MODEL_NUMBER];
double _svm_classify(char *line, TinySVM::Model *m) {
int i = 0;
while (isspace(line[i])) i++;
return m->classify((const char *)(line + i));
}
int init_svm_for_anaphora() {
int i;
for (i = 0; i < PP_NUMBER; i++) {
if (SVMFile[i]) {
model[i] = new TinySVM::Model;
if (!model[i]->read(SVMFile[i])) {
fprintf(stderr, ";; SVM initialization error (%s is corrupted?).\n", SVMFile[i]);
exit(1);
}
if (i == 0) { /* すべての格用 */
return 0;
}
}
else {
model[i] = NULL;
}
}
return 0;
}
int init_svm_for_NE() {
int i;
for (i = 0; i < NE_MODEL_NUMBER; i++) {
modelNE[i] = new TinySVM::Model;
if (!modelNE[i]->read(SVMFileNE[i])) {
fprintf(stderr, ";; SVM initialization error (%s is corrupted?).\n", SVMFileNE[i]);
exit(1);
}
}
return 0;
}
double svm_classify_for_anaphora(char *line, int pp) {
TinySVM::Model *m;
/* 0はすべての格用 */
if (model[0]) {
m = model[0];
pp = 0;
}
else {
m = model[pp];
}
if (!m) {
fprintf(stderr, ";; SVM model[%d] cannot be read.\n", pp);
exit(1);
}
return _svm_classify(line, m);
}
double svm_classify_for_NE(char *line, int n) {
TinySVM::Model *m;
m = modelNE[n];
if (!m) {
fprintf(stderr, ";; SVM model for NE [%d] cannot be read.\n", n);
exit(1);
}
return _svm_classify(line, m);
}
| 16.474074 | 88 | 0.624101 | [
"model"
] |
9fccd1e678e395030411142567f203cd71827f74 | 389 | cpp | C++ | lib/utilities.cpp | BlaMaeda/abed | b10eebd2155d22d516ea5c6a1c31c45128a37122 | [
"BSD-3-Clause"
] | null | null | null | lib/utilities.cpp | BlaMaeda/abed | b10eebd2155d22d516ea5c6a1c31c45128a37122 | [
"BSD-3-Clause"
] | null | null | null | lib/utilities.cpp | BlaMaeda/abed | b10eebd2155d22d516ea5c6a1c31c45128a37122 | [
"BSD-3-Clause"
] | null | null | null | #include <vector>
#include "../include/utilities.hpp"
namespace abed {
void normalize_distribution(std::vector<double>& d) {
const unsigned int N = d.size();
double sum = 0.0;
for (unsigned int i = 0; i < N; i++) {
sum += d[i];
}
for (unsigned int i = 0; i < N; i++) {
d[i] /= sum;
}
}
} // namespace abed
| 21.611111 | 57 | 0.48329 | [
"vector"
] |
9fcdd97cb13ee42d49adf9d403faabdea96aaa8a | 1,705 | cpp | C++ | src/application/gui/propertyeditor/EvFileDelegate.cpp | kaabimg/EvLibrary | 47acd8fdb39c05edb843238a61d0faea5ed6ea88 | [
"Unlicense"
] | 2 | 2017-02-01T11:05:26.000Z | 2017-07-10T13:26:29.000Z | src/application/gui/propertyeditor/EvFileDelegate.cpp | kaabimg/EvLibrary | 47acd8fdb39c05edb843238a61d0faea5ed6ea88 | [
"Unlicense"
] | null | null | null | src/application/gui/propertyeditor/EvFileDelegate.cpp | kaabimg/EvLibrary | 47acd8fdb39c05edb843238a61d0faea5ed6ea88 | [
"Unlicense"
] | null | null | null | #include "EvFileDelegate.h"
#include <QFileDialog>
#include <QLineEdit>
#include "EvEditWidget.h"
QWidget *EvFileDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const
{
return new EvEditWidget(new QLineEdit,parent);
}
void EvFileDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
EvEditWidget * editWidget = qobject_cast<EvEditWidget*>(editor);
qobject_cast<QLineEdit*>(editWidget->widget())->setText((property(index)->value().toString()));
editWidget->setData(index.internalPointer());
disconnect(editWidget,0,this,0);
connect(editWidget,SIGNAL(editRequest()),this,SLOT(browseFile()));
}
void EvFileDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
EvEditWidget * editWidget = qobject_cast<EvEditWidget*>(editor);
model->setData(
index,
qobject_cast<QLineEdit*>(editWidget->widget())->text(),
Qt::EditRole );
}
void EvFileDelegate::browseFile()
{
EvEditWidget * editWidget = qobject_cast<EvEditWidget*>(sender());
EvProperty * property = static_cast<EvProperty*>(editWidget->data());
QString dir = QDir::homePath();
if(property->hasAttribute("dir"))
dir = property->attribute("dir").toString();
QString filter;
if(property->hasAttribute("filters"))
filter = property->attribute("filters").toString();
QString file = QFileDialog::getOpenFileName(
editWidget,
property->label(),
dir,
filter);
if(!file.isEmpty())
qobject_cast<QLineEdit*>(editWidget->widget())->setText(file);
}
| 34.1 | 111 | 0.672727 | [
"model"
] |
9fd58914ea132dc23cfacd59c7b4d3f879b8df29 | 3,148 | cpp | C++ | src/test/metrics_tests.cpp | pro-bitcoin/pro-bitcoin | 8e73d85560d2efdfbb3aee66cadca7cdfeaac197 | [
"MIT"
] | null | null | null | src/test/metrics_tests.cpp | pro-bitcoin/pro-bitcoin | 8e73d85560d2efdfbb3aee66cadca7cdfeaac197 | [
"MIT"
] | null | null | null | src/test/metrics_tests.cpp | pro-bitcoin/pro-bitcoin | 8e73d85560d2efdfbb3aee66cadca7cdfeaac197 | [
"MIT"
] | 1 | 2021-12-06T10:24:50.000Z | 2021-12-06T10:24:50.000Z | #include <boost/test/unit_test.hpp>
#include <metrics/container.h>
#include <test/util/setup_common.h>
#include <txmempool.h>
BOOST_FIXTURE_TEST_SUITE(metrics_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(metrics_config)
{
std::map<std::string, prometheus::MetricType> metric_names;
auto& reg = metrics::Registry();
BOOST_CHECK(reg.Collect().size() > 0);
for (auto m : reg.Collect()) {
metric_names.insert({m.name, m.type});
}
std::vector<std::string> expected_names = {
"bitcoin_boot_time",
"block_connect_avg",
"block_connect_tip",
"block_tip",
"initial_block_download",
"mempool",
"mempool_changes",
"mempool_timer",
"mempool_orphans",
"net_bandwidth",
"net_connection",
"net_max_outbound",
"net_ping",
"net_ping_problem",
"net_socket",
"peer_connection",
"peer_permission",
"peer_process",
"peers_banned",
"peers_discourage",
"peer_send",
"peers_known",
"peers_misbehave",
"peer_process",
"peer_validation_result",
"transaction",
"tx_cache",
};
for (auto m : expected_names) {
auto found = metric_names.find(m);
BOOST_CHECK_MESSAGE(found != metric_names.end(), strprintf("metric %s is not found", m));
}
}
void check_mempool_reason(size_t reason)
{
auto& mempoolMetrics = metrics::Instance()->MemPool();
mempoolMetrics.Removed(reason);
auto v = mempoolMetrics.GetRemoved(reason);
BOOST_CHECK(v);
BOOST_CHECK_EQUAL(1, *v);
}
BOOST_AUTO_TEST_CASE(metrics_mempool_remove)
{
check_mempool_reason(static_cast<size_t>(MemPoolRemovalReason::BLOCK));
check_mempool_reason(static_cast<size_t>(MemPoolRemovalReason::CONFLICT));
check_mempool_reason(static_cast<size_t>(MemPoolRemovalReason::EXPIRY));
check_mempool_reason(static_cast<size_t>(MemPoolRemovalReason::REORG));
check_mempool_reason(static_cast<size_t>(MemPoolRemovalReason::REPLACED));
check_mempool_reason(static_cast<size_t>(MemPoolRemovalReason::SIZELIMIT));
}
BOOST_AUTO_TEST_CASE(metrics_rpc_counters)
{
auto& rpcMetrics = metrics::Instance()->Rpc();
rpcMetrics.ObserveMethod("amethod", 1000);
rpcMetrics.ObserveMethod("amethod", 2000);
BOOST_CHECK(rpcMetrics.HasMethod("amethod"));
rpcMetrics.IncrementError("amethod");
rpcMetrics.IncrementError("amethod");
BOOST_CHECK(rpcMetrics.GetErrorCount("amethod").has_value());
BOOST_CHECK_EQUAL(2, *rpcMetrics.GetErrorCount("amethod"));
std::map<std::string, prometheus::MetricType> metric_names;
auto& reg = metrics::Registry();
BOOST_CHECK(reg.Collect().size() > 0);
for (auto m : reg.Collect()) {
metric_names.insert({m.name, m.type});
}
std::vector<std::string> expected_names = {
"rpc_access",
"rpc_error",
};
for (auto m : expected_names) {
auto found = metric_names.find(m);
BOOST_CHECK_MESSAGE(found != metric_names.end(), strprintf("metric %s is not found", m));
}
}
BOOST_AUTO_TEST_SUITE_END()
| 31.168317 | 97 | 0.667408 | [
"vector"
] |
9fd5d90267ce6734c4daf44bac08815607c707cd | 521,469 | cc | C++ | libipp/ipp_operations.cc | strassek/chromiumos-platform2 | 12c953f41f48b8a6b0bd1c181d09bdb1de38325c | [
"BSD-3-Clause"
] | 4 | 2020-07-24T06:54:16.000Z | 2021-06-16T17:13:53.000Z | libipp/ipp_operations.cc | strassek/chromiumos-platform2 | 12c953f41f48b8a6b0bd1c181d09bdb1de38325c | [
"BSD-3-Clause"
] | 1 | 2021-04-02T17:35:07.000Z | 2021-04-02T17:35:07.000Z | libipp/ipp_operations.cc | strassek/chromiumos-platform2 | 12c953f41f48b8a6b0bd1c181d09bdb1de38325c | [
"BSD-3-Clause"
] | 1 | 2020-11-04T22:31:45.000Z | 2020-11-04T22:31:45.000Z | // Copyright 2019 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libipp/ipp_operations.h"
#include <memory>
namespace ipp {
std::unique_ptr<Request> Request::NewRequest(Operation id) {
switch (id) {
case Operation::CUPS_Add_Modify_Class:
return std::make_unique<Request_CUPS_Add_Modify_Class>();
case Operation::CUPS_Add_Modify_Printer:
return std::make_unique<Request_CUPS_Add_Modify_Printer>();
case Operation::CUPS_Authenticate_Job:
return std::make_unique<Request_CUPS_Authenticate_Job>();
case Operation::CUPS_Create_Local_Printer:
return std::make_unique<Request_CUPS_Create_Local_Printer>();
case Operation::CUPS_Delete_Class:
return std::make_unique<Request_CUPS_Delete_Class>();
case Operation::CUPS_Delete_Printer:
return std::make_unique<Request_CUPS_Delete_Printer>();
case Operation::CUPS_Get_Classes:
return std::make_unique<Request_CUPS_Get_Classes>();
case Operation::CUPS_Get_Default:
return std::make_unique<Request_CUPS_Get_Default>();
case Operation::CUPS_Get_Document:
return std::make_unique<Request_CUPS_Get_Document>();
case Operation::CUPS_Get_Printers:
return std::make_unique<Request_CUPS_Get_Printers>();
case Operation::CUPS_Move_Job:
return std::make_unique<Request_CUPS_Move_Job>();
case Operation::CUPS_Set_Default:
return std::make_unique<Request_CUPS_Set_Default>();
case Operation::Cancel_Job:
return std::make_unique<Request_Cancel_Job>();
case Operation::Create_Job:
return std::make_unique<Request_Create_Job>();
case Operation::Get_Job_Attributes:
return std::make_unique<Request_Get_Job_Attributes>();
case Operation::Get_Jobs:
return std::make_unique<Request_Get_Jobs>();
case Operation::Get_Printer_Attributes:
return std::make_unique<Request_Get_Printer_Attributes>();
case Operation::Hold_Job:
return std::make_unique<Request_Hold_Job>();
case Operation::Pause_Printer:
return std::make_unique<Request_Pause_Printer>();
case Operation::Print_Job:
return std::make_unique<Request_Print_Job>();
case Operation::Print_URI:
return std::make_unique<Request_Print_URI>();
case Operation::Release_Job:
return std::make_unique<Request_Release_Job>();
case Operation::Resume_Printer:
return std::make_unique<Request_Resume_Printer>();
case Operation::Send_Document:
return std::make_unique<Request_Send_Document>();
case Operation::Send_URI:
return std::make_unique<Request_Send_URI>();
case Operation::Validate_Job:
return std::make_unique<Request_Validate_Job>();
default:
return nullptr;
}
}
std::unique_ptr<Response> Response::NewResponse(Operation id) {
switch (id) {
case Operation::CUPS_Add_Modify_Class:
return std::make_unique<Response_CUPS_Add_Modify_Class>();
case Operation::CUPS_Add_Modify_Printer:
return std::make_unique<Response_CUPS_Add_Modify_Printer>();
case Operation::CUPS_Authenticate_Job:
return std::make_unique<Response_CUPS_Authenticate_Job>();
case Operation::CUPS_Create_Local_Printer:
return std::make_unique<Response_CUPS_Create_Local_Printer>();
case Operation::CUPS_Delete_Class:
return std::make_unique<Response_CUPS_Delete_Class>();
case Operation::CUPS_Delete_Printer:
return std::make_unique<Response_CUPS_Delete_Printer>();
case Operation::CUPS_Get_Classes:
return std::make_unique<Response_CUPS_Get_Classes>();
case Operation::CUPS_Get_Default:
return std::make_unique<Response_CUPS_Get_Default>();
case Operation::CUPS_Get_Document:
return std::make_unique<Response_CUPS_Get_Document>();
case Operation::CUPS_Get_Printers:
return std::make_unique<Response_CUPS_Get_Printers>();
case Operation::CUPS_Move_Job:
return std::make_unique<Response_CUPS_Move_Job>();
case Operation::CUPS_Set_Default:
return std::make_unique<Response_CUPS_Set_Default>();
case Operation::Cancel_Job:
return std::make_unique<Response_Cancel_Job>();
case Operation::Create_Job:
return std::make_unique<Response_Create_Job>();
case Operation::Get_Job_Attributes:
return std::make_unique<Response_Get_Job_Attributes>();
case Operation::Get_Jobs:
return std::make_unique<Response_Get_Jobs>();
case Operation::Get_Printer_Attributes:
return std::make_unique<Response_Get_Printer_Attributes>();
case Operation::Hold_Job:
return std::make_unique<Response_Hold_Job>();
case Operation::Pause_Printer:
return std::make_unique<Response_Pause_Printer>();
case Operation::Print_Job:
return std::make_unique<Response_Print_Job>();
case Operation::Print_URI:
return std::make_unique<Response_Print_URI>();
case Operation::Release_Job:
return std::make_unique<Response_Release_Job>();
case Operation::Resume_Printer:
return std::make_unique<Response_Resume_Printer>();
case Operation::Send_Document:
return std::make_unique<Response_Send_Document>();
case Operation::Send_URI:
return std::make_unique<Response_Send_URI>();
case Operation::Validate_Job:
return std::make_unique<Response_Validate_Job>();
default:
return nullptr;
}
}
Request_CUPS_Add_Modify_Class::Request_CUPS_Add_Modify_Class()
: Request(Operation::CUPS_Add_Modify_Class) {}
std::vector<Group*> Request_CUPS_Add_Modify_Class::GetKnownGroups() {
return {&operation_attributes, &printer_attributes};
}
std::vector<const Group*> Request_CUPS_Add_Modify_Class::GetKnownGroups()
const {
return {&operation_attributes, &printer_attributes};
}
std::vector<Attribute*>
Request_CUPS_Add_Modify_Class::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset, &attributes_natural_language, &printer_uri};
}
std::vector<const Attribute*>
Request_CUPS_Add_Modify_Class::G_operation_attributes::GetKnownAttributes()
const {
return {&attributes_charset, &attributes_natural_language, &printer_uri};
}
const std::map<AttrName, AttrDef>
Request_CUPS_Add_Modify_Class::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}}};
std::vector<Attribute*>
Request_CUPS_Add_Modify_Class::G_printer_attributes::GetKnownAttributes() {
return {&auth_info_required,
&member_uris,
&printer_is_accepting_jobs,
&printer_info,
&printer_location,
&printer_more_info,
&printer_state,
&printer_state_message,
&requesting_user_name_allowed,
&requesting_user_name_denied};
}
std::vector<const Attribute*>
Request_CUPS_Add_Modify_Class::G_printer_attributes::GetKnownAttributes()
const {
return {&auth_info_required,
&member_uris,
&printer_is_accepting_jobs,
&printer_info,
&printer_location,
&printer_more_info,
&printer_state,
&printer_state_message,
&requesting_user_name_allowed,
&requesting_user_name_denied};
}
const std::map<AttrName, AttrDef>
Request_CUPS_Add_Modify_Class::G_printer_attributes::defs_{
{AttrName::auth_info_required,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::member_uris, {AttrType::uri, InternalType::kString, true}},
{AttrName::printer_is_accepting_jobs,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::printer_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_location,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_more_info,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_state,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::printer_state_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::requesting_user_name_allowed,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::requesting_user_name_denied,
{AttrType::name, InternalType::kStringWithLanguage, true}}};
Response_CUPS_Add_Modify_Class::Response_CUPS_Add_Modify_Class()
: Response(Operation::CUPS_Add_Modify_Class) {}
std::vector<Group*> Response_CUPS_Add_Modify_Class::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Response_CUPS_Add_Modify_Class::GetKnownGroups()
const {
return {&operation_attributes};
}
std::vector<Attribute*>
Response_CUPS_Add_Modify_Class::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset, &attributes_natural_language, &status_message,
&detailed_status_message};
}
std::vector<const Attribute*>
Response_CUPS_Add_Modify_Class::G_operation_attributes::GetKnownAttributes()
const {
return {&attributes_charset, &attributes_natural_language, &status_message,
&detailed_status_message};
}
const std::map<AttrName, AttrDef>
Response_CUPS_Add_Modify_Class::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::status_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::detailed_status_message,
{AttrType::text, InternalType::kStringWithLanguage, false}}};
Request_CUPS_Add_Modify_Printer::Request_CUPS_Add_Modify_Printer()
: Request(Operation::CUPS_Add_Modify_Printer) {}
std::vector<Group*> Request_CUPS_Add_Modify_Printer::GetKnownGroups() {
return {&operation_attributes, &printer_attributes};
}
std::vector<const Group*> Request_CUPS_Add_Modify_Printer::GetKnownGroups()
const {
return {&operation_attributes, &printer_attributes};
}
std::vector<Attribute*>
Request_CUPS_Add_Modify_Printer::G_printer_attributes::GetKnownAttributes() {
return {&auth_info_required,
&job_sheets_default,
&device_uri,
&printer_is_accepting_jobs,
&printer_info,
&printer_location,
&printer_more_info,
&printer_state,
&printer_state_message,
&requesting_user_name_allowed,
&requesting_user_name_denied};
}
std::vector<const Attribute*>
Request_CUPS_Add_Modify_Printer::G_printer_attributes::GetKnownAttributes()
const {
return {&auth_info_required,
&job_sheets_default,
&device_uri,
&printer_is_accepting_jobs,
&printer_info,
&printer_location,
&printer_more_info,
&printer_state,
&printer_state_message,
&requesting_user_name_allowed,
&requesting_user_name_denied};
}
const std::map<AttrName, AttrDef>
Request_CUPS_Add_Modify_Printer::G_printer_attributes::defs_{
{AttrName::auth_info_required,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::job_sheets_default,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::device_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::printer_is_accepting_jobs,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::printer_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_location,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_more_info,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_state,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::printer_state_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::requesting_user_name_allowed,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::requesting_user_name_denied,
{AttrType::name, InternalType::kStringWithLanguage, true}}};
Response_CUPS_Add_Modify_Printer::Response_CUPS_Add_Modify_Printer()
: Response(Operation::CUPS_Add_Modify_Printer) {}
std::vector<Group*> Response_CUPS_Add_Modify_Printer::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Response_CUPS_Add_Modify_Printer::GetKnownGroups()
const {
return {&operation_attributes};
}
Request_CUPS_Authenticate_Job::Request_CUPS_Authenticate_Job()
: Request(Operation::CUPS_Authenticate_Job) {}
std::vector<Group*> Request_CUPS_Authenticate_Job::GetKnownGroups() {
return {&operation_attributes, &job_attributes};
}
std::vector<const Group*> Request_CUPS_Authenticate_Job::GetKnownGroups()
const {
return {&operation_attributes, &job_attributes};
}
std::vector<Attribute*>
Request_CUPS_Authenticate_Job::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset, &attributes_natural_language, &printer_uri,
&job_id, &job_uri};
}
std::vector<const Attribute*>
Request_CUPS_Authenticate_Job::G_operation_attributes::GetKnownAttributes()
const {
return {&attributes_charset, &attributes_natural_language, &printer_uri,
&job_id, &job_uri};
}
const std::map<AttrName, AttrDef>
Request_CUPS_Authenticate_Job::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::job_id, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_uri, {AttrType::uri, InternalType::kString, false}}};
std::vector<Attribute*>
Request_CUPS_Authenticate_Job::G_job_attributes::GetKnownAttributes() {
return {&auth_info, &job_hold_until};
}
std::vector<const Attribute*>
Request_CUPS_Authenticate_Job::G_job_attributes::GetKnownAttributes() const {
return {&auth_info, &job_hold_until};
}
const std::map<AttrName, AttrDef>
Request_CUPS_Authenticate_Job::G_job_attributes::defs_{
{AttrName::auth_info,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::job_hold_until,
{AttrType::keyword, InternalType::kString, false}}};
Response_CUPS_Authenticate_Job::Response_CUPS_Authenticate_Job()
: Response(Operation::CUPS_Authenticate_Job) {}
std::vector<Group*> Response_CUPS_Authenticate_Job::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes};
}
std::vector<const Group*> Response_CUPS_Authenticate_Job::GetKnownGroups()
const {
return {&operation_attributes, &unsupported_attributes};
}
std::vector<Attribute*>
Response_CUPS_Authenticate_Job::G_unsupported_attributes::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*>
Response_CUPS_Authenticate_Job::G_unsupported_attributes::GetKnownAttributes()
const {
return {};
}
const std::map<AttrName, AttrDef>
Response_CUPS_Authenticate_Job::G_unsupported_attributes::defs_{};
Request_CUPS_Create_Local_Printer::Request_CUPS_Create_Local_Printer()
: Request(Operation::CUPS_Create_Local_Printer) {}
std::vector<Group*> Request_CUPS_Create_Local_Printer::GetKnownGroups() {
return {&operation_attributes, &printer_attributes};
}
std::vector<const Group*> Request_CUPS_Create_Local_Printer::GetKnownGroups()
const {
return {&operation_attributes, &printer_attributes};
}
std::vector<Attribute*> Request_CUPS_Create_Local_Printer::
G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset, &attributes_natural_language};
}
std::vector<const Attribute*>
Request_CUPS_Create_Local_Printer::G_operation_attributes::GetKnownAttributes()
const {
return {&attributes_charset, &attributes_natural_language};
}
const std::map<AttrName, AttrDef>
Request_CUPS_Create_Local_Printer::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}}};
std::vector<Attribute*>
Request_CUPS_Create_Local_Printer::G_printer_attributes::GetKnownAttributes() {
return {&printer_name, &device_uri, &printer_device_id,
&printer_geo_location, &printer_info, &printer_location};
}
std::vector<const Attribute*>
Request_CUPS_Create_Local_Printer::G_printer_attributes::GetKnownAttributes()
const {
return {&printer_name, &device_uri, &printer_device_id,
&printer_geo_location, &printer_info, &printer_location};
}
const std::map<AttrName, AttrDef>
Request_CUPS_Create_Local_Printer::G_printer_attributes::defs_{
{AttrName::printer_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::device_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::printer_device_id,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_geo_location,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_location,
{AttrType::text, InternalType::kStringWithLanguage, false}}};
Response_CUPS_Create_Local_Printer::Response_CUPS_Create_Local_Printer()
: Response(Operation::CUPS_Create_Local_Printer) {}
std::vector<Group*> Response_CUPS_Create_Local_Printer::GetKnownGroups() {
return {&operation_attributes, &printer_attributes};
}
std::vector<const Group*> Response_CUPS_Create_Local_Printer::GetKnownGroups()
const {
return {&operation_attributes, &printer_attributes};
}
std::vector<Attribute*>
Response_CUPS_Create_Local_Printer::G_printer_attributes::GetKnownAttributes() {
return {&printer_id, &printer_is_accepting_jobs, &printer_state,
&printer_state_reasons, &printer_uri_supported};
}
std::vector<const Attribute*>
Response_CUPS_Create_Local_Printer::G_printer_attributes::GetKnownAttributes()
const {
return {&printer_id, &printer_is_accepting_jobs, &printer_state,
&printer_state_reasons, &printer_uri_supported};
}
const std::map<AttrName, AttrDef>
Response_CUPS_Create_Local_Printer::G_printer_attributes::defs_{
{AttrName::printer_id,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_is_accepting_jobs,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::printer_state,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::printer_state_reasons,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::printer_uri_supported,
{AttrType::uri, InternalType::kString, true}}};
Request_CUPS_Delete_Class::Request_CUPS_Delete_Class()
: Request(Operation::CUPS_Delete_Class) {}
std::vector<Group*> Request_CUPS_Delete_Class::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_CUPS_Delete_Class::GetKnownGroups() const {
return {&operation_attributes};
}
Response_CUPS_Delete_Class::Response_CUPS_Delete_Class()
: Response(Operation::CUPS_Delete_Class) {}
std::vector<Group*> Response_CUPS_Delete_Class::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Response_CUPS_Delete_Class::GetKnownGroups() const {
return {&operation_attributes};
}
Request_CUPS_Delete_Printer::Request_CUPS_Delete_Printer()
: Request(Operation::CUPS_Delete_Printer) {}
std::vector<Group*> Request_CUPS_Delete_Printer::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_CUPS_Delete_Printer::GetKnownGroups() const {
return {&operation_attributes};
}
Response_CUPS_Delete_Printer::Response_CUPS_Delete_Printer()
: Response(Operation::CUPS_Delete_Printer) {}
std::vector<Group*> Response_CUPS_Delete_Printer::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Response_CUPS_Delete_Printer::GetKnownGroups() const {
return {&operation_attributes};
}
Request_CUPS_Get_Classes::Request_CUPS_Get_Classes()
: Request(Operation::CUPS_Get_Classes) {}
std::vector<Group*> Request_CUPS_Get_Classes::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_CUPS_Get_Classes::GetKnownGroups() const {
return {&operation_attributes};
}
std::vector<Attribute*>
Request_CUPS_Get_Classes::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset, &attributes_natural_language,
&first_printer_name, &limit,
&printer_location, &printer_type,
&printer_type_mask, &requested_attributes,
&requested_user_name};
}
std::vector<const Attribute*>
Request_CUPS_Get_Classes::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset, &attributes_natural_language,
&first_printer_name, &limit,
&printer_location, &printer_type,
&printer_type_mask, &requested_attributes,
&requested_user_name};
}
const std::map<AttrName, AttrDef>
Request_CUPS_Get_Classes::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::first_printer_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::limit, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_location,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_type,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_type_mask,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::requested_attributes,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::requested_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
Response_CUPS_Get_Classes::Response_CUPS_Get_Classes()
: Response(Operation::CUPS_Get_Classes) {}
std::vector<Group*> Response_CUPS_Get_Classes::GetKnownGroups() {
return {&operation_attributes, &printer_attributes};
}
std::vector<const Group*> Response_CUPS_Get_Classes::GetKnownGroups() const {
return {&operation_attributes, &printer_attributes};
}
std::vector<Attribute*>
Response_CUPS_Get_Classes::G_printer_attributes::GetKnownAttributes() {
return {&member_names, &member_uris};
}
std::vector<const Attribute*>
Response_CUPS_Get_Classes::G_printer_attributes::GetKnownAttributes() const {
return {&member_names, &member_uris};
}
const std::map<AttrName, AttrDef>
Response_CUPS_Get_Classes::G_printer_attributes::defs_{
{AttrName::member_names,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::member_uris, {AttrType::uri, InternalType::kString, true}}};
Request_CUPS_Get_Default::Request_CUPS_Get_Default()
: Request(Operation::CUPS_Get_Default) {}
std::vector<Group*> Request_CUPS_Get_Default::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_CUPS_Get_Default::GetKnownGroups() const {
return {&operation_attributes};
}
std::vector<Attribute*>
Request_CUPS_Get_Default::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset, &attributes_natural_language,
&requested_attributes};
}
std::vector<const Attribute*>
Request_CUPS_Get_Default::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset, &attributes_natural_language,
&requested_attributes};
}
const std::map<AttrName, AttrDef>
Request_CUPS_Get_Default::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::requested_attributes,
{AttrType::keyword, InternalType::kString, true}}};
Response_CUPS_Get_Default::Response_CUPS_Get_Default()
: Response(Operation::CUPS_Get_Default) {}
std::vector<Group*> Response_CUPS_Get_Default::GetKnownGroups() {
return {&operation_attributes, &printer_attributes};
}
std::vector<const Group*> Response_CUPS_Get_Default::GetKnownGroups() const {
return {&operation_attributes, &printer_attributes};
}
std::vector<Attribute*>
Response_CUPS_Get_Default::G_printer_attributes::GetKnownAttributes() {
return {&baling_type_supported,
&baling_when_supported,
&binding_reference_edge_supported,
&binding_type_supported,
&charset_configured,
&charset_supported,
&coating_sides_supported,
&coating_type_supported,
&color_supported,
&compression_supported,
&copies_default,
&copies_supported,
&cover_back_default,
&cover_back_supported,
&cover_front_default,
&cover_front_supported,
&covering_name_supported,
&document_charset_default,
&document_charset_supported,
&document_digital_signature_default,
&document_digital_signature_supported,
&document_format_default,
&document_format_details_default,
&document_format_details_supported,
&document_format_supported,
&document_format_version_default,
&document_format_version_supported,
&document_natural_language_default,
&document_natural_language_supported,
&document_password_supported,
&feed_orientation_supported,
&finishing_template_supported,
&finishings_col_database,
&finishings_col_default,
&finishings_col_ready,
&finishings_default,
&finishings_ready,
&finishings_supported,
&folding_direction_supported,
&folding_offset_supported,
&folding_reference_edge_supported,
&font_name_requested_default,
&font_name_requested_supported,
&font_size_requested_default,
&font_size_requested_supported,
&generated_natural_language_supported,
&identify_actions_default,
&identify_actions_supported,
&insert_after_page_number_supported,
&insert_count_supported,
&insert_sheet_default,
&ipp_features_supported,
&ipp_versions_supported,
&ippget_event_life,
&job_account_id_default,
&job_account_id_supported,
&job_account_type_default,
&job_account_type_supported,
&job_accounting_sheets_default,
&job_accounting_user_id_default,
&job_accounting_user_id_supported,
&job_authorization_uri_supported,
&job_constraints_supported,
&job_copies_default,
&job_copies_supported,
&job_cover_back_default,
&job_cover_back_supported,
&job_cover_front_default,
&job_cover_front_supported,
&job_delay_output_until_default,
&job_delay_output_until_supported,
&job_delay_output_until_time_supported,
&job_error_action_default,
&job_error_action_supported,
&job_error_sheet_default,
&job_finishings_col_default,
&job_finishings_col_ready,
&job_finishings_default,
&job_finishings_ready,
&job_finishings_supported,
&job_hold_until_default,
&job_hold_until_supported,
&job_hold_until_time_supported,
&job_ids_supported,
&job_impressions_supported,
&job_k_octets_supported,
&job_media_sheets_supported,
&job_message_to_operator_default,
&job_message_to_operator_supported,
&job_pages_per_set_supported,
&job_password_encryption_supported,
&job_password_supported,
&job_phone_number_default,
&job_phone_number_supported,
&job_priority_default,
&job_priority_supported,
&job_recipient_name_default,
&job_recipient_name_supported,
&job_resolvers_supported,
&job_sheet_message_default,
&job_sheet_message_supported,
&job_sheets_col_default,
&job_sheets_default,
&job_sheets_supported,
&job_spooling_supported,
&jpeg_k_octets_supported,
&jpeg_x_dimension_supported,
&jpeg_y_dimension_supported,
&laminating_sides_supported,
&laminating_type_supported,
&max_save_info_supported,
&max_stitching_locations_supported,
&media_back_coating_supported,
&media_bottom_margin_supported,
&media_col_database,
&media_col_default,
&media_col_ready,
&media_color_supported,
&media_default,
&media_front_coating_supported,
&media_grain_supported,
&media_hole_count_supported,
&media_info_supported,
&media_left_margin_supported,
&media_order_count_supported,
&media_pre_printed_supported,
&media_ready,
&media_recycled_supported,
&media_right_margin_supported,
&media_size_supported,
&media_source_supported,
&media_supported,
&media_thickness_supported,
&media_tooth_supported,
&media_top_margin_supported,
&media_type_supported,
&media_weight_metric_supported,
&multiple_document_handling_default,
&multiple_document_handling_supported,
&multiple_document_jobs_supported,
&multiple_operation_time_out,
&multiple_operation_time_out_action,
&natural_language_configured,
¬ify_events_default,
¬ify_events_supported,
¬ify_lease_duration_default,
¬ify_lease_duration_supported,
¬ify_pull_method_supported,
¬ify_schemes_supported,
&number_up_default,
&number_up_supported,
&oauth_authorization_server_uri,
&operations_supported,
&orientation_requested_default,
&orientation_requested_supported,
&output_bin_default,
&output_bin_supported,
&output_device_supported,
&output_device_uuid_supported,
&page_delivery_default,
&page_delivery_supported,
&page_order_received_default,
&page_order_received_supported,
&page_ranges_supported,
&pages_per_subset_supported,
&parent_printers_supported,
&pdf_k_octets_supported,
&pdf_versions_supported,
&pdl_init_file_default,
&pdl_init_file_entry_supported,
&pdl_init_file_location_supported,
&pdl_init_file_name_subdirectory_supported,
&pdl_init_file_name_supported,
&pdl_init_file_supported,
&pdl_override_supported,
&preferred_attributes_supported,
&presentation_direction_number_up_default,
&presentation_direction_number_up_supported,
&print_color_mode_default,
&print_color_mode_supported,
&print_content_optimize_default,
&print_content_optimize_supported,
&print_quality_default,
&print_quality_supported,
&print_rendering_intent_default,
&print_rendering_intent_supported,
&printer_charge_info,
&printer_charge_info_uri,
&printer_contact_col,
&printer_current_time,
&printer_device_id,
&printer_dns_sd_name,
&printer_driver_installer,
&printer_geo_location,
&printer_icc_profiles,
&printer_icons,
&printer_info,
&printer_location,
&printer_make_and_model,
&printer_more_info_manufacturer,
&printer_name,
&printer_organization,
&printer_organizational_unit,
&printer_resolution_default,
&printer_resolution_supported,
&printer_static_resource_directory_uri,
&printer_static_resource_k_octets_supported,
&printer_strings_languages_supported,
&printer_strings_uri,
&printer_xri_supported,
&proof_print_default,
&proof_print_supported,
&punching_hole_diameter_configured,
&punching_locations_supported,
&punching_offset_supported,
&punching_reference_edge_supported,
&pwg_raster_document_resolution_supported,
&pwg_raster_document_sheet_back,
&pwg_raster_document_type_supported,
&reference_uri_schemes_supported,
&requesting_user_uri_supported,
&save_disposition_supported,
&save_document_format_default,
&save_document_format_supported,
&save_location_default,
&save_location_supported,
&save_name_subdirectory_supported,
&save_name_supported,
&separator_sheets_default,
&sheet_collate_default,
&sheet_collate_supported,
&sides_default,
&sides_supported,
&stitching_angle_supported,
&stitching_locations_supported,
&stitching_method_supported,
&stitching_offset_supported,
&stitching_reference_edge_supported,
&subordinate_printers_supported,
&trimming_offset_supported,
&trimming_reference_edge_supported,
&trimming_type_supported,
&trimming_when_supported,
&uri_authentication_supported,
&uri_security_supported,
&which_jobs_supported,
&x_image_position_default,
&x_image_position_supported,
&x_image_shift_default,
&x_image_shift_supported,
&x_side1_image_shift_default,
&x_side1_image_shift_supported,
&x_side2_image_shift_default,
&x_side2_image_shift_supported,
&y_image_position_default,
&y_image_position_supported,
&y_image_shift_default,
&y_image_shift_supported,
&y_side1_image_shift_default,
&y_side1_image_shift_supported,
&y_side2_image_shift_default,
&y_side2_image_shift_supported};
}
std::vector<const Attribute*>
Response_CUPS_Get_Default::G_printer_attributes::GetKnownAttributes() const {
return {&baling_type_supported,
&baling_when_supported,
&binding_reference_edge_supported,
&binding_type_supported,
&charset_configured,
&charset_supported,
&coating_sides_supported,
&coating_type_supported,
&color_supported,
&compression_supported,
&copies_default,
&copies_supported,
&cover_back_default,
&cover_back_supported,
&cover_front_default,
&cover_front_supported,
&covering_name_supported,
&document_charset_default,
&document_charset_supported,
&document_digital_signature_default,
&document_digital_signature_supported,
&document_format_default,
&document_format_details_default,
&document_format_details_supported,
&document_format_supported,
&document_format_version_default,
&document_format_version_supported,
&document_natural_language_default,
&document_natural_language_supported,
&document_password_supported,
&feed_orientation_supported,
&finishing_template_supported,
&finishings_col_database,
&finishings_col_default,
&finishings_col_ready,
&finishings_default,
&finishings_ready,
&finishings_supported,
&folding_direction_supported,
&folding_offset_supported,
&folding_reference_edge_supported,
&font_name_requested_default,
&font_name_requested_supported,
&font_size_requested_default,
&font_size_requested_supported,
&generated_natural_language_supported,
&identify_actions_default,
&identify_actions_supported,
&insert_after_page_number_supported,
&insert_count_supported,
&insert_sheet_default,
&ipp_features_supported,
&ipp_versions_supported,
&ippget_event_life,
&job_account_id_default,
&job_account_id_supported,
&job_account_type_default,
&job_account_type_supported,
&job_accounting_sheets_default,
&job_accounting_user_id_default,
&job_accounting_user_id_supported,
&job_authorization_uri_supported,
&job_constraints_supported,
&job_copies_default,
&job_copies_supported,
&job_cover_back_default,
&job_cover_back_supported,
&job_cover_front_default,
&job_cover_front_supported,
&job_delay_output_until_default,
&job_delay_output_until_supported,
&job_delay_output_until_time_supported,
&job_error_action_default,
&job_error_action_supported,
&job_error_sheet_default,
&job_finishings_col_default,
&job_finishings_col_ready,
&job_finishings_default,
&job_finishings_ready,
&job_finishings_supported,
&job_hold_until_default,
&job_hold_until_supported,
&job_hold_until_time_supported,
&job_ids_supported,
&job_impressions_supported,
&job_k_octets_supported,
&job_media_sheets_supported,
&job_message_to_operator_default,
&job_message_to_operator_supported,
&job_pages_per_set_supported,
&job_password_encryption_supported,
&job_password_supported,
&job_phone_number_default,
&job_phone_number_supported,
&job_priority_default,
&job_priority_supported,
&job_recipient_name_default,
&job_recipient_name_supported,
&job_resolvers_supported,
&job_sheet_message_default,
&job_sheet_message_supported,
&job_sheets_col_default,
&job_sheets_default,
&job_sheets_supported,
&job_spooling_supported,
&jpeg_k_octets_supported,
&jpeg_x_dimension_supported,
&jpeg_y_dimension_supported,
&laminating_sides_supported,
&laminating_type_supported,
&max_save_info_supported,
&max_stitching_locations_supported,
&media_back_coating_supported,
&media_bottom_margin_supported,
&media_col_database,
&media_col_default,
&media_col_ready,
&media_color_supported,
&media_default,
&media_front_coating_supported,
&media_grain_supported,
&media_hole_count_supported,
&media_info_supported,
&media_left_margin_supported,
&media_order_count_supported,
&media_pre_printed_supported,
&media_ready,
&media_recycled_supported,
&media_right_margin_supported,
&media_size_supported,
&media_source_supported,
&media_supported,
&media_thickness_supported,
&media_tooth_supported,
&media_top_margin_supported,
&media_type_supported,
&media_weight_metric_supported,
&multiple_document_handling_default,
&multiple_document_handling_supported,
&multiple_document_jobs_supported,
&multiple_operation_time_out,
&multiple_operation_time_out_action,
&natural_language_configured,
¬ify_events_default,
¬ify_events_supported,
¬ify_lease_duration_default,
¬ify_lease_duration_supported,
¬ify_pull_method_supported,
¬ify_schemes_supported,
&number_up_default,
&number_up_supported,
&oauth_authorization_server_uri,
&operations_supported,
&orientation_requested_default,
&orientation_requested_supported,
&output_bin_default,
&output_bin_supported,
&output_device_supported,
&output_device_uuid_supported,
&page_delivery_default,
&page_delivery_supported,
&page_order_received_default,
&page_order_received_supported,
&page_ranges_supported,
&pages_per_subset_supported,
&parent_printers_supported,
&pdf_k_octets_supported,
&pdf_versions_supported,
&pdl_init_file_default,
&pdl_init_file_entry_supported,
&pdl_init_file_location_supported,
&pdl_init_file_name_subdirectory_supported,
&pdl_init_file_name_supported,
&pdl_init_file_supported,
&pdl_override_supported,
&preferred_attributes_supported,
&presentation_direction_number_up_default,
&presentation_direction_number_up_supported,
&print_color_mode_default,
&print_color_mode_supported,
&print_content_optimize_default,
&print_content_optimize_supported,
&print_quality_default,
&print_quality_supported,
&print_rendering_intent_default,
&print_rendering_intent_supported,
&printer_charge_info,
&printer_charge_info_uri,
&printer_contact_col,
&printer_current_time,
&printer_device_id,
&printer_dns_sd_name,
&printer_driver_installer,
&printer_geo_location,
&printer_icc_profiles,
&printer_icons,
&printer_info,
&printer_location,
&printer_make_and_model,
&printer_more_info_manufacturer,
&printer_name,
&printer_organization,
&printer_organizational_unit,
&printer_resolution_default,
&printer_resolution_supported,
&printer_static_resource_directory_uri,
&printer_static_resource_k_octets_supported,
&printer_strings_languages_supported,
&printer_strings_uri,
&printer_xri_supported,
&proof_print_default,
&proof_print_supported,
&punching_hole_diameter_configured,
&punching_locations_supported,
&punching_offset_supported,
&punching_reference_edge_supported,
&pwg_raster_document_resolution_supported,
&pwg_raster_document_sheet_back,
&pwg_raster_document_type_supported,
&reference_uri_schemes_supported,
&requesting_user_uri_supported,
&save_disposition_supported,
&save_document_format_default,
&save_document_format_supported,
&save_location_default,
&save_location_supported,
&save_name_subdirectory_supported,
&save_name_supported,
&separator_sheets_default,
&sheet_collate_default,
&sheet_collate_supported,
&sides_default,
&sides_supported,
&stitching_angle_supported,
&stitching_locations_supported,
&stitching_method_supported,
&stitching_offset_supported,
&stitching_reference_edge_supported,
&subordinate_printers_supported,
&trimming_offset_supported,
&trimming_reference_edge_supported,
&trimming_type_supported,
&trimming_when_supported,
&uri_authentication_supported,
&uri_security_supported,
&which_jobs_supported,
&x_image_position_default,
&x_image_position_supported,
&x_image_shift_default,
&x_image_shift_supported,
&x_side1_image_shift_default,
&x_side1_image_shift_supported,
&x_side2_image_shift_default,
&x_side2_image_shift_supported,
&y_image_position_default,
&y_image_position_supported,
&y_image_shift_default,
&y_image_shift_supported,
&y_side1_image_shift_default,
&y_side1_image_shift_supported,
&y_side2_image_shift_default,
&y_side2_image_shift_supported};
}
const std::map<AttrName, AttrDef>
Response_CUPS_Get_Default::G_printer_attributes::defs_{
{AttrName::baling_type_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::baling_when_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::binding_reference_edge_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::binding_type_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::charset_configured,
{AttrType::charset, InternalType::kString, false}},
{AttrName::charset_supported,
{AttrType::charset, InternalType::kString, true}},
{AttrName::coating_sides_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::coating_type_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::color_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::compression_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::copies_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::copies_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::cover_back_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_back_default(); }}},
{AttrName::cover_back_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::cover_front_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_front_default(); }}},
{AttrName::cover_front_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::covering_name_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::document_charset_default,
{AttrType::charset, InternalType::kString, false}},
{AttrName::document_charset_supported,
{AttrType::charset, InternalType::kString, true}},
{AttrName::document_digital_signature_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::document_digital_signature_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::document_format_default,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::document_format_details_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* {
return new C_document_format_details_default();
}}},
{AttrName::document_format_details_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::document_format_supported,
{AttrType::mimeMediaType, InternalType::kString, true}},
{AttrName::document_format_version_default,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_format_version_supported,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::document_natural_language_default,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::document_natural_language_supported,
{AttrType::naturalLanguage, InternalType::kString, true}},
{AttrName::document_password_supported,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::feed_orientation_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::finishing_template_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::finishings_col_database,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_finishings_col_database(); }}},
{AttrName::finishings_col_default,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_finishings_col_default(); }}},
{AttrName::finishings_col_ready,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_finishings_col_ready(); }}},
{AttrName::finishings_default,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::finishings_ready,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::finishings_supported,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::folding_direction_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::folding_offset_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::folding_reference_edge_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::font_name_requested_default,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::font_name_requested_supported,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::font_size_requested_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::font_size_requested_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::generated_natural_language_supported,
{AttrType::naturalLanguage, InternalType::kString, true}},
{AttrName::identify_actions_default,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::identify_actions_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::insert_after_page_number_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::insert_count_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::insert_sheet_default,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_insert_sheet_default(); }}},
{AttrName::ipp_features_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::ipp_versions_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::ippget_event_life,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_account_id_default,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_account_id_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_account_type_default,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_account_type_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::job_accounting_sheets_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* {
return new C_job_accounting_sheets_default();
}}},
{AttrName::job_accounting_user_id_default,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_accounting_user_id_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_authorization_uri_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_constraints_supported,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_constraints_supported(); }}},
{AttrName::job_copies_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_copies_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::job_cover_back_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_back_default(); }}},
{AttrName::job_cover_back_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::job_cover_front_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_front_default(); }}},
{AttrName::job_cover_front_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::job_delay_output_until_default,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_delay_output_until_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::job_delay_output_until_time_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::job_error_action_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::job_error_action_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::job_error_sheet_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_error_sheet_default(); }}},
{AttrName::job_finishings_col_default,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_finishings_col_default(); }}},
{AttrName::job_finishings_col_ready,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_finishings_col_ready(); }}},
{AttrName::job_finishings_default,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::job_finishings_ready,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::job_finishings_supported,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::job_hold_until_default,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_hold_until_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::job_hold_until_time_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::job_ids_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_impressions_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::job_k_octets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::job_media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::job_message_to_operator_default,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_message_to_operator_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_pages_per_set_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_password_encryption_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::job_password_supported,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_phone_number_default,
{AttrType::uri, InternalType::kString, false}},
{AttrName::job_phone_number_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_priority_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_priority_supported,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_recipient_name_default,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_recipient_name_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_resolvers_supported,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_resolvers_supported(); }}},
{AttrName::job_sheet_message_default,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_sheet_message_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_sheets_col_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_sheets_col_default(); }}},
{AttrName::job_sheets_default,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_sheets_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::job_spooling_supported,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::jpeg_k_octets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::jpeg_x_dimension_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::jpeg_y_dimension_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::laminating_sides_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::laminating_type_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::max_save_info_supported,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::max_stitching_locations_supported,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_back_coating_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_bottom_margin_supported,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::media_col_database,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_media_col_database(); }}},
{AttrName::media_col_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col_default(); }}},
{AttrName::media_col_ready,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_media_col_ready(); }}},
{AttrName::media_color_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_default,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_front_coating_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_grain_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_hole_count_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::media_info_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::media_left_margin_supported,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::media_order_count_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::media_pre_printed_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_ready,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_recycled_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_right_margin_supported,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::media_size_supported,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_media_size_supported(); }}},
{AttrName::media_source_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_thickness_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_tooth_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_top_margin_supported,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::media_type_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_weight_metric_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::multiple_document_handling_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::multiple_document_handling_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::multiple_document_jobs_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::multiple_operation_time_out,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::multiple_operation_time_out_action,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::natural_language_configured,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::notify_events_default,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::notify_events_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::notify_lease_duration_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::notify_lease_duration_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::notify_pull_method_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::notify_schemes_supported,
{AttrType::uriScheme, InternalType::kString, true}},
{AttrName::number_up_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::number_up_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::oauth_authorization_server_uri,
{AttrType::uri, InternalType::kString, false}},
{AttrName::operations_supported,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::orientation_requested_default,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::orientation_requested_supported,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::output_bin_default,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::output_bin_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::output_device_supported,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::output_device_uuid_supported,
{AttrType::uri, InternalType::kString, true}},
{AttrName::page_delivery_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_delivery_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::page_order_received_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_order_received_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::page_ranges_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::pages_per_subset_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::parent_printers_supported,
{AttrType::uri, InternalType::kString, true}},
{AttrName::pdf_k_octets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::pdf_versions_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::pdl_init_file_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_pdl_init_file_default(); }}},
{AttrName::pdl_init_file_entry_supported,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::pdl_init_file_location_supported,
{AttrType::uri, InternalType::kString, true}},
{AttrName::pdl_init_file_name_subdirectory_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::pdl_init_file_name_supported,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::pdl_init_file_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::pdl_override_supported,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::preferred_attributes_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::presentation_direction_number_up_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::presentation_direction_number_up_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::print_color_mode_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_color_mode_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::print_content_optimize_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_content_optimize_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::print_quality_default,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::print_quality_supported,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::print_rendering_intent_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_rendering_intent_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::printer_charge_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_charge_info_uri,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_contact_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_printer_contact_col(); }}},
{AttrName::printer_current_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::printer_device_id,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_dns_sd_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::printer_driver_installer,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_geo_location,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_icc_profiles,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_printer_icc_profiles(); }}},
{AttrName::printer_icons, {AttrType::uri, InternalType::kString, true}},
{AttrName::printer_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_location,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_make_and_model,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_more_info_manufacturer,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::printer_organization,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::printer_organizational_unit,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::printer_resolution_default,
{AttrType::resolution, InternalType::kResolution, false}},
{AttrName::printer_resolution_supported,
{AttrType::resolution, InternalType::kResolution, false}},
{AttrName::printer_static_resource_directory_uri,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_static_resource_k_octets_supported,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_strings_languages_supported,
{AttrType::naturalLanguage, InternalType::kString, true}},
{AttrName::printer_strings_uri,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_xri_supported,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_printer_xri_supported(); }}},
{AttrName::proof_print_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_proof_print_default(); }}},
{AttrName::proof_print_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::punching_hole_diameter_configured,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_locations_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::punching_offset_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::punching_reference_edge_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::pwg_raster_document_resolution_supported,
{AttrType::resolution, InternalType::kResolution, true}},
{AttrName::pwg_raster_document_sheet_back,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::pwg_raster_document_type_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::reference_uri_schemes_supported,
{AttrType::uriScheme, InternalType::kString, true}},
{AttrName::requesting_user_uri_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::save_disposition_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::save_document_format_default,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::save_document_format_supported,
{AttrType::mimeMediaType, InternalType::kString, true}},
{AttrName::save_location_default,
{AttrType::uri, InternalType::kString, false}},
{AttrName::save_location_supported,
{AttrType::uri, InternalType::kString, true}},
{AttrName::save_name_subdirectory_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::save_name_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::separator_sheets_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_separator_sheets_default(); }}},
{AttrName::sheet_collate_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::sheet_collate_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::sides_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::sides_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::stitching_angle_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::stitching_locations_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::stitching_method_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::stitching_offset_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::stitching_reference_edge_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::subordinate_printers_supported,
{AttrType::uri, InternalType::kString, true}},
{AttrName::trimming_offset_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::trimming_reference_edge_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::trimming_type_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::trimming_when_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::uri_authentication_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::uri_security_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::which_jobs_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::x_image_position_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::x_image_position_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::x_image_shift_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_image_shift_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::x_side1_image_shift_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side1_image_shift_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::x_side2_image_shift_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side2_image_shift_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::y_image_position_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::y_image_position_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::y_image_shift_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_image_shift_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::y_side1_image_shift_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_side1_image_shift_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::y_side2_image_shift_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_side2_image_shift_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_cover_back_default::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_cover_back_default::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_cover_back_default::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_cover_front_default::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_cover_front_default::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_cover_front_default::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_document_format_details_default::GetKnownAttributes() {
return {&document_format,
&document_format_device_id,
&document_format_version,
&document_natural_language,
&document_source_application_name,
&document_source_application_version,
&document_source_os_name,
&document_source_os_version};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_document_format_details_default::GetKnownAttributes() const {
return {&document_format,
&document_format_device_id,
&document_format_version,
&document_natural_language,
&document_source_application_name,
&document_source_application_version,
&document_source_os_name,
&document_source_os_version};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_document_format_details_default::defs_{
{AttrName::document_format,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::document_format_device_id,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_format_version,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_natural_language,
{AttrType::naturalLanguage, InternalType::kString, true}},
{AttrName::document_source_application_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::document_source_application_version,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_source_os_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::document_source_os_version,
{AttrType::text, InternalType::kStringWithLanguage, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::GetKnownAttributes() const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_database::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_database::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_database::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_database::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_database::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_database::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_database::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_database::C_media_size::defs_{};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_database::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_database::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_database::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_database::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::GetKnownAttributes() const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_default::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_default::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_default::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_default::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_default::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_default::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_default::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_default::C_media_size::defs_{};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_default::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_default::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_default::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_default::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::GetKnownAttributes() const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_ready::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_ready::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_ready::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_ready::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_ready::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_ready::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_ready::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_ready::C_media_size::defs_{};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_ready::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_ready::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_finishings_col_ready::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_finishings_col_ready::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_insert_sheet_default::GetKnownAttributes() {
return {&insert_after_page_number, &insert_count, &media, &media_col};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_insert_sheet_default::GetKnownAttributes() const {
return {&insert_after_page_number, &insert_count, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_insert_sheet_default::defs_{
{AttrName::insert_after_page_number,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::insert_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_accounting_sheets_default::GetKnownAttributes() {
return {&job_accounting_output_bin, &job_accounting_sheets_type, &media,
&media_col};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_accounting_sheets_default::GetKnownAttributes() const {
return {&job_accounting_output_bin, &job_accounting_sheets_type, &media,
&media_col};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_accounting_sheets_default::defs_{
{AttrName::job_accounting_output_bin,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_accounting_sheets_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_constraints_supported::GetKnownAttributes() {
return {&resolver_name};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_constraints_supported::GetKnownAttributes() const {
return {&resolver_name};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_constraints_supported::defs_{
{AttrName::resolver_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_cover_back_default::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_cover_back_default::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_cover_back_default::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_cover_front_default::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_cover_front_default::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_cover_front_default::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_error_sheet_default::GetKnownAttributes() {
return {&job_error_sheet_type, &job_error_sheet_when, &media, &media_col};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_error_sheet_default::GetKnownAttributes() const {
return {&job_error_sheet_type, &job_error_sheet_when, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_error_sheet_default::defs_{
{AttrName::job_error_sheet_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_error_sheet_when,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::GetKnownAttributes() const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_default::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_default::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_default::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_default::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_default::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_default::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_default::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_default::C_media_size::defs_{};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_default::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_default::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_default::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_default::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::GetKnownAttributes() const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_ready::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_ready::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_ready::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_ready::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_ready::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_ready::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_ready::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_ready::C_media_size::defs_{};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_ready::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_ready::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_finishings_col_ready::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_finishings_col_ready::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_resolvers_supported::GetKnownAttributes() {
return {&resolver_name};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_resolvers_supported::GetKnownAttributes() const {
return {&resolver_name};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_resolvers_supported::defs_{
{AttrName::resolver_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_sheets_col_default::GetKnownAttributes() {
return {&job_sheets, &media, &media_col};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_job_sheets_col_default::GetKnownAttributes() const {
return {&job_sheets, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_job_sheets_col_default::defs_{
{AttrName::job_sheets,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_database::GetKnownAttributes() {
return {&media_back_coating, &media_bottom_margin,
&media_color, &media_front_coating,
&media_grain, &media_hole_count,
&media_info, &media_key,
&media_left_margin, &media_order_count,
&media_pre_printed, &media_recycled,
&media_right_margin, &media_size,
&media_size_name, &media_source,
&media_thickness, &media_tooth,
&media_top_margin, &media_type,
&media_weight_metric, &media_source_properties};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_database::GetKnownAttributes() const {
return {&media_back_coating, &media_bottom_margin,
&media_color, &media_front_coating,
&media_grain, &media_hole_count,
&media_info, &media_key,
&media_left_margin, &media_order_count,
&media_pre_printed, &media_recycled,
&media_right_margin, &media_size,
&media_size_name, &media_source,
&media_thickness, &media_tooth,
&media_top_margin, &media_type,
&media_weight_metric, &media_source_properties};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_media_col_database::defs_{
{AttrName::media_back_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_bottom_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_color,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_front_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_grain,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_hole_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::media_key,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_left_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_order_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_pre_printed,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_recycled,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_right_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::media_source,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_thickness,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_tooth,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_top_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_weight_metric,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_source_properties,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_source_properties(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_database::C_media_size::GetKnownAttributes() {
return {&x_dimension, &y_dimension};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_database::C_media_size::GetKnownAttributes() const {
return {&x_dimension, &y_dimension};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_media_col_database::C_media_size::defs_{
{AttrName::x_dimension,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_dimension,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_database::C_media_source_properties::GetKnownAttributes() {
return {&media_source_feed_direction, &media_source_feed_orientation};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_database::C_media_source_properties::GetKnownAttributes()
const {
return {&media_source_feed_direction, &media_source_feed_orientation};
}
const std::map<AttrName, AttrDef>
Response_CUPS_Get_Default::G_printer_attributes::C_media_col_database::
C_media_source_properties::defs_{
{AttrName::media_source_feed_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media_source_feed_orientation,
{AttrType::enum_, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_default::GetKnownAttributes() {
return {&media_back_coating, &media_bottom_margin, &media_color,
&media_front_coating, &media_grain, &media_hole_count,
&media_info, &media_key, &media_left_margin,
&media_order_count, &media_pre_printed, &media_recycled,
&media_right_margin, &media_size, &media_size_name,
&media_source, &media_thickness, &media_tooth,
&media_top_margin, &media_type, &media_weight_metric};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_default::GetKnownAttributes() const {
return {&media_back_coating, &media_bottom_margin, &media_color,
&media_front_coating, &media_grain, &media_hole_count,
&media_info, &media_key, &media_left_margin,
&media_order_count, &media_pre_printed, &media_recycled,
&media_right_margin, &media_size, &media_size_name,
&media_source, &media_thickness, &media_tooth,
&media_top_margin, &media_type, &media_weight_metric};
}
const std::map<AttrName, AttrDef>
Response_CUPS_Get_Default::G_printer_attributes::C_media_col_default::defs_{
{AttrName::media_back_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_bottom_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_color,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_front_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_grain,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_hole_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::media_key,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_left_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_order_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_pre_printed,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_recycled,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_right_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::media_source,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_thickness,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_tooth,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_top_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_weight_metric,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_default::C_media_size::GetKnownAttributes() {
return {&x_dimension, &y_dimension};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_default::C_media_size::GetKnownAttributes() const {
return {&x_dimension, &y_dimension};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_media_col_default::C_media_size::defs_{
{AttrName::x_dimension,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_dimension,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_ready::GetKnownAttributes() {
return {&media_back_coating, &media_bottom_margin,
&media_color, &media_front_coating,
&media_grain, &media_hole_count,
&media_info, &media_key,
&media_left_margin, &media_order_count,
&media_pre_printed, &media_recycled,
&media_right_margin, &media_size,
&media_size_name, &media_source,
&media_thickness, &media_tooth,
&media_top_margin, &media_type,
&media_weight_metric, &media_source_properties};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_ready::GetKnownAttributes() const {
return {&media_back_coating, &media_bottom_margin,
&media_color, &media_front_coating,
&media_grain, &media_hole_count,
&media_info, &media_key,
&media_left_margin, &media_order_count,
&media_pre_printed, &media_recycled,
&media_right_margin, &media_size,
&media_size_name, &media_source,
&media_thickness, &media_tooth,
&media_top_margin, &media_type,
&media_weight_metric, &media_source_properties};
}
const std::map<AttrName, AttrDef>
Response_CUPS_Get_Default::G_printer_attributes::C_media_col_ready::defs_{
{AttrName::media_back_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_bottom_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_color,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_front_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_grain,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_hole_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::media_key,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_left_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_order_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_pre_printed,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_recycled,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_right_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::media_source,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_thickness,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_tooth,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_top_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_weight_metric,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_source_properties,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_source_properties(); }}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_ready::C_media_size::GetKnownAttributes() {
return {&x_dimension, &y_dimension};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_ready::C_media_size::GetKnownAttributes() const {
return {&x_dimension, &y_dimension};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_media_col_ready::C_media_size::defs_{
{AttrName::x_dimension,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_dimension,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_ready::C_media_source_properties::GetKnownAttributes() {
return {&media_source_feed_direction, &media_source_feed_orientation};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_col_ready::C_media_source_properties::GetKnownAttributes() const {
return {&media_source_feed_direction, &media_source_feed_orientation};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_media_col_ready::C_media_source_properties::defs_{
{AttrName::media_source_feed_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media_source_feed_orientation,
{AttrType::enum_, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_size_supported::GetKnownAttributes() {
return {&x_dimension, &y_dimension};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_media_size_supported::GetKnownAttributes() const {
return {&x_dimension, &y_dimension};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_media_size_supported::defs_{
{AttrName::x_dimension,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::y_dimension,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_pdl_init_file_default::GetKnownAttributes() {
return {&pdl_init_file_entry, &pdl_init_file_location, &pdl_init_file_name};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_pdl_init_file_default::GetKnownAttributes() const {
return {&pdl_init_file_entry, &pdl_init_file_location, &pdl_init_file_name};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_pdl_init_file_default::defs_{
{AttrName::pdl_init_file_entry,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::pdl_init_file_location,
{AttrType::uri, InternalType::kString, false}},
{AttrName::pdl_init_file_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_printer_contact_col::GetKnownAttributes() {
return {&contact_name, &contact_uri, &contact_vcard};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_printer_contact_col::GetKnownAttributes() const {
return {&contact_name, &contact_uri, &contact_vcard};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_printer_contact_col::defs_{
{AttrName::contact_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::contact_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::contact_vcard,
{AttrType::text, InternalType::kStringWithLanguage, true}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_printer_icc_profiles::GetKnownAttributes() {
return {&profile_name, &profile_url};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_printer_icc_profiles::GetKnownAttributes() const {
return {&profile_name, &profile_url};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_printer_icc_profiles::defs_{
{AttrName::profile_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::profile_url, {AttrType::uri, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_printer_xri_supported::GetKnownAttributes() {
return {&xri_authentication, &xri_security, &xri_uri};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_printer_xri_supported::GetKnownAttributes() const {
return {&xri_authentication, &xri_security, &xri_uri};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_printer_xri_supported::defs_{
{AttrName::xri_authentication,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::xri_security,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::xri_uri, {AttrType::uri, InternalType::kString, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_proof_print_default::GetKnownAttributes() {
return {&media, &media_col, &proof_print_copies};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_proof_print_default::GetKnownAttributes() const {
return {&media, &media_col, &proof_print_copies};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_proof_print_default::defs_{
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::proof_print_copies,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_separator_sheets_default::GetKnownAttributes() {
return {&media, &media_col, &separator_sheets_type};
}
std::vector<const Attribute*> Response_CUPS_Get_Default::G_printer_attributes::
C_separator_sheets_default::GetKnownAttributes() const {
return {&media, &media_col, &separator_sheets_type};
}
const std::map<AttrName, AttrDef> Response_CUPS_Get_Default::
G_printer_attributes::C_separator_sheets_default::defs_{
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::separator_sheets_type,
{AttrType::keyword, InternalType::kInteger, true}}};
Request_CUPS_Get_Document::Request_CUPS_Get_Document()
: Request(Operation::CUPS_Get_Document) {}
std::vector<Group*> Request_CUPS_Get_Document::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_CUPS_Get_Document::GetKnownGroups() const {
return {&operation_attributes};
}
std::vector<Attribute*>
Request_CUPS_Get_Document::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&job_id,
&job_uri,
&document_number};
}
std::vector<const Attribute*>
Request_CUPS_Get_Document::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&job_id,
&job_uri,
&document_number};
}
const std::map<AttrName, AttrDef>
Request_CUPS_Get_Document::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::job_id, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::document_number,
{AttrType::integer, InternalType::kInteger, false}}};
Response_CUPS_Get_Document::Response_CUPS_Get_Document()
: Response(Operation::CUPS_Get_Document) {}
std::vector<Group*> Response_CUPS_Get_Document::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Response_CUPS_Get_Document::GetKnownGroups() const {
return {&operation_attributes};
}
std::vector<Attribute*>
Response_CUPS_Get_Document::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset, &attributes_natural_language,
&status_message, &detailed_status_message,
&document_format, &document_number,
&document_name};
}
std::vector<const Attribute*>
Response_CUPS_Get_Document::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset, &attributes_natural_language,
&status_message, &detailed_status_message,
&document_format, &document_number,
&document_name};
}
const std::map<AttrName, AttrDef>
Response_CUPS_Get_Document::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::status_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::detailed_status_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_format,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::document_number,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::document_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
Request_CUPS_Get_Printers::Request_CUPS_Get_Printers()
: Request(Operation::CUPS_Get_Printers) {}
std::vector<Group*> Request_CUPS_Get_Printers::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_CUPS_Get_Printers::GetKnownGroups() const {
return {&operation_attributes};
}
std::vector<Attribute*>
Request_CUPS_Get_Printers::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset, &attributes_natural_language,
&first_printer_name, &limit,
&printer_id, &printer_location,
&printer_type, &printer_type_mask,
&requested_attributes, &requested_user_name};
}
std::vector<const Attribute*>
Request_CUPS_Get_Printers::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset, &attributes_natural_language,
&first_printer_name, &limit,
&printer_id, &printer_location,
&printer_type, &printer_type_mask,
&requested_attributes, &requested_user_name};
}
const std::map<AttrName, AttrDef>
Request_CUPS_Get_Printers::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::first_printer_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::limit, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_id,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_location,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_type,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_type_mask,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::requested_attributes,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::requested_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
Response_CUPS_Get_Printers::Response_CUPS_Get_Printers()
: Response(Operation::CUPS_Get_Printers) {}
std::vector<Group*> Response_CUPS_Get_Printers::GetKnownGroups() {
return {&operation_attributes, &printer_attributes};
}
std::vector<const Group*> Response_CUPS_Get_Printers::GetKnownGroups() const {
return {&operation_attributes, &printer_attributes};
}
Request_CUPS_Move_Job::Request_CUPS_Move_Job()
: Request(Operation::CUPS_Move_Job) {}
std::vector<Group*> Request_CUPS_Move_Job::GetKnownGroups() {
return {&operation_attributes, &job_attributes};
}
std::vector<const Group*> Request_CUPS_Move_Job::GetKnownGroups() const {
return {&operation_attributes, &job_attributes};
}
std::vector<Attribute*>
Request_CUPS_Move_Job::G_job_attributes::GetKnownAttributes() {
return {&job_printer_uri};
}
std::vector<const Attribute*>
Request_CUPS_Move_Job::G_job_attributes::GetKnownAttributes() const {
return {&job_printer_uri};
}
const std::map<AttrName, AttrDef>
Request_CUPS_Move_Job::G_job_attributes::defs_{
{AttrName::job_printer_uri,
{AttrType::uri, InternalType::kString, false}}};
Response_CUPS_Move_Job::Response_CUPS_Move_Job()
: Response(Operation::CUPS_Move_Job) {}
std::vector<Group*> Response_CUPS_Move_Job::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Response_CUPS_Move_Job::GetKnownGroups() const {
return {&operation_attributes};
}
Request_CUPS_Set_Default::Request_CUPS_Set_Default()
: Request(Operation::CUPS_Set_Default) {}
std::vector<Group*> Request_CUPS_Set_Default::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_CUPS_Set_Default::GetKnownGroups() const {
return {&operation_attributes};
}
Response_CUPS_Set_Default::Response_CUPS_Set_Default()
: Response(Operation::CUPS_Set_Default) {}
std::vector<Group*> Response_CUPS_Set_Default::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Response_CUPS_Set_Default::GetKnownGroups() const {
return {&operation_attributes};
}
Request_Cancel_Job::Request_Cancel_Job() : Request(Operation::Cancel_Job) {}
std::vector<Group*> Request_Cancel_Job::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_Cancel_Job::GetKnownGroups() const {
return {&operation_attributes};
}
std::vector<Attribute*>
Request_Cancel_Job::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&job_id,
&job_uri,
&requesting_user_name,
&message};
}
std::vector<const Attribute*>
Request_Cancel_Job::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&job_id,
&job_uri,
&requesting_user_name,
&message};
}
const std::map<AttrName, AttrDef>
Request_Cancel_Job::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::job_id, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::requesting_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::message,
{AttrType::text, InternalType::kStringWithLanguage, false}}};
Response_Cancel_Job::Response_Cancel_Job() : Response(Operation::Cancel_Job) {}
std::vector<Group*> Response_Cancel_Job::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes};
}
std::vector<const Group*> Response_Cancel_Job::GetKnownGroups() const {
return {&operation_attributes, &unsupported_attributes};
}
Request_Create_Job::Request_Create_Job() : Request(Operation::Create_Job) {}
std::vector<Group*> Request_Create_Job::GetKnownGroups() {
return {&operation_attributes, &job_attributes};
}
std::vector<const Group*> Request_Create_Job::GetKnownGroups() const {
return {&operation_attributes, &job_attributes};
}
std::vector<Attribute*>
Request_Create_Job::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset, &attributes_natural_language,
&printer_uri, &requesting_user_name,
&job_name, &ipp_attribute_fidelity,
&job_k_octets, &job_impressions,
&job_media_sheets};
}
std::vector<const Attribute*>
Request_Create_Job::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset, &attributes_natural_language,
&printer_uri, &requesting_user_name,
&job_name, &ipp_attribute_fidelity,
&job_k_octets, &job_impressions,
&job_media_sheets};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::requesting_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::ipp_attribute_fidelity,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_k_octets,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_impressions,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_media_sheets,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::GetKnownAttributes() {
return {&copies,
&cover_back,
&cover_front,
&feed_orientation,
&finishings,
&finishings_col,
&font_name_requested,
&font_size_requested,
&force_front_side,
&imposition_template,
&insert_sheet,
&job_account_id,
&job_account_type,
&job_accounting_sheets,
&job_accounting_user_id,
&job_copies,
&job_cover_back,
&job_cover_front,
&job_delay_output_until,
&job_delay_output_until_time,
&job_error_action,
&job_error_sheet,
&job_finishings,
&job_finishings_col,
&job_hold_until,
&job_hold_until_time,
&job_message_to_operator,
&job_pages_per_set,
&job_phone_number,
&job_priority,
&job_recipient_name,
&job_save_disposition,
&job_sheet_message,
&job_sheets,
&job_sheets_col,
&media,
&media_col,
&media_input_tray_check,
&multiple_document_handling,
&number_up,
&orientation_requested,
&output_bin,
&output_device,
&overrides,
&page_delivery,
&page_order_received,
&page_ranges,
&pages_per_subset,
&pdl_init_file,
&presentation_direction_number_up,
&print_color_mode,
&print_content_optimize,
&print_quality,
&print_rendering_intent,
&print_scaling,
&printer_resolution,
&proof_print,
&separator_sheets,
&sheet_collate,
&sides,
&x_image_position,
&x_image_shift,
&x_side1_image_shift,
&x_side2_image_shift,
&y_image_position,
&y_image_shift,
&y_side1_image_shift,
&y_side2_image_shift};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::GetKnownAttributes() const {
return {&copies,
&cover_back,
&cover_front,
&feed_orientation,
&finishings,
&finishings_col,
&font_name_requested,
&font_size_requested,
&force_front_side,
&imposition_template,
&insert_sheet,
&job_account_id,
&job_account_type,
&job_accounting_sheets,
&job_accounting_user_id,
&job_copies,
&job_cover_back,
&job_cover_front,
&job_delay_output_until,
&job_delay_output_until_time,
&job_error_action,
&job_error_sheet,
&job_finishings,
&job_finishings_col,
&job_hold_until,
&job_hold_until_time,
&job_message_to_operator,
&job_pages_per_set,
&job_phone_number,
&job_priority,
&job_recipient_name,
&job_save_disposition,
&job_sheet_message,
&job_sheets,
&job_sheets_col,
&media,
&media_col,
&media_input_tray_check,
&multiple_document_handling,
&number_up,
&orientation_requested,
&output_bin,
&output_device,
&overrides,
&page_delivery,
&page_order_received,
&page_ranges,
&pages_per_subset,
&pdl_init_file,
&presentation_direction_number_up,
&print_color_mode,
&print_content_optimize,
&print_quality,
&print_rendering_intent,
&print_scaling,
&printer_resolution,
&proof_print,
&separator_sheets,
&sheet_collate,
&sides,
&x_image_position,
&x_image_shift,
&x_side1_image_shift,
&x_side2_image_shift,
&y_image_position,
&y_image_shift,
&y_side1_image_shift,
&y_side2_image_shift};
}
const std::map<AttrName, AttrDef> Request_Create_Job::G_job_attributes::defs_{
{AttrName::copies, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::cover_back,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_back(); }}},
{AttrName::cover_front,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_front(); }}},
{AttrName::feed_orientation,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::finishings, {AttrType::enum_, InternalType::kInteger, true}},
{AttrName::finishings_col,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_finishings_col(); }}},
{AttrName::font_name_requested,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::font_size_requested,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::force_front_side,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::insert_sheet,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_insert_sheet(); }}},
{AttrName::job_account_id,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_account_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_accounting_sheets,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_accounting_sheets(); }}},
{AttrName::job_accounting_user_id,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_copies, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_cover_back,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_back(); }}},
{AttrName::job_cover_front,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_front(); }}},
{AttrName::job_delay_output_until,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_delay_output_until_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::job_error_action,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::job_error_sheet,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_error_sheet(); }}},
{AttrName::job_finishings, {AttrType::enum_, InternalType::kInteger, true}},
{AttrName::job_finishings_col,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_finishings_col(); }}},
{AttrName::job_hold_until,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_hold_until_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::job_message_to_operator,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_pages_per_set,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_phone_number, {AttrType::uri, InternalType::kString, false}},
{AttrName::job_priority,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_recipient_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_save_disposition,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_save_disposition(); }}},
{AttrName::job_sheet_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_sheets, {AttrType::keyword, InternalType::kString, false}},
{AttrName::job_sheets_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_sheets_col(); }}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::media_input_tray_check,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::multiple_document_handling,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::number_up, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::orientation_requested,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::output_bin, {AttrType::keyword, InternalType::kString, false}},
{AttrName::output_device,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::overrides,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_overrides(); }}},
{AttrName::page_delivery,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_order_received,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_ranges,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::pages_per_subset,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::pdl_init_file,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_pdl_init_file(); }}},
{AttrName::presentation_direction_number_up,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_color_mode,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_content_optimize,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_quality, {AttrType::enum_, InternalType::kInteger, false}},
{AttrName::print_rendering_intent,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_scaling,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::printer_resolution,
{AttrType::resolution, InternalType::kResolution, false}},
{AttrName::proof_print,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_proof_print(); }}},
{AttrName::separator_sheets,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_separator_sheets(); }}},
{AttrName::sheet_collate,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::sides, {AttrType::keyword, InternalType::kInteger, false}},
{AttrName::x_image_position,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::x_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side1_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side2_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_image_position,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::y_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_side1_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_side2_image_shift,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::C_cover_back::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_cover_back::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_cover_back::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::C_cover_front::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_cover_front::GetKnownAttributes()
const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_cover_front::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::C_finishings_col::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_finishings_col::GetKnownAttributes()
const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_finishings_col::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::C_finishings_col::
C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_finishings_col::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_finishings_col::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::C_finishings_col::
C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_finishings_col::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_finishings_col::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::C_finishings_col::
C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_finishings_col::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_finishings_col::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::C_finishings_col::
C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_finishings_col::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_finishings_col::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::C_finishings_col::
C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_finishings_col::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_finishings_col::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::C_finishings_col::
C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_finishings_col::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_finishings_col::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::C_finishings_col::
C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_finishings_col::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Request_Create_Job::G_job_attributes::
C_finishings_col::C_media_size::defs_{};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::C_finishings_col::
C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_finishings_col::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_finishings_col::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::C_finishings_col::
C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_finishings_col::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_finishings_col::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::C_finishings_col::
C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_finishings_col::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_finishings_col::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::C_insert_sheet::GetKnownAttributes() {
return {&insert_after_page_number, &insert_count, &media, &media_col};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_insert_sheet::GetKnownAttributes()
const {
return {&insert_after_page_number, &insert_count, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_insert_sheet::defs_{
{AttrName::insert_after_page_number,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::insert_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_accounting_sheets::GetKnownAttributes() {
return {&job_accounting_output_bin, &job_accounting_sheets_type, &media,
&media_col};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_job_accounting_sheets::GetKnownAttributes() const {
return {&job_accounting_output_bin, &job_accounting_sheets_type, &media,
&media_col};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_job_accounting_sheets::defs_{
{AttrName::job_accounting_output_bin,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_accounting_sheets_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::C_job_cover_back::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_job_cover_back::GetKnownAttributes()
const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_job_cover_back::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::C_job_cover_front::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_job_cover_front::GetKnownAttributes()
const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_job_cover_front::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::C_job_error_sheet::GetKnownAttributes() {
return {&job_error_sheet_type, &job_error_sheet_when, &media, &media_col};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_job_error_sheet::GetKnownAttributes()
const {
return {&job_error_sheet_type, &job_error_sheet_when, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_job_error_sheet::defs_{
{AttrName::job_error_sheet_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_error_sheet_when,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_job_finishings_col::GetKnownAttributes()
const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_job_finishings_col::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_job_finishings_col::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_media_size::defs_{};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Request_Create_Job::G_job_attributes::
C_job_finishings_col::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_save_disposition::GetKnownAttributes() {
return {&save_disposition, &save_info};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_job_save_disposition::GetKnownAttributes() const {
return {&save_disposition, &save_info};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_job_save_disposition::defs_{
{AttrName::save_disposition,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::save_info,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_save_info(); }}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::
C_job_save_disposition::C_save_info::GetKnownAttributes() {
return {&save_document_format, &save_location, &save_name};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_job_save_disposition::C_save_info::GetKnownAttributes() const {
return {&save_document_format, &save_location, &save_name};
}
const std::map<AttrName, AttrDef> Request_Create_Job::G_job_attributes::
C_job_save_disposition::C_save_info::defs_{
{AttrName::save_document_format,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::save_location,
{AttrType::uri, InternalType::kString, false}},
{AttrName::save_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::C_job_sheets_col::GetKnownAttributes() {
return {&job_sheets, &media, &media_col};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_job_sheets_col::GetKnownAttributes()
const {
return {&job_sheets, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_job_sheets_col::defs_{
{AttrName::job_sheets,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::C_media_col::GetKnownAttributes() {
return {&media_back_coating, &media_bottom_margin, &media_color,
&media_front_coating, &media_grain, &media_hole_count,
&media_info, &media_key, &media_left_margin,
&media_order_count, &media_pre_printed, &media_recycled,
&media_right_margin, &media_size, &media_size_name,
&media_source, &media_thickness, &media_tooth,
&media_top_margin, &media_type, &media_weight_metric};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_media_col::GetKnownAttributes() const {
return {&media_back_coating, &media_bottom_margin, &media_color,
&media_front_coating, &media_grain, &media_hole_count,
&media_info, &media_key, &media_left_margin,
&media_order_count, &media_pre_printed, &media_recycled,
&media_right_margin, &media_size, &media_size_name,
&media_source, &media_thickness, &media_tooth,
&media_top_margin, &media_type, &media_weight_metric};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_media_col::defs_{
{AttrName::media_back_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_bottom_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_color,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_front_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_grain,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_hole_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::media_key,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_left_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_order_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_pre_printed,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_recycled,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_right_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::media_source,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_thickness,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_tooth,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_top_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_weight_metric,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Request_Create_Job::G_job_attributes::C_media_col::
C_media_size::GetKnownAttributes() {
return {&x_dimension, &y_dimension};
}
std::vector<const Attribute*> Request_Create_Job::G_job_attributes::
C_media_col::C_media_size::GetKnownAttributes() const {
return {&x_dimension, &y_dimension};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_media_col::C_media_size::defs_{
{AttrName::x_dimension,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_dimension,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::C_overrides::GetKnownAttributes() {
return {&job_account_id,
&job_account_type,
&job_accounting_sheets,
&job_accounting_user_id,
&job_copies,
&job_cover_back,
&job_cover_front,
&job_delay_output_until,
&job_delay_output_until_time,
&job_error_action,
&job_error_sheet,
&job_finishings,
&job_finishings_col,
&job_hold_until,
&job_hold_until_time,
&job_message_to_operator,
&job_pages_per_set,
&job_phone_number,
&job_priority,
&job_recipient_name,
&job_save_disposition,
&job_sheet_message,
&job_sheets,
&job_sheets_col,
&pages_per_subset,
&output_bin,
&output_device,
&multiple_document_handling,
&y_side1_image_shift,
&y_side2_image_shift,
&number_up,
&orientation_requested,
&page_delivery,
&page_order_received,
&page_ranges,
&pdl_init_file,
&print_color_mode,
&print_content_optimize,
&print_quality,
&print_rendering_intent,
&printer_resolution,
&presentation_direction_number_up,
&media,
&sides,
&x_image_position,
&x_image_shift,
&x_side1_image_shift,
&x_side2_image_shift,
&y_image_position,
&y_image_shift,
&copies,
&cover_back,
&cover_front,
&imposition_template,
&insert_sheet,
&media_col,
&media_input_tray_check,
&print_scaling,
&proof_print,
&separator_sheets,
&sheet_collate,
&feed_orientation,
&finishings,
&finishings_col,
&font_name_requested,
&font_size_requested,
&force_front_side,
&document_copies,
&document_numbers,
&pages};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_overrides::GetKnownAttributes() const {
return {&job_account_id,
&job_account_type,
&job_accounting_sheets,
&job_accounting_user_id,
&job_copies,
&job_cover_back,
&job_cover_front,
&job_delay_output_until,
&job_delay_output_until_time,
&job_error_action,
&job_error_sheet,
&job_finishings,
&job_finishings_col,
&job_hold_until,
&job_hold_until_time,
&job_message_to_operator,
&job_pages_per_set,
&job_phone_number,
&job_priority,
&job_recipient_name,
&job_save_disposition,
&job_sheet_message,
&job_sheets,
&job_sheets_col,
&pages_per_subset,
&output_bin,
&output_device,
&multiple_document_handling,
&y_side1_image_shift,
&y_side2_image_shift,
&number_up,
&orientation_requested,
&page_delivery,
&page_order_received,
&page_ranges,
&pdl_init_file,
&print_color_mode,
&print_content_optimize,
&print_quality,
&print_rendering_intent,
&printer_resolution,
&presentation_direction_number_up,
&media,
&sides,
&x_image_position,
&x_image_shift,
&x_side1_image_shift,
&x_side2_image_shift,
&y_image_position,
&y_image_shift,
&copies,
&cover_back,
&cover_front,
&imposition_template,
&insert_sheet,
&media_col,
&media_input_tray_check,
&print_scaling,
&proof_print,
&separator_sheets,
&sheet_collate,
&feed_orientation,
&finishings,
&finishings_col,
&font_name_requested,
&font_size_requested,
&force_front_side,
&document_copies,
&document_numbers,
&pages};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_overrides::defs_{
{AttrName::job_account_id,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_account_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_accounting_sheets,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_accounting_sheets(); }}},
{AttrName::job_accounting_user_id,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_copies,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_cover_back,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_back(); }}},
{AttrName::job_cover_front,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_front(); }}},
{AttrName::job_delay_output_until,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_delay_output_until_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::job_error_action,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::job_error_sheet,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_error_sheet(); }}},
{AttrName::job_finishings,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::job_finishings_col,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_finishings_col(); }}},
{AttrName::job_hold_until,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_hold_until_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::job_message_to_operator,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_pages_per_set,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_phone_number,
{AttrType::uri, InternalType::kString, false}},
{AttrName::job_priority,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_recipient_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_save_disposition,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_save_disposition(); }}},
{AttrName::job_sheet_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_sheets,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_sheets_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_sheets_col(); }}},
{AttrName::pages_per_subset,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::output_bin,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::output_device,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::multiple_document_handling,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::y_side1_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_side2_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::number_up,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::orientation_requested,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::page_delivery,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_order_received,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_ranges,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::pdl_init_file,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_pdl_init_file(); }}},
{AttrName::print_color_mode,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_content_optimize,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_quality,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::print_rendering_intent,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::printer_resolution,
{AttrType::resolution, InternalType::kResolution, false}},
{AttrName::presentation_direction_number_up,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::sides, {AttrType::keyword, InternalType::kInteger, false}},
{AttrName::x_image_position,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::x_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side1_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side2_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_image_position,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::y_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::copies, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::cover_back,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_back(); }}},
{AttrName::cover_front,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_front(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::insert_sheet,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_insert_sheet(); }}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::media_input_tray_check,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::print_scaling,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::proof_print,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_proof_print(); }}},
{AttrName::separator_sheets,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_separator_sheets(); }}},
{AttrName::sheet_collate,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::feed_orientation,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::finishings, {AttrType::enum_, InternalType::kInteger, true}},
{AttrName::finishings_col,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_finishings_col(); }}},
{AttrName::font_name_requested,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::font_size_requested,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::force_front_side,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::document_copies,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::document_numbers,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::pages,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::C_pdl_init_file::GetKnownAttributes() {
return {&pdl_init_file_entry, &pdl_init_file_location, &pdl_init_file_name};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_pdl_init_file::GetKnownAttributes()
const {
return {&pdl_init_file_entry, &pdl_init_file_location, &pdl_init_file_name};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_pdl_init_file::defs_{
{AttrName::pdl_init_file_entry,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::pdl_init_file_location,
{AttrType::uri, InternalType::kString, false}},
{AttrName::pdl_init_file_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::C_proof_print::GetKnownAttributes() {
return {&media, &media_col, &proof_print_copies};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_proof_print::GetKnownAttributes()
const {
return {&media, &media_col, &proof_print_copies};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_proof_print::defs_{
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::proof_print_copies,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*>
Request_Create_Job::G_job_attributes::C_separator_sheets::GetKnownAttributes() {
return {&media, &media_col, &separator_sheets_type};
}
std::vector<const Attribute*>
Request_Create_Job::G_job_attributes::C_separator_sheets::GetKnownAttributes()
const {
return {&media, &media_col, &separator_sheets_type};
}
const std::map<AttrName, AttrDef>
Request_Create_Job::G_job_attributes::C_separator_sheets::defs_{
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::separator_sheets_type,
{AttrType::keyword, InternalType::kInteger, true}}};
Response_Create_Job::Response_Create_Job() : Response(Operation::Create_Job) {}
std::vector<Group*> Response_Create_Job::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
std::vector<const Group*> Response_Create_Job::GetKnownGroups() const {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
std::vector<Attribute*>
Response_Create_Job::G_job_attributes::GetKnownAttributes() {
return {&job_id,
&job_uri,
&job_state,
&job_state_reasons,
&job_state_message,
&number_of_intervening_jobs};
}
std::vector<const Attribute*>
Response_Create_Job::G_job_attributes::GetKnownAttributes() const {
return {&job_id,
&job_uri,
&job_state,
&job_state_reasons,
&job_state_message,
&number_of_intervening_jobs};
}
const std::map<AttrName, AttrDef> Response_Create_Job::G_job_attributes::defs_{
{AttrName::job_id, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::job_state, {AttrType::enum_, InternalType::kInteger, false}},
{AttrName::job_state_reasons,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::job_state_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::number_of_intervening_jobs,
{AttrType::integer, InternalType::kInteger, false}}};
Request_Get_Job_Attributes::Request_Get_Job_Attributes()
: Request(Operation::Get_Job_Attributes) {}
std::vector<Group*> Request_Get_Job_Attributes::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_Get_Job_Attributes::GetKnownGroups() const {
return {&operation_attributes};
}
std::vector<Attribute*>
Request_Get_Job_Attributes::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&job_id,
&job_uri,
&requesting_user_name,
&requested_attributes};
}
std::vector<const Attribute*>
Request_Get_Job_Attributes::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&job_id,
&job_uri,
&requesting_user_name,
&requested_attributes};
}
const std::map<AttrName, AttrDef>
Request_Get_Job_Attributes::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::job_id, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::requesting_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::requested_attributes,
{AttrType::keyword, InternalType::kString, true}}};
Response_Get_Job_Attributes::Response_Get_Job_Attributes()
: Response(Operation::Get_Job_Attributes) {}
std::vector<Group*> Response_Get_Job_Attributes::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
std::vector<const Group*> Response_Get_Job_Attributes::GetKnownGroups() const {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
std::vector<Attribute*>
Response_Get_Job_Attributes::G_job_attributes::GetKnownAttributes() {
return {&attributes_charset,
&attributes_natural_language,
&copies,
&copies_actual,
&cover_back,
&cover_back_actual,
&cover_front,
&cover_front_actual,
¤t_page_order,
&date_time_at_completed,
&date_time_at_creation,
&date_time_at_processing,
&document_charset_supplied,
&document_format_details_supplied,
&document_format_ready,
&document_format_supplied,
&document_format_version_supplied,
&document_message_supplied,
&document_metadata,
&document_name_supplied,
&document_natural_language_supplied,
&errors_count,
&feed_orientation,
&finishings,
&finishings_col,
&finishings_col_actual,
&font_name_requested,
&font_size_requested,
&force_front_side,
&force_front_side_actual,
&imposition_template,
&impressions_completed_current_copy,
&insert_sheet,
&insert_sheet_actual,
&job_account_id,
&job_account_id_actual,
&job_account_type,
&job_accounting_sheets,
&job_accounting_sheets_actual,
&job_accounting_user_id,
&job_accounting_user_id_actual,
&job_attribute_fidelity,
&job_charge_info,
&job_collation_type,
&job_copies,
&job_copies_actual,
&job_cover_back,
&job_cover_back_actual,
&job_cover_front,
&job_cover_front_actual,
&job_delay_output_until,
&job_delay_output_until_time,
&job_detailed_status_messages,
&job_document_access_errors,
&job_error_action,
&job_error_sheet,
&job_error_sheet_actual,
&job_finishings,
&job_finishings_col,
&job_finishings_col_actual,
&job_hold_until,
&job_hold_until_time,
&job_id,
&job_impressions,
&job_impressions_completed,
&job_k_octets,
&job_k_octets_processed,
&job_mandatory_attributes,
&job_media_sheets,
&job_media_sheets_completed,
&job_message_from_operator,
&job_message_to_operator,
&job_message_to_operator_actual,
&job_more_info,
&job_name,
&job_originating_user_name,
&job_originating_user_uri,
&job_pages,
&job_pages_completed,
&job_pages_completed_current_copy,
&job_pages_per_set,
&job_phone_number,
&job_printer_up_time,
&job_printer_uri,
&job_priority,
&job_priority_actual,
&job_recipient_name,
&job_resource_ids,
&job_save_disposition,
&job_save_printer_make_and_model,
&job_sheet_message,
&job_sheet_message_actual,
&job_sheets,
&job_sheets_col,
&job_sheets_col_actual,
&job_state,
&job_state_message,
&job_state_reasons,
&job_uri,
&job_uuid,
&media,
&media_col,
&media_col_actual,
&media_input_tray_check,
&multiple_document_handling,
&number_of_documents,
&number_of_intervening_jobs,
&number_up,
&number_up_actual,
&orientation_requested,
&original_requesting_user_name,
&output_bin,
&output_device,
&output_device_actual,
&output_device_assigned,
&output_device_job_state_message,
&output_device_uuid_assigned,
&overrides,
&overrides_actual,
&page_delivery,
&page_order_received,
&page_ranges,
&page_ranges_actual,
&pages_per_subset,
&pdl_init_file,
&presentation_direction_number_up,
&print_color_mode,
&print_content_optimize,
&print_quality,
&print_rendering_intent,
&print_scaling,
&printer_resolution,
&printer_resolution_actual,
&proof_print,
&separator_sheets,
&separator_sheets_actual,
&sheet_collate,
&sheet_completed_copy_number,
&sheet_completed_document_number,
&sides,
&time_at_completed,
&time_at_creation,
&time_at_processing,
&warnings_count,
&x_image_position,
&x_image_shift,
&x_image_shift_actual,
&x_side1_image_shift,
&x_side1_image_shift_actual,
&x_side2_image_shift,
&x_side2_image_shift_actual,
&y_image_position,
&y_image_shift,
&y_image_shift_actual,
&y_side1_image_shift,
&y_side1_image_shift_actual,
&y_side2_image_shift,
&y_side2_image_shift_actual};
}
std::vector<const Attribute*>
Response_Get_Job_Attributes::G_job_attributes::GetKnownAttributes() const {
return {&attributes_charset,
&attributes_natural_language,
&copies,
&copies_actual,
&cover_back,
&cover_back_actual,
&cover_front,
&cover_front_actual,
¤t_page_order,
&date_time_at_completed,
&date_time_at_creation,
&date_time_at_processing,
&document_charset_supplied,
&document_format_details_supplied,
&document_format_ready,
&document_format_supplied,
&document_format_version_supplied,
&document_message_supplied,
&document_metadata,
&document_name_supplied,
&document_natural_language_supplied,
&errors_count,
&feed_orientation,
&finishings,
&finishings_col,
&finishings_col_actual,
&font_name_requested,
&font_size_requested,
&force_front_side,
&force_front_side_actual,
&imposition_template,
&impressions_completed_current_copy,
&insert_sheet,
&insert_sheet_actual,
&job_account_id,
&job_account_id_actual,
&job_account_type,
&job_accounting_sheets,
&job_accounting_sheets_actual,
&job_accounting_user_id,
&job_accounting_user_id_actual,
&job_attribute_fidelity,
&job_charge_info,
&job_collation_type,
&job_copies,
&job_copies_actual,
&job_cover_back,
&job_cover_back_actual,
&job_cover_front,
&job_cover_front_actual,
&job_delay_output_until,
&job_delay_output_until_time,
&job_detailed_status_messages,
&job_document_access_errors,
&job_error_action,
&job_error_sheet,
&job_error_sheet_actual,
&job_finishings,
&job_finishings_col,
&job_finishings_col_actual,
&job_hold_until,
&job_hold_until_time,
&job_id,
&job_impressions,
&job_impressions_completed,
&job_k_octets,
&job_k_octets_processed,
&job_mandatory_attributes,
&job_media_sheets,
&job_media_sheets_completed,
&job_message_from_operator,
&job_message_to_operator,
&job_message_to_operator_actual,
&job_more_info,
&job_name,
&job_originating_user_name,
&job_originating_user_uri,
&job_pages,
&job_pages_completed,
&job_pages_completed_current_copy,
&job_pages_per_set,
&job_phone_number,
&job_printer_up_time,
&job_printer_uri,
&job_priority,
&job_priority_actual,
&job_recipient_name,
&job_resource_ids,
&job_save_disposition,
&job_save_printer_make_and_model,
&job_sheet_message,
&job_sheet_message_actual,
&job_sheets,
&job_sheets_col,
&job_sheets_col_actual,
&job_state,
&job_state_message,
&job_state_reasons,
&job_uri,
&job_uuid,
&media,
&media_col,
&media_col_actual,
&media_input_tray_check,
&multiple_document_handling,
&number_of_documents,
&number_of_intervening_jobs,
&number_up,
&number_up_actual,
&orientation_requested,
&original_requesting_user_name,
&output_bin,
&output_device,
&output_device_actual,
&output_device_assigned,
&output_device_job_state_message,
&output_device_uuid_assigned,
&overrides,
&overrides_actual,
&page_delivery,
&page_order_received,
&page_ranges,
&page_ranges_actual,
&pages_per_subset,
&pdl_init_file,
&presentation_direction_number_up,
&print_color_mode,
&print_content_optimize,
&print_quality,
&print_rendering_intent,
&print_scaling,
&printer_resolution,
&printer_resolution_actual,
&proof_print,
&separator_sheets,
&separator_sheets_actual,
&sheet_collate,
&sheet_completed_copy_number,
&sheet_completed_document_number,
&sides,
&time_at_completed,
&time_at_creation,
&time_at_processing,
&warnings_count,
&x_image_position,
&x_image_shift,
&x_image_shift_actual,
&x_side1_image_shift,
&x_side1_image_shift_actual,
&x_side2_image_shift,
&x_side2_image_shift_actual,
&y_image_position,
&y_image_shift,
&y_image_shift_actual,
&y_side1_image_shift,
&y_side1_image_shift_actual,
&y_side2_image_shift,
&y_side2_image_shift_actual};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::copies, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::copies_actual,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::cover_back,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_back(); }}},
{AttrName::cover_back_actual,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_cover_back_actual(); }}},
{AttrName::cover_front,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_front(); }}},
{AttrName::cover_front_actual,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_cover_front_actual(); }}},
{AttrName::current_page_order,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::date_time_at_completed,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::date_time_at_creation,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::date_time_at_processing,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::document_charset_supplied,
{AttrType::charset, InternalType::kString, false}},
{AttrName::document_format_details_supplied,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* {
return new C_document_format_details_supplied();
}}},
{AttrName::document_format_ready,
{AttrType::mimeMediaType, InternalType::kString, true}},
{AttrName::document_format_supplied,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::document_format_version_supplied,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_message_supplied,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_metadata,
{AttrType::octetString, InternalType::kString, true}},
{AttrName::document_name_supplied,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::document_natural_language_supplied,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::errors_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::feed_orientation,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::finishings, {AttrType::enum_, InternalType::kInteger, true}},
{AttrName::finishings_col,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_finishings_col(); }}},
{AttrName::finishings_col_actual,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_finishings_col_actual(); }}},
{AttrName::font_name_requested,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::font_size_requested,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::force_front_side,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::force_front_side_actual,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::impressions_completed_current_copy,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::insert_sheet,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_insert_sheet(); }}},
{AttrName::insert_sheet_actual,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_insert_sheet_actual(); }}},
{AttrName::job_account_id,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_account_id_actual,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::job_account_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_accounting_sheets,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_accounting_sheets(); }}},
{AttrName::job_accounting_sheets_actual,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* {
return new C_job_accounting_sheets_actual();
}}},
{AttrName::job_accounting_user_id,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_accounting_user_id_actual,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::job_attribute_fidelity,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_charge_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_collation_type,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::job_copies,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_copies_actual,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::job_cover_back,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_back(); }}},
{AttrName::job_cover_back_actual,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_cover_back_actual(); }}},
{AttrName::job_cover_front,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_front(); }}},
{AttrName::job_cover_front_actual,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_cover_front_actual(); }}},
{AttrName::job_delay_output_until,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_delay_output_until_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::job_detailed_status_messages,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::job_document_access_errors,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::job_error_action,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::job_error_sheet,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_error_sheet(); }}},
{AttrName::job_error_sheet_actual,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_error_sheet_actual(); }}},
{AttrName::job_finishings,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::job_finishings_col,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_finishings_col(); }}},
{AttrName::job_finishings_col_actual,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_finishings_col_actual(); }}},
{AttrName::job_hold_until,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_hold_until_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::job_id, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_impressions,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_impressions_completed,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_k_octets,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_k_octets_processed,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_mandatory_attributes,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::job_media_sheets,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_media_sheets_completed,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_message_from_operator,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_message_to_operator,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_message_to_operator_actual,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::job_more_info,
{AttrType::uri, InternalType::kString, false}},
{AttrName::job_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_originating_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_originating_user_uri,
{AttrType::uri, InternalType::kString, false}},
{AttrName::job_pages,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_pages_completed,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_pages_completed_current_copy,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_pages_per_set,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_phone_number,
{AttrType::uri, InternalType::kString, false}},
{AttrName::job_printer_up_time,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_printer_uri,
{AttrType::uri, InternalType::kString, false}},
{AttrName::job_priority,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_priority_actual,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::job_recipient_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_resource_ids,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::job_save_disposition,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_save_disposition(); }}},
{AttrName::job_save_printer_make_and_model,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_sheet_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_sheet_message_actual,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::job_sheets,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_sheets_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_sheets_col(); }}},
{AttrName::job_sheets_col_actual,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_sheets_col_actual(); }}},
{AttrName::job_state, {AttrType::enum_, InternalType::kInteger, false}},
{AttrName::job_state_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_state_reasons,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::job_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::job_uuid, {AttrType::uri, InternalType::kString, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::media_col_actual,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_media_col_actual(); }}},
{AttrName::media_input_tray_check,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::multiple_document_handling,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::number_of_documents,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::number_of_intervening_jobs,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::number_up,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::number_up_actual,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::orientation_requested,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::original_requesting_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::output_bin,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::output_device,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::output_device_actual,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::output_device_assigned,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::output_device_job_state_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::output_device_uuid_assigned,
{AttrType::uri, InternalType::kString, false}},
{AttrName::overrides,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_overrides(); }}},
{AttrName::overrides_actual,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_overrides_actual(); }}},
{AttrName::page_delivery,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_order_received,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_ranges,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::page_ranges_actual,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::pages_per_subset,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::pdl_init_file,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_pdl_init_file(); }}},
{AttrName::presentation_direction_number_up,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_color_mode,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_content_optimize,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_quality,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::print_rendering_intent,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_scaling,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::printer_resolution,
{AttrType::resolution, InternalType::kResolution, false}},
{AttrName::printer_resolution_actual,
{AttrType::resolution, InternalType::kResolution, true}},
{AttrName::proof_print,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_proof_print(); }}},
{AttrName::separator_sheets,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_separator_sheets(); }}},
{AttrName::separator_sheets_actual,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_separator_sheets_actual(); }}},
{AttrName::sheet_collate,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::sheet_completed_copy_number,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::sheet_completed_document_number,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::sides, {AttrType::keyword, InternalType::kInteger, false}},
{AttrName::time_at_completed,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::time_at_creation,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::time_at_processing,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::warnings_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_image_position,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::x_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_image_shift_actual,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::x_side1_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side1_image_shift_actual,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::x_side2_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side2_image_shift_actual,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::y_image_position,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::y_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_image_shift_actual,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::y_side1_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_side1_image_shift_actual,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::y_side2_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_side2_image_shift_actual,
{AttrType::integer, InternalType::kInteger, true}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_cover_back::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_cover_back::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_cover_back::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_cover_back_actual::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_cover_back_actual::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_cover_back_actual::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_cover_front::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_cover_front::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_cover_front::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_cover_front_actual::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_cover_front_actual::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_cover_front_actual::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_document_format_details_supplied::GetKnownAttributes() {
return {&document_format,
&document_format_device_id,
&document_format_version,
&document_natural_language,
&document_source_application_name,
&document_source_application_version,
&document_source_os_name,
&document_source_os_version};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_document_format_details_supplied::GetKnownAttributes() const {
return {&document_format,
&document_format_device_id,
&document_format_version,
&document_natural_language,
&document_source_application_name,
&document_source_application_version,
&document_source_os_name,
&document_source_os_version};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_document_format_details_supplied::defs_{
{AttrName::document_format,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::document_format_device_id,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_format_version,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_natural_language,
{AttrType::naturalLanguage, InternalType::kString, true}},
{AttrName::document_source_application_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::document_source_application_version,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_source_os_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::document_source_os_version,
{AttrType::text, InternalType::kStringWithLanguage, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::GetKnownAttributes() const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_finishings_col::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col::C_media_size::defs_{};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::GetKnownAttributes() const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col_actual::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col_actual::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col_actual::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col_actual::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col_actual::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col_actual::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col_actual::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col_actual::C_media_size::defs_{};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col_actual::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col_actual::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_finishings_col_actual::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_finishings_col_actual::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_insert_sheet::GetKnownAttributes() {
return {&insert_after_page_number, &insert_count, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_insert_sheet::GetKnownAttributes() const {
return {&insert_after_page_number, &insert_count, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_insert_sheet::defs_{
{AttrName::insert_after_page_number,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::insert_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_insert_sheet_actual::GetKnownAttributes() {
return {&insert_after_page_number, &insert_count, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_insert_sheet_actual::GetKnownAttributes() const {
return {&insert_after_page_number, &insert_count, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_insert_sheet_actual::defs_{
{AttrName::insert_after_page_number,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::insert_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_accounting_sheets::GetKnownAttributes() {
return {&job_accounting_output_bin, &job_accounting_sheets_type, &media,
&media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_accounting_sheets::GetKnownAttributes() const {
return {&job_accounting_output_bin, &job_accounting_sheets_type, &media,
&media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_accounting_sheets::defs_{
{AttrName::job_accounting_output_bin,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_accounting_sheets_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_accounting_sheets_actual::GetKnownAttributes() {
return {&job_accounting_output_bin, &job_accounting_sheets_type, &media,
&media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_accounting_sheets_actual::GetKnownAttributes() const {
return {&job_accounting_output_bin, &job_accounting_sheets_type, &media,
&media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_accounting_sheets_actual::defs_{
{AttrName::job_accounting_output_bin,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_accounting_sheets_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_cover_back::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_cover_back::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_job_cover_back::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_cover_back_actual::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_cover_back_actual::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_cover_back_actual::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_cover_front::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_cover_front::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_job_cover_front::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_cover_front_actual::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_cover_front_actual::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_cover_front_actual::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_error_sheet::GetKnownAttributes() {
return {&job_error_sheet_type, &job_error_sheet_when, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_error_sheet::GetKnownAttributes() const {
return {&job_error_sheet_type, &job_error_sheet_when, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_job_error_sheet::defs_{
{AttrName::job_error_sheet_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_error_sheet_when,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_error_sheet_actual::GetKnownAttributes() {
return {&job_error_sheet_type, &job_error_sheet_when, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_error_sheet_actual::GetKnownAttributes() const {
return {&job_error_sheet_type, &job_error_sheet_when, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_error_sheet_actual::defs_{
{AttrName::job_error_sheet_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_error_sheet_when,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::GetKnownAttributes() const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_job_finishings_col::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_finishings_col::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_finishings_col::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_finishings_col::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_finishings_col::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_finishings_col::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_finishings_col::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_finishings_col::C_media_size::defs_{};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_finishings_col::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_finishings_col::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_finishings_col::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col_actual::GetKnownAttributes() {
return {&media_back_coating, &media_bottom_margin, &media_color,
&media_front_coating, &media_grain, &media_hole_count,
&media_info, &media_key, &media_left_margin,
&media_order_count, &media_pre_printed, &media_recycled,
&media_right_margin, &media_size, &media_size_name,
&media_source, &media_thickness, &media_tooth,
&media_top_margin, &media_type, &media_weight_metric};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col_actual::GetKnownAttributes() const {
return {&media_back_coating, &media_bottom_margin, &media_color,
&media_front_coating, &media_grain, &media_hole_count,
&media_info, &media_key, &media_left_margin,
&media_order_count, &media_pre_printed, &media_recycled,
&media_right_margin, &media_size, &media_size_name,
&media_source, &media_thickness, &media_tooth,
&media_top_margin, &media_type, &media_weight_metric};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_finishings_col_actual::defs_{
{AttrName::media_back_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_bottom_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_color,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_front_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_grain,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_hole_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::media_key,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_left_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_order_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_pre_printed,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_recycled,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_right_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::media_source,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_thickness,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_tooth,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_top_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_weight_metric,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col_actual::C_media_size::GetKnownAttributes() {
return {&x_dimension, &y_dimension};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_finishings_col_actual::C_media_size::GetKnownAttributes() const {
return {&x_dimension, &y_dimension};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_finishings_col_actual::C_media_size::defs_{
{AttrName::x_dimension,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_dimension,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_save_disposition::GetKnownAttributes() {
return {&save_disposition, &save_info};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_save_disposition::GetKnownAttributes() const {
return {&save_disposition, &save_info};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_save_disposition::defs_{
{AttrName::save_disposition,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::save_info,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_save_info(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_save_disposition::C_save_info::GetKnownAttributes() {
return {&save_document_format, &save_location, &save_name};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_save_disposition::C_save_info::GetKnownAttributes() const {
return {&save_document_format, &save_location, &save_name};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_save_disposition::C_save_info::defs_{
{AttrName::save_document_format,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::save_location,
{AttrType::uri, InternalType::kString, false}},
{AttrName::save_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_sheets_col::GetKnownAttributes() {
return {&job_sheets, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_sheets_col::GetKnownAttributes() const {
return {&job_sheets, &media, &media_col};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_job_sheets_col::defs_{
{AttrName::job_sheets,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_sheets_col_actual::GetKnownAttributes() {
return {&job_sheets, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_job_sheets_col_actual::GetKnownAttributes() const {
return {&job_sheets, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_job_sheets_col_actual::defs_{
{AttrName::job_sheets,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_media_col::GetKnownAttributes() {
return {&media_back_coating, &media_bottom_margin, &media_color,
&media_front_coating, &media_grain, &media_hole_count,
&media_info, &media_key, &media_left_margin,
&media_order_count, &media_pre_printed, &media_recycled,
&media_right_margin, &media_size, &media_size_name,
&media_source, &media_thickness, &media_tooth,
&media_top_margin, &media_type, &media_weight_metric};
}
std::vector<const Attribute*>
Response_Get_Job_Attributes::G_job_attributes::C_media_col::GetKnownAttributes()
const {
return {&media_back_coating, &media_bottom_margin, &media_color,
&media_front_coating, &media_grain, &media_hole_count,
&media_info, &media_key, &media_left_margin,
&media_order_count, &media_pre_printed, &media_recycled,
&media_right_margin, &media_size, &media_size_name,
&media_source, &media_thickness, &media_tooth,
&media_top_margin, &media_type, &media_weight_metric};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_media_col::defs_{
{AttrName::media_back_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_bottom_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_color,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_front_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_grain,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_hole_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::media_key,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_left_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_order_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_pre_printed,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_recycled,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_right_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::media_source,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_thickness,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_tooth,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_top_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_weight_metric,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_media_col::C_media_size::GetKnownAttributes() {
return {&x_dimension, &y_dimension};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_media_col::C_media_size::GetKnownAttributes() const {
return {&x_dimension, &y_dimension};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_media_col::C_media_size::defs_{
{AttrName::x_dimension,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_dimension,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_media_col_actual::GetKnownAttributes() {
return {&media_back_coating, &media_bottom_margin, &media_color,
&media_front_coating, &media_grain, &media_hole_count,
&media_info, &media_key, &media_left_margin,
&media_order_count, &media_pre_printed, &media_recycled,
&media_right_margin, &media_size, &media_size_name,
&media_source, &media_thickness, &media_tooth,
&media_top_margin, &media_type, &media_weight_metric};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_media_col_actual::GetKnownAttributes() const {
return {&media_back_coating, &media_bottom_margin, &media_color,
&media_front_coating, &media_grain, &media_hole_count,
&media_info, &media_key, &media_left_margin,
&media_order_count, &media_pre_printed, &media_recycled,
&media_right_margin, &media_size, &media_size_name,
&media_source, &media_thickness, &media_tooth,
&media_top_margin, &media_type, &media_weight_metric};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_media_col_actual::defs_{
{AttrName::media_back_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_bottom_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_color,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_front_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_grain,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_hole_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::media_key,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_left_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_order_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_pre_printed,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_recycled,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_right_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::media_source,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_thickness,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_tooth,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_top_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_weight_metric,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_media_col_actual::C_media_size::GetKnownAttributes() {
return {&x_dimension, &y_dimension};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_media_col_actual::C_media_size::GetKnownAttributes() const {
return {&x_dimension, &y_dimension};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_media_col_actual::C_media_size::defs_{
{AttrName::x_dimension,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_dimension,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_overrides::GetKnownAttributes() {
return {&job_account_id,
&job_account_type,
&job_accounting_sheets,
&job_accounting_user_id,
&job_copies,
&job_cover_back,
&job_cover_front,
&job_delay_output_until,
&job_delay_output_until_time,
&job_error_action,
&job_error_sheet,
&job_finishings,
&job_finishings_col,
&job_hold_until,
&job_hold_until_time,
&job_message_to_operator,
&job_pages_per_set,
&job_phone_number,
&job_priority,
&job_recipient_name,
&job_save_disposition,
&job_sheet_message,
&job_sheets,
&job_sheets_col,
&pages_per_subset,
&output_bin,
&output_device,
&multiple_document_handling,
&y_side1_image_shift,
&y_side2_image_shift,
&number_up,
&orientation_requested,
&page_delivery,
&page_order_received,
&page_ranges,
&pdl_init_file,
&print_color_mode,
&print_content_optimize,
&print_quality,
&print_rendering_intent,
&printer_resolution,
&presentation_direction_number_up,
&media,
&sides,
&x_image_position,
&x_image_shift,
&x_side1_image_shift,
&x_side2_image_shift,
&y_image_position,
&y_image_shift,
&copies,
&cover_back,
&cover_front,
&imposition_template,
&insert_sheet,
&media_col,
&media_input_tray_check,
&print_scaling,
&proof_print,
&separator_sheets,
&sheet_collate,
&feed_orientation,
&finishings,
&finishings_col,
&font_name_requested,
&font_size_requested,
&force_front_side,
&document_copies,
&document_numbers,
&pages};
}
std::vector<const Attribute*>
Response_Get_Job_Attributes::G_job_attributes::C_overrides::GetKnownAttributes()
const {
return {&job_account_id,
&job_account_type,
&job_accounting_sheets,
&job_accounting_user_id,
&job_copies,
&job_cover_back,
&job_cover_front,
&job_delay_output_until,
&job_delay_output_until_time,
&job_error_action,
&job_error_sheet,
&job_finishings,
&job_finishings_col,
&job_hold_until,
&job_hold_until_time,
&job_message_to_operator,
&job_pages_per_set,
&job_phone_number,
&job_priority,
&job_recipient_name,
&job_save_disposition,
&job_sheet_message,
&job_sheets,
&job_sheets_col,
&pages_per_subset,
&output_bin,
&output_device,
&multiple_document_handling,
&y_side1_image_shift,
&y_side2_image_shift,
&number_up,
&orientation_requested,
&page_delivery,
&page_order_received,
&page_ranges,
&pdl_init_file,
&print_color_mode,
&print_content_optimize,
&print_quality,
&print_rendering_intent,
&printer_resolution,
&presentation_direction_number_up,
&media,
&sides,
&x_image_position,
&x_image_shift,
&x_side1_image_shift,
&x_side2_image_shift,
&y_image_position,
&y_image_shift,
&copies,
&cover_back,
&cover_front,
&imposition_template,
&insert_sheet,
&media_col,
&media_input_tray_check,
&print_scaling,
&proof_print,
&separator_sheets,
&sheet_collate,
&feed_orientation,
&finishings,
&finishings_col,
&font_name_requested,
&font_size_requested,
&force_front_side,
&document_copies,
&document_numbers,
&pages};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_overrides::defs_{
{AttrName::job_account_id,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_account_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_accounting_sheets,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_accounting_sheets(); }}},
{AttrName::job_accounting_user_id,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_copies,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_cover_back,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_back(); }}},
{AttrName::job_cover_front,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_front(); }}},
{AttrName::job_delay_output_until,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_delay_output_until_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::job_error_action,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::job_error_sheet,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_error_sheet(); }}},
{AttrName::job_finishings,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::job_finishings_col,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_finishings_col(); }}},
{AttrName::job_hold_until,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_hold_until_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::job_message_to_operator,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_pages_per_set,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_phone_number,
{AttrType::uri, InternalType::kString, false}},
{AttrName::job_priority,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_recipient_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_save_disposition,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_save_disposition(); }}},
{AttrName::job_sheet_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_sheets,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_sheets_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_sheets_col(); }}},
{AttrName::pages_per_subset,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::output_bin,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::output_device,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::multiple_document_handling,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::y_side1_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_side2_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::number_up,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::orientation_requested,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::page_delivery,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_order_received,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_ranges,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::pdl_init_file,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_pdl_init_file(); }}},
{AttrName::print_color_mode,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_content_optimize,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_quality,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::print_rendering_intent,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::printer_resolution,
{AttrType::resolution, InternalType::kResolution, false}},
{AttrName::presentation_direction_number_up,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::sides, {AttrType::keyword, InternalType::kInteger, false}},
{AttrName::x_image_position,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::x_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side1_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side2_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_image_position,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::y_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::copies, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::cover_back,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_back(); }}},
{AttrName::cover_front,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_front(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::insert_sheet,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_insert_sheet(); }}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::media_input_tray_check,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::print_scaling,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::proof_print,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_proof_print(); }}},
{AttrName::separator_sheets,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_separator_sheets(); }}},
{AttrName::sheet_collate,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::feed_orientation,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::finishings, {AttrType::enum_, InternalType::kInteger, true}},
{AttrName::finishings_col,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_finishings_col(); }}},
{AttrName::font_name_requested,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::font_size_requested,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::force_front_side,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::document_copies,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::document_numbers,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::pages,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_overrides_actual::GetKnownAttributes() {
return {&job_account_id,
&job_account_type,
&job_accounting_sheets,
&job_accounting_user_id,
&job_copies,
&job_cover_back,
&job_cover_front,
&job_delay_output_until,
&job_delay_output_until_time,
&job_error_action,
&job_error_sheet,
&job_finishings,
&job_finishings_col,
&job_hold_until,
&job_hold_until_time,
&job_message_to_operator,
&job_pages_per_set,
&job_phone_number,
&job_priority,
&job_recipient_name,
&job_save_disposition,
&job_sheet_message,
&job_sheets,
&job_sheets_col,
&pages_per_subset,
&output_bin,
&output_device,
&multiple_document_handling,
&y_side1_image_shift,
&y_side2_image_shift,
&number_up,
&orientation_requested,
&page_delivery,
&page_order_received,
&page_ranges,
&pdl_init_file,
&print_color_mode,
&print_content_optimize,
&print_quality,
&print_rendering_intent,
&printer_resolution,
&presentation_direction_number_up,
&media,
&sides,
&x_image_position,
&x_image_shift,
&x_side1_image_shift,
&x_side2_image_shift,
&y_image_position,
&y_image_shift,
&copies,
&cover_back,
&cover_front,
&imposition_template,
&insert_sheet,
&media_col,
&media_input_tray_check,
&print_scaling,
&proof_print,
&separator_sheets,
&sheet_collate,
&feed_orientation,
&finishings,
&finishings_col,
&font_name_requested,
&font_size_requested,
&force_front_side,
&document_copies,
&document_numbers,
&pages};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_overrides_actual::GetKnownAttributes() const {
return {&job_account_id,
&job_account_type,
&job_accounting_sheets,
&job_accounting_user_id,
&job_copies,
&job_cover_back,
&job_cover_front,
&job_delay_output_until,
&job_delay_output_until_time,
&job_error_action,
&job_error_sheet,
&job_finishings,
&job_finishings_col,
&job_hold_until,
&job_hold_until_time,
&job_message_to_operator,
&job_pages_per_set,
&job_phone_number,
&job_priority,
&job_recipient_name,
&job_save_disposition,
&job_sheet_message,
&job_sheets,
&job_sheets_col,
&pages_per_subset,
&output_bin,
&output_device,
&multiple_document_handling,
&y_side1_image_shift,
&y_side2_image_shift,
&number_up,
&orientation_requested,
&page_delivery,
&page_order_received,
&page_ranges,
&pdl_init_file,
&print_color_mode,
&print_content_optimize,
&print_quality,
&print_rendering_intent,
&printer_resolution,
&presentation_direction_number_up,
&media,
&sides,
&x_image_position,
&x_image_shift,
&x_side1_image_shift,
&x_side2_image_shift,
&y_image_position,
&y_image_shift,
&copies,
&cover_back,
&cover_front,
&imposition_template,
&insert_sheet,
&media_col,
&media_input_tray_check,
&print_scaling,
&proof_print,
&separator_sheets,
&sheet_collate,
&feed_orientation,
&finishings,
&finishings_col,
&font_name_requested,
&font_size_requested,
&force_front_side,
&document_copies,
&document_numbers,
&pages};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_overrides_actual::defs_{
{AttrName::job_account_id,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_account_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_accounting_sheets,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_accounting_sheets(); }}},
{AttrName::job_accounting_user_id,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_copies,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_cover_back,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_back(); }}},
{AttrName::job_cover_front,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_front(); }}},
{AttrName::job_delay_output_until,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_delay_output_until_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::job_error_action,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::job_error_sheet,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_error_sheet(); }}},
{AttrName::job_finishings,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::job_finishings_col,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_finishings_col(); }}},
{AttrName::job_hold_until,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_hold_until_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::job_message_to_operator,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_pages_per_set,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_phone_number,
{AttrType::uri, InternalType::kString, false}},
{AttrName::job_priority,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_recipient_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_save_disposition,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_save_disposition(); }}},
{AttrName::job_sheet_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_sheets,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_sheets_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_sheets_col(); }}},
{AttrName::pages_per_subset,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::output_bin,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::output_device,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::multiple_document_handling,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::y_side1_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_side2_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::number_up,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::orientation_requested,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::page_delivery,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_order_received,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_ranges,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::pdl_init_file,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_pdl_init_file(); }}},
{AttrName::print_color_mode,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_content_optimize,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_quality,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::print_rendering_intent,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::printer_resolution,
{AttrType::resolution, InternalType::kResolution, false}},
{AttrName::presentation_direction_number_up,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::sides, {AttrType::keyword, InternalType::kInteger, false}},
{AttrName::x_image_position,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::x_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side1_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side2_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_image_position,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::y_image_shift,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::copies, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::cover_back,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_back(); }}},
{AttrName::cover_front,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_front(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::insert_sheet,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_insert_sheet(); }}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::media_input_tray_check,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::print_scaling,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::proof_print,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_proof_print(); }}},
{AttrName::separator_sheets,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_separator_sheets(); }}},
{AttrName::sheet_collate,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::feed_orientation,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::finishings, {AttrType::enum_, InternalType::kInteger, true}},
{AttrName::finishings_col,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_finishings_col(); }}},
{AttrName::font_name_requested,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::font_size_requested,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::force_front_side,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::document_copies,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::document_numbers,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::pages,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_pdl_init_file::GetKnownAttributes() {
return {&pdl_init_file_entry, &pdl_init_file_location, &pdl_init_file_name};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_pdl_init_file::GetKnownAttributes() const {
return {&pdl_init_file_entry, &pdl_init_file_location, &pdl_init_file_name};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_pdl_init_file::defs_{
{AttrName::pdl_init_file_entry,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::pdl_init_file_location,
{AttrType::uri, InternalType::kString, false}},
{AttrName::pdl_init_file_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_proof_print::GetKnownAttributes() {
return {&media, &media_col, &proof_print_copies};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_proof_print::GetKnownAttributes() const {
return {&media, &media_col, &proof_print_copies};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_proof_print::defs_{
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::proof_print_copies,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_separator_sheets::GetKnownAttributes() {
return {&media, &media_col, &separator_sheets_type};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_separator_sheets::GetKnownAttributes() const {
return {&media, &media_col, &separator_sheets_type};
}
const std::map<AttrName, AttrDef>
Response_Get_Job_Attributes::G_job_attributes::C_separator_sheets::defs_{
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::separator_sheets_type,
{AttrType::keyword, InternalType::kInteger, true}}};
std::vector<Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_separator_sheets_actual::GetKnownAttributes() {
return {&media, &media_col, &separator_sheets_type};
}
std::vector<const Attribute*> Response_Get_Job_Attributes::G_job_attributes::
C_separator_sheets_actual::GetKnownAttributes() const {
return {&media, &media_col, &separator_sheets_type};
}
const std::map<AttrName, AttrDef> Response_Get_Job_Attributes::
G_job_attributes::C_separator_sheets_actual::defs_{
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::separator_sheets_type,
{AttrType::keyword, InternalType::kInteger, true}}};
Request_Get_Jobs::Request_Get_Jobs() : Request(Operation::Get_Jobs) {}
std::vector<Group*> Request_Get_Jobs::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_Get_Jobs::GetKnownGroups() const {
return {&operation_attributes};
}
std::vector<Attribute*>
Request_Get_Jobs::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&requesting_user_name,
&limit,
&requested_attributes,
&which_jobs,
&my_jobs};
}
std::vector<const Attribute*>
Request_Get_Jobs::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&requesting_user_name,
&limit,
&requested_attributes,
&which_jobs,
&my_jobs};
}
const std::map<AttrName, AttrDef>
Request_Get_Jobs::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::requesting_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::limit, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::requested_attributes,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::which_jobs,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::my_jobs,
{AttrType::boolean, InternalType::kInteger, false}}};
Response_Get_Jobs::Response_Get_Jobs() : Response(Operation::Get_Jobs) {}
std::vector<Group*> Response_Get_Jobs::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
std::vector<const Group*> Response_Get_Jobs::GetKnownGroups() const {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
Request_Get_Printer_Attributes::Request_Get_Printer_Attributes()
: Request(Operation::Get_Printer_Attributes) {}
std::vector<Group*> Request_Get_Printer_Attributes::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_Get_Printer_Attributes::GetKnownGroups()
const {
return {&operation_attributes};
}
std::vector<Attribute*>
Request_Get_Printer_Attributes::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset, &attributes_natural_language,
&printer_uri, &requesting_user_name,
&requested_attributes, &document_format};
}
std::vector<const Attribute*>
Request_Get_Printer_Attributes::G_operation_attributes::GetKnownAttributes()
const {
return {&attributes_charset, &attributes_natural_language,
&printer_uri, &requesting_user_name,
&requested_attributes, &document_format};
}
const std::map<AttrName, AttrDef>
Request_Get_Printer_Attributes::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::requesting_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::requested_attributes,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::document_format,
{AttrType::mimeMediaType, InternalType::kString, false}}};
Response_Get_Printer_Attributes::Response_Get_Printer_Attributes()
: Response(Operation::Get_Printer_Attributes) {}
std::vector<Group*> Response_Get_Printer_Attributes::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes, &printer_attributes};
}
std::vector<const Group*> Response_Get_Printer_Attributes::GetKnownGroups()
const {
return {&operation_attributes, &unsupported_attributes, &printer_attributes};
}
std::vector<Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::GetKnownAttributes() {
return {&baling_type_supported,
&baling_when_supported,
&binding_reference_edge_supported,
&binding_type_supported,
&charset_configured,
&charset_supported,
&coating_sides_supported,
&coating_type_supported,
&color_supported,
&compression_supported,
&copies_default,
&copies_supported,
&cover_back_default,
&cover_back_supported,
&cover_front_default,
&cover_front_supported,
&covering_name_supported,
&device_service_count,
&device_uuid,
&document_charset_default,
&document_charset_supported,
&document_digital_signature_default,
&document_digital_signature_supported,
&document_format_default,
&document_format_details_default,
&document_format_details_supported,
&document_format_supported,
&document_format_varying_attributes,
&document_format_version_default,
&document_format_version_supported,
&document_natural_language_default,
&document_natural_language_supported,
&document_password_supported,
&feed_orientation_supported,
&finishing_template_supported,
&finishings_col_database,
&finishings_col_default,
&finishings_col_ready,
&finishings_default,
&finishings_ready,
&finishings_supported,
&folding_direction_supported,
&folding_offset_supported,
&folding_reference_edge_supported,
&font_name_requested_default,
&font_name_requested_supported,
&font_size_requested_default,
&font_size_requested_supported,
&generated_natural_language_supported,
&identify_actions_default,
&identify_actions_supported,
&insert_after_page_number_supported,
&insert_count_supported,
&insert_sheet_default,
&ipp_features_supported,
&ipp_versions_supported,
&ippget_event_life,
&job_account_id_default,
&job_account_id_supported,
&job_account_type_default,
&job_account_type_supported,
&job_accounting_sheets_default,
&job_accounting_user_id_default,
&job_accounting_user_id_supported,
&job_authorization_uri_supported,
&job_constraints_supported,
&job_copies_default,
&job_copies_supported,
&job_cover_back_default,
&job_cover_back_supported,
&job_cover_front_default,
&job_cover_front_supported,
&job_delay_output_until_default,
&job_delay_output_until_supported,
&job_delay_output_until_time_supported,
&job_error_action_default,
&job_error_action_supported,
&job_error_sheet_default,
&job_finishings_col_default,
&job_finishings_col_ready,
&job_finishings_default,
&job_finishings_ready,
&job_finishings_supported,
&job_hold_until_default,
&job_hold_until_supported,
&job_hold_until_time_supported,
&job_ids_supported,
&job_impressions_supported,
&job_k_octets_supported,
&job_media_sheets_supported,
&job_message_to_operator_default,
&job_message_to_operator_supported,
&job_pages_per_set_supported,
&job_password_encryption_supported,
&job_password_supported,
&job_phone_number_default,
&job_phone_number_supported,
&job_priority_default,
&job_priority_supported,
&job_recipient_name_default,
&job_recipient_name_supported,
&job_resolvers_supported,
&job_sheet_message_default,
&job_sheet_message_supported,
&job_sheets_col_default,
&job_sheets_default,
&job_sheets_supported,
&job_spooling_supported,
&jpeg_k_octets_supported,
&jpeg_x_dimension_supported,
&jpeg_y_dimension_supported,
&laminating_sides_supported,
&laminating_type_supported,
&max_save_info_supported,
&max_stitching_locations_supported,
&media_back_coating_supported,
&media_bottom_margin_supported,
&media_col_database,
&media_col_default,
&media_col_ready,
&media_color_supported,
&media_default,
&media_front_coating_supported,
&media_grain_supported,
&media_hole_count_supported,
&media_info_supported,
&media_left_margin_supported,
&media_order_count_supported,
&media_pre_printed_supported,
&media_ready,
&media_recycled_supported,
&media_right_margin_supported,
&media_size_supported,
&media_source_supported,
&media_supported,
&media_thickness_supported,
&media_tooth_supported,
&media_top_margin_supported,
&media_type_supported,
&media_weight_metric_supported,
&multiple_document_handling_default,
&multiple_document_handling_supported,
&multiple_document_jobs_supported,
&multiple_operation_time_out,
&multiple_operation_time_out_action,
&natural_language_configured,
¬ify_events_default,
¬ify_events_supported,
¬ify_lease_duration_default,
¬ify_lease_duration_supported,
¬ify_pull_method_supported,
¬ify_schemes_supported,
&number_up_default,
&number_up_supported,
&oauth_authorization_server_uri,
&operations_supported,
&orientation_requested_default,
&orientation_requested_supported,
&output_bin_default,
&output_bin_supported,
&output_device_supported,
&output_device_uuid_supported,
&page_delivery_default,
&page_delivery_supported,
&page_order_received_default,
&page_order_received_supported,
&page_ranges_supported,
&pages_per_minute,
&pages_per_minute_color,
&pages_per_subset_supported,
&parent_printers_supported,
&pdf_k_octets_supported,
&pdf_versions_supported,
&pdl_init_file_default,
&pdl_init_file_entry_supported,
&pdl_init_file_location_supported,
&pdl_init_file_name_subdirectory_supported,
&pdl_init_file_name_supported,
&pdl_init_file_supported,
&pdl_override_supported,
&preferred_attributes_supported,
&presentation_direction_number_up_default,
&presentation_direction_number_up_supported,
&print_color_mode_default,
&print_color_mode_supported,
&print_content_optimize_default,
&print_content_optimize_supported,
&print_quality_default,
&print_quality_supported,
&print_rendering_intent_default,
&print_rendering_intent_supported,
&printer_alert,
&printer_alert_description,
&printer_charge_info,
&printer_charge_info_uri,
&printer_config_change_date_time,
&printer_config_change_time,
&printer_config_changes,
&printer_contact_col,
&printer_current_time,
&printer_detailed_status_messages,
&printer_device_id,
&printer_dns_sd_name,
&printer_driver_installer,
&printer_finisher,
&printer_finisher_description,
&printer_finisher_supplies,
&printer_finisher_supplies_description,
&printer_geo_location,
&printer_icc_profiles,
&printer_icons,
&printer_id,
&printer_impressions_completed,
&printer_info,
&printer_input_tray,
&printer_is_accepting_jobs,
&printer_location,
&printer_make_and_model,
&printer_media_sheets_completed,
&printer_message_date_time,
&printer_message_from_operator,
&printer_message_time,
&printer_more_info,
&printer_more_info_manufacturer,
&printer_name,
&printer_organization,
&printer_organizational_unit,
&printer_output_tray,
&printer_pages_completed,
&printer_resolution_default,
&printer_resolution_supported,
&printer_state,
&printer_state_change_date_time,
&printer_state_change_time,
&printer_state_message,
&printer_state_reasons,
&printer_static_resource_directory_uri,
&printer_static_resource_k_octets_free,
&printer_static_resource_k_octets_supported,
&printer_strings_languages_supported,
&printer_strings_uri,
&printer_supply,
&printer_supply_description,
&printer_supply_info_uri,
&printer_up_time,
&printer_uri_supported,
&printer_uuid,
&printer_xri_supported,
&proof_print_default,
&proof_print_supported,
&punching_hole_diameter_configured,
&punching_locations_supported,
&punching_offset_supported,
&punching_reference_edge_supported,
&pwg_raster_document_resolution_supported,
&pwg_raster_document_sheet_back,
&pwg_raster_document_type_supported,
&queued_job_count,
&reference_uri_schemes_supported,
&requesting_user_uri_supported,
&save_disposition_supported,
&save_document_format_default,
&save_document_format_supported,
&save_location_default,
&save_location_supported,
&save_name_subdirectory_supported,
&save_name_supported,
&separator_sheets_default,
&sheet_collate_default,
&sheet_collate_supported,
&sides_default,
&sides_supported,
&stitching_angle_supported,
&stitching_locations_supported,
&stitching_method_supported,
&stitching_offset_supported,
&stitching_reference_edge_supported,
&subordinate_printers_supported,
&trimming_offset_supported,
&trimming_reference_edge_supported,
&trimming_type_supported,
&trimming_when_supported,
&uri_authentication_supported,
&uri_security_supported,
&which_jobs_supported,
&x_image_position_default,
&x_image_position_supported,
&x_image_shift_default,
&x_image_shift_supported,
&x_side1_image_shift_default,
&x_side1_image_shift_supported,
&x_side2_image_shift_default,
&x_side2_image_shift_supported,
&xri_authentication_supported,
&xri_security_supported,
&xri_uri_scheme_supported,
&y_image_position_default,
&y_image_position_supported,
&y_image_shift_default,
&y_image_shift_supported,
&y_side1_image_shift_default,
&y_side1_image_shift_supported,
&y_side2_image_shift_default,
&y_side2_image_shift_supported};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::GetKnownAttributes()
const {
return {&baling_type_supported,
&baling_when_supported,
&binding_reference_edge_supported,
&binding_type_supported,
&charset_configured,
&charset_supported,
&coating_sides_supported,
&coating_type_supported,
&color_supported,
&compression_supported,
&copies_default,
&copies_supported,
&cover_back_default,
&cover_back_supported,
&cover_front_default,
&cover_front_supported,
&covering_name_supported,
&device_service_count,
&device_uuid,
&document_charset_default,
&document_charset_supported,
&document_digital_signature_default,
&document_digital_signature_supported,
&document_format_default,
&document_format_details_default,
&document_format_details_supported,
&document_format_supported,
&document_format_varying_attributes,
&document_format_version_default,
&document_format_version_supported,
&document_natural_language_default,
&document_natural_language_supported,
&document_password_supported,
&feed_orientation_supported,
&finishing_template_supported,
&finishings_col_database,
&finishings_col_default,
&finishings_col_ready,
&finishings_default,
&finishings_ready,
&finishings_supported,
&folding_direction_supported,
&folding_offset_supported,
&folding_reference_edge_supported,
&font_name_requested_default,
&font_name_requested_supported,
&font_size_requested_default,
&font_size_requested_supported,
&generated_natural_language_supported,
&identify_actions_default,
&identify_actions_supported,
&insert_after_page_number_supported,
&insert_count_supported,
&insert_sheet_default,
&ipp_features_supported,
&ipp_versions_supported,
&ippget_event_life,
&job_account_id_default,
&job_account_id_supported,
&job_account_type_default,
&job_account_type_supported,
&job_accounting_sheets_default,
&job_accounting_user_id_default,
&job_accounting_user_id_supported,
&job_authorization_uri_supported,
&job_constraints_supported,
&job_copies_default,
&job_copies_supported,
&job_cover_back_default,
&job_cover_back_supported,
&job_cover_front_default,
&job_cover_front_supported,
&job_delay_output_until_default,
&job_delay_output_until_supported,
&job_delay_output_until_time_supported,
&job_error_action_default,
&job_error_action_supported,
&job_error_sheet_default,
&job_finishings_col_default,
&job_finishings_col_ready,
&job_finishings_default,
&job_finishings_ready,
&job_finishings_supported,
&job_hold_until_default,
&job_hold_until_supported,
&job_hold_until_time_supported,
&job_ids_supported,
&job_impressions_supported,
&job_k_octets_supported,
&job_media_sheets_supported,
&job_message_to_operator_default,
&job_message_to_operator_supported,
&job_pages_per_set_supported,
&job_password_encryption_supported,
&job_password_supported,
&job_phone_number_default,
&job_phone_number_supported,
&job_priority_default,
&job_priority_supported,
&job_recipient_name_default,
&job_recipient_name_supported,
&job_resolvers_supported,
&job_sheet_message_default,
&job_sheet_message_supported,
&job_sheets_col_default,
&job_sheets_default,
&job_sheets_supported,
&job_spooling_supported,
&jpeg_k_octets_supported,
&jpeg_x_dimension_supported,
&jpeg_y_dimension_supported,
&laminating_sides_supported,
&laminating_type_supported,
&max_save_info_supported,
&max_stitching_locations_supported,
&media_back_coating_supported,
&media_bottom_margin_supported,
&media_col_database,
&media_col_default,
&media_col_ready,
&media_color_supported,
&media_default,
&media_front_coating_supported,
&media_grain_supported,
&media_hole_count_supported,
&media_info_supported,
&media_left_margin_supported,
&media_order_count_supported,
&media_pre_printed_supported,
&media_ready,
&media_recycled_supported,
&media_right_margin_supported,
&media_size_supported,
&media_source_supported,
&media_supported,
&media_thickness_supported,
&media_tooth_supported,
&media_top_margin_supported,
&media_type_supported,
&media_weight_metric_supported,
&multiple_document_handling_default,
&multiple_document_handling_supported,
&multiple_document_jobs_supported,
&multiple_operation_time_out,
&multiple_operation_time_out_action,
&natural_language_configured,
¬ify_events_default,
¬ify_events_supported,
¬ify_lease_duration_default,
¬ify_lease_duration_supported,
¬ify_pull_method_supported,
¬ify_schemes_supported,
&number_up_default,
&number_up_supported,
&oauth_authorization_server_uri,
&operations_supported,
&orientation_requested_default,
&orientation_requested_supported,
&output_bin_default,
&output_bin_supported,
&output_device_supported,
&output_device_uuid_supported,
&page_delivery_default,
&page_delivery_supported,
&page_order_received_default,
&page_order_received_supported,
&page_ranges_supported,
&pages_per_minute,
&pages_per_minute_color,
&pages_per_subset_supported,
&parent_printers_supported,
&pdf_k_octets_supported,
&pdf_versions_supported,
&pdl_init_file_default,
&pdl_init_file_entry_supported,
&pdl_init_file_location_supported,
&pdl_init_file_name_subdirectory_supported,
&pdl_init_file_name_supported,
&pdl_init_file_supported,
&pdl_override_supported,
&preferred_attributes_supported,
&presentation_direction_number_up_default,
&presentation_direction_number_up_supported,
&print_color_mode_default,
&print_color_mode_supported,
&print_content_optimize_default,
&print_content_optimize_supported,
&print_quality_default,
&print_quality_supported,
&print_rendering_intent_default,
&print_rendering_intent_supported,
&printer_alert,
&printer_alert_description,
&printer_charge_info,
&printer_charge_info_uri,
&printer_config_change_date_time,
&printer_config_change_time,
&printer_config_changes,
&printer_contact_col,
&printer_current_time,
&printer_detailed_status_messages,
&printer_device_id,
&printer_dns_sd_name,
&printer_driver_installer,
&printer_finisher,
&printer_finisher_description,
&printer_finisher_supplies,
&printer_finisher_supplies_description,
&printer_geo_location,
&printer_icc_profiles,
&printer_icons,
&printer_id,
&printer_impressions_completed,
&printer_info,
&printer_input_tray,
&printer_is_accepting_jobs,
&printer_location,
&printer_make_and_model,
&printer_media_sheets_completed,
&printer_message_date_time,
&printer_message_from_operator,
&printer_message_time,
&printer_more_info,
&printer_more_info_manufacturer,
&printer_name,
&printer_organization,
&printer_organizational_unit,
&printer_output_tray,
&printer_pages_completed,
&printer_resolution_default,
&printer_resolution_supported,
&printer_state,
&printer_state_change_date_time,
&printer_state_change_time,
&printer_state_message,
&printer_state_reasons,
&printer_static_resource_directory_uri,
&printer_static_resource_k_octets_free,
&printer_static_resource_k_octets_supported,
&printer_strings_languages_supported,
&printer_strings_uri,
&printer_supply,
&printer_supply_description,
&printer_supply_info_uri,
&printer_up_time,
&printer_uri_supported,
&printer_uuid,
&printer_xri_supported,
&proof_print_default,
&proof_print_supported,
&punching_hole_diameter_configured,
&punching_locations_supported,
&punching_offset_supported,
&punching_reference_edge_supported,
&pwg_raster_document_resolution_supported,
&pwg_raster_document_sheet_back,
&pwg_raster_document_type_supported,
&queued_job_count,
&reference_uri_schemes_supported,
&requesting_user_uri_supported,
&save_disposition_supported,
&save_document_format_default,
&save_document_format_supported,
&save_location_default,
&save_location_supported,
&save_name_subdirectory_supported,
&save_name_supported,
&separator_sheets_default,
&sheet_collate_default,
&sheet_collate_supported,
&sides_default,
&sides_supported,
&stitching_angle_supported,
&stitching_locations_supported,
&stitching_method_supported,
&stitching_offset_supported,
&stitching_reference_edge_supported,
&subordinate_printers_supported,
&trimming_offset_supported,
&trimming_reference_edge_supported,
&trimming_type_supported,
&trimming_when_supported,
&uri_authentication_supported,
&uri_security_supported,
&which_jobs_supported,
&x_image_position_default,
&x_image_position_supported,
&x_image_shift_default,
&x_image_shift_supported,
&x_side1_image_shift_default,
&x_side1_image_shift_supported,
&x_side2_image_shift_default,
&x_side2_image_shift_supported,
&xri_authentication_supported,
&xri_security_supported,
&xri_uri_scheme_supported,
&y_image_position_default,
&y_image_position_supported,
&y_image_shift_default,
&y_image_shift_supported,
&y_side1_image_shift_default,
&y_side1_image_shift_supported,
&y_side2_image_shift_default,
&y_side2_image_shift_supported};
}
const std::map<AttrName, AttrDef>
Response_Get_Printer_Attributes::G_printer_attributes::defs_{
{AttrName::baling_type_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::baling_when_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::binding_reference_edge_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::binding_type_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::charset_configured,
{AttrType::charset, InternalType::kString, false}},
{AttrName::charset_supported,
{AttrType::charset, InternalType::kString, true}},
{AttrName::coating_sides_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::coating_type_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::color_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::compression_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::copies_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::copies_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::cover_back_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_back_default(); }}},
{AttrName::cover_back_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::cover_front_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_cover_front_default(); }}},
{AttrName::cover_front_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::covering_name_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::device_service_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::device_uuid, {AttrType::uri, InternalType::kString, false}},
{AttrName::document_charset_default,
{AttrType::charset, InternalType::kString, false}},
{AttrName::document_charset_supported,
{AttrType::charset, InternalType::kString, true}},
{AttrName::document_digital_signature_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::document_digital_signature_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::document_format_default,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::document_format_details_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* {
return new C_document_format_details_default();
}}},
{AttrName::document_format_details_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::document_format_supported,
{AttrType::mimeMediaType, InternalType::kString, true}},
{AttrName::document_format_varying_attributes,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::document_format_version_default,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_format_version_supported,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::document_natural_language_default,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::document_natural_language_supported,
{AttrType::naturalLanguage, InternalType::kString, true}},
{AttrName::document_password_supported,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::feed_orientation_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::finishing_template_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::finishings_col_database,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_finishings_col_database(); }}},
{AttrName::finishings_col_default,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_finishings_col_default(); }}},
{AttrName::finishings_col_ready,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_finishings_col_ready(); }}},
{AttrName::finishings_default,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::finishings_ready,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::finishings_supported,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::folding_direction_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::folding_offset_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::folding_reference_edge_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::font_name_requested_default,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::font_name_requested_supported,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::font_size_requested_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::font_size_requested_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::generated_natural_language_supported,
{AttrType::naturalLanguage, InternalType::kString, true}},
{AttrName::identify_actions_default,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::identify_actions_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::insert_after_page_number_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::insert_count_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::insert_sheet_default,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_insert_sheet_default(); }}},
{AttrName::ipp_features_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::ipp_versions_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::ippget_event_life,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_account_id_default,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_account_id_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_account_type_default,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_account_type_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::job_accounting_sheets_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* {
return new C_job_accounting_sheets_default();
}}},
{AttrName::job_accounting_user_id_default,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_accounting_user_id_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_authorization_uri_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_constraints_supported,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_constraints_supported(); }}},
{AttrName::job_copies_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_copies_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::job_cover_back_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_back_default(); }}},
{AttrName::job_cover_back_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::job_cover_front_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_cover_front_default(); }}},
{AttrName::job_cover_front_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::job_delay_output_until_default,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_delay_output_until_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::job_delay_output_until_time_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::job_error_action_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::job_error_action_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::job_error_sheet_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_error_sheet_default(); }}},
{AttrName::job_finishings_col_default,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_finishings_col_default(); }}},
{AttrName::job_finishings_col_ready,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_finishings_col_ready(); }}},
{AttrName::job_finishings_default,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::job_finishings_ready,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::job_finishings_supported,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::job_hold_until_default,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_hold_until_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::job_hold_until_time_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::job_ids_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_impressions_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::job_k_octets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::job_media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::job_message_to_operator_default,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_message_to_operator_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_pages_per_set_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_password_encryption_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::job_password_supported,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_phone_number_default,
{AttrType::uri, InternalType::kString, false}},
{AttrName::job_phone_number_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_priority_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_priority_supported,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_recipient_name_default,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_recipient_name_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_resolvers_supported,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_job_resolvers_supported(); }}},
{AttrName::job_sheet_message_default,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_sheet_message_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::job_sheets_col_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_job_sheets_col_default(); }}},
{AttrName::job_sheets_default,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_sheets_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::job_spooling_supported,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::jpeg_k_octets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::jpeg_x_dimension_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::jpeg_y_dimension_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::laminating_sides_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::laminating_type_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::max_save_info_supported,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::max_stitching_locations_supported,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_back_coating_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_bottom_margin_supported,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::media_col_database,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_media_col_database(); }}},
{AttrName::media_col_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col_default(); }}},
{AttrName::media_col_ready,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_media_col_ready(); }}},
{AttrName::media_color_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_default,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_front_coating_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_grain_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_hole_count_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::media_info_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::media_left_margin_supported,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::media_order_count_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::media_pre_printed_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_ready,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_recycled_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_right_margin_supported,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::media_size_supported,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_media_size_supported(); }}},
{AttrName::media_source_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_thickness_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_tooth_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_top_margin_supported,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::media_type_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::media_weight_metric_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::multiple_document_handling_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::multiple_document_handling_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::multiple_document_jobs_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::multiple_operation_time_out,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::multiple_operation_time_out_action,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::natural_language_configured,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::notify_events_default,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::notify_events_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::notify_lease_duration_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::notify_lease_duration_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::notify_pull_method_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::notify_schemes_supported,
{AttrType::uriScheme, InternalType::kString, true}},
{AttrName::number_up_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::number_up_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::oauth_authorization_server_uri,
{AttrType::uri, InternalType::kString, false}},
{AttrName::operations_supported,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::orientation_requested_default,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::orientation_requested_supported,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::output_bin_default,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::output_bin_supported,
{AttrType::keyword, InternalType::kString, true}},
{AttrName::output_device_supported,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::output_device_uuid_supported,
{AttrType::uri, InternalType::kString, true}},
{AttrName::page_delivery_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_delivery_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::page_order_received_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::page_order_received_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::page_ranges_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::pages_per_minute,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::pages_per_minute_color,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::pages_per_subset_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::parent_printers_supported,
{AttrType::uri, InternalType::kString, true}},
{AttrName::pdf_k_octets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::pdf_versions_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::pdl_init_file_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_pdl_init_file_default(); }}},
{AttrName::pdl_init_file_entry_supported,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::pdl_init_file_location_supported,
{AttrType::uri, InternalType::kString, true}},
{AttrName::pdl_init_file_name_subdirectory_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::pdl_init_file_name_supported,
{AttrType::name, InternalType::kStringWithLanguage, true}},
{AttrName::pdl_init_file_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::pdl_override_supported,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::preferred_attributes_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::presentation_direction_number_up_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::presentation_direction_number_up_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::print_color_mode_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_color_mode_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::print_content_optimize_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_content_optimize_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::print_quality_default,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::print_quality_supported,
{AttrType::enum_, InternalType::kInteger, true}},
{AttrName::print_rendering_intent_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::print_rendering_intent_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::printer_alert,
{AttrType::octetString, InternalType::kString, true}},
{AttrName::printer_alert_description,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::printer_charge_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_charge_info_uri,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_config_change_date_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::printer_config_change_time,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_config_changes,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_contact_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_printer_contact_col(); }}},
{AttrName::printer_current_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::printer_detailed_status_messages,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::printer_device_id,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_dns_sd_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::printer_driver_installer,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_finisher,
{AttrType::octetString, InternalType::kString, true}},
{AttrName::printer_finisher_description,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::printer_finisher_supplies,
{AttrType::octetString, InternalType::kString, true}},
{AttrName::printer_finisher_supplies_description,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::printer_geo_location,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_icc_profiles,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_printer_icc_profiles(); }}},
{AttrName::printer_icons, {AttrType::uri, InternalType::kString, true}},
{AttrName::printer_id,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_impressions_completed,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_input_tray,
{AttrType::octetString, InternalType::kString, true}},
{AttrName::printer_is_accepting_jobs,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::printer_location,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_make_and_model,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_media_sheets_completed,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_message_date_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::printer_message_from_operator,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_message_time,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_more_info,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_more_info_manufacturer,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::printer_organization,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::printer_organizational_unit,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::printer_output_tray,
{AttrType::octetString, InternalType::kString, true}},
{AttrName::printer_pages_completed,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_resolution_default,
{AttrType::resolution, InternalType::kResolution, false}},
{AttrName::printer_resolution_supported,
{AttrType::resolution, InternalType::kResolution, false}},
{AttrName::printer_state,
{AttrType::enum_, InternalType::kInteger, false}},
{AttrName::printer_state_change_date_time,
{AttrType::dateTime, InternalType::kDateTime, false}},
{AttrName::printer_state_change_time,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_state_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::printer_state_reasons,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::printer_static_resource_directory_uri,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_static_resource_k_octets_free,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_static_resource_k_octets_supported,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_strings_languages_supported,
{AttrType::naturalLanguage, InternalType::kString, true}},
{AttrName::printer_strings_uri,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_supply,
{AttrType::octetString, InternalType::kString, true}},
{AttrName::printer_supply_description,
{AttrType::text, InternalType::kStringWithLanguage, true}},
{AttrName::printer_supply_info_uri,
{AttrType::uri, InternalType::kString, false}},
{AttrName::printer_up_time,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::printer_uri_supported,
{AttrType::uri, InternalType::kString, true}},
{AttrName::printer_uuid, {AttrType::uri, InternalType::kString, false}},
{AttrName::printer_xri_supported,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_printer_xri_supported(); }}},
{AttrName::proof_print_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_proof_print_default(); }}},
{AttrName::proof_print_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::punching_hole_diameter_configured,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_locations_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::punching_offset_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::punching_reference_edge_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::pwg_raster_document_resolution_supported,
{AttrType::resolution, InternalType::kResolution, true}},
{AttrName::pwg_raster_document_sheet_back,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::pwg_raster_document_type_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::queued_job_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::reference_uri_schemes_supported,
{AttrType::uriScheme, InternalType::kString, true}},
{AttrName::requesting_user_uri_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::save_disposition_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::save_document_format_default,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::save_document_format_supported,
{AttrType::mimeMediaType, InternalType::kString, true}},
{AttrName::save_location_default,
{AttrType::uri, InternalType::kString, false}},
{AttrName::save_location_supported,
{AttrType::uri, InternalType::kString, true}},
{AttrName::save_name_subdirectory_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::save_name_supported,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::separator_sheets_default,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_separator_sheets_default(); }}},
{AttrName::sheet_collate_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::sheet_collate_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::sides_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::sides_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::stitching_angle_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::stitching_locations_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::stitching_method_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::stitching_offset_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::stitching_reference_edge_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::subordinate_printers_supported,
{AttrType::uri, InternalType::kString, true}},
{AttrName::trimming_offset_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, true}},
{AttrName::trimming_reference_edge_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::trimming_type_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::trimming_when_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::uri_authentication_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::uri_security_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::which_jobs_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::x_image_position_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::x_image_position_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::x_image_shift_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_image_shift_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::x_side1_image_shift_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side1_image_shift_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::x_side2_image_shift_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::x_side2_image_shift_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::xri_authentication_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::xri_security_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::xri_uri_scheme_supported,
{AttrType::uriScheme, InternalType::kString, true}},
{AttrName::y_image_position_default,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::y_image_position_supported,
{AttrType::keyword, InternalType::kInteger, true}},
{AttrName::y_image_shift_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_image_shift_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::y_side1_image_shift_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_side1_image_shift_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::y_side2_image_shift_default,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_side2_image_shift_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_cover_back_default::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_cover_back_default::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_cover_back_default::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_cover_front_default::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_cover_front_default::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_cover_front_default::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_document_format_details_default::GetKnownAttributes() {
return {&document_format,
&document_format_device_id,
&document_format_version,
&document_natural_language,
&document_source_application_name,
&document_source_application_version,
&document_source_os_name,
&document_source_os_version};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_document_format_details_default::GetKnownAttributes() const {
return {&document_format,
&document_format_device_id,
&document_format_version,
&document_natural_language,
&document_source_application_name,
&document_source_application_version,
&document_source_os_name,
&document_source_os_version};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_document_format_details_default::defs_{
{AttrName::document_format,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::document_format_device_id,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_format_version,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_natural_language,
{AttrType::naturalLanguage, InternalType::kString, true}},
{AttrName::document_source_application_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::document_source_application_version,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_source_os_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::document_source_os_version,
{AttrType::text, InternalType::kStringWithLanguage, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_database::GetKnownAttributes()
const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_database::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_database::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_database::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_database::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_database::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_database::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_database::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_database::C_media_size::defs_{};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_database::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_database::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_database::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_database::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_default::GetKnownAttributes() const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_default::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_default::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_default::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_default::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_default::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_default::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_default::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_default::C_media_size::defs_{};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_default::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_default::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_default::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_default::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_ready::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_ready::GetKnownAttributes() const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_ready::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_ready::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_ready::C_baling::GetKnownAttributes()
const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_ready::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_ready::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::C_finishings_col_ready::
C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_ready::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_ready::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::C_finishings_col_ready::
C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_ready::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_ready::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::C_finishings_col_ready::
C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_ready::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_ready::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::C_finishings_col_ready::
C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_ready::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_ready::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::C_finishings_col_ready::
C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_ready::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_ready::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::C_finishings_col_ready::
C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_ready::C_media_size::defs_{};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_ready::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::C_finishings_col_ready::
C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_ready::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_ready::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::C_finishings_col_ready::
C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_ready::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_finishings_col_ready::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::C_finishings_col_ready::
C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_finishings_col_ready::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_insert_sheet_default::GetKnownAttributes() {
return {&insert_after_page_number, &insert_count, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_insert_sheet_default::GetKnownAttributes() const {
return {&insert_after_page_number, &insert_count, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_insert_sheet_default::defs_{
{AttrName::insert_after_page_number,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::insert_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_accounting_sheets_default::GetKnownAttributes() {
return {&job_accounting_output_bin, &job_accounting_sheets_type, &media,
&media_col};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_accounting_sheets_default::GetKnownAttributes()
const {
return {&job_accounting_output_bin, &job_accounting_sheets_type, &media,
&media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_accounting_sheets_default::defs_{
{AttrName::job_accounting_output_bin,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_accounting_sheets_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_constraints_supported::GetKnownAttributes() {
return {&resolver_name};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_constraints_supported::GetKnownAttributes()
const {
return {&resolver_name};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_constraints_supported::defs_{
{AttrName::resolver_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_cover_back_default::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_cover_back_default::GetKnownAttributes() const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_cover_back_default::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_cover_front_default::GetKnownAttributes() {
return {&cover_type, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_cover_front_default::GetKnownAttributes()
const {
return {&cover_type, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_cover_front_default::defs_{
{AttrName::cover_type,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_error_sheet_default::GetKnownAttributes() {
return {&job_error_sheet_type, &job_error_sheet_when, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_error_sheet_default::GetKnownAttributes()
const {
return {&job_error_sheet_type, &job_error_sheet_when, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_error_sheet_default::defs_{
{AttrName::job_error_sheet_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::job_error_sheet_when,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_default::GetKnownAttributes()
const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_default::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_default::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_default::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_default::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_default::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_default::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_default::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_default::C_media_size::defs_{};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_default::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_default::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_default::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_default::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::GetKnownAttributes() {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_ready::GetKnownAttributes()
const {
return {&baling,
&binding,
&coating,
&covering,
&finishing_template,
&folding,
&imposition_template,
&laminating,
&media_sheets_supported,
&media_size,
&media_size_name,
&punching,
&stitching,
&trimming};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_ready::defs_{
{AttrName::baling,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_baling(); }}},
{AttrName::binding,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_binding(); }}},
{AttrName::coating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_coating(); }}},
{AttrName::covering,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_covering(); }}},
{AttrName::finishing_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::folding,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_folding(); }}},
{AttrName::imposition_template,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::laminating,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_laminating(); }}},
{AttrName::media_sheets_supported,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::punching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_punching(); }}},
{AttrName::stitching,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_stitching(); }}},
{AttrName::trimming,
{AttrType::collection, InternalType::kCollection, true,
[]() -> Collection* { return new C_trimming(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_baling::GetKnownAttributes() {
return {&baling_type, &baling_when};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_baling::GetKnownAttributes() const {
return {&baling_type, &baling_when};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_ready::C_baling::defs_{
{AttrName::baling_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::baling_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_binding::GetKnownAttributes() {
return {&binding_reference_edge, &binding_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_binding::GetKnownAttributes() const {
return {&binding_reference_edge, &binding_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_ready::C_binding::defs_{
{AttrName::binding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::binding_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_coating::GetKnownAttributes() {
return {&coating_sides, &coating_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_coating::GetKnownAttributes() const {
return {&coating_sides, &coating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_ready::C_coating::defs_{
{AttrName::coating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::coating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_covering::GetKnownAttributes() {
return {&covering_name};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_covering::GetKnownAttributes() const {
return {&covering_name};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_ready::C_covering::defs_{
{AttrName::covering_name,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_folding::GetKnownAttributes() {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_folding::GetKnownAttributes() const {
return {&folding_direction, &folding_offset, &folding_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_ready::C_folding::defs_{
{AttrName::folding_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::folding_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::folding_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_laminating::GetKnownAttributes() {
return {&laminating_sides, &laminating_type};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_laminating::GetKnownAttributes() const {
return {&laminating_sides, &laminating_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_ready::C_laminating::defs_{
{AttrName::laminating_sides,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::laminating_type,
{AttrType::keyword, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_media_size::GetKnownAttributes() {
return {};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_media_size::GetKnownAttributes() const {
return {};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_ready::C_media_size::defs_{};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_punching::GetKnownAttributes() {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_punching::GetKnownAttributes() const {
return {&punching_locations, &punching_offset, &punching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_ready::C_punching::defs_{
{AttrName::punching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::punching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::punching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_stitching::GetKnownAttributes() {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_stitching::GetKnownAttributes() const {
return {&stitching_angle, &stitching_locations, &stitching_method,
&stitching_offset, &stitching_reference_edge};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_ready::C_stitching::defs_{
{AttrName::stitching_angle,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_locations,
{AttrType::integer, InternalType::kInteger, true}},
{AttrName::stitching_method,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::stitching_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::stitching_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_trimming::GetKnownAttributes() {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::
C_job_finishings_col_ready::C_trimming::GetKnownAttributes() const {
return {&trimming_offset, &trimming_reference_edge, &trimming_type,
&trimming_when};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_finishings_col_ready::C_trimming::defs_{
{AttrName::trimming_offset,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::trimming_reference_edge,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::trimming_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::trimming_when,
{AttrType::keyword, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_resolvers_supported::GetKnownAttributes() {
return {&resolver_name};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_resolvers_supported::GetKnownAttributes()
const {
return {&resolver_name};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_resolvers_supported::defs_{
{AttrName::resolver_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_job_sheets_col_default::GetKnownAttributes() {
return {&job_sheets, &media, &media_col};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_sheets_col_default::GetKnownAttributes() const {
return {&job_sheets, &media, &media_col};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_job_sheets_col_default::defs_{
{AttrName::job_sheets,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_media_col_database::GetKnownAttributes() {
return {&media_back_coating, &media_bottom_margin,
&media_color, &media_front_coating,
&media_grain, &media_hole_count,
&media_info, &media_key,
&media_left_margin, &media_order_count,
&media_pre_printed, &media_recycled,
&media_right_margin, &media_size,
&media_size_name, &media_source,
&media_thickness, &media_tooth,
&media_top_margin, &media_type,
&media_weight_metric, &media_source_properties};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_media_col_database::GetKnownAttributes() const {
return {&media_back_coating, &media_bottom_margin,
&media_color, &media_front_coating,
&media_grain, &media_hole_count,
&media_info, &media_key,
&media_left_margin, &media_order_count,
&media_pre_printed, &media_recycled,
&media_right_margin, &media_size,
&media_size_name, &media_source,
&media_thickness, &media_tooth,
&media_top_margin, &media_type,
&media_weight_metric, &media_source_properties};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_media_col_database::defs_{
{AttrName::media_back_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_bottom_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_color,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_front_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_grain,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_hole_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::media_key,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_left_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_order_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_pre_printed,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_recycled,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_right_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::media_source,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_thickness,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_tooth,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_top_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_weight_metric,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_source_properties,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_source_properties(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_media_col_database::C_media_size::GetKnownAttributes() {
return {&x_dimension, &y_dimension};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::C_media_col_database::
C_media_size::GetKnownAttributes() const {
return {&x_dimension, &y_dimension};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_media_col_database::C_media_size::defs_{
{AttrName::x_dimension,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_dimension,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_media_col_database::C_media_source_properties::GetKnownAttributes() {
return {&media_source_feed_direction, &media_source_feed_orientation};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::C_media_col_database::
C_media_source_properties::GetKnownAttributes() const {
return {&media_source_feed_direction, &media_source_feed_orientation};
}
const std::map<AttrName, AttrDef>
Response_Get_Printer_Attributes::G_printer_attributes::
C_media_col_database::C_media_source_properties::defs_{
{AttrName::media_source_feed_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media_source_feed_orientation,
{AttrType::enum_, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_media_col_default::GetKnownAttributes() {
return {&media_back_coating, &media_bottom_margin, &media_color,
&media_front_coating, &media_grain, &media_hole_count,
&media_info, &media_key, &media_left_margin,
&media_order_count, &media_pre_printed, &media_recycled,
&media_right_margin, &media_size, &media_size_name,
&media_source, &media_thickness, &media_tooth,
&media_top_margin, &media_type, &media_weight_metric};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_media_col_default::GetKnownAttributes() const {
return {&media_back_coating, &media_bottom_margin, &media_color,
&media_front_coating, &media_grain, &media_hole_count,
&media_info, &media_key, &media_left_margin,
&media_order_count, &media_pre_printed, &media_recycled,
&media_right_margin, &media_size, &media_size_name,
&media_source, &media_thickness, &media_tooth,
&media_top_margin, &media_type, &media_weight_metric};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_media_col_default::defs_{
{AttrName::media_back_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_bottom_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_color,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_front_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_grain,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_hole_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::media_key,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_left_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_order_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_pre_printed,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_recycled,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_right_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::media_source,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_thickness,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_tooth,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_top_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_weight_metric,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_media_col_default::C_media_size::GetKnownAttributes() {
return {&x_dimension, &y_dimension};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::C_media_col_default::
C_media_size::GetKnownAttributes() const {
return {&x_dimension, &y_dimension};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_media_col_default::C_media_size::defs_{
{AttrName::x_dimension,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_dimension,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_media_col_ready::GetKnownAttributes() {
return {&media_back_coating, &media_bottom_margin,
&media_color, &media_front_coating,
&media_grain, &media_hole_count,
&media_info, &media_key,
&media_left_margin, &media_order_count,
&media_pre_printed, &media_recycled,
&media_right_margin, &media_size,
&media_size_name, &media_source,
&media_thickness, &media_tooth,
&media_top_margin, &media_type,
&media_weight_metric, &media_source_properties};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_media_col_ready::GetKnownAttributes() const {
return {&media_back_coating, &media_bottom_margin,
&media_color, &media_front_coating,
&media_grain, &media_hole_count,
&media_info, &media_key,
&media_left_margin, &media_order_count,
&media_pre_printed, &media_recycled,
&media_right_margin, &media_size,
&media_size_name, &media_source,
&media_thickness, &media_tooth,
&media_top_margin, &media_type,
&media_weight_metric, &media_source_properties};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_media_col_ready::defs_{
{AttrName::media_back_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_bottom_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_color,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_front_coating,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_grain,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_hole_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_info,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::media_key,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_left_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_order_count,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_pre_printed,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_recycled,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_right_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_size,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_size(); }}},
{AttrName::media_size_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::media_source,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_thickness,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_tooth,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_top_margin,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_type,
{AttrType::keyword, InternalType::kString, false}},
{AttrName::media_weight_metric,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::media_source_properties,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_source_properties(); }}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_media_col_ready::C_media_size::GetKnownAttributes() {
return {&x_dimension, &y_dimension};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_media_col_ready::C_media_size::GetKnownAttributes()
const {
return {&x_dimension, &y_dimension};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_media_col_ready::C_media_size::defs_{
{AttrName::x_dimension,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::y_dimension,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_media_col_ready::C_media_source_properties::GetKnownAttributes() {
return {&media_source_feed_direction, &media_source_feed_orientation};
}
std::vector<const Attribute*>
Response_Get_Printer_Attributes::G_printer_attributes::C_media_col_ready::
C_media_source_properties::GetKnownAttributes() const {
return {&media_source_feed_direction, &media_source_feed_orientation};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_media_col_ready::C_media_source_properties::defs_{
{AttrName::media_source_feed_direction,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::media_source_feed_orientation,
{AttrType::enum_, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_media_size_supported::GetKnownAttributes() {
return {&x_dimension, &y_dimension};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_media_size_supported::GetKnownAttributes() const {
return {&x_dimension, &y_dimension};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_media_size_supported::defs_{
{AttrName::x_dimension,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}},
{AttrName::y_dimension,
{AttrType::rangeOfInteger, InternalType::kRangeOfInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_pdl_init_file_default::GetKnownAttributes() {
return {&pdl_init_file_entry, &pdl_init_file_location, &pdl_init_file_name};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_pdl_init_file_default::GetKnownAttributes() const {
return {&pdl_init_file_entry, &pdl_init_file_location, &pdl_init_file_name};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_pdl_init_file_default::defs_{
{AttrName::pdl_init_file_entry,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::pdl_init_file_location,
{AttrType::uri, InternalType::kString, false}},
{AttrName::pdl_init_file_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_printer_contact_col::GetKnownAttributes() {
return {&contact_name, &contact_uri, &contact_vcard};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_printer_contact_col::GetKnownAttributes() const {
return {&contact_name, &contact_uri, &contact_vcard};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_printer_contact_col::defs_{
{AttrName::contact_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::contact_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::contact_vcard,
{AttrType::text, InternalType::kStringWithLanguage, true}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_printer_icc_profiles::GetKnownAttributes() {
return {&profile_name, &profile_url};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_printer_icc_profiles::GetKnownAttributes() const {
return {&profile_name, &profile_url};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_printer_icc_profiles::defs_{
{AttrName::profile_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::profile_url, {AttrType::uri, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_printer_xri_supported::GetKnownAttributes() {
return {&xri_authentication, &xri_security, &xri_uri};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_printer_xri_supported::GetKnownAttributes() const {
return {&xri_authentication, &xri_security, &xri_uri};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_printer_xri_supported::defs_{
{AttrName::xri_authentication,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::xri_security,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::xri_uri, {AttrType::uri, InternalType::kString, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_proof_print_default::GetKnownAttributes() {
return {&media, &media_col, &proof_print_copies};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_proof_print_default::GetKnownAttributes() const {
return {&media, &media_col, &proof_print_copies};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_proof_print_default::defs_{
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::proof_print_copies,
{AttrType::integer, InternalType::kInteger, false}}};
std::vector<Attribute*> Response_Get_Printer_Attributes::G_printer_attributes::
C_separator_sheets_default::GetKnownAttributes() {
return {&media, &media_col, &separator_sheets_type};
}
std::vector<const Attribute*> Response_Get_Printer_Attributes::
G_printer_attributes::C_separator_sheets_default::GetKnownAttributes()
const {
return {&media, &media_col, &separator_sheets_type};
}
const std::map<AttrName, AttrDef> Response_Get_Printer_Attributes::
G_printer_attributes::C_separator_sheets_default::defs_{
{AttrName::media, {AttrType::keyword, InternalType::kString, false}},
{AttrName::media_col,
{AttrType::collection, InternalType::kCollection, false,
[]() -> Collection* { return new C_media_col(); }}},
{AttrName::separator_sheets_type,
{AttrType::keyword, InternalType::kInteger, true}}};
Request_Hold_Job::Request_Hold_Job() : Request(Operation::Hold_Job) {}
std::vector<Group*> Request_Hold_Job::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_Hold_Job::GetKnownGroups() const {
return {&operation_attributes};
}
std::vector<Attribute*>
Request_Hold_Job::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&job_id,
&job_uri,
&requesting_user_name,
&message,
&job_hold_until};
}
std::vector<const Attribute*>
Request_Hold_Job::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&job_id,
&job_uri,
&requesting_user_name,
&message,
&job_hold_until};
}
const std::map<AttrName, AttrDef>
Request_Hold_Job::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::job_id, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::requesting_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::job_hold_until,
{AttrType::keyword, InternalType::kString, false}}};
Response_Hold_Job::Response_Hold_Job() : Response(Operation::Hold_Job) {}
std::vector<Group*> Response_Hold_Job::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes};
}
std::vector<const Group*> Response_Hold_Job::GetKnownGroups() const {
return {&operation_attributes, &unsupported_attributes};
}
Request_Pause_Printer::Request_Pause_Printer()
: Request(Operation::Pause_Printer) {}
std::vector<Group*> Request_Pause_Printer::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_Pause_Printer::GetKnownGroups() const {
return {&operation_attributes};
}
std::vector<Attribute*>
Request_Pause_Printer::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset, &attributes_natural_language, &printer_uri,
&requesting_user_name};
}
std::vector<const Attribute*>
Request_Pause_Printer::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset, &attributes_natural_language, &printer_uri,
&requesting_user_name};
}
const std::map<AttrName, AttrDef>
Request_Pause_Printer::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::requesting_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}}};
Response_Pause_Printer::Response_Pause_Printer()
: Response(Operation::Pause_Printer) {}
std::vector<Group*> Response_Pause_Printer::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes};
}
std::vector<const Group*> Response_Pause_Printer::GetKnownGroups() const {
return {&operation_attributes, &unsupported_attributes};
}
Request_Print_Job::Request_Print_Job() : Request(Operation::Print_Job) {}
std::vector<Group*> Request_Print_Job::GetKnownGroups() {
return {&operation_attributes, &job_attributes};
}
std::vector<const Group*> Request_Print_Job::GetKnownGroups() const {
return {&operation_attributes, &job_attributes};
}
std::vector<Attribute*>
Request_Print_Job::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset, &attributes_natural_language,
&printer_uri, &requesting_user_name,
&job_name, &ipp_attribute_fidelity,
&document_name, &compression,
&document_format, &document_natural_language,
&job_k_octets, &job_impressions,
&job_media_sheets};
}
std::vector<const Attribute*>
Request_Print_Job::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset, &attributes_natural_language,
&printer_uri, &requesting_user_name,
&job_name, &ipp_attribute_fidelity,
&document_name, &compression,
&document_format, &document_natural_language,
&job_k_octets, &job_impressions,
&job_media_sheets};
}
const std::map<AttrName, AttrDef>
Request_Print_Job::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::requesting_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::ipp_attribute_fidelity,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::document_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::compression,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::document_format,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::document_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::job_k_octets,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_impressions,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_media_sheets,
{AttrType::integer, InternalType::kInteger, false}}};
Response_Print_Job::Response_Print_Job() : Response(Operation::Print_Job) {}
std::vector<Group*> Response_Print_Job::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
std::vector<const Group*> Response_Print_Job::GetKnownGroups() const {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
Request_Print_URI::Request_Print_URI() : Request(Operation::Print_URI) {}
std::vector<Group*> Request_Print_URI::GetKnownGroups() {
return {&operation_attributes, &job_attributes};
}
std::vector<const Group*> Request_Print_URI::GetKnownGroups() const {
return {&operation_attributes, &job_attributes};
}
std::vector<Attribute*>
Request_Print_URI::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&document_uri,
&requesting_user_name,
&job_name,
&ipp_attribute_fidelity,
&document_name,
&compression,
&document_format,
&document_natural_language,
&job_k_octets,
&job_impressions,
&job_media_sheets};
}
std::vector<const Attribute*>
Request_Print_URI::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&document_uri,
&requesting_user_name,
&job_name,
&ipp_attribute_fidelity,
&document_name,
&compression,
&document_format,
&document_natural_language,
&job_k_octets,
&job_impressions,
&job_media_sheets};
}
const std::map<AttrName, AttrDef>
Request_Print_URI::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::document_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::requesting_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::job_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::ipp_attribute_fidelity,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::document_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::compression,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::document_format,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::document_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::job_k_octets,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_impressions,
{AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_media_sheets,
{AttrType::integer, InternalType::kInteger, false}}};
Response_Print_URI::Response_Print_URI() : Response(Operation::Print_URI) {}
std::vector<Group*> Response_Print_URI::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
std::vector<const Group*> Response_Print_URI::GetKnownGroups() const {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
std::vector<Attribute*>
Response_Print_URI::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset, &attributes_natural_language, &status_message,
&detailed_status_message, &document_access_error};
}
std::vector<const Attribute*>
Response_Print_URI::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset, &attributes_natural_language, &status_message,
&detailed_status_message, &document_access_error};
}
const std::map<AttrName, AttrDef>
Response_Print_URI::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::status_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::detailed_status_message,
{AttrType::text, InternalType::kStringWithLanguage, false}},
{AttrName::document_access_error,
{AttrType::text, InternalType::kStringWithLanguage, false}}};
Request_Release_Job::Request_Release_Job() : Request(Operation::Release_Job) {}
std::vector<Group*> Request_Release_Job::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_Release_Job::GetKnownGroups() const {
return {&operation_attributes};
}
Response_Release_Job::Response_Release_Job()
: Response(Operation::Release_Job) {}
std::vector<Group*> Response_Release_Job::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes};
}
std::vector<const Group*> Response_Release_Job::GetKnownGroups() const {
return {&operation_attributes, &unsupported_attributes};
}
Request_Resume_Printer::Request_Resume_Printer()
: Request(Operation::Resume_Printer) {}
std::vector<Group*> Request_Resume_Printer::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_Resume_Printer::GetKnownGroups() const {
return {&operation_attributes};
}
Response_Resume_Printer::Response_Resume_Printer()
: Response(Operation::Resume_Printer) {}
std::vector<Group*> Response_Resume_Printer::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes};
}
std::vector<const Group*> Response_Resume_Printer::GetKnownGroups() const {
return {&operation_attributes, &unsupported_attributes};
}
Request_Send_Document::Request_Send_Document()
: Request(Operation::Send_Document) {}
std::vector<Group*> Request_Send_Document::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_Send_Document::GetKnownGroups() const {
return {&operation_attributes};
}
std::vector<Attribute*>
Request_Send_Document::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&job_id,
&job_uri,
&requesting_user_name,
&document_name,
&compression,
&document_format,
&document_natural_language,
&last_document};
}
std::vector<const Attribute*>
Request_Send_Document::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&job_id,
&job_uri,
&requesting_user_name,
&document_name,
&compression,
&document_format,
&document_natural_language,
&last_document};
}
const std::map<AttrName, AttrDef>
Request_Send_Document::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::job_id, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::requesting_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::document_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::compression,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::document_format,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::document_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::last_document,
{AttrType::boolean, InternalType::kInteger, false}}};
Response_Send_Document::Response_Send_Document()
: Response(Operation::Send_Document) {}
std::vector<Group*> Response_Send_Document::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
std::vector<const Group*> Response_Send_Document::GetKnownGroups() const {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
Request_Send_URI::Request_Send_URI() : Request(Operation::Send_URI) {}
std::vector<Group*> Request_Send_URI::GetKnownGroups() {
return {&operation_attributes};
}
std::vector<const Group*> Request_Send_URI::GetKnownGroups() const {
return {&operation_attributes};
}
std::vector<Attribute*>
Request_Send_URI::G_operation_attributes::GetKnownAttributes() {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&job_id,
&job_uri,
&requesting_user_name,
&document_name,
&compression,
&document_format,
&document_natural_language,
&last_document,
&document_uri};
}
std::vector<const Attribute*>
Request_Send_URI::G_operation_attributes::GetKnownAttributes() const {
return {&attributes_charset,
&attributes_natural_language,
&printer_uri,
&job_id,
&job_uri,
&requesting_user_name,
&document_name,
&compression,
&document_format,
&document_natural_language,
&last_document,
&document_uri};
}
const std::map<AttrName, AttrDef>
Request_Send_URI::G_operation_attributes::defs_{
{AttrName::attributes_charset,
{AttrType::charset, InternalType::kString, false}},
{AttrName::attributes_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::printer_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::job_id, {AttrType::integer, InternalType::kInteger, false}},
{AttrName::job_uri, {AttrType::uri, InternalType::kString, false}},
{AttrName::requesting_user_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::document_name,
{AttrType::name, InternalType::kStringWithLanguage, false}},
{AttrName::compression,
{AttrType::keyword, InternalType::kInteger, false}},
{AttrName::document_format,
{AttrType::mimeMediaType, InternalType::kString, false}},
{AttrName::document_natural_language,
{AttrType::naturalLanguage, InternalType::kString, false}},
{AttrName::last_document,
{AttrType::boolean, InternalType::kInteger, false}},
{AttrName::document_uri,
{AttrType::uri, InternalType::kString, false}}};
Response_Send_URI::Response_Send_URI() : Response(Operation::Send_URI) {}
std::vector<Group*> Response_Send_URI::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
std::vector<const Group*> Response_Send_URI::GetKnownGroups() const {
return {&operation_attributes, &unsupported_attributes, &job_attributes};
}
Request_Validate_Job::Request_Validate_Job()
: Request(Operation::Validate_Job) {}
std::vector<Group*> Request_Validate_Job::GetKnownGroups() {
return {&operation_attributes, &job_attributes};
}
std::vector<const Group*> Request_Validate_Job::GetKnownGroups() const {
return {&operation_attributes, &job_attributes};
}
Response_Validate_Job::Response_Validate_Job()
: Response(Operation::Validate_Job) {}
std::vector<Group*> Response_Validate_Job::GetKnownGroups() {
return {&operation_attributes, &unsupported_attributes};
}
std::vector<const Group*> Response_Validate_Job::GetKnownGroups() const {
return {&operation_attributes, &unsupported_attributes};
}
} // namespace ipp
| 46.497459 | 80 | 0.690108 | [
"vector"
] |
9fd6ff907206bb8ccdcecff4cd0c518d349cfc3d | 2,424 | hpp | C++ | include/particle.hpp | teamclouday/Balloons | 106bf031967e72b54269ca7375481a9327e71c46 | [
"MIT"
] | null | null | null | include/particle.hpp | teamclouday/Balloons | 106bf031967e72b54269ca7375481a9327e71c46 | [
"MIT"
] | null | null | null | include/particle.hpp | teamclouday/Balloons | 106bf031967e72b54269ca7375481a9327e71c46 | [
"MIT"
] | null | null | null | // particle.hpp
// Assignment: CIS425 Final Project
// Environment/Compiler:
// Visual Studio Community 2019 (Tested)
// Linux GCC (Tested)
// MacOS GCC (Not Tested)
// Date: May 14, 2021
// Official Name: Sida Zhu
// E-mail:
// szhu28@syr.edu
// teamclouday@gmail.com
// File Description:
// This header file defines the following classes as particle systems
// ParticleBullet (for bullets appearing on surfaces)
// ParticleBalloon (for balloons with physical interactions)
// Firework (for fireworks appearing after balloon is hit)
#pragma once
#include <glm/glm.hpp>
#include <vector>
#define GRAVITY_G 98.0f // m/s^2
#define BALLOON_SIZE 10.0f
// This class defines the bullets left on the objects
class ParticleBullet
{
public:
void update();
void addBullet(glm::vec3& position, int timeout);
const unsigned MaxBullets = 10;
struct BulletData
{
glm::vec3 pos;
int timeout;
};
std::vector<BulletData> data;
};
// This class collects and updates the balloons at every game stage
class ParticleBalloon
{
public:
enum BallonColor
{
RED = 0,
BLUE = 1,
GREEN = 2,
YELLOW = 3,
PINK = 4,
};
// The balloon object structure
struct Balloon
{
BallonColor color;
glm::vec3 pos;
glm::vec3 vel; // this is the velocity
float radius; // the size of the balloon
};
std::vector<Balloon> balloons;
bool enablePhysics = false; // whether to enable physics (gravity, wind)
bool enableWindForce = false; // whether to enable wind force
void loadBalloonsTest();
void loadBalloonsBegin();
void loadBalloonsStage1();
void loadBalloonsStage2();
void loadBalloonsStage3();
void loadBalloonsStage4();
void update(int fps); // update positions if enablePhysics
};
// This class is created to show a firework
// either after balloon explodes
// or at the end after winning the game
class Firework
{
public:
struct Particle
{
glm::vec3 pos;
glm::vec3 vel;
};
Firework(int num, int timeout, float radius, glm::vec3 center);
~Firework();
void update(int fps); // update particle positions
std::vector<Particle*> particles;
glm::vec3 color; // color is randomly generated
int timeout;
}; | 26.933333 | 78 | 0.632838 | [
"object",
"vector"
] |
9fd79753e0a44efdcd486aaac42f3a1b6184a36d | 312 | cpp | C++ | src/solver/optimize.cpp | cowprotocol/simple-solver-template | 51aeebd91c4d7b99627a93d0a066684553bdc5ad | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | null | null | null | src/solver/optimize.cpp | cowprotocol/simple-solver-template | 51aeebd91c4d7b99627a93d0a066684553bdc5ad | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | 4 | 2021-12-16T09:40:39.000Z | 2022-02-02T18:49:47.000Z | src/solver/optimize.cpp | cowprotocol/simple-solver-template | 51aeebd91c4d7b99627a93d0a066684553bdc5ad | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | 2 | 2022-03-28T15:35:32.000Z | 2022-03-30T14:27:47.000Z | #include "../components/token.hpp"
#include "../components/order.hpp"
#include "../components/amm.hpp"
#include "./optimize.hpp"
void solve_auction(std::vector<Token> &tokens, std::vector<Order> &orders, std::vector<CP_AMM> &amms)
{
// TO BE COMPLETED
int *vertices;
int **edges;
return;
} | 22.285714 | 101 | 0.657051 | [
"vector"
] |
9fdf4c8b6073c0cd88f10f22b12038196d718891 | 19,725 | cpp | C++ | src/gui/tabs/tabgeometry.cpp | henryiii/spatial-model-editor | 2138d03ae4c7cc353b40324dfd1a3e763d7085d9 | [
"MIT"
] | 1 | 2021-04-19T10:23:58.000Z | 2021-04-19T10:23:58.000Z | src/gui/tabs/tabgeometry.cpp | henryiii/spatial-model-editor | 2138d03ae4c7cc353b40324dfd1a3e763d7085d9 | [
"MIT"
] | 418 | 2020-10-08T07:42:27.000Z | 2022-03-08T12:10:52.000Z | src/gui/tabs/tabgeometry.cpp | henryiii/spatial-model-editor | 2138d03ae4c7cc353b40324dfd1a3e763d7085d9 | [
"MIT"
] | 2 | 2021-09-02T11:20:38.000Z | 2021-10-13T14:05:32.000Z | #include "tabgeometry.hpp"
#include "guiutils.hpp"
#include "logger.hpp"
#include "mesh.hpp"
#include "model.hpp"
#include "qlabelmousetracker.hpp"
#include "ui_tabgeometry.h"
#include <QInputDialog>
#include <QMessageBox>
#include <QStatusBar>
#include <stdexcept>
TabGeometry::TabGeometry(sme::model::Model &m, QLabelMouseTracker *mouseTracker,
QStatusBar *statusBar, QWidget *parent)
: QWidget(parent), ui{std::make_unique<Ui::TabGeometry>()}, model(m),
lblGeometry(mouseTracker), statusBar{statusBar} {
ui->setupUi(this);
ui->tabCompartmentGeometry->setCurrentIndex(0);
connect(lblGeometry, &QLabelMouseTracker::mouseClicked, this,
&TabGeometry::lblGeometry_mouseClicked);
connect(ui->btnAddCompartment, &QPushButton::clicked, this,
&TabGeometry::btnAddCompartment_clicked);
connect(ui->btnRemoveCompartment, &QPushButton::clicked, this,
&TabGeometry::btnRemoveCompartment_clicked);
connect(ui->btnChangeCompartment, &QPushButton::clicked, this,
&TabGeometry::btnChangeCompartment_clicked);
connect(ui->txtCompartmentName, &QLineEdit::editingFinished, this,
&TabGeometry::txtCompartmentName_editingFinished);
connect(ui->tabCompartmentGeometry, &QTabWidget::currentChanged, this,
&TabGeometry::tabCompartmentGeometry_currentChanged);
connect(ui->lblCompShape, &QLabelMouseTracker::mouseOver, this,
&TabGeometry::lblCompShape_mouseOver);
connect(ui->lblCompBoundary, &QLabelMouseTracker::mouseClicked, this,
&TabGeometry::lblCompBoundary_mouseClicked);
connect(ui->lblCompBoundary, &QLabelMouseTracker::mouseWheelEvent, this,
[this](QWheelEvent *ev) {
if (ev->modifiers() == Qt::ShiftModifier) {
QApplication::sendEvent(ui->spinBoundaryZoom, ev);
} else {
QApplication::sendEvent(ui->spinMaxBoundaryPoints, ev);
}
});
connect(ui->spinBoundaryIndex, qOverload<int>(&QSpinBox::valueChanged), this,
&TabGeometry::spinBoundaryIndex_valueChanged);
connect(ui->spinMaxBoundaryPoints, qOverload<int>(&QSpinBox::valueChanged),
this, &TabGeometry::spinMaxBoundaryPoints_valueChanged);
connect(ui->spinBoundaryZoom, qOverload<int>(&QSpinBox::valueChanged), this,
&TabGeometry::spinBoundaryZoom_valueChanged);
connect(ui->lblCompMesh, &QLabelMouseTracker::mouseClicked, this,
&TabGeometry::lblCompMesh_mouseClicked);
connect(ui->lblCompMesh, &QLabelMouseTracker::mouseWheelEvent, this,
[this](QWheelEvent *ev) {
if (ev->modifiers() == Qt::ShiftModifier) {
QApplication::sendEvent(ui->spinMeshZoom, ev);
} else {
QApplication::sendEvent(ui->spinMaxTriangleArea, ev);
}
});
connect(ui->spinMaxTriangleArea, qOverload<int>(&QSpinBox::valueChanged),
this, &TabGeometry::spinMaxTriangleArea_valueChanged);
connect(ui->spinMeshZoom, qOverload<int>(&QSpinBox::valueChanged), this,
&TabGeometry::spinMeshZoom_valueChanged);
connect(ui->listCompartments, &QListWidget::itemSelectionChanged, this,
&TabGeometry::listCompartments_itemSelectionChanged);
connect(ui->listCompartments, &QListWidget::itemDoubleClicked, this,
&TabGeometry::listCompartments_itemDoubleClicked);
connect(ui->listMembranes, &QListWidget::itemSelectionChanged, this,
&TabGeometry::listMembranes_itemSelectionChanged);
}
TabGeometry::~TabGeometry() = default;
void TabGeometry::loadModelData(const QString &selection) {
ui->tabCompartmentGeometry->setCurrentIndex(0);
ui->listMembranes->clear();
ui->listMembranes->addItems(model.getMembranes().getNames());
ui->listCompartments->clear();
ui->lblCompShape->clear();
ui->lblCompBoundary->clear();
ui->lblCompMesh->clear();
ui->lblCompartmentColour->clear();
ui->txtCompartmentName->clear();
ui->listCompartments->addItems(model.getCompartments().getNames());
ui->btnChangeCompartment->setEnabled(false);
ui->txtCompartmentName->setEnabled(false);
if (ui->listCompartments->count() > 0) {
ui->txtCompartmentName->setEnabled(true);
ui->listCompartments->setCurrentRow(0);
ui->btnChangeCompartment->setEnabled(true);
}
lblGeometry->setImage(model.getGeometry().getImage());
enableTabs();
selectMatchingOrFirstItem(ui->listCompartments, selection);
}
void TabGeometry::enableTabs() {
bool enableBoundaries = model.getGeometry().getIsValid();
bool enableMesh = model.getGeometry().getMesh() != nullptr &&
model.getGeometry().getMesh()->isValid();
auto *tab = ui->tabCompartmentGeometry;
tab->setTabEnabled(1, enableBoundaries);
tab->setTabEnabled(2, enableBoundaries);
tab->setTabEnabled(3, enableMesh);
ui->listMembranes->setEnabled(enableBoundaries);
}
void TabGeometry::invertYAxis(bool enable) {
ui->lblCompShape->invertYAxis(enable);
ui->lblCompBoundary->invertYAxis(enable);
ui->lblCompMesh->invertYAxis(enable);
}
void TabGeometry::lblGeometry_mouseClicked(QRgb col, QPoint point) {
if (waitingForCompartmentChoice) {
SPDLOG_INFO("colour {:x}", col);
SPDLOG_INFO("point ({},{})", point.x(), point.y());
// update compartment geometry (i.e. colour) of selected compartment to
// the one the user just clicked on
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
const auto &compartmentID =
model.getCompartments().getIds().at(ui->listCompartments->currentRow());
model.getCompartments().setColour(compartmentID, col);
ui->tabCompartmentGeometry->setCurrentIndex(0);
ui->listMembranes->clear();
ui->listMembranes->addItems(model.getMembranes().getNames());
// update display by simulating user click on listCompartments
listCompartments_itemSelectionChanged();
waitingForCompartmentChoice = false;
if (statusBar != nullptr) {
statusBar->clearMessage();
}
QGuiApplication::restoreOverrideCursor();
enableTabs();
emit modelGeometryChanged();
return;
}
// display compartment the user just clicked on
auto compID = model.getCompartments().getIdFromColour(col);
for (int i = 0; i < model.getCompartments().getIds().size(); ++i) {
if (model.getCompartments().getIds().at(i) == compID) {
ui->listCompartments->setCurrentRow(i);
}
}
}
void TabGeometry::btnAddCompartment_clicked() {
bool ok;
auto compartmentName = QInputDialog::getText(
this, "Add compartment", "New compartment name:", QLineEdit::Normal, {},
&ok);
if (ok && !compartmentName.isEmpty()) {
QString newCompartmentName = model.getCompartments().add(compartmentName);
ui->tabCompartmentGeometry->setCurrentIndex(0);
enableTabs();
loadModelData(newCompartmentName);
emit modelGeometryChanged();
}
}
void TabGeometry::btnRemoveCompartment_clicked() {
int index = ui->listCompartments->currentRow();
if (index < 0 || index >= model.getCompartments().getIds().size()) {
return;
}
const auto &compartmentName = ui->listCompartments->item(index)->text();
const auto &compartmentId = model.getCompartments().getIds()[index];
auto result{QMessageBox::question(
this, "Remove compartment?",
QString("Remove compartment '%1' from the model?").arg(compartmentName),
QMessageBox::Yes | QMessageBox::No)};
if (result == QMessageBox::Yes) {
ui->listCompartments->clearSelection();
model.getCompartments().remove(compartmentId);
ui->tabCompartmentGeometry->setCurrentIndex(0);
enableTabs();
loadModelData();
emit modelGeometryChanged();
}
}
void TabGeometry::btnChangeCompartment_clicked() {
if (!(model.getIsValid() && model.getGeometry().getHasImage())) {
emit invalidModelOrNoGeometryImage();
SPDLOG_DEBUG("invalid geometry and/or model: ignoring");
return;
}
SPDLOG_DEBUG("waiting for user to click on geometry image..");
waitingForCompartmentChoice = true;
if (statusBar != nullptr) {
statusBar->showMessage(
"Please click on the desired location on the compartment geometry "
"image...");
}
}
void TabGeometry::txtCompartmentName_editingFinished() {
if (membraneSelected) {
int membraneIndex{ui->listMembranes->currentRow()};
if (membraneIndex < 0 ||
membraneIndex >= model.getMembranes().getIds().size()) {
// invalid index
return;
}
if (ui->txtCompartmentName->text() ==
model.getMembranes().getNames()[membraneIndex]) {
// name is unchanged
return;
}
const auto &membraneId{model.getMembranes().getIds().at(membraneIndex)};
QString name{model.getMembranes().setName(membraneId,
ui->txtCompartmentName->text())};
ui->txtCompartmentName->setText(name);
ui->listMembranes->item(membraneIndex)->setText(name);
return;
}
// compartment
int compIndex{ui->listCompartments->currentRow()};
if (compIndex < 0 || compIndex >= model.getCompartments().getIds().size()) {
return;
}
if (ui->txtCompartmentName->text() ==
model.getCompartments().getNames()[compIndex]) {
return;
}
const auto &compartmentId{model.getCompartments().getIds().at(compIndex)};
QString name{model.getCompartments().setName(compartmentId,
ui->txtCompartmentName->text())};
ui->txtCompartmentName->setText(name);
ui->listCompartments->item(compIndex)->setText(name);
// changing a compartment name may change membrane names
ui->listMembranes->clear();
ui->listMembranes->addItems(model.getMembranes().getNames());
}
void TabGeometry::tabCompartmentGeometry_currentChanged(int index) {
enum TabIndex { IMAGE = 0, BOUNDARIES = 1, MESH = 2 };
SPDLOG_DEBUG("Tab changed to {} [{}]", index,
ui->tabCompartmentGeometry->tabText(index).toStdString());
if (index == TabIndex::IMAGE) {
return;
}
if (index == TabIndex::BOUNDARIES) {
auto size = model.getGeometry().getMesh()->getNumBoundaries();
if (size == 0) {
ui->spinBoundaryIndex->setEnabled(false);
ui->spinMaxBoundaryPoints->setEnabled(false);
ui->spinBoundaryZoom->setEnabled(false);
return;
}
ui->spinBoundaryIndex->setMaximum(static_cast<int>(size) - 1);
ui->spinBoundaryIndex->setEnabled(true);
ui->spinMaxBoundaryPoints->setEnabled(true);
ui->spinBoundaryZoom->setEnabled(true);
spinBoundaryIndex_valueChanged(ui->spinBoundaryIndex->value());
return;
}
if (index == TabIndex::MESH) {
const auto *mesh{model.getGeometry().getMesh()};
if (mesh == nullptr) {
ui->spinMaxTriangleArea->setEnabled(false);
ui->spinMeshZoom->setEnabled(false);
return;
}
ui->spinMaxTriangleArea->setEnabled(true);
ui->spinMeshZoom->setEnabled(true);
auto compIndex =
static_cast<std::size_t>(ui->listCompartments->currentRow());
ui->spinMaxTriangleArea->setValue(static_cast<int>(
model.getGeometry().getMesh()->getCompartmentMaxTriangleArea(
compIndex)));
spinMaxTriangleArea_valueChanged(ui->spinMaxTriangleArea->value());
if (!mesh->isValid()) {
QString msg{"Error: Unable to generate mesh.\n\nImproving the accuracy "
"of the boundary lines might help. To do this, click on the "
"\"Boundary Lines\" "
"tab and increase the maximum number of allowed "
"points.\n\nError message: "};
msg.append(mesh->getErrorMessage().c_str());
ui->lblCompMesh->setText(msg);
ui->spinMaxTriangleArea->setEnabled(false);
ui->spinMeshZoom->setEnabled(false);
return;
}
}
}
void TabGeometry::lblCompShape_mouseOver(QPoint point) {
if (statusBar != nullptr) {
statusBar->showMessage(model.getGeometry().getPhysicalPointAsString(point));
}
}
void TabGeometry::lblCompBoundary_mouseClicked(QRgb col, QPoint point) {
Q_UNUSED(col);
Q_UNUSED(point);
auto index = ui->lblCompBoundary->getMaskIndex();
if (index <= ui->spinBoundaryIndex->maximum() &&
index != ui->spinBoundaryIndex->value()) {
ui->spinBoundaryIndex->setValue(index);
}
}
void TabGeometry::spinBoundaryIndex_valueChanged(int value) {
const auto &size = ui->lblCompBoundary->size();
auto boundaryIndex = static_cast<size_t>(value);
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
ui->spinMaxBoundaryPoints->setValue(static_cast<int>(
model.getGeometry().getMesh()->getBoundaryMaxPoints(boundaryIndex)));
ui->lblCompBoundary->setImages(
model.getGeometry().getMesh()->getBoundariesImages(size, boundaryIndex));
QGuiApplication::restoreOverrideCursor();
}
void TabGeometry::spinMaxBoundaryPoints_valueChanged(int value) {
const auto &size = ui->lblCompBoundary->size();
auto boundaryIndex = static_cast<std::size_t>(ui->spinBoundaryIndex->value());
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
model.getGeometry().getMesh()->setBoundaryMaxPoints(
boundaryIndex, static_cast<size_t>(value));
ui->lblCompBoundary->setImages(
model.getGeometry().getMesh()->getBoundariesImages(size, boundaryIndex));
QGuiApplication::restoreOverrideCursor();
}
void TabGeometry::spinBoundaryZoom_valueChanged(int value) {
if (value == 0) {
// rescale to fit entire scroll region
ui->scrollBoundaryLines->setWidgetResizable(true);
} else {
zoomScrollArea(ui->scrollBoundaryLines, value,
ui->lblCompBoundary->getRelativePosition());
}
spinBoundaryIndex_valueChanged(ui->spinBoundaryIndex->value());
}
void TabGeometry::lblCompMesh_mouseClicked(QRgb col, QPoint point) {
Q_UNUSED(col);
Q_UNUSED(point);
auto index = ui->lblCompMesh->getMaskIndex();
SPDLOG_TRACE("Point ({},{}), Mask index {}", point.x(), point.y(), index);
auto membraneIndex = static_cast<int>(index) - ui->listCompartments->count();
if (index >= 0 && index < ui->listCompartments->count()) {
ui->listCompartments->setCurrentRow(index);
ui->spinMaxTriangleArea->setFocus();
ui->spinMaxTriangleArea->selectAll();
return;
}
if (membraneIndex >= 0 && membraneIndex < ui->listMembranes->count()) {
ui->listMembranes->setCurrentRow(membraneIndex);
return;
}
}
void TabGeometry::spinMaxTriangleArea_valueChanged(int value) {
const auto &size = ui->lblCompMesh->size();
auto compIndex = static_cast<std::size_t>(ui->listCompartments->currentRow());
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
model.getGeometry().getMesh()->setCompartmentMaxTriangleArea(
compIndex, static_cast<std::size_t>(value));
ui->lblCompMesh->setImages(
model.getGeometry().getMesh()->getMeshImages(size, compIndex));
QGuiApplication::restoreOverrideCursor();
}
void TabGeometry::spinMeshZoom_valueChanged(int value) {
if (value == 0) {
// rescale to fit entire scroll region
ui->scrollMesh->setWidgetResizable(true);
} else {
zoomScrollArea(ui->scrollMesh, value,
ui->lblCompMesh->getRelativePosition());
}
spinMaxTriangleArea_valueChanged(ui->spinMaxTriangleArea->value());
}
void TabGeometry::listCompartments_itemSelectionChanged() {
auto items{ui->listCompartments->selectedItems()};
if (items.isEmpty()) {
ui->btnRemoveCompartment->setEnabled(false);
ui->btnChangeCompartment->setEnabled(false);
return;
}
ui->listMembranes->clearSelection();
int currentRow{ui->listCompartments->row(items[0])};
ui->txtCompartmentName->clear();
ui->lblCompSize->clear();
membraneSelected = false;
const QString &compId{model.getCompartments().getIds()[currentRow]};
ui->btnChangeCompartment->setEnabled(true);
ui->btnRemoveCompartment->setEnabled(true);
SPDLOG_DEBUG("row {} selected", currentRow);
SPDLOG_DEBUG(" - Compartment Name: {}",
ui->listCompartments->currentItem()->text().toStdString());
SPDLOG_DEBUG(" - Compartment Id: {}", compId.toStdString());
ui->txtCompartmentName->setEnabled(true);
ui->txtCompartmentName->setText(model.getCompartments().getName(compId));
QRgb col{model.getCompartments().getColour(compId)};
SPDLOG_DEBUG(" - Compartment colour {:x} ", col);
if (col == 0) {
// null (transparent) RGB colour: compartment does not have
// an assigned colour in the image
ui->lblCompShape->setImage(QImage());
ui->lblCompartmentColour->setText("none");
ui->lblCompShape->setImage(QImage());
ui->lblCompShape->setText(
"<p>Compartment has no assigned geometry</p> "
"<ul><li>please click on the 'Select compartment geometry...' "
"button below</li> "
"<li> then on the desired location in the geometry "
"image on the left</li></ul>");
ui->lblCompMesh->setImage(QImage());
ui->lblCompMesh->setText("none");
} else {
// update colour box
QImage img(1, 1, QImage::Format_RGB32);
img.setPixel(0, 0, col);
ui->lblCompartmentColour->setPixmap(QPixmap::fromImage(img));
ui->lblCompartmentColour->setText("");
// update image of compartment
const auto *comp{model.getCompartments().getCompartment(compId)};
ui->lblCompShape->setImage(comp->getCompartmentImage());
ui->lblCompShape->setText("");
// update mesh or boundary image if tab is currently visible
tabCompartmentGeometry_currentChanged(
ui->tabCompartmentGeometry->currentIndex());
// update compartment size
double volume{model.getCompartments().getSize(compId)};
ui->lblCompSize->setText(QString("Volume: %1 %2 (%3 pixels)")
.arg(QString::number(volume, 'g', 13))
.arg(model.getUnits().getVolume().name)
.arg(comp->nPixels()));
}
}
void TabGeometry::listCompartments_itemDoubleClicked(QListWidgetItem *item) {
// double-click on compartment list item is equivalent to
// selecting item, then clicking on btnChangeCompartment
if (item != nullptr) {
btnChangeCompartment_clicked();
}
}
void TabGeometry::listMembranes_itemSelectionChanged() {
auto items{ui->listMembranes->selectedItems()};
if (items.isEmpty()) {
return;
}
int currentRow{ui->listMembranes->row(items[0])};
membraneSelected = true;
ui->listCompartments->clearSelection();
ui->txtCompartmentName->clear();
ui->txtCompartmentName->setEnabled(true);
const QString &membraneId{model.getMembranes().getIds()[currentRow]};
SPDLOG_DEBUG("row {} selected", currentRow);
SPDLOG_DEBUG(" - Membrane Name: {}",
ui->listMembranes->currentItem()->text().toStdString());
SPDLOG_DEBUG(" - Membrane Id: {}", membraneId.toStdString());
ui->txtCompartmentName->setText(ui->listMembranes->currentItem()->text());
// update image
const auto *m{model.getMembranes().getMembrane(membraneId)};
ui->lblCompShape->setImage(m->getImage());
auto nPixels{m->getIndexPairs().size()};
// update colour box
QImage img(1, 2, QImage::Format_RGB32);
img.setPixel(0, 0, m->getCompartmentA()->getColour());
img.setPixel(0, 1, m->getCompartmentB()->getColour());
ui->lblCompartmentColour->setPixmap(QPixmap::fromImage(img));
ui->lblCompartmentColour->setText("");
// update membrane length
double area{model.getMembranes().getSize(membraneId)};
ui->lblCompSize->setText(QString("Area: %1 %2^2 (%3 pixels)")
.arg(QString::number(area, 'g', 13))
.arg(model.getUnits().getLength().name)
.arg(nPixels));
ui->lblCompMesh->setImages(model.getGeometry().getMesh()->getMeshImages(
ui->lblCompMesh->size(),
static_cast<std::size_t>(currentRow + ui->listCompartments->count())));
}
| 41.008316 | 80 | 0.690545 | [
"mesh",
"geometry",
"model"
] |
9fea3730726e74407ee218f560d1b3d0a7353850 | 1,313 | cpp | C++ | Leetcode/Day034/search_in_rotated_sorted.cpp | SujalAhrodia/Practice_2020 | 59b371ada245ed8253d12327f18deee3e47f31d6 | [
"MIT"
] | null | null | null | Leetcode/Day034/search_in_rotated_sorted.cpp | SujalAhrodia/Practice_2020 | 59b371ada245ed8253d12327f18deee3e47f31d6 | [
"MIT"
] | null | null | null | Leetcode/Day034/search_in_rotated_sorted.cpp | SujalAhrodia/Practice_2020 | 59b371ada245ed8253d12327f18deee3e47f31d6 | [
"MIT"
] | null | null | null | // first solution
class Solution {
public:
int search(vector<int>& nums, int target)
{
auto itr = find(nums.begin(), nums.end(), target);
if(itr!=nums.end())
{
return itr-nums.begin();
}
else
return -1;
}
};
// second solution (using modified binary search) : similar time complexity
class Solution {
public:
int search(vector<int>& nums, int target)
{
int n=nums.size();
if(!n)
return -1;
int start=0, end=n-1;
while(start<=end)
{
int mid = start + (end-start)/2;
if(nums[mid] == target)
return mid;
else if(nums[mid] < nums[start])
{
if(target>nums[mid] && target<=nums[end])
//right
start=mid+1;
else
//left
end=mid-1;
}
else
{
if(target<nums[mid] && target>=nums[start])
//left
end=mid-1;
else
//right
start=mid+1;
}
}
return -1;
}
};
| 21.883333 | 75 | 0.37243 | [
"vector"
] |
9feae37cae77d58074ddfc5f780797eb4dcc982b | 1,599 | hpp | C++ | include/clrs/k_way_merge.hpp | thejohnfreeman/clrs | 8ded5fb499e616b8766e944dd120c142b2101b19 | [
"MIT"
] | 2 | 2015-04-22T06:34:42.000Z | 2019-01-16T15:35:37.000Z | include/clrs/k_way_merge.hpp | thejohnfreeman/clrs | 8ded5fb499e616b8766e944dd120c142b2101b19 | [
"MIT"
] | null | null | null | include/clrs/k_way_merge.hpp | thejohnfreeman/clrs | 8ded5fb499e616b8766e944dd120c142b2101b19 | [
"MIT"
] | null | null | null | #ifndef CLRS_K_WAY_MERGE
#define CLRS_K_WAY_MERGE
#include <functional>
#include <utility>
#include "priority_queue.hpp"
namespace clrs {
/* Solution to exercise 6.5-8. */
template <
typename ForwardItIt,
typename OutputIt,
typename Compare
= std::less<typename std::iterator_traits<
typename std::iterator_traits<ForwardItIt>>::value_type>>
void k_way_merge(ForwardItIt begins, ForwardItIt ends, const size_t k,
OutputIt out, Compare comp = Compare())
{
typedef typename std::iterator_traits<ForwardItIt>::value_type ForwardIt;
/* head_t is a pair of iterators:
* - the first points to the current item in the list
* - the second points to the end of the list
*/
typedef std::tuple<ForwardIt, ForwardIt> head_t;
auto headcomp = [&] (const head_t& lhs, const head_t& rhs) {
return comp(*std::get<0>(rhs), *std::get<0>(lhs));
};
/* TODO: make_priority_queue */
priority_queue<head_t, std::vector<head_t>, decltype(headcomp)> pq(headcomp);
for (size_t i = 0; i < k; ++i) {
// Not sure why this would happen, but allow it.
if (begins[i] == ends[i]) continue;
pq.emplace(std::move(begins[i]), std::move(ends[i]));
}
//std::printf("merging %lu lists\n", k);
ForwardIt head, end;
while (!pq.empty()) {
std::tie(head, end) = pq.top();
pq.pop();
*out++ = *head++;
//auto i = std::find(ends, ends + k, end) - ends;
//std::printf("popped list %lu\n", i);
if (head != end) {
pq.emplace(head, end);
}
}
}
}
#endif
| 25.790323 | 81 | 0.612883 | [
"vector"
] |
9ff5a8d1f3e35867e958b579676298c3ddf260e0 | 5,388 | hpp | C++ | domain/include/cstone/util/util.hpp | lks1248/SPH-EXA | af6d2307f022a1892606008e290ab9cba6f683f7 | [
"MIT"
] | 16 | 2022-01-17T19:50:38.000Z | 2022-03-28T08:09:58.000Z | domain/include/cstone/util/util.hpp | sguera/SPH-EXA_mini-app | 0cac399d43118bda1ed2a5e42b593eb18ca55c30 | [
"MIT"
] | 33 | 2021-12-06T12:42:41.000Z | 2022-03-31T10:56:49.000Z | domain/include/cstone/util/util.hpp | sguera/SPH-EXA_mini-app | 0cac399d43118bda1ed2a5e42b593eb18ca55c30 | [
"MIT"
] | 13 | 2021-12-06T09:12:52.000Z | 2022-03-28T08:07:38.000Z | /*
* MIT License
*
* Copyright (c) 2021 CSCS, ETH Zurich
* 2021 University of Basel
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*! @file
* @brief General purpose utilities
*
* @author Sebastian Keller <sebastian.f.keller@gmail.com>
*/
#pragma once
#include <utility>
#include "cstone/cuda/annotation.hpp"
#include "array.hpp"
/*! @brief A template to create structs as a type-safe version to using declarations
*
* Used in public API functions where a distinction between different
* arguments of the same underlying type is desired. This provides a type-safe
* version to using declarations. Instead of naming a type alias, the name
* is used to define a struct that inherits from StrongType<T>, where T is
* the underlying type.
*
* Due to the T() conversion and assignment from T,
* an instance of StrongType<T> struct behaves essentially like an actual T, while construction
* from T is disabled. This makes it impossible to pass a T as a function parameter
* of type StrongType<T>.
*/
template<class T, class Phantom>
struct StrongType
{
using ValueType [[maybe_unused]] = T;
//! default ctor
constexpr HOST_DEVICE_FUN StrongType() : value_{} {}
//! construction from the underlying type T, implicit conversions disabled
explicit constexpr HOST_DEVICE_FUN StrongType(T v) : value_(std::move(v)) {}
//! assignment from T
constexpr HOST_DEVICE_FUN StrongType& operator=(T v)
{
value_ = std::move(v);
return *this;
}
//! conversion to T
constexpr HOST_DEVICE_FUN operator T() const { return value_; } // NOLINT
//! access the underlying value
constexpr HOST_DEVICE_FUN T value() const { return value_; }
private:
T value_;
};
/*! @brief StrongType equality comparison
*
* Requires that both T and Phantom template parameters match.
* For the case where a comparison between StrongTypes with matching T, but differing Phantom
* parameters is desired, the underlying value attribute should be compared instead
*/
template<class T, class Phantom>
constexpr HOST_DEVICE_FUN
bool operator==(const StrongType<T, Phantom>& lhs, const StrongType<T, Phantom>& rhs)
{
return lhs.value() == rhs.value();
}
//! @brief comparison function <
template<class T, class Phantom>
constexpr HOST_DEVICE_FUN
bool operator<(const StrongType<T, Phantom>& lhs, const StrongType<T, Phantom>& rhs)
{
return lhs.value() < rhs.value();
}
//! @brief comparison function >
template<class T, class Phantom>
constexpr HOST_DEVICE_FUN
bool operator>(const StrongType<T, Phantom>& lhs, const StrongType<T, Phantom>& rhs)
{
return lhs.value() > rhs.value();
}
//! @brief addition
template<class T, class Phantom>
constexpr HOST_DEVICE_FUN
StrongType<T, Phantom> operator+(const StrongType<T, Phantom>& lhs, const StrongType<T, Phantom>& rhs)
{
return StrongType<T, Phantom>(lhs.value() + rhs.value());
}
//! @brief subtraction
template<class T, class Phantom>
constexpr HOST_DEVICE_FUN
StrongType<T, Phantom> operator-(const StrongType<T, Phantom>& lhs, const StrongType<T, Phantom>& rhs)
{
return StrongType<T, Phantom>(lhs.value() - rhs.value());
}
//! @brief Utility to call function with each element in tuple_
template<class F, class... Ts>
void for_each_tuple(F&& func, std::tuple<Ts...>& tuple_)
{
std::apply([f = func](auto&... args) { [[maybe_unused]] auto list = std::initializer_list<int>{(f(args), 0)...}; },
tuple_);
}
//! @brief Utility to call function with each element in tuple_ with const guarantee
template<class F, class... Ts>
void for_each_tuple(F&& func, const std::tuple<Ts...>& tuple_)
{
std::apply([f = func](auto&... args) { [[maybe_unused]] auto list = std::initializer_list<int>{(f(args), 0)...}; },
tuple_);
}
//! @brief resizes a vector with a determined growth rate upon reallocation
template<class Vector>
void reallocate(Vector& vector, size_t size, double growthRate)
{
size_t current_capacity = vector.capacity();
if (size > current_capacity)
{
size_t reserve_size = double(size) * growthRate;
vector.reserve(reserve_size);
}
vector.resize(size);
}
//! @brief ceil(divident/divisor) for integers
HOST_DEVICE_FUN constexpr unsigned iceil(size_t dividend, unsigned divisor)
{
return (dividend + divisor - 1) / divisor;
}
| 33.886792 | 119 | 0.715108 | [
"vector"
] |
9ff675a2c2d24929bff5e89be7f94177dd615e8d | 737 | cpp | C++ | src/raytracer/raytracer.cpp | al13n321/fract | 8551530336d00044bda6871e04d243cfa1cb5314 | [
"MIT"
] | null | null | null | src/raytracer/raytracer.cpp | al13n321/fract | 8551530336d00044bda6871e04d243cfa1cb5314 | [
"MIT"
] | null | null | null | src/raytracer/raytracer.cpp | al13n321/fract | 8551530336d00044bda6871e04d243cfa1cb5314 | [
"MIT"
] | null | null | null | #include "raytracer.h"
#include <cassert>
namespace fract {
Raytracer::Raytracer(Config::View *config)
: config_(config)
, shader_provider_(config_, "Predefined/pass.vert", {"raytracer"},
{{"Camera-shader", "Predefined/PerspectiveCamera.frag"}}) {}
void Raytracer::TraceGrid(const RayGrid &grid, RaytracedView &target) {
assert(grid.resolution == target.size);
std::shared_ptr<GL::Shader> shader = shader_provider_.Get();
target.framebuffer.BindForWriting();
if (!shader) {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); CHECK_GL_ERROR();
glClear(GL_COLOR_BUFFER_BIT); CHECK_GL_ERROR();
return;
}
shader->Use();
grid.AssignToUniforms(*shader);
quad_renderer_.Render();
GL::Framebuffer::Unbind();
}
}
| 23.774194 | 71 | 0.698779 | [
"render"
] |
9ffb1cc05519b72efea524bd1bbce107b3cf8717 | 628 | cpp | C++ | 4th-semester/aisd/lab/lista-3/ex-2/random-generator.cpp | jerry-sky/academic-notebook | be2d350289441b99168ea40412891bc65b9cb431 | [
"Unlicense"
] | 4 | 2020-12-28T21:53:00.000Z | 2022-03-22T19:24:47.000Z | 4th-semester/aisd/lab/lista-3/ex-2/random-generator.cpp | jerry-sky/academic-notebook | be2d350289441b99168ea40412891bc65b9cb431 | [
"Unlicense"
] | 3 | 2022-02-13T18:07:10.000Z | 2022-02-13T18:16:07.000Z | 4th-semester/aisd/lab/lista-3/ex-2/random-generator.cpp | jerry-sky/academic-notebook | be2d350289441b99168ea40412891bc65b9cb431 | [
"Unlicense"
] | 4 | 2020-12-28T16:05:35.000Z | 2022-03-08T16:20:00.000Z | #include "random-generator.h"
std::vector<int> RandomGenerator(int size, bool unique)
{
std::vector<int> output(size);
srand(time(NULL));
if (unique)
{
std::vector<int> possibleNumbers(size);
for (int i = 1; i <= size; i++)
possibleNumbers.at(i - 1) = i;
int i = 0;
while (possibleNumbers.size() > 0)
{
int t = rand() % possibleNumbers.size();
output[i] = possibleNumbers.at(t);
possibleNumbers.erase(possibleNumbers.begin() + t);
i++;
}
}
else
{
for (int i = 0; i < size; i++)
{
output[i] = rand() % size + 1;
}
}
return output;
};
| 18.470588 | 57 | 0.549363 | [
"vector"
] |
b0092bff2f5d49942adb9eef62d211e11e2dbce6 | 1,001 | cc | C++ | lanqiao/basic/51.cc | xsthunder/a | 3c30f31c59030d70462b71ef28c5eee19c6eddd6 | [
"MIT"
] | 1 | 2018-07-22T04:52:10.000Z | 2018-07-22T04:52:10.000Z | lanqiao/basic/51.cc | xsthunder/a | 3c30f31c59030d70462b71ef28c5eee19c6eddd6 | [
"MIT"
] | 1 | 2018-08-11T13:29:59.000Z | 2018-08-11T13:31:28.000Z | lanqiao/basic/51.cc | xsthunder/a | 3c30f31c59030d70462b71ef28c5eee19c6eddd6 | [
"MIT"
] | null | null | null | const bool test=1;
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
const int inf=0x7fffffff;
#define IF if(test)
#define FI if(!test)
#define gts(s) fgets((s),sizeof(s),stdin)
typedef long long int ll;
using namespace std;
typedef pair<int,int> point;
template <typename T>
void pA(T *begin,int n){ for(int i=0;i<n;i++){ printf("%d " ,*(begin+i)); } printf("\n"); }
void sol(){
string s , s2;
char s3[100];
int n;
scanf("%d", &n);
while(n--){
cin>>s;
while(s.length()%3!=0){
s="0"+s;
}
for(unsigned int i = 0 ; i< s.length();i+=3){
int x;
sscanf(s.substr(i,3 ).c_str(), "%x", &x);
sprintf(s3, "%o",x);
s2=s3;
if(i!=0)while(s2.size()!=4)s2="0"+s2;
cout<<s2;
}
printf("\n");
}
}
int main()
{
sol();
return 0;
}
//51.cc
//generated automatically at Tue Jan 17 10:19:25 2017
//by xsthunder
| 18.537037 | 91 | 0.62038 | [
"vector"
] |
b00d0ffb10d634a6d7712d4e37b1d0cf8c46f22d | 17,958 | cpp | C++ | src/TwoChQS/TwoChQS_UpdateMatrices.cpp | lgds/NRG_USP | ff66846e92498aa429cce6fc5793bec23ad03eb4 | [
"MIT"
] | 3 | 2015-09-21T20:58:45.000Z | 2019-03-20T01:21:41.000Z | src/TwoChQS/TwoChQS_UpdateMatrices.cpp | lgds/NRG_USP | ff66846e92498aa429cce6fc5793bec23ad03eb4 | [
"MIT"
] | null | null | null | src/TwoChQS/TwoChQS_UpdateMatrices.cpp | lgds/NRG_USP | ff66846e92498aa429cce6fc5793bec23ad03eb4 | [
"MIT"
] | null | null | null | #include <iostream>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/timer.hpp>
#include <vector>
#include <math.h>
#include "NRGclasses.hpp"
#include "NRGfunctions.hpp"
#include "TwoChQS.hpp"
void TwoChQS_UpdateQm1fQ(CNRGbasisarray* pSingleSite,CNRGarray* pAeig,
CNRGbasisarray* pAbasis,CNRGmatrix* Qm1fNQ){
// Boost matrices
boost::numeric::ublas::matrix<double> Zibl;
boost::numeric::ublas::matrix<double> Zjbl;
boost::numeric::ublas::matrix<double> fnbasis;
boost::numeric::ublas::matrix<double> fnw;
// Check time
boost::timer t;
double time_elapsed;
//Clear all
for (int ich=1;ich<=2;ich++)
{
Qm1fNQ[ich-1].ClearAll();
Qm1fNQ[ich-1].SyncNRGarray(*pAeig);
}
// Note: assumes Abasis and Aeig have
// EXACTLY the same block structure... should check.
double Qi;
double Qj;
double Si,Sj;
// Loop over blocks (icount counts for each matrix)
int icount[2]={0,0};
for (int ibl=0;ibl<pAeig->NumBlocks();ibl++)
{
Qi=pAeig->GetQNumber(ibl,0);
Si=pAeig->GetQNumber(ibl,1);
int Nstibl=pAeig->GetBlockSize(ibl);
for (int jbl=ibl+1;jbl<pAeig->NumBlocks();jbl++)
{
Qj=pAeig->GetQNumber(jbl,0);
Sj=pAeig->GetQNumber(jbl,1);
int Nstjbl=pAeig->GetBlockSize(jbl);
//Loop over channels: check if the matrix elements are non-zero
for (int ich=1;ich<=2;ich++)
{
if ( dEqual(Qi+1.0,Qj)&&
( dEqual(Si+0.5,Sj)||dEqual(Si-0.5,Sj) ) )
{
// Set Zi,Zj
cout << " BC: Nshell = " << pAeig->Nshell << endl;
cout << "Matrix in channel: " << ich << endl;
cout << " Setting up Block i : " << ibl
<< " (size " << Nstibl
<< ") x Block j " << jbl
<< " (size " << Nstjbl << ") of " << pAeig->NumBlocks() << endl;
Qm1fNQ[ich-1].MatBlockMap.push_back(ibl);
Qm1fNQ[ich-1].MatBlockMap.push_back(jbl);
Qm1fNQ[ich-1].MatBlockBegEnd.push_back(icount[ich-1]);
icount[ich-1]+=Nstibl*Nstjbl;
Qm1fNQ[ich-1].MatBlockBegEnd.push_back(icount[ich-1]-1);
cout << " Setting up BLAS matrices..." << endl;
//boost::numeric::ublas::matrix<double> Zibl(Nstibl,Nstibl);
//boost::numeric::ublas::matrix<double> Zjbl(Nstjbl,Nstjbl);
Zibl.resize(Nstibl,Nstibl);
Zjbl.resize(Nstjbl,Nstjbl);
Zibl=pAeig->EigVec2BLAS(ibl);
Zjbl=pAeig->EigVec2BLAS(jbl);
cout << " ...Zs done ..." << endl;
//boost::numeric::ublas::matrix<double> fnbasis (Nstibl,Nstjbl);
fnbasis.resize(Nstibl,Nstjbl);
// Set-up fn basis: Loop in the basis states
int istbl=0;
for (int ist=pAbasis->GetBlockLimit(ibl,0);
ist<=pAbasis->GetBlockLimit(ibl,1);ist++)
{
int typei=pAbasis->iType[ist];
int stcfi=pAbasis->StCameFrom[ist];
int jstbl=0;
for (int jst=pAbasis->GetBlockLimit(jbl,0);
jst<=pAbasis->GetBlockLimit(jbl,1);jst++)
{
int typej=pAbasis->iType[jst];
int stcfj=pAbasis->StCameFrom[jst];
fnbasis(istbl,jstbl)=0.0;
if (stcfi==stcfj)
{
// New approach
// Get SingleSite QNumbers
int pos=0;
int iblssi=pSingleSite->GetBlockFromSt(typei,pos);
int iblssj=pSingleSite->GetBlockFromSt(typej,pos);
double Qtildei=pSingleSite->GetQNumber(iblssi,0);
double Stildei=pSingleSite->GetQNumber(iblssi,1);
double Sztildei=pSingleSite->GetQNumber(iblssi,2);
double Qtildej=pSingleSite->GetQNumber(iblssj,0);
double Stildej=pSingleSite->GetQNumber(iblssj,1);
double Sztildej=pSingleSite->GetQNumber(iblssj,2);
double siteqnumsi[]={Qtildei,Stildei,Sztildei};
double siteqnumsj[]={Qtildej,Stildej,Sztildej};
double Scfi=Si-Sztildei;
double Scfj=Sj-Sztildej; // should be the same!!
double auxBasis[2]={0.0,0.0};
double auxCG[2]={0.0,0.0};
double CGnorm=1.0;
int sigma=0;
// Choose which sigma
auxCG[0]=CGordan(Si,Si,0.5,-0.5,Sj,Sj);
auxCG[1]=CGordan(Si,Si,0.5,0.5,Sj,Sj);
if ( dNEqual(auxCG[0],0.0) )
{sigma=-1;CGnorm=auxCG[0];}
else
{
if ( dNEqual(auxCG[1],0.0) )
{sigma=1;CGnorm=auxCG[1];}
else fnbasis(istbl,jstbl)=0.0;
}
// cout << " UpMat: "
// << " ist = " << ist
// << " jst = " << jst
// << " CG0 = " << auxCG[0]
// << " CG1 = " << auxCG[1]
// << " sigma = " << sigma
// << endl;
double dSigma=0.5*sigma;
// Now Sj=Si+dSigma necessarily
// Calculate
if (sigma!=0)
{
for (double Szcfj=Scfj;
Szcfj>=-Scfj;Szcfj-=1.0)
{
Sztildei=Si-Szcfj; //Szcfi=Szcfj
Sztildej=Sj-Szcfj;
siteqnumsi[2]=Sztildei;
int blockstatei=pSingleSite->GetBlockFromQNumbers(siteqnumsi);
siteqnumsj[2]=Sztildej;
int blockstatej=pSingleSite->GetBlockFromQNumbers(siteqnumsj);
auxCG[0]=CGordan(Scfi,Szcfj,
Stildei,Sztildei,
Si,Si);
auxCG[1]=CGordan(Scfj,Szcfj,
Stildej,Sztildej,
Sj,Sj);
for (
int sitestatei=pSingleSite->GetBlockLimit(blockstatei,0);
sitestatei<=pSingleSite->GetBlockLimit(blockstatei,1);
sitestatei++)
{
for (
int sitestatej=pSingleSite->GetBlockLimit(blockstatej,0);
sitestatej<=pSingleSite->GetBlockLimit(blockstatej,1);
sitestatej++)
{
auxBasis[0]+=TwoChQS_fd_table(ich,sigma,sitestatej,sitestatei)*auxCG[0]*auxCG[1]*TwoChQS_SpSm_table(sitestatei,typei)*TwoChQS_SpSm_table(sitestatej,typej);
// cout << " Szcfj = " << Szcfj
// << " Stildei = " << Stildei
// << " Sztildei = " << Sztildei
// << " Stildej = " << Stildej
// << " Sztildej = " << Sztildej
// << " typei = " << typei
// << " sitestatei = " << sitestatei
// << " typej = " << typej
// << " sitestatej = " << sitestatej
// << " CG0 = " << auxCG[0]
// << " CG1 = " << auxCG[1]
// << endl;
}
// loop in blockstatej
}
// loop in blockstatei
}
// end Loop in Szcf
//Calculate fbasis
fnbasis(istbl,jstbl)=auxBasis[0]/CGnorm;
// cout << " auxBasis = " << auxBasis[0]
// << " CGnorm = " << CGnorm
// << endl;
}
// end if (sigma!=0)
}
// end istcf=jstcf
jstbl++;
}
// end jst loop
istbl++;
}
// end ist loop
cout << " ...fnbasis done." << endl;
cout << " Multiplying BLAS matrices... " << endl;
fnw.resize(Nstibl,Nstjbl);
t.restart();
noalias(fnw)=prod (Zibl,
boost::numeric::ublas::matrix<double>(prod(fnbasis,trans(Zjbl))) );
time_elapsed=t.elapsed();
cout << " ...done. Elapsed time:" << time_elapsed << endl;
// cout << "Z(i="<<ibl<<") : " << Zibl << endl;
// cout << "Z(j="<<jbl<<") : " << Zjbl << endl;
// cout << "fbasis :" << fnbasis << endl;
// cout << "Zi.fbasis.ZjT : " << fnw << endl;
// Add to Qm1fNQ[ich-1]
for (int ii=0;ii<fnw.size1();ii++)
for (int jj=0;jj<fnw.size2();jj++)
Qm1fNQ[ich-1].MatEl.push_back(fnw(ii,jj));
}
//end if Q=Q'+1 etc
}
// end channel loop
}
// end jbl loop
}
// end ibl loop
}
// END subroutine
//////////////////////////////////
//////////////////////////////////
//////////////////////////////////
//////////////////////////////////
void TwoChQS_UpdateMatrixAfterCutting(CNRGbasisarray* pSingleSite,
CNRGbasisarray* pAeigCut,
CNRGbasisarray* pAbasis,
CNRGmatrix* Qm1fNQ,
CNRGmatrix* pMQQp1){
// Boost matrices
boost::numeric::ublas::matrix<double> Zibl;
boost::numeric::ublas::matrix<double> Zjbl;
boost::numeric::ublas::matrix<double> fnbasis;
boost::numeric::ublas::matrix<double> fnw;
// Check time
boost::timer t;
double time_elapsed;
//Clear all
for (int ich=1;ich<=2;ich++)
{
Qm1fNQ[ich-1].ClearAll();
Qm1fNQ[ich-1].SyncNRGarray(*pAeigCut);
}
// Note: assumes Abasis and Aeig have
// EXACTLY the same block structure... should check.
double Qi;
double Qj;
double Si,Sj;
double qnums[2];
// Loop over blocks (icount counts for each matrix)
int icount[2]={0,0};
for (int ibl=0;ibl<pAeigCut->NumBlocks();ibl++)
{
Qi=pAeigCut->GetQNumber(ibl,0);
Si=pAeigCut->GetQNumber(ibl,1);
int Nstibl=pAeigCut->GetBlockSize(ibl);
// Get the corresponding block in pAbasis!
qnums[0]=Qi;
qnums[1]=Si;
int ii_corr=pAbasis->GetBlockFromQNumbers(qnums);
int NstiblBC=pAbasis->GetBlockSize(ii_corr);
for (int jbl=ibl+1;jbl<pAeigCut->NumBlocks();jbl++)
{
Qj=pAeigCut->GetQNumber(jbl,0);
Sj=pAeigCut->GetQNumber(jbl,1);
int Nstjbl=pAeigCut->GetBlockSize(jbl);
// Get the corresponding block in pAbasis!
qnums[0]=Qj;
qnums[1]=Sj;
int jj_corr=pAbasis->GetBlockFromQNumbers(qnums);
int NstjblBC=pAbasis->GetBlockSize(jj_corr);
if ( (!dEqual(Qj,pAbasis->GetQNumber(jj_corr,0)))||
(!dEqual(Sj,pAbasis->GetQNumber(jj_corr,1))) )
{
cout << "Ops, problems with GetBlockFromQNumbers" << endl;
pAbasis->PrintQNumbers();
cout << qnums[0] << " " << qnums[1] << endl;
cout << pAbasis->GetBlockFromQNumbers(qnums) << endl;
}
//Loop over channels: check if the matrix elements are non-zero
if ( dEqual(Qi+1.0,Qj)&&
( dEqual(Si+0.5,Sj)||dEqual(Si-0.5,Sj) ) )
{
for (int ich=1;ich<=2;ich++)
{
// Set Zi,Zj
cout << " AC : Nshell = " << pAeigCut->Nshell << endl;
cout << "Matrix in channel: " << ich << endl;
cout << " Setting up Block i : " << ibl
<< " (size " << Nstibl << " was " << NstiblBC
<< ") x Block j " << jbl
<< " (size " << Nstjbl << " was " << NstjblBC
<< ") of " << pAeigCut->NumBlocks() << endl;
Qm1fNQ[ich-1].MatBlockMap.push_back(ibl);
Qm1fNQ[ich-1].MatBlockMap.push_back(jbl);
Qm1fNQ[ich-1].MatBlockBegEnd.push_back(icount[ich-1]);
icount[ich-1]+=Nstibl*Nstjbl;
Qm1fNQ[ich-1].MatBlockBegEnd.push_back(icount[ich-1]-1);
cout << " Setting up BLAS matrices..." << endl;
//boost::numeric::ublas::matrix<double> Zibl(Nstibl,Nstibl);
//boost::numeric::ublas::matrix<double> Zjbl(Nstjbl,Nstjbl);
Zibl.resize(Nstibl,NstiblBC);
Zjbl.resize(Nstjbl,NstjblBC);
//Zibl=pAeigCut->EigVec2BLAS(ibl);
//Zjbl=pAeigCut->EigVec2BLAS(jbl);
Zibl=pAeigCut->EigVecCut2BLAS(ibl);
Zjbl=pAeigCut->EigVecCut2BLAS(jbl);
cout << " ...Zs done ..." << endl;
fnbasis.resize(NstiblBC,NstjblBC);
// Set-up fn basis: Loop in the basis states
// Watch out here... ii_corr, not ibl
int istbl=0;
for (int ist=pAbasis->GetBlockLimit(ii_corr,0);
ist<=pAbasis->GetBlockLimit(ii_corr,1);ist++)
{
int typei=pAbasis->iType[ist];
int stcfi=pAbasis->StCameFrom[ist];
int jstbl=0;
for (int jst=pAbasis->GetBlockLimit(jj_corr,0);
jst<=pAbasis->GetBlockLimit(jj_corr,1);jst++)
{
int typej=pAbasis->iType[jst];
int stcfj=pAbasis->StCameFrom[jst];
fnbasis(istbl,jstbl)=0.0;
if (stcfi==stcfj)
{
// New approach
// Get SingleSite QNumbers
int pos=0;
int iblssi=pSingleSite->GetBlockFromSt(typei,pos);
int iblssj=pSingleSite->GetBlockFromSt(typej,pos);
double Qtildei=pSingleSite->GetQNumber(iblssi,0);
double Stildei=pSingleSite->GetQNumber(iblssi,1);
double Sztildei=pSingleSite->GetQNumber(iblssi,2);
double Qtildej=pSingleSite->GetQNumber(iblssj,0);
double Stildej=pSingleSite->GetQNumber(iblssj,1);
double Sztildej=pSingleSite->GetQNumber(iblssj,2);
double siteqnumsi[]={Qtildei,Stildei,Sztildei};
double siteqnumsj[]={Qtildej,Stildej,Sztildej};
double Scfi=Si-Sztildei;
double Scfj=Sj-Sztildej;
double auxBasis[2]={0.0,0.0};
double auxCG[2]={0.0,0.0};
double CGnorm=1.0;
int sigma=0;
// Choose which sigma
auxCG[0]=CGordan(Si,Si,0.5,-0.5,Sj,Sj);
auxCG[1]=CGordan(Si,Si,0.5,0.5,Sj,Sj);
if ( dNEqual(auxCG[0],0.0) )
{sigma=-1;CGnorm=auxCG[0];}
else
{
if ( dNEqual(auxCG[1],0.0) )
{sigma=1;CGnorm=auxCG[1];}
else fnbasis(istbl,jstbl)=0.0;
}
double dSigma=0.5*sigma;
// Now Sj=Si+dSigma necessarily
// Calculate
if (sigma!=0)
{
for (double Szcfj=Scfj;
Szcfj>=-Scfj;Szcfj-=1.0)
{
Sztildei=Si-Szcfj; //Szcfi=Szcfj
Sztildej=Sj-Szcfj;
siteqnumsi[2]=Sztildei;
int blockstatei=pSingleSite->GetBlockFromQNumbers(siteqnumsi);
siteqnumsj[2]=Sztildej;
int blockstatej=pSingleSite->GetBlockFromQNumbers(siteqnumsj);
auxCG[0]=CGordan(Scfi,Szcfj,
Stildei,Sztildei,
Si,Si);
auxCG[1]=CGordan(Scfj,Szcfj,
Stildej,Sztildej,
Sj,Sj);
for (
int sitestatei=pSingleSite->GetBlockLimit(blockstatei,0);
sitestatei<=pSingleSite->GetBlockLimit(blockstatei,1);
sitestatei++)
{
for (
int sitestatej=pSingleSite->GetBlockLimit(blockstatej,0);
sitestatej<=pSingleSite->GetBlockLimit(blockstatej,1);
sitestatej++)
{
auxBasis[0]+=TwoChQS_fd_table(ich,sigma,sitestatej,sitestatei)*auxCG[0]*auxCG[1]*TwoChQS_SpSm_table(sitestatei,typei)*TwoChQS_SpSm_table(sitestatej,typej);
}
// loop in blockstatej
}
// loop in blockstatei
}
// end Loop in Szcf
//Calculate fbasis
fnbasis(istbl,jstbl)=auxBasis[0]/CGnorm;
}
// end if (sigma!=0)
}
// end if icf=jcf
jstbl++;
}
// end jst loop
istbl++;
}
// end ist loop
cout << " ...fnbasis done." << endl;
cout << " Multiplying BLAS matrices... " << endl;
fnw.resize(Nstibl,Nstjbl);
t.restart();
noalias(fnw)=prod (Zibl,
boost::numeric::ublas::matrix<double>(prod(fnbasis,trans(Zjbl))) );
time_elapsed=t.elapsed();
cout << " ...done. Elapsed time:" << time_elapsed << endl;
// cout << "Z(i="<<ibl<<") : " << Zibl << endl;
// cout << "Z(j="<<jbl<<") : " << Zjbl << endl;
// cout << "fbasis :" << fnbasis << endl;
// cout << "Zi.fbasis.ZjT : " << fnw << endl;
// Add to Qm1fNQ[ich-1]
for (int ii=0;ii<fnw.size1();ii++)
for (int jj=0;jj<fnw.size2();jj++)
Qm1fNQ[ich-1].MatEl.push_back(fnw(ii,jj));
}
// end channel loop
}
//end if Q=Q'+1 etc
}
// end jbl loop
}
// end ibl loop
}
//////////////////////////////////
//////////////////////////////////
//////////////////////////////////
//////////////////////////////////
// for (Sztildej=-Stildej;
// Sztildej<=Stildej;Sztildej+=1.0)
// {
// siteqnumsj[2]=Sztildej;
// int sitestatej=pSingleSite->GetBlockFromQNumbers(siteqnumsj);
// int i1=0;
// for (double dSigma=-0.5;dSigma<=0.5;
// dSigma+=1.0)
// {
// siteqnumsi[2]=Sztildej-dSigma;
// int sitestatei=pSingleSite->GetBlockFromQNumbers(siteqnumsi);
// auxCG[0]=CGordan(Scfi,Si-Sztildej+dSigma,
// Stildei,Sztildej-dSigma,
// Si,Si);
// auxCG[1]=CGordan(Scfj,Sj-Sztildej,
// Stildej,Sztildej,
// Sj,Sj);
// auxBasis[i1]+=TwoChQS_fd_table(ich,(int)(dSigma/0.5),sitestatej,sitestatei)*auxCG[0]*auxCG[1];
// i1++;
// }
// // END loop in dSigma
// }
// //END loop in Sztildej
// Check to see which of them is non-zero
// auxCG[0]=CGordan(Si,Si,0.5,-0.5,Sj,Sj);
// auxCG[1]=CGordan(Si,Si,0.5,0.5,Sj,Sj);
// if ( !(dEqual(auxCG[0],0.0)) )
// fnbasis(istbl,jstbl)=auxBasis[0]/auxCG[0];
// else
// {
// if ( !(dEqual(auxCG[1],0.0)) )
// fnbasis(istbl,jstbl)=auxBasis[1]/auxCG[1];
// else fnbasis(istbl,jstbl)=0.0;
// }
// Loop in Sztildej,sigma:
//Sztildei=Sztildej-sigma
// for (Sztildej=-Stildej;
// Sztildej<=Stildej;Sztildej+=1.0)
// {
// siteqnumsj[2]=Sztildej;
// int sitestatej=pSingleSite->GetBlockFromQNumbers(siteqnumsj);
// int i1=0;
// for (double dSigma=-0.5;dSigma<=0.5;
// dSigma+=1.0)
// {
// siteqnumsi[2]=Sztildej-dSigma;
// int sitestatei=pSingleSite->GetBlockFromQNumbers(siteqnumsi);
// auxCG[0]=CGordan(Scfi,Si-Sztildej+dSigma,
// Stildei,Sztildej-dSigma,
// Si,Si);
// auxCG[1]=CGordan(Scfj,Sj-Sztildej,
// Stildej,Sztildej,
// Sj,Sj);
// auxBasis[i1]+=TwoChQS_fd_table(ich,(int)(dSigma/0.5),sitestatej,sitestatei)*auxCG[0]*auxCG[1];
// i1++;
// }
// // END loop in dSigma
// }
// //END loop in Sztildej
// // Check to see which of them is non-zero
// auxCG[0]=CGordan(Si,Si,0.5,-0.5,Sj,Sj);
// auxCG[1]=CGordan(Si,Si,0.5,0.5,Sj,Sj);
// if ( !(dEqual(auxCG[0],0.0)) )
// fnbasis(istbl,jstbl)=auxBasis[0]/auxCG[0];
// else
// {
// if ( !(dEqual(auxCG[1],0.0)) )
// fnbasis(istbl,jstbl)=auxBasis[1]/auxCG[1];
// else fnbasis(istbl,jstbl)=0.0;
// }
// //fnbasis(istbl,jstbl)=TwoChQS_fd_table(ich,-1,typej,typei)+TwoChQS_fd_table(ich,1,typej,typei);
| 28.595541 | 166 | 0.551788 | [
"vector"
] |
b00e49a04311ca369ea19ba130b511bc799c474b | 2,691 | hpp | C++ | src/dataframe.hpp | heavywatal/rigraphlite | aa36ed630266b9bf77bf2609d96f507bba0b9c22 | [
"MIT"
] | 3 | 2020-04-15T21:42:52.000Z | 2021-12-22T09:06:25.000Z | src/dataframe.hpp | heavywatal/rigraphlite | aa36ed630266b9bf77bf2609d96f507bba0b9c22 | [
"MIT"
] | 4 | 2019-04-02T12:13:32.000Z | 2020-06-07T15:11:36.000Z | src/dataframe.hpp | heavywatal/rigraphlite | aa36ed630266b9bf77bf2609d96f507bba0b9c22 | [
"MIT"
] | null | null | null | #pragma once
#ifndef IGRAPHLITE_DATAFRAME_HPP_
#define IGRAPHLITE_DATAFRAME_HPP_
namespace impl {
inline Rcpp::CharacterVector tibble_class() {
return Rcpp::CharacterVector::create("tbl_df", "tbl", "data.frame");
}
inline void set_rownames(Rcpp::DataFrame& df, int n) {
df.attr("row.names") = Rcpp::IntegerVector{Rcpp::IntegerVector::get_na(), -n};
}
inline void mutate(Rcpp::DataFrame& df, const char* name, const Rcpp::RObject& value) {
Rcpp::List attr_holder;
Rf_copyMostAttrib(df, attr_holder);
df[name] = value;
Rf_copyMostAttrib(attr_holder, df);
}
template <class T> inline
T na() {return T{};}
template <> inline
int na<int>() {return R_NaInt;}
template <> inline
double na<double>() {return R_NaReal;}
template <> inline
SEXP na<SEXP>() {return R_NaString;}
template <int RTYPE, class T> inline
Rcpp::Vector<RTYPE> elongate(const Rcpp::Vector<RTYPE>& x, long n) {
long len = x.size();
Rcpp::Vector<RTYPE> res(len + n);
for (long i = 0; i < len; ++i) {
res[i] = x[i];
}
for (long i = len; i < res.size(); ++i) {
res[i] = na<T>();
}
return res;
}
inline Rcpp::LogicalVector negate(const Rcpp::IntegerVector& idx, long n) {
return !Rcpp::in(Rcpp::Range(0, n - 1), idx);
}
template <int RTYPE, class T> inline
Rcpp::Vector<RTYPE> subset(const Rcpp::Vector<RTYPE>& x, const T& idx) {
return x[idx];
}
inline void append_na_rows(Rcpp::DataFrame& df, long n) {
Rcpp::List attr_holder;
const Rcpp::StringVector names = df.attr("names");
for (const char* name: names) {
switch (TYPEOF(df[name])) {
case INTSXP: mutate(df, name, elongate<INTSXP, int>(df[name], n)); break;
case REALSXP: mutate(df, name, elongate<REALSXP, double>(df[name], n)); break;
case STRSXP: mutate(df, name, elongate<STRSXP, SEXP>(df[name], n)); break;
default: Rcpp::stop("Invalid type for attributes: %d", TYPEOF(df[name]));
}
}
impl::set_rownames(df, df.nrow() + n);
}
template <class T>
inline void filter(Rcpp::DataFrame& df, const T& idx) {
Rcpp::List attr_holder;
const Rcpp::StringVector names = df.attr("names");
for (const char* name: names) {
switch (TYPEOF(df[name])) {
case INTSXP: mutate(df, name, subset<INTSXP>(df[name], idx)); break;
case REALSXP: mutate(df, name, subset<REALSXP>(df[name], idx)); break;
case STRSXP: mutate(df, name, subset<STRSXP>(df[name], idx)); break;
default: Rcpp::stop("Invalid type for attributes: %d", TYPEOF(df[name]));
}
}
impl::set_rownames(df, Rcpp::sum(idx));
}
}
#endif // IGRAPHLITE_DATAFRAME_HPP_
| 32.035714 | 89 | 0.628391 | [
"vector"
] |
b0125379f9dbf5ee0d22a9e328b5fbbe6cf39200 | 1,188 | cpp | C++ | src/CommandLineUtils/CommandLineUtilsTest.cpp | tufeigunchu/orbit | 407354cf7c9159ff7e3177c603a6850b95509e3a | [
"BSD-2-Clause"
] | 1,847 | 2020-03-24T19:01:42.000Z | 2022-03-31T13:18:57.000Z | src/CommandLineUtils/CommandLineUtilsTest.cpp | tufeigunchu/orbit | 407354cf7c9159ff7e3177c603a6850b95509e3a | [
"BSD-2-Clause"
] | 1,100 | 2020-03-24T19:41:13.000Z | 2022-03-31T14:27:09.000Z | src/CommandLineUtils/CommandLineUtilsTest.cpp | tufeigunchu/orbit | 407354cf7c9159ff7e3177c603a6850b95509e3a | [
"BSD-2-Clause"
] | 228 | 2020-03-25T05:32:08.000Z | 2022-03-31T11:27:39.000Z | // Copyright (c) 2021 The Orbit Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <gtest/gtest.h>
#include <QStringList>
#include "CommandLineUtils/CommandLineUtils.h"
namespace orbit_command_line_utils {
TEST(CommandLineUtils, RemoveFlagsNotPassedToMainWindow) {
QStringList params{"--some_bool", "-b", "--connection_target=1234@target", "--some_flag"};
QStringList expected{"--some_bool", "-b", "--some_flag"};
QStringList result = RemoveFlagsNotPassedToMainWindow(params);
EXPECT_EQ(expected, result);
}
TEST(CommandLineUtils, ExtractCommandLineFlags) {
char* pos_arg1 = strdup("pos_arg");
char* pos_arg2 = strdup("another_pos_arg");
std::vector<std::string> command_line_args{"-b", "--test_arg", "--another_arg=something",
pos_arg1, pos_arg2};
std::vector<char*> positional_args{pos_arg1, pos_arg2};
auto result = ExtractCommandLineFlags(command_line_args, positional_args);
QStringList expected{"-b", "--test_arg", "--another_arg=something"};
EXPECT_EQ(expected, result);
}
} // namespace orbit_command_line_utils | 36 | 92 | 0.72138 | [
"vector"
] |
b01e6ab46925b3434b27ed0b9437eec48f6c9f36 | 1,493 | cpp | C++ | Server Lib/Game Server/PANGYA_DB/cmd_login_reward_info.cpp | CCasusensa/SuperSS-Dev | 6c6253b0a56bce5dad150c807a9bbf310e8ff61b | [
"MIT"
] | 23 | 2021-10-31T00:20:21.000Z | 2022-03-26T07:24:40.000Z | Server Lib/Game Server/PANGYA_DB/cmd_login_reward_info.cpp | CCasusensa/SuperSS-Dev | 6c6253b0a56bce5dad150c807a9bbf310e8ff61b | [
"MIT"
] | 5 | 2021-10-31T18:44:51.000Z | 2022-03-25T18:04:26.000Z | Server Lib/Game Server/PANGYA_DB/cmd_login_reward_info.cpp | CCasusensa/SuperSS-Dev | 6c6253b0a56bce5dad150c807a9bbf310e8ff61b | [
"MIT"
] | 18 | 2021-10-20T02:31:56.000Z | 2022-02-01T11:44:36.000Z | // Arquivo cmd_login_reward_info.cpp
// Criado em 27/10/2020 as 18:54 por Acrisio
// Implementa��o da classe CmdLoginRewardInfo
#if defined(_WIN32)
#pragma pack(1)
#endif
#include "cmd_login_reward_info.hpp"
using namespace stdA;
CmdLoginRewardInfo::CmdLoginRewardInfo(bool _waiter) : pangya_db(_waiter), m_lr() {
}
CmdLoginRewardInfo::~CmdLoginRewardInfo() {
if (!m_lr.empty()) {
m_lr.clear();
m_lr.shrink_to_fit();
}
}
void CmdLoginRewardInfo::lineResult(result_set::ctx_res* _result, uint32_t /*_index_result*/) {
checkColumnNumber(10, (uint32_t)_result->cols);
stLoginReward::stItemReward item(
(uint32_t)IFNULL(atoi, _result->data[5]),
(uint32_t)IFNULL(atoi, _result->data[6]),
(uint32_t)IFNULL(atoi, _result->data[7])
);
SYSTEMTIME end_date{ 0u };
if (_result->data[9] != nullptr)
_translateDate(_result->data[9], &end_date);
m_lr.push_back(stLoginReward(
(uint64_t)IFNULL(atoll, _result->data[0]),
stLoginReward::eTYPE((unsigned char)IFNULL(atoi, _result->data[2])),
_result->data[1],
(uint32_t)IFNULL(atoi, _result->data[3]),
(uint32_t)IFNULL(atoi, _result->data[4]),
item,
end_date,
(IFNULL(atoi, _result->data[8]) ? true : false)
));
}
response* CmdLoginRewardInfo::prepareConsulta(database& _db) {
if (!m_lr.empty())
m_lr.clear();
auto r = consulta(_db, m_szConsulta);
checkResponse(r, "nao conseguiu pegar o Login Reward Info");
return r;
}
std::vector< stLoginReward >& CmdLoginRewardInfo::getInfo() {
return m_lr;
}
| 22.969231 | 95 | 0.712659 | [
"vector"
] |
b01e7b0622e195f98248b922fa5bafc82b52fb22 | 8,347 | cc | C++ | vector_test.cc | nurettin/libnuwen | 5b3012d9e75552c372a4d09b218b7af04a928e68 | [
"BSL-1.0"
] | 9 | 2019-09-17T10:33:58.000Z | 2021-07-29T10:03:42.000Z | vector_test.cc | nurettin/libnuwen | 5b3012d9e75552c372a4d09b218b7af04a928e68 | [
"BSL-1.0"
] | null | null | null | vector_test.cc | nurettin/libnuwen | 5b3012d9e75552c372a4d09b218b7af04a928e68 | [
"BSL-1.0"
] | 1 | 2019-10-05T04:31:22.000Z | 2019-10-05T04:31:22.000Z | // Copyright Stephan T. Lavavej, http://nuwen.net .
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://boost.org/LICENSE_1_0.txt .
#include "gluon.hh"
#include "test.hh"
#include "typedef.hh"
#include "vector.hh"
#include "external_begin.hh"
#include <string>
#include "external_end.hh"
using namespace std;
using namespace nuwen;
using namespace nuwen::pack;
int main() {
{
packed_bits pb;
NUWEN_TEST("vector1", pb.vuc().empty())
pb.push_back(1);
pb.push_back(0);
pb.push_back(1);
NUWEN_TEST("vector2", pb.vuc() == vuc_t(1, 0xA0))
pb.push_back(0);
pb.push_back(1);
pb.push_back(1);
pb.push_back(0);
pb.push_back(1);
NUWEN_TEST("vector3", pb.vuc() == vuc_t(1, 0xAD))
pb.push_back(0);
NUWEN_TEST("vector4", pb.vuc() == vec(glu<uc_t>(0xAD)(0x00)))
pb.push_back(1);
NUWEN_TEST("vector5", pb.vuc() == vec(glu<uc_t>(0xAD)(0x40)))
}
NUWEN_TEST("vector6", bytes_from_bits(0) == 0)
NUWEN_TEST("vector7", bytes_from_bits(1) == 1)
NUWEN_TEST("vector8", bytes_from_bits(7) == 1)
NUWEN_TEST("vector9", bytes_from_bits(8) == 1)
NUWEN_TEST("vector10", bytes_from_bits(9) == 2)
NUWEN_TEST("vector11", bytes_from_bits(137) == 18)
NUWEN_TEST("vector12", bytes_from_bits(144) == 18)
NUWEN_TEST("vector13", bytes_from_bits(145) == 19)
{
const vuc_t deadbeef = vec(glu<uc_t>(0xDE)(0xAD)(0xBE)(0xEF));
NUWEN_TEST("vector14", bit_from_vuc(deadbeef, 0) == 1)
NUWEN_TEST("vector15", bit_from_vuc(deadbeef, 1) == 1)
NUWEN_TEST("vector16", bit_from_vuc(deadbeef, 2) == 0)
NUWEN_TEST("vector17", bit_from_vuc(deadbeef, 7) == 0)
NUWEN_TEST("vector18", bit_from_vuc(deadbeef, 8) == 1)
NUWEN_TEST("vector19", bit_from_vuc(deadbeef, 9) == 0)
NUWEN_TEST("vector20", bit_from_vuc(deadbeef, 31) == 1)
}
{
const vul_t v(5, 0x12345678UL);
const dul_t d(5, 0x12345678UL);
NUWEN_TEST("vector21", sequence_cast<dul_t>(v) == d)
NUWEN_TEST("vector22", sequence_cast<vul_t>(d) == v)
}
{
const vs_t v = vec(glu<string>("cute")("fluffy")("kittens"));
const ds_t d = deq(glu<string>("cute")("fluffy")("kittens"));
const ls_t l = lst(glu<string>("cute")("fluffy")("kittens"));
NUWEN_TEST("vector23", sequence_cast<ds_t>(v) == d)
NUWEN_TEST("vector24", sequence_cast<vs_t>(d) == v)
NUWEN_TEST("vector25", sequence_cast<ls_t>(v) == l)
NUWEN_TEST("vector26", sequence_cast<vs_t>(l) == v)
NUWEN_TEST("vector27", sequence_cast<ls_t>(d) == l)
NUWEN_TEST("vector28", sequence_cast<ds_t>(l) == d)
}
{
const string s("Meow");
const vuc_t v = vec(glu<uc_t>('M')('e')('o')('w'));
const duc_t d = deq(glu<uc_t>('M')('e')('o')('w'));
const luc_t l = lst(glu<uc_t>('M')('e')('o')('w'));
const vsc_t x = vec(glu<sc_t>('M')('e')('o')('w'));
const vc_t y = vec(glu<char>('M')('e')('o')('w'));
NUWEN_TEST("vector29", string_cast<string>(v) == s)
NUWEN_TEST("vector30", string_cast<string>(d) == s)
NUWEN_TEST("vector31", string_cast<string>(l) == s)
NUWEN_TEST("vector32", string_cast<string>(x) == s)
NUWEN_TEST("vector33", string_cast<string>(y) == s)
NUWEN_TEST("vector34", string_cast<vuc_t>(s) == v)
NUWEN_TEST("vector35", string_cast<duc_t>(s) == d)
NUWEN_TEST("vector36", string_cast<luc_t>(s) == l)
NUWEN_TEST("vector37", string_cast<vsc_t>(s) == x)
NUWEN_TEST("vector38", string_cast<vc_t >(s) == y)
NUWEN_TEST("vector39", string_cast<string>(v) == "Meow")
NUWEN_TEST("vector40", string_cast<vuc_t>("Meow") == v)
NUWEN_TEST("vector41", string_cast<duc_t>("Meow") == d)
NUWEN_TEST("vector42", string_cast<luc_t>("Meow") == l)
NUWEN_TEST("vector43", string_cast<vsc_t>("Meow") == x)
NUWEN_TEST("vector44", string_cast<vc_t >("Meow") == y)
const char * const p = "Meow";
NUWEN_TEST("vector45", string_cast<vuc_t>(p) == v)
}
NUWEN_TEST("vector46", uc_from_sc(-128) == 0)
NUWEN_TEST("vector47", uc_from_sc(5) == 133)
NUWEN_TEST("vector48", uc_from_sc(127) == 255)
NUWEN_TEST("vector49", us_from_ss(-32768) == 0)
NUWEN_TEST("vector50", us_from_ss(5) == 32773)
NUWEN_TEST("vector51", us_from_ss(32767) == 65535)
NUWEN_TEST("vector52", ul_from_sl(-2147483647L - 1) == 0)
NUWEN_TEST("vector53", ul_from_sl(5) == 2147483653UL)
NUWEN_TEST("vector54", ul_from_sl(2147483647) == 4294967295UL)
NUWEN_TEST("vector55", ull_from_sll(-9223372036854775807LL - 1) == 0)
NUWEN_TEST("vector56", ull_from_sll(5) == 9223372036854775813ULL)
NUWEN_TEST("vector57", ull_from_sll(9223372036854775807LL) == 18446744073709551615ULL)
NUWEN_TEST("vector58", sc_from_uc(0) == -128)
NUWEN_TEST("vector59", sc_from_uc(133) == 5)
NUWEN_TEST("vector60", sc_from_uc(255) == 127)
NUWEN_TEST("vector61", ss_from_us(0) == -32768)
NUWEN_TEST("vector62", ss_from_us(32773) == 5)
NUWEN_TEST("vector63", ss_from_us(65535) == 32767)
NUWEN_TEST("vector64", sl_from_ul(0) == -2147483647L - 1)
NUWEN_TEST("vector65", sl_from_ul(2147483653UL) == 5)
NUWEN_TEST("vector66", sl_from_ul(4294967295UL) == 2147483647)
NUWEN_TEST("vector67", sll_from_ull(0) == -9223372036854775807LL - 1)
NUWEN_TEST("vector68", sll_from_ull(9223372036854775813ULL) == 5)
NUWEN_TEST("vector69", sll_from_ull(18446744073709551615ULL) == 9223372036854775807LL)
{
const vuc_t v = vec(glu<uc_t>(0xDE)(0xAD)(0xBE)(0xEF)(0x17)(0x76)(0x21)(0x61)(0x47));
NUWEN_TEST("vector70", us_from_vuc(v) == 0xDEAD)
NUWEN_TEST("vector71", us_from_vuc(v, 1) == 0xADBE)
NUWEN_TEST("vector72", us_from_vuc(v, 7) == 0x6147)
NUWEN_TEST("vector73", ul_from_vuc(v) == 0xDEADBEEFUL)
NUWEN_TEST("vector74", ul_from_vuc(v, 1) == 0xADBEEF17UL)
NUWEN_TEST("vector75", ul_from_vuc(v, 5) == 0x76216147UL)
NUWEN_TEST("vector76", ull_from_vuc(v) == 0xDEADBEEF17762161ULL)
NUWEN_TEST("vector77", ull_from_vuc(v, 1) == 0xADBEEF1776216147ULL)
const vuc_ci_t i = v.begin() + 1;
NUWEN_TEST("vector78", us_from_vuc(i, v.end()) == 0xADBE)
NUWEN_TEST("vector79", ul_from_vuc(i, v.end()) == 0xADBEEF17UL)
NUWEN_TEST("vector80", ull_from_vuc(i, v.end()) == 0xADBEEF1776216147ULL)
const vuc_t a = vec(glu<uc_t>(0x21)(0x61));
const vuc_t b = vec(glu<uc_t>(0x21)(0x61)(0x17)(0x76));
const vuc_t c = vec(glu<uc_t>(0x21)(0x61)(0x17)(0x76)(0xDE)(0xAD)(0xBE)(0xEF));
NUWEN_TEST("vector81", vuc_from_us(0x2161) == a)
NUWEN_TEST("vector82", vuc_from_ul(0x21611776UL) == b)
NUWEN_TEST("vector83", vuc_from_ull(0x21611776DEADBEEFULL) == c)
}
NUWEN_TEST("vector84", hex_from_uc(0x00) == "00")
NUWEN_TEST("vector85", hex_from_uc(0x09) == "09")
NUWEN_TEST("vector86", hex_from_uc(0x2F) == "2F")
NUWEN_TEST("vector87", hex_from_uc(0xC4) == "C4")
NUWEN_TEST("vector88", hex_from_uc(0xDE) == "DE")
NUWEN_TEST("vector89", hex_from_uc(0xFF) == "FF")
NUWEN_TEST("vector90", hex_from_vuc(vec(glu<uc_t>(0xFF)(0xDE)(0xC4)(0x2F)(0x09)(0x00))) == "FFDEC42F0900")
{
const string s("0f1e2d3c4b5a69788796A5B4C3D2E1F0AfBeCdDcEbFa");
NUWEN_TEST("vector91", uc_from_hex("00") == 0x00)
NUWEN_TEST("vector92", uc_from_hex("09") == 0x09)
NUWEN_TEST("vector93", uc_from_hex("2F") == 0x2F)
NUWEN_TEST("vector94", uc_from_hex("C4") == 0xC4)
NUWEN_TEST("vector95", uc_from_hex("DE") == 0xDE)
NUWEN_TEST("vector96", uc_from_hex("FF") == 0xFF)
NUWEN_TEST("vector97", uc_from_hex(s) == 0x0F)
NUWEN_TEST("vector98", uc_from_hex(s, 1) == 0xF1)
NUWEN_TEST("vector99", uc_from_hex(s, 41) == 0xBF)
NUWEN_TEST("vector100", uc_from_hex(s, 42) == 0xFA)
const vuc_t v = vec(glu<uc_t>
(0x0F)(0x1E)(0x2D)(0x3C)(0x4B)(0x5A)(0x69)(0x78)(0x87)(0x96)(0xA5)
(0xB4)(0xC3)(0xD2)(0xE1)(0xF0)(0xAF)(0xBE)(0xCD)(0xDC)(0xEB)(0xFA));
NUWEN_TEST("vector101", vuc_from_hex(s) == v)
}
}
| 39.937799 | 110 | 0.620822 | [
"vector"
] |
b02ccd9a36586460bdfa7c16e72647abbe14c28d | 22,183 | cpp | C++ | src/main.cpp | rubenpenalva/ComputeBasics | c385022c285c5a44e16b2771159b2e861ad9a168 | [
"MIT"
] | null | null | null | src/main.cpp | rubenpenalva/ComputeBasics | c385022c285c5a44e16b2771159b2e861ad9a168 | [
"MIT"
] | null | null | null | src/main.cpp | rubenpenalva/ComputeBasics | c385022c285c5a44e16b2771159b2e861ad9a168 | [
"MIT"
] | null | null | null | #include "common.h"
#include <d3dcompiler.h>
#include <iostream>
#include <algorithm>
#include "utils.h"
#include "cmdqueuesyncer.h"
#include "gpumemory.h"
#include "descriptors.h"
#if ENABLE_D3D12_DEBUG_LAYER
#include <Initguid.h>
#include <dxgidebug.h>
#endif
namespace ComputeBasics
{
struct CommandQueue
{
ID3D12CommandQueueComPtr m_cmdQueue;
uint64_t m_timestampFrequency;
};
struct CommandList
{
ID3D12CommandAllocatorComPtr m_allocator;
ID3D12GraphicsCommandListComPtr m_cmdList;
};
struct PipelineState
{
ID3D12RootSignatureComPtr m_rootSignature;
ID3D12PipelineStateComPtr m_pso;
};
struct ResourceTransitionData
{
ID3D12Resource* m_resource;
D3D12_RESOURCE_STATES m_after;
};
struct ConstantData
{
float m_float;
};
const char* g_rootSignatureTarget = "rootsig_1_1";
const char* g_rootSignatureName = "SimpleRootSig";
const char* g_outputTag = "[ComputeBasics]";
const char* g_computeShaderMain = "main";
#ifdef ENABLE_RGA_COMPATIBILITY
const char* g_computeShaderTarget = "cs_5_0";
#else
const char* g_computeShaderTarget = "cs_5_1";
#endif
const UINT g_compileFlags = D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION;
const D3D12_RESOURCE_STATES g_cbState = D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER;
const D3D12_RESOURCE_STATES g_bufferState = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;
#if ENABLE_PIX_CAPTURE
class PixCapture
{
public:
PixCapture()
{
if (SUCCEEDED(DXGIGetDebugInterface1(0, IID_PPV_ARGS(&m_graphicsAnalysis))))
{
m_graphicsAnalysis->BeginCapture();
}
else
{
std::wcout << g_outputTag << "[PIX] A pix capture will not be triggered. Pix is not attached.\n";
}
}
~PixCapture()
{
if (m_graphicsAnalysis)
m_graphicsAnalysis->EndCapture();
}
PixCapture(const PixCapture&) = delete;
PixCapture(PixCapture&&) = delete;
PixCapture& operator=(const PixCapture&) = delete;
PixCapture& operator=(PixCapture&&) = delete;
private:
IDXGraphicsAnalysisComPtr m_graphicsAnalysis;
};
#endif
IDXGIAdapter1ComPtr CreateDXGIAdapter()
{
IDXGIFactory6ComPtr factory;
Utils::AssertIfFailed(CreateDXGIFactory2(DXGI_CREATE_FACTORY_DEBUG, IID_PPV_ARGS(&factory)));
assert(factory);
IDXGIAdapter1ComPtr adapter;
for (unsigned int adapterIndex = 0; ; ++adapterIndex)
{
HRESULT result = factory->EnumAdapterByGpuPreference(adapterIndex, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE,
IID_PPV_ARGS(adapter.ReleaseAndGetAddressOf()));
if (result != DXGI_ERROR_NOT_FOUND)
{
DXGI_ADAPTER_DESC1 desc;
Utils::AssertIfFailed(adapter->GetDesc1(&desc));
if (!(desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE))
{
std::wcout << g_outputTag << "[Hardware init] Using adapter " << desc.Description << std::endl;
break;
}
}
}
assert(adapter);
return adapter;
}
ID3D12DeviceComPtr CreateD3D12Device(IDXGIAdapter1ComPtr adapter)
{
#if ENABLE_D3D12_DEBUG_LAYER
// Note this needs to be called before creating the d3d12 device
Microsoft::WRL::ComPtr<ID3D12Debug> debugController0;
Utils::AssertIfFailed(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController0)));
debugController0->EnableDebugLayer();
#if ENABLE_D3D12_DEBUG_GPU_VALIDATION
Microsoft::WRL::ComPtr<ID3D12Debug1> debugController1;
Utils::AssertIfFailed(debugController0->QueryInterface(IID_PPV_ARGS(&debugController1)));
debugController1->SetEnableGPUBasedValidation(TRUE);
#endif // ENABLE_D3D12_DEBUG_GPU_VALIDATION
#endif // ENABLE_D3D12_DEBUG_LAYER
ID3D12DeviceComPtr device;
Utils::AssertIfFailed(D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_12_1, IID_PPV_ARGS(&device)));
assert(device);
return device;
}
#if ENABLE_D3D12_DEBUG_LAYER
void ReportLiveObjects()
{
Microsoft::WRL::ComPtr<IDXGIDebug1> debug;
Utils::AssertIfFailed(DXGIGetDebugInterface1(0, IID_PPV_ARGS(&debug)));
debug->ReportLiveObjects(DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL);
}
#endif
// TODO move the command queues and lists codes to its own file
CommandQueue CreateCommandQueue(ID3D12Device* device, D3D12_COMMAND_LIST_TYPE type,
bool disableTimeout, const std::wstring& name)
{
assert(device);
D3D12_COMMAND_QUEUE_DESC queueDesc {};
queueDesc.Type = type;
if (disableTimeout)
queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT;
CommandQueue cmdQueue;
Utils::AssertIfFailed(device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&cmdQueue.m_cmdQueue)));
assert(cmdQueue.m_cmdQueue);
Utils::AssertIfFailed(cmdQueue.m_cmdQueue->GetTimestampFrequency(&cmdQueue.m_timestampFrequency));
cmdQueue.m_cmdQueue->SetName(name.c_str());
return cmdQueue;
}
CommandQueue CreateComputeCmdQueue(ID3D12Device* device)
{
assert(device);
return CreateCommandQueue(device, D3D12_COMMAND_LIST_TYPE_COMPUTE, true, L"Compute Queue");
}
CommandQueue CreateCopyCmdQueue(ID3D12Device* device)
{
assert(device);
return CreateCommandQueue(device, D3D12_COMMAND_LIST_TYPE_COPY, true, L"Copy Queue");
}
// Note sticking together the cmdlist and the allocator. Not the most efficient way of doing it
// but good enough for now
CommandList CreateCommandList(ID3D12Device* device, D3D12_COMMAND_LIST_TYPE type, const std::wstring& name)
{
assert(device);
CommandList cmdList;
Utils::AssertIfFailed(device->CreateCommandAllocator(type, IID_PPV_ARGS(&cmdList.m_allocator)));
assert(cmdList.m_allocator);
cmdList.m_allocator->SetName((L"Command Allocator : CommandList " + name).c_str());
Utils::AssertIfFailed(device->CreateCommandList(0, type, cmdList.m_allocator.Get(), nullptr,
IID_PPV_ARGS(&cmdList.m_cmdList)));
assert(cmdList.m_cmdList);
cmdList.m_cmdList->SetName((L"Command List " + name).c_str());
return cmdList;
}
CommandList CreateCopyCommandList(ID3D12Device* device, const std::wstring& name)
{
D3D12_COMMAND_LIST_TYPE type = D3D12_COMMAND_LIST_TYPE_COPY;
return CreateCommandList(device, type, name);
}
CommandList CreateComputeCommandList(ID3D12Device* device, const std::wstring& name)
{
D3D12_COMMAND_LIST_TYPE type = D3D12_COMMAND_LIST_TYPE_COMPUTE;
return CreateCommandList(device, type, name);
}
D3D12_RESOURCE_BARRIER CreateTransition(ID3D12Resource* resource,
D3D12_RESOURCE_STATES before,
D3D12_RESOURCE_STATES after)
{
assert(resource);
D3D12_RESOURCE_BARRIER copyDestToReadDest;
copyDestToReadDest.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
copyDestToReadDest.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
copyDestToReadDest.Transition.pResource = resource;
copyDestToReadDest.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
copyDestToReadDest.Transition.StateBefore = before;
copyDestToReadDest.Transition.StateAfter = after;
return copyDestToReadDest;
}
// TODO not quite happy with returning the temp here. Good enough for now.
// Note returning the tmp so the object outlives the execution in the gpu
GpuMemAllocation EnqueueUploadDataToBuffer(ID3D12Device* device,
ID3D12GraphicsCommandList* copyCmdList,
ID3D12Resource* dst, const void* data, uint64_t sizeBytes)
{
assert(device);
assert(copyCmdList);
assert(dst);
assert(data && sizeBytes);
assert(copyCmdList->GetType() == D3D12_COMMAND_LIST_TYPE_COPY);
// Create temporal buffer in the upload heap
GpuMemAllocation src = AllocateUpload(device, sizeBytes, L"Upload temp buffer");
MemCpy(src, data, sizeBytes);
// Copy from upload heap to final buffer
copyCmdList->CopyResource(dst, src.m_resource.Get());
return src;
}
void EnqueueCopyBuffer(ID3D12Device* device,
ID3D12GraphicsCommandList* copyCmdList,
ID3D12Resource* dst, ID3D12Resource* src)
{
assert(device);
assert(copyCmdList);
assert(copyCmdList->GetType() == D3D12_COMMAND_LIST_TYPE_COPY);
assert(dst);
assert(src);
copyCmdList->CopyResource(dst, src);
}
// Note batching up the transitions to improve performance
void TransitionCopyDstResources(const std::vector<ResourceTransitionData>& dsts,
ID3D12GraphicsCommandList* computeCmdList)
{
assert(!dsts.empty());
assert(computeCmdList);
assert(computeCmdList->GetType() == D3D12_COMMAND_LIST_TYPE_COMPUTE);
std::vector<D3D12_RESOURCE_BARRIER> transitions;
for (auto& dst : dsts)
{
auto transition = CreateTransition(dst.m_resource,
D3D12_RESOURCE_STATE_COMMON,
dst.m_after);
transitions.push_back(transition);
}
computeCmdList->ResourceBarrier(static_cast<UINT>(transitions.size()), &transitions[0]);
}
void ExecuteCmdList(ID3D12Device* device, ID3D12CommandQueue* cmdQueue,
ID3D12GraphicsCommandList* cmdList)
{
assert(device);
assert(cmdQueue);
assert(cmdList);
Utils::AssertIfFailed(cmdList->Close());
ID3D12CommandList* cmdLists[] = { cmdList };
cmdQueue->ExecuteCommandLists(1, cmdLists);
// Wait for the cmdlist to finish
CmdQueueSyncer cmdQueueSyncer(device, cmdQueue);
auto workId = cmdQueueSyncer.SignalWork();
cmdQueueSyncer.Wait(workId);
}
// TODO move pipelinestate stuff to other file
ID3DBlobComPtr CompileBlob(const char* src, const char* target, const char* mainName, unsigned int flags,
ID3DBlob* errors)
{
ID3DBlobComPtr blob;
auto result = D3DCompile(src, strlen(src), nullptr, nullptr, nullptr, mainName, target, flags, 0, &blob, &errors);
if (FAILED(result))
{
assert(errors);
std::wcout << g_outputTag << " CompileBlob failed " << static_cast<const char*>(errors->GetBufferPointer());
return nullptr;
}
return blob;
}
ID3D12RootSignatureComPtr CreateComputeRootSignature(ID3D12Device* device, const std::vector<char>& rootSignatureSrc,
const std::wstring& name)
{
assert(device);
assert(rootSignatureSrc.size());
ID3DBlobComPtr errors;
auto rootSignatureBlob = CompileBlob(&rootSignatureSrc[0], g_rootSignatureTarget, g_rootSignatureName, 0, errors.Get());
if (!rootSignatureBlob)
{
std::wcout << g_outputTag << " [CreateComputeRootSignature] Failed to compile blob ";
if (errors)
std::cout << static_cast<const char*>(errors->GetBufferPointer()) << "\n";
return nullptr;
}
ID3D12RootSignatureComPtr rootSignature;
if (FAILED(device->CreateRootSignature(0, rootSignatureBlob->GetBufferPointer(), rootSignatureBlob->GetBufferSize(),
IID_PPV_ARGS(&rootSignature))))
{
std::wcout << g_outputTag << " [CreateComputeRootSignature] CreateRootSignature call failed\n";
return nullptr;
}
rootSignature->SetName(name.c_str());
return rootSignature;
}
ID3DBlobComPtr CreateComputeShader(ID3D12Device* device, const std::vector<char>& computeShaderSrc)
{
assert(device);
assert(!computeShaderSrc.empty());
ID3DBlobComPtr errors;
auto computeShader = CompileBlob(&computeShaderSrc[0], g_computeShaderTarget, g_computeShaderMain, g_compileFlags, errors.Get());
if (!computeShader)
{
std::wcout << g_outputTag << " [CreateComputeRootSignature] failed to compile blob ";
if (errors)
std::wcout << static_cast<const char*>(errors->GetBufferPointer()) << "\n";
return nullptr;
}
return computeShader;
}
PipelineState CreatePipelineState(ID3D12Device* device, const std::wstring& shaderFileName,
const std::wstring& rootSignatureName,
const std::wstring& pipelineStateName)
{
assert(device);
assert(!shaderFileName.empty());
const auto shaderSrc = Utils::ReadFullFile(shaderFileName);
if (shaderSrc.empty())
{
std::wcout << g_outputTag << " [CreatePipelineState] ReadFullFile " << shaderFileName.c_str() << " failed\n";
return {};
}
auto rootSignature = CreateComputeRootSignature(device, shaderSrc, rootSignatureName);
if (!rootSignature)
return {};
auto computeShader = CreateComputeShader(device, shaderSrc);
if (!computeShader)
return {};
ID3D12PipelineStateComPtr pipelineState;
D3D12_COMPUTE_PIPELINE_STATE_DESC desc;
desc.pRootSignature = rootSignature.Get();
desc.CS = { computeShader->GetBufferPointer(), computeShader->GetBufferSize() };
desc.NodeMask = 0;
desc.CachedPSO = {nullptr,0};
desc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE;
Utils::AssertIfFailed(device->CreateComputePipelineState(&desc, IID_PPV_ARGS(&pipelineState)));
pipelineState->SetName(pipelineStateName.c_str());
return { rootSignature, pipelineState };
}
ID3D12QueryHeapComPtr CreateTimestampQueryHeap(ID3D12Device* device, uint32_t timeStampsCount)
{
assert(device);
D3D12_QUERY_HEAP_DESC queryHeapDesc;
queryHeapDesc.Type = D3D12_QUERY_HEAP_TYPE_TIMESTAMP;
queryHeapDesc.Count = timeStampsCount;
queryHeapDesc.NodeMask = 0;
ID3D12QueryHeapComPtr queryHeap;
Utils::AssertIfFailed(device->CreateQueryHeap(&queryHeapDesc, IID_PPV_ARGS(&queryHeap)));
return queryHeap;
}
void EnqueueTimestampQuery(ID3D12GraphicsCommandList* cmdList, ID3D12QueryHeap* queryHeap, uint32_t queryIndex)
{
assert(cmdList);
assert(queryHeap);
cmdList->EndQuery(queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, queryIndex);
}
void EnqueueResolveTimestampQueries(ID3D12GraphicsCommandList* cmdList, ID3D12QueryHeap* queryHeap,
uint32_t timeStampsCount, ID3D12Resource* readbackBuffer)
{
assert(cmdList);
assert(queryHeap);
assert(timeStampsCount > 0);
assert(readbackBuffer);
cmdList->ResolveQueryData(queryHeap, D3D12_QUERY_TYPE_TIMESTAMP, 0, timeStampsCount, readbackBuffer, 0);
}
std::vector<double> ReadbackTimestamps(const GpuMemAllocation& allocation, uint32_t timestampsCount,
uint64_t cmdQueueTimestampFrequency)
{
assert(timestampsCount > 0);
ScopedMappedGpuMemAlloc memMap(allocation);
std::vector<double> timestamps(timestampsCount);
// Note timestamps data are ticks and cmd queue timestamp frequency is ticks/sec
const uint64_t* timestampsTicks = reinterpret_cast<uint64_t*>(static_cast<uint8_t*>(memMap.GetBuffer()));
for (uint32_t i = 0; i < timestampsCount; ++i)
{
timestamps[i] = timestampsTicks[i] / static_cast<double>(cmdQueueTimestampFrequency);
}
return timestamps;
}
}
using namespace ComputeBasics;
int main(int argc, char** argv)
{
std::wcout << "\n";
#if ENABLE_PIX_CAPTURE
PixCapture pixCapture;
#endif
auto dxgiAdapter = CreateDXGIAdapter();
auto d3d12DevicePtr = CreateD3D12Device(dxgiAdapter);
auto d3d12Device = d3d12DevicePtr.Get();
// Create a compute shader
const std::wstring computeShaderFileName = L"./data/shaders/simple.hlsl";
PipelineState pipelineState = CreatePipelineState(d3d12Device, computeShaderFileName, L"Simple", L"Simple");
if (!pipelineState.m_rootSignature || !pipelineState.m_pso)
return -1;
// Allocates buffers
auto constantDataBuffer = Allocate(d3d12Device, sizeof(ConstantData), false, L"ConstantData");
const size_t threadsPerGroup = 64;
const size_t threadGroupsCount = 16;
const size_t dataElementsCount = threadsPerGroup * threadGroupsCount;
const uint64_t dataSizeBytes = dataElementsCount * sizeof(float);
auto inputBuffer = Allocate(d3d12Device, dataSizeBytes, false, L"Input");
const uint64_t dataPerGroupSizeBytes = threadGroupsCount * sizeof(float);
auto inputPerGroupBuffer = Allocate(d3d12Device, dataPerGroupSizeBytes, false, L"Input Per Thread Group");
auto outputBuffer = Allocate(d3d12Device, dataSizeBytes, true, L"Output");
auto readbackBuffer = AllocateReadback(d3d12Device, dataSizeBytes, L"Readback");
const uint64_t timestampsCount = 2;
const uint64_t timestampBufferSize = timestampsCount * sizeof(uint64_t);
auto timeStampBuffer = AllocateReadback(d3d12Device, timestampBufferSize, L"TimeStamp");
// Upload data to gpu memory
auto computeCmdQueue = CreateComputeCmdQueue(d3d12Device);
auto computeCmdList = CreateComputeCommandList(d3d12Device, L"Compute");
auto copyCmdQueue = CreateCopyCmdQueue(d3d12Device);
auto copyCmdList = CreateCopyCommandList(d3d12Device, L"Copy");
{
ConstantData constantData{ -1.0f };
auto constantDataTmp = EnqueueUploadDataToBuffer(d3d12Device, copyCmdList.m_cmdList.Get(),
constantDataBuffer.m_resource.Get(),
&constantData, sizeof(ConstantData));
std::vector<float> inputData(dataElementsCount);
std::generate(inputData.begin(), inputData.end(), [v = 0.0f]() mutable
{
return v++;
});
auto inputBufferTmp = EnqueueUploadDataToBuffer(d3d12Device, copyCmdList.m_cmdList.Get(),
inputBuffer.m_resource.Get(),
&inputData[0], dataSizeBytes);
std::vector<float> inputDataPerThreadGroup(threadGroupsCount);
std::generate(inputDataPerThreadGroup.begin(), inputDataPerThreadGroup.end(), [v = 1.0f]() mutable
{
return v++;
});
auto inputPerGroupBuffertmp = EnqueueUploadDataToBuffer(d3d12Device, copyCmdList.m_cmdList.Get(),
inputPerGroupBuffer.m_resource.Get(),
&inputDataPerThreadGroup[0], dataPerGroupSizeBytes);
ExecuteCmdList(d3d12Device, copyCmdQueue.m_cmdQueue.Get(), copyCmdList.m_cmdList.Get());
std::vector<ResourceTransitionData> dsts
{
{ constantDataBuffer.m_resource.Get(), g_cbState},
{ inputBuffer.m_resource.Get(), g_bufferState},
{ inputPerGroupBuffer.m_resource.Get(), g_bufferState}
};
TransitionCopyDstResources(dsts, computeCmdList.m_cmdList.Get());
}
// Creates descriptors
const uint32_t descriptorsCount = 2;
ComputeBasics::DescriptorHeap descriptorHeap(d3d12Device, descriptorsCount);
descriptorHeap.CreateBufferDescriptor(inputBuffer, DXGI_FORMAT_R32_FLOAT, dataElementsCount, false);
descriptorHeap.CreateBufferDescriptor(outputBuffer, DXGI_FORMAT_R32_FLOAT, dataElementsCount, true);
// Start clock
auto& d3d12Cmdlist = computeCmdList.m_cmdList;
auto timestampQueryHeap = CreateTimestampQueryHeap(d3d12Device, timestampsCount);
EnqueueTimestampQuery(d3d12Cmdlist.Get(), timestampQueryHeap.Get(), 0);
// Setup state
ID3D12DescriptorHeap* d3d12DescriptorHeaps[] = { descriptorHeap.GetD3D12DescriptorHeap() };
d3d12Cmdlist->SetDescriptorHeaps(1, d3d12DescriptorHeaps);
d3d12Cmdlist->SetComputeRootSignature(pipelineState.m_rootSignature.Get());
d3d12Cmdlist->SetComputeRootDescriptorTable(0, descriptorHeap.BeginGpuHandle());
d3d12Cmdlist->SetComputeRootConstantBufferView(1, constantDataBuffer.m_resource->GetGPUVirtualAddress());
d3d12Cmdlist->SetComputeRootShaderResourceView(2, inputPerGroupBuffer.m_resource->GetGPUVirtualAddress());
d3d12Cmdlist->SetPipelineState(pipelineState.m_pso.Get());
// Dispatch and execute
d3d12Cmdlist->Dispatch(threadGroupsCount, 1, 1);
// End clock
EnqueueTimestampQuery(d3d12Cmdlist.Get(), timestampQueryHeap.Get(), 1);
EnqueueResolveTimestampQueries(d3d12Cmdlist.Get(), timestampQueryHeap.Get(), timestampsCount, timeStampBuffer.m_resource.Get());
D3D12_RESOURCE_BARRIER transition = CreateTransition(outputBuffer.m_resource.Get(),
D3D12_RESOURCE_STATE_UNORDERED_ACCESS,
D3D12_RESOURCE_STATE_COMMON);
d3d12Cmdlist->ResourceBarrier(1, &transition);
ExecuteCmdList(d3d12Device, computeCmdQueue.m_cmdQueue.Get(), d3d12Cmdlist.Get());
// Read readback buffer
{
// Copy from default buffer to readback buffer
copyCmdList.m_cmdList->Reset(copyCmdList.m_allocator.Get(), nullptr);
EnqueueCopyBuffer(d3d12Device, copyCmdList.m_cmdList.Get(),
readbackBuffer.m_resource.Get(), outputBuffer.m_resource.Get());
ExecuteCmdList(d3d12Device, copyCmdQueue.m_cmdQueue.Get(), copyCmdList.m_cmdList.Get());
std::vector<float> readbackData(dataElementsCount);
{
ScopedMappedGpuMemAlloc scopedMappedAlloc(readbackBuffer);
memcpy(&readbackData[0], scopedMappedAlloc.GetBuffer(), dataSizeBytes);
}
std::wcout << g_outputTag << "[Output Buffer] ";
for (size_t i = 0; i < readbackData.size(); ++i)
{
std::wcout << " " << i << ":"<< readbackData[i] << " ";
}
std::cout << "\n";
}
// Read timestamp buffer
auto timestamps = ReadbackTimestamps(timeStampBuffer, timestampsCount, computeCmdQueue.m_timestampFrequency);
const double deltaMicroSecs = (timestamps[1] - timestamps[0]) * 1000000.0;
std::wcout << g_outputTag << "[Performance] GPU execution time " << deltaMicroSecs << "us\n";
#if ENABLE_D3D12_DEBUG_LAYER
ReportLiveObjects();
#endif
return 0;
} | 36.91015 | 133 | 0.690754 | [
"object",
"vector"
] |
b0386dfc1c88f5012315300c4ced2a042843f4a2 | 12,747 | cpp | C++ | Engine/Source/Editor/ViewportInteraction/Gizmo/VIStretchGizmoHandle.cpp | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | 1 | 2022-01-29T18:36:12.000Z | 2022-01-29T18:36:12.000Z | Engine/Source/Editor/ViewportInteraction/Gizmo/VIStretchGizmoHandle.cpp | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | null | null | null | Engine/Source/Editor/ViewportInteraction/Gizmo/VIStretchGizmoHandle.cpp | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | null | null | null | // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "VIStretchGizmoHandle.h"
#include "UObject/ConstructorHelpers.h"
#include "Engine/StaticMesh.h"
#include "VIBaseTransformGizmo.h"
#include "ViewportInteractionDragOperations.h"
#include "VIGizmoHandleMeshComponent.h"
UStretchGizmoHandleGroup::UStretchGizmoHandleGroup()
: Super()
{
UStaticMesh* StretchingHandleMesh = nullptr;
{
static ConstructorHelpers::FObjectFinder<UStaticMesh> ObjectFinder( TEXT( "/Engine/VREditor/TransformGizmo/PlaneTranslationHandle" ) );
StretchingHandleMesh = ObjectFinder.Object;
check( StretchingHandleMesh != nullptr );
}
UStaticMesh* BoundingBoxCornerMesh = nullptr;
{
static ConstructorHelpers::FObjectFinder<UStaticMesh> ObjectFinder( TEXT( "/Engine/VREditor/TransformGizmo/BoundingBoxCorner" ) );
BoundingBoxCornerMesh = ObjectFinder.Object;
check( BoundingBoxCornerMesh != nullptr );
}
UStaticMesh* BoundingBoxEdgeMesh = nullptr;
{
static ConstructorHelpers::FObjectFinder<UStaticMesh> ObjectFinder( TEXT( "/Engine/VREditor/TransformGizmo/BoundingBoxEdge" ) );
BoundingBoxEdgeMesh = ObjectFinder.Object;
check( BoundingBoxEdgeMesh != nullptr );
}
const bool bAllowGizmoLighting = false; // @todo vreditor: Not sure if we want this for gizmos or not yet. Needs feedback. Also they're translucent right now.
for (int32 X = 0; X < 3; ++X)
{
for (int32 Y = 0; Y < 3; ++Y)
{
for (int32 Z = 0; Z < 3; ++Z)
{
FTransformGizmoHandlePlacement HandlePlacement = GetHandlePlacement( X, Y, Z );
int32 CenterHandleCount, FacingAxisIndex, CenterAxisIndex;
HandlePlacement.GetCenterHandleCountAndFacingAxisIndex( /* Out */ CenterHandleCount, /* Out */ FacingAxisIndex, /* Out */ CenterAxisIndex );
// Don't allow translation/stretching/rotation from the origin
if (CenterHandleCount < 3)
{
const FString HandleName = MakeHandleName( HandlePlacement );
// Stretching handle
if (CenterHandleCount != 1) // @todo vreditor: Remove this line if we want to re-enable support for edge stretching handles (rather than only corners). We disabled this because they sort of got in the way of the rotation gizmo, and weren't very popular to use.
{
FString ComponentName = HandleName + TEXT( "StretchingHandle" );
UStaticMesh* Mesh = nullptr;
if (CenterHandleCount == 0) // Corner?
{
Mesh = BoundingBoxCornerMesh;
}
else if (CenterHandleCount == 1) // Edge?
{
Mesh = BoundingBoxEdgeMesh;
}
else // Face
{
Mesh = StretchingHandleMesh;
}
CreateAndAddMeshHandle( Mesh, ComponentName, HandlePlacement );
}
}
}
}
}
DragOperationComponent->SetDragOperationClass(UStretchGizmoHandleDragOperation::StaticClass());
}
void UStretchGizmoHandleGroup::UpdateGizmoHandleGroup( const FTransform& LocalToWorld, const FBox& LocalBounds, const FVector ViewLocation, const bool bAllHandlesVisible, class UActorComponent* DraggingHandle, const TArray< UActorComponent* >& HoveringOverHandles,
float AnimationAlpha, float GizmoScale, const float GizmoHoverScale, const float GizmoHoverAnimationDuration, bool& bOutIsHoveringOrDraggingThisHandleGroup )
{
// Call parent implementation (updates hover animation)
Super::UpdateGizmoHandleGroup(LocalToWorld, LocalBounds, ViewLocation, bAllHandlesVisible, DraggingHandle, HoveringOverHandles,
AnimationAlpha, GizmoScale, GizmoHoverScale, GizmoHoverAnimationDuration, bOutIsHoveringOrDraggingThisHandleGroup );
for (int32 HandleIndex = 0; HandleIndex < Handles.Num(); ++HandleIndex)
{
FGizmoHandle& Handle = Handles[ HandleIndex ];
UStaticMeshComponent* StretchingHandle = Handle.HandleMesh;
if (StretchingHandle != nullptr) // Can be null if no handle for this specific placement
{
const FTransformGizmoHandlePlacement HandlePlacement = MakeHandlePlacementForIndex( HandleIndex );
float GizmoHandleScale = GizmoScale;
const float OffsetFromSide = GizmoHandleScale *
(0.0f + // @todo vreditor tweak: Hard coded handle offset from side of primitive
(1.0f - AnimationAlpha) * 10.0f); // @todo vreditor tweak: Animation offset
// Make the handle bigger while hovered (but don't affect the offset -- we want it to scale about it's origin)
GizmoHandleScale *= FMath::Lerp( 1.0f, GizmoHoverScale, Handle.HoverAlpha );
FVector HandleRelativeLocation = FVector::ZeroVector;
for (int32 AxisIndex = 0; AxisIndex < 3; ++AxisIndex)
{
if (HandlePlacement.Axes[AxisIndex] == ETransformGizmoHandleDirection::Negative) // Negative direction
{
HandleRelativeLocation[AxisIndex] = LocalBounds.Min[AxisIndex] - OffsetFromSide;
}
else if (HandlePlacement.Axes[AxisIndex] == ETransformGizmoHandleDirection::Positive) // Positive direction
{
HandleRelativeLocation[AxisIndex] = LocalBounds.Max[AxisIndex] + OffsetFromSide;
}
else // ETransformGizmoHandleDirection::Center
{
HandleRelativeLocation[AxisIndex] = LocalBounds.GetCenter()[AxisIndex];
}
}
StretchingHandle->SetRelativeLocation( HandleRelativeLocation );
int32 CenterHandleCount, FacingAxisIndex, CenterAxisIndex;
HandlePlacement.GetCenterHandleCountAndFacingAxisIndex( /* Out */ CenterHandleCount, /* Out */ FacingAxisIndex, /* Out */ CenterAxisIndex );
FRotator Rotator = FRotator::ZeroRotator;
{
// Back bottom left
if (HandlePlacement.Axes[0] == ETransformGizmoHandleDirection::Negative && HandlePlacement.Axes[1] == ETransformGizmoHandleDirection::Negative && HandlePlacement.Axes[2] == ETransformGizmoHandleDirection::Negative)
{
Rotator.Yaw = 0.0f;
Rotator.Pitch = 0.0f;
}
// Back bottom right
else if (HandlePlacement.Axes[0] == ETransformGizmoHandleDirection::Negative && HandlePlacement.Axes[1] == ETransformGizmoHandleDirection::Positive && HandlePlacement.Axes[2] == ETransformGizmoHandleDirection::Negative)
{
Rotator.Yaw = -90.0f;
Rotator.Pitch = 0.0f;
}
// Back top left
else if (HandlePlacement.Axes[0] == ETransformGizmoHandleDirection::Negative && HandlePlacement.Axes[1] == ETransformGizmoHandleDirection::Negative && HandlePlacement.Axes[2] == ETransformGizmoHandleDirection::Positive)
{
Rotator.Yaw = 0.0f;
Rotator.Pitch = -90.0f;
}
// Back top right
else if (HandlePlacement.Axes[0] == ETransformGizmoHandleDirection::Negative && HandlePlacement.Axes[1] == ETransformGizmoHandleDirection::Positive && HandlePlacement.Axes[2] == ETransformGizmoHandleDirection::Positive)
{
Rotator.Yaw = -90.0f;
Rotator.Pitch = -90.0f;
}
// Front bottom left
else if (HandlePlacement.Axes[0] == ETransformGizmoHandleDirection::Positive && HandlePlacement.Axes[1] == ETransformGizmoHandleDirection::Negative && HandlePlacement.Axes[2] == ETransformGizmoHandleDirection::Negative)
{
Rotator.Yaw = 0.0f;
Rotator.Pitch = 90.0f;
}
// Front bottom right
else if (HandlePlacement.Axes[0] == ETransformGizmoHandleDirection::Positive && HandlePlacement.Axes[1] == ETransformGizmoHandleDirection::Positive && HandlePlacement.Axes[2] == ETransformGizmoHandleDirection::Negative)
{
Rotator.Yaw = 90.0f;
Rotator.Pitch = 90.0f;
}
// Front top left
else if (HandlePlacement.Axes[0] == ETransformGizmoHandleDirection::Positive && HandlePlacement.Axes[1] == ETransformGizmoHandleDirection::Negative && HandlePlacement.Axes[2] == ETransformGizmoHandleDirection::Positive)
{
Rotator.Yaw = 0.0f;
Rotator.Pitch = -180.0f;
}
// Front top right
else if (HandlePlacement.Axes[0] == ETransformGizmoHandleDirection::Positive && HandlePlacement.Axes[1] == ETransformGizmoHandleDirection::Positive && HandlePlacement.Axes[2] == ETransformGizmoHandleDirection::Positive)
{
Rotator.Yaw = 180.0f;
Rotator.Pitch = -90.0f;
}
// Back left/right edge
else if (HandlePlacement.Axes[0] == ETransformGizmoHandleDirection::Negative && HandlePlacement.Axes[1] != ETransformGizmoHandleDirection::Center)
{
Rotator.Yaw = 0.0f;
Rotator.Pitch = 90.0f;
}
// Back bottom/top edge
else if (HandlePlacement.Axes[0] == ETransformGizmoHandleDirection::Negative && HandlePlacement.Axes[2] != ETransformGizmoHandleDirection::Center)
{
Rotator.Yaw = 90.0f;
Rotator.Pitch = 0.0f;
}
// Front left/right edge
else if (HandlePlacement.Axes[0] == ETransformGizmoHandleDirection::Positive && HandlePlacement.Axes[1] != ETransformGizmoHandleDirection::Center)
{
Rotator.Yaw = 0.0f;
Rotator.Pitch = 90.0f;
}
// Front bottom/top edge
else if (HandlePlacement.Axes[0] == ETransformGizmoHandleDirection::Positive && HandlePlacement.Axes[2] != ETransformGizmoHandleDirection::Center)
{
Rotator.Yaw = 90.0f;
Rotator.Pitch = 0.0f;
}
else
{
// Facing out from center of a face
if (CenterHandleCount == 2)
{
const FQuat GizmoSpaceOrientation = GetAxisVector( FacingAxisIndex, HandlePlacement.Axes[FacingAxisIndex] ).ToOrientationQuat();
Rotator = GizmoSpaceOrientation.Rotator();
}
else
{
// One of the left/right bottom or top edges
}
}
}
StretchingHandle->SetRelativeRotation( Rotator );
StretchingHandle->SetRelativeScale3D( FVector( GizmoHandleScale ) );
// Update material
UpdateHandleColor( FacingAxisIndex, Handle, DraggingHandle, HoveringOverHandles );
}
}
}
EGizmoHandleTypes UStretchGizmoHandleGroup::GetHandleType() const
{
return EGizmoHandleTypes::Scale;
}
bool UStretchGizmoHandleGroup::SupportsWorldCoordinateSpace() const
{
// Stretching only works with local space gizmos
return false;
}
void UStretchGizmoHandleDragOperation::ExecuteDrag(FDraggingTransformableData& DraggingData)
{
// We only support stretching by a handle currently
const FTransformGizmoHandlePlacement& HandlePlacement = DraggingData.OptionalHandlePlacement.GetValue();
const FVector PassGizmoSpaceDraggedTo = DraggingData.GizmoStartTransform.InverseTransformPositionNoScale(DraggingData.PassDraggedTo);
FBox NewGizmoLocalBounds = DraggingData.GizmoStartLocalBounds;
FVector GizmoSpacePivotLocation = FVector::ZeroVector;
for (int32 AxisIndex = 0; AxisIndex < 3; ++AxisIndex)
{
// Figure out how much the gizmo bounds changes
if (HandlePlacement.Axes[AxisIndex] == ETransformGizmoHandleDirection::Negative) // Negative direction
{
GizmoSpacePivotLocation[AxisIndex] = DraggingData.GizmoStartLocalBounds.Max[AxisIndex];
NewGizmoLocalBounds.Min[AxisIndex] = DraggingData.GizmoStartLocalBounds.Min[AxisIndex] + PassGizmoSpaceDraggedTo[AxisIndex];
}
else if (HandlePlacement.Axes[AxisIndex] == ETransformGizmoHandleDirection::Positive) // Positive direction
{
GizmoSpacePivotLocation[AxisIndex] = DraggingData.GizmoStartLocalBounds.Min[AxisIndex];
NewGizmoLocalBounds.Max[AxisIndex] = DraggingData.GizmoStartLocalBounds.Max[AxisIndex] + PassGizmoSpaceDraggedTo[AxisIndex];
}
else
{
// Must be ETransformGizmoHandleDirection::Center.
GizmoSpacePivotLocation[AxisIndex] = DraggingData.GizmoStartLocalBounds.GetCenter()[AxisIndex];
}
}
const FVector GizmoStartLocalSize = DraggingData.GizmoStartLocalBounds.GetSize();
const FVector NewGizmoLocalSize = NewGizmoLocalBounds.GetSize();
FVector NewGizmoLocalScaleFromStart = FVector(1.0f);
for (int32 AxisIndex = 0; AxisIndex < 3; ++AxisIndex)
{
if (!FMath::IsNearlyZero(GizmoStartLocalSize[AxisIndex]))
{
NewGizmoLocalScaleFromStart[AxisIndex] = NewGizmoLocalSize[AxisIndex] / GizmoStartLocalSize[AxisIndex];
}
else
{
// Zero scale. This is allowed in Unreal, for better or worse.
NewGizmoLocalScaleFromStart[AxisIndex] = 0.0f;
}
}
// Stretch and reposition the gizmo!
{
FTransform& PassGizmoTargetTransform = DraggingData.OutGizmoUnsnappedTargetTransform;
{
const FVector GizmoSpaceTransformableStartLocation = DraggingData.GizmoStartTransform.InverseTransformPositionNoScale(DraggingData.GizmoStartTransform.GetLocation());
const FVector NewGizmoSpaceLocation = (GizmoSpaceTransformableStartLocation - GizmoSpacePivotLocation) * NewGizmoLocalScaleFromStart + GizmoSpacePivotLocation;
PassGizmoTargetTransform.SetLocation(DraggingData.GizmoStartTransform.TransformPosition(NewGizmoSpaceLocation));
}
// @todo vreditor: This scale is still in gizmo space, but we're setting it in world space
PassGizmoTargetTransform.SetScale3D(DraggingData.GizmoStartTransform.GetScale3D() * NewGizmoLocalScaleFromStart);
DraggingData.bOutMovedTransformGizmo = true;
DraggingData.bOutShouldApplyVelocitiesFromDrag = false;
DraggingData.bOutScaled = true;
DraggingData.bAllowSnap = false;
}
}
| 40.084906 | 266 | 0.746058 | [
"mesh",
"object"
] |
b04b9a722d4c0379454526b960cbd3a02bb5d053 | 17,931 | cpp | C++ | mc-sema/cfgToLLVM/raiseX86_64.cpp | randolphwong/mcsema | eb5b376736e7f57ff0a61f7e4e5a436bbb874720 | [
"BSD-3-Clause"
] | 2 | 2021-08-07T16:21:29.000Z | 2021-11-17T10:58:37.000Z | mc-sema/cfgToLLVM/raiseX86_64.cpp | randolphwong/mcsema | eb5b376736e7f57ff0a61f7e4e5a436bbb874720 | [
"BSD-3-Clause"
] | null | null | null | mc-sema/cfgToLLVM/raiseX86_64.cpp | randolphwong/mcsema | eb5b376736e7f57ff0a61f7e4e5a436bbb874720 | [
"BSD-3-Clause"
] | null | null | null |
#include "toLLVM.h"
#include "raiseX86.h"
#include "X86.h"
#include "x86Instrs.h"
#include "x86Helpers.h"
#include "ArchOps.h"
#include "RegisterUsage.h"
#include <llvm/Object/COFF.h>
#include <llvm/IR/Constants.h>
#include <llvm/ADT/StringSwitch.h>
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/Module.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/LinkAllPasses.h"
#include "llvm/IR/Type.h"
#include "Externals.h"
#include "../common/to_string.h"
#include "../common/Defaults.h"
#include <vector>
#include <llvm/IR/InlineAsm.h>
#include <llvm/IR/MDBuilder.h>
#include "ArchOps.h"
using namespace llvm;
using namespace std;
namespace x86_64 {
bool addEntryPointDriverRaw(Module *M, string name, VA entry) {
string s("sub_"+to_string<VA>(entry, hex));
Function *F = M->getFunction(s);
if( F != NULL ) {
vector<Type *> args;
vector<Value*> subArg;
args.push_back(g_PRegStruct);
Type *returnTy = Type::getVoidTy(M->getContext());
FunctionType *FT = FunctionType::get(returnTy, args, false);
// check if driver name already exists.. maybe its the name of an
// extcall and we will have a serious conflict?
Function *driverF = M->getFunction(name);
if(driverF == NULL) {
// function does not exist. this is good.
// insert the function prototype
driverF = (Function *) M->getOrInsertFunction(name, FT);
} else {
throw TErr(__LINE__, __FILE__, "Cannot insert driver. Function "+name+" already exists.");
}
if( driverF == NULL ) {
throw TErr(__LINE__, __FILE__, "Could not get or insert function "+name);
}
//insert the function logical body
//insert a primary BB
BasicBlock *driverBB = BasicBlock::Create( driverF->getContext(),
"driverBlockRaw",
driverF);
Function::ArgumentListType::iterator it =
driverF->getArgumentList().begin();
Function::ArgumentListType::iterator end =
driverF->getArgumentList().end();
while(it != end) {
Argument *curArg = it;
subArg.push_back(curArg);
it++;
}
CallInst* ci = CallInst::Create(F, subArg, "", driverBB);
archSetCallingConv(M, ci);
ReturnInst::Create(driverF->getContext(), driverBB);
return true;
}
return false;
}
bool addEntryPointDriver(Module *M,
string name,
VA entry,
int np,
bool ret,
raw_ostream &report,
ExternalCodeRef::CallingConvention cconv,
string funcSign)
{
//convert the VA into a string name of a function, try and look it up
string s("sub_"+to_string<VA>(entry, hex));
Function *F = M->getFunction(s);
Type *int64ty = Type::getInt64Ty(M->getContext());
Type *int64PtrTy = PointerType::get(int64ty, 0);
if( F != NULL ) {
//build function prototype from name and numParms
vector<Type *> args;
for(int i = 0; i < np; i++) {
if(funcSign.c_str()[i] == 'F'){
args.push_back(Type::getDoubleTy(M->getContext()));
}
else{
args.push_back(Type::getInt64Ty(M->getContext()));
}
}
Type *returnTy = NULL;
if(ret) {
returnTy = Type::getInt64Ty(M->getContext());
} else{
returnTy = Type::getVoidTy(M->getContext());
}
FunctionType *FT = FunctionType::get(returnTy, args, false);
std::cout << __FUNCTION__ << "\n";
//insert the function prototype
Function *driverF = (Function *) M->getOrInsertFunction(name, FT);
// set drivers calling convention to match user specification
archSetCallingConv(M, driverF);
TASSERT(driverF != NULL, "");
//insert the function logical body
//insert a primary BB
BasicBlock *driverBB = BasicBlock::Create( driverF->getContext(),
"driverBlock",
driverF);
//insert an alloca for the register context structure
Instruction *aCtx = new AllocaInst(g_RegStruct, "", driverBB);
TASSERT(aCtx != NULL, "Could not allocate register context!");
//write the parameters into the stack
Function::ArgumentListType::iterator fwd_it =
driverF->getArgumentList().begin();
Function::ArgumentListType::iterator fwd_end =
driverF->getArgumentList().end();
AttrBuilder B;
B.addAttribute(Attribute::InReg);
if(getSystemOS(M) == llvm::Triple::Win32) {
if(fwd_it != fwd_end) {
Type *T = fwd_it->getType();
Value *arg1;
if(T->isDoubleTy()){
int k = x86_64::getRegisterOffset(XMM0);
Value *argFieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
// make driver take this from register
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 1, B));
Instruction *ptr128 = GetElementPtrInst::CreateInBounds(aCtx, argFieldGEPV, "", driverBB);
arg1 = CastInst::CreatePointerCast(ptr128, PointerType::get(Type::getDoubleTy(M->getContext()), 0), "arg0", driverBB);
} else {
int k = x86_64::getRegisterOffset(RCX);
Value *argFieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
// make driver take this from register
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 1, B));
arg1 = GetElementPtrInst::CreateInBounds(aCtx, argFieldGEPV, "", driverBB);
}
Argument *curArg = &(*fwd_it);
aliasMCSemaScope(new StoreInst(curArg, arg1, driverBB));
}
++fwd_it;
if(fwd_it != fwd_end) {
Type *T = fwd_it->getType();
Value *arg2;
if(T->isDoubleTy()){
int k = x86_64::getRegisterOffset(XMM1);
Value *argFieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
// make driver take this from register
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 1, B));
Instruction *ptr128 = GetElementPtrInst::CreateInBounds(aCtx, argFieldGEPV, "", driverBB);
arg2 = CastInst::CreatePointerCast(ptr128, PointerType::get(Type::getDoubleTy(M->getContext()), 0), "arg1", driverBB);
} else {
int k = x86_64::getRegisterOffset(RDX);
Value *argFieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
// make driver take this from register
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 2, B));
arg2 = GetElementPtrInst::CreateInBounds(aCtx, argFieldGEPV, "", driverBB);
}
Argument *curArg = &(*fwd_it);
aliasMCSemaScope(new StoreInst(curArg, arg2, driverBB));
}
++fwd_it;
if(fwd_it != fwd_end) {
Type *T = fwd_it->getType();
Value *arg3;
if(T->isDoubleTy()){
int k = x86_64::getRegisterOffset(XMM2);
Value *argFieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
// make driver take this from register
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 3, B));
Instruction *ptr128 = GetElementPtrInst::CreateInBounds(aCtx, argFieldGEPV, "", driverBB);
arg3 = CastInst::CreatePointerCast(ptr128, PointerType::get(Type::getDoubleTy(M->getContext()), 0), "arg3", driverBB);
} else {
int k = x86_64::getRegisterOffset(R8);
Value *r8FieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 3, B));
arg3 = GetElementPtrInst::CreateInBounds(aCtx, r8FieldGEPV, "", driverBB);
}
Argument *curArg = &(*fwd_it);
new StoreInst(curArg, arg3, driverBB);
}
++fwd_it;
if(fwd_it != fwd_end) {
Type *T = fwd_it->getType();
Value *arg4;
if(T->isDoubleTy()){
int k = x86_64::getRegisterOffset(XMM3);
Value *argFieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
// make driver take this from register
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 1, B));
Instruction *ptr128 = GetElementPtrInst::CreateInBounds(aCtx, argFieldGEPV, "", driverBB);
arg4 = CastInst::CreatePointerCast(ptr128, PointerType::get(Type::getDoubleTy(M->getContext()), 0), "arg3", driverBB);
} else {
int k = x86_64::getRegisterOffset(R9);
Value *r9FieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 4, B));
arg4 = GetElementPtrInst::CreateInBounds(aCtx, r9FieldGEPV, "", driverBB);
}
Argument *curArg = &(*fwd_it);
aliasMCSemaScope(new StoreInst(curArg, arg4, driverBB));
}
} else if (getSystemOS(M) == llvm::Triple::Linux) {
//#else
if(fwd_it != fwd_end) {
int k = x86_64::getRegisterOffset(RDI);
Value *rdiFieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
// make driver take this from register
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 1, B));
Value *rdiP = GetElementPtrInst::CreateInBounds(aCtx, rdiFieldGEPV, "", driverBB);
Argument *curArg = &(*fwd_it);
aliasMCSemaScope(new StoreInst(curArg, rdiP, driverBB));
}
// set rsi to arg[1]
++fwd_it;
if(fwd_it != fwd_end) {
int k = x86_64::getRegisterOffset(RSI);
Value *rsiFieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
// make driver take this from register
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 2, B));
Value *rsiP = GetElementPtrInst::CreateInBounds(aCtx, rsiFieldGEPV, "", driverBB);
Argument *curArg = &(*fwd_it);
aliasMCSemaScope(new StoreInst(curArg, rsiP, driverBB));
}
// set rdx to arg[2]
++fwd_it;
if(fwd_it != fwd_end) {
int k = x86_64::getRegisterOffset(RDX);
Value *rdxFieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 3, B));
Value *rdxP = GetElementPtrInst::CreateInBounds(aCtx, rdxFieldGEPV, "", driverBB);
Argument *curArg = &(*fwd_it);
aliasMCSemaScope(new StoreInst(curArg, rdxP, driverBB));
}
//set rcx to arg[3]
++fwd_it;
if(fwd_it != fwd_end) {
int k = x86_64::getRegisterOffset(RCX);
Value *rcxFieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 4, B));
Value *rcxP = GetElementPtrInst::CreateInBounds(aCtx, rcxFieldGEPV, "", driverBB);
Argument *curArg = &(*fwd_it);
aliasMCSemaScope(new StoreInst(curArg, rcxP, driverBB));
}
//set r8 to arg[4]
++fwd_it;
if(fwd_it != fwd_end) {
int k = x86_64::getRegisterOffset(R8);
Value *r8FieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 5, B));
Value *r8P = GetElementPtrInst::CreateInBounds(aCtx, r8FieldGEPV, "", driverBB);
Argument *curArg = &(*fwd_it);
new StoreInst(curArg, r8P, driverBB);
}
//set r9 to arg[5]
++fwd_it;
if(fwd_it != fwd_end) {
int k = x86_64::getRegisterOffset(R9);
Value *r9FieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
fwd_it->addAttr(AttributeSet::get(fwd_it->getContext(), 6, B));
Value *r9P = GetElementPtrInst::CreateInBounds(aCtx, r9FieldGEPV, "", driverBB);
Argument *curArg = &(*fwd_it);
aliasMCSemaScope(new StoreInst(curArg, r9P, driverBB));
}
} else {
TASSERT(false, "Unsupported OS!");
}
//#endif
// rest of the arguments are passed on stack
Function::ArgumentListType::reverse_iterator it = driverF->getArgumentList().rbegin();
Function::ArgumentListType::reverse_iterator end = driverF->getArgumentList().rend();
Value *stackSize = archGetStackSize(M, driverBB);
Value *aStack = archAllocateStack(M, stackSize, driverBB);
// position pointer to end of stack
Value *stackBaseInt = BinaryOperator::Create(BinaryOperator::Add,
aStack, stackSize, "", driverBB);
Value *stackPosInt = stackBaseInt;
// decrement stackPtr to leave some slack space on the stack.
// our current implementation of varargs functions just passes
// a big number of arguments to the destination function.
// This works because they are declared cdecl and the caller cleans up
// ... BUT
// if there is not enough stack for all these args, we may dereference
// unallocated memory. Leave some slack so this doesn't happen.
stackPosInt = BinaryOperator::Create(BinaryOperator::Sub,
stackPosInt, CONST_V<64>(driverBB, 8*12), "", driverBB);
// decrement stackPtr once to have a slot for
// "return address", even if there are no arguments
stackPosInt = BinaryOperator::Create(BinaryOperator::Sub,
stackPosInt, CONST_V<64>(driverBB, 8), "", driverBB);
// number of arguments to be pushed on stack
int args_to_push = driverF->getArgumentList().size() - 6;
// save arguments on the stack
while(args_to_push > 0)
{
Argument *curArg = &(*it);
// convert to int64 ptr
Value *stackPosPtr = noAliasMCSemaScope(new IntToPtrInst(stackPosInt, int64PtrTy, "", driverBB ));
// write argument
Instruction *k = noAliasMCSemaScope(new StoreInst(curArg, stackPosPtr, driverBB));
// decrement stack
stackPosInt = BinaryOperator::Create(BinaryOperator::Sub,
stackPosInt, CONST_V<64>(driverBB, 8), "", driverBB);
++it;
--args_to_push;
}
int k = x86_64::getRegisterOffset(RSP);
Value *spFieldGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
k = x86_64::getRegisterOffset(STACK_BASE);
Value *stackBaseGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
k = x86_64::getRegisterOffset(STACK_LIMIT);
Value *stackLimitGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
Value *spValP =
GetElementPtrInst::CreateInBounds(aCtx, spFieldGEPV, "", driverBB);
Value *sBaseValP =
GetElementPtrInst::CreateInBounds(aCtx, stackBaseGEPV, "", driverBB);
Value *sLimitValP =
GetElementPtrInst::CreateInBounds(aCtx, stackLimitGEPV, "", driverBB);
// stack limit = start of allocation (stack grows down);
Instruction *tmp1 = aliasMCSemaScope(new StoreInst(aStack, sLimitValP, driverBB));
// stack base = stack alloc start + stack size
Instruction *tmp2 = aliasMCSemaScope(new StoreInst(stackBaseInt, sBaseValP, driverBB));
// all functions assume DF is clear on entry
k = x86_64::getRegisterOffset(DF);
Value *dflagGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, k)
};
Value *dflagP =
GetElementPtrInst::CreateInBounds(aCtx, dflagGEPV, "", driverBB);
Instruction *tmp3 = aliasMCSemaScope(new StoreInst(CONST_V<1>(driverBB, 0), dflagP, driverBB));
Instruction *j = aliasMCSemaScope(new StoreInst(stackPosInt, spValP, driverBB));
TASSERT(j != NULL, "Could not write stack value to RSP");
//call the sub function with register struct as argument
vector<Value*> subArg;
subArg.push_back(aCtx);
CallInst* ci = CallInst::Create(F, subArg, "", driverBB);
archSetCallingConv(M, ci);
archFreeStack(M, aStack, driverBB);
//if we are requested, return the EAX value, else return void
if(ret) {
//do a GEP and load for the EAX register in the reg structure
int j = x86_64::getRegisterOffset(RAX);
Value *raxGEPV[] = {
CONST_V<64>(driverBB, 0),
CONST_V<32>(driverBB, j)
};
Value *raxVP =
GetElementPtrInst::CreateInBounds(aCtx, raxGEPV, "", driverBB);
Instruction *raxV = aliasMCSemaScope(new LoadInst(raxVP, "", driverBB));
//return that value
ReturnInst::Create(driverF->getContext(), raxV, driverBB);
} else {
ReturnInst::Create(driverF->getContext(), driverBB);
}
} else {
report << "Could not find entry point function\n";
return false;
}
return true;
}
}
| 35.506931 | 134 | 0.573588 | [
"object",
"vector"
] |
b04cb373742e0a3830878f62f2267c6b46ea18d7 | 893 | hpp | C++ | mainapp/Classes/Managers/BookManager.hpp | JaagaLabs/GLEXP-Team-KitkitSchool | f94ea3e53bd05fdeb2a9edcc574bc054e575ecc0 | [
"Apache-2.0"
] | 45 | 2019-05-16T20:49:31.000Z | 2021-11-05T21:40:54.000Z | mainapp/Classes/Managers/BookManager.hpp | rdsmarketing/GLEXP-Team-KitkitSchool | 6ed6b76d17fd7560abc35dcdf7cf4a44ce70745e | [
"Apache-2.0"
] | 10 | 2019-05-17T13:38:22.000Z | 2021-07-31T19:38:27.000Z | mainapp/Classes/Managers/BookManager.hpp | rdsmarketing/GLEXP-Team-KitkitSchool | 6ed6b76d17fd7560abc35dcdf7cf4a44ce70745e | [
"Apache-2.0"
] | 29 | 2019-05-16T17:49:26.000Z | 2021-12-30T16:36:24.000Z | //
// BookManager.hpp
// KitkitSchool
//
// Created by Gunho Lee on 11/3/16.
//
//
#ifndef BookManager_hpp
#define BookManager_hpp
#include <stdio.h>
#include <string>
#include <map>
#include <vector>
#include "LanguageManager.hpp"
using namespace std;
class BookInfo {
public:
string bookTitle;
LanguageManager::LocaleType bookLanguage;
string bookPath;
string bookImagePath;
};
class BookManager {
map<string, BookInfo*> _bookMap;
public:
static BookManager *getInstance();
BookManager() { _bookMap.clear(); }
void addBookInfo(BookInfo *info);
void addBookInfo(string title, LanguageManager::LocaleType lang, string path, string imagePath = "");
BookInfo* findBookInfo(string title);
vector<BookInfo*> getBookVector(LanguageManager::LocaleType lang);
};
#endif /* BookManager_hpp */
| 14.174603 | 105 | 0.671892 | [
"vector"
] |
b04e6e433d0827cae4ac62445d665497f52ffc68 | 1,848 | cpp | C++ | tengine/models/models.cpp | dfk789/CodenameInfinite | aeb88b954b65f6beca3fb221fe49459b75e7c15f | [
"BSD-4-Clause"
] | 2 | 2015-01-02T13:11:04.000Z | 2015-01-20T02:46:15.000Z | tengine/models/models.cpp | dfk789/CodenameInfinite | aeb88b954b65f6beca3fb221fe49459b75e7c15f | [
"BSD-4-Clause"
] | null | null | null | tengine/models/models.cpp | dfk789/CodenameInfinite | aeb88b954b65f6beca3fb221fe49459b75e7c15f | [
"BSD-4-Clause"
] | null | null | null | #include "models.h"
#include <modelconverter/modelconverter.h>
#include <renderer/renderer.h>
#include <models/texturelibrary.h>
CModelLibrary* CModelLibrary::s_pModelLibrary = NULL;
static CModelLibrary g_ModelLibrary = CModelLibrary();
CModelLibrary::CModelLibrary()
{
s_pModelLibrary = this;
}
CModelLibrary::~CModelLibrary()
{
for (size_t i = 0; i < m_apModels.size(); i++)
{
delete m_apModels[i];
}
s_pModelLibrary = NULL;
}
size_t CModelLibrary::AddModel(const tstring& sModel, bool bStatic)
{
if (!sModel.length())
return 0;
size_t iModel = FindModel(sModel);
if (iModel != ~0)
return iModel;
m_apModels.push_back(new CModel(sModel));
iModel = m_apModels.size()-1;
m_apModels[iModel]->m_iCallList = CRenderer::CreateCallList(iModel);
m_apModels[iModel]->m_bStatic = bStatic;
return iModel;
}
CModel* CModelLibrary::GetModel(size_t i)
{
if (i >= m_apModels.size())
return NULL;
return m_apModels[i];
}
size_t CModelLibrary::FindModel(const tstring& sModel)
{
for (size_t i = 0; i < m_apModels.size(); i++)
{
if (m_apModels[i]->m_sFilename == sModel)
return i;
}
return ~0;
}
CModel::CModel(const tstring& sFilename)
{
m_sFilename = sFilename;
m_pScene = new CConversionScene();
m_bStatic = false;
m_iCallList = 0;
m_iCallListTexture = 0;
CModelConverter c(m_pScene);
c.ReadModel(sFilename);
m_aiTextures.resize(m_pScene->GetNumMaterials());
for (size_t i = 0; i < m_pScene->GetNumMaterials(); i++)
{
m_aiTextures[i] = LoadTextureIntoGL(i);
m_pScene->GetMaterial(i)->m_vecDiffuse = Vector(1, 1, 1);
}
}
CModel::~CModel()
{
delete m_pScene;
}
size_t CModel::LoadTextureIntoGL(size_t iMaterial)
{
return CTextureLibrary::AddTextureID(m_pScene->GetMaterial(iMaterial)->GetDiffuseTexture());
}
| 21 | 94 | 0.685606 | [
"vector"
] |
b051ceafedf85fe591e23beb1627a2f8833cfce5 | 624 | cpp | C++ | src/linux/linux_process.cpp | nickrioux/CppND-System-Monitor-Project-Updated | b27d7692583b5ca42d7b91c3b239a78b8244bb9b | [
"MIT"
] | null | null | null | src/linux/linux_process.cpp | nickrioux/CppND-System-Monitor-Project-Updated | b27d7692583b5ca42d7b91c3b239a78b8244bb9b | [
"MIT"
] | null | null | null | src/linux/linux_process.cpp | nickrioux/CppND-System-Monitor-Project-Updated | b27d7692583b5ca42d7b91c3b239a78b8244bb9b | [
"MIT"
] | null | null | null | #include <unistd.h>
#include <cctype>
#include <sstream>
#include <string>
#include <vector>
#include "linux/linux_parser.h"
#include "linux/linux_process.h"
using std::string;
using std::to_string;
using std::vector;
// Process Constructor
Linux_Process::Linux_Process(const int& pid)
: Process(pid, LinuxParser::User(pid), LinuxParser::Command(pid)) {
// Contructor
}
// Return this process's memory utilization
string Linux_Process::Ram() const { return (LinuxParser::Ram(Pid())); }
// Return the age of this process (in seconds)
long int Linux_Process::UpTime() const { return (LinuxParser::UpTime(Pid())); } | 24.96 | 79 | 0.725962 | [
"vector"
] |
b05a8e727fc382cbf51e5a012530f05ec0d332e9 | 680 | hpp | C++ | plugins/d3d9/include/sge/d3d9/state/core/sampler/state_vector.hpp | cpreh/spacegameengine | 313a1c34160b42a5135f8223ffaa3a31bc075a01 | [
"BSL-1.0"
] | 2 | 2016-01-27T13:18:14.000Z | 2018-05-11T01:11:32.000Z | plugins/d3d9/include/sge/d3d9/state/core/sampler/state_vector.hpp | cpreh/spacegameengine | 313a1c34160b42a5135f8223ffaa3a31bc075a01 | [
"BSL-1.0"
] | null | null | null | plugins/d3d9/include/sge/d3d9/state/core/sampler/state_vector.hpp | cpreh/spacegameengine | 313a1c34160b42a5135f8223ffaa3a31bc075a01 | [
"BSL-1.0"
] | 3 | 2018-05-11T01:11:34.000Z | 2021-04-24T19:47:45.000Z | // Copyright Carl Philipp Reh 2006 - 2019.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef SGE_D3D9_STATE_CORE_SAMPLER_STATE_VECTOR_HPP_INCLUDED
#define SGE_D3D9_STATE_CORE_SAMPLER_STATE_VECTOR_HPP_INCLUDED
#include <sge/d3d9/state/core/sampler/state.hpp>
#include <fcppt/config/external_begin.hpp>
#include <vector>
#include <fcppt/config/external_end.hpp>
namespace sge
{
namespace d3d9
{
namespace state
{
namespace core
{
namespace sampler
{
typedef std::vector<sge::d3d9::state::core::sampler::state> state_vector;
}
}
}
}
}
#endif
| 20 | 73 | 0.757353 | [
"vector"
] |
b068ff40e49ece688267395b16d2ec98f5e06607 | 1,267 | cpp | C++ | Unique/unique.cpp | LEOBox/Algorithms | be53dceb44bbecb0ce714aea7f2aeeff1be98d2a | [
"MIT"
] | null | null | null | Unique/unique.cpp | LEOBox/Algorithms | be53dceb44bbecb0ce714aea7f2aeeff1be98d2a | [
"MIT"
] | null | null | null | Unique/unique.cpp | LEOBox/Algorithms | be53dceb44bbecb0ce714aea7f2aeeff1be98d2a | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//use left indicator as base indicator
void unique_left_point(vector<int> &v);
//use right indicator as base indicator
void unique_right_point(vector<int> &v);
int main() {
vector<int> v = {3,2,6,3,7,4,6,7,8,1,0,3,5};
unique_left_point(v);
unique_right_point(v);
return 0;
}
void unique_left_point(vector<int> &v) {
//sort the vector
sort(v.begin(), v.end());
//unique the element and cout the number of each element in vector
for (size_t L = 0, R; L < v.size(); L = R) {
for (R = L+1; R < v.size(); ++R) {
if (v[L] != v[R]) {
break;
}
}
std::cout << v[L] << ":" << R-L << std::endl;
}
}
void unique_right_point(vector<int> &v) {
//sort the vector
sort(v.begin(), v.end());
//init left and right indicator
size_t L,R;
//unique the element and cout the number of each element in vector
for (L=0,R=0; R < v.size(); ++R) {
if (v[L] != v[R]) {
std::cout << v[L] << ":" << R-L << std::endl;
L = R;
}
}
//don't forget the tail!!!
if (v.size() > 0) {
std::cout << v[L] << ":" << R-L << std::endl;
}
}
| 24.365385 | 70 | 0.522494 | [
"vector"
] |
b0715fcccf33dd2cf1b673f95a986231dac31c0d | 35,385 | cxx | C++ | OOFSWIG/SWIG/scanner.cxx | usnistgov/OOF3D | 4fd423a48aea9c5dc207520f02de53ae184be74c | [
"X11"
] | 31 | 2015-04-01T15:59:36.000Z | 2022-03-18T20:21:47.000Z | OOFSWIG/SWIG/scanner.cxx | usnistgov/OOF3D | 4fd423a48aea9c5dc207520f02de53ae184be74c | [
"X11"
] | 3 | 2015-02-06T19:30:24.000Z | 2017-05-25T14:14:31.000Z | OOFSWIG/SWIG/scanner.cxx | usnistgov/OOF3D | 4fd423a48aea9c5dc207520f02de53ae184be74c | [
"X11"
] | 7 | 2015-01-23T15:19:22.000Z | 2021-06-09T09:03:59.000Z | /*******************************************************************************
* Simplified Wrapper and Interface Generator (SWIG)
*
* Author : David Beazley
*
* Department of Computer Science
* University of Chicago
* 1100 E 58th Street
* Chicago, IL 60637
* beazley@cs.uchicago.edu
*
* Please read the file LICENSE for the copyright and terms by which SWIG
* can be used and distributed.
*******************************************************************************/
/*************************************************************************
* $Header: /users/langer/FE/CVSoof/OOF2/OOFSWIG/SWIG/scanner.cxx,v 1.1.2.2 2014/06/27 20:28:33 langer Exp $
* scanner.c
*
* Dave Beazley
* January 1996
*
* Input scanner. This scanner finds and returns tokens
* for the wrapper generator. Since using lex/flex from
* C++ is so F'ed up, I've written this function to replace
* them entirely. It's not as fast, but hopefully it will
* eliminate alot of compilation problems.
*
*************************************************************************/
#include "internal.h"
#include "parser.h"
#include <string.h>
#include <ctype.h>
#define YYBSIZE 8192
struct InFile {
FILE *f;
int line_number;
char *in_file;
int extern_mode;
int force_extern;
struct InFile *prev;
};
// This structure is used for managing code fragments as
// might be used by the %inline directive and handling of
// nested structures.
struct CodeFragment {
char *text;
int line_number;
CodeFragment *next;
};
InFile *in_head;
FILE *LEX_in = NULL;
static String header;
static String comment;
String CCode; // String containing C code
static char *yybuffer;
static int lex_pos = 0;
static int lex_len = 0;
static char *inline_yybuffer = 0;
static int inline_lex_pos = 0;
static int inline_lex_len = 0;
static int inline_line_number = 0;
static CodeFragment *fragments = 0; // Code fragments
static
char yytext[YYBSIZE];
static int yylen = 0;
int line_number = 1;
int column = 1;
int column_start = 1;
char *input_file;
int start_line = 0;
static int comment_start;
static int scan_init = 0;
static int num_brace = 0;
static int last_brace = 0;
static int in_define = 0;
static int define_first_id = 0; /* Set when looking for first identifier of a define */
extern int Error;
/**************************************************************
* scanner_init()
*
* Initialize buffers
**************************************************************/
void scanner_init() {
yybuffer = (char *) malloc(YYBSIZE);
scan_init = 1;
}
/**************************************************************
* scanner_file(FILE *f)
*
* Start reading from new file
**************************************************************/
void scanner_file(FILE *f) {
InFile *in;
in = new InFile;
in->f = f;
in->in_file = input_file;
in->extern_mode = WrapExtern;
in->force_extern = ForceExtern;
if (in_head) in_head->line_number = line_number+1;
if (!in_head) in->prev = 0;
else in->prev = in_head;
in_head = in;
LEX_in = f;
line_number = 1;
}
/**************************************************************
* scanner_close()
*
* Close current input file and go to next
**************************************************************/
void scanner_close() {
InFile *p;
static int lib_insert = 0;
fclose(LEX_in);
if (!in_head) return;
p = in_head->prev;
if (p != 0) {
LEX_in = p->f;
line_number = p->line_number;
input_file = p->in_file;
WrapExtern = p->extern_mode;
if (!WrapExtern) remove_symbol((char*)"SWIGEXTERN");
ForceExtern = p->force_extern;
} else {
LEX_in = NULL;
}
delete in_head;
in_head = p;
// if LEX_in is NULL it means we're done with the interface file. We're now
// going to grab all of the library files.
if ((!LEX_in) && (!lib_insert)) {
library_insert();
lib_insert = 1;
}
}
/**************************************************************
* char nextchar()
*
* gets next character from input.
* If we're in inlining mode, we actually retrieve a character
* from inline_yybuffer instead.
**************************************************************/
char nextchar() {
char c = 0;
if (Inline) {
if (inline_lex_pos >= inline_lex_len) {
// Done with inlined code. Check to see if we have any
// new code fragments. If so, switch to them.
delete inline_yybuffer;
if (fragments) {
CodeFragment *f;
inline_yybuffer = fragments->text;
inline_lex_pos = 1;
inline_lex_len = strlen(fragments->text);
line_number = fragments->line_number;
f = fragments->next;
delete fragments;
fragments = f;
c = inline_yybuffer[0];
} else {
c = 0;
Inline = 0;
line_number = inline_line_number; // Restore old line number
}
} else {
inline_lex_pos++;
c = inline_yybuffer[inline_lex_pos-1];
}
}
if (!Inline) {
if (lex_pos >= lex_len) {
if (!LEX_in) {
SWIG_exit(1);
}
while(fgets(yybuffer, YYBSIZE, LEX_in) == NULL) {
scanner_close(); // Close current input file
if (!LEX_in) return 0; // No more, we're outta here
}
lex_len = strlen(yybuffer);
lex_pos = 0;
}
lex_pos++;
c = yybuffer[lex_pos-1];
}
if (yylen >= YYBSIZE) {
fprintf(stderr,"** FATAL ERROR. Buffer overflow in scanner.cxx.\nReport this to swig@cs.utah.edu.\n");
SWIG_exit(1);
}
yytext[yylen] = c;
yylen++;
if (c == '\n') {
line_number++;
column = 1;
} else {
column++;
}
return(c);
}
void retract(int n) {
int i, j, c;
for (i = 0; i < n; i++) {
if (Inline) {
inline_lex_pos--;
if (inline_lex_pos < 0) {
fprintf(stderr,"Internal scanner error. inline_lex_pos < 0\n");
SWIG_exit(1);
}
}
else lex_pos--;
yylen--;
column--;
if (yylen >= 0) {
if (yytext[yylen] == '\n') {
line_number--;
// Figure out what column we're in
c = yylen-1;
j = 1;
while (c >= 0){
if (yytext[c] == '\n') break;
j++;
c--;
}
column = j;
}
}
}
if (yylen < 0) yylen = 0;
}
/**************************************************************
* start_inline(char *text, int line)
*
* This grabs a chunk of text and tries to inline it into
* the current file. (This is kind of wild, but cool when
* it works).
*
* If we're already in inlining mode, we will save the code
* as a new fragment.
**************************************************************/
void start_inline(char *text, int line) {
if (Inline) {
// Already processing a code fragment, simply hang on
// to this one for later.
CodeFragment *f,*f1;
// Add a new code fragment to our list
f = new CodeFragment;
f->text = copy_string(text);
f->line_number = line;
f->next = 0;
if (!fragments) fragments = f;
else {
f1 = fragments;
while (f1->next) f1 = f1->next;
f1->next = f;
}
} else {
// Switch our scanner over to process text from a string.
// Save current line number and other information however.
inline_yybuffer = copy_string(text);
inline_lex_len = strlen(text);
inline_lex_pos = 0;
inline_line_number = line_number; // Make copy of old line number
line_number = line;
Inline = 1;
}
}
/**************************************************************
* yycomment(char *, int line)
*
* Inserts a comment into a documentation entry.
**************************************************************/
void yycomment(char *s, int line, int col) {
comment_handler->add_comment(s,line,col,input_file);
}
/**************************************************************
* void skip_brace(void)
*
* Found a {.
* Skip all characters until we find a matching closed }.
*
* This function is used to skip over inlined C code and other
* garbage found in interface files.
***************************************************************/
void skip_brace(void) {
char c;
CCode = "{";
while (num_brace > last_brace) {
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : Line %d. Missing '}'. Reached end of input.\n",
input_file, line_number);
FatalError();
return;
}
CCode << c;
if (c == '{') num_brace++;
if (c == '}') num_brace--;
yylen = 0;
}
}
/**************************************************************
* void skip_template(void)
*
* Found a <.
* Skip all characters until we find a matching closed >.
*
* This function is used to skip over C++ templated types
* and objective-C protocols.
***************************************************************/
void skip_template(void) {
char c;
CCode = "<";
int num_lt = 1;
while (num_lt > 0) {
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : Line %d. Missing '>'. Reached end of input.\n",
input_file, line_number);
FatalError();
return;
}
CCode << c;
if (c == '<') num_lt++;
if (c == '>') num_lt--;
yylen = 0;
}
}
/**************************************************************
* void skip_to_end(void)
*
* Skips to the @end directive in a Objective-C definition
**************************************************************/
void skip_to_end(void) {
char c;
int state = 0;
yylen = 0;
while ((c = nextchar())){
switch(state) {
case 0:
if (c == '@') state = 1;
else yylen = 0;
break;
case 1:
if (isspace(c)) {
if (strncmp(yytext,"@end",4) == 0) return;
else {
yylen = 0;
state = 0;
}
} else {
state = 1;
}
break;
}
}
fprintf(stderr,"%s : EOF. Missing @end. Reached end of input.\n",
input_file);
FatalError();
return;
}
/**************************************************************
* void skip_decl(void)
*
* This tries to skip over an entire declaration. For example
*
* friend ostream& operator<<(ostream&, const char *s);
*
* or
* friend ostream& operator<<(ostream&, const char *s) { };
*
**************************************************************/
void skip_decl(void) {
char c;
int done = 0;
while (!done) {
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : Line %d. Missing semicolon. Reached end of input.\n",
input_file, line_number);
FatalError();
return;
}
if (c == '{') {
last_brace = num_brace;
num_brace++;
break;
}
yylen = 0;
if (c == ';') done = 1;
}
if (!done) {
while (num_brace > last_brace) {
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : Line %d. Missing '}'. Reached end of input.\n",
input_file, line_number);
FatalError();
return;
}
if (c == '{') num_brace++;
if (c == '}') num_brace--;
yylen = 0;
}
}
}
/**************************************************************
* void skip_define(void)
*
* Skips to the end of a #define statement.
*
**************************************************************/
void skip_define(void) {
char c;
while (in_define) {
if ((c = nextchar()) == 0) return;
if (c == '\\') in_define = 2;
if (c == '\n') {
if (in_define == 2) {
in_define = 1;
} else if (in_define == 1) {
in_define = 0;
}
}
yylen = 0;
}
}
/**************************************************************
* int skip_cond(int inthen)
*
* Skips the false portion of an #ifdef directive. Looks
* for either a matching #else or #endif
*
* inthen is 0 or 1 depending on whether or not we're
* handling the "then" or "else" part of a conditional.
*
* Returns 1 if the else part of the #if-#endif block was
* reached. Returns 0 otherwise. Returns -1 on error.
**************************************************************/
int skip_cond(int inthen) {
int level = 0; /* Used to handled nested if-then-else */
int state = 0;
char c;
int start_line;
char *file;
file = copy_string(input_file);
start_line = line_number;
yylen = 0;
while(1) {
switch(state) {
case 0 :
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : Line %d. Unterminated #if-else directive.\n", file, start_line);
FatalError();
return -1; /* Error */
}
if ((c == '#') || (c == '%')) {
state = 1;
} else if (isspace(c)) {
yylen =0;
state = 0;
} else {
/* Some non-whitespace character. Look for line end */
yylen = 0;
state = 3;
}
break;
case 1:
/* Beginning of a C preprocessor statement */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : Line %d. Unterminated #if-else directive.\n", file, start_line);
FatalError();
return -1; /* Error */
}
if (c == '\n') {
state = 0;
yylen = 0;
}
else if (isspace(c)) {
state = 1;
yylen--;
} else {
state = 2;
}
break;
case 2:
/* CPP directive */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : Line %d. Unterminated #if-else directive.\n", file, start_line);
FatalError();
return -1; /* Error */
}
if ((c == ' ') || (c == '\t') || (c=='\n')) {
yytext[yylen-1] = 0;
if ((strcmp(yytext,"#ifdef") == 0) || (strcmp(yytext,"%ifdef") == 0)) {
level++;
state = 0;
} else if ((strcmp(yytext,"#ifndef") == 0) || (strcmp(yytext,"%ifndef") == 0)) {
level++;
state = 0;
} else if ((strcmp(yytext,"#if") == 0) || (strcmp(yytext,"%if") == 0)) {
level++;
state = 0;
} else if ((strcmp(yytext,"#else") == 0) || (strcmp(yytext,"%else") == 0)) {
if (level == 0) { /* Found matching else. exit */
if (!inthen) {
/* Hmmm. We've got an "extra #else" directive here */
fprintf(stderr,"%s : Line %d. Misplaced #else.\n", input_file, line_number);
FatalError();
yylen = 0;
state = 0;
} else {
yylen = 0;
delete file;
return 1;
}
} else {
yylen = 0;
state = 0;
}
} else if ((strcmp(yytext,"#endif") == 0) || (strcmp(yytext,"%endif") == 0)) {
if (level <= 0) { /* Found matching endif. exit */
yylen = 0;
delete file;
return 0;
} else {
state = 0;
yylen = 0;
level--;
}
} else if ((strcmp(yytext,"#elif") == 0) || (strcmp(yytext,"%elif") == 0)) {
if (level <= 0) {
// If we come across this, we pop it back onto the input queue and return
retract(6);
delete file;
return 0;
} else {
yylen = 0;
state = 0;
}
} else {
yylen = 0;
state = 0;
}
}
break;
case 3:
/* Non-white space. Look for line break */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : Line %d. Unterminated #if directive.\n", file, start_line);
FatalError();
return -1; /* Error */
}
if (c == '\n') {
yylen = 0;
state = 0;
} else {
yylen = 0;
state = 3;
}
break;
}
}
}
/**************************************************************
* int yylook()
*
* Lexical scanner.
* See Aho,Sethi, and Ullman, pg. 106
**************************************************************/
int yylook(void) {
int state;
char c = 0;
state = 0;
yylen = 0;
while(1) {
/* printf("State = %d\n", state); */
switch(state) {
case 0 :
if((c = nextchar()) == 0) return(0);
/* Process delimeters */
if (c == '\n') {
state = 0;
yylen = 0;
if (in_define == 1) {
in_define = 0;
return(ENDDEF);
} else if (in_define == 2) {
in_define = 1;
}
} else if (isspace(c)) {
state = 0;
yylen = 0;
}
/* Look for single character symbols */
else if (c == '(') return (LPAREN);
else if (c == ')') return (RPAREN);
else if (c == ';') return (SEMI);
else if (c == ',') return (COMMA);
else if (c == '*') return (STAR);
else if (c == '}') {
num_brace--;
if (num_brace < 0) {
fprintf(stderr,"%s : Line %d. Error. Extraneous '}' (Ignored)\n",
input_file, line_number);
state = 0;
num_brace = 0;
} else {
return (RBRACE);
}
}
else if (c == '{') {
last_brace = num_brace;
num_brace++;
return (LBRACE);
}
else if (c == '=') return (EQUAL);
else if (c == '+') return (PLUS);
else if (c == '-') return (MINUS);
else if (c == '&') return (AND);
else if (c == '|') return (OR);
else if (c == '^') return (XOR);
else if (c == '<') state = 60;
else if (c == '>') state = 61;
else if (c == '~') return (NOT);
else if (c == '!') return (LNOT);
else if (c == '\\') {
if (in_define == 1) {
in_define = 2;
state = 0;
} else
state = 99;
}
else if (c == '[') return (LBRACKET);
else if (c == ']') return (RBRACKET);
/* Look for multi-character sequences */
else if (c == '/') state = 1; // Comment (maybe)
else if (c == '\"') state = 2; // Possibly a string
else if (c == '#') state = 3; // CPP
else if (c == '%') state = 4; // Directive
else if (c == '@') state = 4; // Objective C keyword
else if (c == ':') state = 5; // maybe double colon
else if (c == '0') state = 83; // An octal or hex value
else if (c == '\'') state = 9; // A character constant
else if (c == '.') state = 100; // Maybe a number, maybe just a period
else if (isdigit(c)) state = 8; // A numerical value
else if ((isalpha(c)) || (c == '_') || (c == '$')) state = 7;
else state = 99;
break;
case 1: /* Comment block */
if ((c = nextchar()) == 0) return(0);
if (c == '/') {
comment_start = line_number;
column_start = column;
comment = " ";
state = 10; // C++ style comment
} else if (c == '*') {
comment_start = line_number;
column_start = column;
comment = " ";
state = 11; // C style comment
} else {
retract(1);
return(SLASH);
}
break;
case 10: /* C++ style comment */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : EOF. Unterminated comment detected.\n",input_file);
FatalError();
return 0;
}
if (c == '\n') {
comment << c;
// Add the comment to documentation
yycomment(comment.get(),comment_start, column_start);
yylen = 0;
state = 0;
if (in_define == 1) {
in_define = 0;
return(ENDDEF);
}
} else {
state = 10;
comment << c;
yylen = 0;
}
break;
case 11: /* C style comment block */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : EOF. Unterminated comment detected.\n", input_file);
FatalError();
return 0;
}
if (c == '*') {
state = 12;
} else {
comment << c;
yylen = 0;
state = 11;
}
break;
case 12: /* Still in C style comment */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : EOF. Unterminated comment detected.\n", input_file);
FatalError();
return 0;
}
if (c == '*') {
comment << c;
state = 12;
} else if (c == '/') {
comment << " \n";
yycomment(comment.get(),comment_start,column_start);
yylen = 0;
state = 0;
} else {
comment << '*' << c;
yylen = 0;
state = 11;
}
break;
case 2: /* Processing a string */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : EOF. Unterminated string detected.\n", input_file);
FatalError();
return 0;
}
if (c == '\"') {
yytext[yylen-1] = 0;
yylval.id = copy_string(yytext+1);
return(STRING);
} else if (c == '\\') {
state = 21; /* Possibly an escape sequence. */
break;
} else state = 2;
break;
case 21: /* An escape sequence. get next character, then go
back to processing strings */
if ((c = nextchar()) == 0) return 0;
state = 2;
break;
case 3: /* a CPP directive */
if (( c= nextchar()) == 0) return 0;
if (c == '\n') {
retract(1);
yytext[yylen] = 0;
yylval.id = yytext;
return(POUND);
} else if ((c == ' ') || (c == '\t')) { // Ignore white space after # symbol
yytext[yylen] = 0;
yylen--;
state = 3;
} else {
yytext[yylen] = 0;
state = 31;
}
break;
case 31:
if ((c = nextchar()) == 0) return 0;
if ((c == ' ') || (c == '\t') || (c=='\n')) {
retract(1);
yytext[yylen] = 0;
if (strcmp(yytext,"#define") == 0) {
in_define = 1;
define_first_id = 1;
return(DEFINE);
} else if (strcmp(yytext,"#ifdef") == 0) {
return(IFDEF);
} else if (strcmp(yytext,"#ifndef") == 0) {
return(IFNDEF);
} else if (strcmp(yytext,"#else") == 0) {
return(ELSE);
} else if (strcmp(yytext,"#endif") == 0) {
return(ENDIF);
} else if (strcmp(yytext,"#undef") == 0) {
return(UNDEF);
} else if (strcmp(yytext,"#if") == 0) {
return(IF);
} else if (strcmp(yytext,"#elif") == 0) {
return(ELIF);
} else {
/* Some kind of "unknown CPP directive. Skip to end of the line */
state = 32;
}
}
break;
case 32:
if ((c = nextchar()) == 0) return 0;
if (c == '\n') {
retract(1);
yytext[yylen] = 0;
yylval.id = yytext;
return(POUND);
}
state = 32;
break;
case 4: /* A wrapper generator directive (maybe) */
if (( c= nextchar()) == 0) return 0;
if (c == '{') {
state = 40; /* Include block */
header = "";
start_line = line_number;
}
else if ((isalpha(c)) || (c == '_')) state = 7;
else {
retract(1);
state = 99;
}
break;
case 40: /* Process an include block */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : EOF. Unterminated include block detected.\n", input_file);
FatalError();
return 0;
}
yylen = 0;
if (c == '%') state = 41;
else {
header << c;
yylen = 0;
state = 40;
}
break;
case 41: /* Still processing include block */
if ((c = nextchar()) == 0) {
fprintf(stderr,"%s : EOF. Unterminated include block detected.\n", input_file);
FatalError();
return 0;
}
if (c == '}') {
yylval.id = header.get();
return(HBLOCK);
} else {
header << '%';
header << c;
yylen = 0;
state = 40;
}
break;
case 5: /* Maybe a double colon */
if (( c= nextchar()) == 0) return 0;
if ( c == ':') return DCOLON;
else {
retract(1);
return COLON;
}
case 60: /* shift operators */
if ((c = nextchar()) == 0) return (0);
if (c == '<') return LSHIFT;
else {
retract(1);
return LESSTHAN;
}
break;
case 61:
if ((c = nextchar()) == 0) return (0);
if (c == '>') return RSHIFT;
else {
retract(1);
return GREATERTHAN;
}
break;
case 7: /* Identifier */
if ((c = nextchar()) == 0) return(0);
if (isalnum(c) || (c == '_') || (c == '.') || (c == '$'))
// || (c == '.') || (c == '-'))
state = 7;
else if (c == '(') {
/* We might just be in a CPP macro definition. Better check */
if ((in_define) && (define_first_id)) {
/* Yep. We're going to ignore the rest of it */
skip_define();
define_first_id = 0;
return (MACRO);
} else {
retract(1);
define_first_id = 0;
return(ID);
}
} else {
retract(1);
define_first_id = 0;
return(ID);
}
break;
case 8: /* A numerical digit */
if ((c = nextchar()) == 0) return(0);
if (c == '.') {state = 81;}
else if ((c == 'e') || (c == 'E')) {state = 86;}
else if ((c == 'f') || (c == 'F')) {
yytext[yylen] = 0;
yylval.id = copy_string(yytext);
return(NUM_FLOAT);
}
else if (isdigit(c)) { state = 8;}
else if ((c == 'l') || (c == 'L')) {
state = 87;
} else if ((c == 'u') || (c == 'U')) {
state = 88;
} else {
retract(1);
yytext[yylen] = 0;
yylval.id = copy_string(yytext);
return(NUM_INT);
}
break;
case 81: /* A floating pointer number of some sort */
if ((c = nextchar()) == 0) return(0);
if (isdigit(c)) state = 81;
else if ((c == 'e') || (c == 'E')) state = 82;
else if ((c == 'f') || (c == 'F') || (c == 'l') || (c == 'L')) {
yytext[yylen] = 0;
yylval.id = copy_string(yytext);
return(NUM_FLOAT);
} else {
retract(1);
yytext[yylen] = 0;
yylval.id = copy_string(yytext);
return(NUM_FLOAT);
}
break;
case 82:
if ((c = nextchar()) == 0) return(0);
if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86;
else {
retract(2);
yytext[yylen-1] = 0;
yylval.id = copy_string(yytext);
return(NUM_INT);
}
break;
case 83:
/* Might be a hexidecimal or octal number */
if ((c = nextchar()) == 0) return(0);
if (isdigit(c)) state = 84;
else if ((c == 'x') || (c == 'X')) state = 85;
else if (c == '.') state = 81;
else if ((c == 'l') || (c == 'L')) {
state = 87;
} else if ((c == 'u') || (c == 'U')) {
state = 88;
} else {
retract(1);
yytext[yylen] = 0;
yylval.id = copy_string(yytext);
return(NUM_INT);
}
break;
case 84:
/* This is an octal number */
if ((c = nextchar()) == 0) return (0);
if (isdigit(c)) state = 84;
else if ((c == 'l') || (c == 'L')) {
state = 87;
} else if ((c == 'u') || (c == 'U')) {
state = 88;
} else {
retract(1);
yytext[yylen] = 0;
yylval.id = copy_string(yytext);
return(NUM_INT);
}
break;
case 85:
/* This is an hex number */
if ((c = nextchar()) == 0) return (0);
if ((isdigit(c)) || (c=='a') || (c=='b') || (c=='c') ||
(c=='d') || (c=='e') || (c=='f') || (c=='A') ||
(c=='B') || (c=='C') || (c=='D') || (c=='E') ||
(c=='F'))
state = 85;
else if ((c == 'l') || (c == 'L')) {
state = 87;
} else if ((c == 'u') || (c == 'U')) {
state = 88;
} else {
retract(1);
yytext[yylen] = 0;
yylval.id = copy_string(yytext);
return(NUM_INT);
}
break;
case 86:
/* Rest of floating point number */
if ((c = nextchar()) == 0) return (0);
if (isdigit(c)) state = 86;
else if ((c == 'f') || (c == 'F') || (c == 'l') || (c == 'L')) {
yytext[yylen] = 0;
yylval.id = copy_string(yytext);
return(NUM_FLOAT);
} else {
retract(1);
yytext[yylen] = 0;
yylval.id = copy_string(yytext);
return(NUM_FLOAT);
}
/* Parse a character constant. ie. 'a' */
break;
case 87 :
/* A long integer of some sort */
if ((c = nextchar()) == 0) return (0);
if ((c == 'u') || (c == 'U')) {
yytext[yylen] = 0;
yylval.id = copy_string(yytext);
return(NUM_ULONG);
} else {
retract(1);
yytext[yylen] = 0;
yylval.id = copy_string(yytext);
return(NUM_LONG);
}
case 88:
/* An unsigned integer of some sort */
if ((c = nextchar()) == 0) return (0);
if ((c == 'l') || (c == 'L')) {
yytext[yylen] = 0;
yylval.id = copy_string(yytext);
return(NUM_ULONG);
} else {
retract(1);
yytext[yylen] = 0;
yylval.id = copy_string(yytext);
return(NUM_UNSIGNED);
}
case 9:
if ((c = nextchar()) == 0) return (0);
if (c == '\'') {
yytext[yylen-1] = 0;
yylval.id = copy_string(yytext+1);
return(CHARCONST);
}
break;
case 100:
if ((c = nextchar()) == 0) return (0);
if (isdigit(c)) state = 81;
else {
retract(1);
return(PERIOD);
}
break;
default:
if (!Error) {
fprintf(stderr,"%s : Line %d ::Illegal character '%c'=%d.\n",input_file, line_number,c,c);
FatalError();
}
state = 0;
Error = 1;
return(ILLEGAL);
}
}
}
static int check_typedef = 0;
void scanner_check_typedef() {
check_typedef = 1;
}
void scanner_ignore_typedef() {
check_typedef = 0;
}
/**************************************************************
* int yylex()
*
* Gets the lexene and returns tokens.
*************************************************************/
extern "C" int yylex(void) {
int l;
if (!scan_init) {
scanner_init();
// if (LEX_in == NULL) LEX_in = stdin;
// scanner_file(LEX_in);
}
l = yylook();
/* We got some sort of non-white space object. We set the start_line
variable unless it has already been set */
if (!start_line) {
start_line = line_number;
}
/* Copy the lexene */
yytext[yylen] = 0;
/* Hack to support ignoring of CPP macros */
if (l != DEFINE) {
define_first_id = 0;
}
switch(l) {
case ID:
/* Look for keywords now */
if (strcmp(yytext,"int") == 0) {
yylval.type = new DataType;
yylval.type->type = T_INT;
strcpy(yylval.type->name,yytext);
return(TYPE_INT);
}
if (strcmp(yytext,"double") == 0) {
yylval.type = new DataType;
yylval.type->type = T_DOUBLE;
strcpy(yylval.type->name,yytext);
return(TYPE_DOUBLE);
}
if (strcmp(yytext,"void") == 0) {
yylval.type = new DataType;
yylval.type->type = T_VOID;
strcpy(yylval.type->name,yytext);
return(TYPE_VOID);
}
if (strcmp(yytext,"char") == 0) {
yylval.type = new DataType;
yylval.type->type = T_CHAR;
strcpy(yylval.type->name,yytext);
return(TYPE_CHAR);
}
if (strcmp(yytext,"short") == 0) {
yylval.type = new DataType;
yylval.type->type = T_SHORT;
strcpy(yylval.type->name,yytext);
return(TYPE_SHORT);
}
if (strcmp(yytext,"long") == 0) {
yylval.type = new DataType;
yylval.type->type = T_LONG;
strcpy(yylval.type->name,yytext);
return(TYPE_LONG);
}
if (strcmp(yytext,"float") == 0) {
yylval.type = new DataType;
yylval.type->type = T_FLOAT;
strcpy(yylval.type->name,yytext);
return(TYPE_FLOAT);
}
if (strcmp(yytext,"signed") == 0) {
yylval.type = new DataType;
yylval.type->type = T_SINT;
strcpy(yylval.type->name,yytext);
return(TYPE_SIGNED);
}
if (strcmp(yytext,"unsigned") == 0) {
yylval.type = new DataType;
yylval.type->type = T_UINT;
strcpy(yylval.type->name,yytext);
return(TYPE_UNSIGNED);
}
if (strcmp(yytext,"bool") == 0) {
yylval.type = new DataType;
yylval.type->type = T_BOOL;
strcpy(yylval.type->name,yytext);
return(TYPE_BOOL);
}
// C++ keywords
if (CPlusPlus) {
if (strcmp(yytext,"class") == 0) return(CLASS);
if (strcmp(yytext,"private") == 0) return(PRIVATE);
if (strcmp(yytext,"public") == 0) return(PUBLIC);
if (strcmp(yytext,"protected") == 0) return(PROTECTED);
if (strcmp(yytext,"friend") == 0) return(FRIEND);
if (strcmp(yytext,"virtual") == 0) return(VIRTUAL);
if (strcmp(yytext,"operator") == 0) return(OPERATOR);
if (strcmp(yytext,"throw") == 0) return(THROW);
if (strcmp(yytext,"inline") == 0) return(yylex());
if (strcmp(yytext,"template") == 0) return(TEMPLATE);
}
// Objective-C keywords
if (ObjC) {
if (strcmp(yytext,"@interface") == 0) return (OC_INTERFACE);
if (strcmp(yytext,"@end") == 0) return (OC_END);
if (strcmp(yytext,"@public") == 0) return (OC_PUBLIC);
if (strcmp(yytext,"@private") == 0) return (OC_PRIVATE);
if (strcmp(yytext,"@protected") == 0) return (OC_PROTECTED);
if (strcmp(yytext,"@class") == 0) return(OC_CLASS);
if (strcmp(yytext,"@implementation") == 0) return(OC_IMPLEMENT);
if (strcmp(yytext,"@protocol") == 0) return(OC_PROTOCOL);
}
// Misc keywords
if (strcmp(yytext,"static") == 0) return(STATIC);
if (strcmp(yytext,"extern") == 0) return(EXTERN);
if (strcmp(yytext,"const") == 0) return(CONST);
if (strcmp(yytext,"struct") == 0) return(STRUCT);
if (strcmp(yytext,"union") == 0) return(UNION);
if (strcmp(yytext,"enum") == 0) return(ENUM);
if (strcmp(yytext,"sizeof") == 0) return(SIZEOF);
if (strcmp(yytext,"defined") == 0) return(DEFINED);
// Ignored keywords
if (strcmp(yytext,"volatile") == 0) return(yylex());
// SWIG directives
if (strcmp(yytext,"%module") == 0) return(MODULE);
if (strcmp(yytext,"%init") == 0) return(INIT);
if (strcmp(yytext,"%wrapper") == 0) return(WRAPPER);
if (strcmp(yytext,"%readonly") == 0) return(READONLY);
if (strcmp(yytext,"%readwrite") == 0) return(READWRITE);
if (strcmp(yytext,"%name") == 0) return(NAME);
if (strcmp(yytext,"%rename") == 0) return(RENAME);
if (strcmp(yytext,"%include") == 0) return(INCLUDE);
if (strcmp(yytext,"%extern") == 0) return(WEXTERN);
if (strcmp(yytext,"%checkout") == 0) return(CHECKOUT);
if (strcmp(yytext,"%val") == 0) return(CVALUE);
if (strcmp(yytext,"%out") == 0) return(COUT);
if (strcmp(yytext,"%section") == 0) {
yylval.ivalue = line_number;
return(SECTION);
}
if (strcmp(yytext,"%subsection") == 0) {
yylval.ivalue = line_number;
return(SUBSECTION);
}
if (strcmp(yytext,"%subsubsection") == 0) {
yylval.ivalue = line_number;
return (SUBSUBSECTION);
}
if (strcmp(yytext,"%title") == 0) {
yylval.ivalue = line_number;
return(TITLE);
}
if (strcmp(yytext,"%style") == 0) return(STYLE);
if (strcmp(yytext,"%localstyle") == 0) return(LOCALSTYLE);
if (strcmp(yytext,"%typedef") == 0) {
yylval.ivalue = 1;
return(TYPEDEF);
}
if (strcmp(yytext,"typedef") == 0) {
yylval.ivalue = 0;
return(TYPEDEF);
}
if (strcmp(yytext,"%alpha") == 0) return(ALPHA_MODE);
if (strcmp(yytext,"%raw") == 0) return(RAW_MODE);
if (strcmp(yytext,"%text") == 0) return(TEXT);
if (strcmp(yytext,"%native") == 0) return(NATIVE);
if (strcmp(yytext,"%disabledoc") == 0) return(DOC_DISABLE);
if (strcmp(yytext,"%enabledoc") == 0) return(DOC_ENABLE);
if (strcmp(yytext,"%ifdef") == 0) return(IFDEF);
if (strcmp(yytext,"%else") == 0) return(ELSE);
if (strcmp(yytext,"%ifndef") == 0) return(IFNDEF);
if (strcmp(yytext,"%endif") == 0) return(ENDIF);
if (strcmp(yytext,"%if") == 0) return(IF);
if (strcmp(yytext,"%elif") == 0) return(ELIF);
if (strcmp(yytext,"%pragma") == 0) return(PRAGMA);
if (strcmp(yytext,"%addmethods") == 0) return(ADDMETHODS);
if (strcmp(yytext,"%inline") == 0) return(INLINE);
if (strcmp(yytext,"%typemap") == 0) return(TYPEMAP);
if (strcmp(yytext,"%except") == 0) return(EXCEPT);
if (strcmp(yytext,"%import") == 0) return(IMPORT);
if (strcmp(yytext,"%echo") == 0) return(ECHO);
if (strcmp(yytext,"%new") == 0) return(NEW);
if (strcmp(yytext,"%apply") == 0) return(APPLY);
if (strcmp(yytext,"%clear") == 0) return(CLEAR);
if (strcmp(yytext,"%doconly") == 0) return(DOCONLY);
// Have an unknown identifier, as a last step, we'll
// do a typedef lookup on it.
if (check_typedef) {
if (DataType::is_typedef(yytext)) {
yylval.type = new DataType;
yylval.type->type = T_USER;
strcpy(yylval.type->name,yytext);
yylval.type->typedef_resolve();
return(TYPE_TYPEDEF);
}
}
yylval.id = copy_string(yytext);
return(ID);
default:
return(l);
}
}
// --------------------------------------------------------------
// scanner_clear_start()
//
// Clears the start of a declaration
// --------------------------------------------------------------
void scanner_clear_start() {
start_line = 0;
}
| 25.604197 | 109 | 0.507842 | [
"object"
] |
b071e43a8ee7c781c35b2a41e8429f219e572b25 | 509 | cpp | C++ | wasm/OpenSimplexNoise.cpp | xaroth8088/react-planet | d959deb265387a7b5d589e16ea9484ff9aa9d80b | [
"MIT"
] | 3 | 2018-09-08T13:49:07.000Z | 2022-03-05T23:41:32.000Z | wasm/OpenSimplexNoise.cpp | xaroth8088/react-planet | d959deb265387a7b5d589e16ea9484ff9aa9d80b | [
"MIT"
] | 24 | 2020-09-04T20:44:52.000Z | 2022-02-26T10:38:23.000Z | wasm/OpenSimplexNoise.cpp | xaroth8088/react-planet | d959deb265387a7b5d589e16ea9484ff9aa9d80b | [
"MIT"
] | null | null | null | #include "OpenSimplexNoise.h"
const float OpenSimplexNoise::STRETCH_3D = -1.0 / 6.0;
const float OpenSimplexNoise::SQUISH_3D = 1.0 / 3.0;
const float OpenSimplexNoise::NORM_3D = 1.0 / 103.0;
std::array<float, 72> OpenSimplexNoise::gradients3D;
std::vector<OpenSimplexNoise::Contribution3*> OpenSimplexNoise::lookup3D;
std::vector<OpenSimplexNoise::pContribution3> OpenSimplexNoise::contributions3D;
// Initialise our static tables
OpenSimplexNoise::StaticConstructor OpenSimplexNoise::staticConstructor;
| 33.933333 | 80 | 0.799607 | [
"vector"
] |
b07fc71984dd0dd30a3c2921f24730dc0efb798c | 1,131 | cpp | C++ | src/gui/object/Sprite.cpp | Robograde/Robograde | 2c9a7d0b8250ec240102d504127f5c54532cb2b0 | [
"Zlib"
] | 5 | 2015-10-11T10:22:39.000Z | 2019-07-24T10:09:13.000Z | src/gui/object/Sprite.cpp | Robograde/Robograde | 2c9a7d0b8250ec240102d504127f5c54532cb2b0 | [
"Zlib"
] | null | null | null | src/gui/object/Sprite.cpp | Robograde/Robograde | 2c9a7d0b8250ec240102d504127f5c54532cb2b0 | [
"Zlib"
] | null | null | null | /**************************************************
Zlib Copyright 2015 Isak Almgren
***************************************************/
#include "Sprite.h"
#include "../GUIEngine.h"
GUI::Sprite::Sprite()
{
}
GUI::Sprite::Sprite( rString name, GUI::SpriteDefinition spriteDefinition, rString parent ) :
Object( name, parent, Rectangle( spriteDefinition.Position.x, spriteDefinition.Position.y, spriteDefinition.Width, spriteDefinition.Height ) )
{
m_SpriteDefinition = spriteDefinition;
}
GUI::Sprite::~Sprite()
{
}
void GUI::Sprite::Initialize()
{
}
void GUI::Sprite::Update(float deltaTime , glm::ivec2 parentPos)
{
}
void GUI::Sprite::Render( glm::ivec2 parentPos )
{
if( m_Visible )
{
m_SpriteDefinition.Origin = parentPos;
m_BoundingBox.Origin = parentPos;
g_GUI.EnqueueSprite( &m_SpriteDefinition );
}
}
GUI::SpriteDefinition& GUI::Sprite::GetSpriteDefinitionRef()
{
return m_SpriteDefinition;
}
void GUI::Sprite::SetTexture( rString texturePath )
{
m_SpriteDefinition.Texture = texturePath.c_str();
}
void GUI::Sprite::SetPosition( int x, int y )
{
m_SpriteDefinition.Position = glm::ivec2( x, y );
} | 21.339623 | 142 | 0.668435 | [
"render",
"object"
] |
b0830a5c387c0414edd4a5f7d6b364cdfeade7dc | 4,182 | cpp | C++ | 2019/day03/main.cpp | alexandru-andronache/adventofcode | ee41d82bae8b705818fda5bd43e9962bb0686fec | [
"Apache-2.0"
] | 3 | 2021-07-01T14:31:06.000Z | 2022-03-29T20:41:21.000Z | 2019/day03/main.cpp | alexandru-andronache/adventofcode | ee41d82bae8b705818fda5bd43e9962bb0686fec | [
"Apache-2.0"
] | null | null | null | 2019/day03/main.cpp | alexandru-andronache/adventofcode | ee41d82bae8b705818fda5bd43e9962bb0686fec | [
"Apache-2.0"
] | null | null | null | #include "file.h"
#include "utilities.h"
#include <iostream>
namespace aoc2019_day03 {
struct point {
point (int _x, int _y, int _steps) : x(_x), y(_y), steps(_steps) {}
int x, y, steps;
};
bool operator==(const point& p1, const point& p2) {
return p1.x == p2.x && p1.y == p2.y;
}
bool operator!=(const point& p1, const point& p2) {
return !(p1 == p2);
}
bool operator< (const point& p1, const point& p2) {
if (p1.x < p2.x) return true;
if (p1.x == p2.x && p1.y < p2.y) return true;
return false;
}
bool operator> (const point& p1, const point& p2) {
return p2 < p1;
}
bool operator<=(const point& p1, const point& p2) {
return !(p1 > p2);
}
bool operator>=(const point& p1, const point& p2) {
return !(p1 < p2);
}
void processInput(const char* str, std::vector<point>& path) {
int k = 0;
int nr = 0;
point current = point(0, 0, 0);
while (k < strlen(str)) {
if (str[k] == 'L') {
nr = utils::getNumber(str, ++k);
for (int i = 1; i <= nr; ++i) {
current.y--;
current.steps++;
path.push_back(current);
}
} else if (str[k] == 'R') {
nr = utils::getNumber(str, ++k);
for (int i = 1; i <= nr; ++i) {
current.y++;
current.steps++;
path.push_back(current);
}
} else if (str[k] == 'U') {
nr = utils::getNumber(str, ++k);
for (int i = 1; i <= nr; ++i) {
current.x--;
current.steps++;
path.push_back(current);
}
} else if (str[k] == 'D') {
nr = utils::getNumber(str, ++k);
for (int i = 1; i <= nr; ++i) {
current.x++;
current.steps++;
path.push_back(current);
}
}
k++;
}
}
int part_1(std::string_view path) {
std::vector<std::string> lines = file::readFileAsArrayString(path);
std::vector<point> path1;
std::vector<point> path2;
processInput(lines[0].c_str(), path1);
processInput(lines[1].c_str(), path2);
int distMin = std::numeric_limits<int>::max();
std::sort(path1.begin(), path1.end());
std::sort(path2.begin(), path2.end());
int i = 0, j = 0;
while (i < path1.size() && j < path2.size()) {
if (path1[i] == path2[j]) {
distMin = std::min(distMin, utils::manhattanDistance(path1[i].x, path1[i].y, 0, 0));
i++;
j++;
}
if (path1[i] < path2[j]) {
i++;
}
if (path1[i] > path2[j]) {
j++;
}
}
return distMin;
}
int part_2(std::string_view path) {
std::vector<std::string> lines = file::readFileAsArrayString(path);
std::vector<point> path1;
std::vector<point> path2;
processInput(lines[0].c_str(), path1);
processInput(lines[1].c_str(), path2);
int stepsMin = std::numeric_limits<int>::max();
std::sort(path1.begin(), path1.end());
std::sort(path2.begin(), path2.end());
int i = 0, j = 0;
while (i < path1.size() && j < path2.size()) {
if (path1[i] == path2[j]) {
stepsMin = std::min(stepsMin, path1[i].steps + path2[j].steps);
i++;
j++;
}
if (path1[i] < path2[j]) {
i++;
}
if (path1[i] > path2[j]) {
j++;
}
}
return stepsMin;
}
}
#ifndef TESTING
int main() {
std::cout << "Part 1: " << aoc2019_day03::part_1("../2019/day03/input.in") << std::endl;
std::cout << "Part 2: " << aoc2019_day03::part_2("../2019/day03/input.in") << std::endl;
return 0;
}
#endif
| 28.44898 | 100 | 0.433764 | [
"vector"
] |
b085b052609c03f763727839c6b9ef59f9c8d1c6 | 2,727 | cpp | C++ | lib/caffe/src/caffe/layers/lattice_spixel_layer.cpp | XiaoPanX/FastLatticeSuperpixels | 9fb7d9680b07b155cb33aa53558e050a923f11c2 | [
"MIT"
] | null | null | null | lib/caffe/src/caffe/layers/lattice_spixel_layer.cpp | XiaoPanX/FastLatticeSuperpixels | 9fb7d9680b07b155cb33aa53558e050a923f11c2 | [
"MIT"
] | null | null | null | lib/caffe/src/caffe/layers/lattice_spixel_layer.cpp | XiaoPanX/FastLatticeSuperpixels | 9fb7d9680b07b155cb33aa53558e050a923f11c2 | [
"MIT"
] | null | null | null | #include "caffe/util/math_functions.hpp"
#include "caffe/malabar_layers.hpp"
#include "caffe/layers/lattice_spixel_layer.hpp"
namespace caffe {
/*
Setup function
*/
template <typename Dtype>
void LatticeSpixelLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
num_ = bottom[0]->num();
in_channels_ = bottom[0]->channels();
height_ = bottom[0]->height();
width_ = bottom[0]->width();
LatticeSpixelParameter lattice_spixel_param = this->layer_param_.lattice_spixel_param();
seeds_h_ = lattice_spixel_param.seeds_h();
seeds_w_ = lattice_spixel_param.seeds_w();
nr_levels_= lattice_spixel_param.nr_levels();
top[0]->Reshape(num_, 1, height_, width_);
if(height_>width_)
{
int temp = seeds_h_;
seeds_h_ = seeds_w_;
seeds_w_ = temp;
}
int nr_seeds_w = floor(float(float(width_)/float(seeds_w_))+0.5);
int nr_seeds_h = floor(float(float(height_)/float(seeds_h_))+0.5);
//int nr_seeds_w = floor(float(width_/seeds_w_)+0.5);
//int nr_seeds_h = floor(float(height_/seeds_h_)+0.5);
get_avcolor_ = false;
if (top.size() > 1) {
get_avcolor_= true;
int nr_seeds_ww=nr_seeds_w;
int nr_seeds_hh=nr_seeds_h;
for( int ll=1;ll<nr_levels_;ll++){
nr_seeds_ww = floor(float(nr_seeds_ww/2.0));
nr_seeds_hh = floor(float(nr_seeds_hh/2.0));
}
top[1]->Reshape(num_,3,nr_seeds_hh,nr_seeds_ww);
}
labels_.Reshape(num_,nr_levels_,height_, width_);
parents_.Reshape(num_,nr_levels_,nr_seeds_h,nr_seeds_w);
nr_partitions_.Reshape(num_,nr_levels_,nr_seeds_h,nr_seeds_w);
//nr_labels_.Reshape(num_,nr_levels_,1,2);
Block_feature_.Reshape(num_,(nr_levels_)*in_channels_,nr_seeds_h,nr_seeds_w);
T_.Reshape(num_,nr_levels_,nr_seeds_h,nr_seeds_w);
pixel_Tag_.Reshape(num_,1,height_,width_);
block_Tag_.Reshape(num_,1,nr_seeds_h,nr_seeds_w);
}
template <typename Dtype>
void LatticeSpixelLayer<Dtype>::Reshape(
const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top) {
top[0]->Reshape(num_, 1, height_, width_);
/* if (top.size() > 1) {
top[1]->Reshape(num_, out_channels_, height_, width_);
}*/
}
/*
Forward CPU function
*/
template <typename Dtype>
void LatticeSpixelLayer<Dtype>::Forward_cpu(
const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
}
/*
Backward CPU function (NOT_IMPLEMENTED for now)
*/
template <typename Dtype>
void LatticeSpixelLayer<Dtype>::Backward_cpu(
const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down,
const vector<Blob<Dtype>*>& bottom) {
}
#ifdef CPU_ONLY
STUB_GPU(LatticeSpixelLayer);
#endif
INSTANTIATE_CLASS(LatticeSpixelLayer);
REGISTER_LAYER_CLASS(LatticeSpixel);
} // namespace caffe
| 29.967033 | 90 | 0.721305 | [
"vector"
] |
b0860776bcfd523a5675b27ed4fec5d3ded40653 | 35,332 | cpp | C++ | src/AstBuilderInt.cpp | PSSTools/py-pss-parser | c068942a770d2abbc4626f7e654f1bb405242f4d | [
"Apache-2.0"
] | null | null | null | src/AstBuilderInt.cpp | PSSTools/py-pss-parser | c068942a770d2abbc4626f7e654f1bb405242f4d | [
"Apache-2.0"
] | null | null | null | src/AstBuilderInt.cpp | PSSTools/py-pss-parser | c068942a770d2abbc4626f7e654f1bb405242f4d | [
"Apache-2.0"
] | null | null | null | /*
* AstBuilderInt.cpp
*
* Created on: Sep 13, 2020
* Author: ballance
*/
#include "AstBuilderInt.h"
#include "PSSLexer.h"
#include "pssp/ast/IFactory.h"
#include "Action.h"
#include "Component.h"
#include "NamedScopeChild.h"
#include "ScopeUtil.h"
namespace pssp {
AstBuilderInt::AstBuilderInt(IMarkerListener *marker_l) : m_marker_l(marker_l) {
// TODO Auto-generated constructor stub
}
AstBuilderInt::~AstBuilderInt() {
// TODO Auto-generated destructor stub
}
void AstBuilderInt::build(
ast::IGlobalScope *global,
std::istream *in) {
ANTLRInputStream input(*in);
PSSLexer lexer(&input);
m_tokens = std::unique_ptr<CommonTokenStream>(new CommonTokenStream(&lexer));
PSSParser parser(m_tokens.get());
parser.removeErrorListeners();
parser.addErrorListener(this);
PSSParser::Compilation_unitContext *ctx = parser.compilation_unit();
// Only proceed to build out the AST if there are no syntax errors
if (!m_marker_l->hasSeverity(Severity_Error)) {
push_scope(global);
ctx->accept(this);
pop_scope();
}
}
antlrcpp::Any AstBuilderInt::visitPackage_declaration(PSSParser::Package_declarationContext *ctx) {
PSSParserBaseVisitor::visitPackage_declaration(ctx);
return 0;
}
antlrcpp::Any AstBuilderInt::visitImport_stmt(PSSParser::Import_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitPackage_import_pattern(PSSParser::Package_import_patternContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitExtend_stmt(PSSParser::Extend_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitConst_field_declaration(PSSParser::Const_field_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitConst_data_declaration(PSSParser::Const_data_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitConst_data_instantiation(PSSParser::Const_data_instantiationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitStatic_const_field_declaration(PSSParser::Static_const_field_declarationContext *ctx) { return 0; }
/********************************************************************
********************************************************************/
antlrcpp::Any AstBuilderInt::visitAction_declaration(PSSParser::Action_declarationContext *ctx) {
ast::Action *a = new ast::Action(0, 0);
addChild(a, ctx->start);
push_scope(a);
for (uint32_t i=0; i<ctx->action_body_item().size(); i++) {
ctx->action_body_item(i)->accept(this);
}
pop_scope();
return 0;
}
antlrcpp::Any AstBuilderInt::visitAbstract_action_declaration(PSSParser::Abstract_action_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAction_super_spec(PSSParser::Action_super_specContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAction_body_item(PSSParser::Action_body_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_declaration(PSSParser::Activity_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAction_field_declaration(PSSParser::Action_field_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitObject_ref_declaration(PSSParser::Object_ref_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitFlow_ref_declaration(PSSParser::Flow_ref_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitResource_ref_declaration(PSSParser::Resource_ref_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitObject_ref_field(PSSParser::Object_ref_fieldContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitFlow_object_type(PSSParser::Flow_object_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitResource_object_type(PSSParser::Resource_object_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAttr_field(PSSParser::Attr_fieldContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAccess_modifier(PSSParser::Access_modifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAttr_group(PSSParser::Attr_groupContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAction_handle_declaration(PSSParser::Action_handle_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAction_instantiation(PSSParser::Action_instantiationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_data_field(PSSParser::Activity_data_fieldContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAction_scheduling_constraint(PSSParser::Action_scheduling_constraintContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitExec_block_stmt(PSSParser::Exec_block_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitExec_block(PSSParser::Exec_blockContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitExec_kind_identifier(PSSParser::Exec_kind_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitExec_stmt(PSSParser::Exec_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitExec_super_stmt(PSSParser::Exec_super_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAssign_op(PSSParser::Assign_opContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitTarget_code_exec_block(PSSParser::Target_code_exec_blockContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitTarget_file_exec_block(PSSParser::Target_file_exec_blockContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitStruct_declaration(PSSParser::Struct_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitStruct_kind(PSSParser::Struct_kindContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitObject_kind(PSSParser::Object_kindContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitStruct_super_spec(PSSParser::Struct_super_specContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitStruct_body_item(PSSParser::Struct_body_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitFunction_decl(PSSParser::Function_declContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitMethod_prototype(PSSParser::Method_prototypeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitMethod_return_type(PSSParser::Method_return_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitMethod_parameter_list_prototype(PSSParser::Method_parameter_list_prototypeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitMethod_parameter(PSSParser::Method_parameterContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitMethod_parameter_dir(PSSParser::Method_parameter_dirContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitFunction_qualifiers(PSSParser::Function_qualifiersContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitImport_function_qualifiers(PSSParser::Import_function_qualifiersContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitMethod_qualifiers(PSSParser::Method_qualifiersContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitTarget_template_function(PSSParser::Target_template_functionContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitMethod_parameter_list(PSSParser::Method_parameter_listContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitPss_function_defn(PSSParser::Pss_function_defnContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitProcedural_stmt(PSSParser::Procedural_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitProcedural_block_stmt(PSSParser::Procedural_block_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitProcedural_var_decl_stmt(PSSParser::Procedural_var_decl_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitProcedural_expr_stmt(PSSParser::Procedural_expr_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitProcedural_return_stmt(PSSParser::Procedural_return_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitProcedural_if_else_stmt(PSSParser::Procedural_if_else_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitProcedural_match_stmt(PSSParser::Procedural_match_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitProcedural_match_choice(PSSParser::Procedural_match_choiceContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitProcedural_repeat_stmt(PSSParser::Procedural_repeat_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitProcedural_foreach_stmt(PSSParser::Procedural_foreach_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitProcedural_break_stmt(PSSParser::Procedural_break_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitProcedural_continue_stmt(PSSParser::Procedural_continue_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitComponent_declaration(PSSParser::Component_declarationContext *ctx) {
ast::IComponent *c = new ast::Component(0, 0);
// tokens.getHiddenTokensToLeft(
addChild(c, ctx->start);
addDocstring(c, ctx->start);
fprintf(stdout, "visitComponent_declaration: %s\n",
ctx->component_identifier()->getText().c_str());
push_scope(c);
for (uint32_t i=0; i<ctx->component_body_item().size(); i++) {
ctx->component_body_item(i)->accept(this);
}
pop_scope();
return 0;
}
antlrcpp::Any AstBuilderInt::visitComponent_super_spec(PSSParser::Component_super_specContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitComponent_body_item(PSSParser::Component_body_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitComponent_field_declaration(PSSParser::Component_field_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitComponent_data_declaration(PSSParser::Component_data_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitComponent_pool_declaration(PSSParser::Component_pool_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitObject_bind_stmt(PSSParser::Object_bind_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitObject_bind_item_or_list(PSSParser::Object_bind_item_or_listContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitComponent_path(PSSParser::Component_pathContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitComponent_path_elem(PSSParser::Component_path_elemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_stmt(PSSParser::Activity_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitLabeled_activity_stmt(PSSParser::Labeled_activity_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_if_else_stmt(PSSParser::Activity_if_else_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_repeat_stmt(PSSParser::Activity_repeat_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_replicate_stmt(PSSParser::Activity_replicate_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_sequence_block_stmt(PSSParser::Activity_sequence_block_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_constraint_stmt(PSSParser::Activity_constraint_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_foreach_stmt(PSSParser::Activity_foreach_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_action_traversal_stmt(PSSParser::Activity_action_traversal_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_select_stmt(PSSParser::Activity_select_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitSelect_branch(PSSParser::Select_branchContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_match_stmt(PSSParser::Activity_match_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitMatch_choice(PSSParser::Match_choiceContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_parallel_stmt(PSSParser::Activity_parallel_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_schedule_stmt(PSSParser::Activity_schedule_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_join_spec(PSSParser::Activity_join_specContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_join_branch_spec(PSSParser::Activity_join_branch_specContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_join_select_spec(PSSParser::Activity_join_select_specContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_join_none_spec(PSSParser::Activity_join_none_specContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_join_first_spec(PSSParser::Activity_join_first_specContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_bind_stmt(PSSParser::Activity_bind_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_bind_item_or_list(PSSParser::Activity_bind_item_or_listContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitSymbol_declaration(PSSParser::Symbol_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitSymbol_paramlist(PSSParser::Symbol_paramlistContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitSymbol_param(PSSParser::Symbol_paramContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitActivity_super_stmt(PSSParser::Activity_super_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitOverrides_declaration(PSSParser::Overrides_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitOverride_stmt(PSSParser::Override_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitType_override(PSSParser::Type_overrideContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitInstance_override(PSSParser::Instance_overrideContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitData_declaration(PSSParser::Data_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitData_instantiation(PSSParser::Data_instantiationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitArray_dim(PSSParser::Array_dimContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitData_type(PSSParser::Data_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitContainer_type(PSSParser::Container_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitArray_size_expression(PSSParser::Array_size_expressionContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitContainer_elem_type(PSSParser::Container_elem_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitContainer_key_type(PSSParser::Container_key_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitScalar_data_type(PSSParser::Scalar_data_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitChandle_type(PSSParser::Chandle_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitInteger_type(PSSParser::Integer_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitInteger_atom_type(PSSParser::Integer_atom_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitDomain_open_range_list(PSSParser::Domain_open_range_listContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitDomain_open_range_value(PSSParser::Domain_open_range_valueContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitString_type(PSSParser::String_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitBool_type(PSSParser::Bool_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitUser_defined_datatype(PSSParser::User_defined_datatypeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitEnum_declaration(PSSParser::Enum_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitEnum_item(PSSParser::Enum_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitEnum_type(PSSParser::Enum_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitEnum_type_identifier(PSSParser::Enum_type_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitTypedef_declaration(PSSParser::Typedef_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitTemplate_param_decl_list(PSSParser::Template_param_decl_listContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitTemplate_param_decl(PSSParser::Template_param_declContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitType_param_decl(PSSParser::Type_param_declContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitGeneric_type_param_decl(PSSParser::Generic_type_param_declContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCategory_type_param_decl(PSSParser::Category_type_param_declContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitType_restriction(PSSParser::Type_restrictionContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitType_category(PSSParser::Type_categoryContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitValue_param_decl(PSSParser::Value_param_declContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitTemplate_param_value_list(PSSParser::Template_param_value_listContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitTemplate_param_value(PSSParser::Template_param_valueContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitConstraint_declaration(PSSParser::Constraint_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitConstraint_body_item(PSSParser::Constraint_body_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitDefault_constraint_item(PSSParser::Default_constraint_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitDefault_constraint(PSSParser::Default_constraintContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitDefault_disable_constraint(PSSParser::Default_disable_constraintContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitForall_constraint_item(PSSParser::Forall_constraint_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitExpression_constraint_item(PSSParser::Expression_constraint_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitImplication_constraint_item(PSSParser::Implication_constraint_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitConstraint_set(PSSParser::Constraint_setContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitConstraint_block(PSSParser::Constraint_blockContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitForeach_constraint_item(PSSParser::Foreach_constraint_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitIf_constraint_item(PSSParser::If_constraint_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitUnique_constraint_item(PSSParser::Unique_constraint_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitSingle_stmt_constraint(PSSParser::Single_stmt_constraintContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_declaration(PSSParser::Covergroup_declarationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_port(PSSParser::Covergroup_portContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_body_item(PSSParser::Covergroup_body_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_option(PSSParser::Covergroup_optionContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_instantiation(PSSParser::Covergroup_instantiationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitInline_covergroup(PSSParser::Inline_covergroupContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_type_instantiation(PSSParser::Covergroup_type_instantiationContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_portmap_list(PSSParser::Covergroup_portmap_listContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_portmap(PSSParser::Covergroup_portmapContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_coverpoint(PSSParser::Covergroup_coverpointContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitBins_or_empty(PSSParser::Bins_or_emptyContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_coverpoint_body_item(PSSParser::Covergroup_coverpoint_body_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_coverpoint_binspec(PSSParser::Covergroup_coverpoint_binspecContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCoverpoint_bins(PSSParser::Coverpoint_binsContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_range_list(PSSParser::Covergroup_range_listContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_value_range(PSSParser::Covergroup_value_rangeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitBins_keyword(PSSParser::Bins_keywordContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_cross(PSSParser::Covergroup_crossContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCross_item_or_null(PSSParser::Cross_item_or_nullContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_cross_body_item(PSSParser::Covergroup_cross_body_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_cross_binspec(PSSParser::Covergroup_cross_binspecContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_expression(PSSParser::Covergroup_expressionContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitPackage_body_compile_if(PSSParser::Package_body_compile_ifContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitPackage_body_compile_if_item(PSSParser::Package_body_compile_if_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAction_body_compile_if(PSSParser::Action_body_compile_ifContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAction_body_compile_if_item(PSSParser::Action_body_compile_if_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitComponent_body_compile_if(PSSParser::Component_body_compile_ifContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitComponent_body_compile_if_item(PSSParser::Component_body_compile_if_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitStruct_body_compile_if(PSSParser::Struct_body_compile_ifContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitStruct_body_compile_if_item(PSSParser::Struct_body_compile_if_itemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCompile_has_expr(PSSParser::Compile_has_exprContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCompile_assert_stmt(PSSParser::Compile_assert_stmtContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitConstant_expression(PSSParser::Constant_expressionContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitExpression(PSSParser::ExpressionContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitConditional_expr(PSSParser::Conditional_exprContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitLogical_or_op(PSSParser::Logical_or_opContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitLogical_and_op(PSSParser::Logical_and_opContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitBinary_or_op(PSSParser::Binary_or_opContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitBinary_xor_op(PSSParser::Binary_xor_opContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitBinary_and_op(PSSParser::Binary_and_opContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitInside_expr_term(PSSParser::Inside_expr_termContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitOpen_range_list(PSSParser::Open_range_listContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitOpen_range_value(PSSParser::Open_range_valueContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitLogical_inequality_op(PSSParser::Logical_inequality_opContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitUnary_op(PSSParser::Unary_opContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitExp_op(PSSParser::Exp_opContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitPrimary(PSSParser::PrimaryContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitParen_expr(PSSParser::Paren_exprContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCast_expression(PSSParser::Cast_expressionContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCasting_type(PSSParser::Casting_typeContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitVariable_ref_path(PSSParser::Variable_ref_pathContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitMethod_function_symbol_call(PSSParser::Method_function_symbol_callContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitMethod_call(PSSParser::Method_callContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitFunction_symbol_call(PSSParser::Function_symbol_callContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitFunction_symbol_id(PSSParser::Function_symbol_idContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitFunction_id(PSSParser::Function_idContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitStatic_ref_path(PSSParser::Static_ref_pathContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitStatic_ref_path_elem(PSSParser::Static_ref_path_elemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitMul_div_mod_op(PSSParser::Mul_div_mod_opContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAdd_sub_op(PSSParser::Add_sub_opContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitShift_op(PSSParser::Shift_opContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitEq_neq_op(PSSParser::Eq_neq_opContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitConstant(PSSParser::ConstantContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitIdentifier(PSSParser::IdentifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitHierarchical_id_list(PSSParser::Hierarchical_id_listContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitHierarchical_id(PSSParser::Hierarchical_idContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitHierarchical_id_elem(PSSParser::Hierarchical_id_elemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAction_type_identifier(PSSParser::Action_type_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitType_identifier(PSSParser::Type_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitType_identifier_elem(PSSParser::Type_identifier_elemContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitPackage_identifier(PSSParser::Package_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovercross_identifier(PSSParser::Covercross_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_identifier(PSSParser::Covergroup_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCoverpoint_target_identifier(PSSParser::Coverpoint_target_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitAction_identifier(PSSParser::Action_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitStruct_identifier(PSSParser::Struct_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitComponent_identifier(PSSParser::Component_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitComponent_action_identifier(PSSParser::Component_action_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCoverpoint_identifier(PSSParser::Coverpoint_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitEnum_identifier(PSSParser::Enum_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitImport_class_identifier(PSSParser::Import_class_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitLabel_identifier(PSSParser::Label_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitLanguage_identifier(PSSParser::Language_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitMethod_identifier(PSSParser::Method_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitSymbol_identifier(PSSParser::Symbol_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitVariable_identifier(PSSParser::Variable_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitIterator_identifier(PSSParser::Iterator_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitIndex_identifier(PSSParser::Index_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitBuffer_type_identifier(PSSParser::Buffer_type_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitCovergroup_type_identifier(PSSParser::Covergroup_type_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitResource_type_identifier(PSSParser::Resource_type_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitState_type_identifier(PSSParser::State_type_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitStream_type_identifier(PSSParser::Stream_type_identifierContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitBool_literal(PSSParser::Bool_literalContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitNumber(PSSParser::NumberContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitBased_hex_number(PSSParser::Based_hex_numberContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitBased_dec_number(PSSParser::Based_dec_numberContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitDec_number(PSSParser::Dec_numberContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitBased_bin_number(PSSParser::Based_bin_numberContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitBased_oct_number(PSSParser::Based_oct_numberContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitOct_number(PSSParser::Oct_numberContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitHex_number(PSSParser::Hex_numberContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitString(PSSParser::StringContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitFilename_string(PSSParser::Filename_stringContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitExport_action(PSSParser::Export_actionContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitImport_class_decl(PSSParser::Import_class_declContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitImport_class_extends(PSSParser::Import_class_extendsContext *ctx) { return 0; }
antlrcpp::Any AstBuilderInt::visitImport_class_method_decl(PSSParser::Import_class_method_declContext *ctx) { return 0; }
void AstBuilderInt::syntaxError(
Recognizer *recognizer,
Token * offendingSymbol,
size_t line,
size_t charPositionInLine,
const std::string &msg,
std::exception_ptr e) {
if (m_marker_l) {
m_marker_l->marker(Marker(
msg,
Severity_Error,
Location(
0,
line,
charPositionInLine)));
}
}
void AstBuilderInt::addChild(ast::IScopeChild *c, Token *t) {
ScopeUtil::addChild(scope(), c);
}
void AstBuilderInt::addChild(ast::INamedScopeChild *c, Token *t) {
ScopeUtil::addChild(scope(), c);
}
void AstBuilderInt::addChild(ast::INamedScope *c, Token *t) {
scope()->getChildren().push_back(ast::IScopeChildUP(c));
}
void AstBuilderInt::addDocstring(ast::IScopeChild *c, Token *t) {
std::vector<Token *> ws_tokens = m_tokens->getHiddenTokensToLeft(
t->getTokenIndex(), 10);
std::vector<Token *> slc_tokens = m_tokens->getHiddenTokensToLeft(
t->getTokenIndex(), 11);
std::vector<Token *> mlc_tokens = m_tokens->getHiddenTokensToLeft(
t->getTokenIndex(), 12);
fprintf(stdout, "ws_tokens=%d slc_tokens=%d mlc_tokens=%d\n",
ws_tokens.size(), slc_tokens.size(), mlc_tokens.size());
if (slc_tokens.size() == 0 && mlc_tokens.size() == 0) {
return;
}
int32_t last_ws_line = -1;
if (ws_tokens.size() > 0) {
last_ws_line = ws_tokens.back()->getLine();
}
std::string docstring;
if (slc_tokens.size() > 0 && mlc_tokens.size() > 0) {
if (slc_tokens.back()->getLine() > mlc_tokens.back()->getLine()) {
// Single-line comment is last
docstring = processDocStringSingleLineComment(
slc_tokens,
ws_tokens);
} else {
// Multi-line comment is last
docstring = processDocStringMultiLineComment(
mlc_tokens,
ws_tokens);
}
} else if (slc_tokens.size() > 0) {
// Single-line comment
docstring = processDocStringSingleLineComment(
slc_tokens,
ws_tokens);
} else {
// Multi-line comment
docstring = processDocStringMultiLineComment(
mlc_tokens,
ws_tokens);
}
if (docstring != "") {
c->setDocstring(docstring);
}
/*
fprintf(stdout, "Token pos: %d\n", comp->getLine());
for (std::vector<Token*>::const_iterator
it=tokens.begin();
it!=tokens.end(); it++) {
fprintf(stdout, "Token %d: %s\n",
(*it)->getLine(),
(*it)->getText().c_str());
}
*/
}
std::string AstBuilderInt::processDocStringMultiLineComment(
const std::vector<Token *> &mlc_tokens,
const std::vector<Token *> &ws_tokens) {
int32_t last_ws_line = -1;
if (ws_tokens.size() > 0) {
last_ws_line = ws_tokens.back()->getLine();
}
fprintf(stdout, "last_ws_line=%d comment_line=%d\n",
last_ws_line,
mlc_tokens.back()->getLine());
std::string comment;
if (last_ws_line < 0 || last_ws_line < mlc_tokens.back()->getLine()) {
fprintf(stdout, "OK: no whitespace between element and comment\n");
} else if (last_ws_line >= 0) {
fprintf(stdout, "TODO: check if whitespace exceeds a limit\n");
// Find the extent of the comment
uint32_t comment_last_line = mlc_tokens.back()->getLine();
comment = mlc_tokens.back()->getText();
std::string ws = ws_tokens.back()->getText();
int32_t i=0;
while (i < comment.size() &&
(i=comment.find('\n', i)) != std::string::npos) {
comment_last_line++;
i++;
}
i=0;
while (i < comment.size() &&
(i=ws.find('\n', i)) != std::string::npos) {
last_ws_line++;
i++;
}
fprintf(stdout, "Comment last line: %d\n", comment_last_line);
fprintf(stdout, "Whitespace last line: %d\n", last_ws_line);
if (last_ws_line <= (comment_last_line+2)) {
fprintf(stdout, "Note: Have a doc comment\n");
// TODO: now we need to clean up the comment
//
// Trim off the beginning and end of the comment
comment = comment.substr(2,comment.size()-4);
fprintf(stdout, "Comment: %s\n", comment.c_str());
// Step through the lines looking for a '*' prefix
i=0;
while (i<comment.size()) {
if (comment.at(i) == '*') {
comment.erase(i, 1);
fprintf(stdout, "Post-remove(1): %s\n", comment.c_str());
} else if ((i+1<comment.size()) &&
(isspace(comment.at(i)) && comment.at(i+1) == '*')) {
comment.erase(i, 2);
fprintf(stdout, "Post-remove(2): %s\n", comment.c_str());
}
if ((i=comment.find('\n',i)) != std::string::npos) {
i++;
} else {
break;
}
}
} else {
fprintf(stdout, "Note: False alarm\n");
comment.clear();
}
}
return comment;
}
std::string AstBuilderInt::processDocStringSingleLineComment(
const std::vector<Token *> &slc_tokens,
const std::vector<Token *> &ws_tokens) {
return "";
}
}
| 45.648579 | 135 | 0.788973 | [
"vector"
] |
b0888a844c5830e6cfef232b7db763bd1be0c737 | 10,904 | hpp | C++ | kfr/include/kfr/dsp/ebu.hpp | yekm/gate_recorder | e76fda4a6d67672c0c2d7802417116ac3c1a1896 | [
"MIT"
] | null | null | null | kfr/include/kfr/dsp/ebu.hpp | yekm/gate_recorder | e76fda4a6d67672c0c2d7802417116ac3c1a1896 | [
"MIT"
] | 1 | 2021-02-25T14:20:19.000Z | 2021-02-25T14:24:03.000Z | kfr/include/kfr/dsp/ebu.hpp | For-The-Birds/gate_recorder | e76fda4a6d67672c0c2d7802417116ac3c1a1896 | [
"MIT"
] | null | null | null | /** @addtogroup ebu
* @{
*/
/*
Copyright (C) 2016 D Levin (https://www.kfrlib.com)
This file is part of KFR
KFR 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.
KFR 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 KFR.
If GPL is not suitable for your project, you must purchase a commercial license to use KFR.
Buying a commercial license is mandatory as soon as you develop commercial activities without
disclosing the source code of your own applications.
See https://www.kfrlib.com for details.
*/
#pragma once
#include <vector>
#include "../base.hpp"
#include "../testo/assert.hpp"
#include "biquad.hpp"
#include "biquad_design.hpp"
#include "speaker.hpp"
#include "units.hpp"
CMT_PRAGMA_GNU(GCC diagnostic push)
#if CMT_HAS_WARNING("-Winaccessible-base")
CMT_PRAGMA_GNU(GCC diagnostic ignored "-Winaccessible-base")
#endif
namespace kfr
{
inline namespace CMT_ARCH_NAME
{
template <typename T>
KFR_INTRINSIC T energy_to_loudness(T energy)
{
return T(10) * log10(energy) - T(0.691);
}
template <typename T>
KFR_INTRINSIC T loudness_to_energy(T loudness)
{
return exp10((loudness + T(0.691)) * T(0.1));
}
template <typename T>
struct integrated_vec : public univector<T>
{
private:
void compute() const
{
const T z_total = mean(*this);
T relative_gate = energy_to_loudness(z_total) - 10;
T z = 0;
size_t num = 0;
for (T v : *this)
{
T lk = energy_to_loudness(v);
if (lk >= relative_gate)
{
z += v;
num++;
}
}
z /= num;
if (num >= 1)
{
m_integrated = energy_to_loudness(z);
}
else
{
m_integrated = -c_infinity<T>;
}
m_integrated_cached = true;
}
public:
integrated_vec() : m_integrated(-c_infinity<T>), m_integrated_cached(false) {}
void push(T mean_square)
{
T lk = energy_to_loudness(mean_square);
if (lk >= T(-70.))
{
this->push_back(mean_square);
m_integrated_cached = false;
}
}
void reset()
{
m_integrated_cached = false;
this->clear();
}
T get() const
{
if (!m_integrated_cached)
{
compute();
}
return m_integrated;
}
private:
mutable T m_integrated;
mutable bool m_integrated_cached;
};
template <typename T>
struct lra_vec : public univector<T>
{
private:
void compute() const
{
m_range_high = -70;
m_range_low = -70;
static const T PRC_LOW = T(0.10);
static const T PRC_HIGH = T(0.95);
const T z_total = mean(*this);
const T relative_gate = energy_to_loudness(z_total) - 20;
if (this->size() < 2)
return;
const size_t start_index =
std::upper_bound(this->begin(), this->end(), loudness_to_energy(relative_gate)) - this->begin();
if (this->size() - start_index < 2)
return;
const size_t end_index = this->size() - 1;
const size_t low_index =
static_cast<size_t>(std::llround(start_index + (end_index - start_index) * PRC_LOW));
const size_t high_index =
static_cast<size_t>(std::llround(start_index + (end_index - start_index) * PRC_HIGH));
m_range_low = energy_to_loudness((*this)[low_index]);
m_range_high = energy_to_loudness((*this)[high_index]);
m_lra_cached = true;
}
public:
lra_vec() : m_range_low(-70), m_range_high(-70), m_lra_cached(false) {}
void push(T mean_square)
{
const T lk = energy_to_loudness(mean_square);
if (lk >= -70)
{
auto it = std::upper_bound(this->begin(), this->end(), mean_square);
this->insert(it, mean_square);
m_lra_cached = false;
}
}
void reset()
{
m_lra_cached = false;
this->clear();
}
void get(T& low, T& high) const
{
if (!m_lra_cached)
compute();
low = m_range_low;
high = m_range_high;
}
private:
mutable T m_range_low;
mutable T m_range_high;
mutable bool m_lra_cached;
};
template <typename T>
KFR_INTRINSIC expression_pointer<T> make_kfilter(int samplerate)
{
const biquad_params<T> bq[] = {
biquad_highshelf(T(1681.81 / samplerate), T(+4.0)),
biquad_highpass(T(38.1106678246655 / samplerate), T(0.5)).normalized_all()
};
return to_pointer(biquad(bq, placeholder<T>()));
}
template <typename T>
struct ebu_r128;
template <typename T>
struct ebu_channel
{
public:
friend struct ebu_r128<T>;
ebu_channel(int sample_rate, Speaker speaker, int packet_size_factor = 1, T input_gain = 1)
: m_sample_rate(sample_rate), m_speaker(speaker), m_input_gain(input_gain),
m_packet_size(sample_rate / 10 / packet_size_factor), m_kfilter(make_kfilter<T>(sample_rate)),
m_short_sum_of_squares(3000 / 100 * packet_size_factor),
m_momentary_sum_of_squares(400 / 100 * packet_size_factor), m_output_energy_gain(1.0),
m_buffer_cursor(0), m_short_sum_of_squares_cursor(0), m_momentary_sum_of_squares_cursor(0)
{
switch (speaker)
{
case Speaker::Lfe:
case Speaker::Lfe2:
m_output_energy_gain = 0.0;
break;
case Speaker::LeftSurround:
case Speaker::RightSurround:
m_output_energy_gain = dB_to_power(+1.5);
break;
default:
break;
}
reset();
}
void reset()
{
std::fill(m_short_sum_of_squares.begin(), m_short_sum_of_squares.end(), T(0));
std::fill(m_momentary_sum_of_squares.begin(), m_momentary_sum_of_squares.end(), T(0));
}
void process_packet(const T* src)
{
substitute(m_kfilter, to_pointer(make_univector(src, m_packet_size) * m_input_gain));
const T filtered_sum_of_squares = sumsqr(truncate(m_kfilter, m_packet_size));
m_short_sum_of_squares.ringbuf_write(m_short_sum_of_squares_cursor, filtered_sum_of_squares);
m_momentary_sum_of_squares.ringbuf_write(m_momentary_sum_of_squares_cursor, filtered_sum_of_squares);
}
Speaker get_speaker() const { return m_speaker; }
private:
const int m_sample_rate;
const Speaker m_speaker;
const T m_input_gain;
const size_t m_packet_size;
expression_pointer<T> m_kfilter;
univector<T> m_short_sum_of_squares;
univector<T> m_momentary_sum_of_squares;
T m_output_energy_gain;
univector<T> m_buffer;
size_t m_buffer_cursor;
size_t m_short_sum_of_squares_cursor;
size_t m_momentary_sum_of_squares_cursor;
};
template <typename T>
struct ebu_r128
{
public:
// Correct values for packet_size_factor: 1 (10Hz refresh rate), 2 (20Hz), 3 (30Hz)
ebu_r128(int sample_rate, const std::vector<Speaker>& channels, int packet_size_factor = 1)
: m_sample_rate(sample_rate), m_running(true), m_need_reset(false),
m_packet_size(sample_rate / 10 / packet_size_factor)
{
for (Speaker sp : channels)
{
m_channels.emplace_back(sample_rate, sp, packet_size_factor, T(1));
}
}
int sample_rate() const { return m_sample_rate; }
size_t packet_size() const { return m_packet_size; }
void get_values(T& loudness_momentary, T& loudness_short, T& loudness_intergrated, T& loudness_range_low,
T& loudness_range_high)
{
T sum_of_mean_square_momentary = 0;
T sum_of_mean_square_short = 0;
for (size_t ch = 0; ch < m_channels.size(); ch++)
{
sum_of_mean_square_momentary += mean(m_channels[ch].m_momentary_sum_of_squares) / m_packet_size *
m_channels[ch].m_output_energy_gain;
sum_of_mean_square_short += mean(m_channels[ch].m_short_sum_of_squares) / m_packet_size *
m_channels[ch].m_output_energy_gain;
}
loudness_momentary = energy_to_loudness(sum_of_mean_square_momentary);
loudness_short = energy_to_loudness(sum_of_mean_square_short);
loudness_intergrated = m_integrated_buffer.get();
m_lra_buffer.get(loudness_range_low, loudness_range_high);
}
const ebu_channel<T>& operator[](size_t index) const { return m_channels[index]; }
size_t count() const { return m_channels.size(); }
void process_packet(const std::initializer_list<univector_dyn<T>>& source)
{
process_packet<tag_dynamic_vector>(source);
}
void process_packet(const std::initializer_list<univector_ref<T>>& source)
{
process_packet<tag_array_ref>(source);
}
template <univector_tag Tag>
void process_packet(const std::vector<univector<T, Tag>>& source)
{
T momentary = 0;
T shortterm = 0;
for (size_t ch = 0; ch < m_channels.size(); ch++)
{
TESTO_ASSERT(source[ch].size() == m_packet_size);
ebu_channel<T>& chan = m_channels[ch];
chan.process_packet(source[ch].data());
if (m_running)
{
momentary += mean(m_channels[ch].m_momentary_sum_of_squares) / m_packet_size *
m_channels[ch].m_output_energy_gain;
shortterm += mean(m_channels[ch].m_short_sum_of_squares) / m_packet_size *
m_channels[ch].m_output_energy_gain;
}
}
if (m_need_reset)
{
m_need_reset = false;
for (size_t ch = 0; ch < m_channels.size(); ch++)
{
m_channels[ch].reset();
}
m_integrated_buffer.reset();
m_lra_buffer.reset();
}
if (m_running)
{
m_integrated_buffer.push(momentary);
m_lra_buffer.push(shortterm);
}
}
void start() { m_running = true; }
void stop() { m_running = false; }
void reset() { m_need_reset = true; }
private:
int m_sample_rate;
bool m_running;
bool m_need_reset;
size_t m_packet_size;
std::vector<ebu_channel<T>> m_channels;
integrated_vec<T> m_integrated_buffer;
lra_vec<T> m_lra_buffer;
};
} // namespace CMT_ARCH_NAME
} // namespace kfr
CMT_PRAGMA_GNU(GCC diagnostic pop)
| 30.204986 | 109 | 0.625917 | [
"vector"
] |
b08ae774d2be1c3d372e7fc6fe8a1759d2a055fd | 42,044 | cpp | C++ | Server Lib/Projeto IOCP/Smart Calculator/Smart Calculator.cpp | CCasusensa/SuperSS-Dev | 6c6253b0a56bce5dad150c807a9bbf310e8ff61b | [
"MIT"
] | 23 | 2021-10-31T00:20:21.000Z | 2022-03-26T07:24:40.000Z | Server Lib/Projeto IOCP/Smart Calculator/Smart Calculator.cpp | CCasusensa/SuperSS-Dev | 6c6253b0a56bce5dad150c807a9bbf310e8ff61b | [
"MIT"
] | 5 | 2021-10-31T18:44:51.000Z | 2022-03-25T18:04:26.000Z | Server Lib/Projeto IOCP/Smart Calculator/Smart Calculator.cpp | CCasusensa/SuperSS-Dev | 6c6253b0a56bce5dad150c807a9bbf310e8ff61b | [
"MIT"
] | 18 | 2021-10-20T02:31:56.000Z | 2022-02-01T11:44:36.000Z | // Arquivo Smart Calculator.cpp
// Criado em 15/11/2020 as 17:32 por Acrisio
// Implementa��o da classe SmartCalculator
#if defined(_WIN32)
#pragma pack(1)
#endif
#if defined(_WIN32)
#include <WinSock2.h>
#elif defined(__linux__)
#include "../UTIL/WinPort.h"
#endif
#include "Smart Calculator.hpp"
#include "../UTIL/message_pool.h"
#include "../UTIL/exception.h"
#include "../Server/server.h"
#include "../UTIL/string_util.hpp"
#ifdef _DEBUG
#include <cstdint>
#if defined(_WIN32)
#if INTPTR_MAX == INT64_MAX
#define PATH_SMART_CALCULATOR_LIB_DLL "../../Smart Calculator lib/x64/Release/SMARTCALCULATORLIB.dll"
#elif INTPTR_MAX == INT32_MAX
#define PATH_SMART_CALCULATOR_LIB_DLL "../../Smart Calculator lib/Release/SMARTCALCULATORLIB.dll"
#else
#error Unknown pointer size or missing size macros!
#endif
#elif defined(__linux__)
#define PATH_SMART_CALCULATOR_LIB_DLL "SMARTCALCULATORLIB.so"
#endif
#else
#if defined(_WIN32)
#define PATH_SMART_CALCULATOR_LIB_DLL "SMARTCALCULATORLIB.dll"
#elif defined(__linux__)
#define PATH_SMART_CALCULATOR_LIB_DLL "SMARTCALCULATORLIB.so"
#endif
#endif // _DEBUG
#define INIT_CMD_PTR(_ptr) SmartCalculator *smart = reinterpret_cast< SmartCalculator* >( (_ptr) ); \
if (smart == nullptr || !smart->isLoad()) \
throw exception("[" + std::string(__FUNCTION__) + "][Error] lib is not loaded.", STDA_MAKE_ERROR(STDA_ERROR_TYPE::SMART_CALCULATOR, 3, 0))
#if defined(_WIN32)
#define TRY_CHECK try { \
EnterCriticalSection(&m_cs);
#elif defined(__linux__)
#define TRY_CHECK try { \
pthread_mutex_lock(&m_cs);
#endif
#if defined(_WIN32)
#define LEAVE_CHECK LeaveCriticalSection(&m_cs);
#elif defined(__linux__)
#define LEAVE_CHECK pthread_mutex_unlock(&m_cs);
#endif
#if defined(_WIN32)
#define CATCH_CHECK }catch (exception& e) { \
LeaveCriticalSection(&m_cs); \
\
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
#elif defined(__linux__)
#define CATCH_CHECK }catch (exception& e) { \
pthread_mutex_unlock(&m_cs); \
\
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
#endif
#define END_CHECK } \
// Verifica se a Lib est� carregada
#define CHECK_LIB if (!isLoad()) \
throw exception("[" + std::string(__FUNCTION__) + "][Error] lib is not loaded.", STDA_MAKE_ERROR(STDA_ERROR_TYPE::SMART_CALCULATOR, 3, 0));
#define CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type) auto ctx = smart->getPlayerCtx((_uid), (_type)); \
\
if (ctx == nullptr) { \
\
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][Error][WARINIG] Player[UID="\
+ std::to_string((_uid)) + "] don't have context of player.", CL_FILE_LOG_AND_CONSOLE)); \
\
return; \
} \
#define CONVERT_ARG_TO_DLL_ARG(_arg) join(const_cast< std::vector< std::string >& >((_arg)), " ").c_str()
using namespace stdA;
EXPORT_LIB void scLog(const char* _log, const eTYPE_LOG _type) {
#ifndef _DEBUG
if (_type != eTYPE_LOG::TL_LOG)
_smp::message_pool::getInstance().push(new message(std::string("[SmartCalculator::scLog][Log] ") + _log, CL_FILE_LOG_AND_CONSOLE));
else
_smp::message_pool::getInstance().push(new message(std::string("[SmartCalculator::scLog][Log] ") + _log, CL_ONLY_CONSOLE));
#else
_smp::message_pool::getInstance().push(new message(std::string("[SmartCalculator::scLog][Log] ") + _log, CL_FILE_LOG_AND_CONSOLE));
#endif // !_DEBUG
};
extern "C" EXPORT_LIB void responseCallBack(const uint32_t _id, const stdA::eTYPE_CALCULATOR_CMD _type, const char* _response, const stdA::eTYPE_RESPONSE _server) {
try {
sSmartCalculator::getInstance().sendReply(_id, _type, _response, _server);
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[SmartCalculator::responseCallBack][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
SmartCalculator::SmartCalculator() : m_commands(), m_ptr_lib{ 0u }, m_hDll(NULL), m_load(false), m_stopped(false) {
try {
#if defined(_WIN32)
InitializeCriticalSection(&m_cs);
#elif defined(__linux__)
INIT_PTHREAD_MUTEXATTR_RECURSIVE;
INIT_PTHREAD_MUTEX_RECURSIVE(&m_cs);
DESTROY_PTHREAD_MUTEXATTR_RECURSIVE;
#endif
// Inicializa os Commandos
initCommand();
// Initialize Smart Calculator Lib
initDllResource();
m_load = true;
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSsytem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
SmartCalculator::~SmartCalculator() {
clearDllResource();
TRY_CHECK;
if (!m_commands.empty())
m_commands.clear();
// Flag que segura requisi��o externa de recarga
m_stopped = false;
LEAVE_CHECK;
CATCH_CHECK;
END_CHECK;
#if defined(_WIN32)
DeleteCriticalSection(&m_cs);
#elif defined(__linux__)
pthread_mutex_destroy(&m_cs);
#endif
}
bool SmartCalculator::isLoad() {
bool is_load = false;
TRY_CHECK;
is_load = (m_load && m_ptr_lib.isValid() && m_hDll != NULL);
LEAVE_CHECK;
CATCH_CHECK;
END_CHECK;
return is_load;
}
void SmartCalculator::load() {
if (isLoad())
clearDllResource();
initDllResource();
}
void SmartCalculator::close() {
if (isLoad())
clearDllResource();
}
bool SmartCalculator::hasStopped(){
bool hasStopped = false;
TRY_CHECK;
hasStopped = m_stopped;
LEAVE_CHECK;
CATCH_CHECK;
END_CHECK;
return hasStopped;
}
void SmartCalculator::setStop(bool _stop) {
TRY_CHECK;
m_stopped = _stop;
LEAVE_CHECK;
CATCH_CHECK;
END_CHECK;
}
void SmartCalculator::initDllResource() {
TRY_CHECK;
#if defined(_WIN32)
m_hDll = LoadLibraryA(PATH_SMART_CALCULATOR_LIB_DLL);
#elif defined(__linux__)
m_hDll = dlopen((std::string(getcwd(nullptr, 0)) + "/" + PATH_SMART_CALCULATOR_LIB_DLL).c_str(), RTLD_LAZY);
#endif
if (m_hDll == NULL)
throw exception("[SmartCalculator::initDllResource][Error] nao conseguiu carregar a DLL="
+ std::string(PATH_SMART_CALCULATOR_LIB_DLL)
#if defined(__linux__)
+ std::string(", Error message: ") + dlerror()
#endif
, STDA_MAKE_ERROR(STDA_ERROR_TYPE::SMART_CALCULATOR, 1, 0));
#if defined(_WIN32)
m_ptr_lib.initSmartCalculatorLib = (FNINITSMARTCALCULATORLIB)GetProcAddress(m_hDll, "initSmartCalculatorLib");
// Send Command Server
m_ptr_lib.sendCommandServer = (FNSENDCOMMANDSERVER)GetProcAddress(m_hDll, "sendCommandServer");
// Player Context
m_ptr_lib.makePlayerContext = (FNMAKEPLAYERCONTEXT)GetProcAddress(m_hDll, "makePlayerContext");
m_ptr_lib.getPlayerContext = (FNGETPLAYERCONTEXT)GetProcAddress(m_hDll, "getPlayerContext");
m_ptr_lib.removeAllPlayerContext = (FNREMOVEALLPLAYERCONTEXT)GetProcAddress(m_hDll, "removeAllPlayerContext");
#elif defined(__linux__)
m_ptr_lib.initSmartCalculatorLib = (FNINITSMARTCALCULATORLIB)dlsym(m_hDll, "initSmartCalculatorLib");
// Send Command Server
m_ptr_lib.sendCommandServer = (FNSENDCOMMANDSERVER)dlsym(m_hDll, "sendCommandServer");
// Player Context
m_ptr_lib.makePlayerContext = (FNMAKEPLAYERCONTEXT)dlsym(m_hDll, "makePlayerContext");
m_ptr_lib.getPlayerContext = (FNGETPLAYERCONTEXT)dlsym(m_hDll, "getPlayerContext");
m_ptr_lib.removeAllPlayerContext = (FNREMOVEALLPLAYERCONTEXT)dlsym(m_hDll, "removeAllPlayerContext");
#endif
if (!m_ptr_lib.isValid())
throw exception("[SmartCalculator::initDllResource][Error] nao conseguiu pegar todas as functions importadas da DLL="
+ std::string(PATH_SMART_CALCULATOR_LIB_DLL), STDA_MAKE_ERROR(STDA_ERROR_TYPE::SMART_CALCULATOR, 2, 0));
// Get UID of Server
uint32_t server_uid = 0;
// Get Server Base Static
if (ssv::sv != nullptr)
server_uid = ssv::sv->getUID();
// Initialize Smart Calculator Lib | UID do server
m_ptr_lib.initSmartCalculatorLib(server_uid);
m_load = true;
// Flag stopped, coloca para false, por que acabou de carregar
m_stopped = false;
// Log
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][Log] Dll Lib initialized with success.", CL_FILE_LOG_AND_CONSOLE));
LEAVE_CHECK;
CATCH_CHECK;
throw; // Relan�a
END_CHECK;
}
void SmartCalculator::clearDllResource() {
TRY_CHECK;
if (m_hDll != NULL)
#if defined(_WIN32)
FreeLibrary(m_hDll);
#elif defined(__linux__)
dlclose(m_hDll);
#endif
m_hDll = NULL;
m_ptr_lib.clear();
m_load = false;
// Log
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][Log] Dll Lib clear resource with success.", CL_FILE_LOG_AND_CONSOLE));
LEAVE_CHECK;
CATCH_CHECK;
END_CHECK;
}
void SmartCalculator::sendCommandServer(std::string _cmd) {
if (!isLoad())
throw exception("[" + std::string(__FUNCTION__) + "][Error] lib is not loaded.", STDA_MAKE_ERROR(STDA_ERROR_TYPE::SMART_CALCULATOR, 3, 0));
if (_cmd.empty())
return; // Command Empty
TRY_CHECK;
// Send command server
m_ptr_lib.sendCommandServer(_cmd.c_str());
LEAVE_CHECK;
CATCH_CHECK;
END_CHECK;
}
void SmartCalculator::checkCommand(const uint32_t _uid, const std::string _cmd, eTYPE_CALCULATOR_CMD _type) {
try {
if (_cmd.empty())
throw exception("[SmartCalculator::checkCommand][Error] Player[UID=" + std::to_string(_uid)
+ "] tentou executar comando, mas ele esta vazio.", STDA_MAKE_ERROR(STDA_ERROR_TYPE::SMART_CALCULATOR, 1, 0));
auto args = split(_cmd, " ");
if (args.size() <= 0)
throw exception("[SmartCalculator::checkCommand][Error] Player[UID=" + std::to_string(_uid)
+ "] tentou executar comando, mas nao tem nenhum argumento. Command(" + _cmd + ")", STDA_MAKE_ERROR(STDA_ERROR_TYPE::SMART_CALCULATOR, 1, 0));
auto command = toLowerCase(args.front());
// Command
args.erase(args.begin());
translateCommand(_uid, command, args, _type);
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[SmartCalculator::checkCommand][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::sendReply(const uint32_t _uid, const eTYPE_CALCULATOR_CMD _type, const std::string _response, const stdA::eTYPE_RESPONSE _server) {
try {
if (_server == eTYPE_RESPONSE::PLAYER_RESPONSE) {
responseCallBackPlayer(_uid, _response, _type);
}else if (_server == eTYPE_RESPONSE::SERVER_RESPONSE) {
UNREFERENCED_PARAMETER(_type);
responseCallBackServer(_uid, _response);
}
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[SmartCalculator::sendReply][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
stContext* SmartCalculator::makePlayerCtx(const uint32_t _uid, eTYPE_CALCULATOR_CMD _type) {
CHECK_LIB;
stContext* ctx = nullptr;
try {
ctx = m_ptr_lib.makePlayerContext(_uid, _type);
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
return ctx;
}
stContext* SmartCalculator::getPlayerCtx(const uint32_t _uid, eTYPE_CALCULATOR_CMD _type) {
CHECK_LIB;
stContext* ctx = nullptr;
try {
ctx = m_ptr_lib.getPlayerContext(_uid, _type);
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
return ctx;
}
void SmartCalculator::removeAllPlayerCtx(const uint32_t _uid) {
CHECK_LIB;
try {
m_ptr_lib.removeAllPlayerContext(_uid);
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::translateCommand(const uint32_t _uid, const std::string& _cmd, const std::vector< std::string >& _args, const eTYPE_CALCULATOR_CMD _type) {
TRY_CHECK;
stKeyCommand key{ _cmd, _type };
auto cmd = m_commands.find(key);
if (cmd == m_commands.end())
throw exception("[SmartCalculator::translateCommand][Error] Player[UID=" + std::to_string(_uid)
+ "] tentou executar o comando(" + _cmd + ", TYPE=" + std::to_string((unsigned short)_type)
+ "), mas ele nao existe.", STDA_MAKE_ERROR(STDA_ERROR_TYPE::SMART_CALCULATOR, 2, 0));
if (cmd->second == nullptr)
throw exception("[SmartCalculator::translateCommand][Error] Player[UID=" + std::to_string(_uid)
+ "] tentou executar o comando(" + _cmd + ", TYPE=" + std::to_string((unsigned short)_type)
+ "), mas nao tem um handler para esse comando. Bug", STDA_MAKE_ERROR(STDA_ERROR_TYPE::SMART_CALCULATOR, 3, 0));
cmd->second(this, _type, _uid, _args);
LEAVE_CHECK;
CATCH_CHECK;
END_CHECK;
}
void SmartCalculator::initCommand() {
// Inicializa os Commandos
m_commands.insert({
{
"ping",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartAndStadiumCalculatorPing
});
m_commands.insert({
{
"ping",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdSmartAndStadiumCalculatorPing
});
m_commands.insert({
{
"info",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartAndStadiumCalculatorInfo
});
m_commands.insert({
{
"info",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdSmartAndStadiumCalculatorInfo
});
m_commands.insert({
{
"myinfo",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartAndStadiumCalculatorMyInfo
});
m_commands.insert({
{
"myinfo",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdSmartAndStadiumCalculatorMyInfo
});
m_commands.insert({
{
"list",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartAndStadiumCalculatorList
});
m_commands.insert({
{
"list",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdSmartAndStadiumCalculatorList
});
m_commands.insert({
{
"calc",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartAndStadiumCalculatorCalculate
});
m_commands.insert({
{
"calc",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdSmartAndStadiumCalculatorCalculate
});
m_commands.insert({
{
"expr",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartAndStadiumCalculatorExpression
});
m_commands.insert({
{
"expr",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdSmartAndStadiumCalculatorExpression
});
m_commands.insert({
{
"m",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartAndStadiumCalculatorMacro
});
m_commands.insert({
{
"m",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdSmartAndStadiumCalculatorMacro
});
m_commands.insert({
{
"lastr",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartAndStadiumCalculatorLastResult
});
m_commands.insert({
{
"lastr",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdSmartAndStadiumCalculatorLastResult
});
m_commands.insert({
{
"resolution",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartAndStadiumCalculatorResolution
});
m_commands.insert({
{
"resolution",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdSmartAndStadiumCalculatorResolution
});
m_commands.insert({
{
"dfav",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartAndStadiumCalculatorDesvioFavorito
});
m_commands.insert({
{
"dfav",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdSmartAndStadiumCalculatorDesvioFavorito
});
m_commands.insert({
{
"auto_fit",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartAndStadiumCalculatorAutoFit
});
m_commands.insert({
{
"auto_fit",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdSmartAndStadiumCalculatorAutoFit
});
m_commands.insert({
{
"mycella",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartAndStadiumCalculatorMycellaDegree
});
m_commands.insert({
{
"mycella",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdSmartAndStadiumCalculatorMycellaDegree
});
// Smart Calculator
m_commands.insert({
{
"club",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorClub
});
m_commands.insert({
{
"shot",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorShot
});
m_commands.insert({
{
"ps",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorPowerShot
});
m_commands.insert({
{
"power",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorPower
});
m_commands.insert({
{
"ring",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorRing
});
m_commands.insert({
{
"mascot",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorMascot
});
m_commands.insert({
{
"card",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorCard
});
m_commands.insert({
{
"card_ps",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorCardPowerShot
});
m_commands.insert({
{
"d",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorDistance
});
m_commands.insert({
{
"h",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorHeight
});
m_commands.insert({
{
"w",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorWind
});
m_commands.insert({
{
"a",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorDegree
});
m_commands.insert({
{
"g",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorGround
});
m_commands.insert({
{
"s",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorSpin
});
m_commands.insert({
{
"c",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorCurve
});
m_commands.insert({
{
"b",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorSlopeBreak
});
m_commands.insert({
{
"make_slope",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorMakeSlopeBreak
});
m_commands.insert({
{
"aim",
eTYPE_CALCULATOR_CMD::SMART_CALCULATOR
},
SmartCalculator::cmdSmartCalculatorAimDegree
});
// Stadium Calculator
m_commands.insert({
{
"open",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdStadiumCalculatorOpen
});
m_commands.insert({
{
"shot",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdStadiumCalculatorShot
});
m_commands.insert({
{
"d",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdStadiumCalculatorDistance
});
m_commands.insert({
{
"h",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdStadiumCalculatorHeight
});
m_commands.insert({
{
"w",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdStadiumCalculatorWind
});
m_commands.insert({
{
"a",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdStadiumCalculatorDegree
});
m_commands.insert({
{
"g",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdStadiumCalculatorGround
});
m_commands.insert({
{
"b",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdStadiumCalculatorSlopeBreak
});
m_commands.insert({
{
"n",
eTYPE_CALCULATOR_CMD::CALCULATOR_STADIUM
},
SmartCalculator::cmdStadiumCalculatorGreenSlope
});
}
void SmartCalculator::responseCallBackPlayer(const uint32_t _uid, const std::string _response, const eTYPE_CALCULATOR_CMD _type) {
try {
if (ssv::sv == nullptr)
return;
// Send Reply to top server reply
ssv::sv->sendSmartCalculatorReplyToPlayer(
_uid,
(_type == eTYPE_CALCULATOR_CMD::SMART_CALCULATOR ? "#SC" : "#CS"),
_response
);
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[SmartCalculator::responseCallBackPlayer][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::responseCallBackServer(const uint32_t _uid, const std::string _response) {
try {
auto v_args = split(_response, " ");
if (v_args.empty())
return; // Empty;
if (v_args.size() == 1) {
#ifdef _DEBUG
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][Error] Invalid command: " + join(v_args, " "), CL_FILE_LOG_AND_CONSOLE));
#else
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][Error] Invalid command: " + join(v_args, " "), CL_ONLY_FILE_LOG));
#endif // _DEBUG
return;
}
auto command = v_args.front(); // Command
v_args.erase(v_args.begin());
if (command.compare("chat_discord") == 0) {
auto value = v_args.front();
#if defined(_WIN32)
if (_stricmp(value.c_str(), "ON") == 0) {
#elif defined(__linux__)
if (strcasecmp(value.c_str(), "ON") == 0) {
#endif
if (ssv::sv != nullptr)
ssv::sv->setChatDiscord(true);
// Log
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][Log] Chat Discord Enable with success.", CL_FILE_LOG_AND_CONSOLE));
#if defined(_WIN32)
}else if (_stricmp(value.c_str(), "OFF") == 0) {
#elif defined(__linux__)
}else if (strcasecmp(value.c_str(), "OFF") == 0) {
#endif
if (ssv::sv != nullptr)
ssv::sv->setChatDiscord(false);
// Log
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][Log] Chat Discord Disable with success.", CL_FILE_LOG_AND_CONSOLE));
}
}else if (command.compare("notice") == 0) {
auto notice = join(v_args, " ");
if (notice.empty())
return; // Empty notice
// Envia a notice para todos do server
if (ssv::sv != nullptr)
ssv::sv->sendNoticeGMFromDiscordCmd(notice);
}
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[SmartCalculator::responseCallBackServer][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartAndStadiumCalculatorPing(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getPlayer()->ping(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartAndStadiumCalculatorInfo(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getPlayer()->info(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartAndStadiumCalculatorMyInfo(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getPlayer()->myInfo(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartAndStadiumCalculatorList(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getPlayer()->list(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartAndStadiumCalculatorCalculate(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getPlayer()->calcule(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartAndStadiumCalculatorExpression(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getPlayer()->expression(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartAndStadiumCalculatorMacro(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getPlayer()->macro(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartAndStadiumCalculatorLastResult(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getPlayer()->last_result(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartAndStadiumCalculatorResolution(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getPlayer()->resolution(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartAndStadiumCalculatorDesvioFavorito(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getPlayer()->desvio_favorito(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartAndStadiumCalculatorAutoFit(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getPlayer()->auto_fit(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartAndStadiumCalculatorMycellaDegree(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getPlayer()->mycella_degree(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorClub(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->club(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorShot(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->shot(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorPowerShot(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->power_shot(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorPower(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->power(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorRing(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->ring(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorMascot(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->mascot(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorCard(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->card(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorCardPowerShot(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->card_power_shot(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorDistance(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->distance(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorHeight(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->height(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorWind(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->wind(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorDegree(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->degree(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorGround(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->ground(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorSpin(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->spin(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorCurve(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->curve(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorSlopeBreak(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->slope_break(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorMakeSlopeBreak(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->make_slope_break(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdSmartCalculatorAimDegree(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getSmartPlayer()->aim_degree(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
// Stadium Calculator
void SmartCalculator::cmdStadiumCalculatorOpen(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getStadiumPlayer()->open(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdStadiumCalculatorShot(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getStadiumPlayer()->shot(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdStadiumCalculatorDistance(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getStadiumPlayer()->distance(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdStadiumCalculatorHeight(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getStadiumPlayer()->height(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdStadiumCalculatorWind(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getStadiumPlayer()->wind(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdStadiumCalculatorDegree(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getStadiumPlayer()->degree(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdStadiumCalculatorGround(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getStadiumPlayer()->ground(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdStadiumCalculatorSlopeBreak(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getStadiumPlayer()->slope_break(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
void SmartCalculator::cmdStadiumCalculatorGreenSlope(void* _this, const eTYPE_CALCULATOR_CMD _type, const uint32_t _uid, const std::vector< std::string >& _args) {
INIT_CMD_PTR(_this);
try {
CHECK_AND_INIT_PLAYER_CONTEXT(_uid, _type);
ctx->getStadiumPlayer()->green_slope(CONVERT_ARG_TO_DLL_ARG(_args));
}catch (exception& e) {
_smp::message_pool::getInstance().push(new message("[" + std::string(__FUNCTION__) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE));
}
}
| 27.248218 | 175 | 0.731829 | [
"vector"
] |
b09b2441ac1a067f6beeefdd425892db25fe1453 | 33,241 | cpp | C++ | MakeIcons.cpp | RogerParkinson/MakeIcons | 74fca9f48d48d17e423f27dc66762296d3a90200 | [
"Apache-2.0"
] | null | null | null | MakeIcons.cpp | RogerParkinson/MakeIcons | 74fca9f48d48d17e423f27dc66762296d3a90200 | [
"Apache-2.0"
] | null | null | null | MakeIcons.cpp | RogerParkinson/MakeIcons | 74fca9f48d48d17e423f27dc66762296d3a90200 | [
"Apache-2.0"
] | null | null | null | //============================================================================
// Name : MakeIcons.cpp
// Author : RJP
// Version :
// Copyright : (C) 2015 Prometheus Consulting
// Description : Makes Icon files
//============================================================================
#include <stdio.h>
#include <stdlib.h>
#include "Icon.h"
#define PROGMEM
static char *Notification_bitmap =
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"#19!]ZA+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%AQ\"9$Y(^0=(0CA%!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!1#E&]ZA+^0=(]ZA+!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!]ZA+^0=(^0=(^0=(]ZA+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!]ZA+"
"^0=(^0=(^0=(]ZA+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^0=(^0=(^0=(^0=(^0=("
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!^0=(^0=(^0=(^0=(^0=(!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!^0=(^0=(^0=(^0=(^0=(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^0=("
"^0=(^0=(^0=(^0=(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^0=(^0=(^0=(^0=(^0=("
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!^0=(^0=(^0=(^0=(^0=(!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!^0=(^0=(^0=(^0=(^0=(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!]ZA+"
"^0=(^0=(^0=(]ZA+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!]ZA+^0=(^0=(^0=(]ZA+"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^0=(^0=(^0=(!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!]ZA+^0=(]ZA+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"]ZA+^0=(]ZA+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^0=(!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^0=(%AQ\"!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!]ZA+%AQ\"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!]ZA+^0=(]ZA+!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!*BA$^0=(^0=(^0=(3D!&%1M\"!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!#19!]ZA+^0=(]ZA+%1M\"!A%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"";
static char *setclock_bitmap =
"I[/DO,CYM\\/TR]@(!!!!!!!!@X^`!!!!IK+CDY_0O\\O\\O,CYGZO<S=H*FJ;7!!!!"
"!!!!!!!!!!!!!!!!!!!!!1%\"!!!!!!!!!!!!!A)#!!!!!!!!````````````````"
"````!!!!````!!!!````````````````````````C)C)W.D9KKKK!!!!!!!!!!!!"
"!!!!!!!!!Q-$!!!!!!!!!!!!!!!!!!!!````````````````````!!!!````!!!!"
"````````````````````````!!!!!!!!K+CIY?(B;WNL!!!!!!!!!!!!!!!!!!!!"
"!A)#!!!!!!!!!!!!````````````````````!!!!!!!!!!!!!!!!````````````"
"````!!!!!!!!!!!!!!!!PL[_L+SMP<W^!!!!!Q-$!!!!!!!!!!!!!1%\"!!!!!!!!"
"````````````````````````````````````````````````````!!!!!!!!!!!!"
"!!!!````````FZ?8O\\O\\!!!!!!!!!!!!!!!!!A)#!!!!!!!!````````````````"
"````````````````````````````````!!!!!!!!!!!!!!!!````````````````"
"P\\_`J+3E!!!!!!!!!!!!!!!!!1%\"!!!!````````````````````````````````"
"````````````````!!!!````````!!!!````````````````````N,3UQ]0$!!!!"
"!!!!!!!!!!!!!1%\"````````````````````````````````````````````````"
"!!!!````````````````````````````````````F*35D)S-!!!!!!!!!Q-$!!!!"
"````````````````````````````````````````````!!!!````````````````"
"````````````````````````````V>86!!!!!!!!!A)#!!!!````````````````"
"````````````````````````!!!!!!!!````````````````````````````````"
"X^`@!!!!!!!!M,#QO<GZ!!!!!!!!!!!!````````````````````````````````"
"````````!!!!````````````````````````````````````!!!!!!!!````!!!!"
"N\\?X!!!!!!!!!!!!````````````````````````````````````````!!!!````"
"````````````````````````````````````!!!!!!!!````M,#QJ;7F!!!!!!!!"
"````````````````````````````````````!!!!!!!!````````````````````"
"````````````````````````````````````N,3U!!!!!!!!````````````````"
"````````````````````!!!!````````````!!!!!!!!!!!!!!!!!!!!````````"
"````````````````````N<7V8FZ?!!!!````````````````````````````````"
"!!!!!!!!````````!!!!!!!!!!!!!!!!!!!!````````````````````````````"
"````N,3UDY_0!!!!````````````````````````````````!!!!````````!!!!"
"!!!!!!!!!!!!!!!!!!!!````````````````````````````````````U>(2!!!!"
"````````````````````````````````!!!!````!!!!!!!!!!!!!!!!!!!!````"
"````````````````````````````````UN,3````ML+S!!!!````````````````"
"````````````!!!!!!!!!!!!!!!!````````````````````````````````````"
"````````!!!!!!!!!!!!!!!!X>X>!!!!````````````````````````!Q-$!!!!"
"!!!!````````````````````````````````````````````````````````````"
"````````N<7V!!!!````````````````````!!!!!!!!!!!!!!!!````````````"
"````````````````````````````````````````!!!!!!!!!!!!!!!!Q=(\"!!!!"
"````````````````````!!!!!!!!!!!!!!!!!!!!!!!!!!!!````````````````"
"````````````````````````````````````````W>H:!!!!````````````````"
"````````````````````!!!!````!!!!````````````````````````````````"
"````````````````````````Q=(\"!!!!````````````````````````````````"
"````````!!!!!!!!!!!!!!!!!!!!````````````````````````````````````"
"````````WNL;!!!!````````````````````````````````````````````!!!!"
"!!!!\\/TM!!!!!!!!````````````````````````````````````````C)C)!!!!"
"````````````````````````````````````````````````!!!!!!!!$!Q-!!!!"
"!!!!````````````````````W>H:````````J+3E:76F!!!!````````````````"
"````````````````````````````````````````````!!!!!!!!````````````"
"````!!!!!!!!T]`0````P\\_`!!!!!!!!````````````````````````````````"
"````````````````````````````````````````````````````!!!!!!!!!!!!"
"````PL[_!!!!!!!!````````````````````````````````````````````````"
"````````````````````````````````!!!!SML+!!!!!!!!TM\\/!!!!!!!!!!!!"
"";
static char *clock_bitmap =
"I[/DO,CYM\\/TR]@(!!!!!!!!@X^`!!!!IK+CDY_0O\\O\\O,CYGZO<S=H*FJ;7!!!!"
"!!!!!!!!!!!!!!!!!!!!!1%\"!!!!!!!!!!!!!A)#!!!!!!!!````````````````"
"````!!!!````!!!!````````````````````````C)C)W.D9KKKK!!!!!!!!!!!!"
"!!!!!!!!!Q-$!!!!!!!!!!!!!!!!!!!!````````````````````!!!!````!!!!"
"````````````````````````!!!!!!!!K+CIY?(B;WNL!!!!!!!!!!!!!!!!!!!!"
"!A)#!!!!!!!!!!!!````````````````````!!!!!!!!!!!!!!!!````````````"
"````!!!!!!!!!!!!!!!!PL[_L+SMP<W^!!!!!Q-$!!!!!!!!!!!!!1%\"!!!!!!!!"
"````````````````````````````````````````````````````!!!!!!!!!!!!"
"!!!!````````FZ?8O\\O\\!!!!!!!!!!!!!!!!!A)#!!!!!!!!````````````````"
"````````````````````````````````!!!!!!!!!!!!!!!!````````````````"
"P\\_`J+3E!!!!!!!!!!!!!!!!!1%\"!!!!````````````````````````````````"
"````````````````!!!!````````!!!!````````````````````N,3UQ]0$!!!!"
"!!!!!!!!!!!!!1%\"````````````````````````````````````````````````"
"!!!!````````````````````````````````````F*35D)S-!!!!!!!!!Q-$!!!!"
"````````````````````````````````````````````!!!!````````````````"
"````````````````````````````V>86!!!!!!!!!A)#!!!!````````````````"
"````````````````````````!!!!!!!!````````````````````````````````"
"X^`@!!!!!!!!M,#QO<GZ!!!!!!!!!!!!````````````````````````````````"
"````````!!!!````````````````````````````````````!!!!!!!!````!!!!"
"N\\?X!!!!!!!!!!!!````````````````````````````````````````!!!!````"
"````````````````````````````````````!!!!!!!!````M,#QJ;7F!!!!!!!!"
"````````````````````````````````````!!!!!!!!````````````````````"
"````````````````````````````````````N,3U!!!!!!!!````````````````"
"````````````````````!!!!````````````!!!!!!!!!!!!!!!!!!!!````````"
"````````````````````N<7V8FZ?!!!!````````````````````````````````"
"!!!!!!!!````````!!!!!!!!!!!!!!!!!!!!````````````````````````````"
"````N,3UDY_0!!!!````````````````````````````````!!!!````````!!!!"
"!!!!!!!!!!!!!!!!!!!!````````````````````````````````````U>(2!!!!"
"````````````````````````````````!!!!````!!!!!!!!!!!!!!!!!!!!````"
"````````````````````````````````UN,3````ML+S!!!!````````````````"
"````````````!!!!!!!!!!!!!!!!````````````````````````````````````"
"````````!!!!!!!!!!!!!!!!X>X>!!!!````````````````````````!Q-$!!!!"
"!!!!````````````````````````````````````````````````````````````"
"````````N<7V!!!!````````````````````!!!!!!!!!!!!!!!!````````````"
"````````````````````````````````````````!!!!!!!!!!!!!!!!Q=(\"!!!!"
"````````````````````!!!!!!!!!!!!!!!!!!!!!!!!!!!!````````````````"
"````````````````````````````````````````W>H:!!!!````````````````"
"````````````````````!!!!````!!!!````````````````````````````````"
"````````````````````````Q=(\"!!!!````````````````````````````````"
"````````!!!!!!!!!!!!!!!!!!!!````````````````````````````````````"
"````````WNL;!!!!````````````````````````````````````````````!!!!"
"!!!!\\/TM!!!!!!!!````````````````````````````````````````C)C)!!!!"
"````````````````````````````````````````````````!!!!!!!!$!Q-!!!!"
"!!!!````````````````````W>H:````````J+3E:76F!!!!````````````````"
"````````````````````````````````````````````!!!!!!!!````````````"
"````!!!!!!!!T]`0````P\\_`!!!!!!!!````````````````````````````````"
"````````````````````````````````````````````````````!!!!!!!!!!!!"
"````PL[_!!!!!!!!````````````````````````````````````````````````"
"````````````````````````````````!!!!SML+!!!!!!!!TM\\/!!!!!!!!!!!!"
"";
#define PROGMEM
static char *compass_bitmap PROGMEM =
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\"!1%%2%2!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\"Q=(/TM\\!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!#!A);'BI!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!\"Q=(F:76!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\"Q=(Q]0$!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!'\"A95V.4$!Q-[N'<6&25)#!A!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!,#QML[_PZ[%-[?@B!Q-$Z[%-[,2%Z[%-P<W^/TM\\!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:76FZ[%-Z[%-Z[%-"
"ML+S!!!!Z[%-Z?8FZ[%-Z[%-Z[%-@X^`!1%\"!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!:76FZ[%-Z[%-R-4%0DY_#!A)!!!![M2UE*#1"
"-4%RM\\/TZ[%-Z[%-AY/$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!,#QMZ[%-Z[%-I+#A#1E*!!!!\"Q=(!!!![M2UP,S]!!!!!Q-$B97&Z[%-"
"Z[%-2E:'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!L[_PZ[%-"
"R=8&#!A)86V>9G*C#QM,!!!![M2U[O,3#1E*6F:7$Q]0KKKKZ[%-TM\\/!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'\"A9Z[%-Z[%-0DY_!!!!\"Q=(@X^`"
"#AI+!!!![M2UZ[%-?(BY@HZ_!!!!)S-DZ[%-Z[%-.$1U!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!56&2Z[%-Z/4E=H*SH:W>T-T-Z[%-B97&!!!!Z[%-I+#A"
"#QM,$1U.#!A)#!A)GJK;Z?8F=H*S!!!!!!!!!!!!!!!!!!!!\"A9',#QM76F:BY?("
"M\\/TZ?8FZ[%-Z[%-Z[%-Z[%-Z[%-Z[%-Z[%-B97&EZ/4\"15&!!!!!!!!!!!!!!!!"
"!!!!!1%\"#QM,\"Q=(#!A)\"Q=(\"Q=(\"!1%$Q]0&B97&B97&R=8&B97&B97&R=8&\"15"
"%\"!1%\"!1%\"!1%2%2%R-4>86VBI;'Z[%-[,2%[M2U[M2U[M2UZ[%-Z[%-Z[%-S-D)"
"GZO<<7VN1E*#&B97!!!!!!!!!!!!!!!!!!!!5V.4T-T-EZ/4#!A)\"A9'\"Q=(!1%\""
":'2EZ[%-%R-4A9'\"\\<J-[,2%QM,#FJ;7V^@8[,2%=8&R!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!(R]@Z[%-Z[%--4%R!!!!5V.4C)C)Z[%-Z[%-%2%2!!!!"
"A9'\"#AI+!!!!'\"A9Z[%-\\<J-04U^!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!P<W^Z[%-M\\/T!Q-$=(\"Q#QM,U>(2Z[%-%\"!1\"A9'=(\"Q<'RM!Q-$F:76"
"\\<J-WNL;\"15&!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!/TM\\Z[%-"
"Z[%-BY?(#!A)!!!!I[/DZ[%-%\"!1\"Q=(!!!!#AI+<'RMZ[%-\\<J-7&B9!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@X^`Z[%-Z[%-KKKK)C)C"
">X>XZ[%-%\"!1#!A)'2E:F*35Z[%-\\<J-HJ[?!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1%\"AY/$Z[%-Z[%-Z[%-U^04Z[%-&\"15@HZ_"
"Z[%-\\<J-\\<J-HJ[?\"Q=(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!2E:'TM\\/Z[%-Z[%-Z[%-&B97R]@(\\<J-WNL;7&B9!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!.$1U<W^P[?@B&B97<W^P04U^\"15&!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!OLK[&B97!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!D9W.&B97!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!8FZ?&B97!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!-D)S&B97!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!#!A)%2%2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"";
static char *Sleep_bitmap PROGMEM =
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!/$AY"
"-4%R!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\"A9'9W.DZ_@HVN<7#!A)!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!\"!1%T=X.````_`P\\#AI+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%R-4X^`@"
"````````@8V^!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!KKKK````````_PL[-4%R!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!/TM\\````````````]`0T#AI+!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!V^@8````````````YO,C!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(BY?`0T]````````"
"````W^P<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!0T]``@X^````````````[?HJ!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!45V.`P\\_````````````^P<W&B97!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"35F*`@X^`````````````@X^256&!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-T-T`0T]````````"
"````````LK[O!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#QM,^@8V````````````````````1U.$"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!FZ?8````````````````````\\_`P(2U>!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!\"15&]`0T````````````````````[?HJ*#1E!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!8FZ?````"
"````````````````````^`@XE*#1!Q-$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!CIK+````````````````"
"````````````````IK+C7FJ;0T]`/TM\\$!Q-!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!35F*`0T]````````````````````````"
"`````````0T]35F*!A)#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!Q-$B)3%TM\\/[?HJ^`@X^`@X[?HJTM\\/B)3%!Q-$!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!\"A9'$Q]0&\"15&\"15$Q]0\"A9'!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"";
static char *hm_bitmap PROGMEM =
"!!!!!!!!!!!!!!!!$Q]0````````````````````#!A)!!!!!!!!!!!!!!!!!!!!"
"!!!!#!A)````````````````````````!!!!!!!!!!!!!!!!!!!!!!!!!!!!^`@X"
"`@X^`&25`RY?`RA9`RE:`4]`ZY/$^@8V!!!!!!!!!!!!!!!!^04U_`P\\`52%`RI;"
"`RA9`RY?`5V.````^P<W#QM,!!!!!!!!!!!!!!!!]0$Q_H&R`SIK`QY/`Q5&`Q1%"
"`Q1%`QI+`RA9`%B)\\_`P!!!!!A)#[/DI_FB9`SIK`QM,`Q1%`Q1%`Q5&`QU.`SAI"
"````]@(R%B)3!!!!!!!!6666`````R15`Q%\"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`QI+"
"`6&2Y?(B.3EJ`````QY/`Q%\"`Q=(`Q=(`Q=(`Q=(`Q=(`Q%\"`TEZ````Y_0D!!!!"
"\"15&^04U`UV.`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`QI+`7.D\\_`P`UV."
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q!!`V\"1````R=8&04U^`Y[/`Q!!`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`QU.`WJK`Q!!`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q)#`:+3````R-0$`S1E`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q!!`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`U\"!`````````Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`SAI````"
"`````Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`S!A`````````Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`S1E`````````QI+`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`S]P`````````S1E`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`T]`````"
"\\_`P`G2E`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(_'\"A]`0T!!!!`````QA)`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`QA)````+#AI!!!!`````S9G`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`TQ]````!1%\"!!!!'\"=8``(R`Q)#`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`QQ-``0T-T-T!!!!"
"!!!!!!!!2%2%`_(B`Q%\"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q%\"`_,C;WJK!A)#!!!!!!!!!!!!!!!!<GZO"
"`^$1`Q%\"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q!!`^(2EYS-#AI+!!!!!!!!!!!!!!!!!!!!!Q-$CIK+`\\[_`Q)#`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q)#`\\[_JK3E"
"%B)3!!!!!!!!!!!!!!!!!!!!!!!!!!!!\"!1%H*S=`[OL`Q)#`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q9'`[OLL[_P&R=8!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!A)#K[OL`Z;7`Q5&`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=("
"`Q=(`Q=(`Q=(`QE*`Z?8N<7V&256!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!O,CY`Y+#`QE*`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`QU.`Y3%"
"Q-$!$Q]0!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"R=8&`WZO`QQ-`Q=(`Q=(`Q=(`Q=(`Q=(`Q=(`QY/`H.TSML+\"A9'!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!U.$1`7*C`QY/"
"`Q=(`Q=(`Q=(`Q=(`QY/`76FV^@8!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!W^P<_FF:`QY/`Q=(`Q=(`QU."
"_VF:Y_0D!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!![/DI_&66`QY/`QQ-_6&2\\?XN!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!]`0T^F*3_%6&^P<W!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!````````!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"";
static char *graphics_bitmap PROGMEM =
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1%\"$!Q-#QM,#QM,#QM,"
"#QM,\"Q=(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!$1U.A)#!@8V^@8V^@8V^@HZ_````!1%\"!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!$AY/````!!!!!!!!!!!!!!!!````!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$Q]0"
"````!!!!!!!!!!!!!!!!````!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$Q]0````!!!!!!!!!!!!"
"!!!!````!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!$Q]0````!!!!!!!!!!!!!!!!````!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!$Q]0````!!!!!!!!!!!!!!!!````!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$Q]0"
"````!!!!!!!!!!!!!!!!````!Q-$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!````%\"!1!!!!!!!!!!!!"
"!!!!1E*##!A)!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!D)S-!!!!!!!!!!!!!!!!!!!!-4%R*S=H!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!(2U>````!!!!!!!!!!!!!!!!!!!!!1%\"````!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<GZO!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!````!1%\"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1%\":W>H!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!*S=H````!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!#!A)````!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<GZO"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!&B97````!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!````!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!````!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!````!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@HZ_!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!)3%B5V.4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!04U^XN\\?GZO<F*35AY/$2%2%$!$`$!$`$!$`3UN,AY/$N,3U"
"U.$1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"````````$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`````%2%2!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!P<W^`P\\_$!$`$!$`"
"$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`5V.4!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Q-$^`@X$!$`$!$`$!$`$!$`$!$`$!$`$!$`"
"$!$`$!$`$!$`$!$`$!$`FJ;7!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!4%R-````$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`"
"$!$`V>86!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!R-4%"
"````$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`````&256!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'\"A9`P\\_$!$`$!$`$!$`$!$`"
"$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`````!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!````````$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`"
"$!$`$!$`$!$`$!$`$!$`$!$`````!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!'RM<````$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`"
"$!$`````````!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'2E:"
"VN<7$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`$!$`IK+C!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#1E**C9G````````"
"````````````````````````````````+3EJ\"A9'!!!!!!!!!!!!!!!!!!!!!!!!"
"";
static const char *gallery_bitmap PROGMEM =
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!86V>FZ?8````````````````DY_0:76F!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!D)S-"
"`````````````P\\_`@X^`P\\_`P\\_`0T]````````^P<WD9W.!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`0T]`@X^`@X^^@8VQM,#[^Y3"
"_`P\\`@X^\\?XN[Y=3\\_`P`P\\_````````````AI+#!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!`````0T]`````0T][^Y3[^Y3[^Y3]0$Q_PL[[Y=3[Y=3"
"[Y=3````````````_`P\\````````!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"]@(R`P\\_````````````[^Y3[^Y3[^Y3\\O\\O^`@X[Y=3[Y=3[Y=3````````````"
"````_`P\\````N,3U!!!!!!!!!!!!!!!!!!!!!!!!!!!!````````````````````"
"````_@HZE*#1[^Y3`````0T]V^@8[Y=3YO,C_`P\\[_PL&R,L&R,LR-4%`@X^`@X^"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!^P<W`PX^N\\?X%OMV3OM3`0T]````````````"
"`````````````````````P\\_&R,L&R,L&R,L&R,L````````````!!!!!!!!!!!!"
"!!!!!!!!!!!!_@HZ````%OMV%OMV%OMV_@HZ````````````````````````````"
"````````^`@X&R,L&R,LYO,C````````\\?XN!!!!!!!!!!!!!!!!!!!!!!!!]P,S"
"`@X^`PX^%OMV3OM3`0T]`````````````````````````````P0T`PHZ`PHZ`@,S"
"`@,S`@,S`.T=````^`@X!!!!!!!!!!!!!!!!!!!!!!!!P<W^`0T]`P\\_^@8V`0T]"
"_`P\\`````````````````````PX^`@,S`P0T`PHZ`PHZ````````````````````"
"^`@X!!!!!!!!!!!!!!!!!!!!!!!!!!!!T]`0`````````````````0T]`P\\_`@X^"
"`@T]`@$Q_`$Q````````````````````````````````````]`0T!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!/$AY66666V>8````_@HZ`@X^`P\\_`@4U`PHZ````````"
"````````````````````````````````\\?XN!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!`````P8V`@(R`PX^[R)3[R)3`PX^````````````````"
"````````````````=(\"Q!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!`PX^````[R)3[R)3[R)3[R)3`````````````````````````0T]X>X>"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\\_`P````"
"`PX^[R)3[R)3`PX^`````P\\_````````````````^`@X!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!M<'R````^`@X`PX^`PX^`PX^"
"````````````_`P\\_`P\\XN\\?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!YO,C`````0T]`@X^````````````````WNL;"
"5&\"1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!?XN\\````````````F*35;'BI!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"";
static char dalek_bitmap[] PROGMEM =
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-D)S86V>($)]!!!!!!!!!!!!!!!!,S]P"
"2E:'K;GJS=H*X.T=F*35;GJK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!(R]@.D9W0FNI6&256&256&25:'2EG*C9K+CIN\\?XW^P<R=8&"
"Z?8FV.45JK;G-T-T!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!6&25!!!!!!!!!!!!!!!!L[_PM<+SRM<'X.T=\\O\\O_`P\\[?HJV^@8QM,#DI_0"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!=(\"Q4EZ/H:W>6V>8<'RM<W^PL+SM6F:756&26&25!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-T-T;'BI=X.T"
"H*S=>H:W@(R]BY?(J;;GC9G*B)3%FZ?9)S-D!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!.T=X!!!!!!!!AY/$!!!!!!!!!!!!"
";WNL!!!!!!!!>X>X!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!<GZO!!!!!!!!;GJK!!!!!!!!!!!!7&F:!!!!!!!!76J;"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!C*;<1%R166F;G:G;6VN>7V^B56F=@Y?+1%N00UV4.52+'\"YB!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!N>(<NMX7R.(8"
"W.P>YO,BUNP?R^,8NML3JL`*GLD%F,4#J]T<!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!M+_PJ[3DO<CYU-`0X^`@]P,S````````"
"``````````\\^[_HIU-\\.:76F!!!!!!!!`[Q!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!V/@PQ>,;K<3ZM<7WP,W_Q],#TM\\/SMT/R=P.QM@*O]0&L<G`"
"J;[T)S)B!!!!!!!!`[Q!3EJ+6V>87FJ;4%R-6&256&676VB986V>6F>88F^@F:;7"
"Y?4EQN8>HKORT^H>WN`BX/,FZO@HVN`CU.H>PM`6OM\\6K]0.K-$*57*J!!!!!!!!"
"`[Q!!!!!!!!!!!!!!!!!!!!!;7FJ9'&B*C9G86V>)\"]@*SUQY@(YJ]0/SM`2T^<:"
"WNX?[?HJ]0$Q[OXOY_POYODLX/4GV.`EQ-\\4EZK=!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!5F&2I*_@K;GIP,O[SML+V.45Y_0D]P,S````````"
"````````````````Y/$AV^@8!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!86Z@V.04VN,1U>(2U^87VN03UM`.````\\OLJ\\/LJZ_@H\\OLJ\\/PL````"
"````I['A!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*#YSH.DUX/4J"
"I>@OP]\\5S.LCPO,SF]@>W/XWM^TO?-(CYP$WON\\PJ^@MZ/8FN^PLCM<A5J?V!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!+%>5%C<GO=L3%C<GV^$-Q>@A%C<G"
";J'CTODU%C<G.I'BVOHS%C<G;J#C]`$O7L$819SN%C<G!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!J;+BZ/(@W.85[.`=Z?<GX^\\?]?4?````_PDX``PW`@P["
"^@8W``8R```^\\?XN\\/<D``DV!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"882_BL`9R^HBL^XQFM(5V^85M>@H?-0F````P.TLL.HNRN\\I]?`OQ/$O@M4D]OXL"
"N><FDMTIJ>\\Y!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$4F..H[>L=40%C<G"
"EL'`X>P;5KD/%C<G````GLX.%C<GJ]<5^P0R4K0)%C<GZO4DO]\\8%C<G<*7I!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!NL+QV>44T-L)Y>@3````````V-\\,W^42"
"````\\?LJ`@(M````````^?`N^/\\LZ_@HZO@H````6V24!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!6GRW@LX9RM#^M^`TC<P2````LM(*Q/8UB,(&````N^PL>M,E````"
"````NN8DL^PPO>0?O^4@L^XRI.$E*&JR!!!!!!!!!!!!!!!!!!!!!!!!!!!!E;KW"
"%C<GU-P*%C<GD;KX````G\\@$%C<G@*CE````4K$%%C<G````````LM80%C<GH,H'"
"Y.`@%C<G@J7A!\"YO!!!!!!!!!!!!!!!!!!!!!!!!'RI:D)K*````````````````"
"````O<CY````````````Y^X;Y^\\=````````````[O,?X.H9````Q\\W\\M+[O!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!>+7\\=L<5````MN4E=LL:````````GMH?G.0ODKCU"
"````P/,T;,<:````````````P_0U:\\<;W^,/GN4O=\\,.FNHX!!!!!!!!!!!!!!!!"
"!!!!!!!!<I;1:8O&QL__%C<GA:3>````````1)[Q%C<G````````%C<G99;8````"
"````L=H6%C<G89+4TMP*3*+T%C<G4ZG[!!!!!!!!!!!!!!!!!!!!1U.$BI;'I;+C"
"````RM8%````SML+L+SM````````L[_PXN\\?Z?$?L[_PW>H:V^@8L[_P````````"
"L[_P````````L[_P!!!!!!!!!!!!!!!!,S]P````````````````````````````"
"````````````````````````````````````````````````````````````````"
"";
static char small_dalek_bitmap[] PROGMEM =
"!!!!!!!!!!!!$QQ-``]4``]4``]4!!!!!!!!!!!!BX*S#AI+!!!!!!!!!!!!!!!!"
"!!!!``]4``]4``]4``]4``]4``]4``]4BX*S&B97!!!!!!!!!!!!!!!!!!!!``]4"
"$QQ-$QQ-$QQ-``]4!!!!!!!!BX*S!1%\"!!!!!!!!!!!!!!!!!!!!``]4``]4``]4"
"``]4``]4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!``]4$QQ-$QQ-$QQ-``]4"
"!!!!!!!!!!!!!!!!!1%\"!!!!!!!!!!!!``]4``]4``]4``]4``]4``]4!!!!!!!!"
"!!!!!!!!!!!!BX*S!!!!!!!!``]4``]4``]4``]4``]4``]4``]4``]4``]4``]4"
"``]4BX*S!1%\"!!!!``]4$QQ-``]4$QQ-``]4$QQ-``]4!!!!!!!!!!!!!!!!BX*S"
"\"A9'``]4``]4``]4``]4``]4``]4``]4``]4!!!!!!!!!!!!!!!!!!!!%B)3``]4"
"$QQ-``]4``]4$QQ-``]4$QQ-``]4``]4!!!!!1%\"!!!!!!!!!!!!``]4``]4``]4"
"``]4``]4``]4``]4``]4``]4%2%2!!!!!!!!!!!!!!!!``]4$QQ-``]4``]4$QQ-"
"``]4$QQ-``]4``]4$!Q-!!!!!!!!!!!!``]4``]4$QQ-``]4``]4$QQ-``]4$QQ-"
"``]4``]4``]4!!!!!!!!!!!!``]4``]4``]4``]4``]4``]4``]4``]4``]4``]4"
"``]4!!!!!!!!!!!!";
int main(void) {
{
printf("SetClock\n");
Icon *m_icon = new Icon(28,&setclock_bitmap[0]);
m_icon->draw(0,0);
}
{
printf("Notification\n");
Icon *m_icon = new Icon(28,&Notification_bitmap[0]);
m_icon->draw(0,0);
}
{
printf("Clock\n");
Icon *m_icon = new Icon(28,&clock_bitmap[0]);
m_icon->draw(0,0);
}
{
printf("Compass\n");
Icon *m_icon = new Icon(28,&compass_bitmap[0]);
m_icon->draw(0,0);
}
{
printf("Dalek\n");
Icon *m_icon = new Icon(28,&dalek_bitmap[0]);
m_icon->draw(0,0);
}
{
printf("Gallery\n");
Icon *m_icon = new Icon(28,&gallery_bitmap[0]);
m_icon->draw(0,0);
}
{
printf("Graphics\n");
Icon *m_icon = new Icon(28,&graphics_bitmap[0]);
m_icon->draw(0,0);
}
{
printf("Heartrate\n");
Icon *m_icon = new Icon(28,&hm_bitmap[0]);
m_icon->draw(0,0);
}
{
printf("Sleep\n");
Icon *m_icon = new Icon(28,&Sleep_bitmap[0]);
m_icon->draw(0,0);
}
{
printf("Small Dalek\n");
Icon *m_icon = new Icon(14,&small_dalek_bitmap[0]);
m_icon->draw(0,0);
}
return EXIT_SUCCESS;
}
| 60.992661 | 78 | 0.134683 | [
"3d"
] |
b0a2aa2f5d7120038f333b3e4bd1258893983dcb | 9,473 | cpp | C++ | src/levels/Level.cpp | Press-Play-On-Tape/LoadRunner_Pokitto | 1de11e6b392a5a382e39718e7d2422021946c2cf | [
"BSD-3-Clause"
] | null | null | null | src/levels/Level.cpp | Press-Play-On-Tape/LoadRunner_Pokitto | 1de11e6b392a5a382e39718e7d2422021946c2cf | [
"BSD-3-Clause"
] | null | null | null | src/levels/Level.cpp | Press-Play-On-Tape/LoadRunner_Pokitto | 1de11e6b392a5a382e39718e7d2422021946c2cf | [
"BSD-3-Clause"
] | null | null | null | #include "Level.h"
//--------------------------------------------------------------------------------------------------------------------------
uint8_t Level::getWidth() {
return this->width;
}
uint8_t Level::getHeight() {
return this->height;
}
int16_t Level::getXOffset() {
return this->xOffset;
}
int16_t Level::getYOffset() {
return this->yOffset;
}
int8_t Level::getXOffsetDelta() {
return this->xOffsetDelta;
}
int8_t Level::getYOffsetDelta() {
return this->yOffsetDelta;
}
uint8_t Level::getLevelNumber() {
return this->levelNumber;
}
uint8_t Level::getGoldLeft() {
return this->goldLeft;
}
uint8_t Level::getLevelLadderElementCount() {
return this->levelLadderElementCount;
}
void Level::setXOffset(int16_t val) {
this->xOffset = val;
}
void Level::setYOffset(int16_t val) {
this->yOffset = val;
}
void Level::setXOffsetDelta(int8_t val) {
this->xOffsetDelta = val;
}
void Level::setYOffsetDelta(int8_t val) {
this->yOffsetDelta = val;
}
void Level::setLevelNumber(uint8_t val) {
this->levelNumber = val;
}
void Level::setGoldLeft(uint8_t val) {
this->goldLeft = val;
}
LevelPoint Level::getLevelLadderElement(const uint8_t index) {
return this->levelLadder[index];
}
LevelPoint Level::getNextReentryPoint() {
return this->reentryPoint[this->reentryPointIndex];
this->reentryPointIndex = (this->reentryPointIndex == 3 ? 0 : this->reentryPointIndex + 1);
}
// -----------------------------------------------------------------------------------------------
// Load level data ..
//
void Level::loadLevel(Player *player, Enemy enemies[]) {
#ifdef DEBUG_LEVEL
printf("-------------\n");
#endif
uint16_t dataOffset = 0;
uint8_t goldLeft = 0;
const uint8_t *levelToLoad = levels[this->levelNumber];
player->setStance(PlayerStance::Running_Right1);
// Load player starting position ..
uint16_t playerX = levelToLoad[dataOffset++] * GRID_SIZE;
uint16_t playerY = levelToLoad[dataOffset++] * GRID_SIZE;
#ifdef DEBUG_LEVEL
printf("Player start: %i, %i = %i, %i\n", playerX / GRID_SIZE, playerY / GRID_SIZE, playerX, playerY);
#endif
// Determine player's X Pos and level offset ..
if (playerX < (220 / 2) - 5) {
this->xOffset = 0;
player->setX(playerX);
#ifdef DEBUG_LEVEL
printf("(A) Offset: %i\n", 0);
#endif
}
else {
// if (playerX >= (220 / 2) - 5 && playerX <= (this->width * GRID_SIZE * 2) - 220) {
if (playerX >= 105 && playerX <= 165) {
// player->setX((220 / 2) - 5);
this->xOffset = (105 - playerX) / 2;
player->setX(playerX + this->xOffset);
#ifdef DEBUG_LEVEL
printf("(B) Offset: %i + %i = %i\n", playerX, this->xOffset, playerX + this->xOffset);
#endif
}
else {
this->xOffset = -60;
player->setX(playerX + this->xOffset);
#ifdef DEBUG_LEVEL
printf("(C) Offset: %i + %i = %i\n", playerX, this->xOffset, playerX + this->xOffset);
#endif
}
}
// Determine player's Y Pos and level offset ..
if (playerY < (HEIGHT_LESS_TOOLBAR / 2) - 5) {
this->yOffset = 0;
player->setY(playerY);
}
else {
if (playerY >= (HEIGHT_LESS_TOOLBAR / 2) - 5 && playerY <= (this->height * GRID_SIZE) - HEIGHT_LESS_TOOLBAR) {
player->setY((HEIGHT_LESS_TOOLBAR / 2) - 5);
this->yOffset = player->getY() - playerY;
}
else {
this->yOffset = -2;
player->setY(playerY + this->yOffset);
}
}
// Load enemies ..
uint8_t numberOfEnemies = levelToLoad[dataOffset++];
#ifdef DEBUG_LEVEL
printf("Number of enemies: %i ", numberOfEnemies);
#endif
for (uint8_t x = 0; x < NUMBER_OF_ENEMIES; x++) {
Enemy *enemy = &enemies[x];
enemy->setId(x);
enemy->setGoldCountdown(0);
if (x < numberOfEnemies) {
enemy->setX(levelToLoad[dataOffset++] * GRID_SIZE);
enemy->setY(levelToLoad[dataOffset++] * GRID_SIZE);
enemy->setEnabled(true);
#ifdef DEBUG_LEVEL
printf("%i,%i ", enemy->getX() / GRID_SIZE, enemy->getY() / GRID_SIZE);
#endif
}
else {
enemy->setEnabled(false);
#ifdef DEBUG_LEVEL
printf("disabled ");
#endif
}
}
#ifdef DEBUG_LEVEL
printf("\n");
#endif
// Load level ladder points ..
this->levelLadderElementCount = levelToLoad[dataOffset++];
#ifdef DEBUG_LEVEL
printf("Number of ladders: %i ", levelLadderElementCount);
#endif
for (uint8_t x = 0; x < this->levelLadderElementCount; x++) {
this->levelLadder[x].x = levelToLoad[dataOffset++];
this->levelLadder[x].y = levelToLoad[dataOffset++];
#ifdef DEBUG_LEVEL
printf("%i,%i ", this->levelLadder[x].x, this->levelLadder[x].y);
#endif
}
#ifdef DEBUG_LEVEL
printf("\n");
#endif
// Load reentry points ..
#ifdef DEBUG_LEVEL
printf("Number of reentry: %i ", NUMBER_OF_REENTRY_POINTS);
#endif
for (uint8_t x = 0; x < NUMBER_OF_REENTRY_POINTS; x++) {
this->reentryPoint[x].x = levelToLoad[dataOffset++];
this->reentryPoint[x].y = levelToLoad[dataOffset++];
#ifdef DEBUG_LEVEL
printf("%i,%i ", this->reentryPoint[x].x, this->reentryPoint[x].y);
#endif
}
#ifdef DEBUG_LEVEL
printf("\n");
#endif
// Load level data ..
uint8_t encryptionType = levelToLoad[dataOffset++];
#ifdef DEBUG_LEVEL
printf("Encryption Type: %i\n", encryptionType);
#endif
if (encryptionType == ENCRYPTION_TYPE_GRID) {
for (uint8_t y = 0; y < this->height; y++) {
for (uint8_t x = 0; x < this->width; x++) {
uint8_t data = levelToLoad[(y * this->width) + x + dataOffset];
if (Utils::leftValue(data) == static_cast<uint8_t>(LevelElement::Gold)) { goldLeft++;}
if (Utils::rightValue(data) == static_cast<uint8_t>(LevelElement::Gold)) { goldLeft++;}
this->levelData[x][y] = data;
}
}
}
else {
uint16_t cursor = 0;
while (true) {
uint8_t data = levelToLoad[dataOffset];
uint8_t block = (data & 0xE0) >> 5;
uint8_t run = data & 0x1F;
#ifdef DEBUG_LEVEL
printf("B: %i, R: %i, ", block, run);
#endif
if (block == static_cast<uint8_t>(LevelElement::Gold)) { goldLeft = goldLeft + run;}
if (run > 0) {
dataOffset++;
for (uint8_t x = 0; x < run; x++) {
if (encryptionType == ENCRYPTION_TYPE_RLE_ROW) {
uint8_t row = cursor / (this->width * 2);
uint8_t col = (cursor % (this->width * 2)) / 2;
if (cursor % 2 == 0) {
this->levelData[col][row] = (this->levelData[col][row] & 0x0f) | (block << 4);
}
else {
this->levelData[col][row] = (this->levelData[col][row] & 0xF0) | block;
}
}
else {
uint8_t col = cursor / this->height;
uint8_t row = cursor % this->height;
#ifdef DEBUG_LEVEL
if (x==0) {
printf("Col: %i, Row: %i\n", col, row);
}
#endif
if (col % 2 == 0) {
this->levelData[col / 2][row] = (this->levelData[col / 2][row] & 0x0f) | (block << 4);
}
else {
this->levelData[col / 2][row] = (this->levelData[col / 2][row] & 0xF0) | block;
}
}
cursor++;
}
}
else {
break;
}
}
}
this->goldLeft = goldLeft;
// Echo level data ..
for (uint8_t y = 0; y < this->height; y++) {
for (uint8_t x = 0; x < this->width; x++) {
#ifdef DEBUG_LEVEL
if (this->levelData[x][y] < 16) printf("0");
printf("%x ", this->levelData[x][y]);
#endif
}
#ifdef DEBUG_LEVEL
printf("\n");
#endif
}
#ifdef DEBUG_LEVEL
printf("\n");
#endif
}
// -----------------------------------------------------------------------------------------------
// Get level element at position x and y ..
//
LevelElement Level::getLevelData(const uint8_t x, const uint8_t y) {
if ((x / 2) >= this->width) return LevelElement::Brick;
if (y == 255) return LevelElement::Blank;
if (y >= this->height) return LevelElement::Solid;
if (x % 2 == 0) {
return static_cast<LevelElement>(this->levelData[x / 2][y] >> 4);
}
else {
return static_cast<LevelElement>(this->levelData[x / 2][y] & 0x0F);
}
return LevelElement::Brick;
}
// -----------------------------------------------------------------------------------------------
// Set level element at position x and y ..
//
void Level::setLevelData(const uint8_t x, const uint8_t y, const LevelElement levelElement) {
if (x % 2 == 0) {
this->levelData[x / 2][y] = (this->levelData[x / 2][y] & 0x0f) | (static_cast<uint8_t>(levelElement) << 4);
}
else {
this->levelData[x / 2][y] = (this->levelData[x / 2][y] & 0xf0) | static_cast<uint8_t>(levelElement);
}
}
// -----------------------------------------------------------------------------------------------
// Update the level when the last gold is collected ..
//
bool Level::pickupGold() {
if (this->goldLeft > 0) this->goldLeft--;
if (this->goldLeft == 0) {
// Update map with level ladder ..
for (uint8_t x = 0; x < this->levelLadderElementCount; x++) {
LevelPoint lp = this->levelLadder[x];
Level::setLevelData(lp.x, lp.y, LevelElement::Ladder);
}
return true;
}
return false;
} | 21.051111 | 124 | 0.549984 | [
"solid"
] |
b0a34dc57fcc7cf55f53fcf4724be00d2c075bcc | 13,087 | cpp | C++ | src/extrinsic_calib_aruco/main_extrinsic_charuco.cpp | neemoh/ART | 3f990b9d3c4b58558adf97866faf4eea553ba71b | [
"Unlicense"
] | 11 | 2018-06-29T19:08:08.000Z | 2021-12-30T07:13:00.000Z | src/extrinsic_calib_aruco/main_extrinsic_charuco.cpp | liuxia-zju/ATAR | 3f990b9d3c4b58558adf97866faf4eea553ba71b | [
"Unlicense"
] | 1 | 2020-05-09T23:44:55.000Z | 2020-05-09T23:44:55.000Z | src/extrinsic_calib_aruco/main_extrinsic_charuco.cpp | liuxia-zju/ATAR | 3f990b9d3c4b58558adf97866faf4eea553ba71b | [
"Unlicense"
] | 6 | 2017-11-28T14:26:18.000Z | 2019-11-29T01:57:14.000Z | //
// Created by nima on 21/05/17.
//
#include <opencv2/highgui.hpp>
#include <opencv2/aruco/charuco.hpp>
#include <iostream>
#include <opencv2/opencv.hpp>
#include <ros/ros.h>
#include <sensor_msgs/Image.h>
#include <cv_bridge/cv_bridge.h>
#include <image_transport/image_transport.h>
#include <geometry_msgs/PoseStamped.h>
#include <custom_conversions/Conversions.h>
#include <pwd.h>
#include "src/ar_core/IntrinsicCalibrationCharuco.h"
using namespace std;
using namespace cv;
cv::Mat image_msg;
bool new_image = false;
void ImgCallback(const sensor_msgs::ImageConstPtr &msg);
cv::Mat &Image(ros::Duration timeout);
static bool readCameraParameters(string filename, Mat &camMatrix,
Mat &distCoeffs);
bool DetectCharucoBoardPose(cv::Mat &image,
Ptr<aruco::CharucoBoard> charucoboard,
Ptr<aruco::Dictionary> dictionary,
const Mat &camMatrix, const Mat &distCoeffs,
Vec3d &rvec, Vec3d &tvec);
bool EstimatePoseCharucoBoard(InputArray _charucoCorners,
InputArray _charucoIds,
const Ptr<aruco::CharucoBoard> &_board,
InputArray _cameraMatrix, InputArray _distCoeffs,
OutputArray _rvec, OutputArray _tvec);
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int main(int argc, char *argv[]) {
ros::init(argc, argv, "extrinsic_charuco");
std::string ros_node_name = ros::this_node::getName();
ros::NodeHandle n(ros_node_name);
ros::Rate loop_rate = ros::Rate(200);
std::stringstream instruction_msg;
//----------- Read camera parameters
struct passwd *pw = getpwuid(getuid());
const char *home_dir = pw->pw_dir;
std::stringstream cam_intrinsics_path;
std::string cam_name;
n.param<std::string>("camera_name", cam_name, "camera");
cam_intrinsics_path << std::string(home_dir) << "/.ros/camera_info/"
<< cam_name << "_intrinsics.yaml";
Mat cam_matrix, dist_coeffs;
if(!readCameraParameters(cam_intrinsics_path.str(), cam_matrix, dist_coeffs))
instruction_msg << std::string(
"Did not find the intrinsic calibration data in ") <<
cam_intrinsics_path.str() <<
" Press C to perform intrinsic calibration.";
//----------- Read boardparameters
// board_params comprises:
// [dictionary_id, board_w, board_h,
// square_length_in_meters, marker_length_in_meters]
std::vector<float> board_params = std::vector<float>(5, 0.0);
if(!n.getParam("board_params", board_params))
{
if(!n.getParam("/calibrations/board_params", board_params))
ROS_ERROR("Ros parameter board_param is required. board_param="
"[dictionary_id, board_w, board_h, "
"square_length_in_meters, marker_length_in_meters]");
}
Ptr<aruco::Dictionary> dictionary =
aruco::getPredefinedDictionary(aruco::PREDEFINED_DICTIONARY_NAME
(board_params[0]));
// create charuco board object
Ptr<aruco::CharucoBoard> charucoboard =
aruco::CharucoBoard::create(board_params[1], board_params[2],
board_params[3], board_params[4],
dictionary);
Ptr<aruco::Board> board = charucoboard.staticCast<aruco::Board>();
float axisLength = 0.5f * ((float)min(board_params[1], board_params[2]) *
(board_params[3]));
//-----------
//----------- ROS pub and sub
// advertise publishers
std::string pose_topic_name = "/" + cam_name +"/world_to_camera_transform";
std::string cams_ns;
if(n.getParam("cams_namespace", cams_ns) && cams_ns!="")
pose_topic_name = "/"+cams_ns+"/"+cam_name+ "/world_to_camera_transform";
ros::Publisher publisher_pose =n.advertise<geometry_msgs::PoseStamped>
(pose_topic_name, 1, 0);
ROS_INFO("Publishing board to camera pose on '%s'",pose_topic_name.c_str());
std::string img_topic = "/"+cam_name+ "/image_raw";
if(cams_ns!="")
img_topic = "/"+cams_ns+"/"+cam_name+ "/image_raw";
// if the topic name is found, check if something is being published on it
if (!ros::topic::waitForMessage<sensor_msgs::Image>(
img_topic, ros::Duration(5)))
ROS_WARN("Topic '%s' is not publishing.", img_topic.c_str());
image_transport::ImageTransport it = image_transport::ImageTransport(n);
// register image transport subscriber
image_transport::Subscriber sub = it.subscribe(
img_topic, 1, &ImgCallback);
//-----------
bool show_image;
n.param<bool>("show_image", show_image, true);
//----------- Intrinsic Calibration
IntrinsicCalibrationCharuco * IC_ptr;
//-----------
while(ros::ok() ){
if(new_image) {
new_image = false;
Mat imageCopy, image;
image = Image(ros::Duration(1));
image.copyTo(imageCopy);
Vec3d rvec, tvec;
bool valid_pose = DetectCharucoBoardPose(image, charucoboard,
dictionary, cam_matrix,
dist_coeffs, rvec, tvec);
if (valid_pose) {
// draw the axes
aruco::drawAxis(imageCopy, cam_matrix, dist_coeffs, rvec, tvec,
axisLength);
// publish the pose
geometry_msgs::PoseStamped board_to_cam_msg;
conversions::RvecTvecToPoseMsg(rvec, tvec, board_to_cam_msg.pose);
publisher_pose.publish(board_to_cam_msg);
}
if(show_image) {
cv::putText(
imageCopy, instruction_msg.str(),
cv::Point(10, 20), cv::FONT_HERSHEY_SIMPLEX, 0.5,
cv::Scalar(255, 0, 0), 2
);
imshow(("extrinsic charuco " + cam_name).c_str(), imageCopy);
}
char key = (char) waitKey(1);
if (key == 27) break;
else if(key == 'c'){
// get home directory
IC_ptr = new IntrinsicCalibrationCharuco(img_topic, board_params);
double intrinsic_calib_err;
if(IC_ptr->DoCalibration(cam_intrinsics_path.str(),
intrinsic_calib_err,
cam_matrix,
dist_coeffs))
instruction_msg.str("");
else
instruction_msg.str("Intrinsic Calibration failed. Please"
" repeat.");
delete IC_ptr;
}
}
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}
//------------------------------------------------------------------------------
void ImgCallback(const sensor_msgs::ImageConstPtr &msg) {
try
{
image_msg = cv_bridge::toCvCopy(msg, "bgr8")->image;
new_image = true;
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("Could not convert from '%s' to 'bgr8'.",
msg->encoding.c_str());
}
}
//------------------------------------------------------------------------------
cv::Mat &Image(ros::Duration timeout) {
ros::Rate loop_rate(1);
ros::Time timeout_time = ros::Time::now() + timeout;
while (image_msg.empty()) {
ros::spinOnce();
loop_rate.sleep();
if (ros::Time::now() > timeout_time) {
ROS_WARN("Timeout: No new Image received.");
}
}
return image_msg;
}
//------------------------------------------------------------------------------
static bool readCameraParameters(string file_path,
Mat &camera_matrix, Mat &camera_distortion) {
FileStorage fs(file_path, FileStorage::READ);
if(!fs.isOpened())
return false;
fs["camera_matrix"] >> camera_matrix;
fs["distortion_coefficients"] >> camera_distortion;
// check if we got something
if(camera_matrix.empty()){
ROS_WARN("distortion_coefficients not found in '%s' ", file_path.c_str());
return false;
}
if(camera_distortion.empty()){
ROS_WARN("camera_matrix not found in '%s' ", file_path.c_str());
return false;
}
return true;
}
//------------------------------------------------------------------------------
bool DetectCharucoBoardPose(cv::Mat &image,
Ptr<aruco::CharucoBoard> charucoboard,
Ptr<aruco::Dictionary> dictionary,
const Mat &camMatrix, const Mat &distCoeffs,
Vec3d &rvec, Vec3d &tvec
){
vector<int> markerIds, charucoIds;
vector<vector<Point2f> > markerCorners, rejectedMarkers;
vector<Point2f> charucoCorners;
Ptr<aruco::DetectorParameters> detector_params =
aruco::DetectorParameters::create();
//detector_params->doCornerRefinement = true;
// detect markers
aruco::detectMarkers(image, dictionary, markerCorners, markerIds,
detector_params,
rejectedMarkers);
// // refind strategy to detect more markers
// if (refindStrategy)
// aruco::refineDetectedMarkers(image, board, markerCorners,
// markerIds, rejectedMarkers,
// camMatrix, distCoeffs);
// interpolate charuco corners
int interpolatedCorners = 0;
if (markerIds.size() > 0)
interpolatedCorners =
aruco::interpolateCornersCharuco(markerCorners,
markerIds, image,
charucoboard,
charucoCorners,
charucoIds, camMatrix,
distCoeffs);
// estimate charuco board pose
bool validPose = false;
if (camMatrix.total() != 0)
validPose = EstimatePoseCharucoBoard(charucoCorners,
charucoIds,
charucoboard,
camMatrix,
distCoeffs, rvec,
tvec);
// double currentTime =
// ((double) getTickCount() - tick) / getTickFrequency();
// totalTime += currentTime;
// totalIterations++;
// if (totalIterations % 30 == 0) {
// cout << "Detection Time = " << currentTime * 1000 << " ms "
// << "(Mean = " << 1000 * totalTime / double(totalIterations)
// << " ms)" << " validPose: " << validPose << " tvec: "
// << tvec[0] << " " << tvec[1] << " " << tvec[2] << endl;
// }
//
// cv::Mat imageCopy;
// // draw results
// image.copyTo(imageCopy);
// if (markerIds.size() > 0) {
// aruco::drawDetectedMarkers(imageCopy, markerCorners);
// }
//
//
// if (interpolatedCorners > 0) {
// Scalar color;
// color = Scalar(255, 0, 255);
// aruco::drawDetectedCornersCharuco(imageCopy, charucoCorners,
// charucoIds, color);
// }
//
// imshow("out", imageCopy);
return validPose;
}
//------------------------------------------------------------------------------
bool EstimatePoseCharucoBoard(InputArray _charucoCorners, InputArray _charucoIds,
const Ptr<aruco::CharucoBoard> &_board,
InputArray _cameraMatrix, InputArray _distCoeffs,
OutputArray _rvec, OutputArray _tvec) {
CV_Assert((_charucoCorners.getMat().total() ==
_charucoIds.getMat().total()));
// need, at least, 4 corners
if(_charucoIds.getMat().total() < 4) return false;
vector< Point3f > objPoints;
objPoints.reserve(_charucoIds.getMat().total());
for(unsigned int i = 0; i < _charucoIds.getMat().total(); i++) {
int currId = _charucoIds.getMat().at< int >(i);
CV_Assert(currId >= 0 && currId < (int)_board->chessboardCorners.size());
objPoints.push_back(_board->chessboardCorners[currId]);
}
// points need to be in different lines, check if detected points are enough
//if(!_arePointsEnoughForPoseEstimation(objPoints)) return false;
solvePnP(objPoints, _charucoCorners,
_cameraMatrix, _distCoeffs, _rvec, _tvec);
return true;
}
| 35.854795 | 83 | 0.526629 | [
"object",
"vector"
] |
b0a7d228e5c0791c96dfe18c81f83f7e4623b494 | 505 | cpp | C++ | compiler/src/Ast/AstArrayCall.cpp | jadedrip/SimpleLang | f39c490e5a41151d1d0d2f8c77c6ce524b7842f0 | [
"BSD-3-Clause"
] | 16 | 2015-03-30T02:46:49.000Z | 2020-07-28T13:36:54.000Z | compiler/src/Ast/AstArrayCall.cpp | jadedrip/SimpleLang | f39c490e5a41151d1d0d2f8c77c6ce524b7842f0 | [
"BSD-3-Clause"
] | 1 | 2020-09-07T03:35:20.000Z | 2020-09-07T04:11:52.000Z | compiler/src/Ast/AstArrayCall.cpp | jadedrip/SimpleLang | f39c490e5a41151d1d0d2f8c77c6ce524b7842f0 | [
"BSD-3-Clause"
] | 2 | 2020-02-07T02:09:48.000Z | 2020-02-19T13:31:35.000Z | #include "stdafx.h"
#include "AstArrayCall.h"
#include "AstCall.h"
#include "Type/ClassInstanceType.h"
#include "CodeGenerate/LambdaGen.h"
CodeGen * AstArrayCall::makeGen(AstContext * parent)
{
auto &c = parent->context();
CodeGen* obj = expr->makeGen(parent);
auto *ct=parent->findCompiledClass(obj->type->getStructName());
auto *l = func->makeGen(parent);
std::vector<std::pair<std::string, CodeGen*>> args;
args.push_back(std::make_pair("", l));
return ct->makeCall(c, "ARRAY", args, obj);
}
| 26.578947 | 64 | 0.70495 | [
"vector"
] |
b0abd455783f8cbc86e7ed199bfffc0e093d4389 | 1,883 | cpp | C++ | src/view/task/task.cpp | panzergame/dxfplotter | 95393027903c8e907c1d1ef7b4982d1aadc968c8 | [
"MIT"
] | 19 | 2020-04-08T16:38:27.000Z | 2022-03-30T19:53:18.000Z | src/view/task/task.cpp | panzergame/dxfplotter | 95393027903c8e907c1d1ef7b4982d1aadc968c8 | [
"MIT"
] | 3 | 2020-10-27T05:50:37.000Z | 2022-03-19T17:22:04.000Z | src/view/task/task.cpp | panzergame/dxfplotter | 95393027903c8e907c1d1ef7b4982d1aadc968c8 | [
"MIT"
] | 6 | 2020-06-15T13:00:58.000Z | 2022-02-09T13:18:04.000Z | #include <task.h>
#include <pathlistmodel.h>
#include <layertreemodel.h>
#include <QLabel>
#include <QDebug>
namespace View::Task
{
Task::Task(Model::Application &app)
:DocumentModelObserver(app)
{
setupUi(this);
}
void Task::setupModel()
{
m_pathListModel = setupTreeViewModel<PathListModel>(pathsTreeView);
m_layerTreeModel = setupTreeViewModel<LayerTreeModel>(layersTreeView);
layersTreeView->expandAll();
}
void Task::setupController()
{
// Track outside path selection, e.g from graphics view.
connect(&task(), &Model::Task::pathSelectedChanged, this, &Task::pathSelectedChanged);
setupTreeViewController(m_pathListModel, pathsTreeView);
setupTreeViewController(m_layerTreeModel, layersTreeView);
connect(moveUp, &QPushButton::pressed, [this](){ moveCurrentPath(Model::Task::MoveDirection::UP); });
connect(moveDown, &QPushButton::pressed, [this](){ moveCurrentPath(Model::Task::MoveDirection::DOWN); });
}
void Task::updateItemSelection(const Model::Path &path, QItemSelectionModel::SelectionFlag flag)
{
m_pathListModel->updateItemSelection(path, flag, pathsTreeView->selectionModel());
m_layerTreeModel->updateItemSelection(path, flag, layersTreeView->selectionModel());
}
void Task::documentChanged()
{
setupModel();
setupController();
}
void Task::pathSelectedChanged(Model::Path &path, bool selected)
{
updateItemSelection(path,
selected ? QItemSelectionModel::Select : QItemSelectionModel::Deselect);
}
void Task::moveCurrentPath(Model::Task::MoveDirection direction)
{
QItemSelectionModel *selectionModel = pathsTreeView->selectionModel();
const QModelIndex currentSelectedIndex = selectionModel->currentIndex();
const QModelIndex newSelectedIndex = m_pathListModel->movePath(currentSelectedIndex, direction);
selectionModel->setCurrentIndex(newSelectedIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Current);
}
}
| 28.969231 | 119 | 0.784918 | [
"model"
] |
b0b3f002dd679443ac73b812454be3d71f0e6838 | 4,091 | cpp | C++ | inside_cpp_object_model/overloading/virtual_tables/virtual_tables.cpp | gymk/Study-CPP | f31b0fbd5ee961690fa7fdfe5c41e96c41c03997 | [
"MIT"
] | 1 | 2020-09-20T16:19:33.000Z | 2020-09-20T16:19:33.000Z | inside_cpp_object_model/overloading/virtual_tables/virtual_tables.cpp | gymk/Study-CPP | f31b0fbd5ee961690fa7fdfe5c41e96c41c03997 | [
"MIT"
] | 1 | 2019-05-12T03:52:40.000Z | 2019-05-12T10:10:24.000Z | inside_cpp_object_model/overloading/virtual_tables/virtual_tables.cpp | gymk/Study-CPP | f31b0fbd5ee961690fa7fdfe5c41e96c41c03997 | [
"MIT"
] | 1 | 2019-05-12T03:48:26.000Z | 2019-05-12T03:48:26.000Z | /*
g++ -fdump-class-hierarchy virtual_tables.cpp
g++ virtual_tables.cpp -o virtual_tables.out
g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.10' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10)
*/
/*
objdump -t
objdump -v
GNU objdump (GNU Binutils for Ubuntu) 2.26.1
Copyright (C) 2015 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
objdump -D virtual_tables.out > virtual_tables.disassembly
objdump -t virtual_tables.out > virtual_tables.symbols
*/
/*
nm virtual_tables.out > virtual_tables.nm
nm --v
GNU nm (GNU Binutils for Ubuntu) 2.26.1
Copyright (C) 2015 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
*/
/*
nm virtual_tables.out | c++filt > virtual_tables.c++filt
c++filt --v
GNU c++filt (GNU Binutils for Ubuntu) 2.26.1
Copyright (C) 2015 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
*/
#include <iostream>
class NoVirtual
{
public:
int nv;
};
class A
{
public:
A() {}
~A() {}
virtual void set_int(int newVal) {
a = newVal;
}
virtual int get_int(void) {
return a;
}
private:
int a;
};
class B
{
public:
B() {}
~B() {}
virtual void set_int(int newVal) {
b = newVal;
}
virtual int get_int(void) {
return b;
}
private:
int b;
};
class C : public A
{
public:
C() {}
~C() {}
virtual void set_int(int newVal) {
c = newVal;
}
virtual int get_int(void) {
return c;
}
private:
int c;
};
class D : public B, public A
{
public:
D() {}
~D() {}
virtual void set_int(int newVal) {
d = newVal;
}
virtual int get_int(void) {
return d;
}
private:
int d;
};
class E : public A, public B
{
public:
E() {}
~E() {}
virtual void set_int(int newVal) {
e = newVal;
}
virtual int get_int(void) {
return e;
}
private:
int e;
};
int main()
{
NoVirtual * nv = new NoVirtual;
delete nv;
A * a = new A;
delete a;
B * b = new B;
delete b;
C * c = new C;
delete c;
D * d = new D;
delete d;
E * e = new E;
delete e;
}
/*
Links:
*) TO DO http://www.alexonlinux.com/how-inheritance-encapsulation-and-polymorphism-work-in-cpp
*/ | 24.945122 | 1,202 | 0.660963 | [
"object",
"model"
] |
b0bf5852d9da53e7f2cd181e1ed5490c35d47b1a | 16,360 | cpp | C++ | FATERUI/common/camera/bobcat/CameraBobcat.cpp | LynnChan706/Fater | dde8e3baaac7be8b0c1f8bee0da628f6e6f2b772 | [
"MIT"
] | 4 | 2018-12-07T02:17:26.000Z | 2020-12-03T05:32:23.000Z | FATERUI/common/camera/bobcat/CameraBobcat.cpp | LynnChan706/Fater | dde8e3baaac7be8b0c1f8bee0da628f6e6f2b772 | [
"MIT"
] | null | null | null | FATERUI/common/camera/bobcat/CameraBobcat.cpp | LynnChan706/Fater | dde8e3baaac7be8b0c1f8bee0da628f6e6f2b772 | [
"MIT"
] | 1 | 2021-12-30T12:14:52.000Z | 2021-12-30T12:14:52.000Z | #include "CameraBobcat.h"
#include <stdlib.h>
#include <vector>
#include <string.h>
#include <iomanip>
using namespace std;
CameraBobcat::CameraBobcat(int _mode, bool _single_mode, float _grabTimeout, bool _strobe_enable,
float _trigger_delay, unsigned int _packetSize, unsigned int _interPacketDelay,
int _intp_method, bool _debug, bool _is_hardware_trigger)
{
mDevice = NULL;
mStream = NULL;
mPipeline = NULL;
mConnectionLost = false;
m_frame_rate = 0;
}
CameraBobcat::~CameraBobcat()
{
release_camera();
}
bool CameraBobcat::release_camera(){
return true;
}
bool CameraBobcat::set_params(){
return true;
}
bool CameraBobcat::camera_discovery(){
return true;
}
bool CameraBobcat::GetFrameDimensions( PvGenParameterArray * aDeviceParams, PvDevice * aDevice )
{
PvGenInteger* lFrameWidth = dynamic_cast<PvGenInteger*>( aDeviceParams->Get( "Width") );
PvGenInteger* lFrameHeight = dynamic_cast<PvGenInteger*>( aDeviceParams->Get( "Height") );
if ( !lFrameWidth )
{
cerr << "Could not get width" << endl;
PvDevice::Free( aDevice );
return false;
}
if ( !lFrameHeight )
{
cerr << "Could not get height" << endl;
PvDevice::Free( aDevice );
return false;
}
lFrameWidth->GetValue( width );
lFrameHeight->GetValue( height );
cout << "Frame dimensions are " << width << "x" << height << endl;
return true;
}
bool CameraBobcat::open(){
const PvDeviceInfo *lDeviceInfo = NULL;
PvResult lResult = PvResult::Code::INVALID_PARAMETER;
PvSystem lSystem;
cout<<endl<<"====================================================="<<endl;
cout<<"= You are trying to connect a Bobcat camera. ="<<endl;
cout<<"====================================================="<<endl<<endl;
lSystem.Find();
for ( uint32_t i = 0; i < lSystem.GetInterfaceCount(); i++ )
{
const PvInterface *lInterface = dynamic_cast<const PvInterface *>( lSystem.GetInterface( i ) );
if ( lInterface != NULL )
{
for ( uint32_t j = 0; j < lInterface->GetDeviceCount(); j++ )
{
lDeviceInfo = dynamic_cast<const PvDeviceInfo *>( lInterface->GetDeviceInfo( j ) );
if ( lDeviceInfo != NULL )
{
cout << lDeviceInfo->GetDisplayID().GetAscii() << endl;
break;
}
}
}
}
if( lDeviceInfo == NULL )
{
cout << "No device found!" << endl;
return false;
}
// Connect to the GigE Vision or USB3 Vision device
cout << "Connecting to " << lDeviceInfo->GetDisplayID().GetAscii() << endl;
mDevice = PvDevice::CreateAndConnect( lDeviceInfo, &lResult );
if ( !lResult.IsOK() )
{
cout << "Unable to connect to " << lDeviceInfo->GetDisplayID().GetAscii()
<< "\tError:" << lResult.GetCodeString().GetAscii() << endl;
PvDevice::Free( mDevice );
return false;
}
// Get device parameters need to control streaming
PvGenParameterArray *lDeviceParams = mDevice->GetParameters();
PvGenCommand *lStart = dynamic_cast<PvGenCommand *>( lDeviceParams->Get( "AcquisitionStart" ) );
PvGenCommand *lStop = dynamic_cast<PvGenCommand *>( lDeviceParams->Get( "AcquisitionStop" ) );
// Get acquisition mode parameter
PvGenEnum *lExpMode = mDevice->GetParameters()->GetEnum( "ExposureMode" );
if ( lExpMode == NULL )
{
cerr << "Can't get ExposureMode Parameters." << endl;
return false;
}
lResult = lExpMode->SetValue(1); // Set Timed Mode 0:Off, 1:Timed, 2:IOExposureControl
if ( !lResult.IsOK() )
{
cerr << "Faile to set ExposureMode(Timed)." << endl;
return false;
}
PvGenEnum *lWhiteBalanceMode = mDevice->GetParameters()->GetEnum( "WhiteBalanceMode" );
if ( lWhiteBalanceMode == NULL )
{
cerr << "Can't get WhiteBalanceMode Parameters." << endl;
return false;
}
// Set White Balance Mode
// 0:Off, 1:Once, 2:Auto, 3:Manual
lResult = lWhiteBalanceMode->SetValue(3);
if ( !lResult.IsOK() )
{
cerr << "Faile to set White Balance Mode(Manual)." << endl;
return false;
}
PvGenBoolean *lFlatFieldCorrection = mDevice->GetParameters()->GetBoolean ( "FlatFieldCorrection" );
if ( lFlatFieldCorrection == NULL )
{
cerr << "Can't get FlatFieldCorrection Parameters." << endl;
return false;
}
lResult = lFlatFieldCorrection->SetValue(true);
if ( !lResult.IsOK() )
{
cerr << "Faile to set FlatFieldCorrection(true)." << endl;
return false;
}
PvGenEnum *lDefectPixelCorrection = mDevice->GetParameters()->GetEnum( "DefectPixelCorrection" );
if ( lDefectPixelCorrection == NULL )
{
cerr << "Can't get DefectPixelCorrection Parameters." << endl;
return false;
}
lResult = lDefectPixelCorrection->SetValue(0);
if ( !lResult.IsOK() )
{
cerr << "Faile to set DefectPixelCorrection(Off)." << endl;
return false;
}
PvGenEnum *lHotPixelCorrection = mDevice->GetParameters()->GetEnum( "HotPixelCorrection" );
if ( lHotPixelCorrection == NULL )
{
cerr << "Can't get HotPixelCorrection Parameters." << endl;
return false;
}
lResult = lHotPixelCorrection->SetValue(0);
if ( !lResult.IsOK() )
{
cerr << "Faile to set HotPixelCorrection(Off)." << endl;
return false;
}
PvGenEnum *lPixelFormat = mDevice->GetParameters()->GetEnum( "PixelFormat" );
if ( lPixelFormat == NULL )
{
cerr << "Can't get PixelFormat Parameters." << endl;
return false;
}
lResult = lPixelFormat->SetValue("BayerGR12");
if ( !lResult.IsOK() )
{
cerr << "Faile to set PixelFormat(BayerGR12)." << endl;
return false;
}
PvGenEnum *lAcquisitionMode = mDevice->GetParameters()->GetEnum( "AcquisitionMode" );
if ( lAcquisitionMode == NULL )
{
cerr << "Can't get AcquisitionMode Parameters." << endl;
return false;
}
lResult = lAcquisitionMode->SetValue("Continuous");
if ( !lResult.IsOK() )
{
cerr << "Faile to set AcquisitionMode(Continuous)." << endl;
return false;
}
if ( !GetFrameDimensions( lDeviceParams, mDevice ) )
{
return false;
}
// Creates stream object
cout << "Opening stream to device" << endl;
mStream = PvStream::CreateAndOpen( lDeviceInfo->GetConnectionID(), &lResult );
if ( ( mStream == NULL ) || !lResult.IsOK() )
{
cout << "Error creating and opening stream object" << endl;
PvStream::Free( mStream );
PvDevice::Free( mDevice );
return false;
}
// Configure streaming for GigE Vision devices
const PvDeviceInfoGEV* lDeviceInfoGEV = dynamic_cast<const PvDeviceInfoGEV *>( lDeviceInfo );
if ( lDeviceInfoGEV != NULL )
{
PvStreamGEV *lStreamGEV = static_cast<PvStreamGEV *>( mStream );
PvDeviceGEV *lDeviceGEV = static_cast<PvDeviceGEV *>( mDevice );
// Negotiate packet size
lDeviceGEV->NegotiatePacketSize();
// Configure device streaming destination
lDeviceGEV->SetStreamDestination( lStreamGEV->GetLocalIPAddress(), lStreamGEV->GetLocalPort() );
}
mPvBuffers = NULL;
// Use min of BUFFER_COUNT and how many buffers can be queued in PvStream.
mBufferCount = ( mStream->GetQueuedBufferMaximum() < BUFFER_COUNT ) ?
mStream->GetQueuedBufferMaximum() :
BUFFER_COUNT;
// Create our image buffers which are holding the real memory buffers
mImagingBuffers = new SimpleImagingLib::ImagingBuffer[ mBufferCount ];
for ( uint32_t i = 0; i < mBufferCount; i++ )
{
mImagingBuffers[ i ].AllocateImage( static_cast<uint32_t>( width ), static_cast<uint32_t>( height ), 2 );
}
// Creates, eBUS SDK buffers, attach out image buffer memory
mPvBuffers = new PvBuffer[ mBufferCount ];
for ( uint32_t i = 0; i < mBufferCount; i++ )
{
// Attach the memory of our imaging buffer to a PvBuffer. The PvBuffer is used as a shell
// that allows directly acquiring image data into the memory owned by our imaging buffer
mPvBuffers[ i ].GetImage()->Attach( mImagingBuffers[ i ].GetTopPtr(),
static_cast<uint32_t>( width ), static_cast<uint32_t>( height ), PvPixelBayerGR12 );
// Set eBUS SDK buffer ID to the buffer/image index
mPvBuffers[ i ].SetID( i );
}
// Queue all buffers in the stream
for ( uint32_t i = 0; i < mBufferCount; i++ )
{
mStream->QueueBuffer( mPvBuffers + i );
}
// Get stream parameters/stats.
PvGenParameterArray *lStreamParams = mStream->GetParameters();
mBlockCount = dynamic_cast<PvGenInteger *>( lStreamParams->Get( "BlockCount" ) );
mFrameRate = dynamic_cast<PvGenFloat *>( lStreamParams->Get( "AcquisitionRate" ) );
mBandwidth = dynamic_cast<PvGenFloat *>( lStreamParams->Get( "Bandwidth" ) );
// Enables stream before sending the AcquisitionStart command.
cout << "Enable streaming on the controller." << endl;
mDevice->StreamEnable();
// The buffers are queued in the stream, we just have to tell the device
// to start sending us images.
cout << "Sending StartAcquisition command to device" << endl;
lStart->Execute();
return true;
}
bool CameraBobcat::reboot_camera(){
return true;
}
unsigned char* CameraBobcat::capture_one_frame(){
PvBuffer *lBuffer = NULL;
PvResult lOperationResult;
PvBufferConverter lBufferConverter;
lBufferConverter.SetBayerFilter(PvBayerFilter3X3);
unsigned char * buffer = NULL;
// Retrieve next buffer
PvResult lResult = mStream->RetrieveBuffer( &lBuffer, &lOperationResult, 1000 );
if ( lResult.IsOK() )
{
if (lOperationResult.IsOK())
{
if ( lBuffer->GetPayloadType() == PvPayloadTypeImage )
{
// Get image specific buffer interface.
PvImage *lImage = lBuffer->GetImage();
PvBuffer *lBufferBGR = new PvBuffer();
PvImage *lImageBRG = lBufferBGR->GetImage();
lImageBRG->Alloc( lImage->GetWidth(), lImage->GetHeight(), PvPixelBGR8 );
lBufferConverter.Convert(lBuffer, lBufferBGR);
buffer = lImageBRG->GetDataPointer();
}
}
// Re-queue the buffer in the stream object.
mStream->QueueBuffer( lBuffer );
}
return buffer;
}
bool CameraBobcat::is_connected(){
return mDevice != NULL && mDevice->IsConnected();
}
int CameraBobcat::get_frame_count() {
return frame_count;
}
int CameraBobcat::get_error_frame_count() {
return error_frame_count;
}
double CameraBobcat::get_frame_rate() {
double rate = 0.0;
PvResult res;
if (mFrameRate)
{
res = mFrameRate->GetValue(rate);
}
return rate;
}
/**
add by Bill.xie
**/
bool CameraBobcat::set_wb_red(int red) {
PvResult res;
// Get GenICam parameter object
PvGenInteger *lInt = dynamic_cast<PvGenInteger *>( mDevice->GetParameters()->Get( "RedCoefficient" ) );
if(lInt)
res = lInt->SetValue(red);
return lInt && res.IsOK();
}
bool CameraBobcat::set_wb_blue(int blue) {
PvResult res;
// Get GenICam parameter object
PvGenInteger *lInt = dynamic_cast<PvGenInteger *>( mDevice->GetParameters()->Get( "BlueCoefficient" ) );
if(lInt)
res = lInt->SetValue(blue);
return lInt && res.IsOK();
}
bool CameraBobcat::set_wb_green(int green){
PvResult res;
// Get GenICam parameter object
PvGenInteger *lInt = dynamic_cast<PvGenInteger *>( mDevice->GetParameters()->Get( "GreenCoefficient" ) );
if(lInt)
res = lInt->SetValue(green);
return lInt && res.IsOK();
}
bool CameraBobcat::set_wb(int red, int green, int blue) {
return set_wb_red(red) && set_wb_blue(blue) && set_wb_green(green);
}
bool CameraBobcat::set_shutter(float _shutter) {
PvResult res;
int64_t val = (int64_t)(_shutter*1000);
// Get GenICam parameter object
PvGenInteger *lInt = dynamic_cast<PvGenInteger *>( mDevice->GetParameters()->Get( "ExposureTimeRaw" ) );
if(lInt)
res = lInt->SetValue(val);
return lInt && res.IsOK();
}
float CameraBobcat::get_shutter() {
PvResult res;
int64_t val = -1;
// Get GenICam parameter object
PvGenInteger *lInt = dynamic_cast<PvGenInteger *>( mDevice->GetParameters()->Get( "ExposureTimeRaw" ) );
if(lInt)
res = lInt->GetValue(val);
if( lInt && res.IsOK() )
{
return val/1000.0;
}
else{
return -1;
}
}
int CameraBobcat::get_white_balance_red() {
PvResult res;
int64_t val = -1;
// Get GenICam parameter object
PvGenInteger *lInt = dynamic_cast<PvGenInteger *>( mDevice->GetParameters()->Get( "CurrentRedCoefficient" ) );
if(lInt)
res = lInt->GetValue(val);
if( lInt && res.IsOK() )
{
return val;
}
else{
return -1;
}
}
int CameraBobcat::get_white_balance_blue() {
PvResult res;
int64_t val = -1;
// Get GenICam parameter object
PvGenInteger *lInt = dynamic_cast<PvGenInteger *>( mDevice->GetParameters()->Get( "CurrentBlueCoefficient" ) );
if(lInt)
res = lInt->GetValue(val);
if( lInt && res.IsOK() )
{
return val;
}
else{
return -1;
}
}
int CameraBobcat::get_white_balance_green() {
PvResult res;
int64_t val = -1;
// Get GenICam parameter object
PvGenInteger *lInt = dynamic_cast<PvGenInteger *>( mDevice->GetParameters()->Get( "CurrentGreenCoefficient" ) );
if(lInt)
res = lInt->GetValue(val);
if( lInt && res.IsOK() )
{
return val;
}
else{
return -1;
}
}
const char* CameraBobcat::get_firmware_version(){
PvResult res;
PvString val;
// Get GenICam parameter object
PvGenString *str = dynamic_cast<PvGenString *>( mDevice->GetParameters()->Get( "DeviceVersion" ) );
if(str)
res = str->GetValue(val);
if( str && res.IsOK() )
{
return val.GetAscii();
}
else{
return NULL;
}
}
const char* CameraBobcat::get_camera_id(){
PvResult res;
PvString val;
// Get GenICam parameter object
PvGenString *str = dynamic_cast<PvGenString *>( mDevice->GetParameters()->Get( "DeviceID" ) );
if(str)
res = str->GetValue(val);
if( str && res.IsOK() )
{
return val.GetAscii();
}
else{
return NULL;
}
}
float CameraBobcat::get_camera_temperature(){
PvResult res;
int64_t val = -1;
// Get GenICam parameter object
PvGenInteger *lInt = dynamic_cast<PvGenInteger *>( mDevice->GetParameters()->Get( "CurrentTemperature" ) );
if(lInt)
res = lInt->GetValue(val);
if( lInt && res.IsOK() )
{
return (float)val;
}
else{
return -1;
}
}
bool CameraBobcat::store_configuration(const char* file_path)
{
if (mDevice == NULL || mStream == NULL)
{
return false;
}
const PvDeviceInfo *lDeviceInfo = NULL;
PvResult lResult = PvResult::Code::INVALID_PARAMETER;
PvConfigurationWriter lWriter;
lWriter.Store(mDevice, DEVICE_CONFIGURATION_TAG);
lWriter.Store(mStream, STREAM_CONFIGURAITON_TAG);
lResult = lWriter.Save(file_path);
if ( !lResult.IsOK() )
{
cout<<"Can't save configuration file."<<endl;
return false;
}
return true;
}
bool CameraBobcat::restore_configuration(const char* file_path)
{
if (mDevice == NULL || !mDevice->IsConnected())
{
return false;
}
PvConfigurationReader lReader;
lReader.Load(file_path);
PvResult lResult = lReader.Restore(DEVICE_CONFIGURATION_TAG, mDevice);
if ( !lResult.IsOK() )
{
cout<<"Can't restore the device configuration."<<endl;
return false;
}
lResult = lReader.Restore( STREAM_CONFIGURAITON_TAG, mStream );
if ( !lResult.IsOK() )
{
cout<<"Can't restore the stream configuration."<<endl;
return false;
}
return true;
}
| 29.16221 | 116 | 0.616504 | [
"object",
"vector"
] |
b0c65da852d53ec38c65516355e2f3daf7e83e71 | 17,256 | cpp | C++ | Hotel_management_System/report_management.cpp | stream12138/- | 1ac74a88b23e277f0163c384cbb085525800f918 | [
"MIT"
] | 3 | 2021-01-09T00:53:27.000Z | 2021-03-08T11:29:01.000Z | Hotel_management_System/report_management.cpp | stream12138/- | 1ac74a88b23e277f0163c384cbb085525800f918 | [
"MIT"
] | 1 | 2021-01-05T13:28:50.000Z | 2021-01-06T14:44:34.000Z | Hotel_management_System/report_management.cpp | stream12138/-Rookie-mutual-carry | 1ac74a88b23e277f0163c384cbb085525800f918 | [
"MIT"
] | null | null | null | #include "report_management.h"
#include "ui_report_management.h"
Report_management::Report_management(QWidget *parent) :
QWidget(parent),
ui(new Ui::Report_management)
{
ui->setupUi(this);
ui->dateEdit_3->setDateTime(QDateTime::currentDateTime());
ui->dateEdit_4->setDateTime(QDateTime::currentDateTime());
ui->dateEdit_5->setDateTime(QDateTime::currentDateTime());
//ui->dateEdit_2->setDateTime(QDateTime::currentDateTime().addDays(1));
this->setWindowFlags(Qt::CustomizeWindowHint|Qt::FramelessWindowHint);
this->hide();
this->setParent(parent);
QIcon myicon1(tr(":/littlebutton/Print.png")); //新建QIcon对象
ui->pushButton_10->setIcon(myicon1);
ui->pushButton_10->setIconSize(QSize(110,70));
QIcon myicon2(tr(":/littlebutton/Print.png")); //新建QIcon对象
ui->pushButton_11->setIcon(myicon2);
ui->pushButton_11->setIconSize(QSize(110,70));
QIcon myicon3(tr(":/littlebutton/Print.png")); //新建QIcon对象
ui->pushButton_12->setIcon(myicon3);
ui->pushButton_12->setIconSize(QSize(110,70));
QIcon myicon4(tr(":/littlebutton/Print.png")); //新建QIcon对象
ui->pushButton_13->setIcon(myicon4);
ui->pushButton_13->setIconSize(QSize(110,70));
QIcon myicon5(tr(":/littlebutton/Print.png")); //新建QIcon对象
ui->pushButton_14->setIcon(myicon5);
ui->pushButton_14->setIconSize(QSize(110,70));
QIcon myicon6(tr(":/littlebutton/Print.png")); //新建QIcon对象
ui->pushButton_15->setIcon(myicon6);
ui->pushButton_15->setIconSize(QSize(110,70));
query_model = new QSqlQueryModel;
this->init_charts();
//创建模型
model = new QSqlTableModel(this);
model->setTable("Guest");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);// 设置编辑策略
model->select(); //选取整个表的所有行
QString str = "";
model->setFilter(tr("bookstart like '%1'").arg("%"+str+"%"));
model->setHeaderData(0,Qt::Horizontal,"顾客名字");
model->setHeaderData(1,Qt::Horizontal,"个人ID");
model->setHeaderData(2,Qt::Horizontal,"电话号码");
model->setHeaderData(3,Qt::Horizontal,"是否为VIP");
model->setHeaderData(4,Qt::Horizontal,"VIP号码");
model->setHeaderData(5,Qt::Horizontal,"入住房间");
model->setHeaderData(6,Qt::Horizontal,"预定入住");
model->setHeaderData(7,Qt::Horizontal,"预定离开");
// model->setHeaderData(8,Qt::Horizontal,"入住时间");
// model->setHeaderData(9,Qt::Horizontal,"离开时间");
// model->setHeaderData(10,Qt::Horizontal,"应缴金额");
model->removeColumn(8);
model->removeColumn(8);
model->removeColumn(8);
ui->tableView_2->setModel(model);
ui->tableView_2->show();
}
void Report_management::init_charts()
{
//显示表格数据
query_model->setQuery("SELECT income FROM Income");
int row = query_model->rowCount();
QChart *chart = new QChart;
chart->setAnimationOptions(QChart::AllAnimations);
QBarSeries *series = new QBarSeries;
QVBarModelMapper *mapper = new QVBarModelMapper(this);
mapper->setFirstBarSetColumn(0);
mapper->setLastBarSetColumn(1);
mapper->setFirstRow(0);
mapper->setRowCount(row);
mapper->setSeries(series);
mapper->setModel(query_model);
chart->addSeries(series);
QDate time2 = ui->dateEdit->date();
QDate time1 = ui->dateEdit_2->date();
qint64 Time_difference = time1.daysTo(time2);
QStringList categories;
//修改坐标字段
if(Time_difference>=6)
{
QBarCategoryAxis *axisX = new QBarCategoryAxis();
for(int i = 0;i<=Time_difference;i++)
{
categories << time1.addDays(i).toString("MM/dd");
//qDebug()<<time1.addDays(i).toString("MM/dd");
axisX->append(categories);
}
chart->addAxis(axisX, Qt::AlignBottom);
series->attachAxis(axisX);
}
else
{
QBarCategoryAxis *axisX = new QBarCategoryAxis();
for(int i = 0;i<=Time_difference;i++)
{
categories << time1.addDays(i).toString("yyyy/MM/dd");
//qDebug()<<time1.addDays(i).toString("yyyy/MM/dd");
axisX->append(categories);
}
chart->addAxis(axisX, Qt::AlignBottom);
series->attachAxis(axisX);
}
QValueAxis *axisY = new QValueAxis();
chart->addAxis(axisY, Qt::AlignLeft);
series->attachAxis(axisY);
ui->chartView->setChart(chart);
ui->chartView->setRenderHint(QPainter::Antialiasing);
}
Report_management::~Report_management()
{
delete ui;
}
void Report_management::on_tabWidget_currentChanged(int index)
{
if(index==0)//预定报表
{
//创建模型
model = new QSqlTableModel(this);
model->setTable("Guest");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);// 设置编辑策略
model->select(); //选取整个表的所有行
QString str = "";
model->setFilter(tr("bookstart like '%1'").arg("%"+str+"%"));
model->setHeaderData(0,Qt::Horizontal,"顾客名字");
model->setHeaderData(1,Qt::Horizontal,"个人ID");
model->setHeaderData(2,Qt::Horizontal,"电话号码");
model->setHeaderData(3,Qt::Horizontal,"是否为VIP");
model->setHeaderData(4,Qt::Horizontal,"VIP号码");
model->setHeaderData(5,Qt::Horizontal,"入住房间");
model->setHeaderData(6,Qt::Horizontal,"预定入住");
model->setHeaderData(7,Qt::Horizontal,"预定离开");
// model->setHeaderData(8,Qt::Horizontal,"入住时间");
// model->setHeaderData(9,Qt::Horizontal,"离开时间");
// model->setHeaderData(10,Qt::Horizontal,"应缴金额");
model->removeColumn(8);
model->removeColumn(8);
model->removeColumn(8);
ui->tableView_2->setModel(model);
ui->tableView_2->show();
}
if(index==1)//入住报表
{
//创建模型
model = new QSqlTableModel(this);
model->setTable("Guest");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);// 设置编辑策略
model->select(); //选取整个表的所有行
QString str = "";
model->setFilter(tr("startdate like '%1'").arg("%"+str+"%"));
model->setHeaderData(0,Qt::Horizontal,"顾客名字");
model->setHeaderData(1,Qt::Horizontal,"个人ID");
model->setHeaderData(2,Qt::Horizontal,"电话号码");
model->setHeaderData(3,Qt::Horizontal,"是否为VIP");
model->setHeaderData(4,Qt::Horizontal,"VIP号码");
model->setHeaderData(5,Qt::Horizontal,"入住房间");
model->setHeaderData(6,Qt::Horizontal,"入住时间");
model->setHeaderData(7,Qt::Horizontal,"离开时间");
model->removeColumn(10);
model->removeColumn(7);
model->removeColumn(6);
ui->tableView_3->setModel(model);
ui->tableView_3->show();
}
if(index==2)//当日客人预定报表
{
//创建模型
model = new QSqlTableModel(this);
model->setTable("Guest");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);// 设置编辑策略
model->select(); //选取整个表的所有行
QString str = ui->dateEdit_5->text();
model->setFilter(tr("bookstart like '%1'").arg("%"+str+"%"));
model->setHeaderData(0,Qt::Horizontal,"顾客名字");
model->setHeaderData(1,Qt::Horizontal,"个人ID");
model->setHeaderData(2,Qt::Horizontal,"电话号码");
model->setHeaderData(3,Qt::Horizontal,"是否为VIP");
model->setHeaderData(4,Qt::Horizontal,"VIP号码");
model->setHeaderData(5,Qt::Horizontal,"入住房间");
model->setHeaderData(6,Qt::Horizontal,"预定入住");
model->setHeaderData(7,Qt::Horizontal,"预定离开");
// model->setHeaderData(8,Qt::Horizontal,"入住时间");
// model->setHeaderData(9,Qt::Horizontal,"离开时间");
// model->setHeaderData(10,Qt::Horizontal,"应缴金额");
model->removeColumn(8);
model->removeColumn(8);
model->removeColumn(8);
ui->tableView_4->setModel(model);
ui->tableView_4->show();
}
if(index==3)//当日入住顾客报表
{
//创建模型
model = new QSqlTableModel(this);
model->setTable("Guest");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);// 设置编辑策略
model->select(); //选取整个表的所有行
QString str = ui->dateEdit_3->text();
model->setFilter(tr("startdate like '%1'").arg("%"+str+"%"));
model->setHeaderData(0,Qt::Horizontal,"顾客名字");
model->setHeaderData(1,Qt::Horizontal,"个人ID");
model->setHeaderData(2,Qt::Horizontal,"电话号码");
model->setHeaderData(3,Qt::Horizontal,"是否为VIP");
model->setHeaderData(4,Qt::Horizontal,"VIP号码");
model->setHeaderData(5,Qt::Horizontal,"入住房间");
model->setHeaderData(6,Qt::Horizontal,"入住时间");
model->setHeaderData(7,Qt::Horizontal,"离开时间");
model->removeColumn(10);
model->removeColumn(7);
model->removeColumn(6);
ui->tableView_5->setModel(model);
ui->tableView_5->show();
}
if(index==4)//当日离店顾客报表
{
//创建模型
model = new QSqlTableModel(this);
model->setTable("Guest");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);// 设置编辑策略
model->select(); //选取整个表的所有行
QString str = ui->dateEdit_4->text();
qDebug()<<str;
model->setFilter(tr("endingdate like '%1'").arg("%"+str+"%"));
model->select();
model->setHeaderData(0,Qt::Horizontal,"顾客名字");
model->setHeaderData(1,Qt::Horizontal,"个人ID");
model->setHeaderData(2,Qt::Horizontal,"电话号码");
model->setHeaderData(3,Qt::Horizontal,"是否为VIP");
model->setHeaderData(4,Qt::Horizontal,"VIP号码");
model->setHeaderData(5,Qt::Horizontal,"入住房间");
model->setHeaderData(6,Qt::Horizontal,"入住时间");
model->setHeaderData(7,Qt::Horizontal,"离开时间");
model->removeColumn(10);
model->removeColumn(7);
model->removeColumn(6);
ui->tableView_6->setModel(model);
ui->tableView_6->show();
}
}
void Report_management::on_pushButton_clicked()
{
this->init_charts();
}
void Report_management::on_pushButton_2_clicked()
{
on_tabWidget_currentChanged(3);
}
void Report_management::on_pushButton_3_clicked()
{
on_tabWidget_currentChanged(4);
}
void Report_management::on_pushButton_4_clicked()
{
on_tabWidget_currentChanged(2);
}
void Report_management::on_pushButton_10_clicked()
{
// 生成PDF文件
QPrinter printer;
QPixmap image;
// QPainter painter(&printer);
image = image.grabWidget(this,40,50,740,580);
QString fileName = QFileDialog::getSaveFileName(this, tr("导出PDF文件"),
QString(), "*.pdf");
if (!fileName.isEmpty()) {
// 如果文件后缀为空,则默认使用.pdf
if (QFileInfo(fileName).suffix().isEmpty())
fileName.append(".pdf");
printer.setOutputFileName(fileName);
QPixmap pixmap=QPixmap::grabWidget(ui->tableView_2,ui->tableView_2->rect()); //抓取界面widget区域,可以抓取任意控件区域,Qt5推荐新的API QWidget::grab
QPainter painter;
painter.begin(&printer);
QRect rect=painter.viewport(); //获取painter的视口区域
int factor=rect.width()/pixmap.width(); //计算painter视口区域与抓取图片区域的尺寸比例因子
painter.scale(factor*1.0,factor*1.0); //绘制时按照比例因子放大
painter.drawPixmap(10,10,pixmap); //按照坐标画图
printer.setPageSize(QPrinter::A4);
printer.setOutputFormat(QPrinter::PdfFormat);
}
}
void Report_management::on_pushButton_11_clicked()
{
// 生成PDF文件
QPrinter printer;
QPixmap image;
// QPainter painter(&printer);
image = image.grabWidget(this,40,50,740,580);
QString fileName = QFileDialog::getSaveFileName(this, tr("导出PDF文件"),
QString(), "*.pdf");
if (!fileName.isEmpty()) {
// 如果文件后缀为空,则默认使用.pdf
if (QFileInfo(fileName).suffix().isEmpty())
fileName.append(".pdf");
printer.setOutputFileName(fileName);
QPixmap pixmap=QPixmap::grabWidget(ui->tableView_3,ui->tableView_3->rect()); //抓取界面widget区域,可以抓取任意控件区域,Qt5推荐新的API QWidget::grab
QPainter painter;
painter.begin(&printer);
QRect rect=painter.viewport(); //获取painter的视口区域
int factor=rect.width()/pixmap.width(); //计算painter视口区域与抓取图片区域的尺寸比例因子
painter.scale(factor*1.0,factor*1.0); //绘制时按照比例因子放大
painter.drawPixmap(10,10,pixmap); //按照坐标画图
printer.setPageSize(QPrinter::A4);
printer.setOutputFormat(QPrinter::PdfFormat);
}
}
void Report_management::on_pushButton_12_clicked()
{
// 生成PDF文件
QPrinter printer;
QPixmap image;
// QPainter painter(&printer);
image = image.grabWidget(this,40,50,740,580);
QString fileName = QFileDialog::getSaveFileName(this, tr("导出PDF文件"),
QString(), "*.pdf");
if (!fileName.isEmpty()) {
// 如果文件后缀为空,则默认使用.pdf
if (QFileInfo(fileName).suffix().isEmpty())
fileName.append(".pdf");
printer.setOutputFileName(fileName);
QPixmap pixmap=QPixmap::grabWidget(ui->tableView_4,ui->tableView_4->rect()); //抓取界面widget区域,可以抓取任意控件区域,Qt5推荐新的API QWidget::grab
QPainter painter;
painter.begin(&printer);
QRect rect=painter.viewport(); //获取painter的视口区域
int factor=rect.width()/pixmap.width(); //计算painter视口区域与抓取图片区域的尺寸比例因子
painter.scale(factor*1.0,factor*1.0); //绘制时按照比例因子放大
painter.drawPixmap(10,10,pixmap); //按照坐标画图
printer.setPageSize(QPrinter::A4);
printer.setOutputFormat(QPrinter::PdfFormat);
}
}
void Report_management::on_pushButton_13_clicked()
{
// 生成PDF文件
QPrinter printer;
QPixmap image;
// QPainter painter(&printer);
image = image.grabWidget(this,40,50,740,580);
QString fileName = QFileDialog::getSaveFileName(this, tr("导出PDF文件"),
QString(), "*.pdf");
if (!fileName.isEmpty()) {
// 如果文件后缀为空,则默认使用.pdf
if (QFileInfo(fileName).suffix().isEmpty())
fileName.append(".pdf");
printer.setOutputFileName(fileName);
QPixmap pixmap=QPixmap::grabWidget(ui->tableView_5,ui->tableView_5->rect()); //抓取界面widget区域,可以抓取任意控件区域,Qt5推荐新的API QWidget::grab
QPainter painter;
painter.begin(&printer);
QRect rect=painter.viewport(); //获取painter的视口区域
int factor=rect.width()/pixmap.width(); //计算painter视口区域与抓取图片区域的尺寸比例因子
painter.scale(factor*1.0,factor*1.0); //绘制时按照比例因子放大
painter.drawPixmap(10,10,pixmap); //按照坐标画图
printer.setPageSize(QPrinter::A4);
printer.setOutputFormat(QPrinter::PdfFormat);
}
}
void Report_management::on_pushButton_14_clicked()
{
// 生成PDF文件
QPrinter printer;
QPixmap image;
// QPainter painter(&printer);
image = image.grabWidget(this,40,50,740,580);
QString fileName = QFileDialog::getSaveFileName(this, tr("导出PDF文件"),
QString(), "*.pdf");
if (!fileName.isEmpty()) {
// 如果文件后缀为空,则默认使用.pdf
if (QFileInfo(fileName).suffix().isEmpty())
fileName.append(".pdf");
printer.setOutputFileName(fileName);
QPixmap pixmap=QPixmap::grabWidget(ui->tableView_6,ui->tableView_6->rect()); //抓取界面widget区域,可以抓取任意控件区域,Qt5推荐新的API QWidget::grab
QPainter painter;
painter.begin(&printer);
QRect rect=painter.viewport(); //获取painter的视口区域
int factor=rect.width()/pixmap.width(); //计算painter视口区域与抓取图片区域的尺寸比例因子
painter.scale(factor*1.0,factor*1.0); //绘制时按照比例因子放大
painter.drawPixmap(10,10,pixmap); //按照坐标画图
printer.setPageSize(QPrinter::A4);
printer.setOutputFormat(QPrinter::PdfFormat);
}
}
void Report_management::on_pushButton_15_clicked()
{
// 生成PDF文件
QPrinter printer;
QPixmap image;
// QPainter painter(&printer);
image = image.grabWidget(this,40,50,740,580);
QString fileName = QFileDialog::getSaveFileName(this, tr("导出PDF文件"),
QString(), "*.pdf");
if (!fileName.isEmpty()) {
// 如果文件后缀为空,则默认使用.pdf
if (QFileInfo(fileName).suffix().isEmpty())
fileName.append(".pdf");
printer.setOutputFileName(fileName);
QPixmap pixmap=QPixmap::grabWidget(ui->chartView,ui->chartView->rect()); //抓取界面widget区域,可以抓取任意控件区域,Qt5推荐新的API QWidget::grab
QPainter painter;
painter.begin(&printer);
QRect rect=painter.viewport(); //获取painter的视口区域
int factor=rect.width()/pixmap.width(); //计算painter视口区域与抓取图片区域的尺寸比例因子
painter.scale(factor*1.0,factor*1.0); //绘制时按照比例因子放大
painter.drawPixmap(10,10,pixmap); //按照坐标画图
printer.setPageSize(QPrinter::A4);
printer.setOutputFormat(QPrinter::PdfFormat);
}
}
| 38.517857 | 140 | 0.604543 | [
"model"
] |
37d46358c58c8c2dd4276a430310c59cd70e873c | 2,269 | cpp | C++ | engine/time/source/TileTransformObserver.cpp | prolog/shadow-of-the-wyrm | a1312c3e9bb74473f73c4e7639e8bd537f10b488 | [
"MIT"
] | 60 | 2019-08-21T04:08:41.000Z | 2022-03-10T13:48:04.000Z | engine/time/source/TileTransformObserver.cpp | prolog/shadow-of-the-wyrm | a1312c3e9bb74473f73c4e7639e8bd537f10b488 | [
"MIT"
] | 3 | 2021-03-18T15:11:14.000Z | 2021-10-20T12:13:07.000Z | engine/time/source/TileTransformObserver.cpp | prolog/shadow-of-the-wyrm | a1312c3e9bb74473f73c4e7639e8bd537f10b488 | [
"MIT"
] | 8 | 2019-11-16T06:29:05.000Z | 2022-01-23T17:33:43.000Z | #include "AgeTimeObserver.hpp"
#include "TileTransformObserver.hpp"
#include "Game.hpp"
#include "TileGenerator.hpp"
using namespace std;
void TileTransformObserver::notify(const ulonglong minutes_passed)
{
double cur_seconds = 0;
Game& game = Game::instance();
World* world = game.get_current_world();
if (world != nullptr)
{
cur_seconds = world->get_calendar().get_seconds();
MapRegistry& mr = game.get_map_registry_ref();
MapRegistryMap& maps = mr.get_maps_ref();
for (auto& m_pair : maps)
{
MapPtr cur_map = m_pair.second;
if (cur_map != nullptr)
{
process_tile_transforms(cur_map, cur_seconds);
}
}
}
}
// Iterate over the tile transforms for this map, and if any have passed
// the minimum required time, do the transformation.
void TileTransformObserver::process_tile_transforms(MapPtr cur_map, const double cur_seconds)
{
if (cur_map != nullptr)
{
TileTransformContainer& ttc = cur_map->get_tile_transforms_ref();
for (auto t_it = ttc.begin(); t_it != ttc.end(); )
{
double seconds = t_it->first;
if (cur_seconds < seconds)
{
break;
}
else
{
vector<TileTransform> tt_vec = t_it->second;
for (const TileTransform tt : tt_vec)
{
Coordinate c = tt.get_coordinate();
TileGenerator tg;
TilePtr new_tile = tg.generate(tt.get_tile_type(), tt.get_tile_subtype(), tt.get_properties());
// Copy over features and items.
new_tile->transform_from(cur_map->at(c));
map<string, string> tt_props = tt.get_properties();
for (const auto& p_pair : tt_props)
{
new_tile->set_additional_property(p_pair.first, p_pair.second);
}
cur_map->insert(c, new_tile);
}
ttc.erase(t_it++);
}
}
}
}
std::unique_ptr<ITimeObserver> TileTransformObserver::clone()
{
std::unique_ptr<ITimeObserver> tto = std::make_unique<TileTransformObserver>(*this);
return tto;
}
ClassIdentifier TileTransformObserver::internal_class_identifier() const
{
return ClassIdentifier::CLASS_ID_TILE_TRANSFORM_OBSERVER;
}
#ifdef UNIT_TESTS
#include "unit_tests/TileTransformObserver_test.cpp"
#endif
| 24.138298 | 105 | 0.657999 | [
"vector"
] |
37d6d065283e71f76f19d9aa8f9e131a3071a1f8 | 12,646 | cpp | C++ | symtab.cpp | SonicStrain/Symbol-Table | 30d2dad6ee0ff7b481c41cc31d7acc8b17b4c869 | [
"MIT"
] | null | null | null | symtab.cpp | SonicStrain/Symbol-Table | 30d2dad6ee0ff7b481c41cc31d7acc8b17b4c869 | [
"MIT"
] | null | null | null | symtab.cpp | SonicStrain/Symbol-Table | 30d2dad6ee0ff7b481c41cc31d7acc8b17b4c869 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
fstream ofs;
map<string,string> hash_table;
map<string,string>::iterator itr;
//map<string,pair<int,vector<int>>> attr;
map<string,pair<pair<int,int>,vector<pair<int,int>>>> attr;
void lookUpValue(string key){
string result = "Not Found!";
for (itr = hash_table.begin(); itr != hash_table.end(); ++itr) {
if(itr->first == key){
cout << "\t<KEY>\t<VALUE>\n";
cout << '\t' << itr->first
<< '\t' << itr->second << '\n';
result = "Found!";
break;
}
}
cout << "\n" << result << "\n";
}
bool lookUpBool(string key){
bool result = false;
for (itr = hash_table.begin(); itr != hash_table.end(); ++itr) {
if(itr->first == key){
result = true;
break;
}
}
return result;
}
void findDeclaration(string key){
pair<pair<int,int>,vector<pair<int,int>>> p;
if(lookUpBool(key)){
for (itr = hash_table.begin(); itr != hash_table.end(); ++itr) {
if(itr->first == key){
p = attr[itr->first];
if(p.first.first != -1){
cout << "\nDeclaration Line : " << p.first.first << "\n";
}else{
cout << "\nDeclaration not needed!\n";
}
break;
}
}
}else{
cout << "key does not exist" << "\n";
}
}
void findReferances(string key){
pair<pair<int,int>,vector<pair<int,int>>> p;
vector <pair<int,int>> v;
string refs = "";
if(lookUpBool(key)){
for (itr = hash_table.begin(); itr != hash_table.end(); ++itr) {
if(itr->first == key){
p = attr[itr->first];
v = p.second;
for(int i=0;i<(int)v.size();i++){
refs += to_string(v[i].first);
refs += ",";
}
cout << "\nReferanced Lines : " << refs << "\n";
break;
}
}
}else{
cout << "key does not exist" << "\n";
}
}
int helperForScope(string key){
int result = 0;
for (itr = hash_table.begin(); itr != hash_table.end(); ++itr) {
if(itr->first == key){
if(itr->second == "Identifier"){
result = 2;
}else{
result = 1;
}
break;
}
}
return result;
}
void findScope(string key,int lineno){
int keyType = helperForScope(key);
pair<pair<int,int>,vector<pair<int,int>>> p;
vector <pair<int,int>> v;
int flag = 1,notFound = 1;
if(keyType == 2){
if(notFound){
for (itr = hash_table.begin(); itr != hash_table.end(); ++itr) {
if(itr->first == key){
p = attr[itr->first];
if(p.first.first == lineno){
cout << "\nScope : " << p.first.second << "\n";
notFound = 0;
flag = 0;
break;
}
}
}
}
if(notFound){
for (itr = hash_table.begin(); itr != hash_table.end(); ++itr) {
if(itr->first == key){
p = attr[itr->first];
v = p.second;
for(int i=0;i<(int)v.size();i++){
if(v[i].first == lineno){
cout << "\nScope : " << v[i].second << "\n";
flag = 0;
notFound = 0;
break;
}
}
break;
}
}
}
}else if(keyType == 1){
for (itr = hash_table.begin(); itr != hash_table.end(); ++itr) {
if(itr->first == key){
p = attr[itr->first];
v = p.second;
for(int i=0;i<(int)v.size();i++){
if(v[i].first == lineno){
cout << "\nScope : " << v[i].second << "\n";
flag = 0;
break;
}
}
break;
}
}
}else{
cout << "\nkey does not exist" << "\n";
}
if(flag) cout << "\nNo key present at line " << lineno << "\n";
}
void printTable(){
ofs.open("table.txt", ios::out | ios::trunc);
map<string,string>::iterator itr;
pair<pair<int,int>,vector<pair<int,int>>> p;
vector <pair<int,int>> v;
string refs = "";
ofs << "\tNAME\tCLASS\tDECLARED\tREFERANCED\n";
ofs << "\t------------------------------------\n";
cout << "\tNAME\tCLASS\tDECLARED\tREFERANCED\n";
cout << "\t------------------------------------\n";
for (itr = hash_table.begin(); itr != hash_table.end(); ++itr) {
p = attr[itr->first];
v = p.second;
for(int i=0;i<(int)v.size();i++){
refs += "[ "+ to_string(v[i].first) + " " + to_string(v[i].second) + " ]";
refs += ",";
}
ofs << '\t' << itr->first
<< '\t' << itr->second
<< '\t' << "[ " <<p.first.first << " " << p.first.second << " ]"
<< '\t' << refs << '\n';
cout << '\t' << itr->first
<< '\t' << itr->second
<< '\t' << "[ " <<p.first.first << " " << p.first.second << " ]"
<< '\t' << refs << '\n';
refs = "";
}
ofs.close();
}
void symbolTable(){
//take the file as input----------------------------
string inputFile , input;
inputFile = "../sampleCode/";
//cout << "Enter a file: " ;
//cin >> input;
input = inputFile + "test1.txt" ;
std::ifstream filePath;
filePath.open(input);
//--------------------------------------------------
//get the values into hashmap
ifstream paramFile;
paramFile.open("demo_table.txt");
string line;
string key;
string value;
string temp;
while ( paramFile.good() ){
getline(paramFile, line);
istringstream ss(line);
ss >> key >> value;
if(value == "Identifier"){
hash_table[key] = value;
}
}
paramFile.close();
//--------------------------------------------------
// for (itr = hash_table.begin(); itr != hash_table.end(); ++itr) {
// cout << '\t' << itr->first
// << " " << itr->second << '\n';
// }
for (itr = hash_table.begin(); itr != hash_table.end(); ++itr) {
if(itr->second == "Identifier"){
//if(filePath.is_open()){
unsigned int curLine = 0;
string line1;
bool flag = true;
vector <pair<int,int>> v;
pair<int,int> p;
int decLine;
int scpnum = 0;
while(!filePath.eof()) {
getline(filePath, line1);
curLine++;
//find scope
if(line1.find("{") != string::npos){
scpnum++;
}
if (line1.find(itr->first) != string::npos) {
//cout << "found: " << itr->second << " line: " << curLine << endl;
if(flag){
decLine = curLine;
p = make_pair(decLine,scpnum);
flag = false;
}else{
v.push_back(make_pair(curLine,scpnum));
}
}
if(line1.find("}") != string::npos){
scpnum--;
}
}
//add to attribute map
attr[itr->first] = make_pair(p,v);
v.clear();
filePath.clear();
filePath.seekg(0);
//}
}else{
//if(filePath.is_open()){
unsigned int curLine = 0;
string line1;
vector <pair<int,int>> v;
int scpnum = 0;
while(getline(filePath, line1)) {
curLine++;
//find scope
if(line1.find("{") != string::npos){
scpnum++;
}
if (line1.find(itr->first) != string::npos) {
//cout << "found: " << itr->second << " line: " << curLine << endl;
//add to the referance list
v.push_back(make_pair(curLine,scpnum));
}
// for(int i=0;i<(int)line1.size();i++){
// temp = line1[i];
// if( temp == itr->first){
// v.push_back(make_pair(curLine,scpnum));
// }
// }
if(line1.find("}") != string::npos){
scpnum--;
}
}
//add to attribute map
attr[itr->first] = make_pair(make_pair(-1,-1),v);
v.clear();
filePath.clear();
filePath.seekg(0);
// }
}
}
string holder;
for (itr = hash_table.begin(); itr != hash_table.end(); ++itr){
while(!filePath.eof()) {
getline(filePath, line);
if(line.find("string") != string::npos){
holder = "string";
}else if(line.find("int") != string::npos){
holder = "int";
}else if(line.find("float") != string::npos){
holder = "float";
}
if(line.find(itr->first) != string::npos){
hash_table[itr->first] = holder;
if(itr->first == "main"){
hash_table[itr->first] = "function";
}
break;
}
}
filePath.clear();
filePath.seekg(0);
}
filePath.close();
}
int main(){
symbolTable();
//--------------------------------------------------------------------------------------
printTable();
cout << "\n------------------------------------------------------------------------\n";
int selection = -1;
string keyID;
int lineno;
while (selection != 42)
{
std::cout << "\nEnter Your Choice:\n"
<< "\t1.Look up Symbol Table.\n"
<< "\t2.Look up Declaration.\n"
<< "\t3.Look up Referanced Lines.\n"
<< "\t4.Look up Scope.\n"
<< "\t0. exit" << std::endl;
std::cout << "\nEnter a value [0/1/2/3/4] -> ";
std::cin >> selection;
if (!std::cin.good())
{
std::cin.clear();
std::cin.ignore(std::cin.rdbuf()->in_avail());
continue;
}
switch (selection)
{
case 1:
cout << "\nEnter key : ";
cin >> keyID;
lookUpValue(keyID);
cout << "\n------------------------------------------------------------------------\n";
break;
case 2:
cout << "\nEnter key : ";
cin >> keyID;
findDeclaration(keyID);
cout << "\n------------------------------------------------------------------------\n";
break;
case 3:
cout << "\nEnter key : ";
cin >> keyID;
findReferances(keyID);
cout << "\n------------------------------------------------------------------------\n";
break;
case 4:
cout << "\nEnter key : ";
cin >> keyID;
cout << "\nEnter line no : ";
cin >> lineno;
findScope(keyID,lineno);
cout << "\n------------------------------------------------------------------------\n";
break;
case 0:
selection = 42;
}
}
return 0;
} | 29.341067 | 104 | 0.356318 | [
"vector"
] |
37ea635c781901ede6f50e1df198020bb3ebd00a | 4,377 | cpp | C++ | src/ZoneReversal.cpp | allandemiranda/forex-financial-analysis | 7688478607da258cb61bd7e009961083ee7849cf | [
"Unlicense"
] | null | null | null | src/ZoneReversal.cpp | allandemiranda/forex-financial-analysis | 7688478607da258cb61bd7e009961083ee7849cf | [
"Unlicense"
] | null | null | null | src/ZoneReversal.cpp | allandemiranda/forex-financial-analysis | 7688478607da258cb61bd7e009961083ee7849cf | [
"Unlicense"
] | null | null | null | /**
* @file ZoneReversal.cpp
* @author Allan de Miranda Silva (allandemiranda@gmail.com)
* @brief Métodos da classe ZoneReversal
* @version 0.1
* @date 18-10-2019
*
* @copyright Copyright (c) 2019
*
*/
#include "ZoneReversal.hpp"
#include <algorithm>
#include "Candlestick.hpp"
#include <iostream> // deletar
/**
* @brief Construa um novo objeto Zone Reversal:: Zone Reversal
*
* @param chart_a Gráfico
* @param zoneSize Tamanho da zona
* @param normalizador Número de normalização para gráfico de tendência
*/
ZoneReversal::ZoneReversal(Chart* chart_a, pip_t zoneSize,
unsigned int normalizador) {
setSizeOfZones(&zoneSize);
LinePrice grafico_tendencia(chart_a, normalizador, "Zone Reversal");
std::vector<price_t> valores_unicos;
for (auto i : grafico_tendencia.linha) {
valores_unicos.push_back(*i.getPrice());
}
valores_unicos.shrink_to_fit();
std::sort(valores_unicos.begin(), valores_unicos.end());
auto last = std::unique(valores_unicos.begin(), valores_unicos.end());
valores_unicos.erase(last, valores_unicos.end());
valores_unicos.shrink_to_fit();
price_t half_zoneSize_price = *Pip((*getSizeOfZones() / 2), true).getPrice();
#pragma omp parallel
{
#pragma omp for
for (unsigned long i = 0; i < valores_unicos.size(); ++i) {
price_t menor = valores_unicos.at(i) - half_zoneSize_price;
price_t maior = valores_unicos.at(i) + half_zoneSize_price;
unsigned long poder = 0;
for (unsigned long j = 0; j < grafico_tendencia.linha.size(); ++j) {
if ((*grafico_tendencia.linha.at(j).getPrice() >= menor) and
(*grafico_tendencia.linha.at(j).getPrice() <= maior)) {
++poder;
}
}
if (poder > 1) {
Zone temporaria(&maior, &menor, &poder,
chart_a->chart.front().getDate(),
chart_a->chart.back().getDate());
#pragma omp critical
{ zones.push_back(temporaria); }
}
}
}
std::sort(zones.begin(), zones.end());
zones.shrink_to_fit();
}
ZoneReversal::ZoneReversal(Chart* chart_a, pip_t zoneSize,
unsigned int normalizador, time_t dataInicial,
time_t dataFinal) {
setSizeOfZones(&zoneSize);
LinePrice grafico_tendencia(chart_a, normalizador, "Zone Reversal");
std::vector<price_t> valores_unicos;
for (auto i : grafico_tendencia.linha) {
valores_unicos.push_back(*i.getPrice());
}
valores_unicos.shrink_to_fit();
std::sort(valores_unicos.begin(), valores_unicos.end());
auto last = std::unique(valores_unicos.begin(), valores_unicos.end());
valores_unicos.erase(last, valores_unicos.end());
valores_unicos.shrink_to_fit();
price_t half_zoneSize_price = *Pip((*getSizeOfZones() / 2), true).getPrice();
#pragma omp parallel
{
#pragma omp for
for (unsigned long i = 0; i < valores_unicos.size(); ++i) {
price_t menor = valores_unicos.at(i) - half_zoneSize_price;
price_t maior = valores_unicos.at(i) + half_zoneSize_price;
unsigned long poder = 0;
for (unsigned long j = 0; j < grafico_tendencia.linha.size(); ++j) {
if ((*grafico_tendencia.linha.at(j).getPrice() >= menor) and
(*grafico_tendencia.linha.at(j).getPrice() <= maior)) {
if ((*grafico_tendencia.linha.at(j).getDate() >= dataInicial) and
(*grafico_tendencia.linha.at(j).getDate() <= dataFinal)) {
++poder;
}
}
}
if (poder > 1) {
Zone temporaria(&maior, &menor, &poder,
chart_a->chart.front().getDate(),
chart_a->chart.back().getDate());
#pragma omp critical
{ zones.push_back(temporaria); }
}
}
}
std::sort(zones.begin(), zones.end());
zones.shrink_to_fit();
}
/**
* @brief Destrua o objeto Zone Reversal:: Zone Reversal
*
*/
ZoneReversal::~ZoneReversal() {}
/**
* @brief Defina o objeto Size Of Zones
*
* @param new_size Tamanho da zona (número impar)
*/
void ZoneReversal::setSizeOfZones(pip_t* new_size) {
if (*new_size % 2 == 0) {
throw "ERRO! Determine um númro impar para o tamanho da zona";
} else {
sizeOfZones = *new_size;
}
}
/**
* @brief Obter o objeto Size Of Zones
*
* @return pip_t Tamanho da zona
*/
pip_t* ZoneReversal::getSizeOfZones(void) { return &sizeOfZones; } | 30.608392 | 79 | 0.638794 | [
"vector"
] |
37f56033169b16dc40796fc8de680ee691fe35ee | 9,503 | cpp | C++ | sdrs/src/v1/model/FailureJobParams.cpp | huaweicloud/huaweicloud-sdk-cpp-v3 | d3b5e07b0ee8367d1c7f6dad17be0212166d959c | [
"Apache-2.0"
] | 5 | 2021-03-03T08:23:43.000Z | 2022-02-16T02:16:39.000Z | sdrs/src/v1/model/FailureJobParams.cpp | ChenwxJay/huaweicloud-sdk-cpp-v3 | f821ec6d269b50203e0c1638571ee1349c503c41 | [
"Apache-2.0"
] | null | null | null | sdrs/src/v1/model/FailureJobParams.cpp | ChenwxJay/huaweicloud-sdk-cpp-v3 | f821ec6d269b50203e0c1638571ee1349c503c41 | [
"Apache-2.0"
] | 7 | 2021-02-26T13:53:35.000Z | 2022-03-18T02:36:43.000Z |
#include "huaweicloud/sdrs/v1/model/FailureJobParams.h"
namespace HuaweiCloud {
namespace Sdk {
namespace Sdrs {
namespace V1 {
namespace Model {
FailureJobParams::FailureJobParams()
{
jobType_ = "";
jobTypeIsSet_ = false;
jobStatus_ = "";
jobStatusIsSet_ = false;
beginTime_ = "";
beginTimeIsSet_ = false;
jobId_ = "";
jobIdIsSet_ = false;
failureStatus_ = "";
failureStatusIsSet_ = false;
resourceId_ = "";
resourceIdIsSet_ = false;
resourceName_ = "";
resourceNameIsSet_ = false;
errorCode_ = "";
errorCodeIsSet_ = false;
failReason_ = "";
failReasonIsSet_ = false;
resourceType_ = "";
resourceTypeIsSet_ = false;
}
FailureJobParams::~FailureJobParams() = default;
void FailureJobParams::validate()
{
}
web::json::value FailureJobParams::toJson() const
{
web::json::value val = web::json::value::object();
if(jobTypeIsSet_) {
val[utility::conversions::to_string_t("job_type")] = ModelBase::toJson(jobType_);
}
if(jobStatusIsSet_) {
val[utility::conversions::to_string_t("job_status")] = ModelBase::toJson(jobStatus_);
}
if(beginTimeIsSet_) {
val[utility::conversions::to_string_t("begin_time")] = ModelBase::toJson(beginTime_);
}
if(jobIdIsSet_) {
val[utility::conversions::to_string_t("job_id")] = ModelBase::toJson(jobId_);
}
if(failureStatusIsSet_) {
val[utility::conversions::to_string_t("failure_status")] = ModelBase::toJson(failureStatus_);
}
if(resourceIdIsSet_) {
val[utility::conversions::to_string_t("resource_id")] = ModelBase::toJson(resourceId_);
}
if(resourceNameIsSet_) {
val[utility::conversions::to_string_t("resource_name")] = ModelBase::toJson(resourceName_);
}
if(errorCodeIsSet_) {
val[utility::conversions::to_string_t("error_code")] = ModelBase::toJson(errorCode_);
}
if(failReasonIsSet_) {
val[utility::conversions::to_string_t("fail_reason")] = ModelBase::toJson(failReason_);
}
if(resourceTypeIsSet_) {
val[utility::conversions::to_string_t("resource_type")] = ModelBase::toJson(resourceType_);
}
return val;
}
bool FailureJobParams::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t("job_type"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("job_type"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setJobType(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("job_status"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("job_status"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setJobStatus(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("begin_time"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("begin_time"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setBeginTime(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("job_id"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("job_id"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setJobId(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("failure_status"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("failure_status"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setFailureStatus(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("resource_id"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("resource_id"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setResourceId(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("resource_name"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("resource_name"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setResourceName(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("error_code"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("error_code"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setErrorCode(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("fail_reason"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("fail_reason"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setFailReason(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("resource_type"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("resource_type"));
if(!fieldValue.is_null())
{
std::string refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setResourceType(refVal);
}
}
return ok;
}
std::string FailureJobParams::getJobType() const
{
return jobType_;
}
void FailureJobParams::setJobType(const std::string& value)
{
jobType_ = value;
jobTypeIsSet_ = true;
}
bool FailureJobParams::jobTypeIsSet() const
{
return jobTypeIsSet_;
}
void FailureJobParams::unsetjobType()
{
jobTypeIsSet_ = false;
}
std::string FailureJobParams::getJobStatus() const
{
return jobStatus_;
}
void FailureJobParams::setJobStatus(const std::string& value)
{
jobStatus_ = value;
jobStatusIsSet_ = true;
}
bool FailureJobParams::jobStatusIsSet() const
{
return jobStatusIsSet_;
}
void FailureJobParams::unsetjobStatus()
{
jobStatusIsSet_ = false;
}
std::string FailureJobParams::getBeginTime() const
{
return beginTime_;
}
void FailureJobParams::setBeginTime(const std::string& value)
{
beginTime_ = value;
beginTimeIsSet_ = true;
}
bool FailureJobParams::beginTimeIsSet() const
{
return beginTimeIsSet_;
}
void FailureJobParams::unsetbeginTime()
{
beginTimeIsSet_ = false;
}
std::string FailureJobParams::getJobId() const
{
return jobId_;
}
void FailureJobParams::setJobId(const std::string& value)
{
jobId_ = value;
jobIdIsSet_ = true;
}
bool FailureJobParams::jobIdIsSet() const
{
return jobIdIsSet_;
}
void FailureJobParams::unsetjobId()
{
jobIdIsSet_ = false;
}
std::string FailureJobParams::getFailureStatus() const
{
return failureStatus_;
}
void FailureJobParams::setFailureStatus(const std::string& value)
{
failureStatus_ = value;
failureStatusIsSet_ = true;
}
bool FailureJobParams::failureStatusIsSet() const
{
return failureStatusIsSet_;
}
void FailureJobParams::unsetfailureStatus()
{
failureStatusIsSet_ = false;
}
std::string FailureJobParams::getResourceId() const
{
return resourceId_;
}
void FailureJobParams::setResourceId(const std::string& value)
{
resourceId_ = value;
resourceIdIsSet_ = true;
}
bool FailureJobParams::resourceIdIsSet() const
{
return resourceIdIsSet_;
}
void FailureJobParams::unsetresourceId()
{
resourceIdIsSet_ = false;
}
std::string FailureJobParams::getResourceName() const
{
return resourceName_;
}
void FailureJobParams::setResourceName(const std::string& value)
{
resourceName_ = value;
resourceNameIsSet_ = true;
}
bool FailureJobParams::resourceNameIsSet() const
{
return resourceNameIsSet_;
}
void FailureJobParams::unsetresourceName()
{
resourceNameIsSet_ = false;
}
std::string FailureJobParams::getErrorCode() const
{
return errorCode_;
}
void FailureJobParams::setErrorCode(const std::string& value)
{
errorCode_ = value;
errorCodeIsSet_ = true;
}
bool FailureJobParams::errorCodeIsSet() const
{
return errorCodeIsSet_;
}
void FailureJobParams::unseterrorCode()
{
errorCodeIsSet_ = false;
}
std::string FailureJobParams::getFailReason() const
{
return failReason_;
}
void FailureJobParams::setFailReason(const std::string& value)
{
failReason_ = value;
failReasonIsSet_ = true;
}
bool FailureJobParams::failReasonIsSet() const
{
return failReasonIsSet_;
}
void FailureJobParams::unsetfailReason()
{
failReasonIsSet_ = false;
}
std::string FailureJobParams::getResourceType() const
{
return resourceType_;
}
void FailureJobParams::setResourceType(const std::string& value)
{
resourceType_ = value;
resourceTypeIsSet_ = true;
}
bool FailureJobParams::resourceTypeIsSet() const
{
return resourceTypeIsSet_;
}
void FailureJobParams::unsetresourceType()
{
resourceTypeIsSet_ = false;
}
}
}
}
}
}
| 23.937028 | 105 | 0.661265 | [
"object",
"model"
] |
37f91b93f281bee341977426f7f74d277da7925d | 1,832 | cpp | C++ | SPOJ/CANDY3 - Candy III.cpp | ravirathee/Competitive-Programming | 20a0bfda9f04ed186e2f475644e44f14f934b533 | [
"Unlicense"
] | 6 | 2018-11-26T02:38:07.000Z | 2021-07-28T00:16:41.000Z | SPOJ/CANDY3 - Candy III.cpp | ravirathee/Competitive-Programming | 20a0bfda9f04ed186e2f475644e44f14f934b533 | [
"Unlicense"
] | 1 | 2021-05-30T09:25:53.000Z | 2021-06-05T08:33:56.000Z | SPOJ/CANDY3 - Candy III.cpp | ravirathee/Competitive-Programming | 20a0bfda9f04ed186e2f475644e44f14f934b533 | [
"Unlicense"
] | 4 | 2020-04-16T07:15:01.000Z | 2020-12-04T06:26:07.000Z | /*CANDY3 - Candy III
#ad-hoc-1
A class went to a school trip. And, as usually, all N kids have got their backpacks stuffed with candy. But soon quarrels started all over the place, as some of the kids had more candies than others. Soon, the teacher realized that he has to step in: "Everybody, listen! Put all the candies you have on this table here!"
Soon, there was quite a large heap of candies on the teacher's table. "Now, I will divide the candies into N equal heaps and everyone will get one of them." announced the teacher.
"Wait, is this really possible?" wondered some of the smarter kids.
Problem specification
You are given the number of candies each child brought. Find out whether the teacher can divide the candies into N exactly equal heaps. (For the purpose of this task, all candies are of the same type.)
Input specification
The first line of the input file contains an integer T specifying the number of test cases. Each test case is preceded by a blank line.
Each test case looks as follows: The first line contains N : the number of children. Each of the next N lines contains the number of candies one child brought.
Output specification
For each of the test cases output a single line with a single word "YES" if the candies can be distributed equally, or "NO" otherwise.
Example
Input:
2
5
5
2
7
3
8
6
7
11
2
7
3
4
Output:
YES
NO
*/
#include <iostream>
#include <vector>
int main()
{
int tests;
std::cin >> tests;
while (tests--)
{
long long n, tmp, sum = 0;
std::cin >> n;
for (int i = 0; i < n; ++i)
{
std::cin >> tmp;
sum += tmp;
sum %= n;
}
if (sum % n == 0)
std::cout << "YES\n";
else
std::cout << "NO\n";
}
return 0;
}
| 24.756757 | 320 | 0.658843 | [
"vector"
] |
37fbe4b027f1db000d73d9bf6dd60518f0d91825 | 4,975 | cpp | C++ | cisco-ios-xr/ydk/models/cisco_ios_xr/Cisco_IOS_XR_sysadmin_fpd_infra_cli_fpd.cpp | CiscoDevNet/ydk-cpp | ef7d75970f2ef1154100e0f7b0a2ee823609b481 | [
"ECL-2.0",
"Apache-2.0"
] | 17 | 2016-12-02T05:45:49.000Z | 2022-02-10T19:32:54.000Z | cisco-ios-xr/ydk/models/cisco_ios_xr/Cisco_IOS_XR_sysadmin_fpd_infra_cli_fpd.cpp | CiscoDevNet/ydk-cpp | ef7d75970f2ef1154100e0f7b0a2ee823609b481 | [
"ECL-2.0",
"Apache-2.0"
] | 2 | 2017-03-27T15:22:38.000Z | 2019-11-05T08:30:16.000Z | cisco-ios-xr/ydk/models/cisco_ios_xr/Cisco_IOS_XR_sysadmin_fpd_infra_cli_fpd.cpp | CiscoDevNet/ydk-cpp | ef7d75970f2ef1154100e0f7b0a2ee823609b481 | [
"ECL-2.0",
"Apache-2.0"
] | 11 | 2016-12-02T05:45:52.000Z | 2019-11-07T08:28:17.000Z |
#include <sstream>
#include <iostream>
#include <ydk/entity_util.hpp>
#include "bundle_info.hpp"
#include "generated_entity_lookup.hpp"
#include "Cisco_IOS_XR_sysadmin_fpd_infra_cli_fpd.hpp"
using namespace ydk;
namespace cisco_ios_xr {
namespace Cisco_IOS_XR_sysadmin_fpd_infra_cli_fpd {
Fpd::Fpd()
:
config(std::make_shared<Fpd::Config>())
{
config->parent = this;
yang_name = "fpd"; yang_parent_name = "Cisco-IOS-XR-sysadmin-fpd-infra-cli-fpd"; is_top_level_class = true; has_list_ancestor = false;
}
Fpd::~Fpd()
{
}
bool Fpd::has_data() const
{
if (is_presence_container) return true;
return (config != nullptr && config->has_data());
}
bool Fpd::has_operation() const
{
return is_set(yfilter)
|| (config != nullptr && config->has_operation());
}
std::string Fpd::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "Cisco-IOS-XR-sysadmin-fpd-infra-cli-fpd:fpd";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Fpd::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Fpd::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
if(child_yang_name == "config")
{
if(config == nullptr)
{
config = std::make_shared<Fpd::Config>();
}
return config;
}
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Fpd::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
if(config != nullptr)
{
_children["config"] = config;
}
return _children;
}
void Fpd::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
}
void Fpd::set_filter(const std::string & value_path, YFilter yfilter)
{
}
std::shared_ptr<ydk::Entity> Fpd::clone_ptr() const
{
return std::make_shared<Fpd>();
}
std::string Fpd::get_bundle_yang_models_location() const
{
return ydk_cisco_ios_xr_models_path;
}
std::string Fpd::get_bundle_name() const
{
return "cisco_ios_xr";
}
augment_capabilities_function Fpd::get_augment_capabilities_function() const
{
return cisco_ios_xr_augment_lookup_tables;
}
std::map<std::pair<std::string, std::string>, std::string> Fpd::get_namespace_identity_lookup() const
{
return cisco_ios_xr_namespace_identity_lookup;
}
bool Fpd::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "config")
return true;
return false;
}
Fpd::Config::Config()
:
auto_upgrade{YType::enumeration, "auto-upgrade"}
{
yang_name = "config"; yang_parent_name = "fpd"; is_top_level_class = false; has_list_ancestor = false;
}
Fpd::Config::~Config()
{
}
bool Fpd::Config::has_data() const
{
if (is_presence_container) return true;
return auto_upgrade.is_set;
}
bool Fpd::Config::has_operation() const
{
return is_set(yfilter)
|| ydk::is_set(auto_upgrade.yfilter);
}
std::string Fpd::Config::get_absolute_path() const
{
std::ostringstream path_buffer;
path_buffer << "Cisco-IOS-XR-sysadmin-fpd-infra-cli-fpd:fpd/" << get_segment_path();
return path_buffer.str();
}
std::string Fpd::Config::get_segment_path() const
{
std::ostringstream path_buffer;
path_buffer << "config";
return path_buffer.str();
}
std::vector<std::pair<std::string, LeafData> > Fpd::Config::get_name_leaf_data() const
{
std::vector<std::pair<std::string, LeafData> > leaf_name_data {};
if (auto_upgrade.is_set || is_set(auto_upgrade.yfilter)) leaf_name_data.push_back(auto_upgrade.get_name_leafdata());
return leaf_name_data;
}
std::shared_ptr<ydk::Entity> Fpd::Config::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path)
{
return nullptr;
}
std::map<std::string, std::shared_ptr<ydk::Entity>> Fpd::Config::get_children() const
{
std::map<std::string, std::shared_ptr<ydk::Entity>> _children{};
char count_=0;
return _children;
}
void Fpd::Config::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix)
{
if(value_path == "auto-upgrade")
{
auto_upgrade = value;
auto_upgrade.value_namespace = name_space;
auto_upgrade.value_namespace_prefix = name_space_prefix;
}
}
void Fpd::Config::set_filter(const std::string & value_path, YFilter yfilter)
{
if(value_path == "auto-upgrade")
{
auto_upgrade.yfilter = yfilter;
}
}
bool Fpd::Config::has_leaf_or_child_of_name(const std::string & name) const
{
if(name == "auto-upgrade")
return true;
return false;
}
const Enum::YLeaf Fpd::Config::AutoUpgrade::enable {0, "enable"};
const Enum::YLeaf Fpd::Config::AutoUpgrade::disable {1, "disable"};
}
}
| 23.356808 | 157 | 0.692864 | [
"vector"
] |
37fe703c2af4404b8b65f35984464f3668854c80 | 3,723 | cpp | C++ | SolarSystem/Source/Viewers/IMGuiViewer/Drawers/Scene/Camera.cpp | janwaltl/SolarSystem | f148ed7aef00450bda3c6ae97166678a41872bdf | [
"MIT"
] | null | null | null | SolarSystem/Source/Viewers/IMGuiViewer/Drawers/Scene/Camera.cpp | janwaltl/SolarSystem | f148ed7aef00450bda3c6ae97166678a41872bdf | [
"MIT"
] | null | null | null | SolarSystem/Source/Viewers/IMGuiViewer/Drawers/Scene/Camera.cpp | janwaltl/SolarSystem | f148ed7aef00450bda3c6ae97166678a41872bdf | [
"MIT"
] | null | null | null | #include "Camera.h"
#include <vector>
#include <glad/glad.h>
#include "Source/Viewers/IMGuiViewer/OpenGL/Shader.h"
#include "Source/Viewers/IMGuiViewer/OpenGL/Error.h"
namespace solar
{
namespace
{
constexpr size_t matSize = 16 * sizeof(float);
constexpr size_t bufferSize = 6 * matSize;
//Cameras' UBOs will use this binding point
constexpr size_t UBOBinding = 4;
}
Camera::Camera()
{
targetObjectIndex = noTarget;
proj = view = MakeIdentity<float>();
glGenBuffers(1, &UBO);
glBindBuffer(GL_UNIFORM_BUFFER, UBO);
glBufferData(GL_UNIFORM_BUFFER, (GLsizeiptr)bufferSize, nullptr, GL_STREAM_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
Bind();
}
Camera::~Camera()
{
UnBind();
glDeleteBuffers(1, &UBO);
}
void Camera::LookAt(const Vec3d& newCamPos, const Vec3d& newTargetPos, const Vec3d& newUpDir)
{
camPos = newCamPos;
targetPos = newTargetPos;
auto dir = (camPos - targetPos).Normalize();
this->rightDir = CrossProduct(newUpDir, dir).Normalize();
this->upDir = CrossProduct(dir, rightDir);
view[0] = float(rightDir.x); view[4] = float(rightDir.y); view[8] = float(rightDir.z); view[12] = -float(DotProduct(camPos, rightDir));
view[1] = float(upDir.x); view[5] = float(upDir.y); view[9] = float(upDir.z); view[13] = -float(DotProduct(camPos, upDir));
view[2] = float(dir.x); view[6] = float(dir.y); view[10] = float(dir.z); view[14] = -float(DotProduct(camPos, dir));
view[3] = 0; view[7] = 0; view[11] = 0; view[15] = 1;
}
void Camera::Update(const SimData & data)
{
if (targetObjectIndex != noTarget)
{
assert(targetObjectIndex < data.Get().size());
LookAt(camPos, data[targetObjectIndex].pos, upDir);
}
UpdateCamera();
SubmitMatrices();
}
void Camera::Bind()
{
glBindBufferBase(GL_UNIFORM_BUFFER, UBOBinding, UBO);
}
void Camera::UnBind()
{
glBindBufferBase(GL_UNIFORM_BUFFER, UBOBinding, 0);
}
void Camera::Subscribe(const openGL::Shader& shader, const std::string& blockName) const
{
size_t blockIndex = shader.GetUniformBlockIndex(blockName);
//Bind it to correct index
glUniformBlockBinding(shader.GetID(), blockIndex, UBOBinding);
}
void Camera::SubmitMatrices()
{
//This is layout of buffer:
//
//mat4 projection;
//mat4 view;
//mat4 projView;
//mat4 invProj;
//mat4 invView;
//mat4 invProjView;
//
glBindBuffer(GL_UNIFORM_BUFFER, UBO);
glBufferSubData(GL_UNIFORM_BUFFER, 0 * matSize, matSize, proj.Data());
glBufferSubData(GL_UNIFORM_BUFFER, 1 * matSize, matSize, view.Data());
glBufferSubData(GL_UNIFORM_BUFFER, 2 * matSize, matSize, (proj*view).Data());
//TODO inverses if needed
//glBufferSubData(GL_UNIFORM_BUFFER, 3 * matSize, matSize, Inverse(projection).Data());
//glBufferSubData(GL_UNIFORM_BUFFER, 4 * matSize, matSize, Inverse(view).Data());
//glBufferSubData(GL_UNIFORM_BUFFER, 5 * matSize, matSize, Inverse(projection*view).Data());
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
PerspectiveCamera::PerspectiveCamera(float FOV, float AR, float near, float far)
{
proj = MakePerspective(FOV, AR, near, far);
}
OrthographicCamera::OrthographicCamera(float width, float height, float near, float far)
{
proj = MakeOrtho(width, height, near, far);
}
ScaledOrthoCamera::ScaledOrthoCamera(float width, float height, float near, float far) :
projOriginal(MakeOrtho(width, height, near, far))
{
proj = projOriginal;
}
void ScaledOrthoCamera::LookAt(const Vec3d & newCamPos, const Vec3d & newTargetPos, const Vec3d & newUpDir)
{
Camera::LookAt(newCamPos, newTargetPos, newUpDir);
proj = projOriginal;
auto dist = (newTargetPos - newCamPos).Length();
proj[0] /= static_cast<float>(dist);
proj[5] /= static_cast<float>(dist);
}
}
| 30.768595 | 137 | 0.703465 | [
"vector"
] |
5302225513ea4ff0e7262d0ceac548c620918804 | 1,122 | cpp | C++ | Dynamic Programming/357. Count Numbers with Unique Digits/main.cpp | Minecodecraft/LeetCode-Minecode | 185fd6efe88d8ffcad94e581915c41502a0361a0 | [
"MIT"
] | 1 | 2021-11-19T19:58:33.000Z | 2021-11-19T19:58:33.000Z | Dynamic Programming/357. Count Numbers with Unique Digits/main.cpp | Minecodecraft/LeetCode-Minecode | 185fd6efe88d8ffcad94e581915c41502a0361a0 | [
"MIT"
] | null | null | null | Dynamic Programming/357. Count Numbers with Unique Digits/main.cpp | Minecodecraft/LeetCode-Minecode | 185fd6efe88d8ffcad94e581915c41502a0361a0 | [
"MIT"
] | 2 | 2021-11-26T12:47:27.000Z | 2022-01-13T16:14:46.000Z | //
// main.cpp
// 357. Count Numbers with Unique Digits
//
// Created by 边俊林 on 2019/9/4.
// Copyright © 2019 Minecode.Link. All rights reserved.
//
/* ------------------------------------------------------ *\
https://leetcode.com/problems/count-numbers-with-unique-digits/
\* ------------------------------------------------------ */
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;
/// Solution:
//
class Solution {
public:
int countNumbersWithUniqueDigits(int n) {
if (n <= 0) return 1;
vector<int> dp (n+1, 0);
dp[1] = 10;
for (int i = 2; i <= n; ++i) {
dp[i] = 9;
for (int j = 9; j >= (9-i+2); --j) {
dp[i] *= j;
}
dp[i] += dp[i-1];
}
return dp[n];
}
};
int main() {
Solution sol = Solution();
int n = 0;
int res = sol.countNumbersWithUniqueDigits(n);
cout << res << endl;
return 0;
}
| 21.169811 | 64 | 0.491087 | [
"vector"
] |
5306a884809cdd7a988bf1530f6cc78995a1db47 | 3,362 | cpp | C++ | sandbox/src/pawn/combat_controller.cpp | vitodtagliente/AwesomeEngine | eff06dbad1c4a168437f69800629a7e20619051c | [
"MIT"
] | 3 | 2019-08-15T18:57:20.000Z | 2020-01-09T22:19:26.000Z | sandbox/src/pawn/combat_controller.cpp | vitodtagliente/AwesomeEngine | eff06dbad1c4a168437f69800629a7e20619051c | [
"MIT"
] | null | null | null | sandbox/src/pawn/combat_controller.cpp | vitodtagliente/AwesomeEngine | eff06dbad1c4a168437f69800629a7e20619051c | [
"MIT"
] | null | null | null | #include "combat_controller.h"
#include <awesome/application/canvas.h>
#include <awesome/application/input.h>
#include <awesome/asset/asset_library.h>
#include <awesome/components/camera.h>
#include <awesome/components/sprite_animator.h>
#include <awesome/editor/layout.h>
#include <awesome/entity/entity.h>
#include <awesome/entity/world.h>
#include <awesome/graphics/renderer.h>
#include <awesome/graphics/texture_library.h>
#include "bullet.h"
void CombatController::init()
{
m_pawn = getOwner()->findComponent<Pawn>();
}
void CombatController::render(graphics::Renderer* const renderer)
{
if (m_type != Type::Ranged)
return;
if (m_crosshair && m_crosshair->data.has_value())
{
const Sprite& data = m_crosshair->data.value();
if (data.image)
{
std::shared_ptr<graphics::Texture> texture = graphics::TextureLibrary::instance().find(data.image->descriptor.id);
if (texture)
{
renderer->drawSprite(texture.get(), m_crosshairTransform.matrix(), data.rect);
}
}
}
}
void CombatController::update(const double /*deltaTime*/)
{
math::vec3& position = getOwner()->transform.position;
m_direction = m_pawn->getDirection();
Input& input = Input::instance();
if (input.isMousePositionValid())
{
m_direction = (Camera::main()->screenToWorldCoords(input.getMousePosition()) - position).normalize();
if (input.isKeyPressed(KeyCode::MouseWheelButton))
{
position = Camera::main()->screenToWorldCoords(input.getMousePosition());
}
}
auto angle = std::atan2(m_direction.y, m_direction.x);
m_crosshairTransform.position = position + math::vec3(
std::cos(angle) * m_crosshairRadius,
std::sin(angle) * m_crosshairRadius,
1.5f
);
m_crosshairTransform.update();
}
void CombatController::attack()
{
if (m_type == Type::Ranged)
{
Entity* const entity = World::instance().spawn(m_bulletPrefab, m_crosshairTransform.position);
Bullet* const bullet = entity->findComponent<Bullet>();
if (bullet)
{
bullet->shoot(m_direction);
}
}
else
{
SpriteAnimator* const animator = getOwner()->findComponent<SpriteAnimator>();
if (animator) animator->play("attack");
}
}
void CombatController::inspect()
{
Component::inspect();
editor::Layout::input("Type", m_type);
editor::Layout::input("Bullet Prefab", m_bulletPrefab);
editor::Layout::input("Crosshair", m_crosshair);
editor::Layout::input("Crosshair Radius", m_crosshairRadius);
}
json::value CombatController::serialize() const
{
json::value data = Component::serialize();
data["type"] = enumToString(m_type);
data["bulletPrefab"] = m_bulletPrefab ? ::serialize(m_bulletPrefab->descriptor.id) : "";
data["crosshair"] = m_crosshair ? ::serialize(m_crosshair->descriptor.id) : "";
data["crosshairRadius"] = m_crosshairRadius;
return data;
}
void CombatController::deserialize(const json::value& value)
{
Component::deserialize(value);
stringToEnum(value.safeAt("type").as_string(""), m_type);
uuid bulletId = uuid::Invalid;
::deserialize(value.safeAt("bulletPrefab"), bulletId);
m_bulletPrefab = AssetLibrary::instance().find<PrefabAsset>(bulletId);
uuid crosshairId = uuid::Invalid;
::deserialize(value.safeAt("crosshair"), crosshairId);
m_crosshair = AssetLibrary::instance().find<SpriteAsset>(crosshairId);
m_crosshairRadius = value.safeAt("crosshairRadius").as_number(1.f).as_float();
}
REFLECT_COMPONENT(CombatController) | 28.491525 | 117 | 0.73022 | [
"render",
"transform"
] |
53096a0901ae853a6ab6545c4c1aa42cc179f2a0 | 709 | cpp | C++ | AcCoRD2/src/basic_plane.cpp | Jackrekirby/AcCoRD2 | d712b3f7e73f32dc1894fcb79bec4510a13a9dce | [
"MIT"
] | null | null | null | AcCoRD2/src/basic_plane.cpp | Jackrekirby/AcCoRD2 | d712b3f7e73f32dc1894fcb79bec4510a13a9dce | [
"MIT"
] | null | null | null | AcCoRD2/src/basic_plane.cpp | Jackrekirby/AcCoRD2 | d712b3f7e73f32dc1894fcb79bec4510a13a9dce | [
"MIT"
] | null | null | null | // The AcCoRD 2 Simulator (Actor - based Communication via Reaction - Diffusion)
// Copyright 2021 Jack Kirby. All rights reserved.
// For license details, read LICENSE.txt in the root AcCoRD2 directory
#include "pch.h"
#include "basic_plane.h"
namespace accord::shape::basic
{
Plane::Plane(double position, Axis3D axis)
: position(position), axis(axis)
{
}
const Axis3D& Plane::GetAxis() const
{
return axis;
}
const double& Plane::GetPosition() const
{
return position;
}
void Plane::ToJson(Json& j) const
{
j = *this;
}
void to_json(Json& j, const Plane& plane)
{
j["type"] = "plane";
j["position"] = plane.GetPosition();
j["axis"] = EnumToString(plane.GetAxis());
}
} | 19.162162 | 80 | 0.675599 | [
"shape"
] |
530987e0790f2fc0e77374b7666632fd9156a937 | 6,041 | hpp | C++ | src/NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyBoundaryFluxesLocalTimeStepping.hpp | osheamonn/spectre | 4a3332c61d749d83c161ea1c2ea014a937fd5dd8 | [
"MIT"
] | null | null | null | src/NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyBoundaryFluxesLocalTimeStepping.hpp | osheamonn/spectre | 4a3332c61d749d83c161ea1c2ea014a937fd5dd8 | [
"MIT"
] | null | null | null | src/NumericalAlgorithms/DiscontinuousGalerkin/Actions/ApplyBoundaryFluxesLocalTimeStepping.hpp | osheamonn/spectre | 4a3332c61d749d83c161ea1c2ea014a937fd5dd8 | [
"MIT"
] | null | null | null | // Distributed under the MIT License.
// See LICENSE.txt for details.
#pragma once
#include <cstddef>
#include <tuple>
#include "DataStructures/DataBox/DataBox.hpp"
#include "DataStructures/DataBox/DataBoxTag.hpp"
#include "DataStructures/VariablesHelpers.hpp"
#include "Domain/IndexToSliceAt.hpp"
#include "Domain/Tags.hpp" // IWYU pragma: keep // for db::item_type<Tags::Mesh<...>>
#include "NumericalAlgorithms/DiscontinuousGalerkin/FluxCommunicationTypes.hpp"
#include "NumericalAlgorithms/DiscontinuousGalerkin/MortarHelpers.hpp"
#include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp" // IWYU pragma: keep // for db::item_type<Tags::Mortars<...>>
#include "Time/Tags.hpp" // IWYU pragma: keep // for db::item_type<Tags::TimeStep>
// IWYU pragma: no_include "Time/Time.hpp" // for TimeDelta
#include "Utilities/Gsl.hpp"
#include "Utilities/TaggedTuple.hpp"
/// \cond
// IWYU pragma: no_forward_declare TimeDelta
namespace Parallel {
template <typename Metavariables>
class ConstGlobalCache;
} // namespace Parallel
// IWYU pragma: no_forward_declare db::DataBox
/// \endcond
namespace dg {
namespace Actions {
/// \ingroup ActionsGroup
/// \ingroup DiscontinuousGalerkinGroup
/// \brief Perform the boundary part of the update of the variables
/// for local time stepping.
///
/// Uses:
/// - ConstGlobalCache:
/// - OptionTags::TimeStepper
/// - Metavariables::normal_dot_numerical_flux
/// - DataBox:
/// - Tags::Mesh<volume_dim>
/// - Tags::Mortars<Tags::Mesh<volume_dim - 1>, volume_dim>
/// - Tags::Mortars<Tags::MortarSize<volume_dim - 1>, volume_dim>
/// - Tags::TimeStep
///
/// DataBox changes:
/// - Adds: nothing
/// - Removes: nothing
/// - Modifies:
/// - variables_tag
/// - FluxCommunicationTypes<Metavariables>::mortar_data_tag
struct ApplyBoundaryFluxesLocalTimeStepping {
template <typename DbTags, typename... InboxTags, typename Metavariables,
typename ArrayIndex, typename ActionList,
typename ParallelComponent>
static auto apply(db::DataBox<DbTags>& box,
const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
const Parallel::ConstGlobalCache<Metavariables>& cache,
const ArrayIndex& /*array_index*/,
const ActionList /*meta*/,
const ParallelComponent* const /*meta*/) noexcept {
static_assert(Metavariables::local_time_stepping,
"ApplyBoundaryFluxesLocalTimeStepping can only be used with "
"local time-stepping.");
using system = typename Metavariables::system;
constexpr size_t volume_dim = system::volume_dim;
using variables_tag = typename system::variables_tag;
using flux_comm_types = FluxCommunicationTypes<Metavariables>;
using mortar_data_tag =
typename flux_comm_types::local_time_stepping_mortar_data_tag;
db::mutate<variables_tag, mortar_data_tag>(
make_not_null(&box),
[&cache](
const gsl::not_null<db::item_type<variables_tag>*> vars,
const gsl::not_null<db::item_type<mortar_data_tag>*> mortar_data,
const db::item_type<Tags::Mesh<volume_dim>>& mesh,
const db::item_type<Tags::Mortars<Tags::Mesh<volume_dim - 1>,
volume_dim>>& mortar_meshes,
const db::item_type<Tags::Mortars<Tags::MortarSize<volume_dim - 1>,
volume_dim>>& mortar_sizes,
const db::item_type<Tags::TimeStep>& time_step) noexcept {
// Having the lambda just wrap another lambda works around a
// gcc 6.4.0 segfault.
[
&cache, &vars, &mortar_data, &mesh, &mortar_meshes, &mortar_sizes,
&time_step
]() noexcept {
const auto& normal_dot_numerical_flux_computer =
get<typename Metavariables::normal_dot_numerical_flux>(cache);
const auto& time_stepper = get<OptionTags::TimeStepper>(cache);
for (auto& mortar_id_and_data : *mortar_data) {
const auto& mortar_id = mortar_id_and_data.first;
auto& data = mortar_id_and_data.second;
const auto& direction = mortar_id.first;
const size_t dimension = direction.dimension();
const auto face_mesh = mesh.slice_away(dimension);
const auto perpendicular_extent = mesh.extents(dimension);
const auto& mortar_mesh = mortar_meshes.at(mortar_id);
const auto& mortar_size = mortar_sizes.at(mortar_id);
// This lambda must only capture quantities that are
// independent of the simulation state.
const auto coupling =
[
&face_mesh, &mortar_mesh, &mortar_size,
&normal_dot_numerical_flux_computer, &perpendicular_extent
](const typename flux_comm_types::LocalData& local_data,
const typename flux_comm_types::PackagedData&
remote_data) noexcept {
return compute_boundary_flux_contribution<flux_comm_types>(
normal_dot_numerical_flux_computer, local_data, remote_data,
face_mesh, mortar_mesh, perpendicular_extent, mortar_size);
};
const auto lifted_data = time_stepper.compute_boundary_delta(
coupling, make_not_null(&data), time_step);
add_slice_to_data(vars, lifted_data, mesh.extents(), dimension,
index_to_slice_at(mesh.extents(), direction));
}
}();
},
db::get<Tags::Mesh<volume_dim>>(box),
db::get<Tags::Mortars<Tags::Mesh<volume_dim - 1>, volume_dim>>(box),
db::get<Tags::Mortars<Tags::MortarSize<volume_dim - 1>, volume_dim>>(
box),
db::get<Tags::TimeStep>(box));
return std::forward_as_tuple(std::move(box));
}
};
} // namespace Actions
} // namespace dg
| 42.843972 | 124 | 0.642774 | [
"mesh"
] |
5314ec8bb213eb801672e7927766bc3801093061 | 10,641 | cpp | C++ | Source/TracerLib/SceneNodeJson.cpp | yalcinerbora/meturay | cff17b537fd8723af090802dfd17a0a740b404f5 | [
"MIT"
] | null | null | null | Source/TracerLib/SceneNodeJson.cpp | yalcinerbora/meturay | cff17b537fd8723af090802dfd17a0a740b404f5 | [
"MIT"
] | null | null | null | Source/TracerLib/SceneNodeJson.cpp | yalcinerbora/meturay | cff17b537fd8723af090802dfd17a0a740b404f5 | [
"MIT"
] | null | null | null | #include "SceneNodeJson.h"
#include "RayLib/SceneIO.h"
#include "RayLib/Log.h"
#include "RayLib/SceneNodeNames.h"
template <class T, LoadFunc<T> LoadF>
std::vector<T> SceneNodeJson::AccessSingle(const std::string& name,
double time) const
{
const nlohmann::json& nodeInner = node[name];
std::vector<T> result;
result.reserve(indexIdPairs.size());
for(const auto& list : indexIdPairs)
{
const InnerIndex i = list.second;
const nlohmann::json& node = (indexIdPairs.size() > 1) ? nodeInner[i] : nodeInner;
result.push_back(LoadF(node, time));
}
return std::move(result);
}
template <class T>
std::vector<T> SceneNodeJson::AccessRanged(const std::string& name) const
{
const nlohmann::json& nodeInner = node[name];
std::vector<T> result;
result.reserve(indexIdPairs.size());
if(indexIdPairs.size() == 1)
{
result.push_back(SceneIO::LoadNumber<T>(nodeInner));
}
else
{
std::vector<Range<T>> ranges = SceneIO::LoadRangedNumbers<T>(nodeInner);
T total = 0;
size_t j = 0;
// Do single loop over pairings and ranges
for(const auto& list : indexIdPairs)
{
// Find Data from the ranges
const InnerIndex i = list.second;
//for(const Range<T>& r : ranges)
for(; j < ranges.size() ; j++)
{
Range<T> r = ranges[j];
T count = r.end - r.start;
if(i >= total && i < total + count)
{
// Find the range now add the value
result.push_back(r.start + total - i);
break;
}
total += count;
}
}
}
return std::move(result);
}
template <class T, LoadFunc<T> LoadF>
std::vector<std::vector<T>> SceneNodeJson::AccessList(const std::string& name,
double time) const
{
const nlohmann::json& nodeInner = node[name];
std::vector<std::vector<T>> result;
result.reserve(indexIdPairs.size());
for(const auto& list : indexIdPairs)
{
result.emplace_back();
const InnerIndex i = list.second;
const nlohmann::json& node = (indexIdPairs.size() > 1) ? nodeInner[i] : nodeInner;
for(const nlohmann::json& n : node)
result.back().push_back(LoadF(n, time));
}
return std::move(result);
}
template <class T, LoadFunc<T> LoadF>
std::vector<T> SceneNodeJson::CommonList(const std::string& name,
double time) const
{
std::vector<T> result;
const nlohmann::json& nodeInner = node[name];
for(const nlohmann::json& n : nodeInner)
result.push_back(LoadF(n, time));
return std::move(result);
}
SceneNodeJson::SceneNodeJson(const nlohmann::json& jsn, NodeId id, bool forceFetchAll)
: SceneNodeI(id)
, node(jsn)
{
if(forceFetchAll)
{
const auto idList = jsn[NodeNames::ID];
if(idList.is_array())
{
uint32_t i = 0;
for(uint32_t id : idList)
AddIdIndexPair(id, i);
}
else AddIdIndexPair(idList, 0);
}
}
std::string SceneNodeJson::Name() const
{
return SceneIO::LoadString(node[NodeNames::NAME]);
}
std::string SceneNodeJson::Tag() const
{
nlohmann::json::const_iterator i;
if((i = node.find(NodeNames::TAG)) != node.end())
return SceneIO::LoadString(node[NodeNames::TAG]);
return "";
}
size_t SceneNodeJson::CommonListSize(const std::string& name) const
{
const nlohmann::json& nodeInner = node[name];
return nodeInner.size();
}
bool SceneNodeJson::CommonBool(const std::string& name, double time) const
{
return SceneIO::LoadBool(node[name], time);
}
std::string SceneNodeJson::CommonString(const std::string& name, double time) const
{
return SceneIO::LoadString(node[name], time);
}
float SceneNodeJson::CommonFloat(const std::string& name, double time) const
{
return SceneIO::LoadNumber<float>(node[name], time);
}
Vector2 SceneNodeJson::CommonVector2(const std::string& name, double time) const
{
return SceneIO::LoadVector<2, float>(node[name], time);
}
Vector3 SceneNodeJson::CommonVector3(const std::string& name, double time) const
{
return SceneIO::LoadVector<3, float>(node[name], time);
}
Vector4 SceneNodeJson::CommonVector4(const std::string& name, double time) const
{
return SceneIO::LoadVector<4, float>(node[name], time);
}
Matrix4x4 SceneNodeJson::CommonMatrix4x4(const std::string& name, double time) const
{
return SceneIO::LoadMatrix<4, float>(node[name], time);
}
uint32_t SceneNodeJson::CommonUInt(const std::string& name, double time) const
{
return SceneIO::LoadNumber<uint32_t>(node[name], time);
}
uint64_t SceneNodeJson::CommonUInt64(const std::string& name, double time) const
{
return SceneIO::LoadNumber<uint64_t>(node[name], time);
}
std::vector<bool> SceneNodeJson::CommonBoolList(const std::string& name, double time) const
{
return CommonList<bool, SceneIO::LoadBool>(name, time);
}
std::vector<std::string> SceneNodeJson::CommonStringList(const std::string& name, double time) const
{
return CommonList<std::string, SceneIO::LoadString>(name, time);
}
std::vector<float> SceneNodeJson::CommonFloatList(const std::string& name, double time) const
{
return CommonList<float, SceneIO::LoadNumber>(name, time);
}
std::vector<Vector2> SceneNodeJson::CommonVector2List(const std::string& name, double time) const
{
return CommonList<Vector2, SceneIO::LoadVector<2, float>>(name, time);
}
std::vector<Vector3> SceneNodeJson::CommonVector3List(const std::string& name, double time) const
{
return CommonList<Vector3, SceneIO::LoadVector<3, float>>(name, time);
}
std::vector<Vector4> SceneNodeJson::CommonVector4List(const std::string& name, double time) const
{
return CommonList<Vector4, SceneIO::LoadVector<4, float>>(name, time);
}
std::vector<Matrix4x4> SceneNodeJson::CommonMatrix4x4List(const std::string& name, double time) const
{
return CommonList<Matrix4x4, SceneIO::LoadMatrix<4, float>>(name, time);
}
std::vector<uint32_t> SceneNodeJson::CommonUIntList(const std::string& name, double time) const
{
return CommonList<uint32_t, SceneIO::LoadNumber>(name, time);
}
std::vector<uint64_t> SceneNodeJson::CommonUInt64List(const std::string& name, double time) const
{
return CommonList<uint64_t, SceneIO::LoadNumber>(name, time);
}
size_t SceneNodeJson::AccessListTotalCount(const std::string& name) const
{
const auto r = AccessListCount(name);
return std::accumulate(r.begin(), r.end(), 0ull);
}
std::vector<size_t> SceneNodeJson::AccessListCount(const std::string& name) const
{
const nlohmann::json& nodeInner = node[name];
std::vector<size_t> result;
result.reserve(indexIdPairs.size());
for(const auto& list : indexIdPairs)
{
const InnerIndex i = list.second;
const nlohmann::json& node = (indexIdPairs.size() > 1) ? nodeInner[i] : nodeInner;
result.push_back(node.size());
}
return std::move(result);
}
std::vector<uint32_t> SceneNodeJson::AccessUIntRanged(const std::string& name) const
{
return AccessRanged<uint32_t>(name);
}
std::vector<uint64_t> SceneNodeJson::AccessUInt64Ranged(const std::string& name) const
{
return AccessRanged<uint64_t>(name);
}
std::vector<bool> SceneNodeJson::AccessBool(const std::string& name, double time) const
{
return AccessSingle<bool, SceneIO::LoadBool>(name, time);
}
std::vector<std::string> SceneNodeJson::AccessString(const std::string& name, double time) const
{
return AccessSingle<std::string, SceneIO::LoadString>(name, time);
}
std::vector<float> SceneNodeJson::AccessFloat(const std::string& name, double time) const
{
return AccessSingle<float, SceneIO::LoadNumber<float>>(name, time);
}
std::vector<Vector2> SceneNodeJson::AccessVector2(const std::string& name, double time) const
{
return AccessSingle<Vector2, SceneIO::LoadVector<2, float>>(name, time);
}
std::vector<Vector3> SceneNodeJson::AccessVector3(const std::string& name, double time) const
{
return AccessSingle<Vector3, SceneIO::LoadVector<3, float>>(name, time);
}
std::vector<Vector4> SceneNodeJson::AccessVector4(const std::string& name, double time) const
{
return AccessSingle<Vector4, SceneIO::LoadVector<4, float>>(name, time);
}
std::vector<Matrix4x4> SceneNodeJson::AccessMatrix4x4(const std::string& name, double time) const
{
return AccessSingle<Matrix4x4, SceneIO::LoadMatrix<4, float>>(name, time);
}
std::vector<uint32_t> SceneNodeJson::AccessUInt(const std::string& name, double time) const
{
return AccessSingle<uint32_t, SceneIO::LoadNumber<uint32_t>>(name, time);
}
std::vector<uint64_t> SceneNodeJson::AccessUInt64(const std::string& name, double time) const
{
return AccessSingle<uint64_t, SceneIO::LoadNumber<uint64_t>>(name, time);
}
std::vector<BoolList> SceneNodeJson::AccessBoolList(const std::string& name, double time) const
{
return AccessList<bool, SceneIO::LoadBool>(name, time);
}
std::vector<StringList> SceneNodeJson::AccessStringList(const std::string& name, double time) const
{
return AccessList<std::string, SceneIO::LoadString>(name, time);
}
std::vector<FloatList> SceneNodeJson::AccessFloatList(const std::string& name, double time) const
{
return AccessList<float, SceneIO::LoadNumber<float>>(name, time);
}
std::vector<Vector2List> SceneNodeJson::AccessVector2List(const std::string& name, double time) const
{
return AccessList<Vector2, SceneIO::LoadVector<2, float>>(name, time);
}
std::vector<Vector3List> SceneNodeJson::AccessVector3List(const std::string& name, double time) const
{
return AccessList<Vector3, SceneIO::LoadVector<3, float>>(name, time);
}
std::vector<Vector4List> SceneNodeJson::AccessVector4List(const std::string& name, double time) const
{
return AccessList<Vector4, SceneIO::LoadVector<4, float>>(name, time);
}
std::vector<Matrix4x4List> SceneNodeJson::AccessMatrix4x4List(const std::string& name, double time) const
{
return AccessList<Matrix4x4, SceneIO::LoadMatrix<4, float>>(name, time);
}
std::vector<UIntList> SceneNodeJson::AccessUIntList(const std::string& name, double time) const
{
return AccessList<uint32_t, SceneIO::LoadNumber<uint32_t>>(name, time);
}
std::vector<UInt64List> SceneNodeJson::AccessUInt64List(const std::string& name, double time) const
{
return AccessList<uint64_t, SceneIO::LoadNumber<uint64_t>>(name, time);
} | 31.297059 | 105 | 0.679447 | [
"vector"
] |
531c2e9067f6711773037ecf0ec9d6a430b8814d | 2,601 | cpp | C++ | ROS/sudoku_bot_ws/src/sudoku_pub/src/sudoku_pub_node.cpp | Zarif-Karim/Project-Work | 0ee080b5ad1b7cfb70737caaf738b8261c43d95a | [
"BSD-3-Clause"
] | null | null | null | ROS/sudoku_bot_ws/src/sudoku_pub/src/sudoku_pub_node.cpp | Zarif-Karim/Project-Work | 0ee080b5ad1b7cfb70737caaf738b8261c43d95a | [
"BSD-3-Clause"
] | null | null | null | ROS/sudoku_bot_ws/src/sudoku_pub/src/sudoku_pub_node.cpp | Zarif-Karim/Project-Work | 0ee080b5ad1b7cfb70737caaf738b8261c43d95a | [
"BSD-3-Clause"
] | null | null | null | #include <ros/ros.h>
#include <sudoku_pub/grid_num.h>
#include <sudoku_pub/grid_num_vector.h>
#include <stdlib.h>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
const int GRID_SIZE = 16;
using namespace std;
int main(int argc, char **argv)
{
ros::init(argc, argv, "sudokuPublisher");
ros::NodeHandle nh;
ros::Publisher pub = nh.advertise<sudoku_pub::grid_num_vector>("num_grids/vector", 1000);
sudoku_pub::grid_num_vector solMsgs;
int grid[GRID_SIZE][GRID_SIZE] = {
{ 6, 10, 0, 12, 9, 16, 0, 5, 0, 0, 2, 0, 14, 8, 0, 11},
{ 1, 7, 0, 11, 10, 14, 4, 0, 5, 0, 0, 8, 2, 0, 13, 15},
{ 9, 0, 4, 2, 0, 8, 0, 0, 16, 13, 0, 0, 12, 6, 0, 10},
{ 0, 14, 8, 13, 0, 15, 0, 12, 0, 0, 1, 0, 0, 3, 4, 0},
{15, 0, 0, 0, 0, 1, 12, 0, 8, 0, 0, 0, 0, 0, 7, 14},
{ 3, 11, 0, 5, 13, 9, 0, 0, 0, 0, 0, 15, 1, 2, 0, 0},
{ 4, 0, 0, 16, 6, 11, 5, 3, 0, 2, 14, 0, 0, 10, 0, 13},
{12, 0, 0, 0, 15, 10, 0, 16, 9, 7, 0, 11, 6, 0, 3, 0},
{ 0, 0, 0, 0, 14, 0, 9, 0, 11, 8, 0, 12, 0, 0, 0, 0},
{ 0, 9, 14, 0, 0, 0, 6, 2, 4, 0, 0, 0, 0, 0, 16, 7},
{10, 0, 0, 6, 7, 3, 0, 0, 0, 0, 0, 0, 0, 11, 12, 1},
{ 0, 16, 0, 0, 4, 13, 10, 11, 0, 1, 6, 0, 5, 0, 9, 8},
{ 0, 0, 11, 3, 5, 0, 0, 1, 2, 4, 8, 0, 13, 0, 0, 9},
{ 8, 12, 5, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 4},
{ 0, 2, 0, 7, 0, 4, 14, 0, 0, 11, 15, 16, 8, 0, 0, 3},
{14, 0, 0, 9, 8, 0, 0, 10, 0, 0, 0, 5, 0, 1, 0, 2}
};
/*int grid[GRID_SIZE][GRID_SIZE = {
{0,0,0,4,1,0,0,0,0},
{0,0,8,9,2,0,0,0,0},
{0,0,9,7,3,0,0,0,0},
{0,0,0,1,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,2,0,0,0,0,0},
{0,0,0,6,4,0,0,0,0},
{0,0,0,5,0,0,0,0,0},
{0,0,0,8,0,0,0,0,0}
};*/
for(int i = 0; i < GRID_SIZE; i++)
{
for (int j = 0; j < GRID_SIZE; j++)
{
if (grid[i][j] > 0)
{
sudoku_pub::grid_num g;
g.row = i + 1;
g.col = j + 1;
g.num = grid[i][j];
//save to grid_num_vector
solMsgs.numbered_grids.push_back(g);
//ROS_INFO_STREAM("MES: " << solMsgs.numbered_grids[i]);
}
}
}
//if(ros::ok()) pub.publish(solMsgs);
//std::string publish;
/*ros::Rate rate(1);*/
while (ros::ok())
{
int publish;
//publish
std::cout << "Enter 1 to publish message: ";
std::cin >> publish;
if(publish == 1)
{
pub.publish(solMsgs);
ROS_INFO_STREAM(" STARTING SUDOKU PUZZLE PUBLISHED" << "\n\n");
break;
/*rate.sleep();*/
}
}
if (ros::ok()) ros::shutdown();
return 0;
}
| 27.378947 | 90 | 0.461745 | [
"vector"
] |
5323e682147b42487f79209de8619dd0e65d0fb5 | 59,881 | cpp | C++ | src/libs/fileext/excel/sheet.cpp | dmryutov/document2html | 753d37a42a7c9e9daeb33183228ac5bf0df87295 | [
"MIT"
] | 7 | 2018-01-18T05:39:53.000Z | 2020-05-25T10:16:44.000Z | src/libs/fileext/excel/sheet.cpp | dmryutov/document2html | 753d37a42a7c9e9daeb33183228ac5bf0df87295 | [
"MIT"
] | 1 | 2018-02-07T11:04:23.000Z | 2018-02-10T18:16:02.000Z | src/libs/fileext/excel/sheet.cpp | dmryutov/document2html | 753d37a42a7c9e9daeb33183228ac5bf0df87295 | [
"MIT"
] | 4 | 2018-06-27T23:53:46.000Z | 2021-09-22T05:38:39.000Z | /**
* @brief Excel files (xls/xlsx) into HTML сonverter
* @package excel
* @file sheet.cpp
* @author dmryutov (dmryutov@gmail.com)
* @copyright python-excel (https://github.com/python-excel/xlrd)
* @date 02.12.2016 -- 10.02.2018
*/
#include "../../tools.hpp"
#include "biffh.hpp"
#include "sheet.hpp"
namespace excel {
/** XL_SHRFMLA types */
const std::vector<int> XL_SHRFMLA_ETC {
XL_SHRFMLA, XL_ARRAY, XL_TABLEOP, XL_TABLEOP2, XL_ARRAY2, XL_TABLEOP_B2
};
/** Cell horizontal aligment list */
const std::vector<std::string> CELL_HORZ_ALIGN {
"left", "left", "center", "right", "justify", "justify", "center", "center"
};
/** Cell vertical aligment list */
const std::vector<std::string> CELL_VERT_ALIGN {
"top", "middle", "bottom", "middle", "middle"
};
/** Cell border type list */
const std::vector<std::string> CELL_BORDER_TYPE {
"none", "solid", "solid", "dashed", "dotted", "solid", "double", "dotted",
"dashed", "dashed", "dashed", "dotted", "dotted", "dashed"
};
/** Cell border size list */
const std::vector<int> CELL_BORDER_SIZE {
1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 2, 1, 2, 3
};
/** Table parts background color map. `type`: {`firstRow`, `evenRow`, `oddRow`} */
const std::unordered_map<int, std::vector<std::string>> TABLE_BACKGROUND {
// Light
{101, {"", "D9D9D9", ""}},
{102, {"", "DDEBF7", ""}},
{103, {"", "FCE4D6", ""}},
{104, {"", "EDEDED", ""}},
{105, {"", "2CC", ""}},
{106, {"", "D9E1F2", ""}},
{107, {"", "E2EFDA", ""}},
{108, {"000000", "", ""}},
{109, {"5B9BD5", "", ""}},
{110, {"ED7D31", "", ""}},
{111, {"A5A5A5", "", ""}},
{112, {"FFC000", "", ""}},
{113, {"4472C4", "", ""}},
{114, {"70AD47", "", ""}},
{115, {"", "D9D9D9", ""}},
{116, {"", "DDEBF7", ""}},
{117, {"", "FCE4D6", ""}},
{118, {"", "EDEDED", ""}},
{119, {"", "FFC000", ""}},
{120, {"", "D9E1F2", ""}},
{121, {"", "E2EFDA", ""}},
// Medium
{201, {"000000", "D9D9D9", ""}},
{202, {"5B9BD5", "DDEBF7", ""}},
{203, {"ED7D31", "FCE4D6", ""}},
{204, {"A5A5A5", "EDEDED", ""}},
{205, {"FFC000", "2CC", ""}},
{206, {"4472C4", "D9E1F2", ""}},
{207, {"70AD47", "E2EFDA", ""}},
{208, {"000000", "A6A6A6", "D9D9D9"}},
{209, {"5B9BD5", "BDD7EE", "DDEBF7"}},
{210, {"ED7D31", "F8CBAD", "FCE4D6"}},
{211, {"A5A5A5", "DBDBDB", "EDEDED"}},
{212, {"FFC000", "FFE699", "FFF2CC"}},
{213, {"4472C4", "B4C6E7", "D9E1F2"}},
{214, {"70AD47", "C6E0B4", "E2EFDA"}},
{215, {"000000", "D9D9D9", ""}},
{216, {"5B9BD5", "D9D9D9", ""}},
{217, {"ED7D31", "D9D9D9", ""}},
{218, {"A5A5A5", "D9D9D9", ""}},
{219, {"FFC000", "D9D9D9", ""}},
{220, {"4472C4", "D9D9D9", ""}},
{221, {"70AD47", "D9D9D9", ""}},
{222, {"D9D9D9", "A6A6A6", "D9D9D9"}},
{223, {"DDEBF7", "BDD7EE", "DDEBF7"}},
{224, {"FCE4D6", "F8CBAD", "FCE4D6"}},
{225, {"EDEDED", "DBDBDB", "EDEDED"}},
{226, {"FFF2CC", "FFE699", "FFF2CC"}},
{227, {"D9E1F2", "B4C6E7", "D9E1F2"}},
{228, {"E2EFDA", "C6E0B4", "E2EFDA"}},
// Dark
{301, {"000", "404040", "737373"}},
{302, {"000", "2F75B5", "5B9BD5"}},
{303, {"000", "C65911", "ED7D31"}},
{304, {"000", "7B7B7B", "A5A5A5"}},
{305, {"000", "BF8F00", "FFC000"}},
{306, {"000", "305496", "4472C4"}},
{307, {"000", "548235", "70AD47"}},
{308, {"000", "A6A6A6", "D9D9D9"}},
{309, {"ED7D31", "BDD7EE", "DDEBF7"}},
{310, {"FFC000", "DBDBDB", "EDEDED"}},
{311, {"70AD47", "B4C6E7", "D9E1F2"}}
};
/** Table parts font color map. `type`: {`firstRow`, `otherRow`} */
const std::unordered_map<int, std::vector<std::string>> TABLE_COLOR {
// Light
{102, {"2F75B5", "2F75B5"}},
{103, {"C65911", "C65911"}},
{104, {"7B7B7B", "7B7B7B"}},
{105, {"BF8F00", "BF8F00"}},
{106, {"305496", "305496"}},
{107, {"548235", "548235"}},
{108, {"fff", ""}},
// Medium
{201, {"fff", ""}},
{202, {"fff", ""}},
{203, {"fff", ""}},
{204, {"fff", ""}},
{205, {"fff", ""}},
{206, {"fff", ""}},
{207, {"fff", ""}},
{208, {"fff", ""}},
// Dark
{301, {"fff", "fff"}},
{302, {"fff", "fff"}},
{303, {"fff", "fff"}},
{304, {"fff", "fff"}},
{305, {"fff", "fff"}},
{306, {"fff", "fff"}},
{307, {"fff", "fff"}},
{308, {"fff", ""}},
};
// public:
Sheet::Sheet(Book* book, int position, const std::string& name, size_t number, pugi::xml_node& table)
: m_book(book), m_table(table), m_name(name), m_number(number),
m_maxRowCount((m_book->m_biffVersion >= 80) ? 65536 : 16384), m_position(position) {}
void Sheet::read() {
bool isSstRichtext = m_book->m_addStyle && !m_book->m_richtextRunlistMap.empty();
std::map<std::pair<unsigned short, int>, Rowinfo> rowinfoSharingDict;
std::unordered_map<unsigned short, MSTxo> msTxos;
bool eofFound = false;
int savedObjectId;
int oldPosition = m_book->m_position;
m_book->m_position = m_position;
while (true) {
unsigned short code;
unsigned short size;
std::string data;
m_book->getRecordParts(code, size, data);
if (code == XL_NUMBER) {
// [:14] in following stmt ignores extraneous rubbish at end of record
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short colIndex = m_book->readByte<unsigned short>(data, 2, 2);
unsigned short xfIndex = m_book->readByte<unsigned short>(data, 4, 2);
double d = m_book->readByte<double>(data, 6, 8);
putCell(rowIndex, colIndex, std::to_string(d), xfIndex);
}
else if (code == XL_LABELSST) {
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short colIndex = m_book->readByte<unsigned short>(data, 2, 2);
unsigned short xfIndex = m_book->readByte<unsigned short>(data, 4, 2);
int sstIndex = m_book->readByte<int>(data, 6, 4);
putCell(rowIndex, colIndex, m_book->m_sharedStrings[sstIndex], xfIndex);
if (isSstRichtext) {
auto& runlist = m_book->m_richtextRunlistMap[sstIndex];
if (!runlist.empty())
m_richtextRunlistMap[{rowIndex, colIndex}] = runlist;
}
}
else if (code == XL_LABEL) {
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short colIndex = m_book->readByte<unsigned short>(data, 2, 2);
unsigned short xfIndex = m_book->readByte<unsigned short>(data, 4, 2);
std::string str;
if (m_book->m_biffVersion < 80)
str = m_book->unpackString(data, 6, 2);
else
str = m_book->unpackUnicode(data, 6, 2);
putCell(rowIndex, colIndex, str, xfIndex);
}
else if (code == XL_RSTRING) {
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short colIndex = m_book->readByte<unsigned short>(data, 2, 2);
unsigned short xfIndex = m_book->readByte<unsigned short>(data, 4, 2);
int pos = 6;
std::string str;
std::vector<std::pair<unsigned short, unsigned short>> runlist;
if (m_book->m_biffVersion < 80) {
str = m_book->unpackStringUpdatePos(data, pos, 2);
char nrt = data[pos];
pos += 1;
for (int i = 0; i < nrt; ++i) {
runlist.emplace_back(
m_book->readByte<unsigned char>(data, pos, 1),
m_book->readByte<unsigned char>(data, pos+1, 1)
);
pos += 2;
}
}
else {
str = m_book->unpackUnicodeUpdatePos(data, pos, 2);
unsigned short nrt = m_book->readByte<unsigned short>(data, pos, 2);
pos += 2;
for (int i = 0; i < nrt; ++i) {
runlist.emplace_back(
m_book->readByte<unsigned short>(data, pos, 2),
m_book->readByte<unsigned short>(data, pos+2, 2)
);
pos += 4;
}
}
putCell(rowIndex, colIndex, str, xfIndex);
m_richtextRunlistMap[{rowIndex, colIndex}] = runlist;
}
else if (code == XL_RK) {
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short colIndex = m_book->readByte<unsigned short>(data, 2, 2);
unsigned short xfIndex = m_book->readByte<unsigned short>(data, 4, 2);
double d = unpackRK(data.substr(6, 4));
putCell(rowIndex, colIndex, std::to_string(d), xfIndex);
}
else if (code == XL_MULRK) {
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short firstCol = m_book->readByte<unsigned short>(data, 2, 2);
unsigned short lastCol = m_book->readByte<unsigned short>(data, (int)data.size()-2, 2);
int pos = 4;
for (int i = firstCol; i <= lastCol; ++i) {
unsigned short xfIndex = m_book->readByte<unsigned short>(data, pos, 2);
double d = unpackRK(data.substr(pos+2, 4));
pos += 6;
putCell(rowIndex, i, std::to_string(d), xfIndex);
}
}
else if (code == XL_ROW) {
if (!m_book->m_addStyle)
continue;
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short flag1 = m_book->readByte<unsigned short>(data, 6, 2);
int flag2 = m_book->readByte<int>(data, 12, 4);
if (!(0 <= rowIndex && rowIndex < m_maxRowCount))
continue;
auto key = std::make_pair(flag1, flag2);
Rowinfo rowinfo;
if (rowinfoSharingDict.find(key) == rowinfoSharingDict.end()) {
// Using upkbits() is far too slow on a file with 30 sheets each with 10K rows. So:
rowinfo.m_height = flag1 & 0x7fff;
rowinfo.m_hasDefaultHeight = (flag1 >> 15) & 1;
rowinfo.m_outlineLevel = flag2 & 7;
rowinfo.m_isOutlineGroupStartsEnds = (flag2 >> 4) & 1;
rowinfo.m_isHidden = (flag2 >> 5) & 1;
rowinfo.m_isHeightMismatch = (flag2 >> 6) & 1;
rowinfo.m_hasDefaultXfIndex = (flag2 >> 7) & 1;
rowinfo.m_xfIndex = (flag2 >> 16) & 0xfff;
rowinfo.m_hasAdditionalSpaceAbove = (flag2 >> 28) & 1;
rowinfo.m_hasAdditionalSpaceBelow = (flag2 >> 29) & 1;
if (!rowinfo.m_hasDefaultXfIndex)
rowinfo.m_xfIndex = -1;
rowinfoSharingDict[key] = rowinfo;
}
else
rowinfo = rowinfoSharingDict[key];
m_rowinfoMap[rowIndex] = rowinfo;
}
else if (code == 0x0006 || code == 0x0406 || code == 0x0206) {
unsigned short rowIndex;
unsigned short colIndex;
unsigned short xfIndex;
unsigned short flags;
std::string result;
if (m_book->m_biffVersion >= 50) {
rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
colIndex = m_book->readByte<unsigned short>(data, 2, 2);
xfIndex = m_book->readByte<unsigned short>(data, 4, 2);
result = m_book->readByte<std::string>(data, 6, 8);
flags = m_book->readByte<unsigned short>(data, 14, 2);
}
else if (m_book->m_biffVersion >= 30) {
rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
colIndex = m_book->readByte<unsigned short>(data, 2, 2);
xfIndex = m_book->readByte<unsigned short>(data, 4, 2);
result = m_book->readByte<std::string>(data, 6, 8);
flags = m_book->readByte<unsigned short>(data, 14, 2);
}
// BIFF2
else {
rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
colIndex = m_book->readByte<unsigned short>(data, 2, 2);
std::string cellAttributes = m_book->readByte<std::string>(data, 4, 3);
result = m_book->readByte<std::string>(data, 7, 8);
flags = m_book->readByte<unsigned char>(data, 15, 1);
xfIndex = fixedXfIndexB2(cellAttributes);
}
if (result.substr(6, 2) == "\xFF\xFF") {
char firstByte = result[0];
if (firstByte == 0) {
// Need to read next record (STRING)
bool gotString = false;
// "if flags & 8" applies only to SHRFMLA
// Actually there's an optional SHRFMLA or ARRAY etc record to skip over
unsigned short code2;
unsigned short size2;
std::string data2;
m_book->getRecordParts(code2, size2, data2);
if (code2 == XL_STRING || code2 == XL_STRING_B2)
gotString = true;
else if (find(XL_SHRFMLA_ETC.begin(), XL_SHRFMLA_ETC.end(), code2) == XL_SHRFMLA_ETC.end())
throw std::logic_error(
"Expected SHRFMLA, ARRAY, TABLEOP* or STRING record; found " +
std::to_string(code2)
);
// Now for the STRING record
if (!gotString) {
m_book->getRecordParts(code2, size2, data2);
if (code2 != XL_STRING && code2 != XL_STRING_B2)
throw std::logic_error(
"Expected STRING record; found " +
std::to_string(code2)
);
}
std::string str = stringRecordContent(data2);
putCell(rowIndex, colIndex, str, xfIndex);
}
// Boolean formula result
else if (firstByte == 1) {
putCell(rowIndex, colIndex, std::string(1, result[2]), xfIndex);
}
// Error in cell
else if (firstByte == 2) {
putCell(rowIndex, colIndex, std::string(1, result[2]), xfIndex);
}
// Empty ... i.e. empty (zero-length) string, NOT an empty cell
else if (firstByte == 3) {
putCell(rowIndex, colIndex, "", xfIndex);
}
else {
throw std::logic_error(
"Unexpected special case (" + std::to_string(firstByte) +
") in FORMULA"
);
}
}
// It is a number
else {
double d = m_book->readByte<double>(result, 0, 8);
putCell(rowIndex, colIndex, std::to_string(d), xfIndex);
}
}
else if (code == XL_BOOLERR) {
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short colIndex = m_book->readByte<unsigned short>(data, 2, 2);
unsigned short xfIndex = m_book->readByte<unsigned short>(data, 4, 2);
unsigned char value = m_book->readByte<unsigned char>(data, 6, 1);
//unsigned char hasError = m_book->readByte<unsigned char>(data, 7, 1);
// Note: OOo Calc 2.0 writes 9-byte BOOLERR records. OOo docs say 8. Excel writes 8
//int cellType = hasError ? XL_CELL_ERROR : XL_CELL_BOOLEAN;
putCell(rowIndex, colIndex, std::string(1, value), xfIndex);
}
else if (code == XL_COLINFO) {
if (!m_book->m_addStyle)
continue;
Colinfo colinfo;
unsigned short firstColIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short lastColIndex = m_book->readByte<unsigned short>(data, 2, 2);
colinfo.m_width = m_book->readByte<unsigned short>(data, 4, 2);
colinfo.m_xfIndex = m_book->readByte<unsigned char>(data, 6, 1);
unsigned short flags = m_book->readByte<unsigned short>(data, 8, 2);
// #Colinfo.m_width is denominated in 256ths of a character, not in characters
// Note: 256 instead of 255 is a common mistake. Silently ignore non-existing
// 257th column in that case
if (0 > firstColIndex || firstColIndex > lastColIndex || lastColIndex > 256)
continue;
colinfo.m_isHidden = (flags & 0x0001) >> 0;
colinfo.m_bitFlag = (flags & 0x0002) >> 1;
colinfo.m_outlineLevel = (flags & 0x0700) >> 8;
colinfo.m_isCollapsed = (flags & 0x1000) >> 12;
for (int i = firstColIndex; i <= lastColIndex; ++i) {
// Excel does 0 to 256 inclusive
if (i > 255)
break;
m_colinfoMap[i] = colinfo;
}
}
else if (code == XL_DEFCOLWIDTH) {
m_defaultColWidth = m_book->readByte<unsigned short>(data, 0, 2);
}
else if (code == XL_STANDARDWIDTH) {
m_standardWidth = m_book->readByte<unsigned short>(data, 0, 2);
}
else if (code == XL_GCW) {
// Useless w/o COLINFO
if (!m_book->m_addStyle)
continue;
std::vector<int> iguff;
for (int i = 0; i < 8; ++i)
iguff.emplace_back(m_book->readByte<int>(data, 2 + i*4, 4));
m_gcw.clear();
for (auto& bits : iguff) {
for (int i = 0; i < 32; ++i) {
m_gcw.push_back(bits & 1);
bits >>= 1;
}
}
}
else if (code == XL_BLANK) {
if (!m_book->m_addStyle)
continue;
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short colIndex = m_book->readByte<unsigned short>(data, 2, 2);
unsigned short xfIndex = m_book->readByte<unsigned short>(data, 4, 2);
putCell(rowIndex, colIndex, "", xfIndex);
}
else if (code == XL_MULBLANK) { // 00BE
if (!m_book->m_addStyle)
continue;
std::vector<unsigned short> result;
for (int i = 0; i < (size >> 1); ++i)
result.emplace_back(m_book->readByte<unsigned short>(data, 0 + i*2, 2));
auto mul_last = result.back();
int pos = 2;
for (int colx = result[1]; colx < mul_last+1; ++colx) {
putCell(result[0], colx, "", result[pos]);
pos += 1;
}
}
else if (code == XL_DIMENSION || code == XL_DIMENSION2) {
// Four zero bytes after some other record
if (size == 0)
continue;
if (m_book->m_biffVersion < 80) {
m_dimensionRowCount = m_book->readByte<unsigned short>(data, 2, 2);
m_dimensionColCount = m_book->readByte<unsigned short>(data, 6, 2);
}
else {
m_dimensionRowCount = m_book->readByte<int>(data, 4, 4);
m_dimensionColCount = m_book->readByte<unsigned short>(data, 10, 2);
}
m_rowCount = 0;
m_colCount = 0;
if (
(m_book->m_biffVersion == 21 || m_book->m_biffVersion == 30 || m_book->m_biffVersion == 40) &&
!m_book->m_xfList.empty() && !m_book->m_xfEpilogueDone
) {
Formatting formatting(m_book);
formatting.xfEpilogue();
}
}
else if (code == XL_HLINK) {
handleHyperlink(data);
}
else if (code == XL_QUICKTIP) {
handleQuicktip(data);
}
else if (code == XL_EOF) {
eofFound = true;
break;
}
else if (code == XL_OBJ) {
// Handle SHEET-level objects
MSObj savedObject;
handleMSObj(data, savedObject);
savedObjectId = savedObject.m_isNull ? -1 : savedObject.m_id;
}
//else if (code == XL_MSO_DRAWING) {
// handleMsodrawingetc(code, size, data);
//}
else if (code == XL_TXO) {
MSTxo msTxo;
handleMSTxo(data, msTxo);
if (!msTxo.m_isNull && (savedObjectId > 0)) {
msTxos[savedObjectId] = msTxo;
savedObjectId = -1;
}
}
else if (code == XL_NOTE) {
handleNote(data, msTxos);
}
//else if (code == XL_FEAT11) {
// handleFeat11(data);
//}
else if (find(BOF_CODES.begin(), BOF_CODES.end(), code) != BOF_CODES.end()) {
//unsigned short version = m_book->readByte<unsigned short>(data, 0, 2);
//unsigned short bofType = m_book->readByte<unsigned short>(data, 2, 2);
unsigned short code2;
while (true) {
m_book->getRecordParts(code2, size, data);
if (code2 == XL_EOF)
break;
}
}
else if (code == XL_COUNTRY) {
// Handle country
m_book->m_countries = {
m_book->readByte<unsigned short>(data, 0, 2),
m_book->readByte<unsigned short>(data, 2, 2)
};
}
else if (code == XL_LABELRANGES) {
int pos = 0;
unpackCellRangeAddressListUpdatePos(m_rowLabelRanges, data, pos, 8);
unpackCellRangeAddressListUpdatePos(m_colLabelRanges, data, pos, 8);
}
//else if (code == XL_ARRAY) {
// unsigned short firstRowIndex = m_book->readByte<unsigned short>(data, 0, 2);
// unsigned short lastRowIndex = m_book->readByte<unsigned short>(data, 2, 2);
// unsigned char firstColIndex = m_book->readByte<unsigned char>(data, 4, 1);
// unsigned char lastColIndex = m_book->readByte<unsigned char>(data, 5, 1);
// unsigned char flags = m_book->readByte<unsigned char>(data, 6, 1);
// unsigned short tokenLength = m_book->readByte<unsigned short>(data, 12, 2);
//}
//else if (code == XL_SHRFMLA) {
// unsigned short firstRowIndex = m_book->readByte<unsigned short>(data, 0, 2);
// unsigned short lastRowIndex = m_book->readByte<unsigned short>(data, 2, 2);
// unsigned char firstColIndex = m_book->readByte<unsigned char>(data, 4, 1);
// unsigned char lastColIndex = m_book->readByte<unsigned char>(data, 5, 1);
// unsigned char formulaCount = m_book->readByte<unsigned char>(data, 7, 1);
// unsigned short tokenLength = m_book->readByte<unsigned short>(data, 8, 2);
//}
else if (code == XL_CONDFMT) {
if (!m_book->m_addStyle)
continue;
//unsigned short cfCount = m_book->readByte<unsigned short>(data, 0, 2);
//unsigned short needRecalc = m_book->readByte<unsigned short>(data, 2, 2);
//unsigned short rowIndex1 = m_book->readByte<unsigned short>(data, 4, 2);
//unsigned short rowIndex2 = m_book->readByte<unsigned short>(data, 6, 2);
//unsigned short colIndex1 = m_book->readByte<unsigned short>(data, 8, 2);
//unsigned short colIndex2 = m_book->readByte<unsigned short>(data, 10, 2);
int pos = 12;
std::vector<std::vector<int>> oList; // Updated by function
unpackCellRangeAddressListUpdatePos(oList, data, pos, 8);
}
else if (code == XL_CF) {
if (!m_book->m_addStyle)
continue;
//unsigned char cfType = m_book->readByte<unsigned char>(data, 0, 1);
//unsigned char cmpOp = m_book->readByte<unsigned char>(data, 1, 1);
unsigned short size1 = m_book->readByte<unsigned short>(data, 2, 2);
unsigned short size2 = m_book->readByte<unsigned short>(data, 4, 2);
int flags = m_book->readByte<int>(data, 6, 4);
bool fontBlock = (flags >> 26) & 1;
bool borderBlock = (flags >> 28) & 1;
bool paletteBlock = (flags >> 29) & 1;
int pos = 12;
if (fontBlock) {
//int fontHeight = m_book->readByte<int>(data, 64, 4);
//int fontOptions = m_book->readByte<int>(data, 68, 4);
//unsigned short weight = m_book->readByte<unsigned short>(data, 72, 2);
//unsigned short escapement = m_book->readByte<unsigned short>(data, 74, 2);
//unsigned char underline = m_book->readByte<unsigned char>(data, 76, 1);
//int fontColorIndex = m_book->readByte<int>(data, 80, 4);
//int twoBits = m_book->readByte<int>(data, 88, 4);
//int fontEscapment = m_book->readByte<int>(data, 92, 4);
//int fontUnderlying = m_book->readByte<int>(data, 96, 4);
//bool fontStyle = (twoBits > 1) & 1;
//bool posture = (fontOptions > 1) & 1;
//bool fontCancel = (twoBits > 7) & 1;
//bool cancellation = (fontOptions > 7) & 1;
pos += 118;
}
if (borderBlock)
pos += 8;
if (paletteBlock)
pos += 4;
std::string formula1 = data.substr(pos, size1);
pos += size1;
std::string formula2 = data.substr(pos, size2);
pos += size2;
}
else if (code == XL_DEFAULTROWHEIGHT) {
unsigned short bits;
if (size == 4) {
bits = m_book->readByte<unsigned short>(data, 0, 2);
m_defaultRowHeight = m_book->readByte<unsigned short>(data, 2, 2);
}
else if (size == 2) {
bits = 0;
m_defaultRowHeight = m_book->readByte<unsigned short>(data, 0, 2);
}
else {
bits = 0;
}
m_isDefaultRowHeightMismatch = bits & 1;
m_isDefaultRowHidden = (bits >> 1) & 1;
m_hasDefaultAdditionalSpaceAbove = (bits >> 2) & 1;
m_hasDefaultAdditionalSpaceBelow = (bits >> 3) & 1;
}
else if (code == XL_MERGEDCELLS) {
if (!m_book->m_addStyle)
continue;
int pos = 0;
unpackCellRangeAddressListUpdatePos(m_mergedCells, data, pos, 8);
}
else if (code == XL_WINDOW2) {
unsigned short options;
if (m_book->m_biffVersion >= 80 && size >= 14) {
options = m_book->readByte<unsigned short>(data, 0, 2);
m_firstVisibleRowIndex = m_book->readByte<unsigned short>(data, 2, 2);
m_firstVisibleColIndex = m_book->readByte<unsigned short>(data, 4, 2);
m_gridlineColorIndex = m_book->readByte<unsigned short>(data, 6, 2);
m_cachedPageBreakPreviewMagFactor = m_book->readByte<unsigned short>(data, 8, 2);
m_cachedNormalViewMagFactor = m_book->readByte<unsigned short>(data, 10, 2);
}
else {
options = m_book->readByte<unsigned short>(data, 0, 2);
m_firstVisibleRowIndex = m_book->readByte<unsigned short>(data, 2, 2);
m_firstVisibleColIndex = m_book->readByte<unsigned short>(data, 4, 2);
m_gridlineColor = {
m_book->readByte<unsigned char>(data, 6, 1),
m_book->readByte<unsigned char>(data, 7, 1),
m_book->readByte<unsigned char>(data, 8, 1),
};
m_gridlineColorIndex = Formatting::getNearestColorIndex(m_book->m_colorMap, m_gridlineColor);
}
m_showFormula = (options >> 0) & 1;
m_showGridLine = (options >> 1) & 1;
m_showSheetHeader = (options >> 2) & 1;
m_isFrozenPanes = (options >> 3) & 1;
m_showZeroValue = (options >> 4) & 1;
m_automaticGridLineColor = (options >> 5) & 1;
m_columnsRightToLeft = (options >> 6) & 1;
m_showOutlineSymbol = (options >> 7) & 1;
m_removeSplits = (options >> 8) & 1;
m_isSheetSelected = (options >> 9) & 1;
m_isSheetVisible = (options >> 10) & 1;
m_showPageBreakPreview = (options >> 11) & 1;
}
else if (code == XL_SCL) {
unsigned short num = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short den = m_book->readByte<unsigned short>(data, 2, 2);
int result = 0;
if (den)
result = (num * 100);
if (!(10 <= result && result <= 400))
result = 100;
m_sclMagFactor = result;
}
else if (code == XL_PANE) {
m_vertSplitPos = m_book->readByte<unsigned short>(data, 0, 2);
m_horzSplitPos = m_book->readByte<unsigned short>(data, 2, 2);
m_horzSplitFirstVisible = m_book->readByte<unsigned short>(data, 4, 2);
m_vertSplitFirstVisible = m_book->readByte<unsigned short>(data, 6, 2);
m_splitActivePane = m_book->readByte<unsigned char>(data, 8, 1);
m_hasPaneRecord = true;
}
else if (code == XL_HORIZONTALBREAKS) {
if (!m_book->m_addStyle)
continue;
//unsigned short breakCount = m_book->readByte<unsigned short>(data, 0, 2);
int pos = 2;
if (m_book->m_biffVersion < 80)
while (pos < size) {
m_horizontalPageBreaks.push_back({
m_book->readByte<unsigned short>(data, pos, 2),
0,
255
});
pos += 2;
}
else
while (pos < size) {
m_horizontalPageBreaks.push_back({
m_book->readByte<unsigned short>(data, pos, 2),
m_book->readByte<unsigned short>(data, pos+2, 2),
m_book->readByte<unsigned short>(data, pos+4, 2)
});
pos += 6;
}
}
else if (code == XL_VERTICALPAGEBREAKS) {
if (!m_book->m_addStyle)
continue;
//unsigned short breakCount = m_book->readByte<unsigned short>(data, 0, 2);
int pos = 2;
if (m_book->m_biffVersion < 80)
while (pos < size) {
m_verticalPageBreaks.push_back({
m_book->readByte<unsigned short>(data, pos, 2),
0,
65535
});
pos += 2;
}
else
while (pos < size) {
m_verticalPageBreaks.push_back({
m_book->readByte<unsigned short>(data, pos, 2),
m_book->readByte<unsigned short>(data, pos+2, 2),
m_book->readByte<unsigned short>(data, pos+4, 2)
});
pos += 6;
}
}
// All of the following are for BIFF <= 4W
else if (m_book->m_biffVersion <= 45) {
Formatting formatting(m_book);
if (code == XL_FORMAT || code == XL_FORMAT2)
formatting.handleFormat(data, code);
else if (code == XL_FONT || code == XL_FONT_B3B4)
formatting.handleFont(data);
else if (code == XL_STYLE) {
if (!m_book->m_xfEpilogueDone)
formatting.xfEpilogue();
formatting.handleStyle(data);
}
else if (code == XL_PALETTE)
formatting.handlePalette(data);
else if (code == XL_BUILTINFMTCOUNT)
m_book->m_builtinFormatCount = m_book->readByte<unsigned short>(data, 0, 2);
else if (code == XL_XF4 || code == XL_XF3 || code == XL_XF2) // N.B. not XL_XF
formatting.handleXf(data);
else if (code == XL_DATEMODE)
m_book->m_dateMode = m_book->readByte<unsigned short>(data, 0, 2);
else if (code == XL_CODEPAGE) {
m_book->m_codePage = m_book->readByte<unsigned short>(data, 0, 2);
m_book->getEncoding();
}
else if (code == XL_WRITEACCESS)
m_book->handleWriteAccess(data);
else if (code == XL_IXFE)
m_ixfe = m_book->readByte<unsigned short>(data, 0, 2);
else if (code == XL_NUMBER_B2) {
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short colIndex = m_book->readByte<unsigned short>(data, 2, 2);
std::string cellAttributes = m_book->readByte<std::string>(data, 4, 3);
double d = m_book->readByte<unsigned short>(data, 7, 4);
putCell(rowIndex, colIndex, std::to_string(d), fixedXfIndexB2(cellAttributes));
}
else if (code == XL_INTEGER) {
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short colIndex = m_book->readByte<unsigned short>(data, 2, 2);
std::string cellAttributes = m_book->readByte<std::string>(data, 4, 3);
float d = m_book->readByte<unsigned short>(data, 7, 2);
putCell(rowIndex, colIndex, std::to_string(d), fixedXfIndexB2(cellAttributes));
}
else if (code == XL_LABEL_B2) {
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short colIndex = m_book->readByte<unsigned short>(data, 2, 2);
std::string cellAttributes = m_book->readByte<std::string>(data, 4, 3);
std::string str = m_book->unpackString(data, 7, 1);
putCell(rowIndex, colIndex, str, fixedXfIndexB2(cellAttributes));
}
else if (code == XL_BOOLERR_B2) {
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short colIndex = m_book->readByte<unsigned short>(data, 2, 2);
std::string cellAttributes = m_book->readByte<std::string>(data, 4, 3);
unsigned char value = m_book->readByte<unsigned char>(data, 7, 1);
//unsigned char hasError = m_book->readByte<unsigned char>(data, 8, 1);
//int cellType = hasError ? XL_CELL_ERROR : XL_CELL_BOOLEAN;
putCell(rowIndex, colIndex, std::to_string(value), fixedXfIndexB2(cellAttributes));
}
else if (code == XL_BLANK_B2) {
if (!m_book->m_addStyle)
continue;
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short colIndex = m_book->readByte<unsigned short>(data, 2, 2);
std::string cellAttributes = m_book->readByte<std::string>(data, 4, 3);
putCell(rowIndex, colIndex, "", fixedXfIndexB2(cellAttributes));
}
else if (code == XL_EFONT) {
if (!m_book->m_addStyle)
continue;
m_book->m_fontList.back().m_color.m_index = m_book->readByte<unsigned short>(data, 0, 2);
}
else if (code == XL_ROW_B2) {
if (!m_book->m_addStyle)
continue;
unsigned short rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short flag1 = m_book->readByte<unsigned short>(data, 6, 2);
unsigned char flag2 = m_book->readByte<unsigned char>(data, 10, 1);
if (!(0 <= rowIndex && rowIndex < m_maxRowCount))
continue;
int xfIndex;
// hasDefaultXfIndex is false
if (!(flag2 & 1)) {
xfIndex = -1;
}
// Seems XF index in the cellAttributes is dodgy
else if (size == 18) {
unsigned short xfx = m_book->readByte<unsigned short>(data, 16, 2);
xfIndex = fixedXfIndexB2("", xfx);
}
else {
std::string cellAttributes = data.substr(13, 3);
xfIndex = fixedXfIndexB2(cellAttributes);
}
auto key = std::make_pair(flag1, flag2);
Rowinfo rowinfo;
if (rowinfoSharingDict.find(key) == rowinfoSharingDict.end()) {
rowinfo.m_height = flag1 & 0x7fff;
rowinfo.m_hasDefaultHeight = (flag1 >> 15) & 1;
rowinfo.m_hasDefaultXfIndex = flag2 & 1;
rowinfo.m_xfIndex = xfIndex;
}
else {
rowinfo = rowinfoSharingDict[key];
}
m_rowinfoMap[rowIndex] = rowinfo;
}
else if (code == XL_COLWIDTH) { // BIFF2 only
if (!m_book->m_addStyle)
continue;
unsigned char firstColIndex = m_book->readByte<unsigned char>(data, 0, 1);
unsigned char lastColIndex = m_book->readByte<unsigned char>(data, 1, 1);
unsigned short width = m_book->readByte<unsigned short>(data, 2, 2);
if (firstColIndex > lastColIndex)
continue;
for (int i = firstColIndex; i <= lastColIndex; ++i) {
Colinfo colinfo;
if (m_colinfoMap.find(i) != m_colinfoMap.end()) {
m_colinfoMap[i].m_width = width;
//colinfo = m_colinfoMap[i];
}
else {
colinfo.m_width = width;
m_colinfoMap[i] = colinfo;
}
}
}
else if (code == XL_COLUMNDEFAULT) { // BIFF2 only
if (!m_book->m_addStyle)
continue;
unsigned short firstColIndex = m_book->readByte<unsigned short>(data, 0, 2);
unsigned short lastColIndex = m_book->readByte<unsigned short>(data, 2, 2);
// Warning: OOo docs wrong; firstColIndex <= colx < lastColIndex
if (0 > firstColIndex || firstColIndex >= lastColIndex || lastColIndex > 256)
lastColIndex = std::min((int)lastColIndex, 256);
for (int i = firstColIndex; i < lastColIndex; ++i) {
std::string cellAttributes = data.substr(4 + 3*(i - firstColIndex), 3);
int xfIndex = fixedXfIndexB2(cellAttributes);
Colinfo colinfo;
if (m_colinfoMap.find(i) != m_colinfoMap.end()) {
m_colinfoMap[i].m_xfIndex = xfIndex;
//colinfo = m_colinfoMap[i];
}
else {
colinfo.m_xfIndex = xfIndex;
m_colinfoMap[i] = colinfo;
}
}
}
else if (code == XL_WINDOW2_B2) { // BIFF 2 only
m_showFormula = (data[0] != '\0');
m_showGridLine = (data[1] != '\0');
m_showSheetHeader = (data[2] != '\0');
m_isFrozenPanes = (data[3] != '\0');
m_showZeroValue = (data[4] != '\0');
m_firstVisibleRowIndex = m_book->readByte<unsigned short>(data, 5, 2);
m_firstVisibleColIndex = m_book->readByte<unsigned short>(data, 7, 2);
m_automaticGridLineColor = m_book->readByte<unsigned char>(data, 9, 1);
m_gridlineColor = {
m_book->readByte<unsigned char>(data, 10, 1),
m_book->readByte<unsigned char>(data, 11, 1),
m_book->readByte<unsigned char>(data, 12, 1)
};
m_gridlineColorIndex = Formatting::getNearestColorIndex(m_book->m_colorMap, m_gridlineColor);
}
}
}
if (!eofFound)
throw std::logic_error("Sheet "+ std::to_string(m_number) +
" ("+ m_name + ") missing EOF record");
tidyDimensions();
updateCookedFactors();
m_book->m_position = oldPosition;
}
void Sheet::putCell(int rowIndex, int colIndex, const std::string& value, int xfIndex) {
int rowCount = rowIndex + 1;
int colCount = colIndex + 1;
if (colCount > m_colCount) {
m_colCount = colCount;
// The row firstFullRowIndex and all subsequent rows are guaranteed to have length == m_colCount
// Cell data is not in non-descending row order AND m_colCount has been bumped up.
// This very rare case ruins this optmisation
if (rowCount < m_rowCount)
m_firstFullRowIndex = -2;
else if (rowIndex > m_firstFullRowIndex && m_firstFullRowIndex > -2)
m_firstFullRowIndex = rowIndex;
}
if (rowCount > m_rowCount)
m_rowCount = rowCount;
// Add missing rows to table
for (int i = tools::xmlChildrenCount(m_table, "tr"); i <= rowIndex; ++i) {
auto tr = m_table.append_child("tr");
addRowStyle(tr, i);
}
pugi::xml_node tr = *std::next(m_table.children("tr").begin(), rowIndex);
// Add missing cells to row
for (int i = tools::xmlChildrenCount(tr, "td"); i < colIndex; ++i) {
auto td = tr.append_child("td");
addColStyle(td, i);
}
auto td = tr.append_child("td");
auto node = td;
// Get cell style
if (m_book->m_addStyle) {
auto& xf = m_book->m_xfList[xfIndex];
auto& cellFont = m_book->m_fontList[xf.m_fontIndex];
addCellStyle(td, xf, rowIndex, colIndex);
if (cellFont.m_isBold)
node = node.append_child("b");
if (cellFont.m_isItalic)
node = node.append_child("i");
if (cellFont.m_isUnderlined)
node = node.append_child("u");
if (cellFont.m_isStruckOut)
node = node.append_child("s");
if (cellFont.m_escapement == 1)
node = node.append_child("sup");
if (cellFont.m_escapement == 2)
node = node.append_child("sub");
}
node.append_child(pugi::node_pcdata).set_value(value.c_str());
}
void Sheet::tidyDimensions() {
if (!m_mergedCells.empty()) {
int rowCount = 0;
int colCount = 0;
for (const auto& cRange : m_mergedCells) {
if (cRange[1] > rowCount)
rowCount = cRange[1];
if (cRange[3] > colCount)
colCount = cRange[3];
}
if (colCount > m_colCount) {
m_colCount = colCount;
m_firstFullRowIndex = -2;
}
// Put one empty cell at (rowCount-1, 0) to make sure we have right number of rows
if (rowCount > m_rowCount)
putCell(rowCount-1, 0, "", -1);
}
// Add missing cells to row
int rIndex = 0;
for (auto& tr : m_table.children("tr")) {
for (int i = tools::xmlChildrenCount(tr, "td"); i < m_colCount; ++i) {
auto td = tr.append_child("td");
addColStyle(td, i);
}
rIndex++;
}
// Add colspan/rowspan attributes
if (m_book->m_mergingMode == 0) {
int rowIndex = -1;
int colCount = -1;
for (const auto& cRange : m_mergedCells) {
auto tr = std::next(m_table.children("tr").begin(), cRange[0]);
for (int i = cRange[0]; i < cRange[1]; ++i) {
if (rowIndex != i) {
rowIndex = i;
colCount = 0;
}
int offset = std::min(tools::xmlChildrenCount(*tr, "td"), cRange[3] - colCount) - 1;
auto td = std::next(tr->children("td").begin(), offset);
int endRange = cRange[3] - (rowIndex == cRange[0]);
for (int j = cRange[2]; j < endRange; ++j) {
auto next = td--;
tr->remove_child(*next);
colCount++;
}
if (rowIndex == cRange[0]) {
td->append_attribute("colspan") = std::to_string(cRange[3]-cRange[2]).c_str();
td->append_attribute("rowspan") = std::to_string(cRange[1]-cRange[0]).c_str();
}
tr++;
}
}
}
// Fill empty cells with duplicate values
else if (m_book->m_mergingMode == 1) {
for (const auto& cRange : m_mergedCells) {
auto tr = std::next(m_table.children("tr").begin(), cRange[0]);
auto tdMain = std::next(tr->children("td").begin(), cRange[2]);
for (int i = cRange[0]; i < cRange[1]; ++i) {
auto td = std::next(tr->children("td").begin(), cRange[2]);
for (int j = cRange[2]; j < cRange[3]; ++j) {
// Each cell has only 1 element, so we need to copy only first child
if (td != tdMain)
td->append_copy(tdMain->first_child());
td++;
}
tr++;
}
}
}
}
// private:
std::string Sheet::stringRecordContent(const std::string& data) {
int length = (m_book->m_biffVersion >= 30) + 1;
unsigned short expectedCharCount = m_book->readByte<unsigned short>(data, 0, length);
int offset = length;
int foundCharCount = 0;
std::string result = "";
while (true) {
if (m_book->m_biffVersion >= 80)
offset++;
std::string chunk = data.substr(offset);
result += chunk;
foundCharCount += static_cast<unsigned short>(chunk.size());
if (foundCharCount == expectedCharCount)
return result;
if (foundCharCount > expectedCharCount)
throw std::logic_error(
"STRING/CONTINUE: expected " + std::to_string(expectedCharCount) +
" chars, found " + std::to_string(foundCharCount)
);
unsigned short code;
unsigned short unusedLength;
std::string data;
m_book->getRecordParts(code, unusedLength, data);
if (code != XL_CONTINUE)
throw std::logic_error("Expected CONTINUE record; found record-type "+ std::to_string(code));
offset = 0;
}
}
int Sheet::fixedXfIndexB2(const std::string& cellAttributes, int trueXfIndex) {
int xfIndex;
if (m_book->m_biffVersion == 21) {
if (!m_book->m_xfList.empty()) {
if (trueXfIndex != -1)
xfIndex = trueXfIndex;
else
xfIndex = cellAttributes[0] & 0x3F;
if (xfIndex == 0x3F) {
if (m_ixfe == 0)
throw std::logic_error("BIFF2 cell record has XF index 63 but no preceding IXFE record");
xfIndex = m_ixfe;
// OOo docs are capable of interpretation that each
// cell record is preceded immediately by its own IXFE record.
// Empirical evidence is that (sensibly) an IXFE record applies to all
// following cell records until another IXFE comes along.
}
return xfIndex;
}
// Have either Excel 2.0, or broken 2.1 w/o XF records - same effect
m_book->m_biffVersion = 20;
}
xfIndex = m_cellAttributesToXfIndex[cellAttributes];
if (xfIndex)
return xfIndex;
if (m_book->m_xfList.empty()) {
for (int i = 0; i < 16; ++i)
insertXfB20("\x40\x00\x00", i < 15);
}
xfIndex = insertXfB20(cellAttributes);
return xfIndex;
}
int Sheet::insertXfB20(const std::string& cellAttributes, bool isStyle) {
int xfx = static_cast<int>(m_book->m_xfList.size());
XF xf;
fakeXfFromCellAttrB20(xf, cellAttributes, isStyle);
xf.m_xfIndex = xfx;
m_book->m_xfList.emplace_back(xf);
if (m_book->m_formatMap.find(xf.m_formatKey) == m_book->m_formatMap.end()) {
Format fmt(xf.m_formatKey, FUN, "General");
m_book->m_formatMap[xf.m_formatKey] = fmt;
m_book->m_formatList.emplace_back(fmt);
}
Format fmt = m_book->m_formatMap[xf.m_formatKey];
int cellty = CELL_TYPE_FROM_FORMAT_TYPE.at(fmt.m_type);
m_book->m_xfIndexXlTypeMap[xf.m_xfIndex] = cellty;
m_cellAttributesToXfIndex[cellAttributes] = xfx;
return xfx;
}
void Sheet::fakeXfFromCellAttrB20(XF& xf, const std::string& cellAttributes, bool isStyle) {
xf.m_alignment = XFAlignment();
xf.m_alignment.m_indentLevel = 0;
xf.m_alignment.m_isShrinkToFit = 0;
xf.m_alignment.m_textDirection = 0;
xf.m_border = XFBorder();
xf.m_border.m_diagUp = false;
xf.m_border.m_diagDown = false;
xf.m_border.m_diagColor.m_index = 0;
xf.m_border.m_diagLineStyle = 0; // No line
xf.m_background = XFBackground();
xf.m_protection = XFProtection();
unsigned char protection = m_book->readByte<unsigned char>(cellAttributes, 0, 1);
unsigned char fontFormat = m_book->readByte<unsigned char>(cellAttributes, 0, 1);
unsigned char style = m_book->readByte<unsigned char>(cellAttributes, 0, 1);
xf.m_protection.m_isCellLocked = (protection & 0x40) >> 6;
xf.m_protection.m_isFormulaHidden = (protection & 0x80) >> 7;
xf.m_parentStyleIndex = isStyle ? 0 : 0x0FFF;
xf.m_formatKey = fontFormat & 0x3F;
xf.m_fontIndex = (fontFormat & 0xC0) >> 6;
xf.m_alignment.m_isShrinkToFit = style & 0x07;
xf.m_alignment.m_verticalAlign = 2; // Bottom
xf.m_alignment.m_rotation = 0;
xf.m_border.m_leftLineStyle = (style & 0x08) ? 1 : 0; // 1 - thin
xf.m_border.m_leftColor.m_index = (style & 0x08) ? 8 : 0; // 8 - black
xf.m_border.m_rightLineStyle = (style & 0x10) ? 1 : 0;
xf.m_border.m_rightColor.m_index = (style & 0x10) ? 8 : 0;
xf.m_border.m_topLineStyle = (style & 0x20) ? 1 : 0;
xf.m_border.m_topColor.m_index = (style & 0x20) ? 8 : 0;
xf.m_border.m_bottomLineStyle = (style & 0x40) ? 1 : 0;
xf.m_border.m_bottomColor.m_index = (style & 0x40) ? 8 : 0;
xf.m_formatFlag = true;
xf.m_fontFlag = true;
xf.m_alignmentFlag = true;
xf.m_borderFlag = true;
xf.m_backgroundFlag = true;
xf.m_protectionFlag = true;
xf.m_background.m_fillPattern = (style & 0x80) ? 17 : 0;
xf.m_background.m_backgroundColor.m_index = 9; // White
xf.m_background.m_patternColor.m_index = 8; // Black
}
std::string Sheet::getNullTerminatedUnicode(const std::string& buf, int& offset) const {
unsigned long size = m_book->readByte<int>(buf, offset, 4) * 2;
offset += 4;
std::string res = buf.substr(offset, size-1);
offset += size;
return res;
}
void Sheet::handleHyperlink(const std::string& data) {
int recordSize = static_cast<int>(data.size());
Hyperlink hlink;
hlink.m_firstRowIndex = m_book->readByte<unsigned short>(data, 0, 2);
hlink.m_lastRowIndex = m_book->readByte<unsigned short>(data, 2, 2);
hlink.m_firstColIndex = m_book->readByte<unsigned short>(data, 4, 2);
hlink.m_lastColIndex = m_book->readByte<unsigned short>(data, 6, 2);
int options = m_book->readByte<int>(data, 28, 4);
int offset = 32;
// Has a description
if (options & 0x14)
hlink.m_description = getNullTerminatedUnicode(data, offset);
// Has a target
if (options & 0x80)
hlink.m_target = getNullTerminatedUnicode(data, offset);
// HasMoniker and not MonikerSavedAsString
if ((options & 1) && !(options & 0x100)) {
// An OLEMoniker structure
std::string clsId = m_book->readByte<std::string>(data, offset, 16);
offset += 16;
if (clsId == "\xE0\xC9\xEA\x79\xF9\xBA\xCE\x11\x8C\x82\x00\xAA\x00\x4B\xA9\x0B") {
// URL Moniker
unsigned long size = m_book->readByte<unsigned long>(data, offset, 4);
offset += 4;
hlink.m_type = "url";
hlink.m_url = data.substr(offset, size);
hlink.m_url = hlink.m_url.substr(0, hlink.m_url.find("\x00"));
offset += size;
}
else if (clsId == "\x03\x03\x00\x00\x00\x00\x00\x00\xC0\x00\x00\x00\x00\x00\x00\x46") {
// File moniker
unsigned long upLevels = m_book->readByte<unsigned short>(data, offset, 2);
int size = m_book->readByte<int>(data, offset+2, 4);
hlink.m_type = "local file";
offset += 6;
// BYTES, not unicode
std::string shortPath = tools::repeatString("..\\", upLevels) +
data.substr(offset, size - 1);
offset += size + 24; // OOo: "unknown byte sequence"
// Above is version 0xDEAD + 20 reserved zero bytes
size = m_book->readByte<int>(data, offset, 4);
offset += 4;
if (size) {
size = m_book->readByte<int>(data, offset, 4);
offset += 6; // "unknown byte sequence" MS: 0x0003
std::string extendedPath = data.substr(offset, size); // Not zero-terminated
offset += size;
hlink.m_url = extendedPath;
}
// The "shortpath" is bytes encoded in *UNKNOWN* creator's "ANSI" encoding
else {
hlink.m_url = shortPath;
}
}
}
// UNC
else if ((options & 0x163) == 0x103) {
hlink.m_type = "unc";
hlink.m_url = getNullTerminatedUnicode(data, offset);
}
else if ((options & 0x16B) == 8)
hlink.m_type = "workbook";
else
hlink.m_type = "unknown";
// Has textmark
if (options & 0x8)
hlink.m_textmark = getNullTerminatedUnicode(data, offset);
int extraByteCount = recordSize - offset;
if (extraByteCount < 0)
throw std::logic_error("Bug or corrupt file, send copy of input file for debugging");
m_hyperlinkList.push_back(hlink);
for (int i = hlink.m_firstRowIndex; i <= hlink.m_lastRowIndex; ++i)
for (int j = hlink.m_firstColIndex; j <= hlink.m_lastColIndex; ++j)
m_hyperlinkMap[{i, j}] = hlink;
}
void Sheet::handleQuicktip(const std::string& data) {
//unsigned short codeIndex = m_book->readByte<unsigned short>(data, 0, 2);
//unsigned short firstRowIndex = m_book->readByte<unsigned short>(data, 2, 2);
//unsigned short lastRowIndex = m_book->readByte<unsigned short>(data, 4, 2);
//unsigned short firstColIndex = m_book->readByte<unsigned short>(data, 6, 2);
//unsigned short lastColIndex = m_book->readByte<unsigned short>(data, 8, 2);
m_hyperlinkList.back().m_quicktip = data.substr(10, data.size() - 10 - 2);
}
void Sheet::handleMSObj(const std::string& data, MSObj& msObj) {
if (m_book->m_biffVersion < 80) {
msObj.m_isNull = true;
return;
}
int size = static_cast<int>(data.size());
int pos = 0;
while (pos < size) {
unsigned short ft = m_book->readByte<unsigned short>(data, pos, 2);
unsigned short cb = m_book->readByte<unsigned short>(data, pos+2, 2);
if (pos == 0 && !(ft == 0x15 && cb == 18)) {
msObj.m_isNull = true;
return;
}
// ftCmo ... s/b first
if (ft == 0x15) {
msObj.m_type = m_book->readByte<unsigned short>(data, pos+4, 2);
msObj.m_id = m_book->readByte<unsigned short>(data, pos+6, 2);
unsigned short options = m_book->readByte<unsigned short>(data, pos+8, 2);
msObj.m_isLocked = (options & 0x0001) >> 0;
msObj.m_isPrintable = (options & 0x0010) >> 4;
msObj.m_autoFilter = (options & 0x0100) >> 8; // Not documented in Excel 97 dev kit
msObj.m_scrollbarFlag = (options & 0x0200) >> 9; // Not documented in Excel 97 dev kit
msObj.m_autoFill = (options & 0x2000) >> 13;
msObj.m_autoLine = (options & 0x4000) >> 14;
}
else if (ft == 0x00) {
// Ignore "optional reserved" data at end of record
if (data.substr(pos, size - pos) == std::string(size - pos, '\0'))
break;
throw std::logic_error("Unexpected data at end of OBJECT record");
}
// Scrollbar
else if (ft == 0x0C) {
msObj.m_scrollbarValue = m_book->readByte<unsigned short>(data, pos+8, 2);
msObj.m_scrollbarMin = m_book->readByte<unsigned short>(data, pos+10, 2);
msObj.m_scrollbarMax = m_book->readByte<unsigned short>(data, pos+12, 2);
msObj.m_scrollbarInc = m_book->readByte<unsigned short>(data, pos+14, 2);
msObj.m_scrollbarPage = m_book->readByte<unsigned short>(data, pos+16, 2);
}
// List box data
else if (ft == 0x13) {
// Non standard exit. NOT documented
if (msObj.m_autoFilter)
break;
}
pos += cb + 4;
}
}
void Sheet::handleMSTxo(const std::string& data, MSTxo& msTxo) {
if (m_book->m_biffVersion < 80) {
msTxo.m_isNull = true;
return;
}
size_t size = data.size();
unsigned short options = m_book->readByte<unsigned short>(data, 0, 2);
msTxo.m_rotation = m_book->readByte<unsigned short>(data, 2, 2);
std::string controlInfo = data.substr(4, 6);
unsigned short cchText = m_book->readByte<unsigned short>(data, 10, 2);
unsigned short cbRuns = m_book->readByte<unsigned short>(data, 12, 2);
msTxo.m_isNotEmpty = m_book->readByte<unsigned short>(data, 14, 2);
msTxo.m_formula = data.substr(16, size);
msTxo.m_horzAlign = (options & 0x0001) >> 3;
msTxo.m_vertAlign = (options & 0x0001) >> 6;
msTxo.m_lockText = (options & 0x0001) >> 9;
msTxo.m_justLast = (options & 0x0001) >> 14;
msTxo.m_secretEdit = (options & 0x0001) >> 15;
msTxo.m_text.clear();
int totalCharCount = 0;
while (totalCharCount < cchText) {
unsigned short code2;
unsigned short size2;
std::string data2;
m_book->getRecordParts(code2, size2, data2);
char nb = data2[0]; // 0 means latin1, 1 means utf_16_le
int charCount = size2 - 1;
if (nb)
charCount /= 2;
int endPos = 0;
msTxo.m_text += m_book->unpackUnicodeUpdatePos(data2, endPos, 2, charCount);
totalCharCount += charCount;
}
msTxo.m_richtextRunlist.clear();
int totalRuns = 0;
while (totalRuns < cbRuns) { // Counts of BYTES, not runs
unsigned short code2;
unsigned short size2;
std::string data2;
m_book->getRecordParts(code2, size2, data2);
for (int pos = 0; pos < size2; pos += 8) {
msTxo.m_richtextRunlist.emplace_back(m_book->readByte<unsigned short>(data2, pos, 2),
m_book->readByte<unsigned short>(data2, pos+2, 2));
totalRuns += 8;
}
}
// Remove trailing entries that point to the end of string
for (
auto it = msTxo.m_richtextRunlist.rbegin();
(it != msTxo.m_richtextRunlist.rend()) && (it->first == cchText);
++it
)
msTxo.m_richtextRunlist.pop_back();
}
void Sheet::handleNote(const std::string& data, std::unordered_map<unsigned short, MSTxo>& msTxos) {
Note note;
int size = static_cast<int>(data.size());
if (m_book->m_biffVersion < 80) {
note.m_rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
note.m_colIndex = m_book->readByte<unsigned short>(data, 2, 2);
unsigned short expectedByteCount = m_book->readByte<unsigned short>(data, 4, 2);
unsigned short nb = size - 6;
note.m_text = data.substr(6, size);
expectedByteCount -= nb;
while (expectedByteCount > 0) {
unsigned short code2;
unsigned short size2;
std::string data2;
m_book->getRecordParts(code2, size2, data2);
nb = m_book->readByte<unsigned short>(data2, 4, 2);
note.m_text += data2.substr(6);
expectedByteCount -= nb;
}
note.m_richtextRunlist.emplace_back(0, 0);
m_cellNoteMap[{note.m_rowIndex, note.m_colIndex}] = note;
return;
}
// Excel 8.0+
note.m_rowIndex = m_book->readByte<unsigned short>(data, 0, 2);
note.m_colIndex = m_book->readByte<unsigned short>(data, 2, 2);
unsigned short options = m_book->readByte<unsigned short>(data, 4, 2);
note.m_objectId = m_book->readByte<unsigned short>(data, 6, 2);
note.m_isShown = (options >> 1) & 1;
note.m_isRowHidden = (options >> 7) & 1;
note.m_isColHidden = (options >> 8) & 1;
// XL97 dev kit says NULL [sic] bytes padding between string count and string data
// to ensure that string is word-aligned. Appears to be nonsense
int endPos = 8;
note.m_author = m_book->unpackUnicodeUpdatePos(data, endPos, 2);
// There is a random/undefined byte after the author string (not counted in string length)
if (msTxos.find(note.m_objectId) != msTxos.end()) {
auto& msTxo = msTxos[note.m_objectId];
note.m_text = msTxo.m_text;
note.m_richtextRunlist = msTxo.m_richtextRunlist;
m_cellNoteMap[{note.m_rowIndex, note.m_colIndex}] = note;
}
}
void Sheet::updateCookedFactors() {
if (m_showPageBreakPreview) {
// No SCL record
if (m_sclMagFactor == -1)
m_cookedPageBreakPreviewMagFactor = 100; // Yes, 100, not 60, NOT a typo
else
m_cookedPageBreakPreviewMagFactor = m_sclMagFactor;
int zoom = m_cachedNormalViewMagFactor;
if (!(10 <= zoom && zoom <= 400))
zoom = m_cookedPageBreakPreviewMagFactor;
m_cookedNormalViewMagFactor = zoom;
}
// Normal view mode
else {
// No SCL record
if (m_sclMagFactor == -1)
m_cookedNormalViewMagFactor = 100;
else
m_cookedNormalViewMagFactor = m_sclMagFactor;
int zoom = m_cachedPageBreakPreviewMagFactor;
// VALID, defaults to 60
if (!zoom)
zoom = 60;
else if (!(10 <= zoom && zoom <= 400))
zoom = m_cookedNormalViewMagFactor;
m_cookedPageBreakPreviewMagFactor = zoom;
}
}
void Sheet::unpackCellRangeAddressListUpdatePos(std::vector<std::vector<int>>& outputList,
const std::string& data, int& pos, int addressSize) const
{
unsigned short listSize = m_book->readByte<unsigned short>(data, pos, 2);
pos += 2;
if (listSize) {
for (int i = 0; i < listSize; ++i) {
if (addressSize == 6)
outputList.push_back({
m_book->readByte<unsigned short>(data, pos, 2),
m_book->readByte<unsigned short>(data, pos+2, 2) + 1,
m_book->readByte<unsigned char>(data, pos+4, 1),
m_book->readByte<unsigned char>(data, pos+5, 1) + 1
});
else
outputList.push_back({
m_book->readByte<unsigned short>(data, pos, 2),
m_book->readByte<unsigned short>(data, pos+2, 2) + 1,
m_book->readByte<unsigned short>(data, pos+4, 2),
m_book->readByte<unsigned short>(data, pos+6, 2) + 1
});
pos += addressSize;
}
}
}
double Sheet::unpackRK(const std::string& data) const {
char flags = data[0];
// There's a SIGNED 30-bit integer in there
if (flags & 2) {
int i = m_book->readByte<int>(data, 0, 4);
i >>= 2; // Div by 4 to drop the 2 flag bits
if (flags & 1)
return i / 100.0;
return i;
}
// It's the most significant 30 bits of IEEE 754 64-bit FP number
else {
double d = m_book->readByte<double>(
std::string(4, '\0') + (char)(flags & 252) + data.substr(1, 3),
0, 8
);
if (flags & 1)
return d / 100.0;
return d;
}
}
void Sheet::addCellStyle(pugi::xml_node& node, const XF& xf, int rowIndex, int colIndex) {
auto& cellFont = m_book->m_fontList[xf.m_fontIndex];
auto fontColor = getColor(cellFont.m_color);
auto cellColor = getColor(xf.m_background.m_patternColor);
std::unordered_map<std::string, std::string> styleMap;
std::unordered_map<std::string, std::string> borderMap;
// Column style
addColStyle(node, colIndex);
// Table parts style
for (const auto& cRange : m_tableParts) {
if (cRange[0] <= rowIndex && rowIndex <= cRange[1] &&
cRange[2] <= colIndex && colIndex <= cRange[3]
) {
if (cRange[0] == rowIndex) {
getTableColor(styleMap["color"], TABLE_COLOR.at(cRange[4]), 0);
getTableColor(styleMap["background"], TABLE_BACKGROUND.at(cRange[4]), 0);
}
/*else {
getTableColor(styleMap["color"], TABLE_COLOR[cRange[4]], 1);
if ((rowIndex - cRange[0]) % 2)
getTableColor(styleMap["background"], TABLE_BACKGROUND[cRange[4]], 1);
else
getTableColor(styleMap["background"], TABLE_BACKGROUND[cRange[4]], 2);
}*/
break;
}
}
// Cell style
styleMap["font-size"] = std::to_string(cellFont.m_height/20) +"px";
styleMap["font-family"] = "'"+ cellFont.m_name +"'";
if (!cellColor.empty())
styleMap["background"] = cellColor;
if (!fontColor.empty())
styleMap["color"] = fontColor;
if (xf.m_alignment.m_horizontalAlign)
styleMap["text-align"] = CELL_HORZ_ALIGN[xf.m_alignment.m_horizontalAlign];
if (xf.m_alignment.m_verticalAlign)
styleMap["vertical-align"] = CELL_VERT_ALIGN[xf.m_alignment.m_verticalAlign];
borderMap["top"] = getColor(xf.m_border.m_topColor);
borderMap["left"] = getColor(xf.m_border.m_leftColor);
borderMap["right"] = getColor(xf.m_border.m_rightColor);
borderMap["bottom"] = getColor(xf.m_border.m_bottomColor);
styleMap["border-top"] = std::to_string(CELL_BORDER_SIZE[xf.m_border.m_topLineStyle]) +"px "+
CELL_BORDER_TYPE[xf.m_border.m_topLineStyle] +" "+
(borderMap["top"].empty() ? "#000" : borderMap["top"]);
styleMap["border-left"] = std::to_string(CELL_BORDER_SIZE[xf.m_border.m_leftLineStyle]) +"px "+
CELL_BORDER_TYPE[xf.m_border.m_leftLineStyle] +" "+
(borderMap["left"].empty() ? "#000" : borderMap["left"]);
styleMap["border-right"] = std::to_string(CELL_BORDER_SIZE[xf.m_border.m_rightLineStyle]) +"px "+
CELL_BORDER_TYPE[xf.m_border.m_rightLineStyle] +" "+
(borderMap["right"].empty() ? "#000" : borderMap["right"]);
styleMap["border-bottom"] = std::to_string(CELL_BORDER_SIZE[xf.m_border.m_bottomLineStyle]) +"px "+
CELL_BORDER_TYPE[xf.m_border.m_bottomLineStyle] +" "+
(borderMap["bottom"].empty() ? "#000" : borderMap["bottom"]);
if (xf.m_alignment.m_rotation) {
if (xf.m_alignment.m_rotation <= 90)
styleMap["transform"] = "rotate("+
std::to_string(-xf.m_alignment.m_rotation) +"deg)";
else if (xf.m_alignment.m_rotation <= 180)
styleMap["transform"] = "rotate("+
std::to_string(xf.m_alignment.m_rotation - 90) +"deg)";
}
if (xf.m_alignment.m_textDirection)
styleMap["direction"] = "rtl";
std::string style;
for (const auto& sm : styleMap) {
if (!sm.second.empty())
style += sm.first + ":" + sm.second + "; ";
}
if (!style.empty()) {
if (node.attribute("style"))
node.attribute("style").set_value((style + node.attribute("style").value()).c_str());
else
node.append_attribute("style") = style.c_str();
}
}
void Sheet::addRowStyle(pugi::xml_node& node, int rowIndex) {
if (!m_book->m_addStyle || m_rowinfoMap.find(rowIndex) == m_rowinfoMap.end())
return;
std::unordered_map<std::string, std::string> styleMap;
if (m_rowinfoMap[rowIndex].m_height)
styleMap["height"] = std::to_string(m_rowinfoMap[rowIndex].m_height/20) +"px";
if (m_rowinfoMap[rowIndex].m_isHidden)
styleMap["display"] = "none";
std::string style;
for (const auto& sm : styleMap)
style += sm.first + ":" + sm.second + "; ";
if (!style.empty())
node.append_attribute("style") = style.c_str();
}
void Sheet::addColStyle(pugi::xml_node& node, int colIndex) {
if (!m_book->m_addStyle || m_colinfoMap.find(colIndex) == m_colinfoMap.end())
return;
std::unordered_map<std::string, std::string> styleMap;
if (m_colinfoMap[colIndex].m_width)
styleMap["min-width"] = std::to_string(m_colinfoMap[colIndex].m_width/45) +"px";
if (m_colinfoMap[colIndex].m_isHidden)
styleMap["display"] = "none";
std::string style;
for (const auto& sm : styleMap)
style += sm.first + ":" + sm.second + "; ";
if (!style.empty())
node.append_attribute("style") = style.c_str();
}
std::string Sheet::getColor(const XFColor& color) const {
std::vector<unsigned char> result;
if (color.m_isRgb) {
result = color.m_rgb;
}
else {
result = m_book->m_colorMap[color.m_index];
if (result.empty())
return "";
}
if (color.m_tint < 0) {
for (auto& c : result)
c = static_cast<unsigned char>(c * (1 + color.m_tint));
}
else if (color.m_tint > 0) {
for (auto& c : result)
c = static_cast<unsigned char>(c * (1 - color.m_tint) + (255 - 255 * (1 - color.m_tint)));
}
return "rgb("+ std::to_string(result[0]) +", "+
std::to_string(result[1]) +", "+ std::to_string(result[2]) +")";
}
void Sheet::getTableColor(std::string& style, const std::vector<std::string>& colorMap,
int colorIndex) const
{
if (static_cast<int>(colorMap.size()) > colorIndex && !colorMap[colorIndex].empty())
style = "#" + colorMap[colorIndex];
}
} // End namespace
| 35.749851 | 101 | 0.638466 | [
"object",
"vector",
"transform",
"solid"
] |
53359b2fd1ced5b70368ebca7d6a7d909d4dfad4 | 2,647 | cpp | C++ | src/lib/formats/dim_dsk.cpp | Robbbert/messui | 49b756e2140d8831bc81335298ee8c5471045e79 | [
"BSD-3-Clause"
] | 26 | 2015-03-31T06:25:51.000Z | 2021-12-14T09:29:04.000Z | src/lib/formats/dim_dsk.cpp | Robbbert/messui | 49b756e2140d8831bc81335298ee8c5471045e79 | [
"BSD-3-Clause"
] | null | null | null | src/lib/formats/dim_dsk.cpp | Robbbert/messui | 49b756e2140d8831bc81335298ee8c5471045e79 | [
"BSD-3-Clause"
] | 10 | 2015-03-27T05:45:51.000Z | 2022-02-04T06:57:36.000Z | // license:BSD-3-Clause
// copyright-holders:Olivier Galibert
/*********************************************************************
formats/dim_dsk.c
DIM disk images
*********************************************************************/
#include "dim_dsk.h"
#include "ioprocs.h"
#include <cstring>
dim_format::dim_format()
{
}
const char *dim_format::name() const
{
return "dim";
}
const char *dim_format::description() const
{
return "DIM disk image";
}
const char *dim_format::extensions() const
{
return "dim";
}
int dim_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants)
{
uint8_t h[16];
size_t actual;
io.read_at(0xab, h, 16, actual);
if(strncmp((const char *)h, "DIFC HEADER", 11) == 0)
return 100;
return 0;
}
bool dim_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image)
{
size_t actual;
int offset = 0x100;
uint8_t h;
uint8_t track_total = 77;
int cell_count = form_factor == floppy_image::FF_35 ? 200000 : 166666;
io.read_at(0, &h, 1, actual);
int spt, gap3, bps, size;
switch(h) {
case 0:
default:
spt = 8;
gap3 = 0x74;
size = 3;
break;
case 1:
spt = 9;
gap3 = 0x39;
size = 3;
break;
case 3:
spt = 9;
gap3 = 0x39;
size = 3;
break;
case 2:
spt = 15;
gap3 = 0x54;
size = 2;
break;
case 9:
spt = 18;
gap3 = 0x54;
size = 2;
break;
case 17:
spt = 26;
gap3 = 0x33;
size = 1;
break;
}
bps = 128 << size;
for(int track=0; track < track_total; track++)
for(int head=0; head < 2; head++) {
desc_pc_sector sects[30];
uint8_t sect_data[10000];
int sdatapos = 0;
for(int i=0; i<spt; i++) {
sects[i].track = track;
sects[i].head = head;
if(h == 1) // handle 2HS sector layout
{
if(i == 0 && track == 0)
sects[i].sector = i+1;
else
sects[i].sector = i+10;
}
else
sects[i].sector = i+1;
sects[i].size = size;
sects[i].actual_size = bps;
sects[i].deleted = false;
sects[i].bad_crc = false;
sects[i].data = §_data[sdatapos];
io.read_at(offset, sects[i].data, bps, actual);
offset += bps;
sdatapos += bps;
}
build_pc_track_mfm(track, head, image, cell_count, spt, sects, gap3);
}
return true;
}
bool dim_format::save(util::random_read_write &io, const std::vector<uint32_t> &variants, floppy_image *image)
{
return false;
}
bool dim_format::supports_save() const
{
return false;
}
const floppy_format_type FLOPPY_DIM_FORMAT = &floppy_image_format_creator<dim_format>;
| 18.907143 | 126 | 0.587457 | [
"vector"
] |
533d4e116395e35e2fa43bb25af1987e20e05767 | 2,232 | hpp | C++ | src/slide/slide.hpp | moredu/upm | d6f76ff8c231417666594214679c49399513112e | [
"MIT"
] | 619 | 2015-01-14T23:50:18.000Z | 2019-11-08T14:04:33.000Z | src/slide/slide.hpp | moredu/upm | d6f76ff8c231417666594214679c49399513112e | [
"MIT"
] | 576 | 2015-01-02T09:55:14.000Z | 2019-11-12T15:31:10.000Z | src/slide/slide.hpp | moredu/upm | d6f76ff8c231417666594214679c49399513112e | [
"MIT"
] | 494 | 2015-01-14T18:33:56.000Z | 2019-11-07T10:08:15.000Z | /*
* Authors: Brendan Le Foll <brendan.le.foll@intel.com>
* Mihai Tudor Panu <mihai.tudor.panu@intel.com>
* Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 - 2016 Intel Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the The MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <string>
#include <mraa/aio.hpp>
namespace upm {
/**
* @brief Slide Sensor Library
* @defgroup slide libupm-slide
* @ingroup seeed analog ainput
*/
/**
* @library slide
* @sensor slide
* @comname Slide Potentiometer
* @altname Grove Slide
* @type ainput
* @man seeed
* @web http://wiki.seeed.cc/Grove-Slide_Potentiometer/
* @con analog
*
* @brief API for the Slide Potentiometer
*
* Basic UPM module for the slide potentiometer on analog that
* returns either a raw value or a scaled voltage value.
*
* @image html slide.jpg
* @snippet slide.cxx Interesting
*/
class Slide {
public:
/**
* Analog slide potentiometer constructor
*
* @param pin Number of the analog pin to use
*
* @param ref_voltage Reference voltage the board is set to, as a floating-point value; default is 5.0V
*/
Slide(unsigned int pin, float ref_voltage = 5.0);
/**
* Slide destructor
*/
~Slide();
/**
* Gets the raw value from the AIO pin
*
* @return Raw value from the ADC
*/
float raw_value();
/**
* Gets the voltage value from the pin
*
* @return Voltage reading based on the reference voltage
*/
float voltage_value();
/**
* Gets the board's reference voltage passed on object initialization
*
* @return Reference voltage the class was set for
*/
float ref_voltage();
/* Gets the sensor name
*
* @return sensor name
*/
std::string name() {return "Slide Potentiometer";}
private:
mraa_aio_context m_aio;
float m_ref_voltage;
};
}
| 25.655172 | 111 | 0.596774 | [
"object"
] |
533f0c2dc7252c94968ab81c04f20b30881e21c1 | 3,694 | cpp | C++ | test/LinearAlgebra/AdjustedCSRSpMV/src/AdjustedCSRSpMVCpuCode.cpp | custom-computing-ic/dfe-snippets | 8721e6272c25f77360e2de423d8ff5a9299ee5b2 | [
"MIT"
] | 17 | 2015-02-02T13:23:49.000Z | 2021-02-09T11:04:40.000Z | test/LinearAlgebra/AdjustedCSRSpMV/src/AdjustedCSRSpMVCpuCode.cpp | custom-computing-ic/dfe-snippets | 8721e6272c25f77360e2de423d8ff5a9299ee5b2 | [
"MIT"
] | 14 | 2015-07-02T10:13:05.000Z | 2017-05-30T15:59:43.000Z | test/LinearAlgebra/AdjustedCSRSpMV/src/AdjustedCSRSpMVCpuCode.cpp | custom-computing-ic/dfe-snippets | 8721e6272c25f77360e2de423d8ff5a9299ee5b2 | [
"MIT"
] | 8 | 2015-04-08T13:27:50.000Z | 2016-12-16T14:38:52.000Z | #include <vector>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/lexical_cast.hpp>
#include "SpmvBase.h"
#include "MaxSLiCInterface.h"
#include <dfesnippets/sparse/common.hpp>
#include <dfesnippets/sparse/sparse_matrix.hpp>
#include <dfesnippets/sparse/partition.hpp>
#include "fpga.hpp"
// #define DEBUG_PRINT_MATRICES
// #define DEBUG_PARTITIONS
using namespace std;
string check_file(char **argv) {
string path{argv[2]};
ifstream f{path};
if (!f) {
cout << "Error opening input file" << endl;
exit(1);
}
return path;
}
int main(int argc, char** argv) {
cout << "Program arguments:" << endl;
for (int i = 0; i < argc; i++)
cout << " " << argv[i] << endl;
string path = check_file(argv);
int num_repeat = boost::lexical_cast<int>(argv[3]);
// -- Design Parameters
int numPipes = SpmvBase_numPipes;
// -- Matrix Parameters
int n, nnzs;
double* values;
int *col_ind, *row_ptr;
read_ge_mm_csr((char *)path.c_str(), &n, &nnzs, &col_ind, &row_ptr, &values);
// adjust from 1 indexed CSR (used by MKL) to 0 indexed CSR
for (int i = 0; i < nnzs; i++)
col_ind[i]--;
using namespace boost::numeric;
// generate multiplicand
vector<double> v(n);
ublas::vector<double> vu(n);
for (int i = 1; i <=n; i++) {
v[i - 1] = i;
vu(i - 1) = i;
}
// -- load the CSR matrix
CsrMatrix<> inMatrix(n, n);
for (int i = 0; i < n; ++i)
{
int rowStart = row_ptr[i] - 1;
int rowEnd = row_ptr[i + 1] - 1;
for (int j = rowStart; j < rowEnd; ++j)
{
inMatrix(i, col_ind[j]) = values[j];
}
}
auto res = ublas::prod(inMatrix, vu);
vector<double> bExp = SpMV_MKL_ge((char *)path.c_str(), v);
int partitionSize = min(SpmvBase_vectorCacheSize, n);
vector<CsrMatrix<double>> partitions = partition(inMatrix, partitionSize);
vector<double> dfe_res(n, 0);
AdjustedCsrMatrix<double> full_original_matrix(n);
full_original_matrix.load_from_csr(
&inMatrix.value_data()[0],
&inMatrix.index2_data()[0],
&inMatrix.index1_data()[0]);
#ifdef DEBUG_PRINT_MATRICES
cout << "Full original matrix " << endl;
full_original_matrix.print_dense();
cout << "Vector: " << endl;
print_vector(v);
#endif
int offset = 0;
for (size_t i = 0; i < partitions.size(); ++i) {
auto p = partitions[i];
AdjustedCsrMatrix<double> original_matrix(n);
original_matrix.load_from_csr(
&p.value_data()[0],
&p.index2_data()[0],
&p.index1_data()[0]
);
#ifdef DEBUG_PRINT_MATRICES
original_matrix.print();
original_matrix.print_dense();
#endif
// find expected result
vector<double> vblock(v.begin() + offset, v.begin() + offset + partitionSize);
auto b = SpMV_DFE(original_matrix, vblock, numPipes, num_repeat);
for (int j = 0; j < n; ++j)
{
dfe_res[j] += b[j];
}
offset += partitionSize;
}
cout << "Checking ublas " << endl;
for (int i = 0; i < n; ++i) {
if (!dfesnippets::numeric_utils::almost_equal(res(i), bExp[i])) {
cerr << "Expected " << bExp[i] << " got: " << res(i) << endl;
exit(1);
}
}
cout << "Ran SPMV " << endl;
int errors = 0;
for (size_t i = 0; i < dfe_res.size(); i++)
if (!dfesnippets::numeric_utils::almost_equal(bExp[i], dfe_res[i])) {
cerr << "Expected [ " << i << " ] " << bExp[i] << " got: " << dfe_res[i] << endl;
errors++;
}
if (errors != 0) {
cerr << "Errors " << errors <<endl;
return 1;
}
cout << "Test passed!" << endl;
return 0;
}
| 24.791946 | 87 | 0.60287 | [
"vector"
] |
534414137d6a4e050ae5371b0da16248fedb393d | 5,709 | cpp | C++ | src/main.cpp | j-i-k-o/OpenGLLib | 03e4be9b52efcbb02cba0dac15d268c857fcf5c4 | [
"MIT"
] | null | null | null | src/main.cpp | j-i-k-o/OpenGLLib | 03e4be9b52efcbb02cba0dac15d268c857fcf5c4 | [
"MIT"
] | null | null | null | src/main.cpp | j-i-k-o/OpenGLLib | 03e4be9b52efcbb02cba0dac15d268c857fcf5c4 | [
"MIT"
] | null | null | null | /*******************************************************************************
* OpenGLLib
*
* The MIT License (MIT)
*
* Copyright (c) 2015 j-i-k-o
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*******************************************************************************/
#include "../include/gllib/gl_all.h"
#include <vector>
#include <SDL2/SDL.h>
#include <IL/ilu.h>
#include <SDL2/SDL_opengl.h>
jikoLib::GLLib::GLObject obj;
int threadfunction(void* data)
{
using namespace jikoLib::GLLib;
return 0;
}
const std::string vshader_source =
#include "geom.vert"
;
const std::string gshader_source =
#include "geom.geom"
;
const std::string fshader_source =
#include "geom.frag"
;
int main(int argc, char* argv[])
{
using namespace jikoLib::GLLib;
/*************************************
* SDL initialize
* **********************************/
if(SDL_Init(SDL_INIT_EVERYTHING) < 0)
{
std::cerr << "Cannot Initialize SDL!: " << SDL_GetError() << std::endl;
return -1;
}
//SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
//SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
//SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
//SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_Rect window_rect;
if(SDL_GetDisplayBounds(0, &window_rect) != 0)
{
std::cerr << "SDL_GetDisplayBounds failed" << std::endl;
return 0;
}
SDL_Window* window = SDL_CreateWindow("SDL_Window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, window_rect.w, window_rect.h, SDL_WINDOW_OPENGL);
if(window == NULL)
{
std::cerr << "Window could not be created!: " << SDL_GetError() << std::endl;
}
SDL_GLContext context;
context = SDL_GL_CreateContext(window);
/***************************************
*
* ************************************/
obj << Begin();
SDL_GL_SetSwapInterval(1);
SDL_GL_MakeCurrent(window, context);
//load shaders
VShader vshader;
GShader gshader;
FShader fshader;
ShaderProgram program;
vshader << vshader_source;
gshader << gshader_source;
fshader << fshader_source;
program << vshader << gshader << fshader << link_these();
Mesh3D cube;
MeshSample::Cube cubeHelper(1.0);
cube.copyData(cubeHelper.getVertex(), cubeHelper.getNormal(), cubeHelper.getTexcrd(), cubeHelper.getNumVertex());
Camera camera;
camera.setPos(glm::vec3(3.0f, 3.0f, -2.0f));
camera.setDrct(glm::vec3(0.0f, 0.0f, 0.0f));
camera.setUp(glm::vec3(0.0f, 1.0f, 0.0f));
camera.setFar(10.0f);
//window size
obj.connectAttrib(program, cube.getNormal(), cube.getVArray(), "norm");
obj.connectAttrib(program, cube.getVertex(), cube.getVArray(), "vertex");
obj.connectAttrib(program, cube.getTexcrd(), cube.getVArray(), "texcrd");
program.setUniformMatrixXtv("model", glm::value_ptr(cube.getModelMatrix()), 1, 4);
//program.setUniformMatrixXtv("view", glm::value_ptr(camera.getViewMatrix()), 1, 4);
//program.setUniformMatrixXtv("projection", glm::value_ptr(camera.getProjectionMatrix()), 1, 4);
program.setUniformXt("light.ambient", 0.25f, 0.25f, 0.25f, 1.0f);
program.setUniformXt("light.diffuse", 1.0f, 1.0f, 1.0f, 1.0f);
program.setUniformXt("light.specular", 1.0f, 1.0f, 1.0f, 1.0f);
program.setUniformXt("material.ambient", 0.3f, 0.0f, 0.4f, 1.0f);
program.setUniformXt("material.diffuse", 0.75f, 0.0f, 1.0f, 1.0f);
program.setUniformXt("material.specular", 1.0f, 1.0f, 1.0f, 1.0f);
program.setUniformXt("material.shininess", 3.0f);
program.setUniformXt("attenuation.constant", 0.0f);
program.setUniformXt("attenuation.linear", 0.5f);
program.setUniformXt("attenuation.quadratic", 0.075f);
program.setUniformXt("textureobj", 0);
//draw
volatile bool quit = false;
SDL_Event e;
while(!quit)
{
while(SDL_PollEvent(&e) != 0)
{
if(e.type == SDL_QUIT)
quit = true;
}
CHECK_GL_ERROR;
obj.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
obj.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
program.setUniformXt("light.position", 0.6f, 0.6f, -0.6f);
int width, height;
SDL_GetWindowSize(window, &width, &height);
camera.setAspect(width, height);
program.setUniformMatrixXtv("view", glm::value_ptr(camera.getViewMatrix()), 1, 4);
program.setUniformMatrixXtv("projection", glm::value_ptr(camera.getProjectionMatrix()), 1, 4);
obj.viewport(0, 0, width, height);
obj.draw(cube, program);
SDL_GL_SwapWindow(window);
}
/*************************************
* SDL desctuction
* **********************************/
SDL_GL_DeleteContext(context);
SDL_DestroyWindow(window);
SDL_Quit();
/***************************************
*
* ************************************/
return 0;
}
| 30.047368 | 152 | 0.659485 | [
"vector",
"model"
] |
5346c69c9f79c65bf3a474294f6d073742656c84 | 1,918 | cpp | C++ | templates/BluecadetApp/src/_TBOX_PREFIX_App.cpp | bluecadet/Cinder-BluecadetViews | d6ff2fecfbfd5399dfd375170083c9230a0e0d6b | [
"MIT"
] | 10 | 2017-10-23T15:27:50.000Z | 2021-02-03T03:28:27.000Z | templates/BluecadetApp/src/_TBOX_PREFIX_App.cpp | bluecadet/Cinder-BluecadetViews | d6ff2fecfbfd5399dfd375170083c9230a0e0d6b | [
"MIT"
] | 40 | 2017-10-20T13:56:08.000Z | 2021-10-01T15:39:37.000Z | templates/BluecadetApp/src/_TBOX_PREFIX_App.cpp | bluecadet/Cinder-BluecadetViews | d6ff2fecfbfd5399dfd375170083c9230a0e0d6b | [
"MIT"
] | 3 | 2018-07-16T16:34:37.000Z | 2020-05-07T02:49:37.000Z | #include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
#include "bluecadet/core/BaseApp.h"
#include "bluecadet/views/TouchView.h"
#include "bluecadet/_TBOX_PREFIX_Settings.h"
using namespace ci;
using namespace ci::app;
using namespace std;
using namespace bluecadet::core;
using namespace bluecadet::views;
using namespace bluecadet::touch;
class _TBOX_PREFIX_App : public BaseApp {
public:
static void prepareSettings(ci::app::App::Settings* settings);
void setup() override;
void update() override;
void draw() override;
};
void _TBOX_PREFIX_App::prepareSettings(ci::app::App::Settings* settings) {
// Optional: Override the shared settings manager instance with your subclass
// This will return the correct instance whenever you call SettingsManager::get()
SettingsManager::setInstance(bluecadet::_TBOX_PREFIX_Settings::get());
// Initialize the settings manager with the cinder app settings and the settings json
SettingsManager::get()->setup(settings);
}
void _TBOX_PREFIX_App::setup() {
BaseApp::setup();
// Optional: configure your root view
getRootView()->setBackgroundColor(Color::gray(0.5f));
// Sample content
auto button = make_shared<TouchView>();
button->setPosition(400.f, 300.f);
button->setSize(200.f, 100.f);
button->setBackgroundColor(Color(1, 0, 0));
button->getSignalTapped().connect([=](...) { CI_LOG_I("Button tapped"); });
getRootView()->addChild(button);
}
void _TBOX_PREFIX_App::update() {
// Optional override. BaseApp::update() will update all views.
BaseApp::update();
}
void _TBOX_PREFIX_App::draw() {
// Optional override. BaseApp::draw() will draw all views.
BaseApp::draw();
}
// Make sure to pass a reference to prepareSettings to configure the app correctly. MSAA and other render options are optional.
CINDER_APP(_TBOX_PREFIX_App, RendererGl(RendererGl::Options().msaa(4)), _TBOX_PREFIX_App::prepareSettings); | 31.442623 | 127 | 0.751825 | [
"render"
] |
c72b76c211f750a2d86767eb4d80d111efe5f619 | 27,313 | cpp | C++ | landed_title/landed_title.cpp | Andrettin/Metternich | 513a7d3cddacad5d5efd2fa5faeed03bc55a190c | [
"MIT"
] | 12 | 2019-08-03T05:58:12.000Z | 2022-01-20T20:46:41.000Z | landed_title/landed_title.cpp | Andrettin/Metternich | 513a7d3cddacad5d5efd2fa5faeed03bc55a190c | [
"MIT"
] | 6 | 2019-08-03T11:46:49.000Z | 2022-01-22T10:20:32.000Z | landed_title/landed_title.cpp | Andrettin/Metternich | 513a7d3cddacad5d5efd2fa5faeed03bc55a190c | [
"MIT"
] | null | null | null | #include "landed_title/landed_title.h"
#include "character/character.h"
#include "character/dynasty.h"
#include "culture/culture.h"
#include "culture/culture_group.h"
#include "culture/culture_supergroup.h"
#include "database/defines.h"
#include "economy/trade_node.h"
#include "economy/trade_route.h"
#include "game/game.h"
#include "history/history.h"
#include "holding/holding.h"
#include "holding/holding_slot.h"
#include "holding/holding_type.h"
#include "landed_title/landed_title_tier.h"
#include "map/map.h"
#include "map/map_mode.h"
#include "map/province.h"
#include "map/star_system.h"
#include "map/world.h"
#include "politics/government_type.h"
#include "politics/government_type_group.h"
#include "politics/law.h"
#include "politics/law_group.h"
#include "religion/religion.h"
#include "religion/religion_group.h"
#include "util/container_util.h"
#include "util/map_util.h"
#include "util/translator.h"
#include "util/vector_util.h"
#include <stdexcept>
namespace metternich {
const std::vector<landed_title *> &landed_title::get_tier_titles(const landed_title_tier tier)
{
static std::vector<landed_title *> empty_vector;
auto find_iterator = landed_title::titles_by_tier.find(tier);
if (find_iterator != landed_title::titles_by_tier.end()) {
return find_iterator->second;
}
return empty_vector;
}
landed_title *landed_title::add(const std::string &identifier)
{
landed_title *title = data_type<landed_title>::add(identifier);
std::string identifier_prefix;
const size_t find_pos = identifier.find("_");
if (find_pos != std::string::npos) {
identifier_prefix = identifier.substr(0, find_pos + 1);
}
//set the title's tier depending on the prefix of its identifier
if (identifier_prefix == landed_title::barony_prefix) {
title->tier = landed_title_tier::barony;
} else if (identifier_prefix == landed_title::county_prefix) {
title->tier = landed_title_tier::county;
} else if (identifier_prefix == landed_title::duchy_prefix) {
title->tier = landed_title_tier::duchy;
} else if (identifier_prefix == landed_title::kingdom_prefix) {
title->tier = landed_title_tier::kingdom;
} else if (identifier_prefix == landed_title::empire_prefix) {
title->tier = landed_title_tier::empire;
} else {
throw std::runtime_error("Invalid identifier for new landed title: \"" + identifier + "\". Landed title identifiers must begin with a valid prefix, which depends on the title's tier.");
}
landed_title::titles_by_tier[title->get_tier()].push_back(title);
return title;
}
const char *landed_title::get_tier_identifier(const landed_title_tier tier)
{
switch (tier) {
case landed_title_tier::barony: return landed_title::barony_identifier;
case landed_title_tier::county: return landed_title::county_identifier;
case landed_title_tier::duchy: return landed_title::duchy_identifier;
case landed_title_tier::kingdom: return landed_title::kingdom_identifier;
case landed_title_tier::empire: return landed_title::empire_identifier;
}
throw std::runtime_error("Invalid landed title tier enumeration value: " + std::to_string(static_cast<int>(tier)) + ".");
}
const char *landed_title::get_tier_holder_identifier(const landed_title_tier tier)
{
switch (tier) {
case landed_title_tier::barony: return landed_title::baron_identifier;
case landed_title_tier::county: return landed_title::count_identifier;
case landed_title_tier::duchy: return landed_title::duke_identifier;
case landed_title_tier::kingdom: return landed_title::king_identifier;
case landed_title_tier::empire: return landed_title::emperor_identifier;
}
throw std::runtime_error("Invalid landed title tier enumeration value: " + std::to_string(static_cast<int>(tier)) + ".");
}
std::string landed_title::get_tier_name(const landed_title_tier tier)
{
return translator::get()->translate(landed_title::get_tier_identifier(tier));
}
void landed_title::process_gsml_dated_property(const gsml_property &property, const QDateTime &date)
{
Q_UNUSED(date)
if (property.get_key() == "holder") {
if (property.get_operator() != gsml_operator::assignment) {
throw std::runtime_error("Only the assignment operator is available for the \"" + property.get_key() + "\" property.");
}
if (property.get_value() == "random") {
this->set_holder(nullptr);
this->random_holder = true;
return;
} else if (property.get_value() == "none") {
this->set_holder(nullptr);
return;
} else {
const character *holder = character::get(property.get_value());
if (holder != nullptr && !holder->is_alive()) {
return;
}
}
}
this->process_gsml_property(property);
}
void landed_title::process_gsml_scope(const gsml_data &scope)
{
const std::string &tag = scope.get_tag();
if (tag.substr(0, 2) == landed_title::barony_prefix) {
landed_title *barony = landed_title::add(tag);
barony->set_de_jure_liege_title(this);
database::process_gsml_data(barony, scope);
} else {
data_entry_base::process_gsml_scope(scope);
}
}
void landed_title::initialize()
{
if (this->get_tier() == landed_title_tier::barony) {
if (this->get_holding_slot() != nullptr) {
if (!this->get_holding_slot()->is_initialized()) {
this->get_holding_slot()->initialize();
}
if (this->get_holding_slot()->get_province() != nullptr) {
this->set_capital_province(this->get_holding_slot()->get_province());
} else if (this->get_holding_slot()->get_world() != nullptr) {
this->set_capital_world(this->get_holding_slot()->get_world());
} else {
throw std::runtime_error("Holding slot \"" + this->get_holding_slot()->get_identifier() + "\" is not located in either a province or a world.");
}
//if a non-titular barony has no de jure liege, set the latter to be the county of the barony's holding slot's territory
if (this->get_de_jure_liege_title() == nullptr) {
this->set_de_jure_liege_title(this->get_holding_slot()->get_territory()->get_county());
}
} else if (this->get_de_jure_liege_title() != nullptr && !this->get_de_jure_liege_title()->is_titular()) {
//set the barony's capital province to its county's province or world
if (this->get_de_jure_liege_title()->get_province() != nullptr) {
this->set_capital_province(this->get_de_jure_liege_title()->get_province());
} else if (this->get_de_jure_liege_title()->get_world() != nullptr) {
this->capital_world = this->get_de_jure_liege_title()->get_world();
}
}
}
if (this->get_capital_territory() == nullptr) {
throw std::runtime_error("Landed title \"" + this->get_identifier() + "\" has no capital territory.");
}
data_entry_base::initialize();
}
void landed_title::initialize_history()
{
if (this->random_holder) {
culture *culture = nullptr;
religion *religion = nullptr;
if (this->get_holding() != nullptr) {
if (!this->get_holding()->is_history_initialized()) {
this->get_holding()->initialize_history();
}
culture = this->get_holding()->get_culture();
religion = this->get_holding()->get_religion();
} else {
culture = this->get_capital_territory()->get_culture();
religion = this->get_capital_territory()->get_religion();
}
this->set_holder(character::generate(culture, religion));
}
if (this->holder_title != nullptr) {
if (!this->holder_title->is_history_initialized()) {
this->holder_title->initialize_history();
}
if (this->holder_title->get_holder() == nullptr) {
qWarning() << ("Tried to set the \"" + this->holder_title->get_identifier_qstring() + "\" holder title for \"" + this->get_identifier_qstring() + "\", but the former has no holder.");
}
this->set_holder(this->holder_title->get_holder());
this->holder_title = nullptr;
}
if (this->liege_title != nullptr) {
if (!this->liege_title->is_history_initialized()) {
this->liege_title->initialize_history();
}
if (this->liege_title->get_holder() == nullptr) {
throw std::runtime_error("Tried to set the \"" + this->liege_title->get_identifier() + "\" liege title for \"" + this->get_identifier() + "\", but the former has no holder.");
}
if (this->get_holder() == nullptr) {
throw std::runtime_error("Tried to set the \"" + this->liege_title->get_identifier() + "\" liege title for \"" + this->get_identifier() + "\", but the latter has no holder.");
}
this->get_holder()->set_liege(this->liege_title->get_holder());
this->liege_title = nullptr;
}
data_entry_base::initialize_history();
}
void landed_title::check() const
{
if (this->get_tier() != landed_title_tier::barony && this->get_world() == nullptr && !this->get_color().isValid()) {
throw std::runtime_error("Landed title \"" + this->get_identifier() + "\" has no valid color.");
}
if (this->get_territory() != nullptr && this->get_territory() != this->get_capital_territory()) {
throw std::runtime_error("Landed title \"" + this->get_identifier() + "\" has a different territory and capital territory.");
}
if (this->get_tier() >= landed_title_tier::duchy) {
this->get_flag_path(); //throws an exception if the flag isn't found
}
}
void landed_title::check_history() const
{
if (this->get_capital_territory() == nullptr) {
throw std::runtime_error("Landed title \"" + this->get_identifier() + "\" has no capital territory.");
}
if (this->get_holding_slot() != nullptr && this->get_holding_slot()->get_territory() != this->get_capital_territory()) {
throw std::runtime_error("Landed title \"" + this->get_identifier() + "\" has its holding slot in a different province than its capital province.");
}
if (this->get_holding_slot() != nullptr && this->get_holding_slot()->get_world() != this->get_capital_world()) {
throw std::runtime_error("Landed title \"" + this->get_identifier() + "\" has its holding slot in a different province than its capital province.");
}
if (this->get_territory() != nullptr) {
if (this->get_tier() != landed_title_tier::county) {
throw std::runtime_error("Landed title \"" + this->get_identifier() + "\" has been assigned to a territory, but is not a county.");
}
}
if (this->get_holding_slot() != nullptr) {
if (this->get_tier() != landed_title_tier::barony) {
throw std::runtime_error("Landed title \"" + this->get_identifier() + "\" has been assigned to a holding slot, but is not a barony.");
}
}
if (this->get_star_system() != nullptr) {
if (this->get_tier() != landed_title_tier::duchy) {
throw std::runtime_error("Landed title \"" + this->get_identifier() + "\" has been assigned to a star system, but is not a duchy.");
}
}
this->check();
}
std::string landed_title::get_name() const
{
return translator::get()->translate(this->get_identifier_with_aliases(), this->get_tag_suffix_list_with_fallbacks());
}
std::string landed_title::get_tier_title_name() const
{
std::vector<std::vector<std::string>> tag_suffix_list_with_fallbacks = this->get_tag_suffix_list_with_fallbacks();
tag_suffix_list_with_fallbacks.push_back({this->get_identifier()});
return translator::get()->translate(landed_title::get_tier_identifier(this->get_tier()), tag_suffix_list_with_fallbacks);
}
std::string landed_title::get_titled_name() const
{
std::string titled_name = this->get_tier_title_name() + " of ";
titled_name += this->get_name();
return titled_name;
}
std::string landed_title::get_holder_title_name() const
{
std::vector<std::vector<std::string>> tag_suffix_list_with_fallbacks = this->get_tag_suffix_list_with_fallbacks();
tag_suffix_list_with_fallbacks.push_back(this->get_identifier_with_aliases());
if (this->get_holder() != nullptr && this->get_holder()->is_female()) {
tag_suffix_list_with_fallbacks.push_back({"female"});
}
return translator::get()->translate(landed_title::get_tier_holder_identifier(this->get_tier()), tag_suffix_list_with_fallbacks);
}
std::vector<std::vector<std::string>> landed_title::get_tag_suffix_list_with_fallbacks() const
{
std::vector<std::vector<std::string>> tag_list_with_fallbacks;
if (this->get_holding() != nullptr) {
//for non-titular baronies, use the holding's type for the localization, so that e.g. a city's holder title name will be "mayor", regardless of the character's actual government
tag_list_with_fallbacks.push_back({this->get_holding()->get_type()->get_identifier()});
}
if (this->get_government_type() != nullptr) {
tag_list_with_fallbacks.push_back({this->get_government_type()->get_identifier(), government_type_group_to_string(this->get_government_type()->get_group())});
}
const culture *culture = this->get_culture();
if (culture != nullptr) {
tag_list_with_fallbacks.push_back({culture->get_identifier(), culture->get_group()->get_identifier(), culture->get_supergroup()->get_identifier()});
}
const religion *religion = this->get_religion();
if (religion != nullptr) {
tag_list_with_fallbacks.push_back({religion->get_identifier(), religion->get_group()->get_identifier()});
}
if (this->get_holder() != nullptr && this->get_holder()->get_dynasty() != nullptr) {
//allow for different localizations/flags depending on the title holder's dynasty
tag_list_with_fallbacks.push_back({this->get_holder()->get_dynasty()->get_identifier()});
}
return tag_list_with_fallbacks;
}
void landed_title::set_holder(character *character)
{
if (character == this->get_holder()) {
return;
}
metternich::character *old_holder = this->get_holder();
const landed_title *old_realm = this->get_realm();
if (old_holder != nullptr) {
old_holder->remove_landed_title(this);
}
this->holder = character;
if (character != nullptr) {
character->add_landed_title(this);
if (!this->is_primary()) {
this->clear_non_succession_laws();
this->set_missing_law_to_default_for_law_group(defines::get()->get_succession_law_group());
}
} else {
this->laws.clear();
emit laws_changed();
}
this->holder_title = nullptr; //set the holder title to null, so that the new holder (null or otherwise) isn't overwritten by a previous holder title
this->random_holder = false;
const landed_title *realm = this->get_realm();
if (this->get_star_system() != nullptr) {
//if this is a star system's duchy, then the character holding it must also possess the duchy's capital world
if (this->get_capital_world() != nullptr && this->get_capital_world()->get_county() != nullptr) {
this->get_capital_world()->get_county()->set_holder(character);
}
} else if (this->get_territory() != nullptr) {
//if this is a non-titular county, then the character holding it must also possess the county's capital holding
if (this->get_territory()->get_capital_holding() != nullptr) {
this->get_territory()->get_capital_holding()->get_barony()->set_holder(character);
}
//if this is a non-titular county, the fort, university and hospital of its province must belong to the county holder
holding *fort_holding = this->get_territory()->get_fort_holding();
if (fort_holding != nullptr) {
fort_holding->set_owner(character);
}
holding *university_holding = this->get_territory()->get_university_holding();
if (university_holding != nullptr) {
university_holding->set_owner(character);
}
holding *hospital_holding = this->get_territory()->get_hospital_holding();
if (hospital_holding != nullptr) {
hospital_holding->set_owner(character);
}
//transfer trading posts and factories along with counties if the old county holder owned them, or if they had no holder
holding *trading_post_holding = this->get_territory()->get_trading_post_holding();
if (trading_post_holding != nullptr && (trading_post_holding->get_owner() == nullptr || trading_post_holding->get_owner() == old_holder)) {
trading_post_holding->set_owner(character);
}
holding *factory_holding = this->get_territory()->get_factory_holding();
if (factory_holding != nullptr && (factory_holding->get_owner() == nullptr || factory_holding->get_owner() == old_holder)) {
factory_holding->set_owner(character);
}
}
if (this->get_province() != nullptr) {
if (old_holder == nullptr || character == nullptr) {
if (!history::get()->is_loading()) {
this->get_province()->calculate_trade_node();
}
if (this->get_province()->is_center_of_trade()) {
this->get_province()->get_trade_node()->set_active(character != nullptr);
}
//update the activity of trade routes which pass through this province
for (trade_route *route : this->get_province()->get_trade_routes()) {
if (route->is_endpoint(this->get_province())) {
if (character != nullptr) {
route->calculate_active();
} else {
route->set_active(false);
}
}
}
} else if (old_realm != realm) {
this->get_province()->set_trade_node_recalculation_needed(true);
}
}
if (map::get()->get_mode() == map_mode::country && old_realm != realm) {
if (this->get_province() != nullptr) {
this->get_province()->update_color_for_map_mode(map::get()->get_mode());
} else if (this->get_star_system() != nullptr) {
this->get_star_system()->update_color_for_map_mode(map::get()->get_mode());
}
}
//if this title is associated with a holding (i.e. it is a non-titular barony), then its holder must also be the owner of the holding
if (this->get_holding() != nullptr) {
this->get_holding()->set_owner(character);
}
emit holder_changed();
}
void landed_title::set_holding_slot(metternich::holding_slot *holding_slot)
{
if (holding_slot == this->get_holding_slot()) {
return;
}
this->holding_slot = holding_slot;
}
holding *landed_title::get_holding() const
{
if (this->get_holding_slot() != nullptr) {
return this->get_holding_slot()->get_holding();
}
return nullptr;
}
territory *landed_title::get_territory() const
{
if (this->get_province() != nullptr) {
return this->get_province();
} else if (this->get_world() != nullptr) {
return this->get_world();
}
return nullptr;
}
landed_title *landed_title::get_realm() const
{
character *holder = this->get_holder();
if (holder != nullptr) {
character *top_liege = holder->get_top_liege();
return top_liege->get_primary_title();
}
return nullptr;
}
/**
** @brief Get the landed title's (de facto) liege title
**
** @return The (de facto) liege title
*/
landed_title *landed_title::get_liege_title() const
{
character *holder = this->get_holder();
if (holder != nullptr) {
landed_title *holder_primary_title = holder->get_primary_title();
if (holder_primary_title->get_tier() == this->get_tier()) {
character *liege = holder->get_liege();
if (liege != nullptr) {
return liege->get_primary_title();
}
} else {
if (this->get_tier() < landed_title_tier::county && holder_primary_title->get_tier() >= landed_title_tier::county && holder->has_landed_title(this->get_de_jure_county())) {
return this->get_de_jure_county();
}
if (this->get_tier() < landed_title_tier::duchy && holder_primary_title->get_tier() >= landed_title_tier::duchy && holder->has_landed_title(this->get_de_jure_duchy())) {
return this->get_de_jure_duchy();
}
if (this->get_tier() < landed_title_tier::kingdom && holder_primary_title->get_tier() >= landed_title_tier::kingdom && holder->has_landed_title(this->get_de_jure_kingdom())) {
return this->get_de_jure_kingdom();
}
if (this->get_tier() < landed_title_tier::empire && holder_primary_title->get_tier() >= landed_title_tier::empire && holder->has_landed_title(this->get_de_jure_empire())) {
return this->get_de_jure_empire();
}
return holder_primary_title;
}
}
return nullptr;
}
void landed_title::set_holder_title(landed_title *title)
{
this->set_holder(nullptr); //set the holder title to null, so that the new holder title isn't overwritten by a previous holder
this->random_holder = false;
this->holder_title = title;
}
void landed_title::set_de_jure_liege_title(landed_title *title)
{
if (title == this->get_de_jure_liege_title()) {
return;
}
if (this->get_de_jure_liege_title() != nullptr) {
this->get_de_jure_liege_title()->remove_de_jure_vassal_title(this);
}
if (title != nullptr && static_cast<int>(title->get_tier()) - static_cast<int>(this->get_tier()) != 1) {
throw std::runtime_error("Tried to set title \"" + title->get_identifier() + "\" as the de jure liege of \"" + this->get_identifier() + "\", but the former is not one title tier above the latter.");
}
this->de_jure_liege_title = title;
if (title != nullptr) {
title->add_de_jure_vassal_title(this);
}
emit de_jure_liege_title_changed();
}
void landed_title::remove_de_jure_vassal_title(landed_title *title)
{
vector::remove(this->de_jure_vassal_titles, title);
}
/**
** @brief Get the title's (de facto) title for a given tier
**
** @return The title's (de facto) title for the given tier
*/
landed_title *landed_title::get_tier_title(const landed_title_tier tier) const
{
if (this->get_tier() > tier) {
return nullptr;
} else if (this->get_tier() == tier) {
return const_cast<landed_title *>(this);
}
for (int i = static_cast<int>(tier) - 1; i >= static_cast<int>(landed_title_tier::barony); --i) {
landed_title *tier_title = this->get_tier_title(static_cast<landed_title_tier>(i));
if (tier_title != nullptr) {
landed_title *liege_title = tier_title->get_liege_title();
if (liege_title != nullptr && liege_title->get_tier() == tier) {
return liege_title;
}
return nullptr;
}
}
landed_title *liege_title = this->get_liege_title();
if (liege_title != nullptr && liege_title->get_tier() == tier) {
return liege_title;
}
return nullptr;
}
/**
** @brief Get the title's de jure title for a given tier
**
** @return The title's de jure title for the given tier
*/
landed_title *landed_title::get_tier_de_jure_title(const landed_title_tier tier) const
{
if (this->get_tier() > tier) {
return nullptr;
} else if (this->get_tier() == tier) {
return const_cast<landed_title *>(this);
}
if (tier > landed_title_tier::barony) {
landed_title *lower_tier_title = this->get_tier_de_jure_title(static_cast<landed_title_tier>(static_cast<int>(tier) - 1));
if (lower_tier_title != nullptr) {
return lower_tier_title->get_de_jure_liege_title();
}
}
return nullptr;
}
/**
** @brief Get the title's (de facto) county
**
** @return The title's (de facto) county
*/
landed_title *landed_title::get_county() const
{
return this->get_tier_title(landed_title_tier::county);
}
landed_title *landed_title::get_de_jure_county() const
{
return this->get_tier_de_jure_title(landed_title_tier::county);
}
/**
** @brief Get the title's (de facto) duchy
**
** @return The title's (de facto) duchy
*/
landed_title *landed_title::get_duchy() const
{
return this->get_tier_title(landed_title_tier::duchy);
}
landed_title *landed_title::get_de_jure_duchy() const
{
return this->get_tier_de_jure_title(landed_title_tier::duchy);
}
/**
** @brief Get the title's (de facto) kingdom
**
** @return The title's (de facto) kingdom
*/
landed_title *landed_title::get_kingdom() const
{
return this->get_tier_title(landed_title_tier::kingdom);
}
landed_title *landed_title::get_de_jure_kingdom() const
{
return this->get_tier_de_jure_title(landed_title_tier::kingdom);
}
/**
** @brief Get the title's (de facto) empire
**
** @return The title's (de facto) empire
*/
landed_title *landed_title::get_empire() const
{
return this->get_tier_title(landed_title_tier::empire);
}
landed_title *landed_title::get_de_jure_empire() const
{
return this->get_tier_de_jure_title(landed_title_tier::empire);
}
bool landed_title::is_primary() const
{
if (this->get_holder() == nullptr) {
return false;
}
return this->get_holder()->get_primary_title() == this;
}
territory *landed_title::get_capital_territory() const
{
if (this->get_capital_province() != nullptr) {
return this->get_capital_province();
} else if (this->get_capital_world() != nullptr) {
return this->get_capital_world();
}
return nullptr;
}
holding *landed_title::get_capital_holding() const
{
if (this->get_holding() != nullptr) {
return this->get_holding();
}
if (this->get_capital_territory() != nullptr) {
return this->get_capital_territory()->get_capital_holding();
}
return nullptr;
}
culture *landed_title::get_culture() const
{
if (this->get_holder() != nullptr) {
return this->get_holder()->get_culture();
} else if (this->get_capital_territory() != nullptr) {
return this->get_capital_territory()->get_culture();
}
return nullptr;
}
religion *landed_title::get_religion() const
{
if (this->get_holder() != nullptr) {
return this->get_holder()->get_religion();
} else if (this->get_capital_territory() != nullptr) {
return this->get_capital_territory()->get_religion();
}
return nullptr;
}
const std::filesystem::path &landed_title::get_flag_path() const
{
std::string base_tag = this->get_flag_tag();
const std::filesystem::path &flag_path = database::get()->get_tagged_flag_path(base_tag, this->get_tag_suffix_list_with_fallbacks());
return flag_path;
}
QVariantList landed_title::get_laws_qvariant_list() const
{
return container::to_qvariant_list(map_container::get_values(this->laws));
}
bool landed_title::has_law(const law *law) const
{
auto find_iterator = this->laws.find(law->get_group());
if (find_iterator != this->laws.end() && find_iterator->second == law) {
return true;
}
return false;
}
Q_INVOKABLE void landed_title::add_law(law *law)
{
if (!this->has_law(law)) {
this->laws[law->get_group()] = law;
emit laws_changed();
if (this->is_primary()) {
emit this->get_holder()->laws_changed();
}
}
}
Q_INVOKABLE void landed_title::remove_law(law *law)
{
if (this->has_law(law)) {
this->laws.erase(law->get_group());
emit laws_changed();
if (this->is_primary()) {
emit this->get_holder()->laws_changed();
}
}
}
void landed_title::clear_non_succession_laws()
{
if (this->laws.empty()) {
return;
}
if (this->laws.size() == 1 && this->laws.contains(defines::get()->get_succession_law_group())) {
//the title already has only a succession law
return;
}
//save the old succession law
law *succession_law = this->get_law(defines::get()->get_succession_law_group());
this->laws.clear();
if (succession_law != nullptr) {
//restore the succession law
this->laws[defines::get()->get_succession_law_group()] = succession_law;
}
emit laws_changed();
if (this->is_primary()) {
emit this->get_holder()->laws_changed();
}
}
void landed_title::set_missing_laws_to_default()
{
const holding *capital_holding = this->get_capital_holding();
if (capital_holding != nullptr) {
for (const auto &kv_pair : capital_holding->get_type()->get_default_laws()) {
if (this->laws.contains(kv_pair.first)) {
continue;
}
this->add_law(kv_pair.second);
}
}
}
void landed_title::set_missing_law_to_default_for_law_group(law_group *law_group)
{
if (this->laws.contains(law_group)) {
return;
}
const holding *capital_holding = this->get_capital_holding();
if (capital_holding != nullptr) {
const auto &default_laws = capital_holding->get_type()->get_default_laws();
auto find_iterator = default_laws.find(law_group);
if (find_iterator != default_laws.end()) {
this->add_law(find_iterator->second);
return;
}
}
}
government_type *landed_title::get_government_type() const
{
if (this->get_holder() != nullptr) {
return this->get_holder()->get_government_type();
}
return nullptr;
}
}
| 31.358209 | 200 | 0.716326 | [
"vector"
] |
c72f134d265afd78bd839482fcd11a9d5bc1d6cb | 116,397 | cc | C++ | src/svict_caller.cc | vpc-ccg/svict | c10627bbec3f621a1b446c246064a151b7400685 | [
"BSD-3-Clause"
] | 21 | 2019-02-06T06:02:34.000Z | 2022-03-29T14:19:44.000Z | src/svict_caller.cc | vpc-ccg/svict | c10627bbec3f621a1b446c246064a151b7400685 | [
"BSD-3-Clause"
] | 13 | 2019-02-18T09:48:34.000Z | 2022-03-12T09:12:09.000Z | src/svict_caller.cc | vpc-ccg/svict | c10627bbec3f621a1b446c246064a151b7400685 | [
"BSD-3-Clause"
] | 6 | 2019-08-29T05:34:13.000Z | 2022-02-20T08:47:45.000Z | #include <iostream>
#include <fstream>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <ctime>
#include <cmath>
#include <cerrno>
#include <cstring>
#include <cfenv>
#include <math.h>
#include <pthread.h>
#include <unistd.h>
#include <sstream>
#include <sys/time.h>
#include "svict_caller.h"
#pragma STDC FENV_ACCESS ON
using namespace std;
#define strequ(A,B) (strcmp(A.c_str(), B.c_str()) == 0)
svict_caller::svict_caller(int kmer_len, const int assembler_overlap, const int anchor_len, const string &input_file, const string &reference, const string >f, const bool print_reads, const bool print_stats, const vector<string> &chromosomes) :
variant_caller(assembler_overlap, input_file, reference), ANCHOR_SIZE(anchor_len), USE_ANNO((gtf != "")), PRINT_READS(print_reads), PRINT_STATS(print_stats) {
k = kmer_len;
num_kmer = (unsigned long long)pow(4,k);
kmer_mask = (unsigned long long)(num_kmer-1);
num_intervals = 1;
u_ids = 0;
if(USE_ANNO) ensembl_Reader(gtf.c_str(), iso_gene_map, gene_sorted_map );
chromos.reserve( chromosomes.size() );
for(int id=0; id < chromosomes.size(); id++){
chromos.push_back(chromosomes[id]);
cerr << chromos[id] << endl;
}
contig_mappings = new vector<vector<mapping>>*[2];
for(int rc=0; rc < 2; rc++){
contig_mappings[rc] = new vector<vector<mapping>>[ chromos.size()];
}
last_intervals = new vector<last_interval>*[2];
for(int rc=0; rc < 2; rc++){
last_intervals[rc] = new vector<last_interval>[chromos.size()];
}
results = new unordered_map<long, vector<result>>*[6];
for(int sv=0; sv < sv_types.size(); sv++){
results[sv] = new unordered_map<long, vector<result>>[chromos.size()];
}
init();
}
svict_caller::~svict_caller(){
delete[] contig_kmers_index;
for(int rc=0; rc < 2; rc++){
delete[] contig_mappings[rc];
}
delete[] contig_mappings;
for(int rc=0; rc < 2; rc++){
delete[] last_intervals[rc];
}
delete[] last_intervals;
for(int sv=0; sv < sv_types.size(); sv++){
delete[] results[sv];
}
delete[] results;
}
void svict_caller::init(){
for(int sv=0; sv < sv_types.size(); sv++){
for(int chr=0; chr < chromos.size(); chr++){
results[sv][chr] = unordered_map<long, vector<result>>();
}
}
}
//================================================================
// Helper functions
//================================================================
vector<string> svict_caller::split(string str, char sep)
{
vector<string> ret;
istringstream stm(str);
string token;
while(getline(stm, token, sep)) ret.push_back(token);
return ret;
}
inline string svict_caller::itoa (int i)
{
char c[50];
sprintf(c, "%d", i);
return string(c);
}
inline double factorial(double n)
{
return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;
}
inline string svict_caller::con_string(int& id, int start, int len)
{
string out = "";
if(PRINT_READS){
if(all_contigs[id].data.empty())return out;
out = all_contigs[id].data.substr(start, len);
}
else{
vector<bool>& data = all_compressed_contigs[id].data;
if(data.empty())return out;
int adj_start = start*2;
int adj_len = len*2;
for(int i = adj_start; i < adj_start+adj_len; i+=2){
bool bit1 = data[i];
bool bit2 = data[i+1];
if(bit1){
if(bit2){
out += 'G';
}
else{
out += 'T';
}
}
else{
if(bit2){
out += 'C';
}
else{
out += 'A';
}
}
}
}
return out;
}
compressed_contig svict_caller::compress(contig& con){
compressed_contig comp_con;
vector<bool> data;
vector<unsigned short> coverage(con.data.length());
vector<string> read_names;
data.reserve(con.data.length()*2);
for(char& n : con.data){
switch (n) {
case 'A': data.push_back(0);
data.push_back(0);
break;
case 'T': data.push_back(1);
data.push_back(0);
break;
case 'C': data.push_back(0);
data.push_back(1);
break;
default: data.push_back(1); //Ns turn to G because I don't care!
data.push_back(1);
}
}
for (int j = 0; j < con.support(); j++){
for (int k=0; k < con.read_information[j].seq.length(); k++){
coverage[k+con.read_information[j].location_in_contig]++;
}
read_names.push_back(con.read_information[j].name);
}
comp_con.data = data;
comp_con.coverage = coverage;
comp_con.read_names = read_names;
return comp_con;
}
pair<unsigned short,pair<unsigned short,unsigned short>> svict_caller::compute_support(int& id, int start, int end){
unsigned short len = PRINT_READS ? (unsigned short)all_contigs[id].data.length() : (unsigned short)all_compressed_contigs[id].data.size()/2;
end = min(end, len-1);
unsigned short max = 0;
unsigned short min = 0;
unsigned short sum = 0;
pair<unsigned short,pair<unsigned short,unsigned short>> result;
vector<unsigned short> coverage;
if(PRINT_READS){
contig& con = all_contigs[id];
for (int k=0; k < con.data.length(); k++){
coverage.push_back((unsigned short)0);
}
for (int j = 0; j < con.support(); j++){
for (int k=0; k < con.read_information[j].seq.length(); k++){
coverage[k+con.read_information[j].location_in_contig]++;
}
}
}
else{
coverage = all_compressed_contigs[id].coverage;
}
for (int k = start; k <= end; k++)
{
if (coverage[k]>max){
max = coverage[k];
}
if (coverage[k]<min){
min = coverage[k];
}
sum += coverage[k];
}
result = {sum/len,{min, max}};
return result;
}
vector<pair<string, string>> svict_caller::correct_reads(vector<pair<string, string>> reads){
unordered_map<string, unordered_map<string, int>> consensus;
vector<pair<string, string>> corrected_reads;
int max_count = 0;
int len = 0;
string c = "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"; //quick and dirty fix TODO CCAGCGCCT-TATCGTGCA_
string g = "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG";
string max_seq = "";
for(auto & read : reads){
len = read.second.length() < 50 ? read.second.length() : 50;
if(read.second.substr(0,len) == c.substr(0,len) ||
read.second.substr(read.second.length()-len,len) == c.substr(0,len) ||
read.second.substr(0,len) == g.substr(0,len) ||
read.second.substr(read.second.length()-len,len) == g.substr(0,len))continue;
consensus[read.first.substr((read.first.length()-20), 20)][read.second]++;
}
for(auto & barcode : consensus){
max_count = 0;
max_seq = "";
for(auto & seq : barcode.second){
if(seq.second > max_count){
max_count = seq.second;
max_seq = seq.first;
}
}
corrected_reads.push_back({barcode.first, max_seq});
}
return corrected_reads;
}
bool svict_caller::is_low_complexity(string seq, double cutoff){
double a = 0;
double t = 0;
double c = 0;
double g = 0;
for(char & i : seq){
switch (i) {
case 'A': a++;
break;
case 'T': t++;
break;
case 'C': c++;
break;
default: g++;
}
}
if((c+g)/(double)seq.length() >= cutoff ||
(a+t)/(double)seq.length() >= cutoff ||
(a+c)/(double)seq.length() >= cutoff ||
(a+g)/(double)seq.length() >= cutoff ||
(t+c)/(double)seq.length() >= cutoff ||
(t+g)/(double)seq.length() >= cutoff){
return true;
}
else{
return false;
}
}
svict_caller::mapping_ext svict_caller::copy_interval(char chr, bool rc, int con_id, mapping& interval){
mapping_ext mapping_copy;
mapping_copy.chr = chr;
mapping_copy.rc = rc;
mapping_copy.loc = interval.loc;
mapping_copy.len = interval.len;
mapping_copy.con_loc = interval.con_loc;
mapping_copy.error = interval.error;
mapping_copy.con_id = con_id;
mapping_copy.id = -1;
return mapping_copy;
}
void svict_caller::print_interval(string label, mapping_ext& interval){
cerr << label << "\tRef_Loc: " << interval.loc << "-" << (interval.loc+interval.len) << "\tCon_Loc: " << ((interval.con_loc+k)-interval.len) << "-" << (interval.con_loc+k)
<< "\tLen:" << interval.len << "\tChr: " << chromos[interval.chr] << "\tRC: " << interval.rc << "\tCon_ID: " << interval.con_id << endl;
}
void svict_caller::dump_contig(FILE* writer, contig c, int id, int support, int loc, char chr){
string qual = string(c.data.size(), 'I');
fprintf(writer, "@contig_%d_%d_%d_%d\n", id, support, loc, chr);
fprintf(writer, "%s\n", c.data.c_str());
fprintf(writer, "+\n");
fprintf(writer, "%s\n", qual.c_str());
}
//======================================================
// Main Functions
//======================================================
void svict_caller::run(const string &out_vcf, const string& print_fastq, int min_support, int max_support, int uncertainty, int min_length, int max_length, int sub_optimal, const bool LOCAL_MODE, int window_size, int min_sc, int max_fragment_size, double clip_ratio, bool use_indel, bool heuristic)
{
clock_t begin = clock();
clock_t end;
double elapsed_secs;
assemble(print_fastq, min_support, max_support, window_size, LOCAL_MODE, min_sc, max_fragment_size, clip_ratio, use_indel, heuristic);
if(PRINT_STATS){
end = clock();
elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
cerr << "ASSEMBLY TIME: " << elapsed_secs << endl;
cerr << endl;
begin = clock();
}
if(print_fastq != ""){
cerr << "done" << endl;
cerr << "Please map the contigs with your mapper of choice and resume SViCT." << endl;
exit(0);
}
probalistic_filter();
if(PRINT_STATS){
end = clock();
elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
cerr << "PROBABILISTIC FILTER TIME: " << elapsed_secs << endl;
cerr << endl;
begin = clock();
}
index();
if(PRINT_STATS){
end = clock();
elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
cerr << "INDEX TIME: " << elapsed_secs << endl;
cerr << endl;
begin = clock();
}
generate_intervals(out_vcf, LOCAL_MODE);
if(PRINT_STATS){
end = clock();
elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
cerr << "MAPPING TIME: " << elapsed_secs << endl;
cerr << endl;
begin = clock();
}
predict_variants(out_vcf, uncertainty, min_length, max_length, sub_optimal);
if(PRINT_STATS){
end = clock();
elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
cerr << "CALLING TIME: " << elapsed_secs << endl;
cerr << endl;
}
}
void svict_caller::resume(const string &out_vcf, const string &input_file, const string& print_fastq, int uncertainty, int min_length, int max_length, int sub_optimal, const bool LOCAL_MODE)
{
clock_t begin = clock();
clock_t end;
double elapsed_secs;
generate_intervals_from_file(input_file, print_fastq, LOCAL_MODE);
if(PRINT_STATS){
end = clock();
elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
cerr << "MAPPING TIME: " << elapsed_secs << endl;
cerr << endl;
begin = clock();
}
predict_variants(out_vcf, uncertainty, min_length, max_length, sub_optimal);
if(PRINT_STATS){
end = clock();
elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;
cerr << "CALLING TIME: " << elapsed_secs << endl;
cerr << endl;
}
}
//======================================================
// Local Assembly Stage
//======================================================
void svict_caller::assemble(string print_fastq, int min_support, int max_support, int window_size, const bool LOCAL_MODE, int min_sc, int max_fragment_size, double clip_ratio, bool use_indel, bool heuristic)
{
FILE* writer;
vector<contig> contigs;
vector<contig> last_contigs;
compressed_contig con;
extractor ext(in_file, min_sc, max_support, max_fragment_size, clip_ratio, use_indel, PRINT_STATS);
vector<extractor::cluster> clusters;
extractor::cluster clust;
double sum = 0;
double count = 0;
int cur_start;
string cur_ref;
if(print_fastq != "")writer = fopen(print_fastq.c_str(), "wb");
clock_t begin;
clock_t end;
double elapsed_secs;
//########### Read TP ##############
// FILE *writer = fopen("all.contigs.reads", "wb");
// for(int i = 0; i < 14000; i++){
// TP[i] = false;
// }
// string line;
// ifstream myfile ("TP.contigs");
// if (myfile.is_open()) {
// while ( getline (myfile, line) ) {
// TP[stoi(line)] = true;
// }
// myfile.close();
// }
//STATS
double part_count = 0;
double contig_count1 = 0;
double contig_count2 = 0;
double support_count = 0;
int read_count = 0;
// If local mode enabled, use regions around contigs. Otherwise, add all chromosomes as regions
if(!LOCAL_MODE){
for(char chr=0; chr < chromos.size(); chr++){
regions.push_back({chr,{1, 300000000}});
}
}
//Assemble contigs and build kmer index
//=====================================
cerr << "Assembling contigs..." << endl;
clust = ext.get_next_cluster(window_size, min_support, heuristic);
while (1) {
if(!ext.has_next_cluster()){
break;
}
cur_start = clust.start;
cur_ref = clust.ref;
while(abs(clust.start - cur_start) < window_size && cur_ref == clust.ref){
clusters.push_back(clust);
cur_start = clust.start;
cur_ref = clust.ref;
if(!ext.has_next_cluster())break;
clust = ext.get_next_cluster(window_size, min_support, heuristic);
while(!clust.reads.size() || clust.reads.size() > max_support){
if(!ext.has_next_cluster())break; // if last cluster is bad, it will still be included
clust = ext.get_next_cluster(window_size, min_support, heuristic);
}
}
if(clusters.size() > 1){
set_cover(clusters);
}
for(auto& p : clusters){
if (!p.reads.size() || p.reads.size() > max_support)
continue;
if(USE_BARCODES)p.reads = correct_reads(p.reads);
if (!p.reads.size())
continue;
//Assemble contigs
contigs = as.assemble(p.reads);
//STATS
if(PRINT_STATS){
read_count += p.reads.size();
part_count++;
contig_count1 += contigs.size();
}
for (auto &contig: contigs){
//TODO why are these long contigs happening? TP is in 6000bp contig :(
if (contig.support() >= min_support && contig.support() <= max_support && contig.data.size() <= MAX_ASSEMBLY_RANGE*2 ){// && contig.data.size() <= (4*301)) { //Conservative threshold based on 4 times the longest read length of current short read sequencing technologies
if(print_fastq != "")dump_contig(writer, contig, (int)cluster_info.size(), contig.support(), p.start, (find(chromos.begin(), chromos.end(), p.ref) - chromos.begin()));
//STATS
if(PRINT_STATS){
contig_count2++;
support_count += contig.support();
if(p.start >= -42147802 && p.start <= -42147902 ){
cerr << "support: " << contig.support() << " " << contig.data.length() << " " << p.start << " " << cluster_info.size() << " " << p.ref << endl;
cerr << contig.data << endl;
}
}
//if(LOCAL_MODE)regions.push_back({contig.cluster_chr, {(pt.get_start()-ref_flank), (pt.get_end()+ref_flank)}});
// =================== Probablistic Filter =====================
set<double> positions;
double cur_pos = 0;
double last_pos = 0;
double max_dist = 0;
double num_reads = 1;
for (int j = 0; j < contig.support(); j++){
positions.insert((double)contig.read_information[j].location_in_contig);
}
for(double pos : positions){
if((pos-last_pos) > max_dist)max_dist = (pos-last_pos);
if(pos != 0){
sum += (pos-last_pos);
num_reads++;
}
last_pos = pos;
}
count += num_reads;
all_contig_metrics.push_back({num_reads, (double)contig.data.length(), max_dist});
// ==================================================================
//########### Write Contigs with TP ##############
//cout << cluster_info.size() << "\t" << contig.support() << "\t" << max_dist << "\t" << TP[cluster_info.size()] << "\tchr" << p.ref << "\t" << p.start << endl;
//########### Write Clusters ##############
// fprintf(writer, ">Cluster: %d Contig: %d MaxSupport: %d TP: %d Reads: \n", p.start, cluster_info.size(), contig.support(), TP[cluster_info.size()]); //TODO find way to get start loc in contig
// fprintf(writer, "ContigSeq: %s\n", contig.data.c_str());
// for (auto &read: contig.read_information)
// fprintf(writer, "+ %d %d %s %s\n", read.location_in_contig, read.seq.size(), read.name.c_str(), read.seq.c_str());
cluster_info.push_back({ p.start, p.total_coverage, static_cast<char>(find(chromos.begin(), chromos.end(), p.ref) - chromos.begin()) });
vector<bool> Ns = vector<bool>(contig.data.size(),false);
//store N positions
for (int i = 0; i < contig.data.length(); i++){
if(contig.data[i] == 'N')Ns[i] = true;
}
all_contig_Ns.push_back(Ns);
if(PRINT_READS){
all_contigs.push_back(contig);
}
else{
all_compressed_contigs.push_back(compress(contig));
}
}
}
vector<contig>().swap(contigs);
}//clusters
vector<extractor::cluster>().swap(clusters);
}
if(all_contigs.empty() && all_compressed_contigs.empty()){
cerr << "No contigs could be assembled. Exiting..." << endl;
exit(1);
}
rate_param = 1/(sum/count);
if(print_fastq != "")fclose(writer);
if(PRINT_STATS){
cerr << "Read Count: " << read_count << endl;
cerr << "Partition Count: " << part_count << endl;
cerr << "Total Contigs: " << contig_count1 << endl;
cerr << "Contigs: " << all_contigs.size() << " " << all_compressed_contigs.size() << endl;
cerr << "Average Num Contigs Pre-Filter: " << (contig_count1/part_count) << endl;
cerr << "Average Num Contigs Post-Filter: " << (contig_count2/part_count) << endl;
cerr << "Average Contig Support: " << (support_count/contig_count2) << endl;
cerr << "Rate Parameter Estimate: " << rate_param << endl;
}
}
vector<int> svict_caller::set_cover(vector<extractor::cluster>& clusters){
smoother sm;
vector<smoother::cluster> cover_clusters;
vector<smoother::Xread> reads;
unordered_map<string, int> read_to_id;
vector<int> selected_clusters;
int cid, num, st, ed;
for (auto& c : clusters) {
int id = cover_clusters.size();
cover_clusters.push_back({id, c.start, 0, 0, vector<int>()});
for(auto& read : c.reads){
int rid = read_to_id.size();
auto f = read_to_id.find(string(read.first));
if (f == read_to_id.end()) {
reads.push_back({vector<int>()});
read_to_id[read.first] = rid;
} else {
rid = f->second;
}
reads[rid].clusters.push_back(id);
cover_clusters[id].reads.push_back(rid);
}
}
for (auto& c : cover_clusters) {
auto s = unordered_set<int>(c.reads.begin(), c.reads.end());
c.reads = vector<int>(s.begin(), s.end());
for (auto &r: c.reads) {
auto s = unordered_set<int>(reads[r].clusters.begin(), reads[r].clusters.end());
reads[r].clusters = vector<int>(s.begin(), s.end());
assert(reads[r].clusters.size() > 0);
c.unresolved += reads[r].clusters.size() > 1;
}
c.support = c.reads.size() - c.unresolved;
}
sm.set_cover(cover_clusters, reads, read_to_id);
for (auto& c : cover_clusters) {
if(c.reads.empty()){
clusters[c.id].reads.clear();
}
}
return selected_clusters;
}
void svict_caller::probalistic_filter(){
double pkall, pk, pk2;
double pgk, pgk2;
double contig_rate;
int num_filtered = 0;
for(int j = 0; j < all_contig_metrics.size(); j++){
contig_metrics& m = all_contig_metrics[j];
//Binomial
pk = (m.len-AVG_READ_LEN) > 0 ? m.num_reads/(m.len-AVG_READ_LEN) : 0;
pgk = 1-pow((1-pow((1-pk),m.max_dist)),(m.num_reads-1));
//Poisson
//pkall = (pow(rate_param*m.len, m.num_reads)*exp(-rate_param*m.len))/factorial(m.num_reads);
//pk2 = (rate_param*m.max_dist)*exp(-rate_param*m.max_dist);
//pgk2 = 1-pow((1-(1-pk2)),(m.num_reads-1));
//feclearexcept(FE_ALL_EXCEPT);
//errno = 0;
//pk2 = exp(-rate_param*m.max_dist);
//contig_rate = (m.len-150) > 0 ? m.num_reads/(m.len-150) : 0;
//pk2 = exp(-contig_rate*m.max_dist);
//if(errno == ERANGE)pk2 = 0;
//pgk2 = 1-pow((1-pk2),(m.num_reads-1));
if(pgk < 0.001 && m.num_reads <= 10){
if(PRINT_READS){
all_contigs[j].data.clear();
num_filtered++;
}
else{
all_compressed_contigs[j].data.clear();
num_filtered++;
}
}
}
if(PRINT_STATS){
cerr << "Filtered " << num_filtered << " contigs." << endl;
}
}
//======================================================
// Contig Indexing Stage
//======================================================
void svict_caller::index()
{
int contig_id = 0;
int max_hits = 0;
int i, j, x;
unsigned long long index = 0;
vector<int> contig_list;
contig_kmers.push_back(contig_list);
//Assemble contigs and build kmer index
//=====================================
cerr << "Indexing contigs..." << endl;
contig_kmers_index = new int[num_kmer]; //Dangerous thing to do, think of different solution
for(int i = 0; i < num_kmer; i++){
contig_kmers_index[i] = 0;
}
//TODO: Contig merging
for (contig_id = 0; contig_id < max(all_contigs.size(), all_compressed_contigs.size()); contig_id++){
string con = PRINT_READS ? all_contigs[contig_id].data : con_string(contig_id, 0, all_compressed_contigs[contig_id].data.size()/2);
tsl::sparse_map<int, vector<int>> kmer_location;
kmer_location.reserve(con.size());
kmer_locations.push_back(kmer_location);
i = 0, j = 0, x = 0;
// Per chromosome repeat flag for each contig
for(int rc=0; rc < 2; rc++){
for(int chr=0; chr < chromos.size(); chr++){
last_intervals[rc][chr].push_back((last_interval){ 0, static_cast<unsigned int>(k), 0});
}
}
if(con.empty())continue;
// k-1 kmer for first round
for(j = 0; j < k-1; j++){
if(j > 0 && con[i+j] == 'N'){
i += (j+1);
j = -1;
index = 0;
continue;
}
index <<= 2;
index |= ((con[i+j] & MASK) >> 1);
}
// Skip N nucleotides
for (i; i < con.length()-k+1; i++){
if(con[i+k-1] == 'N'){
i+=k;
while(con[i] == 'N'){
i++;
}
index = 0;
for(x = 0; x < k-1; x++){
if(con[i+x] == 'N'){
i += (x+1);
x = -1;
index = 0;
continue;
}
index <<= 2;
index |= ((con[i+x] & MASK) >> 1);
}
i--;
continue;
}
// Compute next kmer via bit shift
index <<= 2;
index |= ((con[i+k-1] & MASK) >> 1);
index &= kmer_mask;
//if(i % (k+2) != 0)continue;
int& cur_index = contig_kmers_index[index];
// Add to index
if(!cur_index){
contig_kmers_index[index] = contig_kmers.size();
vector<int> contig_list;
contig_list.reserve(1);
contig_list.push_back(contig_id);
contig_kmers.push_back(contig_list);
}
else{
if(contig_kmers[cur_index].back() != contig_id){
contig_kmers[cur_index].push_back(contig_id);
}
}
kmer_locations[contig_id][cur_index].push_back(i);
}
}
// Initialize mappings vector based on number of contigs
for(int rc=0; rc <= 1; rc++){
for(int chr=0; chr < chromos.size(); chr++){
contig_mappings[rc][chr] = vector<vector<mapping>>(contig_id, vector<mapping>(1, {0, k, -1}));
}
}
//STATS
if(PRINT_STATS){
cerr << "Number of unique kmers: " << contig_kmers.size() << endl;
cerr << "Max hits: " << max_hits << endl;
}
}
//======================================================
// Interval Mapping Stage
//======================================================
void svict_caller::generate_intervals_from_file(const string &input_file, const string &fastq_file, const bool LOCAL_MODE){
string line;
ifstream myfile(fastq_file);
if (myfile.is_open()) {
while ( getline (myfile, line) ) {
if(line[0] == '@'){
char* cline = (char*)line.c_str();
strtok(cline, "_");
int con_id = stoi(strtok(NULL, "_"));
int support = stoi(strtok(NULL, "_"));
int loc = stoi(strtok(NULL, "_"));
char chr = stoi(strtok(NULL, "_"));
getline(myfile, line);
compressed_contig contig;
vector<bool> data;
vector<unsigned short> coverage(line.length());
data.reserve(line.length()*2);
for(char& n : line){
switch (n) {
case 'A': data.push_back(0);
data.push_back(0);
break;
case 'T': data.push_back(1);
data.push_back(0);
break;
case 'C': data.push_back(0);
data.push_back(1);
break;
default: data.push_back(1); //Ns turn to G because I don't care!
data.push_back(1);
}
}
for(int i = 0; i < line.length(); i++){
coverage[i] = support;
}
contig.data = data;
contig.coverage = coverage;
all_compressed_contigs.push_back(contig);
cluster_info.push_back({loc, 0, chr}); //TODO coverage support
vector<bool> Ns = vector<bool>(line.length(),false);
//store N positions
for (int i = 0; i < line.length(); i++){
if(line[i] == 'N')Ns[i] = true;
}
all_contig_Ns.push_back(Ns);
}
else{
continue;
}
}
myfile.close();
}
for(int rc=0; rc <= 1; rc++){
for(int chr=0; chr < chromos.size(); chr++){
contig_mappings[rc][chr] = vector<vector<mapping>>(all_compressed_contigs.size(), vector<mapping>());
}
}
Parser* parser;
FILE *fi = fopen(input_file.c_str(), "rb");
char magic[2];
fread(magic, 1, 2, fi);
fclose(fi);
int ftype = 1; // 0 for BAM and 1 for SAM
if (magic[0] == char(0x1f) && magic[1] == char(0x8b))
ftype = 0;
if ( !ftype )
parser = new BAMParser(input_file);
else
parser = new SAMParser(input_file);
string comment = parser->readComment();
while(parser->hasNext()){
const Record &rec = parser->next();
mapping interval;
interval.loc = rec.getLocation();
interval.error = 0; //TODO
string cigar = string(rec.getCigar());
string optional = string(rec.getOptional());
string supple = "";
char chromo = (find(chromos.begin(), chromos.end(), string(rec.getChromosome())) - chromos.begin());
char* con_name = strdup(rec.getReadName());
strtok(con_name, "_");
uint32_t flag = rec.getMappingFlag();
int con_id = stoi(strtok(NULL, "_"));
int len = 0;
int con_loc = 0;
int con_len = all_compressed_contigs[con_id].data.size()/2;
bool neg = ( 0x10 == (flag&0x10));
for(char c : cigar){
if(isdigit(c)){
len *= 10;
len += int(c - '0');
}
else{
if(c == 'S' || c == 'H' || c == 'I'){
con_loc += len;
}
else if(c == 'M'){
interval.len = len;
interval.con_loc = neg ? con_len-con_loc-k : con_loc+len-k;
if(len >= k)contig_mappings[neg][chromo][con_id].push_back(interval);
con_loc += len;
interval.loc += len;
}
else{
interval.loc += len;
}
len = 0;
}
}
free(con_name);
parser->readNext();
}
delete parser;
}
void svict_caller::generate_intervals(const string &out_vcf, const bool LOCAL_MODE)
{
//Read reference and map contig kmers
//=====================================
cerr << "Generating intervals..." << endl;
char chromo = -1;
char last_chromo = chromo;
int use_rc = 2; //1 no, 2 yes
int jj = 0;
int id = 1; //zero reserved for sink
unsigned long long index = 0;
unsigned long long rc_index = 0;
unsigned long long cur_index = 0;
unsigned long long cur_index2 = 0;
unsigned long long index_mask = 0;
long iend;
int shift = 2*(k-1)-1;
int i, ii, ii1, ik, iik, iik1, j, js, je, x, y, z, rc, len, ilen, k1 = k+1, km1 = k-1;
int MAX_CONTIG_LEN = 0;
int MAX_INTERVAL_LEN = 20000;
int max_interval_len_k1;
int num_contigs = PRINT_READS ? all_contigs.size() : all_compressed_contigs.size();
int gen_start, gen_end, interval_len, contig_len, contig_lenk1, error;
bool con_repeat;
vector<pair<int,int>> starts;
string gen;
FILE *fo_vcf = fopen(out_vcf.c_str(), "wb");
//fprintf(fo_vcf, "##fileformat=VCFv4.2\n##source=SVICT-v1.0\n");
fprintf(fo_vcf, "##fileformat=VCFv4.2\n##source=SVICT-v%s\n", versionNumber);
//STATS
int anchor_intervals = 0;
int non_anchor_intervals = 0;
int pop_back1 = 0;
int pop_back2 = 0;
int pop_back3 = 0;
int pop_back4 = 0;
int max_ints = 0;
int max_int_len = 0;
int max_con_len = 0;
int max_starts = 0;
int max_sub = 0;
int index_misses = 0;
long kmer_hits = 0;
long kmer_hits_con = 0;
double interval_count = 0;
int corrected_bp = 0;
// Initialization
if(PRINT_READS){
for(auto& contig : all_contigs){
if(contig.data.length() > MAX_CONTIG_LEN) MAX_CONTIG_LEN = contig.data.length();
}
}
else{
for(auto& contig : all_compressed_contigs){
if(contig.data.size()/2 > MAX_CONTIG_LEN) MAX_CONTIG_LEN = contig.data.size()/2;
}
}
MAX_CONTIG_LEN += k1; //Rare case of SNP near the end of the longest contig.
MAX_INTERVAL_LEN = MAX_CONTIG_LEN+100;
max_interval_len_k1 = MAX_INTERVAL_LEN-k-1;
bool** valid_mappings = new bool*[MAX_INTERVAL_LEN]; //think of a better solution
for(int i=0; i < MAX_INTERVAL_LEN; i++){
valid_mappings[i] = new bool[MAX_CONTIG_LEN];
}
for(int i=0; i < MAX_INTERVAL_LEN; i++){
for(int j=0; j < MAX_CONTIG_LEN; j++){
valid_mappings[i][j] = false;
}
}
// Traverse each chromosome or region (Local mode)
for (auto ®ion: regions){
chromo = (find(chromos.begin(), chromos.end(), ref.get_ref_name()) - chromos.begin());
gen = ref.extract(chromos[chromo], region.second.first, region.second.second); //get region sequence
gen_start = max(0,region.second.first-1);
gen_end = gen.length()-k+1;
fprintf(fo_vcf, "##contig=<ID=%s,length=%d>\n", chromos[chromo].c_str(), gen.length());
js = LOCAL_MODE ? jj : 0;
je = LOCAL_MODE ? (jj+1) : num_contigs;
// Skip leading Ns
i = 0;
while(gen[i] == 'N'){
i++;
}
index = 0;
rc_index = 0;
// k-1 kmer for first round
for(x = 0; x < km1; x++){
if(x > 0 && gen[i+x] == 'N'){
i += (x+1);
x = -1;
index = 0;
rc_index = 0;
continue;
}
index <<= 2;
index |= ((gen[i+x] & MASK) >> 1);
rc_index <<= 2;
rc_index |= (((gen[(i+km1)-x] & MASK) ^ MASK_RC) >> 1);
}
// Skip N nucleotides
for (i; i < gen_end; i++){ //-ANCHOR_SIZE
if(gen[i+km1] == 'N'){
i+=k;
while(gen[i] == 'N'){
i++;
}
index = 0;
rc_index = 0;
for(x = 0; x < km1; x++){
if(gen[i+x] == 'N'){
i += (x+1);
x = -1;
index = 0;
rc_index = 0;
continue;
}
index <<= 2;
index |= ((gen[i+x] & MASK) >> 1);
rc_index <<= 2;
rc_index |= (((gen[(i+km1)-x] & MASK) ^ MASK_RC) >> 1);
}
i--;
continue;
}
// Precompute some arithmetic
// index_mask = 2nd and 3rd bit of char, which is a unique value for each nucleotide
ii = i + gen_start;// + 1;
ii1 = ii-1;
iik1 = ii1+k;
index_mask = (gen[i+km1] & MASK);
// Forward and reverse strand
for(rc=0; rc < use_rc; rc++){
// Convert kmer string to index
// Bit shift (reuse last kmer) -> shift mask to 1st and 2nd bit -> mask bits for char of last kmer
// Slightly modified for reverse compliment to flip bits
if(rc){
rc_index = ((rc_index >> 2) | ((index_mask ^ MASK_RC) << shift));
if(!contig_kmers_index[rc_index])continue;
cur_index = rc_index;
}
else{
index = (((index << 2) | (index_mask >> 1)) & kmer_mask);
if(!contig_kmers_index[index])continue;
cur_index = index;
}
//kmer_hits++;
//contig_kmer_counts[contig_kmers_index[cur_index]]++; //178956970
for(const int& j : contig_kmers[contig_kmers_index[cur_index]]){
// Local mode temporarily disabled
//if( (!LOCAL_MODE || j == jj)){
//kmer_hits_con++;
last_interval& l_interval = last_intervals[rc][chromo][j];
iend = l_interval.loc + l_interval.len;
// Else end last interval and start new one
if(iend < ii1){
// Get last interval for this contig
vector<mapping>& intervals = contig_mappings[rc][chromo][j];
// Check if sufficiently long
if(l_interval.len >= ANCHOR_SIZE && l_interval.len < max_interval_len_k1){
mapping& cur_interval = intervals.back();
cur_interval.loc = l_interval.loc;
cur_interval.len = l_interval.len;
intervals.push_back((mapping){ii, k, -1, 0});
}
l_interval.loc = ii;
l_interval.len = k;
}
// Extend interval by one
else if(iend == iik1){
l_interval.len++;
}
// Extend interval by k+1 if a SNP/SNV is detected
else if(iend == ii1){
l_interval.len += k1;
}
// if(LOCAL_MODE)break;
//}
}
}
}// gen, slowest loop
//Remove intervals without consectutive kmers in contigs
//======================================================
for(rc=0; rc < use_rc; rc++){
for(j = js; j < je; j++){
contig_len = PRINT_READS ? all_contigs[j].data.length() : all_compressed_contigs[j].data.size()/2;
last_interval& l_interval = last_intervals[rc][chromo][j];
mapping& back_interval = contig_mappings[rc][chromo][j].back();
if(l_interval.loc == back_interval.loc){
contig_mappings[rc][chromo][j].pop_back();
if(contig_mappings[rc][chromo][j].empty())continue;
}
else{
if(l_interval.len >= ANCHOR_SIZE && l_interval.len < max_interval_len_k1){
back_interval.loc = l_interval.loc;
back_interval.len = l_interval.len;
}
}
if(contig_len == 0)continue;
cluster_metrics& bp = cluster_info[j];
vector<bool>& Ns = all_contig_Ns[j];
vector<mapping> valid_intervals;
contig_lenk1 = contig_len+k1;
if(contig_mappings[rc][chromo][j].size() > max_ints)max_ints = contig_mappings[rc][chromo][j].size();
if(contig_len > max_con_len)max_con_len = contig_len;
for(auto &interval: contig_mappings[rc][chromo][j]){
if(interval.len > contig_lenk1)continue;
//STATS
if(PRINT_STATS){
int& contig_loc = bp.sc_loc;
char& contig_chr = bp.chr;
if(chromo == contig_chr && abs(interval.loc - contig_loc) < MAX_ASSEMBLY_RANGE){
anchor_intervals++;
}
else{
non_anchor_intervals++;
}
}
if(interval.len > max_int_len)max_int_len = interval.len;
int sub_count = 0;
// intialization
starts.clear();
ii = interval.loc - gen_start;// + 1;
len = interval.len-km1;
interval_len = interval.len+k1; //maybe off by one
con_repeat = false;
cur_index = 0;
if(rc){
// k-1 kmer for first round
for(x = 0; x < km1; x++){
cur_index <<= 2;
cur_index |= (((gen[(ii+interval.len-1)-x] & MASK) ^ MASK_RC) >> 1);
}
}
else{
// k-1 kmer for first round
for(x = 0; x < km1; x++){
cur_index <<= 2;
cur_index |= ((gen[ii+x] & MASK) >> 1);
}
}
// Traverse the interval
for (i = 0; i < len; i++){
if(rc){
cur_index = (((cur_index << 2) | (((gen[ii+(interval.len-1-i)-km1] & MASK) ^ MASK_RC) >> 1)) & kmer_mask);
}
else{
cur_index = (((cur_index << 2) | ((gen[ii+i+km1] & MASK) >> 1)) & kmer_mask);
}
int& kmer_index = contig_kmers_index[cur_index];
if(kmer_index && binary_search(contig_kmers[kmer_index].begin(), contig_kmers[kmer_index].end(), j)){
for(auto &loc: kmer_locations[j][kmer_index]){
if(!Ns[loc]){
valid_mappings[i][loc] = true;
// Record starts when interval no longer consecutive
if(i == 0 || loc == 0){
starts.push_back({i,loc});
}
else if((i < k1 || loc < k1) && !valid_mappings[i-1][loc-1]){
starts.push_back({i,loc});
}
else if(!valid_mappings[i-1][loc-1] && !valid_mappings[i-k1][loc-k-1]){
starts.push_back({i,loc});
}
}
}
}
if(starts.size() > CON_REPEAT_LIMIT){
con_repeat = true;
break;
}
}
if(starts.size() > max_starts)max_starts = starts.size();
// Check each start point
for(auto& start : starts){
x = start.first;
y = start.second;
error = 0;
// Traverse diagonal
while(x < interval.len && y < contig_len && valid_mappings[x][y]){
valid_mappings[x++][y++] = false;
if(y+k < contig_len){
if(!valid_mappings[x][y]){
if(valid_mappings[x+k][y+k]){
error++;
x +=k;
y +=k;
}
}
}
}
x--;
y--;
ilen = (y - start.second)+k;
//TODO: Use this table to identify duplications, although maybe no point since all can be found without this
if(ilen > ANCHOR_SIZE && !con_repeat){
//Add to final list of intervals
mapping sub_interval;
sub_interval.loc = interval.loc + start.first;
sub_interval.len = ilen;
sub_interval.con_loc = y;
sub_interval.error = error;
valid_intervals.push_back(sub_interval);
sub_count++;
if(sub_count > max_sub)max_sub = sub_count;
}
}
}//intervals
vector<mapping>& cur_intervals = contig_mappings[rc][chromo][j];
if(!valid_intervals.empty() && valid_intervals.size() > 10){
cur_intervals.clear();
vector<int> mapped = vector<int>(contig_len, 0);
int map_count = 0;
sort(valid_intervals.begin(), valid_intervals.end());
for(auto& interval : valid_intervals){
for(x = ((interval.con_loc+k)-interval.len); x < (interval.con_loc+k); x++){
if(mapped[x] < REPEAT_LIMIT){
for(y = ((interval.con_loc+k)-interval.len); y < (interval.con_loc+k); y++){
mapped[y]++;
if(mapped[y] == REPEAT_LIMIT)map_count++;
}
cur_intervals.push_back(interval);
break;
}
}
if(map_count == contig_len)break;
}
vector<mapping>().swap(valid_intervals);
}
else{
cur_intervals = move(valid_intervals);
}
//SNP near BP error correction.
if(!cur_intervals.empty() && cur_intervals.size() <= 20){ // Arbitrary for now
corrected_bp++;
sort(cur_intervals.begin(), cur_intervals.end(), con_interval_compare());
for(i = 0; i < cur_intervals.size(); i++){
mapping& bp_map = cur_intervals[i];
if(i > 0 && abs(bp_map.loc - bp.sc_loc) < 3){
for(x = i-1; x >= 0; x--){
mapping& prior_map = cur_intervals[x];
int e_con_loc = (prior_map.con_loc+k);
int bp_con_loc = ((bp_map.con_loc+k)-bp_map.len);
int missed_len = (bp_con_loc-e_con_loc)-1;
if(bp_con_loc > e_con_loc+1 && (bp_con_loc-e_con_loc) <= k){
string contig_seq = PRINT_READS ? all_contigs[j].data : con_string(j, 0, all_compressed_contigs[j].data.size()/2);
string missed_con_seq_left = contig_seq.substr(e_con_loc+1, missed_len);
string missed_con_seq_right = contig_seq.substr(e_con_loc, missed_len);
string missed_ref_seq_left = gen.substr(prior_map.loc+prior_map.len+1,missed_len);
string missed_ref_seq_right = gen.substr(bp_map.loc-missed_len,missed_len);
if(missed_ref_seq_left == missed_con_seq_left){
prior_map.con_loc += missed_len+1;
prior_map.len += missed_len+1;
}
else if(missed_ref_seq_right == missed_con_seq_right){
bp_map.loc -= missed_len+1;
bp_map.len += missed_len+1;
}
break;
}
}
break;
}
else if(i < cur_intervals.size()-1 && abs((bp_map.loc+bp_map.len) - bp.sc_loc) < 3){
for(x = i+1; x < cur_intervals.size(); x++){
mapping& post_map = cur_intervals[x];
int bp_con_loc = (bp_map.con_loc+k);
int s_con_loc = ((post_map.con_loc+k)-post_map.len);
int missed_len = (s_con_loc-bp_con_loc)-1;
if(s_con_loc > bp_con_loc+1 && (s_con_loc-bp_con_loc) <= k){
string contig_seq = PRINT_READS ? all_contigs[j].data : con_string(j, 0, all_compressed_contigs[j].data.size()/2);
string missed_con_seq_left = contig_seq.substr(bp_con_loc+1, missed_len);
string missed_con_seq_right = contig_seq.substr(bp_con_loc, missed_len);
string missed_ref_seq_left = gen.substr(bp_map.loc+bp_map.len+1, missed_len);
string missed_ref_seq_right = gen.substr(post_map.loc-missed_len, missed_len);
if(missed_ref_seq_left == missed_con_seq_left){
bp_map.con_loc += missed_len+1;
bp_map.len += missed_len+1;
}
else if(missed_ref_seq_right == missed_con_seq_right){
post_map.loc -= missed_len+1;
post_map.len += missed_len+1;
}
break;
}
}
break;
}
}
}
//STATS
interval_count += cur_intervals.size();
num_intervals += cur_intervals.size();
}//j
}//rc
jj++;
cerr << "chr" << ref.get_ref_name() << " done" << endl;
if(region.first != regions[regions.size()-1].first)ref.load_next();
}//regions
//STATS
if(PRINT_STATS){
cerr << "Intervals: " << num_intervals << endl;
cerr << "Anchor Intervals: " << anchor_intervals << endl;
cerr << "Non-Anchor Intervals: " << non_anchor_intervals << endl;
cerr << "Average Intervals per Contig: " << (interval_count/(double)num_contigs) << endl;
cerr << "Pop backs Short: " << pop_back1 << endl;
cerr << "Pop backs Repeat1: " << pop_back2 << endl;
cerr << "Pop backs Repeat2: " << pop_back3 << endl;
cerr << "Pop backs Last: " << pop_back4 << endl;
cerr << "Max Intervals: " << max_ints << endl;
cerr << "Max Interval Len: " << max_int_len << endl;
cerr << "Max Contig Len: " << max_con_len<< endl;
cerr << "Max Starts: " << max_starts << endl;
cerr << "Max Subintervals: " << max_sub << endl;
cerr << "Index Misses: " << index_misses << endl;
//cerr << "Kmer Hits: " << kmer_hits << endl;
//cerr << "Kmer Hits Total: " << kmer_hits_con << endl;
cerr << "Corrected BP: " << corrected_bp << endl;
}
for(int i=0; i < MAX_INTERVAL_LEN; i++){
delete[] valid_mappings[i];
}
delete[] valid_mappings;
fclose(fo_vcf);
}
//======================================================
// Predict Structural Variants Stage
//======================================================
void svict_caller::predict_variants(const string &out_vcf, int uncertainty, int min_length, int max_length, int sub_optimal)
{
//Predict structural variants
//=====================================
cerr << "Predicting short structural variants..." << endl;
//STATS
int normal_edges = 0, ins_edges = 0, source_edges = 0, sink_edges = 0, singletons = 0;
int path_count = 0, cons_with_paths = 0;
int intc1 = 0, intc2 = 0, intc3 = 0, intc4 = 0, intc5 = 0, intc6 = 0;
int anchor_fails = 0, ugly_fails = 0;
int short_dup1 = 0, short_dup2 = 0, short_dup3 = 0, short_del = 0, short_inv1 = 0, short_inv2 = 0, short_ins1 = 0, short_ins2 = 0, short_trans = 0, mystery1 = 0, mystery2 = 0, mystery3 = 0;
int long_del = 0, long_inv1 = 0, long_inv2 = 0, long_inv3 = 0, long_ins = 0, long_trans = 0, long_dup = 0;
int one_bp_del = 0, one_bp_dup = 0, one_bp_inv = 0, one_bp_ins = 0, one_bp_trans = 0;
if(PRINT_STATS)num_intervals = 0;
int interval_count = 0;
int one_bp_id = 0;
int pair_id = 0;
int num_contigs = PRINT_READS ? all_contigs.size() : all_compressed_contigs.size();
int rc = 0;
int use_rc = 1;
int contig_loc, contig_len, contig_sup, loc, id, ref_dist, con_dist;
unsigned long long index = 0;
bool found = false;
char contig_chr;
string contig_seq;
mapping_ext cur_interval;
mapping_ext source = {-1, 0, 0, -1, 0, 0, 0};
mapping_ext sink = {-1, 0, 0, -1, 0, 0, 0};
min_length = max(min_length, uncertainty+1);
vector<sortable_mapping>* sorted_intervals = new vector<sortable_mapping>[ chromos.size() ]; // Sorted list for traversal
unordered_map<int, vector<int>> interval_pair_ids; // Mapping from interval -> interval_pairs
vector<interval_pair> interval_pairs; // Pairs of intervals
FILE *fo_vcf = fopen(out_vcf.c_str(), "ab");
fprintf(fo_vcf, "##INFO=<ID=SVTYPE,Number=1,Type=String,Description=\"Type of structural variant\">\n");
fprintf(fo_vcf, "##INFO=<ID=END,Number=1,Type=Integer,Description=\"End position of the variant described in this record\">\n");
if(PRINT_READS){
fprintf(fo_vcf, "##INFO=<ID=CLUSTER,Number=.,Type=Integer,Description=\"Cluster IDs supporting this SV\">\n");
fprintf(fo_vcf, "##INFO=<ID=CONTIG,Number=.,Type=Integer,Description=\"Contigs IDs supporting this SV\">\n");
}
else{
fprintf(fo_vcf, "##INFO=<ID=CLUSTER,Number=1,Type=Integer,Description=\"Number of clusters supporting this SV\">\n");
fprintf(fo_vcf, "##INFO=<ID=CONTIG,Number=1,Type=Integer,Description=\"Number of contigs supporting this SV\">\n");
}
fprintf(fo_vcf, "##INFO=<ID=SUPPORT,Number=1,Type=Integer,Description=\"Maximum basepair read support at or nearby the breakpoint\">\n");
if(USE_ANNO){
fprintf(fo_vcf, "##INFO=<ID=ANNOL,Number=4,Type=String,Description=\"Annotation information for region left of the BP: genomic context, gene ID, transcript ID, gene name\">\n");
fprintf(fo_vcf, "##INFO=<ID=ANNOC,Number=4,Type=String,Description=\"Annotation information for inserted region (if applicable): genomic context, gene ID, transcript ID, gene name\">\n");
fprintf(fo_vcf, "##INFO=<ID=ANNOR,Number=4,Type=String,Description=\"Annotation information for region right of the BP: genomic context, gene ID, transcript ID, gene name\">\n");
}
fprintf(fo_vcf, "##INFO=<ID=MATEID,Number=.,Type=String,Description=\"ID of mate breakends\">\n");
fprintf(fo_vcf, "##FILTER=<ID=TWO_BP,Description=\"Support for both breakpoints\">\n");
fprintf(fo_vcf, "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n");
// Traverse each contig
for(int j = 0; j < num_contigs; j++){
contig_loc = cluster_info[j].sc_loc;
contig_chr = cluster_info[j].chr;
contig_seq = PRINT_READS ? all_contigs[j].data : con_string(j, 0, all_compressed_contigs[j].data.size()/2);
contig_len = PRINT_READS ? all_contigs[j].data.length() : all_compressed_contigs[j].data.size()/2;
if(contig_len == 0)continue;
vector<vector<mapping_ext>> intervals(contig_len+1, vector<mapping_ext>());
unordered_map<int, pair<int,int>> lookup;
vector<mapping_ext> grouped_intervals;
vector<int> mapped = vector<int>(contig_len, 0);
vector<bool>& Ns = all_contig_Ns[j];
bool visited[contig_len];
memset(visited, 0, sizeof(visited));
id = 1;
interval_count = 1;
// Handle repeats, sort by length and select any interval included an unmapped contig base.
for(char chr=0; chr < chromos.size(); chr++){
for(rc=0; rc <= use_rc; rc++){
if(!contig_mappings[rc][chr][j].empty()){
for(auto &interval: contig_mappings[rc][chr][j]){
grouped_intervals.push_back(copy_interval(chr, rc, j, interval));
}
contig_mappings[rc][chr][j].clear();
}
}
}
sort(grouped_intervals.begin(), grouped_intervals.end());
for(auto& interval : grouped_intervals){
for(int x = ((interval.con_loc+k)-interval.len); x < (interval.con_loc+k); x++){
if(mapped[x] < REPEAT_LIMIT){
for(int y = ((interval.con_loc+k)-interval.len); y < (interval.con_loc+k); y++){
mapped[y]++;
}
loc = (interval.con_loc+k-interval.len);
//Ns at breakpoint correction
while(loc-1 >= 0 && Ns[loc-1]){
loc--;
}
if(loc < 0){
print_interval("ERROR Invalid Interval:", interval);
continue;
}
intervals[loc].push_back(interval);
id++;
if(j == CON_NUM_DEBUG)print_interval("Included", interval);
break;
}
}
}
intervals[contig_len].push_back(source);
intervals[contig_len].push_back(sink);
lookup[0] = {contig_len,0};
lookup[id] = {contig_len,id};
for(int i = 0; i < contig_len; i++){
for(int x = 0; x < intervals[i].size(); x++){
intervals[i][x].id = interval_count++;
lookup[intervals[i][x].id] = {i,x};
}
}
interval_count++;
num_intervals += interval_count;
// Initialization
int** contig_graph = new int*[interval_count]; //think of a better solution
for(int i=0; i < interval_count; i++){
contig_graph[i] = new int[interval_count];
}
for(int i=0; i < interval_count; i++){
for(int j=0; j < interval_count; j++){
contig_graph[i][j] = 0;
}
}
BUILD_DIST = ANCHOR_SIZE;
//Build Edges
//==================================
for(int i = 0; i < contig_len; i++){
if(!intervals[i].empty()){
for(auto &interval1: intervals[i]){
found = false;
//Build edge for balanced SVs and deletions
for(int u = max(0, i+interval1.len-BUILD_DIST); u <= min(contig_len-1, i+interval1.len+BUILD_DIST); u++){ //was k
if(!intervals[u].empty()){
for(auto &interval2: intervals[u]){
if(!interval1.rc && !interval2.rc){
ref_dist = interval2.loc-(interval1.loc+interval1.len);
}
else if(interval1.rc && !interval2.rc){
ref_dist = (interval2.loc-interval1.loc);
}
else if(!interval1.rc && interval2.rc){
ref_dist = (interval2.loc+interval2.len-(interval1.loc-interval1.len));
}
else{
ref_dist = ((interval2.loc-interval2.len)-interval1.loc);
}
con_dist = (interval2.con_loc+k-interval2.len)-(interval1.con_loc+k);
if(abs(abs(ref_dist)-abs(con_dist)) <= uncertainty || ref_dist <= uncertainty || con_dist <= BUILD_DIST){//uncertainty){ //Temporary until performance issues are resolved
visited[u] = true;
found = true;
contig_graph[interval1.id][interval2.id] = -(interval2.len-interval2.error);
normal_edges++;
}
}
}
}
//to sink
if(!found && ( ((interval1.con_loc+k-interval1.len) <= BUILD_DIST) || ((contig_len - (interval1.con_loc+k)) <= BUILD_DIST) || interval1.id == (id-1)) ){
contig_graph[interval1.id][id] = -(interval1.len-interval1.error);
sink_edges++;
}
//from source
if(!visited[i] && ( ((interval1.con_loc+k-interval1.len) <= BUILD_DIST) || ((contig_len - (interval1.con_loc+k)) <= BUILD_DIST) || interval1.id == 1) ){
contig_graph[0][interval1.id] = -(interval1.len-interval1.error);
source_edges++;
}
}
}
}
cur_debug_id = j;
// Run Ford Fulkerson for max flow
//====================================
//vector<vector<int>> paths2 = fordFulkerson(id+1, contig_graph, 0, id);
vector<pair<vector<int>, int>> paths = dijkstra(id+1, contig_graph, 0, id, PATH_LIMIT);
// Predict short variants
//====================================
if(!paths.empty()){
cons_with_paths++;
int max_paths = PATH_LIMIT;
int short_dist = paths[0].second;
// Check each path and classify variant
for(int p = 0; p < min(max_paths, (int)paths.size()); p++){ //top x paths
vector<int>& path = paths[p].first;
if(j == CON_NUM_DEBUG){
cerr << "All examined paths:" << endl;
for(int i = path.size()-2; i > 0; i--){
cerr << intervals[lookup[path[i]].first][lookup[path[i]].second].loc << "-" << intervals[lookup[path[i]].first][lookup[path[i]].second].loc + intervals[lookup[path[i]].first][lookup[path[i]].second].len << "\t";
}
cerr << endl;
for(int i = path.size()-2; i > 0; i--){
cerr << intervals[lookup[path[i]].first][lookup[path[i]].second].con_loc+k - intervals[lookup[path[i]].first][lookup[path[i]].second].len << "-" << intervals[lookup[path[i]].first][lookup[path[i]].second].con_loc+k << "\t";
}
cerr << "\n========================================================" << endl;
}
mapping_ext cur_i, i1, i2, i3, i4;
int chromo_dist, contig_dist;
int a1 = -1;
int a2 = -1;
bool is_anchor;
bool anchor_found = false;
for(int i = path.size()-2; i > 0; i--){
// Check if anchor (located near partition range)
cur_i = intervals[lookup[path[i]].first][lookup[path[i]].second];
is_anchor = ((cur_i.chr == contig_chr) && (abs(cur_i.loc+(cur_i.len/2) - contig_loc) < (MAX_ASSEMBLY_RANGE*2)));
found = false;
if(is_anchor)anchor_found = true;
//Note: For a small variant to be called it requires two anchors flanking the variant
// Otherwise "interval pairs" are created and passed on to long structural variant detection.
// If first anchor not set
if(a1 == -1){
if(is_anchor){
a1 = i;
//leading non-anchor region
if(a1 != path.size()-2){
i1 = intervals[lookup[path[a1+1]].first][lookup[path[a1+1]].second];
i2 = intervals[lookup[path[a1]].first][lookup[path[a1]].second];
chromo_dist = (i1.rc && i2.rc) ? i1.loc-(i2.loc+i2.len) : i2.loc-(i1.loc+i1.len);
contig_dist = (i2.con_loc-i2.len)-i1.con_loc;
if(abs(chromo_dist) <= uncertainty || abs(contig_dist) <= uncertainty){
intc1++;
i1.id = all_intervals.size();
all_intervals.push_back(i1);
i2.id = all_intervals.size();
all_intervals.push_back(i2);
sorted_intervals[i1.chr].push_back({i1.id,i1.loc});
sorted_intervals[i2.chr].push_back({i2.id,i2.loc});
interval_pairs.push_back({false,i1.id,i2.id});
interval_pair_ids[i1.id].push_back(pair_id);
interval_pair_ids[i2.id].push_back(pair_id++);
}
}
else{
i1 = intervals[lookup[path[a1]].first][lookup[path[a1]].second];
if(i1.con_loc+k-i1.len > ((int)contig_len - (i1.con_loc+k)) || a1 != 1){
//Insertion, Left Side
if(i1.con_loc+k-i1.len > ANCHOR_SIZE && !i1.rc){
intc2++;
i1.id = all_intervals.size();
all_intervals.push_back(i1);
sorted_intervals[i1.chr].push_back({i1.id,i1.loc});
interval_pairs.push_back({false,-1,i1.id});
interval_pair_ids[i1.id].push_back(pair_id++);
}
}
else{
//Insertion, Right Side, singleton case
if(((int)contig_len - (i1.con_loc+k)) > ANCHOR_SIZE && !i1.rc){
intc3++;
i1.id = all_intervals.size();
all_intervals.push_back(i1);
sorted_intervals[i1.chr].push_back({i1.id,i1.loc});
interval_pairs.push_back({false,i1.id,-1});
interval_pair_ids[i1.id].push_back(pair_id++);
}
}
}
}
else{
anchor_fails++;
}
}
// If second anchor not set
else if(a2 == -1){
// Interval is anchor with the same orientation as the other anchor
if((is_anchor) && cur_i.rc == intervals[lookup[path[a1]].first][lookup[path[a1]].second].rc){// && !cur_i.rc){
a2 = i;
// No interval in between anchors
if(a1 - a2 == 1){
i1 = intervals[lookup[path[a1]].first][lookup[path[a1]].second];
i2 = intervals[lookup[path[a2]].first][lookup[path[a2]].second];
chromo_dist = i2.loc-(i1.loc+i1.len);
contig_dist = (i2.con_loc-i2.len)-i1.con_loc;
if(contig_dist > 0){
bool allNs = true;
for(int c = i1.con_loc+k+1; c < (i2.con_loc+k-i2.len); c++){
if(!Ns[c]){
allNs = false;
break;
}
}
if(allNs)contig_dist = 0;
}
//Negative Strand (Rare, only handle most common case: INV)
if(i1.rc && i2.rc){
chromo_dist = i1.loc-(i2.loc+i2.len);
if(abs(chromo_dist - contig_dist) <= uncertainty && min(abs(chromo_dist), abs(contig_dist)) > uncertainty){// max(min_length, uncertainty+1)){ This is stupid
add_result(j, i1, i2, INV, i2.chr, 0); // 1 TP
i1.id = all_intervals.size();
all_intervals.push_back(i1);
i2.id = all_intervals.size();
all_intervals.push_back(i2);
// results_full.push_back({{i2.id, -1, -1, i1.id}, INV});
short_inv1++;
}
}
//Positive Strand
else{
//DUP
if(i1.loc+i1.len-i2.loc >= min_length && i1.loc+i1.len-i2.loc <= max_length && abs(contig_dist) <= uncertainty){
add_result(j, i1, i2, DUP, i2.chr, 0);
i1.id = all_intervals.size();
all_intervals.push_back(i1);
i2.id = all_intervals.size();
all_intervals.push_back(i2);
// results_full.push_back({{i2.id, i1.id, -1, -1}, DUP});
// results_full.push_back({{ -1, -1, i2.id, i1.id}, DUP});
short_dup2++;
}
else{
//INS
if(abs(chromo_dist) <= uncertainty && contig_dist > uncertainty){
add_result(j, i1, i2, INS, i2.chr, 0);
i1.id = all_intervals.size();
all_intervals.push_back(i1);
i2.id = all_intervals.size();
all_intervals.push_back(i2);
// results_full.push_back({{i1.id, -1, -1, i2.id}, INS});
short_ins2++;
}//DEL
else if(chromo_dist > uncertainty && abs(contig_dist) <= uncertainty){
intc4++;
i1.id = all_intervals.size();
all_intervals.push_back(i1);
i2.id = all_intervals.size();
all_intervals.push_back(i2);
sorted_intervals[i1.chr].push_back({i1.id,i1.loc});
sorted_intervals[i2.chr].push_back({i2.id,i2.loc});
interval_pairs.push_back({false,i1.id,i2.id});
interval_pair_ids[i1.id].push_back(pair_id);
interval_pair_ids[i2.id].push_back(pair_id++);
}//INV
else if(abs(chromo_dist - contig_dist) <= uncertainty && min(abs(chromo_dist), abs(contig_dist)) >= max(min_length, uncertainty+1)){ // min_length){ This is stupid
add_result(j, i1, i2, INV, i2.chr, 0);
i1.id = all_intervals.size();
all_intervals.push_back(i1);
i2.id = all_intervals.size();
all_intervals.push_back(i2);
// results_full.push_back({{i1.id, -1, -1, i2.id}, INV});
short_inv1++;
}//??? Maybe SNPs/errors near breakpoint
else if(chromo_dist > uncertainty && contig_dist > uncertainty){
if(chromo_dist - abs(contig_dist) >= MIN_SV_LEN_DEFAULT){
add_result(j, i1, i2, DEL, i2.chr, 0); // This is stupid
i1.id = all_intervals.size();
all_intervals.push_back(i1);
i2.id = all_intervals.size();
all_intervals.push_back(i2);
// results_full.push_back({{i1.id, -1, -1, i2.id}, DEL});
}
}
else{
mystery2++;
}
}
}
}
// Interval(s) between anchors, specifically TRANS and INV
else{
// Inner non-anchor region
for(int u = a1; u > a2; u--){
i1 = intervals[lookup[path[u]].first][lookup[path[u]].second];
i2 = intervals[lookup[path[u-1]].first][lookup[path[u-1]].second];
chromo_dist = i2.loc-(i1.loc+i1.len);
contig_dist = (i2.con_loc-i2.len)-i1.con_loc;
if(i1.rc && i2.rc)chromo_dist = i1.loc-(i2.loc+i2.len);
if(abs(contig_dist) > uncertainty)break;
if((u != a1 && u-1 != a2) && (i1.chr != i2.chr || i1.rc != i2.rc || abs(chromo_dist) > uncertainty))break; //This is stupid (Inversions)
if(u-1 == a2)found = true;
}
if(found){
i1 = intervals[lookup[path[a1]].first][lookup[path[a1]].second];
i2 = intervals[lookup[path[a1-1]].first][lookup[path[a1-1]].second];
i3 = intervals[lookup[path[a2+1]].first][lookup[path[a2+1]].second];
i4 = intervals[lookup[path[a2]].first][lookup[path[a2]].second];
if(i2.rc != i1.rc && i3.rc != i4.rc){
// add_result(j, i1, i2, INV, i2.chr, 0);
short_inv2++;
}
else if(i1.chr != i2.chr && i3.chr != i4.chr){
//add_result(i1.con_id, i1, i2, TRANS, i3.chr, add_result(i4.con_id, i3, i4, TRANS, i4.chr, -1));
short_trans++;
}
}
}
a1 = a2;
a2 = -1;
}
// Interval is anchor with different orientation from the other anchor (one BP INV)
else if(is_anchor && cur_i.rc != intervals[lookup[path[a1]].first][lookup[path[a1]].second].rc){
a2 = i;
if(a1 - a2 == 1){
i1 = intervals[lookup[path[a1]].first][lookup[path[a1]].second];
i2 = intervals[lookup[path[a2]].first][lookup[path[a2]].second];
chromo_dist = (i1.rc && i2.rc) ? i1.loc-(i2.loc+i2.len) : i2.loc-(i1.loc+i1.len);
contig_dist = (i2.con_loc-i2.len)-i1.con_loc;
if(abs(chromo_dist) <= uncertainty || abs(contig_dist) <= uncertainty){
intc5++;
i1.id = all_intervals.size();
all_intervals.push_back(i1);
i2.id = all_intervals.size();
all_intervals.push_back(i2);
sorted_intervals[i1.chr].push_back({i1.id,i1.loc});
sorted_intervals[i2.chr].push_back({i2.id,i2.loc});
interval_pairs.push_back({false,i1.id,i2.id});
interval_pair_ids[i1.id].push_back(pair_id);
interval_pair_ids[i2.id].push_back(pair_id++);
}
}
a1 = a2;
a2 = -1;
}
// trailing non-anchor region
else if(i == 1){
i1 = intervals[lookup[path[a1]].first][lookup[path[a1]].second];
i2 = intervals[lookup[path[a1-1]].first][lookup[path[a1-1]].second];
chromo_dist = (i1.rc && i2.rc) ? i1.loc-(i2.loc+i2.len) : i2.loc-(i1.loc+i1.len);
contig_dist = (i2.con_loc-i2.len)-i1.con_loc;
if(abs(chromo_dist) <= uncertainty || abs(contig_dist) <= uncertainty){
intc5++;
i1.id = all_intervals.size();
all_intervals.push_back(i1);
i2.id = all_intervals.size();
all_intervals.push_back(i2);
sorted_intervals[i1.chr].push_back({i1.id,i1.loc});
sorted_intervals[i2.chr].push_back({i2.id,i2.loc});
interval_pairs.push_back({false,i1.id,i2.id});
interval_pair_ids[i1.id].push_back(pair_id);
interval_pair_ids[i2.id].push_back(pair_id++);
}
}
else{
if(!is_anchor)anchor_fails++;
}
// Insertion Right Side, after last anchor interval
if(a1 == 1 || a2 == 1){
i1 = (a2 == 1) ? intervals[lookup[path[a2]].first][lookup[path[a2]].second] : intervals[lookup[path[a1]].first][lookup[path[a1]].second];
if(((int)contig_len - (i1.con_loc+k)) > ANCHOR_SIZE && !i1.rc){
intc6++;
i1.id = all_intervals.size();
all_intervals.push_back(i1);
sorted_intervals[i1.chr].push_back({i1.id,i1.loc});
interval_pairs.push_back({false,i1.id,-1});
interval_pair_ids[i1.id].push_back(pair_id++);
}
}
}//anchor set
}//path
if(p+1 < paths.size() && paths[p+1].second - short_dist > sub_optimal)break;
if(!anchor_found){
max_paths++;
}
}//paths
}//empty
//Debug graph
if(j == CON_NUM_DEBUG){
for(int i=0; i <= id; i++){
for(int j=0; j <= id; j++){
cerr << contig_graph[i][j] << ", ";
}
cerr << endl;
}
cerr << "All generated paths:" << endl;
for(auto &path_pair: paths){
vector<int>& path = path_pair.first;
for(int i = path.size()-2; i > 0; i--){
cerr << intervals[lookup[path[i]].first][lookup[path[i]].second].loc << "-" << intervals[lookup[path[i]].first][lookup[path[i]].second].loc + intervals[lookup[path[i]].first][lookup[path[i]].second].len << "\t";
}
cerr << endl;
for(int i = path.size()-2; i > 0; i--){
cerr << intervals[lookup[path[i]].first][lookup[path[i]].second].con_loc+k - intervals[lookup[path[i]].first][lookup[path[i]].second].len << "-" << intervals[lookup[path[i]].first][lookup[path[i]].second].con_loc+k << "\t";
}
cerr << endl;
}
}
for(int i=0; i < interval_count; i++){
delete[] contig_graph[i];
}
delete[] contig_graph;
}//j
// Long Structural Variants
//============================================
cerr << "Predicting long structural variants..." << endl;
int w, w_id, z, z_id;
int last_z_loc = 0;
int last_w_loc = 0;
int next_w_loc = 0;
int chromo_dist, contig_dist, contig_dist1, contig_dist2;
for(char chr=0; chr < chromos.size(); chr++){
if(sorted_intervals[chr].empty())continue;
sort(sorted_intervals[chr].begin(), sorted_intervals[chr].end());
last_z_loc = 0;
last_w_loc = 0;
next_w_loc = 0;
for(z=0; z < sorted_intervals[chr].size()-1; z++){
z_id = sorted_intervals[chr][z].id;
found = false;
if(!interval_pair_ids[z_id].empty()){
w = (z-1 > 0) ? z-1 : 0;
mapping_ext iz = all_intervals[z_id];
mapping_ext ix, iy, iw;
next_w_loc = all_intervals[sorted_intervals[chr][w].id].rc ? sorted_intervals[chr][w].loc : sorted_intervals[chr][w].loc + all_intervals[sorted_intervals[chr][w].id].len;
while(w >= 0 && next_w_loc >= last_w_loc && abs(iz.loc - sorted_intervals[chr][w].loc) < max_length){
w_id = sorted_intervals[chr][w].id;
if(!interval_pair_ids[w_id].empty()){
iw = all_intervals[w_id];
chromo_dist = (iz.rc && iw.rc) ? iw.loc-(iz.loc+iz.len) : iz.loc-(iw.loc+iw.len);
// Try matching all interval pairs w,x with downstream interval pairs y,z within a user-specified max distance
for(int x: interval_pair_ids[w_id]){
for(int y: interval_pair_ids[z_id]){ //Shit, all combinations, TODO: Check if always small.
interval_pair& ip1 = interval_pairs[x];
interval_pair& ip2 = interval_pairs[y];
// If not visited and compatible
if(!ip1.visited && !ip2.visited && ip1.id1 == w_id && ip2.id2 == z_id && ip1.id2 != z_id && ip2.id1 != w_id && ip1.id1 != -1 && ip2.id2 != -1 && iw.con_id != iz.con_id){
//Both have empty intervals on opposite sides, INS
if(ip1.id2 == -1 && ip2.id1 == -1){
if(abs(chromo_dist) <= uncertainty){
ip1.visited = true;
ip2.visited = true;
add_result(iw.con_id, iw, iw, INS, iz.chr, add_result(iz.con_id, iz, iz, INS, iz.chr, -1));
// results_full.push_back({{w_id, -1, -1, z_id}, INS});
found = true;
long_ins++;
}
}
else if(ip1.id2 != -1 && ip2.id1 != -1){
ix = all_intervals[ip1.id2];
iy = all_intervals[ip2.id1];
contig_dist1 = abs(iw.con_loc - (ix.con_loc-ix.len));
contig_dist2 = abs(iy.con_loc - (iz.con_loc-iz.len));
// Opposite sides are on the same chromosome
if(ix.chr == iy.chr && contig_dist1 <= uncertainty && contig_dist2 <= uncertainty){
// If internal intervals are mapped to the opposite strand of external intervals INV
if(iw.rc != ix.rc && iy.rc != iz.rc){ //if(ix.rc || iy.rc){
if(ix.rc && iy.rc){
//Standard INV case
if(ix.loc > iy.loc && (ix.loc+ix.len)-iy.loc < max_length && abs(((ix.loc+ix.len)-iy.loc) - chromo_dist) <= uncertainty){
ip1.visited = true;
ip2.visited = true;
add_result(iw.con_id, iw, ix, INV, iy.chr, add_result(iz.con_id, iy, iz, INV, iz.chr, -1));
// results_full.push_back({{w_id, ip1.id2, ip2.id1, z_id}, INV});
found = true;
long_inv1++;
}
}
else if(iw.rc && iz.rc){
if(ix.loc < iy.loc && (iy.loc+iy.len)-ix.loc < max_length && abs(((iy.loc+iy.len)-ix.loc) - chromo_dist) <= uncertainty){
ip1.visited = true;
ip2.visited = true;
add_result(iw.con_id, iw, ix, INV, iy.chr, add_result(iz.con_id, iy, iz, INV, iz.chr, -1));
// results_full.push_back({{w_id, ip1.id2, ip2.id1, z_id}, INV});
found = true;
long_inv3++;
}
}
}
else{
if(iw.rc && ix.rc && iy.rc && iz.rc){
// Rare, if ever. Ignore for now.
}
else{
if(ix.loc < iy.loc && (iy.loc+iy.len)-ix.loc < max_length && (iw.chr != ix.chr || (ix.loc > iz.loc+iz.len || iy.loc+iy.len < iw.loc))){ //last check = 1 Trans
ip1.visited = true;
ip2.visited = true;
add_result(iw.con_id, iw, ix, TRANS, iy.chr, add_result(iz.con_id, iy, iz, TRANS, iz.chr, -1));
// results_full.push_back({{w_id, ip1.id2, ip2.id1, z_id}, TRANS});
found = true;
long_trans++;
}
//else if(ix.loc > iy.loc && (ix.loc+ix.len)-iy.loc < max_length && abs(iw.loc-iy.loc) <= uncertainty && abs(iz.loc-ix.loc) <= uncertainty){
else if(ix.loc > iw.loc && iz.loc > iy.loc && abs((iw.loc+iw.len)-ix.loc) < max_length && abs((iy.loc+iy.len)-iz.loc) < max_length && abs(iw.loc-iy.loc) <= uncertainty && abs(iz.loc-ix.loc) <= uncertainty){
// ip1.first = true;
// ip2.first = true;
// print_variant(fo_vcf, fr_vcf, fo_full, iw.con_id, iz.con_id, iw, ix, iy, iz, "DEL");
// Does not work well
long_del++;
}
else if(ix.loc < iy.loc && (iy.loc+iy.len)-ix.loc < max_length && abs(iz.loc-(iw.loc+iw.len)) <= uncertainty){
// Mostly false positives?
long_dup++;
}
}
}
}
}//ins or not
}//not used yet and correct side
if(found)break;
}//ip2
if(found)break;
}//ip1
}
if(found){
int cur_z_loc = iz.rc ? iz.loc + iz.len : iz.loc;
if(abs(cur_z_loc-last_z_loc) > uncertainty){
last_w_loc = last_z_loc; //So not really "w" but ok
last_z_loc = cur_z_loc;
}
else{
last_w_loc = iw.rc ? iw.loc : iw.loc + iw.len;
}
break;
}
else{
w--;
}
} //w
if(found)continue;
}
}//z
}
//Single interval pair case (WARNING: may cause many false positives)
for(char chr=0; chr < chromos.size(); chr++){
if(sorted_intervals[chr].empty())continue;
sort(sorted_intervals[chr].begin(), sorted_intervals[chr].end());
for(w=0; w < sorted_intervals[chr].size()-1; w++){
w_id = sorted_intervals[chr][w].id;
if(!interval_pair_ids[w_id].empty()){
mapping_ext iw, ix;
//Same as above but with only w,x
for(int x: interval_pair_ids[w_id]){
interval_pair& ip1 = interval_pairs[x];
if(!ip1.visited && (ip1.id1 == -1 || ip1.id2 == -1)){
int contig_id = (ip1.id1 == -1) ? all_intervals[ip1.id2].con_id : all_intervals[ip1.id1].con_id;
int bp = (ip1.id1 == -1) ? (all_intervals[ip1.id2].con_loc+k-all_intervals[ip1.id2].len) : all_intervals[ip1.id1].con_loc+k;
contig_seq = PRINT_READS ? all_contigs[contig_id].data : con_string(contig_id, 0, all_compressed_contigs[contig_id].data.size()/2);
vector<bool>& Ns = all_contig_Ns[contig_id];
bool Nfix = true;
for(int i = 0; i < 10; i++){
if(!Ns[bp+i] && !Ns[bp-i-1])Nfix = false;
}
if(Nfix)continue;
}
if(!ip1.visited && ip1.id1 != -1 && ip1.id2 != -1){
iw = all_intervals[ip1.id1];
ix = all_intervals[ip1.id2];
contig_dist = abs(iw.con_loc - (ix.con_loc-ix.len));
if(contig_dist <= uncertainty){
chromo_dist = (ix.rc && iw.rc) ? iw.loc-(ix.loc+ix.len) : ix.loc-(iw.loc+iw.len);
contig_seq = PRINT_READS ? all_contigs[ix.con_id].data : con_string(ix.con_id, 0, all_compressed_contigs[ix.con_id].data.size()/2);
contig_len = PRINT_READS ? all_contigs[ix.con_id].data.length() : all_compressed_contigs[ix.con_id].data.size()/2;
contig_sup = compute_support(iw.con_id, iw.con_loc+k, iw.con_loc+k).second.second;
if(( (iw.chr != ix.chr || abs(ix.loc - (iw.loc+iw.len)) > max_length/2) && !is_low_complexity(contig_seq.substr(iw.con_loc+k-iw.len,iw.len), LOW_COMPLEX) && !is_low_complexity(contig_seq.substr(ix.con_loc+k-ix.len,ix.len), LOW_COMPLEX)) ){
add_result(iw.con_id, iw, ix, TRANS, ix.chr, 0);
// results_full.push_back({{w_id, ip1.id2, -1, -1}, TRANS});
// results_full.push_back({{-1, -1, w_id, ip1.id2}, TRANS});
ip1.visited = true;
one_bp_trans++;
}
else if(abs(ix.loc - iw.loc) <= max_length && abs(ix.loc - iw.loc) >= min_length){
if(iw.rc != ix.rc){
add_result(iw.con_id, iw, ix, INV, ix.chr, 0); //ALL FP come from here
// if(ix.rc){
// results_full.push_back({{w_id, ip1.id2, -1, -1}, INV});
// }
// else{
// results_full.push_back({{-1, -1, w_id, ip1.id2}, INV});
// }
one_bp_inv++;
}
else if(chromo_dist >= min_length){
add_result(iw.con_id, iw, ix, DEL, ix.chr, 0);
//results_full.push_back({{w_id, -1, -1, ip1.id2}, DEL});
one_bp_del++;
}
else if(iw.loc+iw.len-ix.loc >= min_length){
//DUP
one_bp_dup++;
}
else{
mystery3++;
}
ip1.visited = true;
}
}
}
else if(!ip1.visited && ip1.id1 == -1){ //Two more possible with extra FP
ix = all_intervals[ip1.id2];
contig_seq = PRINT_READS ? all_contigs[ix.con_id].data : con_string(ix.con_id, 0, all_compressed_contigs[ix.con_id].data.size()/2);
contig_len = PRINT_READS ? all_contigs[ix.con_id].data.length() : all_compressed_contigs[ix.con_id].data.size()/2;
contig_sup = compute_support(ix.con_id, (ix.con_loc+k-ix.len), (ix.con_loc+k-ix.len)).second.second;
if(ix.len >= contig_len/3 && (ix.con_loc+k-ix.len) > contig_len/4 && !is_low_complexity(contig_seq.substr(0,ix.con_loc+k-ix.len), LOW_COMPLEX_UNMAPPED)){
add_result(ix.con_id, ix, ix, INSL, ix.chr, 0);
//results_full.push_back({{-1, -1, -1, ip1.id2}, INS});
one_bp_ins++;
}
ip1.visited = true;
}
else if(!ip1.visited && ip1.id2 == -1){
iw = all_intervals[ip1.id1];
contig_seq = PRINT_READS ? all_contigs[iw.con_id].data : con_string(iw.con_id, 0, all_compressed_contigs[iw.con_id].data.size()/2);
contig_len = PRINT_READS ? all_contigs[iw.con_id].data.length() : all_compressed_contigs[iw.con_id].data.size()/2;
contig_sup = compute_support(iw.con_id, iw.con_loc+k, iw.con_loc+k).second.second;
if(iw.len >= contig_len/3 && (contig_len-(iw.con_loc+k)) > contig_len/4 && !is_low_complexity(contig_seq.substr(iw.con_loc+k+1,contig_len-(iw.con_loc+k)), LOW_COMPLEX_UNMAPPED)){
add_result(iw.con_id, iw, iw, INSR, iw.chr, 0);
//results_full.push_back({{ip1.id1, -1, -1, -1}, INS});
one_bp_ins++;
}
ip1.visited = true;
}
}//ip1
}
}//i
}//chr
if(PRINT_STATS){
cerr << "Used intervals: " << num_intervals << endl;
cerr << "Normal Edges: " << normal_edges << endl;
cerr << "INS Edges: " << ins_edges << endl;
cerr << "Source Edges: " << source_edges << endl;
cerr << "Sink Edges: " << sink_edges << endl;
cerr << "Singletons: " << singletons << endl;
cerr << "Paths: " << path_count << endl;
cerr << "Contigs with Paths: " << cons_with_paths << endl;
cerr << "Short_INV1: " << short_inv1 << endl;
cerr << "Short_INV2: " << short_inv2 << endl;
cerr << "Short_INS1: " << short_ins1 << endl;
cerr << "Short_INS2: " << short_ins2 << endl;
cerr << "Short_DEL: " << short_del << endl;
cerr << "Short_DUP1: " << short_dup1 << endl;
cerr << "Short_DUP2: " << short_dup2 << endl;
cerr << "Short_DUP3: " << short_dup3 << endl;
cerr << "Short_TRANS: " << short_trans << endl;
cerr << "Long_INV1: " << long_inv1 << endl;
cerr << "Long_INV2: " << long_inv2 << endl;
cerr << "Long_INV3: " << long_inv3 << endl;
cerr << "Long_INS: " << long_ins << endl;
cerr << "Long_DEL: " << long_del << endl;
cerr << "Long_TRANS: "<< long_trans << endl;
cerr << "Long_DUP: "<< long_dup << endl;
cerr << "1bp_INV: " << one_bp_inv << endl;
cerr << "1bp_DEL: " << one_bp_del << endl;
cerr << "1bp_DUP: " << one_bp_dup << endl;
cerr << "1bp_TRANS: "<< one_bp_trans << endl;
cerr << "1bp_INS: " << one_bp_ins << endl;
cerr << "Interval_pairs: " << interval_pairs.size() << endl;
cerr << "Leading: " << intc1 << endl;
cerr << "INS IP left: " << intc2 << endl;
cerr << "INS IP right: " << intc3 << endl;
cerr << "DEL IP: " << intc4 << endl;
cerr << "Mystery 1: " << mystery1 << endl;
cerr << "Mystery 2: " << mystery2 << endl;
cerr << "Mystery 3: " << mystery3 << endl;
cerr << "Trailing: " << intc5 << endl;
cerr << "INS IP right: " << intc6 << endl;
cerr << "Anchor fails: " << anchor_fails << endl;
cerr << "Ugly Fails: " << ugly_fails << endl;
}
//find_consensus();
print_results(fo_vcf, out_vcf, uncertainty);
cerr << "Done." << endl;
fclose(fo_vcf);
delete[] sorted_intervals;
}
//Introduction to Algorithms 3rd Edition by Clifford Stein, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
/* Returns true if there is a path from source 's' to sink 't' in
residual graph. Also fills parent[] to store the path */
bool svict_caller::bfs(const int DEPTH, int** rGraph, int s, int t, int parent[])
{
// Create a visited array and mark all vertices as not visited
bool visited[DEPTH];
memset(visited, 0, sizeof(visited));
// Create a queue, enqueue source vertex and mark source vertex
// as visited
queue <int> q;
q.push(s);
visited[s] = true;
parent[s] = -1;
// Standard BFS Loop
while (!q.empty())
{
int u = q.front();
q.pop();
for (int v=0; v<DEPTH; v++)
{
if (visited[v]==false && rGraph[u][v] > 0)
{
q.push(v);
parent[v] = u;
visited[v] = true;
}
}
}
// If we reached sink in BFS starting from source, then return
// true, else false
return (visited[t] == true);
}
// Returns the maximum flow from s to t in the given graph
vector<vector<int>> svict_caller::fordFulkerson(const int DEPTH, int** rGraph, int s, int t)
{
int u, v;
vector<vector<int>> paths;
// Create a residual graph and fill the residual graph with
// given capacities in the original graph as residual capacities
// in residual graph
int parent[DEPTH]; // This array is filled by BFS and to store path
int max_flow = 0; // There is no flow initially
// Augment the flow while there is path from source to sink
while (bfs(DEPTH, rGraph, s, t, parent))
{
vector<int> path;
// Find minimum residual capacity of the edges along the
// path filled by BFS. Or we can say find the maximum flow
// through the path found.
int path_flow = 999999999;
for (v=t; v!=s; v=parent[v])
{
u = parent[v];
//cerr << v << "\t";
if(v != t)path.push_back(v);
path_flow = min(path_flow, rGraph[u][v]);
}
//cerr << endl;
// update residual capacities of the edges and reverse edges
// along the path
for (v=t; v != s; v=parent[v])
{
u = parent[v];
rGraph[u][v] -= path_flow;
rGraph[v][u] += path_flow;
}
//if(path.size() > 1)
paths.push_back(path);
// Add path flow to overall flow
max_flow += path_flow;
}
// Return the overall flow
return paths;
}
int svict_caller::minDistance(const int DEPTH, int dist[], bool sptSet[])
{
// Initialize min value
int min = 9999999, min_index;
for (int v = 0; v < DEPTH; v++){
if (sptSet[v] == false && dist[v] <= min){
min = dist[v];
min_index = v;
}
}
return min_index;
}
// Function to print shortest path from source to j
// using parent array
void svict_caller::getPath(vector<int>& path, int dist[], int parent[], int j)
{
path.push_back(j);
// Base Case : If j is source
if (parent[j]==-1)return;
getPath(path, dist, parent, parent[j]);
}
pair<vector<pair<int,int>>,int> svict_caller::findNextPath(const int DEPTH, int** graph, treeNode* node, vector<pair<int,int>> ancestors, int dist[], int parent[]){
pair<vector<pair<int,int>>,int> min_sub_path;
pair<vector<pair<int,int>>,int> cur_sub_path;
pair<int,int> min_edge;
int min_dist = 99999;
int cur_dist;
node->ancestors = ancestors;
for (int v=node->v; v != -1; v=parent[v]){
for(int w = 0; w < DEPTH; w++){
if(graph[w][v] && w != parent[v]){
if(!node->children.empty() && node->children.find(w) != node->children.end()){
cur_sub_path = findNextPath(DEPTH, graph, node->children[w], ancestors, dist, parent);
if(!cur_sub_path.first.empty()){
cur_dist = ((cur_sub_path.second-dist[parent[v]])+dist[node->v]);
if(cur_dist < min_dist){
min_sub_path = cur_sub_path;
min_sub_path.second = cur_dist;
min_edge = {parent[v],w};
min_dist = cur_dist;
}
}
}
else{
cur_dist = ((dist[w]-dist[parent[v]])+dist[node->v]);
if(cur_dist < min_dist){
min_edge = {parent[v],w};
min_dist = cur_dist;
}
}
}
}
}
if((node->children.empty() || node->children.find(min_edge.second) == node->children.end()) && min_dist != 99999){
ancestors.push_back(min_edge);
min_sub_path.first = ancestors;
min_sub_path.second = min_dist;
}
return min_sub_path;
}
// Funtion that implements Dijkstra's single source shortest path
// algorithm for a graph represented using adjacency matrix
// representation
vector<pair<vector<int>, int>> svict_caller::dijkstra(const int DEPTH, int** graph, int s, int t, int max_paths)
{
int dist[DEPTH]; // The output array. dist[i] will hold
// the shortest distance from src to i
// sptSet[i] will true if vertex i is included / in shortest
// path tree or shortest distance from src to i is finalized
bool sptSet[DEPTH];
// Parent array to store shortest path tree
int parent[DEPTH];
vector<pair<vector<int>, int>> paths;
// Initialize all distances as INFINITE and stpSet[] as false
for (int i = 0; i < DEPTH; i++)
{
parent[i] = -1;
dist[i] = 9999999;
sptSet[i] = false;
}
// Distance of source vertex from itself is always 0
dist[s] = 0;
// Find shortest path for all vertices
for (int count = 0; count < DEPTH-1; count++)
{
// Pick the minimum distance vertex from the set of
// vertices not yet processed. u is always equal to src
// in first iteration.
int u = minDistance(DEPTH, dist, sptSet);
// Mark the picked vertex as processed
sptSet[u] = true;
// Update dist value of the adjacent vertices of the
// picked vertex.
for (int v = 0; v < DEPTH; v++){
// Update dist[v] only if is not in sptSet, there is
// an edge from u to v, and total weight of path from
// src to v through u is smaller than current value of
// dist[v]
if (!sptSet[v] && graph[u][v] && (dist[u] + graph[u][v]) <= dist[v]){
parent[v] = u;
dist[v] = dist[u] + graph[u][v];
}
}
}
if(parent[t] != -1){
vector<int> path;
vector<treeNode> nodes;
unordered_map<string, bool> visted;
int path_tree[max_paths];
//shortest path
getPath(path, dist, parent, t);
paths.push_back({path, dist[t]});//parent[t]]});
treeNode sink;
sink.v = t;
max_paths--;
while(max_paths > 0){
vector<int> next_path;
pair<vector<pair<int,int>>,int> min_sub_path = findNextPath(DEPTH, graph, &sink, sink.ancestors, dist, parent);
if(min_sub_path.first.empty())break;
int v = t;
int w;
treeNode* cur_node = &sink;
//if(cur_debug_id == CON_NUM_DEBUG)cerr << "t: " << t << " size: " << min_sub_path.first.size() << " replace: " << min_sub_path.first.back().first << " with: " << min_sub_path.first.back().second << " dist: " << min_sub_path.second << endl;
for(int i = 0; i < min_sub_path.first.size()+1; i++){
w = (i == min_sub_path.first.size()) ? s : min_sub_path.first[i].first;
for (v; v != s && v != w; v=parent[v]){
next_path.push_back(v);
}
if(v == s)break;
if(i == min_sub_path.first.size()-1){
treeNode new_node;
new_node.v = min_sub_path.first.back().second;
new_node.ancestors = min_sub_path.first;
nodes.push_back(new_node);
cur_node->children[new_node.v] = &nodes.back();
}
cur_node = cur_node->children[min_sub_path.first[i].second];
v = cur_node->v;
}
next_path.push_back(v);
paths.push_back({next_path, min_sub_path.second});
max_paths--;
}
}
return paths;
}
int svict_caller::check_loc(int id, pair<int,int>& cloc, bool left){
if(id != -1){
mapping_ext& m = all_intervals[id];
int loc;
if(left){
loc = m.loc + m.len;
}
else{
loc = m.loc;
}
if(loc-cloc.first <= 5 && cloc.second-loc <= 5){
return 1;
}
else{
return 0;
}
}
return 2;
}
void svict_caller::update_loc(int id, pair<int,int>& cloc, bool left){
if(id != -1){
mapping_ext& m = all_intervals[id];
int loc;
if(left){
loc = m.loc + m.len;
}
else{
loc = m.loc;
}
if(loc < cloc.first){
cloc.first = loc;
}
else if(loc > cloc.second){
cloc.second = loc;
}
}
}
vector<int> svict_caller::compute_result_support(result_consensus& rc){
vector<int> supports = vector<int>(5,0);
unordered_set<int> contig_ids;
unordered_set<string> all_reads;
for(int i = 0; i < 4; i++){
unordered_set<string> reads;
if(!rc.intervals[i].empty()){
for(const int& id : rc.intervals[i]){
contig_ids.insert(all_intervals[id].con_id);
}
for(const int& id : contig_ids){
if(PRINT_READS){
for(Read& r : all_contigs[id].read_information){
reads.insert(r.name);
all_reads.insert(r.name);
}
}
else{
for(string& r : all_compressed_contigs[id].read_names){
reads.insert(r);
all_reads.insert(r);
}
}
}
}
supports[i] = reads.size();
}
supports[4] = all_reads.size();
return supports;
}
void svict_caller::print_consensus(result_consensus& rc){
for(int i = 0; i < 4; i++){
cerr << rc.locs[i].first << "-" << rc.locs[i].second << ", ";
}
cerr << endl;
for(int i = 0; i < 4; i++){
cerr << rc.intervals[i].size() << ",";
}
cerr << endl;
cerr << "conflicts: " << rc.conflicts.size() << endl;
if(!rc.conflicts.empty()){
for(pair<int, vector<bool>>& conflict : rc.conflicts){
cerr << conflict.second[0] << "," << conflict.second[1] << "," << conflict.second[2] << "," << conflict.second[3] << "," << conflict.second[4] << endl;
}
}
cerr << "type: " << rc.type << endl;
}
void svict_caller::find_consensus(){
for(int id = 0; id < results_full.size(); id++){
result_full& r = results_full[id];
bool found = false;
for(int idc = 0; idc < results_consensus.size(); idc++){
result_consensus& rc = results_consensus[idc];
found = true;
for(int i = 0; i < 4; i++){
if(!check_loc(r.intervals[i], rc.locs[i], !(i%2))){
found = false;
break;
}
}
if(found && r.type == rc.type){
for(int i = 0; i < 4; i++){
update_loc(r.intervals[i], rc.locs[i], !(i%2));
if(r.intervals[i] != -1)rc.intervals[i].insert(r.intervals[i]);
}
break;
}
}
if(!found){
for(int idc = 0; idc < results_consensus.size(); idc++){
result_consensus& rc = results_consensus[idc];
vector<bool> conflict = vector<bool>(5,false);
found = false;
for(int i = 0; i < 4; i++){
conflict[i] = (check_loc(r.intervals[i], rc.locs[i], !(i%2)) == 1);
if(conflict[i]){
found = true;
}
}
if(found){
conflict[4] = (r.type == rc.type);
rc.conflicts.push_back({results_consensus.size(), conflict});
}
}
result_consensus rc_new;
for(int i = 0; i < 4; i++){
unordered_set<int> new_set;
if(r.intervals[i] == -1){
rc_new.locs.push_back((pair<int,int>){-1,-1});
}
else{
if(!(i%2)){
rc_new.locs.push_back((pair<int,int>){(all_intervals[r.intervals[i]].loc + all_intervals[r.intervals[i]].len), (all_intervals[r.intervals[i]].loc + all_intervals[r.intervals[i]].len)});
}
else{
rc_new.locs.push_back((pair<int,int>){all_intervals[r.intervals[i]].loc, all_intervals[r.intervals[i]].loc});
}
new_set.insert(r.intervals[i]);
}
rc_new.intervals.push_back(new_set);
}
rc_new.type = r.type;
results_consensus.push_back(rc_new);
}
}
//resolve conflicts
cerr << "Calls: " << results_consensus.size() << endl;
for(int idc = 0; idc < results_consensus.size(); idc++){
result_consensus& rc = results_consensus[idc];
if(rc.conflicts.size() > 0){
//print_consensus(rc);
}
}
cerr << "Conflict Resolution" << endl;
cerr << "===================" << endl;
for(int idc = 0; idc < results_consensus.size(); idc++){
result_consensus& rc = results_consensus[idc];
vector<int> support = compute_result_support(rc);
if(rc.ignore)continue;
if(rc.conflicts.size() > 0){
for(pair<int, vector<bool>>& conflict : rc.conflicts){
int sim = 0;
for(const bool& c : conflict.second){
if(c)sim++;
}
//Conflict on type
if(sim == 4 && conflict.second[4]){
//DEL DUP
//INS DUP
//All TRANS
if(rc.type == TRANS){
print_consensus(rc);
cerr << "----------------------" << endl;
print_consensus(results_consensus[conflict.first]);
cerr << "===================" << endl;
}
else if(rc.type != INV){
}
}
}
}
}
}
void svict_caller::print_results2(FILE* fo_vcf, FILE* fr_vcf, int uncertainty){
long loc1, loc2, loc3, loc4, start, end;
int sup;
char chr;
string best_gene1 = "", best_name1 = "", best_trans1 = "", context1 = "";
string best_gene2 = "", best_name2 = "", best_trans2 = "", context2 = "";
string best_gene3 = "", best_name3 = "", best_trans3 = "", context3 = "";
string ref_seq, alt_seq;
string contig_labels;
string cluster_labels;
string contig_seq_left, contig_seq_right;
string filter = "PASS";
string anno = "";
string info = "";
vector<uint32_t> vec_best1, vec_best2, vec_best3;
vector<char> chrs = vector<char>(4,0);
for(int idc = 0; idc < results_consensus.size(); idc++){
result_consensus& rc = results_consensus[idc];
//if(rc.ignore)continue;
vector<int> support = compute_result_support(rc);
loc1 = rc.locs[0].first;
loc2 = rc.locs[1].second; //leave a gap if necessary
loc3 = rc.locs[2].first;
loc4 = rc.locs[3].second;
//string contig_seq_left = (rc.intervals[0].empty()) ? ( PRINT_READS ? all_contigs[rc.intervals[0].begin()].data : con_string(j, 0, all_compressed_contigs[j].data.size()/2) ) : "";
//string contig_seq_right = (rc.intervals[4].empty()) ? ( PRINT_READS ? all_contigs[j].data : con_string(j, 0, all_compressed_contigs[j].data.size()/2);
unordered_set<int> all_contig_ids;
unordered_set<int> all_cluster_ids;
ref_seq = "N";
alt_seq = "N";
for(int i = 0; i < 4; i++){
if(!rc.intervals[i].empty()){
unordered_set<int> contig_ids;
for(const int& id : rc.intervals[i]){
all_contig_ids.insert(all_intervals[id].con_id);
contig_ids.insert(all_intervals[id].con_id);
chrs[i] = all_intervals[id].chr;
}
if(PRINT_READS){
for(const int& id : contig_ids){
contig& con = all_contigs[id];
cluster_metrics& c = cluster_info[id];
fprintf(fr_vcf, ">Cluster: %d Contig: %d MaxSupport: %d BP: %d Reads: \n", c.sc_loc, id, con.support(), 0); //TODO find way to get start loc in contig
fprintf(fr_vcf, "ContigSeq: %s\n", con.data.c_str());
for (auto &read: con.read_information)
fprintf(fr_vcf, "+ %d %d %s %s\n", read.location_in_contig, read.seq.size(), read.name.c_str(), read.seq.c_str());
}
}
else{
for(const int& id : contig_ids){
compressed_contig& con = all_compressed_contigs[id];
cluster_metrics& c = cluster_info[id];
}
}
}
else{
}
}
contig_labels = "";
cluster_labels = "";
for(const int& id : all_contig_ids){
all_cluster_ids.insert(cluster_info[id].sc_loc);
contig_labels = contig_labels + (to_string(id) + ",");
}
for(const int& id : all_cluster_ids){
cluster_labels = cluster_labels + (to_string(id) + ",");
}
contig_labels.resize(contig_labels.length()-1);
cluster_labels.resize(cluster_labels.length()-1);
if(rc.type == INS){
}
else if(rc.type == INV){
}
else if(rc.type == DEL){
}
else if(rc.type == DUP){
}
if(rc.type == TRANS){
if(loc4 == -1){
fprintf(fo_vcf, "%s\t%d\tbnd_%d_1\t%s\t%s[%s:%d[\t.\t%s\tSVTYPE=BND;MATEID=bnd_%d_2;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n",
chromos[chrs[0]].c_str(), loc1, idc, ref_seq.c_str(), ref_seq.c_str(), chromos[chrs[1]].c_str(), loc2, filter.c_str(), idc, cluster_labels.c_str(), contig_labels.c_str(), support[0], anno.c_str());
fprintf(fo_vcf, "%s\t%d\tbnd_%d_2\tN\t.N\t.\t%s\tSVTYPE=BND;MATEID=bnd_%d_1;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n",
chromos[chrs[0]].c_str(), (loc1+1), idc, filter.c_str(), idc, cluster_labels.c_str(), contig_labels.c_str(), support[0], anno.c_str());
}
else if(loc1 == -1){
fprintf(fo_vcf, "%s\t%d\tbnd_%d_1\tN\tN.\t.\t%s\tSVTYPE=BND;MATEID=bnd_%d_2;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n",
chromos[chrs[2]].c_str(), loc3, idc, filter.c_str(), idc, cluster_labels.c_str(), contig_labels.c_str(), support[3], anno.c_str());
fprintf(fo_vcf, "%s\t%d\tbnd_%d_2\t%s\t]%s:%d]%s\t.\t%s\tSVTYPE=BND;MATEID=bnd_%d_1;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n",
chromos[chrs[2]].c_str(), (loc3+1), idc, ref_seq.c_str(), chromos[chrs[3]].c_str(), loc4, ref_seq.c_str(), filter.c_str(), idc, cluster_labels.c_str(), contig_labels.c_str(), support[3], anno.c_str());
}
else{
fprintf(fo_vcf, "%s\t%d\tbnd_%d_1\t%s\t%s[%s:%d[\t.\t%s\tSVTYPE=BND;MATEID=bnd_%d_2;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n",
chromos[chrs[0]].c_str(), loc1, idc, ref_seq.c_str(), ref_seq.c_str(), chromos[chrs[1]].c_str(), loc2, filter.c_str(), idc, cluster_labels.c_str(), contig_labels.c_str(), support[0], anno.c_str());
fprintf(fo_vcf, "%s\t%d\tbnd_%d_2\t%s\t]%s:%d]%s\t.\t%s\tSVTYPE=BND;MATEID=bnd_%d_1;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n",
chromos[chrs[0]].c_str(), loc4, idc, ref_seq.c_str(), chromos[chrs[1]].c_str(), loc3, ref_seq.c_str(), filter.c_str(), idc, cluster_labels.c_str(), contig_labels.c_str(), support[3], anno.c_str());
}
}
else{
if(loc3 == -1){
chr = chrs[0];
start = loc1;
end = (loc4 == -1) ? ((loc2 == -1) ? loc1 : loc2) : loc4;
}
else if(loc2 == -1){
chr = chrs[0];
start = (loc1 == -1) ? ((loc3 == -1) ? loc4 : loc3) : loc1;
end = loc4;
}
else{
chr = chrs[0];
start = loc1;
end = loc4;
}
fprintf(fo_vcf, "%s\t%d\t.\t%s\t%s\t.\tPASS\tSVTYPE=%s%s;END=%d;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n",
chromos[chr].c_str(), start, ref_seq.c_str(), alt_seq.c_str(), sv_types[rc.type].c_str(), info.c_str(), end, cluster_labels.c_str(), contig_labels.c_str(), support[4], anno.c_str());
}
// 1 179112343 bnd_698_1 N N[22:-1[ . PASS SVTYPE=BND;MATEID=bnd_698_2;CLUSTER=179114916,179112344;CONTIG=2097,50;SUPPORT=39;
// 1 179114915 bnd_698_2 N ]22:-1]N . PASS SVTYPE=BND;MATEID=bnd_698_1;CLUSTER=179114916,179112344;CONTIG=2097,50;SUPPORT=39;
// if(USE_ANNO){
// locate_interval(chromos[chr], loc, loc, gene_sorted_map[chromos[chr]], 0, iso_gene_map, best_gene1, best_name1, best_trans1, vec_best1);
// context1 = contexts[vec_best1[0]];
// locate_interval(chromos[pchr], pend, pend, gene_sorted_map[chromos[pchr]], 0, iso_gene_map, best_gene2, best_name2, best_trans2, vec_best2);
// context2 = contexts[vec_best2[0]];
// locate_interval(chromos[chr], loc, pend, gene_sorted_map[chromos[chr]], 0, iso_gene_map, best_gene3, best_name3, best_trans3, vec_best3);
// context3 = contexts[vec_best3[0]];
// anno = "ANNOL=" + context1 + "," + best_gene1 + "," + best_trans1 + "," + best_name1 + ";ANNOC=" + context3 + "," + best_gene3 + "," + best_trans3 + "," + best_name3 + ";ANNOR=" + context2 + "," + best_gene2 + "," + best_trans2 + "," + best_name2;
// if(vec_best1[0] > 0 && vec_best2[0] > 0 && best_gene1 != best_gene2)type = type + ":FUSION";
// }
}
}
long svict_caller::add_result(int id, mapping_ext& m1, mapping_ext& m2, short type, char pair_chr, long pair_loc){
long loc = m1.rc ? m1.loc : (m1.loc + m1.len);
long end = m2.rc ? (m2.loc + m2.len) : m2.loc;
int contig_dist = (m2.con_loc-m2.len)-m1.con_loc;
int contig_len = PRINT_READS ? all_contigs[id].data.length() : all_compressed_contigs[id].data.size()/2;
int contig_sup;
int contig_loc = cluster_info[id].sc_loc;
int total_coverage = cluster_info[id].total_coverage;
char contig_chr = cluster_info[id].chr;
char strand = '+';
pair<int,pair<int,int>> support;
call_support sup;
result new_result;
new_result.info = "";
new_result.one_bp = false;
new_result.u_id = u_ids++;
//TO think about:
//end location for 2 contig
//alt seq for 2 contig
if(m1.rc && m2.rc)strand = '-';
if(type == INS){
new_result.ref_seq = con_string(id, m1.con_loc+k-1, 1);
new_result.alt_seq = con_string(id, m1.con_loc+k-1, contig_dist+1);
if(new_result.alt_seq == "")new_result.alt_seq = "<INS>"; //two contig cases where contigdist <= uncertainty
}
else if(type == INSL){
type = INS;
new_result.ref_seq = "N";
new_result.alt_seq = con_string(id, 0, (m1.con_loc+k-m1.len));
new_result.info = ":L";
new_result.one_bp = true;
loc = end;
}
else if(type == INSR){
type = INS;
new_result.ref_seq = con_string(id, m1.con_loc+k-1, 1);
new_result.alt_seq = con_string(id, m1.con_loc+k-1, (contig_len-(m1.con_loc+k-1)+1));
new_result.info = ":R";
new_result.one_bp = true;
end = loc;
}
else if(type == DEL){
new_result.ref_seq = "<DEL>";
new_result.alt_seq = con_string(id, m1.con_loc+k-1, 1);
}
else if(type == DUP){
new_result.info = ":INTERSPERSED";
new_result.ref_seq = "N";
new_result.alt_seq = "<DUP>";
if(strand == '+'){
if(m1.loc < m2.loc && (m1.loc + m1.len)-m2.loc > MIN_SV_LEN_DEFAULT){
new_result.info = ":TANDEM";
loc = m2.loc;
end = (m1.loc + m1.len);
int len = ((m1.loc + m1.len)-m2.loc)+1;
if(m1.con_loc+k-1-len >= 0){
new_result.ref_seq = con_string(id, m1.con_loc+k-1-len, 1);
new_result.alt_seq = con_string(id, m1.con_loc+k-1-len, len+1);
}
else{
new_result.alt_seq = con_string(id,m1.con_loc+k-len, len);
}
}
else if(m1.loc > m2.loc && (m1.loc + m1.len) > (m2.loc + m2.len)){
new_result.info = ":TANDEM";
new_result.ref_seq = con_string(id,m1.con_loc+k-1, 1);
}
else{
new_result.info = ":INTERSPERSED"; //TODO we have the alt sequence
new_result.ref_seq = con_string(id,m1.con_loc+k-1, 1);
}
}
else{
new_result.info = ""; //negative
}
}
else if(type == INV){
new_result.ref_seq = con_string(id,m1.con_loc+k-1, 1);
new_result.alt_seq = "<INV>";
new_result.info = ":LONG";
new_result.one_bp = true;
if(m1.rc){
new_result.ref_seq = "N";
}
else if(!m2.rc){
new_result.alt_seq = con_string(id,m1.con_loc+k-1, contig_dist+1);
new_result.info = ":MICRO";
}
}
else if(type == TRANS){
bool is_anchor1 = ((m1.chr == contig_chr) && (abs(m1.loc - contig_loc) < MAX_ASSEMBLY_RANGE));
bool is_anchor2 = ((m2.chr == contig_chr) && (abs(m2.loc - contig_loc) < MAX_ASSEMBLY_RANGE));
if(!is_anchor1){
new_result.ref_seq = con_string(id,m2.con_loc+k-1-m2.len, 1);;
new_result.alt_seq = "<TRANS>";
new_result.info = "right_bp";
new_result.one_bp = true;
}
else if(!is_anchor2){
new_result.ref_seq = con_string(id,m1.con_loc+k-1, 1);
new_result.alt_seq = "<TRANS>";
new_result.info = "left_bp";
new_result.one_bp = true;
}
else{
new_result.info = "small";
new_result.ref_seq = con_string(id,m1.con_loc+k-1, 1);
new_result.alt_seq = con_string(id,m1.con_loc+k-1, contig_dist+1);
}
}
if(loc > end){
if(type == INV || type == DEL || type == DUP){
long tmp = loc;
loc = end;
end = tmp;
}
}
//quick and dirty fix
if(type == INS){
int g_count = 0;
for(int i = 0; i < new_result.alt_seq.length(); i++){
if(new_result.alt_seq[i] == 'G'){
g_count++;
}
else{
g_count = 0;
}
if(g_count > ANCHOR_SIZE){
return 0;
}
}
}
if(new_result.info == ":L" || new_result.alt_seq == "<INS>"){
support = compute_support(id, (m1.con_loc+k-m1.len), (m1.con_loc+k-m1.len));
}
else{
support = compute_support(id, (m1.con_loc+k), (m1.con_loc+k));
}
sup.l_sup = support.second.second;
sup.l_sup_total = total_coverage;
if(contig_dist > 0){
support = compute_support(id, (m1.con_loc+k+contig_dist), (m1.con_loc+k+contig_dist));
}
sup.r_sup = support.second.second;
sup.r_sup_total = pair_chr == -1 ? total_coverage : total_coverage;// TODO this is wrong
new_result.end = end;
new_result.clust = contig_loc;
new_result.con = id;
new_result.sup = sup;
new_result.pair_loc = pair_loc;
new_result.pair_chr = pair_chr;
results[type][m1.chr][loc].push_back(new_result);
return loc;
}
void svict_caller::print_results(FILE* fo_vcf, const string &out_vcf, int uncertainty){
long loc, ploc, start, end, pend;
double var, normal, vaf1, vaf2;
char pchr;
string best_gene1 = "", best_name1 = "", best_trans1 = "", context1 = "";
string best_gene2 = "", best_name2 = "", best_trans2 = "", context2 = "";
string best_gene3 = "", best_name3 = "", best_trans3 = "", context3 = "";
string type, info;
string cluster_ids, cluster_ids_pair;
string contig_ids, contig_ids_pair;
string filter = "PASS";
string anno = "";
vector<uint32_t> vec_best1, vec_best2, vec_best3;
result c, cp; //consensus
// DEL signal for interspersed duplications
for(char chr = 0; chr < chromos.size(); chr++){
if(!results[DEL][chr].empty()){
for(auto& rp1 : results[DEL][chr]){
for(auto& rp2 : results[DUP][chr]){
if(abs(rp1.first - rp2.first) < uncertainty || abs(rp1.first - rp2.second[0].end) < uncertainty || abs(rp1.second[0].end - rp2.first) < uncertainty || abs(rp1.second[0].end - rp2.second[0].end) < uncertainty){ // 2bp would be safer
for (auto& r : rp1.second){
r.end = rp2.second[0].end; // Not great
r.ref_seq = "N";
r.alt_seq = "N";
rp2.second.push_back(r);
}
rp1.second.clear();
break;
}
}
}
}
}
// DEL signal for translocations
// for(char chr = 0; chr < chromos.size(); chr++){
// if(!results[DEL][chr].empty()){
// for(auto& rp1 : results[DEL][chr]){
// if(rp1.second.empty())continue;
// for(char chr2 = 0; chr2 < chromos.size(); chr2++){
// for(auto& rp2 : results[TRANS][chr2]){
// if(abs(rp2.second[0].sup - rp1.second[0].sup) < 50){
// if(chr == chr2 && abs(rp2.first - rp1.second[0].end) < uncertainty ){
// for (auto& r : rp1.second){
// r.ref_seq = "N";
// r.alt_seq = "N";
// if(rp2.second[0].pair_loc == -1){
// r.end = rp2.second[0].end; // Not great
// r.pair_loc = -1;
// rp2.second.push_back(r);
// }
// else if (rp2.second[0].pair_loc == 0){
// rp2.second[0].pair_loc = -1;
// r.pair_loc = rp2.first;
// r.end = rp1.first;
// results[TRANS][rp2.second[0].pair_chr][rp2.second[0].end-1].push_back(r);
// }
// for (auto& r2 : rp2.second){
// r2.pair_loc = -1;
// }
// }
// rp1.second.clear();
// break;
// }
// else if(rp2.second[0].pair_chr == chr && ( abs(rp2.second[0].end - rp1.first) < uncertainty || abs(rp2.second[0].pair_loc - rp1.second[0].end) < uncertainty ) ){
// for (auto& r : rp1.second){
// r.ref_seq = "N";
// r.alt_seq = "N";
// if(rp2.second[0].pair_loc){
// r.end = rp2.second[0].end; // Not great
// r.pair_loc = rp2.second[0].pair_loc;
// rp2.second.push_back(r);
// }
// else {
// rp2.second[0].pair_loc = rp1.second[0].end;
// r.pair_loc = -1;
// r.pair_chr = chr2;
// r.end = rp2.first+1;
// results[TRANS][rp2.second[0].pair_chr][rp1.second[0].end].push_back(r);
// }
// for (auto& r2 : rp2.second){
// r2.pair_loc = rp1.second[0].end;
// }
// }
// rp1.second.clear();
// break;
// }
// }
// }
// if(rp1.second.empty())break;
// }
// }
// }
// }
if(PRINT_READS){
FILE *fr_vcf = fopen((out_vcf + ".reads").c_str(), "wb");
for(int id = 0; id < all_contigs.size(); id++ ){
contig& con = all_contigs[id];
fprintf(fr_vcf, ">CLUSTER=%d CONTIG=%d MaxSupport: %d BP: %d Reads: \n", cluster_info[id].sc_loc, id, 0, 0); //TODO find way to get start loc in contig
fprintf(fr_vcf, "ContigSeq: %s\n", con.data.c_str());
for (auto &read: con.read_information)
fprintf(fr_vcf, "+ %d %d %s %s\n", read.location_in_contig, read.seq.size(), read.name.c_str(), read.seq.c_str());
}
fclose(fr_vcf);
}
//STATS
int bnd_count = 0;
int not_bnd_count = 0;
int result_count = 0;
for(int sv = 0; sv < sv_types.size(); sv++){
for(char chr = 0; chr < chromos.size(); chr++){
if(results[sv][chr].empty())continue;
for(auto& result_pair : results[sv][chr]){
loc = result_pair.first;
unordered_set<long> clusters;
unordered_set<paired_result, paired_result_hash> pairs;
unordered_set<int> contigs;
filter = "PASS";
c.sup = {0,0,0,0};
c.end = 0;
if(result_pair.second.empty())continue;
for(auto& r : result_pair.second){
result_count++;
if(r.end != c.end && (r.sup.l_sup+r.sup.r_sup) > (c.sup.l_sup+c.sup.r_sup)){
c = r;
pairs.clear();
pairs.insert({r.pair_loc, r.end, r.pair_chr});
clusters.clear();
clusters.insert(r.clust);
contigs.clear();
contigs.insert(r.con);
}
else if(r.end == c.end || r.pair_loc > 0 || r.pair_chr != c.pair_chr){
clusters.insert(r.clust);
contigs.insert(r.con);
c.sup.l_sup += r.sup.l_sup;
c.sup.r_sup += r.sup.r_sup;
// if(r.pair_loc != 0){
pairs.insert({r.pair_loc, r.end, r.pair_chr});
// c.pair_loc = r.pair_loc;
// c.pair_chr = r.pair_chr;
// }
}
}
cluster_ids = "";
contig_ids = "";
type = sv_types[sv];
if(clusters.empty() || contigs.empty()){
cerr << "ERROR: Invalid call of type " << type << ": " << chromos[chr] << ":" << loc << " ploc " << chromos[c.pair_chr] << ":" << c.pair_loc << endl;
continue;
}
if(PRINT_READS){
for(auto& clust : clusters) {
cluster_ids = cluster_ids + (to_string(clust) + ",");
}
for(auto& con : contigs) {
contig_ids = contig_ids + (to_string(con) + ",");
}
cluster_ids.resize(cluster_ids.length()-1);
contig_ids.resize(contig_ids.length()-1);
}
else{
cluster_ids = to_string(clusters.size());
contig_ids = to_string(contigs.size());
}
for(auto& p : pairs){
ploc = p.loc;
pend = p.end;
pchr = p.chr;
if(ploc == 0 || ploc == loc || (ploc > 0 && (results[sv][pchr].find(ploc) == results[sv][pchr].end()))){ //TODO deal with this last case
if(c.one_bp)filter = "TWO_BP"; //Counter-intuitive I think, but rules are rules
if(USE_ANNO){
locate_interval(chromos[chr], loc, loc, gene_sorted_map[chromos[chr]], 0, iso_gene_map, best_gene1, best_name1, best_trans1, vec_best1);
context1 = contexts[vec_best1[0]];
locate_interval(chromos[pchr], pend, pend, gene_sorted_map[chromos[pchr]], 0, iso_gene_map, best_gene2, best_name2, best_trans2, vec_best2);
context2 = contexts[vec_best2[0]];
locate_interval(chromos[chr], loc, pend, gene_sorted_map[chromos[chr]], 0, iso_gene_map, best_gene3, best_name3, best_trans3, vec_best3);
context3 = contexts[vec_best3[0]];
anno = "ANNOL=" + context1 + "," + best_gene1 + "," + best_trans1 + "," + best_name1 + ";ANNOC=" + context3 + "," + best_gene3 + "," + best_trans3 + "," + best_name3 + ";ANNOR=" + context2 + "," + best_gene2 + "," + best_trans2 + "," + best_name2;
if(vec_best1[0] > 0 && vec_best2[0] > 0 && best_gene1 != best_gene2)type = type + ":FUSION";
}
// var = c.sup.l_sup;
// normal = c.sup.l_sup_total;
// vaf1 = normal == 0 ? 1 : var/normal;
// var = c.sup.r_sup;
// normal = c.sup.r_sup_total;
// vaf2 = normal == 0 ? 1 : var/normal;
// if(vaf1 > 1)vaf1 = 1;
// if(vaf2 > 1)vaf2 = 1;
if(sv == TRANS){
if(c.info == "left_bp"){
fprintf(fo_vcf, "%s\t%d\tbnd_%d_1\t%s\t%s[%s:%d[\t.\t%s\tSVTYPE=BND;MATEID=bnd_%d_2;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n", //VAF=%.3f;
chromos[chr].c_str(), loc, c.u_id, c.ref_seq.c_str(), c.ref_seq.c_str(), chromos[pchr].c_str(), pend, filter.c_str(), c.u_id, cluster_ids.c_str(), contig_ids.c_str(), c.sup.l_sup, anno.c_str()); //max(vaf1,vaf2),
fprintf(fo_vcf, "%s\t%d\tbnd_%d_2\tN\t.N\t.\t%s\tSVTYPE=BND;MATEID=bnd_%d_1;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n", //VAF=%.3f;
chromos[chr].c_str(), (loc+1), c.u_id, filter.c_str(), c.u_id, cluster_ids.c_str(), contig_ids.c_str(), c.sup.r_sup, anno.c_str()); //max(vaf1,vaf2),
}
else if(c.info == "right_bp"){
fprintf(fo_vcf, "%s\t%d\tbnd_%d_1\tN\tN.\t.\t%s\tSVTYPE=BND;MATEID=bnd_%d_2;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n", //VAF=%.3f;
chromos[chr].c_str(), loc, c.u_id, filter.c_str(), c.u_id, cluster_ids.c_str(), contig_ids.c_str(), c.sup.l_sup, anno.c_str()); //max(vaf1,vaf2),
fprintf(fo_vcf, "%s\t%d\tbnd_%d_2\t%s\t]%s:%d]%s\t.\t%s\tSVTYPE=BND;MATEID=bnd_%d_1;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n", //VAF=%.3f;
chromos[chr].c_str(), (loc+1), c.u_id, c.ref_seq.c_str(), chromos[pchr].c_str(), pend, c.ref_seq.c_str(), filter.c_str(), c.u_id, cluster_ids.c_str(), contig_ids.c_str(), c.sup.r_sup, anno.c_str()); // max(vaf1,vaf2),
}
else{
fprintf(fo_vcf, "%s\t%d\tbnd_%d_1\t%s\t%s[%s:%d[\t.\t%s\tSVTYPE=BND;MATEID=bnd_%d_2;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n", //VAF=%.3f;
chromos[chr].c_str(), loc, c.u_id, c.ref_seq.c_str(), c.ref_seq.c_str(), chromos[pchr].c_str(), pend, filter.c_str(), c.u_id, cluster_ids.c_str(), contig_ids.c_str(), c.sup.l_sup, anno.c_str()); //max(vaf1,vaf2),
fprintf(fo_vcf, "%s\t%d\tbnd_%d_2\t%s\t]%s:%d]%s\t.\t%s\tSVTYPE=BND;MATEID=bnd_%d_1;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n", //VAF=%.3f;
chromos[chr].c_str(), (loc+1), c.u_id, c.ref_seq.c_str(), chromos[pchr].c_str(), (pend + c.alt_seq.length()), c.ref_seq.c_str(), filter.c_str(), c.u_id, cluster_ids.c_str(), contig_ids.c_str(), c.sup.r_sup, anno.c_str()); //max(vaf1,vaf2),
}
}
else{
start = loc;
end = pend;
// If it's more than uncertainty it's better to print it so we know something is wrong
if(abs(pend-loc) <= uncertainty){
start = min(loc, pend);
end = max(loc, pend);
}
fprintf(fo_vcf, "%s\t%d\t.\t%s\t%s\t.\t%s\tSVTYPE=%s%s;END=%d;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n", //VAF=%.3f;
chromos[chr].c_str(), start, c.ref_seq.c_str(), c.alt_seq.c_str(), filter.c_str(), type.c_str(), c.info.c_str(), end, cluster_ids.c_str(), contig_ids.c_str(), c.sup.l_sup, anno.c_str()); //max(vaf1,vaf2),
}
}
else if(ploc > 0){
unordered_set<long> clusters;
unordered_set<int> contigs;
cp.sup = {0,0,0,0};
cp.end = 0;
for(result& r : results[sv][pchr][ploc]){
if(r.pair_loc < 0){
if(r.end != cp.end && (r.sup.l_sup+r.sup.r_sup) > (cp.sup.l_sup+cp.sup.r_sup)){
cp = r;
clusters.clear();
clusters.insert(r.clust);
contigs.clear();
contigs.insert(r.con);
}
else if(r.end == cp.end){
clusters.insert(r.clust);
contigs.insert(r.con);
cp.sup.l_sup += r.sup.l_sup;
cp.sup.r_sup += r.sup.r_sup;
}
}
}
cluster_ids_pair = "";
contig_ids_pair = "";
if(clusters.empty() || contigs.empty()){
cerr << "ERROR: Invalid two contig call of type " << type << ": " << chromos[chr] << ":" << loc << " ploc " << chromos[pchr] << ":" << ploc << endl;
continue;
}
if(PRINT_READS){
for(auto& clust : clusters) {
cluster_ids_pair = cluster_ids_pair + to_string(clust) + ",";
}
for(auto& con : contigs) {
contig_ids_pair = contig_ids_pair + to_string(con) + ",";
}
cluster_ids_pair.resize(cluster_ids_pair.length()-1);
contig_ids_pair.resize(contig_ids_pair.length()-1);
}
else{
cluster_ids_pair = to_string(clusters.size());
contig_ids_pair = to_string(contigs.size());
}
// int loc1 == m1.loc + m1.len == loc
// int loc2 == m2.loc == c.end
// int end1 == m4.loc == cp.end
// int end2 == m3.loc+m3.len == c.pair_loc
// var = max(c.sup.l_sup,c.sup.r_sup);
// normal = c.sup.l_sup_total; //TODO capture edge case
// vaf1 = normal == 0 ? 1 : var/normal;
// var = max(cp.sup.l_sup,cp.sup.r_sup);
// normal = cp.sup.r_sup_total;
// vaf2 = normal == 0 ? 1 : var/normal;
// if(vaf1 > 1)vaf1 = 1;
// if(vaf2 > 1)vaf2 = 1;
if(sv == TRANS){
bnd_count++;
if(USE_ANNO){
locate_interval(chromos[chr], loc, cp.end, gene_sorted_map[chromos[chr]], 0, iso_gene_map, best_gene1, best_name1, best_trans1, vec_best1);
context1 = contexts[vec_best1[0]];
locate_interval(chromos[pchr], c.end, ploc, gene_sorted_map[chromos[pchr]], 0, iso_gene_map, best_gene2, best_name2, best_trans2, vec_best2);
context2 = contexts[vec_best2[0]];
anno = "ANNOL=" + context1 + "," + best_gene1 + "," + best_trans1 + "," + best_name1 + ";ANNOR=" + context2 + "," + best_gene2 + "," + best_trans2 + "," + best_name2;
if(vec_best1[0] > 0 && vec_best2[0] > 0 && best_gene1 != best_gene2)type = type + ":FUSION";
}
if(abs(cp.end-loc) <= uncertainty){
info = ":INS";
if(abs(pend-ploc) <= uncertainty)continue; //1 FP
}
else{
if(abs(pend-ploc) <= uncertainty){
info = ":DEL";
}
else{
info = ":SWAP";
}
}
fprintf(fo_vcf, "%s\t%d\tbnd_%d\t%s\t%s[%s:%d[\t.\tPASS\tSVTYPE=BND%s;MATEID=bnd_%d;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n", //VAF=%.3f;
chromos[chr].c_str(), loc, c.con, c.ref_seq.c_str(), c.ref_seq.c_str(), chromos[pchr].c_str(), pend, info.c_str(), cp.con, cluster_ids.c_str(), contig_ids.c_str(), max(c.sup.l_sup,c.sup.r_sup), anno.c_str()); //max(vaf1,vaf2),
if(USE_ANNO)anno = "ANNOL=" + context2 + "," + best_gene2 + "," + best_trans2 + "," + best_name2 + ";ANNOR=" + context1 + "," + best_gene1 + "," + best_trans1 + "," + best_name1;
fprintf(fo_vcf, "%s\t%d\tbnd_%d\t%s\t]%s:%d]%s\t.\tPASS\tSVTYPE=BND%s;MATEID=bnd_%d;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n", //VAF=%.3f;
chromos[chr].c_str(), cp.end, cp.con, cp.ref_seq.c_str(), chromos[pchr].c_str(), ploc, cp.ref_seq.c_str(), info.c_str(), c.con, cluster_ids_pair.c_str(), contig_ids_pair.c_str(), max(cp.sup.l_sup,cp.sup.r_sup), anno.c_str()); //max(vaf1,vaf2),
}
else{
not_bnd_count++;
if(USE_ANNO){
locate_interval(chromos[chr], loc, loc, gene_sorted_map[chromos[chr]], 0, iso_gene_map, best_gene1, best_name1, best_trans1, vec_best1);
context1 = contexts[vec_best1[0]];
locate_interval(chromos[pchr], ploc, ploc, gene_sorted_map[chromos[pchr]], 0, iso_gene_map, best_gene2, best_name2, best_trans2, vec_best2);
context2 = contexts[vec_best2[0]];
locate_interval(chromos[chr], loc, ploc, gene_sorted_map[chromos[chr]], 0, iso_gene_map, best_gene3, best_name3, best_trans3, vec_best3);
context3 = contexts[vec_best3[0]];
anno = "ANNOL=" + context1 + "," + best_gene1 + "," + best_trans1 + "," + best_name1 + ";ANNOC=" + context3 + "," + best_gene3 + "," + best_trans3 + "," + best_name3 + ";ANNOR=" + context2 + "," + best_gene2 + "," + best_trans2 + "," + best_name2;
if(vec_best1[0] > 0 && vec_best2[0] > 0 && best_gene1 != best_gene2)type = type + ":FUSION";
}
if(PRINT_READS){
cluster_ids += "," + cluster_ids_pair;
contig_ids += "," + contig_ids_pair;
}
else{
cluster_ids = to_string(stoi(cluster_ids) + stoi(cluster_ids_pair));
contig_ids = to_string(stoi(contig_ids) + stoi(contig_ids_pair));
}
if(sv == INV || sv == INS){
start = loc;
end = cp.end;
if(abs(cp.end-loc) <= uncertainty){
start = min(loc, ploc);
end = max(loc, cp.end);
}
}
else{
start = loc;
end = ploc;
// If it's more than uncertainty it's better to print it so we know something is wrong
if(abs(ploc-loc) <= uncertainty){
start = min(loc, ploc);
end = max(loc, ploc);
}
}
fprintf(fo_vcf, "%s\t%d\t.\t%s\t%s\t.\tPASS\tSVTYPE=%s%s;END=%d;CLUSTER=%s;CONTIG=%s;SUPPORT=%d;%s\n", //VAF=%.3f;
chromos[chr].c_str(), start, c.ref_seq.c_str(), c.alt_seq.c_str(), type.c_str(), c.info.c_str(), end, cluster_ids.c_str(), contig_ids.c_str(), (max(c.sup.l_sup,c.sup.r_sup)+max(cp.sup.l_sup,cp.sup.r_sup)), anno.c_str()); //max(vaf1,vaf2),
}
}// pair_loc > 0
}//pairs
}
}
}
if(PRINT_STATS){
cerr << "bnd_count: " << bnd_count << endl;
cerr << "not_bnd_count: " << not_bnd_count << endl;
cerr << "result count: " << result_count << endl;
}
}
| 31.390777 | 298 | 0.597919 | [
"vector"
] |
c73217790802d28f77a77ef4f43bf520460ebee7 | 4,198 | cpp | C++ | PSME/agent/storage/src/command/delete_iscsi_target.cpp | opencomputeproject/HWMgmt-DeviceMgr-PSME | 2a00188aab6f4bef3776987f0842ef8a8ea972ac | [
"Apache-2.0"
] | 5 | 2021-10-07T15:36:37.000Z | 2022-03-01T07:21:49.000Z | PSME/agent/storage/src/command/delete_iscsi_target.cpp | opencomputeproject/DM-Redfish-PSME | 912f7b6abf5b5c2aae33c75497de4753281c6a51 | [
"Apache-2.0"
] | null | null | null | PSME/agent/storage/src/command/delete_iscsi_target.cpp | opencomputeproject/DM-Redfish-PSME | 912f7b6abf5b5c2aae33c75497de4753281c6a51 | [
"Apache-2.0"
] | 1 | 2021-03-24T19:37:58.000Z | 2021-03-24T19:37:58.000Z | /*!
* @section LICENSE
*
* @copyright
* Copyright (c) 2015-2017 Intel Corporation
*
* @copyright
* 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
*
* @copyright
* http://www.apache.org/licenses/LICENSE-2.0
*
* @copyright
* 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.
*
* @section DESCRIPTION
* */
#include "agent-framework/module/storage_components.hpp"
#include "agent-framework/command-ref/registry.hpp"
#include "agent-framework/command-ref/storage_commands.hpp"
#include "agent-framework/eventing/event_data.hpp"
#include "iscsi/manager.hpp"
#include "iscsi/response.hpp"
#include "iscsi/tgt/config/tgt_config.hpp"
#include "iscsi/utils.hpp"
#include "event/storage_event.hpp"
using namespace agent_framework;
using namespace agent_framework::command_ref;
using namespace agent::storage::iscsi::tgt::config;
using namespace agent_framework::model;
using namespace agent_framework::model::enums;
using namespace agent_framework::model::attribute;
using namespace agent_framework::module;
using namespace agent_framework::module::managers;
using Errors = agent::storage::iscsi::tgt::Errors;
namespace {
static const constexpr char EMPTY_VALUE[] = "";
void remove_tgt_config_file(const string& target_iqn) {
const auto& iscsi_data =
get_manager<IscsiTarget, IscsiTargetManager>().get_iscsi_data();
TgtConfig tgtConfig(iscsi_data.get_configuration_path());
try {
tgtConfig.remove_target(target_iqn);
} catch (const std::exception& ex) {
log_warning(GET_LOGGER("storage-agent"),
"Unable to remove TGT target config file: " << ex.what());
}
}
void delete_iscsi_target(const DeleteIscsiTarget::Request& request,
DeleteIscsiTarget::Response&) {
const auto target_uuid = request.get_uuid();
const auto target = get_manager<IscsiTarget>().get_entry(target_uuid);
auto prev_chap_username = target.get_chap_username();
auto prev_mutual_chap_username = target.get_mutual_chap_username();
const auto target_id = get_manager<IscsiTarget, IscsiTargetManager>().
get_target_id(target.get_uuid());
::agent::storage::iscsi::tgt::Manager manager{};
// Delete CHAP account if exist
if (prev_chap_username.has_value() && prev_chap_username.value() != EMPTY_VALUE) {
try {
delete_chap_account(manager, prev_chap_username.value());
} catch (const std::exception &ex) {
log_warning(GET_LOGGER("storage-agent"),
"CHAP account delete operation failed: " << ex.what());
}
}
// Delete Mutual CHAP account if exist
if (prev_mutual_chap_username.has_value() && prev_mutual_chap_username.value() != EMPTY_VALUE) {
try {
delete_chap_account(manager, prev_mutual_chap_username.value());
} catch (const std::exception &ex) {
log_warning(GET_LOGGER("storage-agent"),
"Mutual CHAP account delete operation failed: " << ex.what());
}
}
auto tgt_response = manager.destroy_target(int(target_id));
if (!tgt_response.is_valid()) {
Errors::throw_exception(tgt_response.get_error(),
"Cannot destroy target: ");
}
remove_tgt_config_file(target.get_target_iqn());
get_manager<IscsiTarget, IscsiTargetManager>().
remove_target_id(target_id);
log_info(GET_LOGGER("storage-agent"), "iSCSI target removed: " << target_uuid);
get_manager<IscsiTarget>().remove_entry(target_uuid);
}
}
REGISTER_COMMAND(DeleteIscsiTarget, ::delete_iscsi_target);
| 37.150442 | 104 | 0.668652 | [
"model"
] |
c73c87b5085d07934384ff2fa7fcb14bbe5c9fff | 20,445 | cpp | C++ | testPerspShadows/src/demo/Shadows.cpp | aras-p/dingus | 22ef90c2bf01afd53c0b5b045f4dd0b59fe83009 | [
"MIT"
] | 17 | 2016-06-14T20:56:58.000Z | 2021-11-15T10:14:16.000Z | testPerspShadows/src/demo/Shadows.cpp | aras-p/dingus | 22ef90c2bf01afd53c0b5b045f4dd0b59fe83009 | [
"MIT"
] | null | null | null | testPerspShadows/src/demo/Shadows.cpp | aras-p/dingus | 22ef90c2bf01afd53c0b5b045f4dd0b59fe83009 | [
"MIT"
] | 5 | 2016-06-14T20:56:59.000Z | 2021-06-22T00:09:18.000Z | #include "stdafx.h"
#include "Shadows.h"
#include "ShadowBufferRTManager.h"
#include <dingus/gfx/GfxUtils.h>
#include "Hull.h"
extern bool gUseDSTShadows;
// --------------------------------------------------------------------------
SceneEntityPtrs gScene;
LightPtrs gLights;
struct ObjectInfo {
ObjectInfo( const CAABox& aabb_, SceneEntity& e ) : aabb(aabb_), entity(&e) { }
CAABox aabb; // world space
SceneEntity* entity;
};
std::vector<ObjectInfo> gSceneReceivers; // objects in view frustum
std::vector<ObjectInfo> gSceneCasters; // object extrusions in view frustum
CAABox gSceneBounds, gCasterBounds, gReceiverBounds;
static SVector3 gLightDir;
static SVector3 gLightColor;
static SMatrix4x4 gShadowTexProj;
static SVector3 gInvShadowSize;
// ---------------------------------------------------------------------------
#define FLT_AS_INT(F) (*(DWORD*)&(F))
#define FLT_ALMOST_ZERO(F) ((FLT_AS_INT(F) & 0x7f800000L)==0)
#define FLT_IS_SPECIAL(F) ((FLT_AS_INT(F) & 0x7f800000L)==0x7f800000L)
struct Frustum
{
Frustum( const SMatrix4x4& matrix );
bool TestSphere ( const SVector3& pos, float radius ) const;
//bool TestBox ( const CAABox& box ) const;
bool TestSweptSphere( const SVector3& pos, float radius, const SVector3& sweepDir ) const;
SPlane camPlanes[6];
SVector3 pntList[8];
int nVertexLUT[6];
};
// Computes the point where three planes intersect. Returns whether or not the point exists.
static inline bool PlaneIntersection( SVector3* intersectPt, const SPlane& p0, const SPlane& p1, const SPlane& p2 )
{
SVector3 n0( p0.a, p0.b, p0.c );
SVector3 n1( p1.a, p1.b, p1.c );
SVector3 n2( p2.a, p2.b, p2.c );
SVector3 n1_n2, n2_n0, n0_n1;
D3DXVec3Cross( &n1_n2, &n1, &n2 );
D3DXVec3Cross( &n2_n0, &n2, &n0 );
D3DXVec3Cross( &n0_n1, &n0, &n1 );
float cosTheta = n0.dot(n1_n2);
if( FLT_ALMOST_ZERO(cosTheta) || FLT_IS_SPECIAL(cosTheta) )
return false;
float secTheta = 1.0f / cosTheta;
n1_n2 = n1_n2 * p0.d;
n2_n0 = n2_n0 * p1.d;
n0_n1 = n0_n1 * p2.d;
*intersectPt = -(n1_n2 + n2_n0 + n0_n1) * secTheta;
return true;
}
Frustum::Frustum( const SMatrix4x4& matrix )
{
// build a view frustum based on the current view & projection matrices...
SVector4 column4( matrix._14, matrix._24, matrix._34, matrix._44 );
SVector4 column1( matrix._11, matrix._21, matrix._31, matrix._41 );
SVector4 column2( matrix._12, matrix._22, matrix._32, matrix._42 );
SVector4 column3( matrix._13, matrix._23, matrix._33, matrix._43 );
SVector4 planes[6];
planes[0] = column4 - column1; // left
planes[1] = column4 + column1; // right
planes[2] = column4 - column2; // bottom
planes[3] = column4 + column2; // top
planes[4] = column4 - column3; // near
planes[5] = column4 + column3; // far
int p;
for (p=0; p<6; p++) // normalize the planes
{
float dot = planes[p].x*planes[p].x + planes[p].y*planes[p].y + planes[p].z*planes[p].z;
dot = 1.0f / sqrtf(dot);
planes[p] = planes[p] * dot;
}
for (p=0; p<6; p++)
camPlanes[p] = SPlane( planes[p].x, planes[p].y, planes[p].z, planes[p].w );
// build a bit-field that will tell us the indices for the nearest and farthest vertices from each plane...
for (int i=0; i<6; i++)
nVertexLUT[i] = ((planes[i].x<0.f)?1:0) | ((planes[i].y<0.f)?2:0) | ((planes[i].z<0.f)?4:0);
for( int i=0; i<8; ++i ) // compute extrema
{
const SPlane& p0 = (i&1)?camPlanes[4] : camPlanes[5];
const SPlane& p1 = (i&2)?camPlanes[3] : camPlanes[2];
const SPlane& p2 = (i&4)?camPlanes[0] : camPlanes[1];
PlaneIntersection( &pntList[i], p0, p1, p2 );
}
}
bool Frustum::TestSphere( const SVector3& pos, float radius ) const
{
bool inside = true;
for( int i=0; (i<6) && inside; i++ )
inside &= ( (D3DXPlaneDotCoord(&camPlanes[i], &pos) + radius) >= 0.0f );
return inside;
}
// this function tests if the projection of a bounding sphere along the light direction intersects
// the view frustum
bool SweptSpherePlaneIntersect( float& t0, float& t1, const SPlane& plane, const SVector3& pos, float radius, const SVector3& sweepDir )
{
float b_dot_n = D3DXPlaneDotCoord(&plane, &pos);
float d_dot_n = D3DXPlaneDotNormal(&plane, &sweepDir);
if (d_dot_n == 0.f)
{
if (b_dot_n <= radius)
{
// effectively infinity
t0 = 0.f;
t1 = 1e32f;
return true;
}
else
return false;
}
else
{
float tmp0 = ( radius - b_dot_n) / d_dot_n;
float tmp1 = (-radius - b_dot_n) / d_dot_n;
t0 = min(tmp0, tmp1);
t1 = max(tmp0, tmp1);
return true;
}
}
bool Frustum::TestSweptSphere( const SVector3& pos, float radius, const SVector3& sweepDir ) const
{
// algorithm -- get all 12 intersection points of the swept sphere with the view frustum
// for all points >0, displace sphere along the sweep direction. if the displaced sphere
// is inside the frustum, return true. else, return false
float displacements[12];
int cnt = 0;
float a, b;
bool inFrustum = false;
for (int i=0; i<6; i++)
{
if (SweptSpherePlaneIntersect(a, b, camPlanes[i], pos, radius, sweepDir))
{
if (a>=0.f)
displacements[cnt++] = a;
if (b>=0.f)
displacements[cnt++] = b;
}
}
for (int i=0; i<cnt; i++)
{
SVector3 displPos = pos + sweepDir * displacements[i];
float displRadius = radius * 1.1f;
inFrustum |= TestSphere( displPos, displRadius );
}
return inFrustum;
}
// --------------------------------------------------------------------------
void CalculateSceneBounds()
{
gSceneBounds.setNull();
size_t n = gScene.size();
for( size_t i = 0; i < n; ++i )
{
CAABox b = gScene[i]->getAABB();
b.transform( gScene[i]->mWorldMat );
gSceneBounds.extend( b );
}
}
// Computes region-of-interest for the camera based on swept-sphere/frustum intersection.
// If the swept sphere representing the extrusion of an object's bounding
// sphere along the light direction intersects the view frustum, the object is added to
// a list of interesting shadow casters. The field of view is the minimum cone containing
// all eligible bounding spheres.
void ComputeInterestingSceneParts( const SVector3& lightDir, const SMatrix4x4& cameraViewProj )
{
bool hit = false;
SVector3 sweepDir = lightDir;
// camera frustum
Frustum sceneFrustum( cameraViewProj );
gSceneReceivers.clear();
gSceneCasters.clear();
gCasterBounds.setNull();
gReceiverBounds.setNull();
size_t n = gScene.size();
for( size_t i = 0; i < n; ++i )
{
SceneEntity& obj = *gScene[i];
CAABox aabb = obj.getAABB();
aabb.transform( obj.mWorldMat );
if( aabb.frustumCull( cameraViewProj ) )
{
SVector3 spherePos = aabb.getCenter();
float sphereRadius = SVector3(aabb.getMax()-aabb.getMin()).length() / 2;
if( sceneFrustum.TestSweptSphere( spherePos, sphereRadius, sweepDir ) )
{
hit = true;
gSceneCasters.push_back( ObjectInfo(aabb,obj) ); // originally in view space
gCasterBounds.extend( aabb );
}
}
else
{
hit = true;
gSceneCasters.push_back( ObjectInfo(aabb,obj) ); // originally in view space
gSceneReceivers.push_back( ObjectInfo(aabb,obj) ); // originally in view space
gCasterBounds.extend( aabb );
gReceiverBounds.extend( aabb );
}
}
}
static void CalculateOrthoShadow( const CCameraEntity& cam, Light& light )
{
SVector3 target = gCasterBounds.getCenter();
SVector3 size = gCasterBounds.getMax() - gCasterBounds.getMin();
float radius = size.length() * 0.5f;
// figure out the light camera matrix that encloses whole scene
light.mWorldMat.spaceFromAxisZ();
light.mWorldMat.getOrigin() = target - light.mWorldMat.getAxisZ() * radius;
light.setOrthoParams( radius*2, radius*2, radius*0.1f, radius*2 );
light.setOntoRenderContext();
}
static void CalculateLisPSM( const CCameraEntity& cam, Light& light )
{
CalculateOrthoShadow( cam, light );
const SVector3& lightDir = light.mWorldMat.getAxisZ();
const SVector3& viewDir = cam.mWorldMat.getAxisZ();
double dotProd = lightDir.dot( viewDir );
if( fabs(dotProd) >= 0.999 )
{
// degenerates to uniform shadow map
return;
}
// calculate the hull of body B in world space
HullFace bodyB;
SMatrix4x4 invCamVP;
D3DXMatrixInverse( &invCamVP, NULL, &cam.mWorldMat );
invCamVP *= cam.getProjectionMatrix();
D3DXMatrixInverse( &invCamVP, NULL, &invCamVP );
CalculateFocusedLightHull( invCamVP, lightDir, gCasterBounds, bodyB );
int zzz = bodyB.v.size();
int i, j;
/*
Frustum camFrustum( cam.getProjectionMatrix() );
std::vector<SVector3> bodyB;
bodyB.reserve( gSceneCasters.size()*8 + 8 );
for( i = 0; i < 8; ++i )
bodyB.push_back( camFrustum.pntList[i] );
int ncasters = gSceneCasters.size();
for( i = 0; i < ncasters; ++i )
{
const CAABox& aabb = gSceneCasters[i].aabb;
for( j = 0; j < 8; ++j )
{
SVector3 p;
p.x = (j&1) ? aabb.getMin().x : aabb.getMax().x;
p.y = (j&2) ? aabb.getMin().y : aabb.getMax().y;
p.z = (j&4) ? aabb.getMin().z : aabb.getMax().z;
bodyB.push_back( p );
}
}
*/
// calculate basis of light space projection
SVector3 ly = -lightDir;
SVector3 lx = ly.cross( viewDir ).getNormalized();
SVector3 lz = lx.cross( ly );
SMatrix4x4 lightW;
lightW.identify();
lightW.getAxisX() = lx;
lightW.getAxisY() = ly;
lightW.getAxisZ() = lz;
SMatrix4x4 lightV;
D3DXMatrixInverse( &lightV, NULL, &lightW );
// rotate bound body points from world into light projection space and calculate AABB there
D3DXVec3TransformCoordArray( &bodyB.v[0], sizeof(SVector3), &bodyB.v[0], sizeof(SVector3), &lightV, bodyB.v.size() );
CAABox bodyLBounds;
bodyLBounds.setNull();
for( i = 0; i < bodyB.v.size(); ++i )
bodyLBounds.extend( bodyB.v[i] );
float zextent = cam.getZFar() - cam.getZNear();
float zLextent = bodyLBounds.getMax().z - bodyLBounds.getMin().z;
if( zLextent < zextent )
zextent = zLextent;
// calculate free parameter N
double sinGamma = sqrt( 1.0-dotProd*dotProd );
const double n = ( cam.getZNear() + sqrt(cam.getZNear() * (cam.getZNear() + zextent)) ) / sinGamma;
// origin in this light space: looking at center of bounds, from distance n
SVector3 lightSpaceO = bodyLBounds.getCenter();
lightSpaceO.z = bodyLBounds.getMin().z - n;
// go through bound points in light space, and compute projected bound
float maxx = 0.0f, maxy = 0.0f, maxz = 0.0f;
for( i = 0; i < bodyB.v.size(); ++i )
{
SVector3 tmp = bodyB.v[i] - lightSpaceO;
assert( tmp.z > 0.0f );
maxx = max( maxx, fabsf(tmp.x / tmp.z) );
maxy = max( maxy, fabsf(tmp.y / tmp.z) );
maxz = max( maxz, tmp.z );
}
SVector3 lpos;
D3DXVec3TransformCoord( &lpos, &lightSpaceO, &lightW );
lightW.getOrigin() = lpos;
SMatrix4x4 lightProj;
D3DXMatrixPerspectiveLH( &lightProj, 2.0f*maxx*n, 2.0f*maxy*n, n, maxz );
SMatrix4x4 lsPermute, lsOrtho;
lsPermute._11 = 1.f; lsPermute._12 = 0.f; lsPermute._13 = 0.f; lsPermute._14 = 0.f;
lsPermute._21 = 0.f; lsPermute._22 = 0.f; lsPermute._23 =-1.f; lsPermute._24 = 0.f;
lsPermute._31 = 0.f; lsPermute._32 = 1.f; lsPermute._33 = 0.f; lsPermute._34 = 0.f;
lsPermute._41 = 0.f; lsPermute._42 = -0.5f; lsPermute._43 = 1.5f; lsPermute._44 = 1.f;
D3DXMatrixOrthoLH( &lsOrtho, 2.f, 1.f, 0.5f, 2.5f );
lsPermute *= lsOrtho;
lightProj *= lsPermute;
G_RENDERCTX->getCamera().setCameraMatrix( lightW );
SMatrix4x4 lightFinal = G_RENDERCTX->getCamera().getViewMatrix() * lightProj;
// unit cube clipping
/*
{
// receiver hull
std::vector<SVector3> receiverPts;
receiverPts.reserve( gSceneReceivers.size() * 8 );
int nreceivers = gSceneReceivers.size();
for( i = 0; i < nreceivers; ++i )
{
const CAABox& aabb = gSceneReceivers[i].aabb;
for( j = 0; j < 8; ++j )
{
SVector3 p;
p.x = (j&1) ? aabb.getMin().x : aabb.getMax().x;
p.y = (j&2) ? aabb.getMin().y : aabb.getMax().y;
p.z = (j&4) ? aabb.getMin().z : aabb.getMax().z;
receiverPts.push_back( p );
}
}
// transform to light post-perspective space
D3DXVec3TransformCoordArray( &receiverPts[0], sizeof(SVector3), &receiverPts[0], sizeof(SVector3), &lightFinal, receiverPts.size() );
CAABox recvBounds;
recvBounds.setNull();
for( i = 0; i < receiverPts.size(); ++i )
recvBounds.extend( receiverPts[i] );
recvBounds.getMax().x = min( 1.f, recvBounds.getMax().x );
recvBounds.getMin().x = max(-1.f, recvBounds.getMin().x );
recvBounds.getMax().y = min( 1.f, recvBounds.getMax().y );
recvBounds.getMin().y = max(-1.f, recvBounds.getMin().y );
float boxWidth = recvBounds.getMax().x - recvBounds.getMin().x;
float boxHeight = recvBounds.getMax().y - recvBounds.getMin().y;
if( !FLT_ALMOST_ZERO(boxWidth) && !FLT_ALMOST_ZERO(boxHeight) )
{
float boxX = ( recvBounds.getMax().x + recvBounds.getMin().x ) * 0.5f;
float boxY = ( recvBounds.getMax().y + recvBounds.getMin().y ) * 0.5f;
SMatrix4x4 clipMatrix(
2.f/boxWidth, 0.f, 0.f, 0.f,
0.f, 2.f/boxHeight, 0.f, 0.f,
0.f, 0.f, 1.f, 0.f,
-2.f*boxX/boxWidth, -2.f*boxY/boxHeight, 0.f, 1.f );
lightProj *= clipMatrix;
}
}
*/
G_RENDERCTX->getCamera().setProjectionMatrix( lightProj );
}
void Light::PrepareAndSetOntoRenderContext( const CCameraEntity& cam, bool lispsm )
{
SMatrix4x4 viewProj;
D3DXMatrixInverse( &viewProj, NULL, &cam.mWorldMat );
viewProj *= cam.getProjectionMatrix();
ComputeInterestingSceneParts( mWorldMat.getAxisZ(), viewProj );
if( lispsm )
CalculateLisPSM( cam, *this );
else
CalculateOrthoShadow( cam, *this );
m_DebugViewProjMatrix = G_RENDERCTX->getCamera().getViewProjMatrix();
// calculate the rest of matrices for shadow projections
gfx::textureProjectionWorld( G_RENDERCTX->getCamera().getViewProjMatrix(), float(m_RTSize), float(m_RTSize), m_TextureProjMatrix );
}
// --------------------------------------------------------------------------
const char* FX_NAMES[RMCOUNT] = {
"object",
"zfill",
"caster",
};
SceneEntity::SceneEntity( const std::string& name )
: mMesh(0)
, m_CanAnimate(false)
{
assert( !name.empty() );
mMesh = RGET_MESH(name);
if( name=="Teapot" || name=="Torus" || name=="Table" )
m_CanAnimate = true;
for( int i = 0; i < RMCOUNT; ++i ) {
CRenderableMesh* rr = new CRenderableMesh( *mMesh, CRenderableMesh::ALL_GROUPS, &mWorldMat.getOrigin(), 0 );
mRenderMeshes[i] = rr;
rr->getParams().setEffect( *RGET_FX(FX_NAMES[i]) );
addMatricesToParams( rr->getParams() );
}
CEffectParams& ep = mRenderMeshes[RM_NORMAL]->getParams();
ep.addVector3Ref( "vLightDir", gLightDir );
ep.addVector3Ref( "vLightColor", gLightColor );
ep.addMatrix4x4Ref( "mShadowProj", gShadowTexProj );
ep.addVector3Ref( "vInvShadowSize", gInvShadowSize );
ep.addVector3Ref( "vColor", m_Color );
}
SceneEntity::~SceneEntity()
{
for( int i = 0; i < RMCOUNT; ++i )
delete mRenderMeshes[i];
}
void SceneEntity::render( eRenderMode renderMode, bool updateWVP, bool direct )
{
assert( mRenderMeshes[renderMode] );
if( updateWVP )
updateWVPMatrices();
if( direct )
G_RENDERCTX->directRender( *mRenderMeshes[renderMode] );
else
G_RENDERCTX->attach( *mRenderMeshes[renderMode] );
}
// --------------------------------------------------------------------------
void RenderSceneWithShadows( CCameraEntity& camera, CCameraEntity& actualCamera, float shadowQuality, bool lispsm )
{
gShadowRTManager->BeginFrame();
size_t i, j;
size_t nsceneobjs = gScene.size();
size_t nlights = gLights.size();
// Render the shadow buffers
CD3DDevice& dx = CD3DDevice::getInstance();
if( gUseDSTShadows )
{
const float kDepthBias = 0.0005f;
const float kSlopeBias = 2.0f;
dx.getStateManager().SetRenderState( D3DRS_COLORWRITEENABLE, 0 );
dx.getStateManager().SetRenderState( D3DRS_DEPTHBIAS, *(DWORD*)&kDepthBias );
dx.getStateManager().SetRenderState( D3DRS_SLOPESCALEDEPTHBIAS, *(DWORD*)&kSlopeBias );
}
for( i = 0; i < nlights; ++i )
{
Light& light = *gLights[i];
light.m_RTSize = 1 << int(shadowQuality);
bool ok = gShadowRTManager->RequestBuffer(
light.m_RTSize,
&light.m_RTTexture,
&light.m_RTSurface );
// set render target to this SB
if( gUseDSTShadows )
{
dx.setRenderTarget( gShadowRTManager->FindDepthBuffer( light.m_RTSize ) );
dx.setZStencil( light.m_RTSurface );
dx.clearTargets( false, true, false, 0xFFffffff, 1.0f );
}
else
{
dx.setRenderTarget( light.m_RTSurface );
dx.setZStencil( gShadowRTManager->FindDepthBuffer( light.m_RTSize ) );
dx.clearTargets( true, true, false, 0xFFffffff, 1.0f );
}
// calculate and set SB camera matrices
light.PrepareAndSetOntoRenderContext( camera, lispsm );
G_RENDERCTX->applyGlobalEffect();
// render all casters
G_RENDERCTX->directBegin();
size_t ncasters = gSceneCasters.size();
for( j = 0; j < ncasters; ++j )
gSceneCasters[j].entity->render( RM_CASTER, true, true );
G_RENDERCTX->directEnd();
}
if( gUseDSTShadows )
{
dx.getStateManager().SetRenderState( D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_RED|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_ALPHA );
const float temp = 0.0f;
dx.getStateManager().SetRenderState( D3DRS_DEPTHBIAS, *(DWORD*)&temp );
dx.getStateManager().SetRenderState( D3DRS_SLOPESCALEDEPTHBIAS, *(DWORD*)&temp );
}
// Render the main camera with all the shadows and lights and whatever
dx.setDefaultRenderTarget();
dx.setDefaultZStencil();
dx.clearTargets( true, true, false, 0x606060, 1.0f );
actualCamera.setOntoRenderContext();
G_RENDERCTX->applyGlobalEffect();
// lay down depth for all visible objects
G_RENDERCTX->directBegin();
size_t nreceivers = gSceneReceivers.size();
for( i = 0; i < nreceivers; ++i )
{
gSceneReceivers[i].entity->render( RM_ZFILL, true, true );
}
// additive lighting
dx.getStateManager().SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
dx.getStateManager().SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
dx.getStateManager().SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
dx.getStateManager().SetRenderState( D3DRS_ZWRITEENABLE, FALSE );
dx.getStateManager().SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
// shadow map sampling
if( gUseDSTShadows )
{
dx.getStateManager().SetSamplerState( kShaderShadowTextureIndex, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
dx.getStateManager().SetSamplerState( kShaderShadowTextureIndex, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
dx.getStateManager().SetSamplerState( kShaderShadowTextureIndex, D3DSAMP_MIPFILTER, D3DTEXF_NONE );
dx.getStateManager().SetSamplerState( kShaderShadowTextureIndex, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP );
dx.getStateManager().SetSamplerState( kShaderShadowTextureIndex, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP );
}
else
{
dx.getStateManager().SetSamplerState( kShaderShadowTextureIndex, D3DSAMP_MAGFILTER, D3DTEXF_POINT );
dx.getStateManager().SetSamplerState( kShaderShadowTextureIndex, D3DSAMP_MINFILTER, D3DTEXF_POINT );
dx.getStateManager().SetSamplerState( kShaderShadowTextureIndex, D3DSAMP_MIPFILTER, D3DTEXF_POINT );
}
// render all objects with shadows and lights
for( i = 0; i < nreceivers; ++i )
{
SceneEntity& obj = *gSceneReceivers[i].entity;
// additively render all lights on this object
for( size_t j = 0; j < nlights; ++j )
{
Light& light = *gLights[j];
// set the SB
dx.getStateManager().SetTexture( kShaderShadowTextureIndex, light.m_RTTexture->getObject() );
// set light constants
gLightDir = light.mWorldMat.getAxisZ();
gLightColor = light.m_Color;
gShadowTexProj = light.m_TextureProjMatrix;
gInvShadowSize.x = 1.0f / light.m_RTSize;
gInvShadowSize.y = 1.0f / light.m_RTSize;
obj.render( RM_NORMAL, false, true );
}
}
dx.getStateManager().SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
dx.getStateManager().SetRenderState( D3DRS_ZWRITEENABLE, TRUE );
dx.getStateManager().SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
G_RENDERCTX->directEnd();
}
// --------------------------------------------------------------------------
| 32.247634 | 167 | 0.658107 | [
"render",
"object",
"vector",
"transform"
] |
c73e02aa4d3b5a65c47420289304bbd75c2704e7 | 2,980 | cpp | C++ | SyndicateCore/Core/Utilities/File.cpp | askamn/Venus-Game-Engine | 9787fb4f03fcd99b9a9cce92730fb3ba86acd6b5 | [
"MIT"
] | null | null | null | SyndicateCore/Core/Utilities/File.cpp | askamn/Venus-Game-Engine | 9787fb4f03fcd99b9a9cce92730fb3ba86acd6b5 | [
"MIT"
] | null | null | null | SyndicateCore/Core/Utilities/File.cpp | askamn/Venus-Game-Engine | 9787fb4f03fcd99b9a9cce92730fb3ba86acd6b5 | [
"MIT"
] | null | null | null | #include "File.h"
namespace Syndicate {
namespace Utilities {
File::File() :
fileSize(0),
filePath(""),
m_NoRead(true)
{
}
File::File(std::string path, bool binary) :
m_NoRead(true)
{
this->filePath = path;
this->fileType = (binary == true) ? FILETYPE::BINARY : FILETYPE::TEXT;
this->fileSize = 0;
std::fstream file;
}
File& File::Read(int mode)
{
if (!this->filePath.length())
{
SYNDICATE_ERROR("File path is empty.");
return *this;
}
if (this->fileType == FILETYPE::BINARY)
{
mode |= std::ios::binary;
}
std::ifstream file(this->filePath, mode);
if (file.fail())
{
SYNDICATE_ERROR( "Failed to open file: " + this->filePath );
return *this;
}
if (file.is_open())
{
// Calculate the amount to be read (for binary files)
std::streampos startPos = file.tellg(), endPos;
file.seekg(0, std::ios::end);
endPos = file.tellg();
// Reset the file pointer
file.seekg(0, std::ios::beg);
this->readSize = endPos - startPos;
this->fileSize = this->readSize;
this->data = this->_Read(file);
return *this;
}
else
{
SYNDICATE_ERROR("Failed to open file: " + this->filePath);
return *this;
}
}
File& File::Read(std::streampos startPos, int mode)
{
if (!this->filePath.length())
{
SYNDICATE_ERROR("File path is empty.");
return *this;
}
if (this->fileType == FILETYPE::BINARY)
{
mode |= std::ios::binary;
}
std::ifstream file(this->filePath, mode);
if (file.is_open())
{
// Calculate the amount to be read (for binary files)
file.seekg(0, std::ios::end);
std::streampos endPos = file.tellg();
// Reset the file pointer
file.seekg(startPos, std::ios::beg);
this->readSize = endPos - startPos;
this->fileSize = endPos;
this->data = this->_Read(file);
return *this;
}
else
{
SYNDICATE_ERROR("Failed to open file: " + this->filePath);
return *this;
}
}
File& File::Read(std::streampos startPos, std::streampos endPos, int mode)
{
if (!this->filePath.length())
{
SYNDICATE_ERROR("File path is empty.");
return *this;
}
if (this->fileType == FILETYPE::BINARY)
{
mode |= std::ios::binary;
}
std::ifstream file(this->filePath, mode);
if (file.is_open())
{
this->fileSize = endPos;
this->readSize = endPos - startPos;
this->data = this->_Read(file);
return *this;
}
else
{
SYNDICATE_ERROR("Failed to open file: " + this->filePath);
return *this;
}
}
std::vector<char> File::_Read(std::ifstream& file)
{
std::vector<char> buffer;
if (this->fileType == FILETYPE::BINARY)
{
file.seekg(0, std::ios::beg);
if (!file)
{
SYNDICATE_ERROR("Failed to read from file!");
return buffer;
}
buffer.resize(this->readSize);
file.read(&buffer[0], this->readSize);
}
else
{
std::string line;
while (std::getline(file, line))
{
line += "\n";
std::copy(line.begin(), line.end(), std::back_inserter(buffer));
line.clear();
}
}
file.close();
// Data was read
m_NoRead = false;
return buffer;
}
File::~File()
{
}
}} | 16.931818 | 74 | 0.630872 | [
"vector"
] |
c7416902fdcb1ab79bbe482432f4fc9c1019da2e | 1,922 | cpp | C++ | lib/async/src/pipe/Connection.cpp | astateful/dyplat | 37c37c7ee9f55cc2a3abaa0f8ebbde34588d2f44 | [
"BSD-3-Clause"
] | null | null | null | lib/async/src/pipe/Connection.cpp | astateful/dyplat | 37c37c7ee9f55cc2a3abaa0f8ebbde34588d2f44 | [
"BSD-3-Clause"
] | null | null | null | lib/async/src/pipe/Connection.cpp | astateful/dyplat | 37c37c7ee9f55cc2a3abaa0f8ebbde34588d2f44 | [
"BSD-3-Clause"
] | null | null | null | #include "pipe/Connection.hpp"
#include <cassert>
namespace astateful {
namespace async {
namespace pipe {
Connection::Connection( flag_e flag ) :
m_flag( flag ),
async::Connection() {}
Connection::Connection( flag_e flag, const std::vector<uint8_t>& buffer ) :
async::Connection( buffer ),
m_flag( flag ) {}
bool Connection::transfer( HANDLE handle ) {
if ( m_flag == flag_e::READ ) {
return read( handle );
} else if ( m_flag == flag_e::WRITE ) {
return write( handle );
} else if ( m_flag == flag_e::DONE ) {
assert( CloseHandle( handle ) );
return false;
}
return false;
}
int Connection::write( HANDLE handle ) {
ZeroMemory( &overlapped, sizeof( WSAOVERLAPPED ) );
if ( WriteFile( handle,
&m_buffer[0],
m_buffer.size(),
nullptr,
&( overlapped ) ) == TRUE ) return true;
auto last_error = GetLastError();
switch ( last_error ) {
case ERROR_IO_PENDING:
return true;
break;
case ERROR_INVALID_HANDLE:
return false;
break;
default:
assert( false );
break;
}
return false;
}
int Connection::read( HANDLE handle ) {
ZeroMemory( &overlapped, sizeof( WSAOVERLAPPED ) );
if ( ReadFile( handle,
&m_buffer[0],
m_buffer.size(),
nullptr,
&( overlapped ) ) == TRUE ) return true;
auto last_error = GetLastError();
switch ( last_error ) {
case ERROR_IO_PENDING:
return true;
break;
case ERROR_INVALID_HANDLE:
return false;
break;
// This is triggered when a fake event is sent when shutting down
// server; we are waiting for a process that will never take place
// so return false.
case ERROR_PIPE_LISTENING:
return false;
break;
default:
assert( false );
break;
}
return false;
}
}
}
}
| 21.840909 | 77 | 0.58897 | [
"vector"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.