hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
108
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
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
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
4d43e6ac29ce9ba140e1b403f5f6232d4ee5a463
10,288
cpp
C++
modules/ocl/cl_3a_stats_context.cpp
DennissimOS/platform_external_libxcam
97f8476916e67917026de4c6e43c12d2fa1d68c7
[ "Apache-2.0" ]
1
2022-02-14T09:32:03.000Z
2022-02-14T09:32:03.000Z
modules/ocl/cl_3a_stats_context.cpp
DennissimOS/platform_external_libxcam
97f8476916e67917026de4c6e43c12d2fa1d68c7
[ "Apache-2.0" ]
null
null
null
modules/ocl/cl_3a_stats_context.cpp
DennissimOS/platform_external_libxcam
97f8476916e67917026de4c6e43c12d2fa1d68c7
[ "Apache-2.0" ]
null
null
null
/* * cl_3a_stats_context.cpp - CL 3a stats context * * Copyright (c) 2015 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Author: Wind Yuan <feng.yuan@intel.com> * Author: Jia Meng <jia.meng@intel.com> */ #include <xcam_std.h> #include "cl_3a_stats_context.h" namespace XCam { CL3AStatsCalculatorContext::CL3AStatsCalculatorContext (const SmartPtr<CLContext> &context) : _context (context) , _width_factor (1) , _height_factor (1) , _factor_shift (0) , _data_allocated (false) { _stats_pool = new X3aStatsPool (); } CL3AStatsCalculatorContext::~CL3AStatsCalculatorContext () { clean_up_data (); } void CL3AStatsCalculatorContext::set_bit_depth (uint32_t bits) { XCAM_ASSERT (_stats_pool.ptr ()); _stats_pool->set_bit_depth (bits); } bool CL3AStatsCalculatorContext::allocate_data (const VideoBufferInfo &buffer_info, uint32_t width_factor, uint32_t height_factor) { uint32_t multiply_factor = 0; _stats_pool->set_video_info (buffer_info); XCAM_FAIL_RETURN ( WARNING, _stats_pool->reserve (32), // need reserve more if as attachement false, "reserve cl stats buffer failed"); _stats_info = _stats_pool->get_stats_info (); XCAM_ASSERT ((width_factor & (width_factor - 1)) == 0 && (height_factor & (height_factor - 1)) == 0); _width_factor = width_factor; _height_factor = height_factor; multiply_factor = width_factor * height_factor; _factor_shift = 0; while ((multiply_factor >>= 1) != 0) { ++_factor_shift; } _stats_mem_size = _stats_info.aligned_width * _width_factor * _stats_info.aligned_height * _height_factor * sizeof (CL3AStatsStruct); for (uint32_t i = 0; i < XCAM_CL_3A_STATS_BUFFER_COUNT; ++i) { SmartPtr<CLBuffer> buf_new = new CLBuffer ( _context, _stats_mem_size); XCAM_ASSERT (buf_new.ptr ()); XCAM_FAIL_RETURN ( WARNING, buf_new->is_valid (), false, "allocate cl stats buffer failed"); _stats_cl_buffers.push (buf_new); } _data_allocated = true; return true; } void CL3AStatsCalculatorContext::pre_stop () { if (_stats_pool.ptr ()) _stats_pool->stop (); _stats_cl_buffers.pause_pop (); _stats_cl_buffers.wakeup (); } void CL3AStatsCalculatorContext::clean_up_data () { _data_allocated = false; _stats_cl_buffers.pause_pop (); _stats_cl_buffers.wakeup (); _stats_cl_buffers.clear (); } SmartPtr<CLBuffer> CL3AStatsCalculatorContext::get_buffer () { SmartPtr<CLBuffer> buf = _stats_cl_buffers.pop (); return buf; } bool CL3AStatsCalculatorContext::release_buffer (SmartPtr<CLBuffer> &buf) { XCAM_ASSERT (buf.ptr ()); if (!buf.ptr ()) return false; return _stats_cl_buffers.push (buf); } void debug_print_3a_stats (XCam3AStats *stats_ptr) { static int frames = 0; frames++; printf ("********frame(%d) debug 3a stats(%dbits) \n", frames, stats_ptr->info.bit_depth); for (int y = 30; y < 60; ++y) { printf ("---- y "); for (int x = 40; x < 80; ++x) printf ("%4d ", stats_ptr->stats[y * stats_ptr->info.aligned_width + x].avg_y); printf ("\n"); } #if 0 #define DUMP_STATS(ch, w, h, aligned_w, stats) do { \ printf ("stats " #ch ":"); \ for (uint32_t y = 0; y < h; ++y) { \ for (uint32_t x = 0; x < w; ++x) \ printf ("%3d ", stats[y * aligned_w + x].avg_##ch); \ } \ printf ("\n"); \ } while (0) DUMP_STATS (r, stats_ptr->info.width, stats_ptr->info.height, stats_ptr->info.aligned_width, stats_ptr->stats); DUMP_STATS (gr, stats_ptr->info.width, stats_ptr->info.height, stats_ptr->info.aligned_width, stats_ptr->stats); DUMP_STATS (gb, stats_ptr->info.width, stats_ptr->info.height, stats_ptr->info.aligned_width, stats_ptr->stats); DUMP_STATS (b, stats_ptr->info.width, stats_ptr->info.height, stats_ptr->info.aligned_width, stats_ptr->stats); DUMP_STATS (y, stats_ptr->info.width, stats_ptr->info.height, stats_ptr->info.aligned_width, stats_ptr->stats); #endif } void debug_print_histogram (XCam3AStats *stats_ptr) { #define DUMP_HISTOGRAM(ch, bins, hist) do { \ printf ("histogram " #ch ":"); \ for (uint32_t i = 0; i < bins; i++) { \ if (i % 16 == 0) printf ("\n"); \ printf ("%4d ", hist[i].ch); \ } \ printf ("\n"); \ } while (0) DUMP_HISTOGRAM (r, stats_ptr->info.histogram_bins, stats_ptr->hist_rgb); DUMP_HISTOGRAM (gr, stats_ptr->info.histogram_bins, stats_ptr->hist_rgb); DUMP_HISTOGRAM (gb, stats_ptr->info.histogram_bins, stats_ptr->hist_rgb); DUMP_HISTOGRAM (b, stats_ptr->info.histogram_bins, stats_ptr->hist_rgb); printf ("histogram y:"); for (uint32_t i = 0; i < stats_ptr->info.histogram_bins; i++) { if (i % 16 == 0) printf ("\n"); printf ("%4d ", stats_ptr->hist_y[i]); } printf ("\n"); } SmartPtr<X3aStats> CL3AStatsCalculatorContext::copy_stats_out (const SmartPtr<CLBuffer> &stats_cl_buf) { SmartPtr<VideoBuffer> buffer; SmartPtr<X3aStats> stats; SmartPtr<CLEvent> event = new CLEvent; XCam3AStats *stats_ptr = NULL; XCamReturn ret = XCAM_RETURN_NO_ERROR; void *buf_ptr = NULL; const CL3AStatsStruct *cl_buf_ptr = NULL; XCAM_ASSERT (stats_cl_buf.ptr ()); buffer = _stats_pool->get_buffer (_stats_pool); XCAM_FAIL_RETURN (WARNING, buffer.ptr (), NULL, "3a stats pool stopped."); stats = buffer.dynamic_cast_ptr<X3aStats> (); XCAM_ASSERT (stats.ptr ()); stats_ptr = stats->get_stats (); ret = stats_cl_buf->enqueue_map ( buf_ptr, 0, _stats_mem_size, CL_MAP_READ, CLEvent::EmptyList, event); XCAM_FAIL_RETURN (WARNING, ret == XCAM_RETURN_NO_ERROR, NULL, "3a stats enqueue read buffer failed."); XCAM_ASSERT (event->get_event_id ()); ret = event->wait (); XCAM_FAIL_RETURN (WARNING, ret == XCAM_RETURN_NO_ERROR, NULL, "3a stats buffer enqueue event wait failed"); cl_buf_ptr = (const CL3AStatsStruct*)buf_ptr; XCAM_ASSERT (stats_ptr); memset (stats_ptr->stats, 0, sizeof (XCamGridStat) * _stats_info.aligned_width * _stats_info.aligned_height); //uint32_t avg_factor = _width_factor * _height_factor; //uint32_t avg_round_pading = avg_factor / 2; uint32_t cl_stats_width = _stats_info.aligned_width * _width_factor; for (uint32_t h = 0; h < _stats_info.height; ++h) { XCamGridStat *grid_stats_line = &stats_ptr->stats[_stats_info.aligned_width * h]; uint32_t end_i_h = (h + 1) * _height_factor; for (uint32_t i_h = h * _height_factor; i_h < end_i_h; ++i_h) { const CL3AStatsStruct *cl_stats_line = &cl_buf_ptr[cl_stats_width * i_h]; for (uint32_t w = 0; w < _stats_info.width; ++w) { uint32_t end_i_w = (w + 1) * _width_factor; for (uint32_t i_w = w * _width_factor; i_w < end_i_w; ++i_w) { //grid_stats_line[w].avg_y += (cl_stats_line[i_w].avg_y + avg_round_pading) / avg_factor; grid_stats_line[w].avg_y += (cl_stats_line[i_w].avg_y >> _factor_shift); grid_stats_line[w].avg_r += (cl_stats_line[i_w].avg_r >> _factor_shift); grid_stats_line[w].avg_gr += (cl_stats_line[i_w].avg_gr >> _factor_shift); grid_stats_line[w].avg_gb += (cl_stats_line[i_w].avg_gb >> _factor_shift); grid_stats_line[w].avg_b += (cl_stats_line[i_w].avg_b >> _factor_shift); grid_stats_line[w].valid_wb_count += cl_stats_line[i_w].valid_wb_count; grid_stats_line[w].f_value1 += cl_stats_line[i_w].f_value1; grid_stats_line[w].f_value2 += cl_stats_line[i_w].f_value2; } } } } event.release (); SmartPtr<CLEvent> unmap_event = new CLEvent; ret = stats_cl_buf->enqueue_unmap (buf_ptr, CLEvent::EmptyList, unmap_event); XCAM_FAIL_RETURN (WARNING, ret == XCAM_RETURN_NO_ERROR, NULL, "3a stats buffer enqueue unmap failed"); ret = unmap_event->wait (); XCAM_FAIL_RETURN (WARNING, ret == XCAM_RETURN_NO_ERROR, NULL, "3a stats buffer enqueue unmap event wait failed"); unmap_event.release (); //debug_print_3a_stats (stats_ptr); fill_histogram (stats_ptr); //debug_print_histogram (stats_ptr); return stats; } bool CL3AStatsCalculatorContext::fill_histogram (XCam3AStats * stats) { const XCam3AStatsInfo &stats_info = stats->info; const XCamGridStat *grid_stat; XCamHistogram *hist_rgb = stats->hist_rgb; uint32_t *hist_y = stats->hist_y; memset (hist_rgb, 0, sizeof(XCamHistogram) * stats_info.histogram_bins); memset (hist_y, 0, sizeof(uint32_t) * stats_info.histogram_bins); for (uint32_t i = 0; i < stats_info.width; i++) { for (uint32_t j = 0; j < stats_info.height; j++) { grid_stat = &stats->stats[j * stats_info.aligned_width + i]; hist_rgb[grid_stat->avg_r].r++; hist_rgb[grid_stat->avg_gr].gr++; hist_rgb[grid_stat->avg_gb].gb++; hist_rgb[grid_stat->avg_b].b++; hist_y[grid_stat->avg_y]++; } } return true; } }
35.972028
125
0.62325
DennissimOS
4d44b1b692af90d9d08a1683c0f764dcef412996
2,975
cpp
C++
Source/Example/example_LuaLibrary.cpp
mf01/luacpp
ff06f2c5062968616d8e50162148f6cd070d124e
[ "MIT" ]
19
2021-08-29T23:16:02.000Z
2022-03-25T13:16:14.000Z
Source/Example/example_LuaLibrary.cpp
mf01/luacpp
ff06f2c5062968616d8e50162148f6cd070d124e
[ "MIT" ]
3
2021-07-23T19:05:05.000Z
2022-02-27T05:33:26.000Z
Source/Example/example_LuaLibrary.cpp
mf01/luacpp
ff06f2c5062968616d8e50162148f6cd070d124e
[ "MIT" ]
8
2021-03-29T07:39:04.000Z
2022-02-24T18:16:42.000Z
/* MIT License Copyright (c) 2021 Jordan Vrtanoski 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 "../LuaCpp.hpp" #include <iostream> #include <stdexcept> using namespace LuaCpp; using namespace LuaCpp::Registry; using namespace LuaCpp::Engine; extern "C" { static int _foo (lua_State *L, int start) { int n = lua_gettop(L); /* number of arguments */ lua_Number sum = 0.0; int i; for (i = start; i <= n; i++) { if (!lua_isnumber(L, i)) { lua_pushliteral(L, "incorrect argument"); lua_error(L); } sum += lua_tonumber(L, i); } lua_pushnumber(L, sum/n); /* first result */ lua_pushnumber(L, sum); /* second result */ return 2; /* number of results */ } static int foo(lua_State *L) { return _foo(L, 1); } static int foo_meta (lua_State *L) { return _foo(L, 2); } } int main(int argc, char **argv) { // Creage Lua context LuaContext lua; // Create library "foo" conatining the "foo" function std::shared_ptr<LuaLibrary> lib = std::make_shared<LuaLibrary>("foolib"); lib->AddCFunction("foo", foo); // Add library to the context lua.AddLibrary(lib); // Compile a code using the new foolib.foo function lua.CompileString("foo_test", "print(\"Result of calling foolib.foo(1,2,3,4) = \" .. foolib.foo(1,2,3,4))"); // Run the context try { lua.Run("foo_test"); } catch (std::runtime_error& e) { std::cout << e.what() << '\n'; } lua.CompileString("test", "print('Calling foo as a metafunction of a usertype ' .. foo(1,2,3,4))"); std::unique_ptr<LuaState> L = lua.newStateFor("test"); LuaTUserData ud(sizeof(LuaTUserData *)); ud.AddMetaFunction("__call", foo_meta); ud.PushGlobal(*L, "foo"); int res = lua_pcall(*L, 0, LUA_MULTRET, 0); if (res != LUA_OK ) { std::cout << "Error Executing " << res << " " << lua_tostring(*L,1) << "\n"; } }
30.050505
109
0.660504
mf01
4d4a6fde5107b9e9cb6b393324dddcb1d7745fa5
963
cpp
C++
src/QtAVPlayer/qavsubtitlecodec.cpp
valbok/QAVPlayer
6138dc7a2df8aef2bf8c40d004b115af538c627c
[ "MIT" ]
null
null
null
src/QtAVPlayer/qavsubtitlecodec.cpp
valbok/QAVPlayer
6138dc7a2df8aef2bf8c40d004b115af538c627c
[ "MIT" ]
null
null
null
src/QtAVPlayer/qavsubtitlecodec.cpp
valbok/QAVPlayer
6138dc7a2df8aef2bf8c40d004b115af538c627c
[ "MIT" ]
null
null
null
/********************************************************* * Copyright (C) 2020, Val Doroshchuk <valbok@gmail.com> * * * * This file is part of QtAVPlayer. * * Free Qt Media Player based on FFmpeg. * *********************************************************/ #include "qavsubtitlecodec_p.h" #include "qavcodec_p_p.h" #include <QDebug> extern "C" { #include <libavcodec/avcodec.h> } QT_BEGIN_NAMESPACE QAVSubtitleCodec::QAVSubtitleCodec(QObject *parent) : QAVCodec(parent) { } bool QAVSubtitleCodec::decode(const AVPacket *pkt, AVSubtitle *subtitle) const { Q_D(const QAVCodec); int got_output = 0; int ret = avcodec_decode_subtitle2(d->avctx, subtitle, &got_output, const_cast<AVPacket *>(pkt)); if (ret < 0 && ret != AVERROR(EAGAIN)) return false; return got_output; } QT_END_NAMESPACE
25.342105
91
0.519211
valbok
4d4adbd4278c8c0d7d3a851be4f1ff3249f0c1f7
521
cpp
C++
AtCoder/abc084/abc084_c.cpp
itsmevanessi/Competitive-Programming
e14208c0e0943d0dec90757368f5158bb9c4bc17
[ "MIT" ]
null
null
null
AtCoder/abc084/abc084_c.cpp
itsmevanessi/Competitive-Programming
e14208c0e0943d0dec90757368f5158bb9c4bc17
[ "MIT" ]
null
null
null
AtCoder/abc084/abc084_c.cpp
itsmevanessi/Competitive-Programming
e14208c0e0943d0dec90757368f5158bb9c4bc17
[ "MIT" ]
null
null
null
#include<bits/stdc++.h> using namespace std; int val[501], X[501], Y[501], Z[501]; int main(void){ int n; cin >> n; for(int i = 1; i < n; ++i){ cin >> X[i] >> Y[i] >> Z[i]; } for(int i = 1; i <= n; ++i){ long t = Y[i] + X[i]; for(int j = i + 1; j < n; ++j){ if(t > Y[j]){ t -= Y[j]; if(t % Z[j]){ t /= Z[j]; t++; t *= Z[j]; } t += Y[j]; }else{ t = Y[j]; } t += X[j]; } cout << t << "\n"; } }
16.28125
37
0.314779
itsmevanessi
4d4e61fde53446b927e58a271e5d33750d0390a9
1,476
cpp
C++
examples/cpp/normal_estimation.cpp
mushroom-x/Misc3D
10f05c970eda9684b19de42a128224502e23b89b
[ "MIT" ]
13
2022-02-09T11:56:20.000Z
2022-03-31T15:45:04.000Z
examples/cpp/normal_estimation.cpp
mushroom-x/Misc3D
10f05c970eda9684b19de42a128224502e23b89b
[ "MIT" ]
7
2022-02-26T08:58:43.000Z
2022-03-29T11:19:05.000Z
examples/cpp/normal_estimation.cpp
mushroom-x/Misc3D
10f05c970eda9684b19de42a128224502e23b89b
[ "MIT" ]
5
2022-02-16T06:59:00.000Z
2022-03-31T12:03:11.000Z
#include <iostream> #include <memory> #include <misc3d/common/normal_estimation.h> #include <misc3d/utils.h> #include <misc3d/vis/vis_utils.h> #include <open3d/camera/PinholeCameraIntrinsic.h> #include <open3d/geometry/Image.h> #include <open3d/geometry/PointCloud.h> #include <open3d/geometry/RGBDImage.h> #include <open3d/io/ImageIO.h> int main(int argc, char *argv[]) { bool ret; open3d::geometry::Image depth, color; ret = open3d::io::ReadImage("../examples/data/indoor/depth/depth_0.png", depth); ret = open3d::io::ReadImage("../examples/data/indoor/color/color_0.png", color); auto rgbd = open3d::geometry::RGBDImage::CreateFromColorAndDepth( color, depth, 1000, 3.0, false); open3d::camera::PinholeCameraIntrinsic intrinsic( 848, 480, 598.7568, 598.7568, 430.3443, 250.244); auto pcd = open3d::geometry::PointCloud::CreateFromRGBDImage( *rgbd, intrinsic, Eigen::Matrix4d::Identity(), false); misc3d::Timer timer; timer.Start(); misc3d::common::EstimateNormalsFromMap(pcd, {848, 480}, 3); std::cout << "Time cost: " << timer.Stop() << std::endl; auto vis = std::make_shared<open3d::visualization::Visualizer>(); vis->CreateVisualizerWindow("Estimate normals form map", 1920, 1200); misc3d::vis::DrawPose(vis, Eigen::Matrix4d::Identity(), 0.1); misc3d::vis::DrawGeometry3D(vis, pcd); vis->Run(); return 0; }
35.142857
76
0.657182
mushroom-x
4d4faa8ae9fef95b76cc139bafe32577e6d9521e
1,012
hpp
C++
example/sim4ana/source/ApplyEnergyResponse.hpp
goroyabu/anlpy
2d5d65b898d31d69f990e973cbfdbabd8cb0a15c
[ "MIT" ]
null
null
null
example/sim4ana/source/ApplyEnergyResponse.hpp
goroyabu/anlpy
2d5d65b898d31d69f990e973cbfdbabd8cb0a15c
[ "MIT" ]
null
null
null
example/sim4ana/source/ApplyEnergyResponse.hpp
goroyabu/anlpy
2d5d65b898d31d69f990e973cbfdbabd8cb0a15c
[ "MIT" ]
null
null
null
/** @file ApplyEnergyResponse.hpp @date 2020/08/24 @author @detail Automatically generated by make_anlpy_project.sh 1.0.0 **/ #ifndef ApplyEnergyResponse_hpp #define ApplyEnergyResponse_hpp #include <VANL_Module.hpp> class ApplyEnergyResponse : public anl::VANL_Module { public: ApplyEnergyResponse(); ~ApplyEnergyResponse(); int mod_bgnrun() override; int mod_ana() override; int mod_endrun() override; private: double randomize_energy_cathode (double energy, double electronics_noise, const std::string& mate); double randomize_energy_anode (double energy, double electronics_noise, const std::string& mate); double energy_resolution_cathode (double energy, double electronics_noise, const std::string& mate); double energy_resolution_anode (double energy, double electronics_noise, const std::string& mate); struct parameter_list { bool is_enabled_randomize; double electronics_noise; } parameter; }; #endif
23
71
0.733202
goroyabu
4d516fee81e17231ea2fe808adcf9608cadf91d1
3,762
cc
C++
test/unit/core/container/shared_data_test.cc
willhemsley/biodynamo
c36830de621f8e105bf5eac913b96405b5c9d75c
[ "Apache-2.0" ]
null
null
null
test/unit/core/container/shared_data_test.cc
willhemsley/biodynamo
c36830de621f8e105bf5eac913b96405b5c9d75c
[ "Apache-2.0" ]
null
null
null
test/unit/core/container/shared_data_test.cc
willhemsley/biodynamo
c36830de621f8e105bf5eac913b96405b5c9d75c
[ "Apache-2.0" ]
null
null
null
// ----------------------------------------------------------------------------- // // Copyright (C) 2021 CERN & Newcastle University for the benefit of the // BioDynaMo collaboration. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // // See the LICENSE file distributed with this work for details. // See the NOTICE file distributed with this work for additional information // regarding copyright ownership. // // ----------------------------------------------------------------------------- #include "core/container/shared_data.h" #include <gtest/gtest.h> #include <vector> namespace bdm { // Test if resize and size method work correctly. TEST(SharedDataTest, ReSize) { SharedData<int> sdata(10); EXPECT_EQ(10u, sdata.size()); sdata.resize(20); EXPECT_EQ(20u, sdata.size()); } // Test if shared data is occupying full cache lines. TEST(SharedDataTest, CacheLineAlignment) { // Test standard data tyes int, float, double // Test alignment of int EXPECT_EQ( std::alignment_of<typename SharedData<int>::Data::value_type>::value, BDM_CACHE_LINE_SIZE); // Test alignment of float EXPECT_EQ( std::alignment_of<typename SharedData<float>::Data::value_type>::value, BDM_CACHE_LINE_SIZE); // Test alignment of double EXPECT_EQ( std::alignment_of<typename SharedData<double>::Data::value_type>::value, BDM_CACHE_LINE_SIZE); // Test size of vector components int EXPECT_EQ(sizeof(typename SharedData<int>::Data::value_type), BDM_CACHE_LINE_SIZE); // Test size of vector components float EXPECT_EQ(sizeof(typename SharedData<float>::Data::value_type), BDM_CACHE_LINE_SIZE); // Test size of vector components double EXPECT_EQ(sizeof(typename SharedData<double>::Data::value_type), BDM_CACHE_LINE_SIZE); // Test a chache line fully filled with doubles. // Test alignment of double[max_double], e.g. max cache line capacity EXPECT_EQ( std::alignment_of< typename SharedData<double[BDM_CACHE_LINE_SIZE / sizeof(double)]>::Data::value_type>::value, BDM_CACHE_LINE_SIZE); // Test size of vector components double[max_double], e.g. max cache line // capacity EXPECT_EQ( sizeof(typename SharedData< double[BDM_CACHE_LINE_SIZE / sizeof(double)]>::Data::value_type), BDM_CACHE_LINE_SIZE); // Test some custom data structures // Test alignment of data that fills 1 cache line EXPECT_EQ(std::alignment_of<typename SharedData< char[BDM_CACHE_LINE_SIZE - 1]>::Data::value_type>::value, BDM_CACHE_LINE_SIZE); // Test alignment of data that fills 2 cache lines EXPECT_EQ(std::alignment_of<typename SharedData< char[BDM_CACHE_LINE_SIZE + 1]>::Data::value_type>::value, BDM_CACHE_LINE_SIZE); // Test alignment of data that fills 3 cache lines EXPECT_EQ(std::alignment_of<typename SharedData< char[2 * BDM_CACHE_LINE_SIZE + 1]>::Data::value_type>::value, BDM_CACHE_LINE_SIZE); // Test size of data that fills 1 cache line EXPECT_EQ( sizeof( typename SharedData<char[BDM_CACHE_LINE_SIZE - 1]>::Data::value_type), BDM_CACHE_LINE_SIZE); // Test size of data that fills 2 cache lines EXPECT_EQ( sizeof( typename SharedData<char[BDM_CACHE_LINE_SIZE + 1]>::Data::value_type), 2 * BDM_CACHE_LINE_SIZE); // Test size of data that fills 3 cache lines EXPECT_EQ(sizeof(typename SharedData< char[2 * BDM_CACHE_LINE_SIZE + 1]>::Data::value_type), 3 * BDM_CACHE_LINE_SIZE); } } // namespace bdm
38.387755
80
0.662148
willhemsley
4d522a4da74a324d4626bb805ba9fca8290ac038
2,748
cpp
C++
src/StaticControls.cpp
pskowronski97z/EasyWin-GUI
858dc01b025d406dca3007339bb63f82c6996146
[ "MIT" ]
2
2021-03-22T08:17:50.000Z
2021-03-23T10:44:32.000Z
src/StaticControls.cpp
pskowronski97z/WinGUI
858dc01b025d406dca3007339bb63f82c6996146
[ "MIT" ]
null
null
null
src/StaticControls.cpp
pskowronski97z/WinGUI
858dc01b025d406dca3007339bb63f82c6996146
[ "MIT" ]
null
null
null
#include <StaticControls.h> #include <CommCtrl.h> #include <Window.h> WinGUI::Label::Label(const Window& parent, std::string name, const int& x, const int& y) : Control(parent, x, y, std::move(name)) { std::wstring w_name = string_to_wstring(name_); id_= STATIC_CTRL; width_ = w_name.size() * 6; handle_ = CreateWindowEx( 0, L"STATIC", w_name.c_str(), WS_CHILD | WS_VISIBLE | SS_LEFT, x_, y_, width_, FONT_HEIGHT, parent_handle_, (HMENU)id_, parent.get_instance(), 0); SendMessage(handle_, WM_SETFONT, (WPARAM)(HFONT)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE, 0)); } void WinGUI::Label::set_text(std::string name) { name_ = name; std::wstring w_name = string_to_wstring(name_); SetWindowText(handle_,w_name.c_str()); width_ = w_name.size()*6; } int WinGUI::Label::get_width() const noexcept { return width_; } WinGUI::ProgressBar::ProgressBar(const Window& parent, std::string name, const int& x, const int& y, const int& width, const int& height) noexcept : Control(parent,x,y,std::move(name)),width_(width),height_(height),progress_(0.0f) { if (width_ < 0) width_ = 100; id_ = STATIC_CTRL; if(!name.empty()) { Label name_label(parent, name_,x_,y_); y_ += FONT_HEIGHT; } handle_ = CreateWindowEx( WS_EX_CLIENTEDGE, PROGRESS_CLASS, 0, WS_CHILD | WS_VISIBLE | PBS_SMOOTH | PBS_SMOOTHREVERSE, x_, y_, width_, height_, parent_handle_, (HMENU)id_, parent.get_instance(), 0); } int WinGUI::ProgressBar::get_width() const noexcept { return width_; } int WinGUI::ProgressBar::get_height() const noexcept { return height_; } float WinGUI::ProgressBar::get_progress() const noexcept { return progress_; } bool WinGUI::ProgressBar::set_progress(unsigned short progress) noexcept { if (progress < 0 || progress > 100) return false; progress_ = progress; SendMessage(handle_, PBM_SETPOS, (WPARAM)progress_, 0); return true; } WinGUI::GroupBox::GroupBox(const Window& parent, std::string name, const int& x, const int& y, const int& width, const int& height) : Control(parent, x, y, std::move(name)), width_(width), height_(height) { if(width_<=0) width_=100; if(height_<=0) height_=100; std::wstring w_name = string_to_wstring(name_); id_ = STATIC_CTRL; handle_ = CreateWindowEx( 0, L"BUTTON", w_name.c_str(), WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_GROUPBOX, x_, y_, width_, height_, parent_handle_, (HMENU)id_, parent.get_instance(), nullptr); SendMessage(handle_, WM_SETFONT, (WPARAM)((HFONT)GetStockObject(DEFAULT_GUI_FONT)), MAKELPARAM(TRUE, 0)); } int WinGUI::GroupBox::get_width() const noexcept { return width_; } int WinGUI::GroupBox::get_height() const noexcept { return height_; }
23.288136
146
0.699054
pskowronski97z
4d53e76245d75181acecf92baebee26c978be11e
369
cpp
C++
recipes/cern-root/all/test_package/Event.cpp
rockandsalt/conan-center-index
d739adcec3e4dd4c250eff559ceb738e420673dd
[ "MIT" ]
562
2019-09-04T12:23:43.000Z
2022-03-29T16:41:43.000Z
recipes/cern-root/all/test_package/Event.cpp
rockandsalt/conan-center-index
d739adcec3e4dd4c250eff559ceb738e420673dd
[ "MIT" ]
9,799
2019-09-04T12:02:11.000Z
2022-03-31T23:55:45.000Z
recipes/cern-root/all/test_package/Event.cpp
rockandsalt/conan-center-index
d739adcec3e4dd4c250eff559ceb738e420673dd
[ "MIT" ]
1,126
2019-09-04T11:57:46.000Z
2022-03-31T16:43:38.000Z
#include "Event.hpp" Event::Event() {} Event::~Event() {} Particle::Particle() {} Particle::Particle(int _id, TLorentzVector _p4) : id(_id), p4(_p4) {} Particle::~Particle() {} int Particle::getID() { return id; } void Particle::setID(int _id) { id = _id; } TLorentzVector Particle::getP4() { return p4; } void Particle::setP4(TLorentzVector _p4) { p4 = _p4; }
19.421053
69
0.655827
rockandsalt
4d5649a874752696ebeb98383b2e45273a8be0d8
807
cpp
C++
Hashing/Incremental hash/Substring Concatenation.cpp
cenation092/InterviewBit-Solutions
ac4510a10d965fb681f7b3c80990407e18bc2668
[ "MIT" ]
7
2019-06-29T08:57:07.000Z
2021-02-13T06:43:40.000Z
Hashing/Incremental hash/Substring Concatenation.cpp
cenation092/InterviewBit-Solutions
ac4510a10d965fb681f7b3c80990407e18bc2668
[ "MIT" ]
null
null
null
Hashing/Incremental hash/Substring Concatenation.cpp
cenation092/InterviewBit-Solutions
ac4510a10d965fb681f7b3c80990407e18bc2668
[ "MIT" ]
3
2020-06-17T04:26:26.000Z
2021-02-12T04:51:40.000Z
vector<int> Solution::findSubstring(string A, const vector<string> &B) { int l = 0; int n = B[0].size(); map<string, int> Main; map<string, int> checker; for( auto it : B ){ l += it.size(); Main[it]++; } vector<int> ans; for( int i = 0; i < A.size(); i++ ){ checker = Main; int flag = 1; for( int j = i, k = 0; k < l; ){ if( j == A.size() )return ans; string s = ""; for( int m = 0; m < n; m++, j++, k++ ){ s += A[j]; } if( checker.count(s) == 0 ){ flag = 0; break; } checker[s]--; if( checker[s] == 0 )checker.erase(s); } if( flag )ans.push_back(i); } return ans; }
26.032258
72
0.386617
cenation092
4d584cd3d4643561c0529a0bbdcf8228a395b398
7,707
cpp
C++
simxml/xsdgen/QDomNodeModel.cpp
bobzabcik/OpenStudio
858321dc0ad8d572de15858d2ae487b029a8d847
[ "blessing" ]
null
null
null
simxml/xsdgen/QDomNodeModel.cpp
bobzabcik/OpenStudio
858321dc0ad8d572de15858d2ae487b029a8d847
[ "blessing" ]
null
null
null
simxml/xsdgen/QDomNodeModel.cpp
bobzabcik/OpenStudio
858321dc0ad8d572de15858d2ae487b029a8d847
[ "blessing" ]
null
null
null
/* Copyright (c) 2011, Stanislaw Adaszewski All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Stanislaw Adaszewski nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANISLAW ADASZEWSKI BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "QDomNodeModel" #include <QDomNode> #include <QDomDocument> #include <QUrl> #include <QVector> #include <QSourceLocation> #include <QVariant> class MyDomNode: public QDomNode { public: MyDomNode(const QDomNode& other): QDomNode(other) { } MyDomNode(QDomNodePrivate *otherImpl): QDomNode(otherImpl) { } QDomNodePrivate* getImpl() { return impl; } }; QDomNodeModel::QDomNodeModel(QXmlNamePool pool, QDomDocument doc): m_Pool(pool), m_Doc(doc) { } QUrl QDomNodeModel::baseUri (const QXmlNodeModelIndex &) const { // TODO: Not implemented. return QUrl(); } QXmlNodeModelIndex::DocumentOrder QDomNodeModel::compareOrder ( const QXmlNodeModelIndex & ni1, const QXmlNodeModelIndex & ni2 ) const { QDomNode n1 = toDomNode(ni1); QDomNode n2 = toDomNode(ni2); if (n1 == n2) return QXmlNodeModelIndex::Is; Path p1 = path(n1); Path p2 = path(n2); for (int i = 1; i < p1.size(); i++) if (p1[i] == n2) return QXmlNodeModelIndex::Follows; for (int i = 1; i < p2.size(); i++) if (p2[i] == n1) return QXmlNodeModelIndex::Precedes; for (int i = 1; i < p1.size(); i++) for (int j = 1; j < p2.size(); j++) { if (p1[i] == p2[j]) // Common ancestor { int ci1 = childIndex(p1[i-1]); int ci2 = childIndex(p2[j-1]); if (ci1 < ci2) return QXmlNodeModelIndex::Precedes; else return QXmlNodeModelIndex::Follows; } } return QXmlNodeModelIndex::Precedes; // Should be impossible! } QUrl QDomNodeModel::documentUri (const QXmlNodeModelIndex&) const { // TODO: Not implemented. return QUrl(); } QXmlNodeModelIndex QDomNodeModel::elementById ( const QXmlName & id ) const { return fromDomNode(m_Doc.elementById(id.toClarkName(m_Pool))); } QXmlNodeModelIndex::NodeKind QDomNodeModel::kind ( const QXmlNodeModelIndex & ni ) const { QDomNode n = toDomNode(ni); if (n.isAttr()) return QXmlNodeModelIndex::Attribute; else if (n.isText()) return QXmlNodeModelIndex::Text; else if (n.isComment()) return QXmlNodeModelIndex::Comment; else if (n.isDocument()) return QXmlNodeModelIndex::Document; else if (n.isElement()) return QXmlNodeModelIndex::Element; else if (n.isProcessingInstruction()) return QXmlNodeModelIndex::ProcessingInstruction; return (QXmlNodeModelIndex::NodeKind) 0; } QXmlName QDomNodeModel::name ( const QXmlNodeModelIndex & ni ) const { QDomNode n = toDomNode(ni); if (n.isAttr() || n.isElement() || n.isProcessingInstruction()){ if (n.localName().isNull()){ //std::cout << n.nodeName().toStdString() << std::endl; //std::cout << n.localName().toStdString() << std::endl; //std::cout << n.namespaceURI().toStdString() << std::endl; //std::cout << n.prefix().toStdString() << std::endl; return QXmlName(m_Pool, n.nodeName(), QString(), QString()); }else{ //std::cout << n.nodeName().toStdString() << std::endl; //std::cout << n.localName().toStdString() << std::endl; //std::cout << n.namespaceURI().toStdString() << std::endl; //std::cout << n.prefix().toStdString() << std::endl; return QXmlName(m_Pool, n.localName(), n.namespaceURI(), n.prefix()); } } return QXmlName(m_Pool, QString(), QString(), QString()); } QVector<QXmlName> QDomNodeModel::namespaceBindings(const QXmlNodeModelIndex&) const { // TODO: Not implemented. return QVector<QXmlName>(); } QVector<QXmlNodeModelIndex> QDomNodeModel::nodesByIdref(const QXmlName&) const { // TODO: Not implemented. return QVector<QXmlNodeModelIndex>(); } QXmlNodeModelIndex QDomNodeModel::root ( const QXmlNodeModelIndex & ni ) const { QDomNode n = toDomNode(ni); while (!n.parentNode().isNull()) n = n.parentNode(); return fromDomNode(n); } QSourceLocation QDomNodeModel::sourceLocation(const QXmlNodeModelIndex&) const { // TODO: Not implemented. return QSourceLocation(); } QString QDomNodeModel::stringValue ( const QXmlNodeModelIndex & ni ) const { QDomNode n = toDomNode(ni); if (n.isProcessingInstruction()) return n.toProcessingInstruction().data(); else if (n.isText()) return n.toText().data(); else if (n.isComment()) return n.toComment().data(); else if (n.isElement()) return n.toElement().text(); else if (n.isDocument()) return n.toDocument().documentElement().text(); else if (n.isAttr()) return n.toAttr().value(); return QString(); } QVariant QDomNodeModel::typedValue ( const QXmlNodeModelIndex & ni ) const { return qVariantFromValue(stringValue(ni)); } QXmlNodeModelIndex QDomNodeModel::fromDomNode(const QDomNode &n) const { if (n.isNull()) return QXmlNodeModelIndex(); return createIndex(MyDomNode(n).getImpl(), 0); } QDomNode QDomNodeModel::toDomNode(const QXmlNodeModelIndex &ni) const { return MyDomNode((QDomNodePrivate*) ni.data()); } QDomNodeModel::Path QDomNodeModel::path(const QDomNode &n) const { Path res; QDomNode cur = n; while (!cur.isNull()) { res.push_back(cur); cur = cur.parentNode(); } return res; } int QDomNodeModel::childIndex(const QDomNode &n) const { QDomNodeList children = n.parentNode().childNodes(); for (int i = 0; i < children.size(); i++) if (children.at(i) == n) return i; return -1; } QVector<QXmlNodeModelIndex> QDomNodeModel::attributes ( const QXmlNodeModelIndex & ni ) const { QDomElement n = toDomNode(ni).toElement(); QDomNamedNodeMap attrs = n.attributes(); QVector<QXmlNodeModelIndex> res; for (int i = 0; i < attrs.size(); i++) { res.push_back(fromDomNode(attrs.item(i))); } return res; } QXmlNodeModelIndex QDomNodeModel::nextFromSimpleAxis ( SimpleAxis axis, const QXmlNodeModelIndex & ni) const { QDomNode n = toDomNode(ni); switch(axis) { case Parent: return fromDomNode(n.parentNode()); case FirstChild: return fromDomNode(n.firstChild()); case PreviousSibling: return fromDomNode(n.previousSibling()); case NextSibling: return fromDomNode(n.nextSibling()); } return QXmlNodeModelIndex(); }
27.525
109
0.688335
bobzabcik
4d5a4b49aae516e4575a364a1d9a0b556a3330ac
24,032
cpp
C++
test/test_server.cpp
CyanicYang/End_to_End_Encryption
a4908d86d3261a9df89d90078623198d7c03c6a8
[ "MIT" ]
1
2021-03-31T16:47:07.000Z
2021-03-31T16:47:07.000Z
test/test_server.cpp
CyanicYang/End_to_End_Encryption
a4908d86d3261a9df89d90078623198d7c03c6a8
[ "MIT" ]
null
null
null
test/test_server.cpp
CyanicYang/End_to_End_Encryption
a4908d86d3261a9df89d90078623198d7c03c6a8
[ "MIT" ]
null
null
null
#include "communicate.hpp" int log_init(std::ofstream &log_stream, const std::string log_name, const Level level, const bool* const log_env, const bool on_screen, const bool is_trunc) { // log_stream must not be opened before getting into this function. if (log_stream.is_open()) { return -1; } if (is_trunc) { log_stream.open(log_name, ios::out|ios::trunc); } else { log_stream.open(log_name, ios::out|ios::app); } if (!log_stream.is_open()) { return -2; } Log::get().setLogStream(log_stream); Log::get().setLevel(level); Log::get().setEnv(log_env); Log::get().setOnScreen(on_screen); return 0; } std::string logify_data(const uint8_t* data, const int len) { std::stringstream ss, ss_word; // ss_word.str(std::string()); int i; for (i = 0; i < len; i++) { if (i % 16 == 0) { ss << ss_word.str() << std::endl; ss_word.clear(); //clear any bits set ss_word.str(std::string()); ss << ' ' << setw(4) << setfill('0') << hex << uppercase << i << ": "; } else if (i % 8 == 0) { ss << "- "; } ss << setw(2) << setfill('0') << hex << uppercase << +data[i] << ' '; // print printable char. char ch = (data[i] > 31 && data[i] < 127) ? data[i] : '.'; ss_word << ch; // ss_word << data[i]; } if (i%16==0){ ss << setw(0) << ss_word.str(); } else { auto interval = 3 * (16 - (i % 16)) + (i % 16 > 8 ? 0 : 2); // cout << "i: " << i << ", interval: " << interval << endl; ss << setw(interval) << setfill(' ') << ' ' << setw(0) << ss_word.str(); } return ss.str(); } void encrypt_auth(u_int& random_num, u_int& svr_time, uint8_t* auth, const int length) { svr_time = (u_int)time(0); svr_time = svr_time ^ (u_int)0xFFFFFFFF; srand(svr_time); random_num = (u_int)rand(); int pos = random_num % 4093; for (int i = 0; i < length; i++) { auth[i] = auth[i] ^ kSecret[pos]; pos = (pos+1)%4093; } } bool decrypt_auth(const u_int random_num, uint8_t* auth, const int length) { const uint8_t c_auth[33] = "yzmond:id*str&to!tongji@by#Auth^"; int pos = random_num % 4093; for (int i = 0; i < length; i++) { auth[i] = auth[i] ^ kSecret[pos]; if (i > length-32 && auth[i] != c_auth[i-length+32]) { return false; } pos = (pos+1)%4093; } return true; } void create_random_str(uint8_t* random_string, const int length) { uint8_t *p = new uint8_t[length]; srand((unsigned)time(NULL)); for(int i = 0; i < length; i++) { p[i] = rand() % 256; } memcpy(random_string, p, length); delete[] p; return; } // return size of the file, if open file error, return 0. // must read no more than maxLength(8191/4095) bytes. int read_dat(const std::string dat_name, char* result, int maxLength) { ifstream ifs; ifs.open(dat_name, std::ifstream::in); if (!ifs.is_open()) { return -1; } // read no more than 8191 bytes. ifs.seekg(0, std::ios::end); int length = ifs.tellg(); length = length > maxLength ? maxLength : length; ifs.seekg(0, std::ios::beg); ifs.read(result, length); ifs.close(); return length; } // TODO: Is this necessary? DevInfo Server::gene_dev_info() { dev.cpu = 2600; dev.ram = 1846; dev.flash = 3723; srand((unsigned)time(NULL)); //'devid' in database //TODO: need unique instID(devid)! and I'm not doing this. dev.instID = rand() % 512; dev.instInnID = 1; dev.devInnerID = rand() % 256; dev.devInnerID = dev.devInnerID << 8; dev.devInnerID += rand() % 256; create_random_str(dev.groupSeq, 16); create_random_str(dev.type, 16); create_random_str(dev.version, 16); return dev; } void Server::push_back_array(vector<uint8_t> & message, uint8_t * array, int length) { for(int i=0; i<length; i++) { message.push_back(array[i]); } return; } void Server::push_back_uint16(vector<uint8_t> & message, uint16_t data) { auto var16 = inet_htons(data); message.push_back((uint8_t)(var16>>8)); message.push_back((uint8_t)(var16)); } void Server::push_back_uint32(vector<uint8_t> & message, uint32_t data) { auto var32 = inet_htonl(data); message.push_back((uint8_t)(var32>>24)); message.push_back((uint8_t)(var32>>16)); message.push_back((uint8_t)(var32>>8)); message.push_back((uint8_t)(var16)); return; } void Server::pop_first_array(vector<uint8_t> & message, uint8_t * array, int length) { for(int i=0; i<length; i++) { array[i] = message.front(); message.erase(message.begin()); } return; } void Server::pop_first_uint8(vector<uint8_t> & message, uint8_t& data) { data = message.front(); message.erase(message.begin()); } void Server::pop_first_uint16(vector<uint8_t> & message, uint16_t& data) { uint8_t raw[2]; raw[1] = message.front(); message.erase(message.begin()); raw[2] = message.front(); message.erase(message.begin()); memcpy(&data, sizeof(data), raw, 2); data = inet_ntohs(data); } void Server::pop_first_uint32(vector<uint8_t> & message, uint32_t& data) { uint8_t raw[4]; raw[1] = message.front(); message.erase(message.begin()); raw[2] = message.front(); message.erase(message.begin()); raw[3] =message.front(); message.erase(message.begin()); raw[4] = message.front(); message.erase(message.begin()); memcpy(&data, sizeof(data), raw, 4); data = inet_ntohl(data); } // TODO: Is this necessary? void Server::push_back_screen_info(vector<uint8_t> & message) { //screen message.push_back((uint8_t)(1 + rand() % 16)); //pad message.push_back((uint8_t)0x00); //remote server port //TODO: HOW TO GET REMOTE PORT?? push_back_uint16(message, (uint16_t)12350); //remote server ip //TODO: HOW TO GET REMOTE IP?? uint32_t ip = (uint32_t)inet_aton("192.168.0.0"); message.push_back((uint8_t)ip >> 24); message.push_back((uint8_t)ip >> 16); message.push_back((uint8_t)ip >> 8); message.push_back((uint8_t)ip); //proto string prot = "专用SSH"; const char tp[12] = {0}; tp = prot.c_str(); push_back_array(message, (uint8_t *)tp, 12); //screen state string state = "已登录"; const char tp[8] = {0}; tp = prot.c_str(); push_back_array(message, (uint8_t *)tp, 8); //screen prompt string promp = "储蓄系统"; const char tp[24] = {0}; tp = promp.c_str(); push_back_array(message, (uint8_t *)tp, 24); //tty type string ttyType = "vt100"; const char tp[12] = {0}; tp = ttyType.c_str(); push_back_array(message, (uint8_t *)tp, 12); //system time push_back_uint32(message, (uint32_t)time(NULL)); //statics push_back_uint32(message, (uint32_t)rand() % 1000000); push_back_uint32(message, (uint32_t)rand() % 1000000); push_back_uint32(message, (uint32_t)rand() % 1000000); push_back_uint32(message, (uint32_t)rand() % 1000000); //Ping statics push_back_uint32(message, (uint32_t)rand() % 123456); push_back_uint32(message, (uint32_t)rand() % 123456); push_back_uint32(message, (uint32_t)rand() % 123456); } // TODO: Rewrite it symmetrically as client_pack message. void Server::server_unpack_message(Options opt) { vector<uint8_t> message; //head message.push_back((uint8_t)0x91); //descriptor message.push_back((uint8_t)type); switch(type) { case PacketType::VersionRequire: //packet length push_back_uint16(message, (uint16_t)12); //0x0000 push_back_uint16(message, (uint16_t)0x0000); //data length push_back_uint16(message, (uint16_t)4); //main version push_back_uint16(message, serverMainVersion); //sec 1 version message.push_back(serverSec1Version); //sec 2 version message.push_back(serverSec2Version); break; case PacketType::AuthResponse: //packet length push_back_uint16(message, (uint16_t)116); //0x0000 push_back_uint16(message, (uint16_t)0x0000); //data length push_back_uint16(message, (uint16_t)108); //CPU push_back_uint16(message, dev.cpu); //RAM push_back_uint16(message, dev.ram); //FLASH push_back_uint16(message, dev.flash); //dev inner seq push_back_uint16(message, dev.devInnerID); //group seq push_back_array(message, dev.groupSeq, 16); //type push_back_array(message, dev.type, 16); //version push_back_array(message, dev.version,16); //ethernet, usb, printer..., 8 bytes in total for(int ip = 0; ip < 8; ip++) { message.push_back((uint8_t)0); } //instID push_back_uint32(message, dev.instID); //instInnID message.push_back(dev.instInnID); //2 bytes pad for(int ip = 0; ip < 2; ip++) { message.push_back((uint8_t)0); } //authstr vector<uint8_t> tmp; uint8_t tpdata[104]; vector<uint8_t>::iterator it; it = message.begin() + 8; //from CPU for(; it != message.end(); it++) { //to the last uint8_t in current message tmp.push_back(*it); } int n = tmp.size(); if(n != 72) { LOG(Level::Error) << "Descriptor: 0x91" << endl << "PacketType: 0x01" << endl << "the bit num from CPU to AuthStr is not 72!!" << endl; return false; } for(int i = 0; i < 72; i++) { tpdata[i] = tmp[i]; } uint8_t authStr[33] = "yzmond:id*str&to!tongji@by#Auth^"; for(int i = 0; i < 32; i++) { tpdata[72+i] = authStr[i]; } //encrypt u_int random_num=0, svr_time=0; encrypt_auth(random_num, svr_time, tpdata, 104); it = message.begin() + 8; for(int i = 0; i < 72; i++) { // replace old 72 bytes message[i+8] = tpdata[i]; } for(int i = 72; i < 104; i++) { //add new auth str (32 bytes) message.push_back(tpdata[i]); } //random num push_back_uint32(message, (uint32_t)random_num); break; case PacketType::SysInfoResponse: //packet length push_back_uint16(message, (uint16_t)28); //0x0000 push_back_uint16(message, (uint16_t)0x0000); //data length push_back_uint16(message, (uint16_t)20); //user CPU time push_back_uint32(message, (uint32_t)5797); //nice CPU time push_back_uint32(message, (uint32_t)0); //system CPU time push_back_uint32(message, (uint32_t)13013); //idle CPU time push_back_uint32(message, (uint32_t)5101426); //freed memory push_back_uint32(message, (uint32_t)2696); break; case PacketType::ConfInfoResponse: //load config.dat char * read_file = new char[8192]; string file_name = "config.dat"; int size = read_dat(file_name, read_file, 8191); if (size < 0) { LOG(Level::ERR) << "No such file: " << file_name << endl; return -1; } LOG(Level::RDATA) << "read test:" << logify_data(reinterpret_cast<uint8_t*>(read_file), size) << endl; LOG(Level::Debug) << "size of data: " << size << endl; // add '\0' to the end of string read_file[size++] = '\0'; //packet length push_back_uint16(message, (uint16_t)size + 8); //0x0000 push_back_uint16(message, (uint16_t)0x0000); //data length push_back_uint16(message, (uint16_t)size); //config info push_back_array(message, (uint8_t *)read_file, size); break; case PacketType::ProcInfoResponse: //load config.dat char * read_file = new char[8192]; string file_name = "process.dat"; int size = read_dat(file_name, read_file, 8191); if (size < 0) { LOG(Level::ERR) << "No such file: " << file_name << endl; return -1; } LOG(Level::RDATA) << "read test:" << logify_data(reinterpret_cast<uint8_t*>(read_file), size) << endl; LOG(Level::Debug) << "size of data: " << size << endl; // add '\0' to the end of string read_file[size++] = '\0'; //packet length push_back_uint16(message, (uint16_t)size + 8); //0x0000 push_back_uint16(message, (uint16_t)0x0000); //data length push_back_uint16(message, (uint16_t)size); //config info push_back_array(message, (uint8_t *)read_file, size); break; case PacketType::USBfileResponse: //load usefile.dat char * read_file = new char[8192]; string file_name = "usefile.dat"; int size = read_dat(file_name, read_file, 4095); if (size < 0) { LOG(Level::ERR) << "No such file: " << file_name << endl; return -1; } LOG(Level::RDATA) << "read test:" << logify_data(reinterpret_cast<uint8_t*>(read_file), size) << endl; LOG(Level::Debug) << "size of data: " << size << endl; // add '\0' to the end of string read_file[size++] = '\0'; //packet length push_back_uint16(message, (uint16_t)size + 8); //0x0000 push_back_uint16(message, (uint16_t)0x0000); //data length push_back_uint16(message, (uint16_t)size); //config info push_back_array(message, (uint8_t *)read_file, size); break; case PacketType::PrintQueueResponse: //packet length push_back_uint16(message, (uint16_t)9); //0x0000 push_back_uint16(message, (uint16_t)0x0000); //data length push_back_uint16(message, (uint16_t)1); message.push_back((uint8_t)0); break; case PacketType::TerInfoResponse: uint8_t ttyInfoMap[270] = {0}; //dumb+IP terminal map // for(int i = 0; i < 16; i++) { // ttyInfoMap[i] = 0; // } //no dumb terminal //TODO: get max&min tty amount from Options int maxTNum = stoi(opt.at["最大配置终端数量"]); int minTNum = stoi(opt.at["最小配置终端数量"]); LOG(Level::Debug) << "max tty amount = " << maxSNum << endl; LOG(Level::Debug) << "min tty amount = " << minSNum << endl; int total = minTNum + rand() % (maxTNum - minTNum + 1); int async_term_num = 0; int ipterm_num = total - async_term_num; int randPos; //generate random ttyInfoMap for(int i = 0; i < ipterm_num; i++) { randPos = rand() % 254; while(ttyInfoMap[16 + randPos] == 1) { randPos = rand() % 254; } ttyInfoMap[16 + randPos] = 1; } //16 dumb-terminal, 254 ip-terminal, 2 bytes tty num //packet length push_back_uint16(message, (uint16_t)(8+16+254+2)); //0x0000 push_back_uint16(message, (uint16_t)0x0000); //data length push_back_uint16(message, (uint16_t)(16+254+2)); //tty map push_back_array(message, ttyInfoMap, 270); //tty configed push_back_uint16(message, (uint16_t)(total + rand() % (270-total) )); break; case PacketType::DumbTerResponse: int maxSNum = stoi(opt.at["每个终端最大虚屏数量"]); int minSNum = stoi(opt.at["每个终端最小虚屏数量"]); LOG(Level::Debug) << "max screen num = " << maxSNum << endl; LOG(Level::Debug) << "min screen num = " << minSNum << endl; uint8_t screenNum = minSNum + rand() % (maxSNum - minSNum + 1); uint8_t activeScreen = rand() % screenNum; //packet length push_back_uint16(message, (uint16_t)(8 + 28 + screenNum*96)); //dumb terminal number push_back_uint16(message, (uint16_t)(1 + rand() % 16)); //data length push_back_uint16(message, (uint16_t)(28 + screenNum*96)); //port message.push_back((uint8_t)(1 + rand() % 254) ); //asigned port message.push_back((uint8_t)(1 + rand() % 254) ); //active screen message.push_back(activeScreen); //screen numv message.push_back(screenNum); //tty addr push_back_uint32(message, (uint32_t)0); //tty type string ttyType = "串口终端"; const char tp[12] = {0}; tp = ttyType.c_str(); push_back_array(message, (uint8_t *)tp, 12); //tty state string ttyState = "正常"; memset(tp, 0, 12); tp = ttyState.c_str(); push_back_array(message, (uint8_t *)tp, 8); //screen info for(int i = 0; i < screenNum; i++) { push_back_screen_info(message); } break; case PacketType::IPTermResponse: int maxSNum = stoi(opt.at["每个终端最大虚屏数量"]); int minSNum = stoi(opt.at["每个终端最小虚屏数量"]); LOG(Level::Debug) << "max screen num = " << maxSNum << endl; LOG(Level::Debug) << "min screen num = " << minSNum << endl; uint8_t screenNum = minSNum + rand() % (maxSNum - minSNum + 1); uint8_t activeScreen = rand() % screenNum; //packet length push_back_uint16(message, (uint16_t)(8 + 28 + screenNum*96)); //0x0000 push_back_uint16(message, (uint16_t)0x0000); //data length push_back_uint16(message, (uint16_t)(28 + screenNum*96)); //port message.push_back((uint8_t)(1 + rand() % 254) ); //asigned port message.push_back((uint8_t)(1 + rand() % 254) ); //active screen message.push_back(activeScreen); //screen numv message.push_back(screenNum); //tty addr uint32_t ip = (uint32_t)inet_aton("192.168.80.2"); message.push_back((uint8_t)ip >> 24); message.push_back((uint8_t)ip >> 16); message.push_back((uint8_t)ip >> 8); message.push_back((uint8_t)ip); //tty type string ttyType = "IP终端"; const char tp[12] = {0}; tp = ttyType.c_str(); push_back_array(message, (uint8_t *)tp, 12); //tty state string ttyState = "菜单"; memset(tp, 0, 12); tp = ttyState.c_str(); push_back_array(message, (uint8_t *)tp, 8); //screen info for(int i = 0; i < screenNum; i++) { push_back_screen_info(message); } break; case PacketType::End: //packet length push_back_uint16(message, (uint16_t)8; //0x0000 push_back_uint16(message, (uint16_t)0x0000); //data length push_back_uint16(message, (uint16_t)0); break; default: break; } send_message = message; return true; } // TODO: Rewrite it symmetrically as client_unpack message. bool Server::server_pack_message(PacketType type, Options opt) { vector<uint8_t> message; //head message.push_back((uint8_t)0x91); //descriptor message.push_back((uint8_t)type); switch(type) { case PacketType::AuthRequest: //packet length push_back_uint16(message, (uint16_t)60); //padding push_back_uint16(message, (uint16_t)0x0000); //data length push_back_uint16(message, (uint16_t)52); //main version push_back_uint16(message, (uint16_t)3); //sec 1 version message.push_back((uint8_t)0); //sec 2 version message.push_back((uint8_t)0); // 设备连接间隔 push_back_uint16(message, static_cast<uint16_t>(stoi(opt.at["设备连接间隔"])); // 设备采样间隔 push_back_uint16(message, static_cast<uint16_t>(stoi(opt.at["设备采样间隔"])); // 是否允许空终端,强制为1 message.push_back((uint8_t)1); message.push_back((uint8_t)0); push_back_uint16(message, (uint16_t)0); // server_auth, random_num, svr_time uint8_t server_auth[33] = "yzmond:id*str&to!tongji@by#Auth^"; u_int random_num=0, svr_time=0; encrypt_auth(random_num, svr_time, auth, 32); push_back_array(message, server_auth, 32); push_back_uint32(message, static_cast<uint32_t>(random_num)); push_back_uint32(message, static_cast<uint32_t>(svr_time)); return true; // TODO case PacketType::SysInfoRequest: LOG(Level::ENV) << "服务器请求系统信息" << endl; return true; case PacketType::ConfInfoRequest: LOG(Level::ENV) << "服务器请求配置信息" << endl; return true; case PacketType::ProcInfoRequest: LOG(Level::ENV) << "服务器请求进程信息" << endl; return true; case PacketType::EtherInfoRequest: LOG(Level::ENV) << "服务器请求以太网口信息" << endl; return true; case PacketType::USBInfoRequest: LOG(Level::ENV) << "服务器请求USB口信息" << endl; return true; case PacketType::USBfileRequest: LOG(Level::ENV) << "服务器请求U盘信息" << endl; return true; case PacketType::PrintDevRequest: LOG(Level::ENV) << "服务器请求打印口信息" << endl; return true; case PacketType::PrintQueueRequest: LOG(Level::ENV) << "服务器请求打印队列信息" << endl; return true; case PacketType::TerInfoRequest: LOG(Level::ENV) << "服务器请求终端服务信息" << endl; return true; case PacketType::DumbTerRequest: LOG(Level::ENV) << "服务器请求哑终端信息" << endl; pop_first_uint16(message, rawDumbTerFlags); return true; case PacketType::IPTermRequest: LOG(Level::ENV) << "服务器请求IP终端信息" << endl; pop_first_uint16(message, rawIPTerFlags); return true; case PacketType::End: LOG(Level::ENV) << "服务器提示已收到全部包" << endl; return true; default: LOG(Level::ERR) << "不可被识别的包类型" << endl; return false; } } // TODO: now just pseudo. int Server::server_communicate(int socketfd, Options opt) { srand((unsigned)time(NULL)); //block recv(); client_unpack_message(); while(recvPakcet != PacketType::End) { //recv & send message client_pack_message(); send(); recv(); client_unpack_message(); } return 0; }
33.800281
158
0.537908
CyanicYang
4d5b2248c6c1dec2d77d4b23f54b5baa77cd34ea
1,923
cpp
C++
melody/CMPT-1020/ass3-2/q3.cpp
TTWNO/tutoring
be8dc2ea302efe0c5ac1927cd16098bb56464fb5
[ "CC0-1.0" ]
null
null
null
melody/CMPT-1020/ass3-2/q3.cpp
TTWNO/tutoring
be8dc2ea302efe0c5ac1927cd16098bb56464fb5
[ "CC0-1.0" ]
null
null
null
melody/CMPT-1020/ass3-2/q3.cpp
TTWNO/tutoring
be8dc2ea302efe0c5ac1927cd16098bb56464fb5
[ "CC0-1.0" ]
null
null
null
#include <iostream> using namespace std; class Date { int month; int date; int year; public: const string mth[12]={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; const int days[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int getMonth(){ return month; } int getDate(){ return date; } int getYear(){ return year; } void setMonth(int m){ month=m; } void setDate(int d){ date=d; } void setYear(int y){ year=y; } void input(){ month=0; cout<< "month?"<<endl; while (month<1 || month>12) cin>> month; cout<< "date?"<<endl; cin>> date; if (date<1 || date>days[month-1]){ cout<< "date does not exist"<<endl; input(); } cout<< "year"<<endl; cin>> year; } void output1(){ cout<< month<<"/"<<date<<"/"<<year<<endl; } void output2(){ cout<< mth[month-1]<<" "<<date<<", "<<year; } void output3(){ cout<< date<< " "<<mth[month-1]<<" "<<year; } Date increment(Date x){ Date tmr; if (x.year%4==0) mth[1]=29; tmr.date=x+1; if (tmr.date>mth[month-1]){ tmr.date=1; month=month+1; } if (month>12){ month=1; year=year+1; } return tmr; } Date decrement(Date x){ Date yes; if (x.year%4==0) mth[1]=29; yes.date=x-1; if (yes.date<1){ yes.date=day[month-2]; month=month-1; } if (month<1){ month=12; year=year-1; } return yes; } Date(){ month=1; date=1; year=2000; } Date(int m, int d, int y){ month=m; date=d; year=y; } }; int main(){ int a; Date today; today.input(); today.output1(); cin >> a; return 0; }
16.159664
147
0.470619
TTWNO
4d5ca9c2a30d74c6edd552ed3f3aaf879090b801
2,570
cpp
C++
wzemcmbd/VecWzem/VecWzemVStub.cpp
mpsitech/wzem-WhizniumSBE-Engine-Monitor
0d9a204660bfad57f25dbd641fd86713986f32f1
[ "MIT" ]
null
null
null
wzemcmbd/VecWzem/VecWzemVStub.cpp
mpsitech/wzem-WhizniumSBE-Engine-Monitor
0d9a204660bfad57f25dbd641fd86713986f32f1
[ "MIT" ]
null
null
null
wzemcmbd/VecWzem/VecWzemVStub.cpp
mpsitech/wzem-WhizniumSBE-Engine-Monitor
0d9a204660bfad57f25dbd641fd86713986f32f1
[ "MIT" ]
null
null
null
/** * \file VecWzemVStub.cpp * vector VecWzemVStub (implementation) * \copyright (C) 2016-2020 MPSI Technologies GmbH * \author Alexander Wirthmueller (auto-generation) * \date created: 1 Dec 2020 */ // IP header --- ABOVE #include "VecWzemVStub.h" using namespace std; using namespace Sbecore; using namespace Xmlio; /****************************************************************************** namespace VecWzemVStub ******************************************************************************/ uint VecWzemVStub::getIx( const string& sref ) { string s = StrMod::lc(sref); if (s == "stubwzemgroup") return STUBWZEMGROUP; if (s == "stubwzemusgstd") return STUBWZEMUSGSTD; if (s == "stubwzemowner") return STUBWZEMOWNER; if (s == "stubwzemusrstd") return STUBWZEMUSRSTD; if (s == "stubwzemsesmenu") return STUBWZEMSESMENU; if (s == "stubwzemsesstd") return STUBWZEMSESSTD; if (s == "stubwzempststd") return STUBWZEMPSTSTD; if (s == "stubwzemprsstd") return STUBWZEMPRSSTD; if (s == "stubwzemprdstd") return STUBWZEMPRDSTD; if (s == "stubwzemndestd") return STUBWZEMNDESTD; if (s == "stubwzemndexnref") return STUBWZEMNDEXNREF; if (s == "stubwzemopxstd") return STUBWZEMOPXSTD; if (s == "stubwzemjobstd") return STUBWZEMJOBSTD; if (s == "stubwzemjobxjref") return STUBWZEMJOBXJREF; if (s == "stubwzemevtstd") return STUBWZEMEVTSTD; if (s == "stubwzemdchstd") return STUBWZEMDCHSTD; if (s == "stubwzemclnstd") return STUBWZEMCLNSTD; if (s == "stubwzemcalstd") return STUBWZEMCALSTD; return(0); }; string VecWzemVStub::getSref( const uint ix ) { if (ix == STUBWZEMGROUP) return("StubWzemGroup"); if (ix == STUBWZEMUSGSTD) return("StubWzemUsgStd"); if (ix == STUBWZEMOWNER) return("StubWzemOwner"); if (ix == STUBWZEMUSRSTD) return("StubWzemUsrStd"); if (ix == STUBWZEMSESMENU) return("StubWzemSesMenu"); if (ix == STUBWZEMSESSTD) return("StubWzemSesStd"); if (ix == STUBWZEMPSTSTD) return("StubWzemPstStd"); if (ix == STUBWZEMPRSSTD) return("StubWzemPrsStd"); if (ix == STUBWZEMPRDSTD) return("StubWzemPrdStd"); if (ix == STUBWZEMNDESTD) return("StubWzemNdeStd"); if (ix == STUBWZEMNDEXNREF) return("StubWzemNdeXnref"); if (ix == STUBWZEMOPXSTD) return("StubWzemOpxStd"); if (ix == STUBWZEMJOBSTD) return("StubWzemJobStd"); if (ix == STUBWZEMJOBXJREF) return("StubWzemJobXjref"); if (ix == STUBWZEMEVTSTD) return("StubWzemEvtStd"); if (ix == STUBWZEMDCHSTD) return("StubWzemDchStd"); if (ix == STUBWZEMCLNSTD) return("StubWzemClnStd"); if (ix == STUBWZEMCALSTD) return("StubWzemCalStd"); return(""); };
36.197183
80
0.671595
mpsitech
4d5f99250b5504e62f3b76b5cd0c8c3186fa04e8
6,042
cpp
C++
Source/USharp/Private/ModulePaths.cpp
MiheevN/USharp
8f0205cd8628b84a66326947d93588a8c8dcbd24
[ "MIT" ]
353
2018-09-29T07:34:40.000Z
2022-03-07T17:03:06.000Z
Source/USharp/Private/ModulePaths.cpp
MiheevN/USharp
8f0205cd8628b84a66326947d93588a8c8dcbd24
[ "MIT" ]
66
2018-09-29T04:08:06.000Z
2020-09-30T22:10:56.000Z
Source/USharp/Private/ModulePaths.cpp
MiheevN/USharp
8f0205cd8628b84a66326947d93588a8c8dcbd24
[ "MIT" ]
64
2018-09-29T02:12:07.000Z
2022-02-18T07:41:45.000Z
#include "ModulePaths.h" #include "USharpPCH.h" #include "Interfaces/IPluginManager.h" #include "Modules/ModuleManifest.h" #include "HAL/PlatformProcess.h" #include "HAL/FileManager.h" #include "Misc/App.h" #include "Misc/Paths.h" DEFINE_LOG_CATEGORY_STATIC(LogModuleManager, Log, All); bool FModulePaths::BuiltDirectories = false; TArray<FString> FModulePaths::GameBinariesDirectories; TArray<FString> FModulePaths::EngineBinariesDirectories; TOptional<TMap<FName, FString>> FModulePaths::ModulePathsCache; TOptional<FString> FModulePaths::BuildId; void FModulePaths::FindModulePaths(const TCHAR* NamePattern, TMap<FName, FString> &OutModulePaths, bool bCanUseCache /*= true*/) { if (!BuiltDirectories) { BuildDirectories(); } if (!ModulePathsCache) { ModulePathsCache.Emplace(); const bool bCanUseCacheWhileGeneratingIt = false; FindModulePaths(TEXT("*"), ModulePathsCache.GetValue(), bCanUseCacheWhileGeneratingIt); } if (bCanUseCache) { // Try to use cache first if (const FString* ModulePathPtr = ModulePathsCache->Find(NamePattern)) { OutModulePaths.Add(FName(NamePattern), *ModulePathPtr); return; } // Wildcard for all items if (FCString::Strcmp(NamePattern, TEXT("*")) == 0) { OutModulePaths = ModulePathsCache.GetValue(); return; } // Wildcard search if (FCString::Strchr(NamePattern, TEXT('*')) || FCString::Strchr(NamePattern, TEXT('?'))) { bool bFoundItems = false; FString NamePatternString(NamePattern); for (const TPair<FName, FString>& CacheIt : ModulePathsCache.GetValue()) { if (CacheIt.Key.ToString().MatchesWildcard(NamePatternString)) { OutModulePaths.Add(CacheIt.Key, *CacheIt.Value); bFoundItems = true; } } if (bFoundItems) { return; } } } // Search through the engine directory FindModulePathsInDirectory(FPlatformProcess::GetModulesDirectory(), false, NamePattern, OutModulePaths); // Search any engine directories for (int Idx = 0; Idx < EngineBinariesDirectories.Num(); Idx++) { FindModulePathsInDirectory(EngineBinariesDirectories[Idx], false, NamePattern, OutModulePaths); } // Search any game directories for (int Idx = 0; Idx < GameBinariesDirectories.Num(); Idx++) { FindModulePathsInDirectory(GameBinariesDirectories[Idx], true, NamePattern, OutModulePaths); } } void FModulePaths::FindModulePathsInDirectory(const FString& InDirectoryName, bool bIsGameDirectory, const TCHAR* NamePattern, TMap<FName, FString> &OutModulePaths) { // Figure out the BuildId if it's not already set. if (!BuildId.IsSet()) { FString FileName = FModuleManifest::GetFileName(FPlatformProcess::GetModulesDirectory(), false); FModuleManifest Manifest; if (!FModuleManifest::TryRead(FileName, Manifest)) { UE_LOG(LogModuleManager, Fatal, TEXT("Unable to read module manifest from '%s'. Module manifests are generated at build time, and must be present to locate modules at runtime."), *FileName) } BuildId = Manifest.BuildId; } // Find all the directories to search through, including the base directory TArray<FString> SearchDirectoryNames; IFileManager::Get().FindFilesRecursive(SearchDirectoryNames, *InDirectoryName, TEXT("*"), false, true); SearchDirectoryNames.Insert(InDirectoryName, 0); // Enumerate the modules in each directory for(const FString& SearchDirectoryName: SearchDirectoryNames) { FModuleManifest Manifest; if (FModuleManifest::TryRead(FModuleManifest::GetFileName(SearchDirectoryName, bIsGameDirectory), Manifest) && Manifest.BuildId == BuildId.GetValue()) { for (const TPair<FString, FString>& Pair : Manifest.ModuleNameToFileName) { if (Pair.Key.MatchesWildcard(NamePattern)) { OutModulePaths.Add(FName(*Pair.Key), *FPaths::Combine(*SearchDirectoryName, *Pair.Value)); } } } } } void FModulePaths::BuildDirectories() { // From Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp if (FApp::HasProjectName()) { const FString ProjectBinariesDirectory = FPaths::Combine(FPlatformMisc::ProjectDir(), TEXT("Binaries"), FPlatformProcess::GetBinariesSubdirectory()); GameBinariesDirectories.Add(*ProjectBinariesDirectory); } // From Engine\Source\Runtime\Projects\Private\PluginManager.cpp for (TSharedRef<IPlugin>& Plugin : IPluginManager::Get().GetDiscoveredPlugins()) { if (Plugin->IsEnabled()) { // Add the plugin binaries directory const FString PluginBinariesPath = FPaths::Combine(*FPaths::GetPath(Plugin->GetDescriptorFileName()), TEXT("Binaries"), FPlatformProcess::GetBinariesSubdirectory()); AddBinariesDirectory(*PluginBinariesPath, Plugin->GetLoadedFrom() == EPluginLoadedFrom::Project); } } // From FModuleManager::Get() //temp workaround for IPlatformFile being used for FPaths::DirectoryExists before main() sets up the commandline. #if PLATFORM_DESKTOP // Ensure that dependency dlls can be found in restricted sub directories const TCHAR* RestrictedFolderNames[] = { TEXT("NoRedist"), TEXT("NotForLicensees"), TEXT("CarefullyRedist") }; FString ModuleDir = FPlatformProcess::GetModulesDirectory(); for (const TCHAR* RestrictedFolderName : RestrictedFolderNames) { FString RestrictedFolder = ModuleDir / RestrictedFolderName; if (FPaths::DirectoryExists(RestrictedFolder)) { AddBinariesDirectory(*RestrictedFolder, false); } } #endif BuiltDirectories = true; } void FModulePaths::AddBinariesDirectory(const TCHAR *InDirectory, bool bIsGameDirectory) { if (bIsGameDirectory) { GameBinariesDirectories.Add(InDirectory); } else { EngineBinariesDirectories.Add(InDirectory); } // Also recurse into restricted sub-folders, if they exist const TCHAR* RestrictedFolderNames[] = { TEXT("NoRedist"), TEXT("NotForLicensees"), TEXT("CarefullyRedist") }; for (const TCHAR* RestrictedFolderName : RestrictedFolderNames) { FString RestrictedFolder = FPaths::Combine(InDirectory, RestrictedFolderName); if (FPaths::DirectoryExists(RestrictedFolder)) { AddBinariesDirectory(*RestrictedFolder, bIsGameDirectory); } } }
33.016393
192
0.75091
MiheevN
4d6281f71e8ce24ab6c75d1b89c61b74bbeb1d95
578
hpp
C++
src/AST/Expressions/FunctionCallExpression.hpp
CarsonFox/CPSL
07a949166d9399f273ddf15e239ade6e5ea6e4a5
[ "MIT" ]
null
null
null
src/AST/Expressions/FunctionCallExpression.hpp
CarsonFox/CPSL
07a949166d9399f273ddf15e239ade6e5ea6e4a5
[ "MIT" ]
null
null
null
src/AST/Expressions/FunctionCallExpression.hpp
CarsonFox/CPSL
07a949166d9399f273ddf15e239ade6e5ea6e4a5
[ "MIT" ]
null
null
null
#pragma once #include "ExpressionList.hpp" struct FunctionCallExpression : Expression { std::string id; std::vector<std::shared_ptr<Expression>> args; FunctionCallExpression(char *, ExpressionList *); ~FunctionCallExpression() override = default; void print() const override; bool isConst() const override; std::optional<int> try_fold() override; std::string emitToRegister(SymbolTable &table, RegisterPool &pool) override; void emitTailCall(SymbolTable &table, RegisterPool &pool); type getType(SymbolTable &table) override; };
24.083333
80
0.723183
CarsonFox
4d644f6346992070b3021e1b3d9ca09e77b4e09b
5,262
hpp
C++
include/lbann/layers/loss/cross_entropy.hpp
andy-yoo/lbann-andy
237c45c392e7a5548796ac29537ab0a374e7e825
[ "Apache-2.0" ]
null
null
null
include/lbann/layers/loss/cross_entropy.hpp
andy-yoo/lbann-andy
237c45c392e7a5548796ac29537ab0a374e7e825
[ "Apache-2.0" ]
null
null
null
include/lbann/layers/loss/cross_entropy.hpp
andy-yoo/lbann-andy
237c45c392e7a5548796ac29537ab0a374e7e825
[ "Apache-2.0" ]
null
null
null
//////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2014-2016, Lawrence Livermore National Security, LLC. // Produced at the Lawrence Livermore National Laboratory. // Written by the LBANN Research Team (B. Van Essen, et al.) listed in // the CONTRIBUTORS file. <lbann-dev@llnl.gov> // // LLNL-CODE-697807. // All rights reserved. // // This file is part of LBANN: Livermore Big Artificial Neural Network // Toolkit. For details, see http://software.llnl.gov/LBANN or // https://github.com/LLNL/LBANN. // // Licensed under the Apache License, Version 2.0 (the "Licensee"); you // may not use this file except in compliance with the License. You may // obtain a copy of the License at: // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or // implied. See the License for the specific language governing // permissions and limitations under the license. //////////////////////////////////////////////////////////////////////////////// #ifndef LBANN_LAYERS_LOSS_CROSS_ENTROPY_HPP_INCLUDED #define LBANN_LAYERS_LOSS_CROSS_ENTROPY_HPP_INCLUDED #include "lbann/layers/layer.hpp" namespace lbann { /** Cross entropy layer. * Given a predicted distribution \f$y\f$ and ground truth * distribution \f$\hat{y}\f$, the cross entropy is * \f[ * CE(y,\hat{y}) = - \sum\limits_{i} \hat{y}_i \log y_i * \f] */ template <data_layout T_layout, El::Device Dev> class cross_entropy_layer : public Layer { public: cross_entropy_layer(lbann_comm *comm) : Layer(comm) { set_output_dims({1}); // Expects inputs for prediction and ground truth m_expected_num_parent_layers = 2; } cross_entropy_layer(const cross_entropy_layer& other) : Layer(other) { m_workspace.reset(other.m_workspace ? other.m_workspace->Copy() : nullptr); } cross_entropy_layer& operator=(const cross_entropy_layer& other) { Layer::operator=(other); m_workspace.reset(other.m_workspace ? other.m_workspace->Copy() : nullptr); return *this; } cross_entropy_layer* copy() const override { return new cross_entropy_layer(*this); } std::string get_type() const override { return "cross entropy"; } data_layout get_data_layout() const override { return T_layout; } El::Device get_device_allocation() const override { return Dev; } void setup_data() override { Layer::setup_data(); // Initialize workspace const auto& prediction = get_prev_activations(0); switch (get_data_layout()) { case data_layout::DATA_PARALLEL: m_workspace.reset(new StarVCMat<Dev>(prediction.Grid(), prediction.Root())); break; case data_layout::MODEL_PARALLEL: m_workspace.reset(new StarMRMat<Dev>(prediction.Grid(), prediction.Root())); break; default: LBANN_ERROR("invalid data layout"); } #ifdef HYDROGEN_HAVE_CUB if (m_workspace->GetLocalDevice() == El::Device::GPU) { m_workspace->Matrix().SetMemoryMode(1); // CUB memory pool } #endif // HYDROGEN_HAVE_CUB } void fp_compute() override { // Initialize workspace const auto& prediction = get_prev_activations(0); m_workspace->AlignWith(prediction.DistData()); m_workspace->Resize(1, prediction.Width()); // Compute local contributions and accumulate /// @todo Consider reduce rather than allreduce local_fp_compute(get_local_prev_activations(0), get_local_prev_activations(1), m_workspace->Matrix()); m_comm->allreduce(*m_workspace, m_workspace->RedundantComm()); El::Copy(*m_workspace, get_activations()); } void bp_compute() override { // Initialize workspace const auto& prediction = get_prev_activations(0); m_workspace->AlignWith(prediction.DistData()); El::Copy(get_prev_error_signals(), *m_workspace); // Compute local gradients local_bp_compute(get_local_prev_activations(0), get_local_prev_activations(1), m_workspace->LockedMatrix(), get_local_error_signals(0), get_local_error_signals(1)); } private: /** Compute local contributions to cross entropy loss. */ static void local_fp_compute(const AbsMat& local_prediction, const AbsMat& local_ground_truth, AbsMat& local_contribution); /** Compute local gradients. */ static void local_bp_compute(const AbsMat& local_prediction, const AbsMat& local_ground_truth, const AbsMat& local_gradient_wrt_output, AbsMat& local_gradient_wrt_prediction, AbsMat& local_gradient_wrt_ground_truth); /** Workspace matrix. */ std::unique_ptr<AbsDistMat> m_workspace; }; } // namespace lbann #endif // LBANN_LAYERS_LOSS_CROSS_ENTROPY_HPP_INCLUDED
35.08
87
0.640631
andy-yoo
4d67debeb5f31a7517fef7231be535c0f7e330fd
31,714
cc
C++
lullaby/systems/transform/transform_system.cc
dd181818/lullaby
71e696c3798068a350e820433c9d3185fa28c0ce
[ "Apache-2.0" ]
1
2018-11-09T03:45:25.000Z
2018-11-09T03:45:25.000Z
lullaby/systems/transform/transform_system.cc
dd181818/lullaby
71e696c3798068a350e820433c9d3185fa28c0ce
[ "Apache-2.0" ]
null
null
null
lullaby/systems/transform/transform_system.cc
dd181818/lullaby
71e696c3798068a350e820433c9d3185fa28c0ce
[ "Apache-2.0" ]
null
null
null
/* Copyright 2017 Google Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "lullaby/systems/transform/transform_system.h" #include <algorithm> #include <sstream> #include "lullaby/events/entity_events.h" #include "lullaby/modules/dispatcher/dispatcher.h" #include "lullaby/modules/ecs/entity_factory.h" #include "lullaby/modules/flatbuffers/mathfu_fb_conversions.h" #include "lullaby/modules/script/function_binder.h" #include "lullaby/systems/dispatcher/event.h" #include "lullaby/util/logging.h" #include "lullaby/generated/transform_def_generated.h" namespace { // Given an |index| into a list containing |list_size| elements, this transforms // |index| into a valid offset. Allows for negative indices, where '-1' would // map to the last position, '-2', the second to last, etc. Clamps to the valid // range of the |list_size|. size_t RoundAndClampIndex(int index, size_t list_size) { if (index < 0) { if (static_cast<unsigned int>(index * -1) > list_size) { return 0; } else { return list_size + index; } } else { if (static_cast<unsigned int>(index) >= list_size) { return list_size - 1; } else { return static_cast<size_t>(index); } } } } // namespace namespace lull { const TransformSystem::TransformFlags TransformSystem::kInvalidFlag = 0; const TransformSystem::TransformFlags TransformSystem::kAllFlags = ~0; const HashValue kTransformDefHash = ConstHash("TransformDef"); TransformSystem::TransformSystem(Registry* registry) : System(registry), nodes_(16), world_transforms_(16), disabled_transforms_(16), reserved_flags_(0) { RegisterDef(this, kTransformDefHash); EntityFactory* entity_factory = registry_->Get<EntityFactory>(); if (entity_factory) { entity_factory->SetCreateChildFn( [this, entity_factory](Entity parent, BlueprintTree* bpt) -> Entity { if (parent == kNullEntity) { LOG(DFATAL) << "Attempted to create a child for a null parent. " << "Creating child as a parentless entity instead"; return entity_factory->Create(bpt); } const Entity child = entity_factory->Create(); pending_children_[child] = parent; const Entity created_child = entity_factory->Create(child, bpt); pending_children_.erase(child); return created_child; }); } FunctionBinder* binder = registry->Get<FunctionBinder>(); if (binder) { binder->RegisterMethod("lull.Transform.Enable", &lull::TransformSystem::Enable); binder->RegisterMethod("lull.Transform.Disable", &lull::TransformSystem::Disable); binder->RegisterMethod("lull.Transform.IsEnabled", &lull::TransformSystem::IsEnabled); binder->RegisterMethod("lull.Transform.IsLocallyEnabled", &lull::TransformSystem::IsLocallyEnabled); binder->RegisterMethod("lull.Transform.SetLocalTranslation", &lull::TransformSystem::SetLocalTranslation); binder->RegisterMethod("lull.Transform.SetLocalRotation", &lull::TransformSystem::SetLocalRotation); binder->RegisterMethod("lull.Transform.SetLocalScale", &lull::TransformSystem::SetLocalScale); binder->RegisterMethod("lull.Transform.GetLocalTranslation", &lull::TransformSystem::GetLocalTranslation); binder->RegisterMethod("lull.Transform.GetLocalRotation", &lull::TransformSystem::GetLocalRotation); binder->RegisterMethod("lull.Transform.GetLocalScale", &lull::TransformSystem::GetLocalScale); binder->RegisterMethod("lull.Transform.SetWorldFromEntityMatrix", &lull::TransformSystem::SetWorldFromEntityMatrix); binder->RegisterFunction( "lull.Transform.GetWorldFromEntityMatrix", [this](Entity e) { return *GetWorldFromEntityMatrix(e); }); binder->RegisterMethod("lull.Transform.GetParent", &lull::TransformSystem::GetParent); binder->RegisterFunction( "lull.Transform.AddChild", [this](Entity parent, Entity child) { AddChild(parent, child, ModifyParentChildMode::kPreserveParentToEntityTransform); }); binder->RegisterFunction( "lull.Transform.AddChildPreserveWorldToEntityTransform", [this](Entity parent, Entity child) { AddChild(parent, child, ModifyParentChildMode::kPreserveWorldToEntityTransform); }); binder->RegisterMethod("lull.Transform.CreateChild", &lull::TransformSystem::CreateChild); binder->RegisterMethod("lull.Transform.CreateChildWithEntity", &lull::TransformSystem::CreateChildWithEntity); binder->RegisterFunction( "lull.Transform.RemoveParent", [this](Entity child) { RemoveParent(child, ModifyParentChildMode::kPreserveParentToEntityTransform); }); binder->RegisterFunction( "lull.Transform.GetChildren", [this](Entity parent) { return *GetChildren(parent); }); binder->RegisterMethod("lull.Transform.IsAncestorOf", &lull::TransformSystem::IsAncestorOf); } auto* dispatcher = registry->Get<Dispatcher>(); if (dispatcher) { dispatcher->Connect( this, [this](const EnableEvent& event) { Enable(event.entity); }); dispatcher->Connect( this, [this](const DisableEvent& event) { Disable(event.entity); }); dispatcher->Connect(this, [this](const AddChildEvent& event) { AddChild(event.entity, event.child, ModifyParentChildMode::kPreserveParentToEntityTransform); }); dispatcher->Connect( this, [this](const AddChildPreserveWorldToEntityTransformEvent& event) { AddChild(event.entity, event.child, ModifyParentChildMode::kPreserveWorldToEntityTransform); }); dispatcher->Connect(this, [this](const CreateChildEvent& e) { CreateChildWithEntity(e.parent, e.child, e.blueprint); }); dispatcher->Connect(this, [this](const InsertChildEvent& e) { InsertChild(e.entity, e.child, e.index); }); dispatcher->Connect(this, [this](const MoveChildEvent& e) { MoveChild(e.entity, e.index); }); dispatcher->Connect( this, [this](const RemoveChildEvent& e) { RemoveParent(e.child); }); dispatcher->Connect(this, [this](const SetWorldFromEntityMatrixEvent& e) { SetWorldFromEntityMatrix(e.entity, e.transform); }); dispatcher->Connect(this, [this](const SetPositionEvent& e) { const Sqt* sqt = GetSqt(e.entity); if (sqt) { Sqt target = *sqt; target.translation = e.position; SetSqt(e.entity, target); } }); dispatcher->Connect(this, [this](const SetRotationEvent& e) { const Sqt* sqt = GetSqt(e.entity); if (sqt) { Sqt target = *sqt; target.rotation = e.rotation; SetSqt(e.entity, target); } }); dispatcher->Connect(this, [this](const SetScaleEvent& e) { const Sqt* sqt = GetSqt(e.entity); if (sqt) { Sqt target = *sqt; target.scale = e.scale; SetSqt(e.entity, target); } }); dispatcher->Connect(this, [this](const SetAabbEvent& e) { const Aabb aabb(e.min, e.max); SetAabb(e.entity, aabb); }); } } TransformSystem::~TransformSystem() { FunctionBinder* binder = registry_->Get<FunctionBinder>(); if (binder) { binder->UnregisterFunction("lull.Transform.Enable"); binder->UnregisterFunction("lull.Transform.Disable"); binder->UnregisterFunction("lull.Transform.IsEnabled"); binder->UnregisterFunction("lull.Transform.IsLocallyEnabled"); binder->UnregisterFunction("lull.Transform.SetLocalTranslation"); binder->UnregisterFunction("lull.Transform.SetLocalRotation"); binder->UnregisterFunction("lull.Transform.SetLocalScale"); binder->UnregisterFunction("lull.Transform.GetLocalTranslation"); binder->UnregisterFunction("lull.Transform.GetLocalRotation"); binder->UnregisterFunction("lull.Transform.GetLocalScale"); binder->UnregisterFunction("lull.Transform.SetWorldFromEntityMatrix"); binder->UnregisterFunction("lull.Transform.GetWorldFromEntityMatrix"); binder->UnregisterFunction("lull.Transform.GetParent"); binder->UnregisterFunction("lull.Transform.AddChild"); binder->UnregisterFunction("lull.Transform.CreateChild"); binder->UnregisterFunction("lull.Transform.CreateChildWithEntity"); binder->UnregisterFunction("lull.Transform.RemoveParent"); binder->UnregisterFunction("lull.Transform.GetChildren"); binder->UnregisterFunction("lull.Transform.IsAncestorOf"); } auto* dispatcher = registry_->Get<Dispatcher>(); if (dispatcher) { dispatcher->DisconnectAll(this); } } void TransformSystem::Create(Entity e, HashValue type, const Def* def) { if (type != kTransformDefHash) { LOG(DFATAL) << "Invalid type passed to Create. Expecting TransformDef!"; return; } auto data = ConvertDef<TransformDef>(def); auto node = nodes_.Emplace(e); if (!node) { LOG(DFATAL) << "Encountered null node!"; return; } auto world_transform = world_transforms_.Emplace(e); if (!world_transform) { LOG(DFATAL) << "Encountered null world transform!"; nodes_.Destroy(e); return; } node->enable_self = data->enabled(); MathfuVec3FromFbVec3(data->position(), &node->local_sqt.translation); if (data->quaternion()) { MathfuQuatFromFbVec4(data->quaternion(), &node->local_sqt.rotation); } else { MathfuQuatFromFbVec3(data->rotation(), &node->local_sqt.rotation); } MathfuVec3FromFbVec3(data->scale(), &node->local_sqt.scale); AabbFromFbAabb(data->aabb(), &world_transform->box); node->world_from_entity_matrix_function = CalculateWorldFromEntityMatrix; node->local_sqt_function = CalculateLocalSqt; if (data->aabb_padding()) { AabbFromFbAabb(data->aabb_padding(), &node->aabb_padding); world_transform->box.min += node->aabb_padding.min; world_transform->box.max += node->aabb_padding.max; } auto iter = pending_children_.find(e); if (iter != pending_children_.end()) { AddChildNoEvent(iter->second, e, ModifyParentChildMode::kPreserveParentToEntityTransform); } else { RecalculateWorldFromEntityMatrix(e); UpdateEnabled(e, IsEnabled(node->parent)); } } void TransformSystem::Create(Entity e, const Sqt& sqt) { GraphNode* node = nodes_.Get(e); if (!node) { node = nodes_.Emplace(e); world_transforms_.Emplace(e); node->world_from_entity_matrix_function = CalculateWorldFromEntityMatrix; node->local_sqt_function = CalculateLocalSqt; } node->local_sqt = sqt; RecalculateWorldFromEntityMatrix(e); } void TransformSystem::PostCreateInit(Entity e, HashValue type, const Def* def) { if (type != kTransformDefHash) { LOG(DFATAL) << "Invalid type passed to PostCreateInit. Expecting TransformDef!"; return; } auto iter = pending_children_.find(e); if (iter != pending_children_.end()) { const Entity parent = iter->second; SendEvent(registry_, parent, ChildAddedEvent(parent, e)); SendEvent(registry_, e, ParentChangedEvent(e, kNullEntity, parent)); SendEventImmediately(registry_, e, ParentChangedImmediateEvent(e, kNullEntity, parent)); } auto data = ConvertDef<TransformDef>(def); if (data->children()) { for (auto child = data->children()->begin(); child != data->children()->end(); ++child) { CreateChild(e, child->c_str()); } } } void TransformSystem::Destroy(Entity e) { // First destroy any children. auto children = GetChildren(e); if (children) { EntityFactory* entity_factory = registry_->Get<EntityFactory>(); // Make a local copy to avoid re-entrancy problems. std::vector<Entity> local_children(*children); for (auto& child : local_children) { entity_factory->Destroy(child); } } auto node = nodes_.Get(e); if (node) { Entity parent = GetParent(e); RemoveParentNoEvent(e); // Only send out the global events in Destroy since this entity's local // dispatcher (and possibly the parent's) could already be destroyed. auto* dispatcher = registry_->Get<Dispatcher>(); if (dispatcher && parent != kNullEntity) { dispatcher->Send(ChildRemovedEvent(parent, e)); dispatcher->Send(ParentChangedEvent(e, parent, kNullEntity)); dispatcher->SendImmediately( ParentChangedImmediateEvent(e, parent, kNullEntity)); } nodes_.Destroy(e); } world_transforms_.Destroy(e); disabled_transforms_.Destroy(e); } void TransformSystem::SetFlag(Entity e, TransformFlags flag) { auto transform = GetWorldTransform(e); if (transform) { transform->flags = SetBit(transform->flags, flag); } } void TransformSystem::ClearFlag(Entity e, TransformFlags flag) { auto transform = GetWorldTransform(e); if (transform) { transform->flags = ClearBit(transform->flags, flag); } } bool TransformSystem::HasFlag(Entity e, TransformFlags flag) const { auto transform = GetWorldTransform(e); return transform ? CheckBit(transform->flags, flag) : false; } void TransformSystem::SetAabb(Entity e, Aabb box) { auto transform = GetWorldTransform(e); if (transform) { transform->box = box; const auto node = nodes_.Get(e); if (node) { transform->box.min += node->aabb_padding.min; transform->box.max += node->aabb_padding.max; } } SendEvent(registry_, e, AabbChangedEvent(e)); } const Aabb* TransformSystem::GetAabb(Entity e) const { auto transform = GetWorldTransform(e); return transform ? &transform->box : nullptr; } void TransformSystem::SetAabbPadding(Entity e, const Aabb& padding) { auto node = nodes_.Get(e); if (!node) { return; } auto transform = GetWorldTransform(e); if (transform) { transform->box.min += -node->aabb_padding.min + padding.min; transform->box.max += -node->aabb_padding.max + padding.max; } node->aabb_padding = padding; } const Aabb* TransformSystem::GetAabbPadding(Entity e) const { const auto node = nodes_.Get(e); return node ? &node->aabb_padding : nullptr; } void TransformSystem::Enable(Entity e) { SetEnabled(e, true); } void TransformSystem::Disable(Entity e) { SetEnabled(e, false); } bool TransformSystem::IsEnabled(Entity e) const { // We want to return true if the entity is enabled OR if it doesn't exist. // Thus, we only need to check if the entity exists in the disabled pool. return !disabled_transforms_.Contains(e); } bool TransformSystem::IsLocallyEnabled(Entity e) const { const auto node = nodes_.Get(e); return node ? node->enable_self : true; } void TransformSystem::SetSqt(Entity e, const Sqt& sqt) { auto node = nodes_.Get(e); if (node) { node->local_sqt = sqt; RecalculateWorldFromEntityMatrix(e); } } const Sqt* TransformSystem::GetSqt(Entity e) const { auto node = nodes_.Get(e); return node ? &node->local_sqt : nullptr; } void TransformSystem::ApplySqt(Entity e, const Sqt& modifier) { auto node = nodes_.Get(e); if (node) { node->local_sqt.translation += modifier.translation; node->local_sqt.rotation = node->local_sqt.rotation * modifier.rotation; node->local_sqt.scale *= modifier.scale; RecalculateWorldFromEntityMatrix(e); } } void TransformSystem::SetLocalTranslation(Entity e, const mathfu::vec3& translation) { auto node = nodes_.Get(e); if (node) { node->local_sqt.translation = translation; RecalculateWorldFromEntityMatrix(e); } } mathfu::vec3 TransformSystem::GetLocalTranslation(Entity e) const { const Sqt* sqt = GetSqt(e); return sqt ? sqt->translation : mathfu::vec3(0, 0, 0); } void TransformSystem::SetLocalRotation(Entity e, const mathfu::quat& rotation) { auto node = nodes_.Get(e); if (node) { node->local_sqt.rotation = rotation; RecalculateWorldFromEntityMatrix(e); } } mathfu::quat TransformSystem::GetLocalRotation(Entity e) const { const Sqt* sqt = GetSqt(e); return sqt ? sqt->rotation : mathfu::quat(0, 0, 0, 0); } void TransformSystem::SetLocalScale(Entity e, const mathfu::vec3& scale) { auto node = nodes_.Get(e); if (node) { node->local_sqt.scale = scale; RecalculateWorldFromEntityMatrix(e); } } mathfu::vec3 TransformSystem::GetLocalScale(Entity e) const { const Sqt* sqt = GetSqt(e); return sqt ? sqt->scale : mathfu::vec3(0, 0, 0); } void TransformSystem::SetWorldFromEntityMatrix( Entity e, const mathfu::mat4& world_from_entity_mat) { auto node = nodes_.Get(e); if (node == nullptr) { return; } mathfu::mat4* world_from_parent_mat = nullptr; auto parent = GetWorldTransform(node->parent); if (parent) { world_from_parent_mat = &parent->world_from_entity_mat; } node->local_sqt = node->local_sqt_function(world_from_entity_mat, world_from_parent_mat); RecalculateWorldFromEntityMatrix(e); } const mathfu::mat4* TransformSystem::GetWorldFromEntityMatrix(Entity e) const { auto transform = GetWorldTransform(e); return transform ? &transform->world_from_entity_mat : nullptr; } void TransformSystem::SetWorldFromEntityMatrixFunction( Entity e, const CalculateWorldFromEntityMatrixFunc& func, const CalculateLocalSqtFunc* inverse_func) { auto node = nodes_.Get(e); if (node) { node->world_from_entity_matrix_function = func ? func : CalculateWorldFromEntityMatrix; node->local_sqt_function = inverse_func ? *inverse_func : CalculateLocalSqt; #ifdef DEBUG if (func != nullptr && inverse_func == nullptr) { node->local_sqt_function = [e](const mathfu::mat4& world_from_entity_mat, const mathfu::mat4* world_from_parent_mat) { // If you see this log, then whatever is calling // SetWorldFromEntityMatrixFunction needs to implement a function to // calculate the local sqt based on a matrix. LOG(WARNING) << "Attempting to calculate local SQT from " "WorldFromEntityMatrix on entity " << e << ", which does not have a custom CalculateLocalSqt " "function."; return CalculateLocalSqt(world_from_entity_mat, world_from_parent_mat); }; } #endif RecalculateWorldFromEntityMatrix(e); } } Entity TransformSystem::GetParent(Entity child) const { const auto* node = nodes_.Get(child); return node ? node->parent : kNullEntity; } Entity TransformSystem::GetRoot(Entity entity) const { const auto* node = nodes_.Get(entity); if (!node) { return kNullEntity; } Entity root = entity; while (node && node->parent != lull::kNullEntity) { root = node->parent; node = nodes_.Get(node->parent); } return root; } bool TransformSystem::AddChildNoEvent(Entity parent, Entity child, ModifyParentChildMode mode) { if (parent == kNullEntity) { LOG(INFO) << "Cannot add a child to a null parent."; return false; } if (parent == child) { LOG(DFATAL) << "Cannot make an entity its own child."; return false; } if (IsAncestorOf(child, parent)) { LOG(DFATAL) << "Cannot make a node a parent of one of its ancestors."; return false; } auto child_node = nodes_.Get(child); if (!child_node) { LOG(DFATAL) << "Invalid - the child entity doesn't exist."; return false; } if (child_node->parent == parent) { LOG(DFATAL) << "Parent-child relationship already established."; return false; } if (child_node->parent) { RemoveParentNoEvent(child); } const mathfu::mat4* matrix_ptr = nullptr; if (mode == ModifyParentChildMode::kPreserveWorldToEntityTransform) { matrix_ptr = GetWorldFromEntityMatrix(child); if (!matrix_ptr) { LOG(DFATAL) << "No world from entity matrix to keep."; return false; } } auto parent_node = nodes_.Get(parent); if (!parent_node) { // Do nothing if parent doesn't exist. return true; } parent_node->children.emplace_back(child); child_node->parent = parent; if (mode == ModifyParentChildMode::kPreserveWorldToEntityTransform) { // This will call RecalculateWorldFromEntityMatrix(). SetWorldFromEntityMatrix(child, *matrix_ptr); } else { RecalculateWorldFromEntityMatrix(child); } const bool parent_enabled = IsEnabled(parent); UpdateEnabled(child, parent_enabled); return true; } void TransformSystem::AddChild(Entity parent, Entity child, ModifyParentChildMode mode) { auto child_node = nodes_.Get(child); if (!child_node) { LOG(DFATAL) << "Invalid - the child entity doesn't exist."; return; } auto old_parent = child_node->parent; if (AddChildNoEvent(parent, child, mode)) { SendEvent(registry_, parent, ChildAddedEvent(parent, child)); SendEvent(registry_, child, ParentChangedEvent(child, old_parent, parent)); SendEventImmediately( registry_, child, ParentChangedImmediateEvent(child, old_parent, parent)); } } Entity TransformSystem::CreateChild(Entity parent, const std::string& name) { EntityFactory* entity_factory = registry_->Get<EntityFactory>(); const Entity child = entity_factory->Create(); return CreateChildWithEntity(parent, child, name); } Entity TransformSystem::CreateChildWithEntity(Entity parent, Entity child, const std::string& name) { EntityFactory* entity_factory = registry_->Get<EntityFactory>(); if (child == kNullEntity) { LOG(INFO) << "Attempted to create child using a null entity."; return child; } if (parent == kNullEntity) { LOG(INFO) << "Attempted to create a child for a null parent. Creating" << " child as a parentless entity instead"; return entity_factory->Create(child, name); } const auto node = nodes_.Get(child); if (node) { LOG(INFO) << "Child already has a Transform component."; return child; } pending_children_[child] = parent; const Entity created_child = entity_factory->Create(child, name); pending_children_.erase(child); return created_child; } void TransformSystem::InsertChild(Entity parent, Entity child, int index) { if (GetParent(child) != parent) { AddChild(parent, child); } MoveChild(child, index); } void TransformSystem::MoveChild(Entity child, int index) { const auto child_node = nodes_.Get(child); if (!child_node || child_node->parent == kNullEntity) { return; } auto parent_node = nodes_.Get(child_node->parent); if (!parent_node) { return; } auto& children = parent_node->children; const size_t num_children = children.size(); // Get iterator to child's current position. const auto source = std::find(children.begin(), children.end(), child); if (source == children.end()) { LOG(DFATAL) << "Child entity not found in its parent's list of children."; return; } const size_t old_index = static_cast<size_t>(source - children.begin()); const size_t new_index = RoundAndClampIndex(index, num_children); const auto destination = children.begin() + new_index; if (source >= destination) { std::rotate(destination, source, source + 1); } else { std::rotate(source, source + 1, destination + 1); } SendEvent( registry_, child_node->parent, ChildIndexChangedEvent(child_node->parent, child, old_index, new_index)); } void TransformSystem::RemoveParentNoEvent(Entity child) { auto child_node = nodes_.Get(child); if (child_node && child_node->parent) { auto parent_node = nodes_.Get(child_node->parent); if (parent_node) { parent_node->children.erase( std::remove(parent_node->children.begin(), parent_node->children.end(), child), parent_node->children.end()); } child_node->parent = kNullEntity; } } void TransformSystem::RemoveParent(Entity child, ModifyParentChildMode mode) { const auto* node = nodes_.Get(child); const auto* world_from_entity_matrix = GetWorldFromEntityMatrix(child); if (!node || !world_from_entity_matrix) { return; } auto parent = GetParent(child); if (parent == kNullEntity) { return; } RemoveParentNoEvent(child); if (mode == ModifyParentChildMode::kPreserveParentToEntityTransform) { RecalculateWorldFromEntityMatrix(child); } else { // kPreserveWorldToEntityTransform SetWorldFromEntityMatrix(child, *world_from_entity_matrix); } UpdateEnabled(child, true); SendEvent(registry_, parent, ChildRemovedEvent(parent, child)); SendEvent(registry_, child, ParentChangedEvent(child, parent, kNullEntity)); SendEventImmediately(registry_, child, ParentChangedImmediateEvent(child, parent, kNullEntity)); } void TransformSystem::DestroyChildren(Entity parent) { const std::vector<Entity>* children = GetChildren(parent); if (!children) { return; } auto* entity_factory = registry_->Get<EntityFactory>(); // Make a local copy of the children to avoid re-entrancy problems. const std::vector<Entity> children_copy(*children); for (const auto child : children_copy) { entity_factory->Destroy(child); } } const std::vector<Entity>* TransformSystem::GetChildren(Entity parent) const { auto node = nodes_.Get(parent); if (node) { return &node->children; } return nullptr; } size_t TransformSystem::GetChildCount(Entity parent) const { auto node = nodes_.Get(parent); if (node) { return node->children.size(); } return 0; } size_t TransformSystem::GetChildIndex(Entity child) const { auto child_node = nodes_.Get(child); if (child_node == nullptr) { // Child has no TransformDef. LOG(DFATAL) << "GetChildIndex called on entity with no TransformDef."; return 0; } Entity parent = GetParent(child); auto parent_node = nodes_.Get(parent); if (parent_node == nullptr) { // Child has no parent. return 0; } const auto& children = parent_node->children; auto found = std::find(children.begin(), children.end(), child); if (found == children.end()) { return 0; } else { return static_cast<size_t>(found - children.begin()); } } bool TransformSystem::IsAncestorOf(Entity ancestor, Entity target) const { auto node = nodes_.Get(target); while (node && node->parent != kNullEntity) { if (node->parent == ancestor) { return true; } node = nodes_.Get(node->parent); } return false; } mathfu::mat4 TransformSystem::CalculateWorldFromEntityMatrix( const Sqt& local_sqt, const mathfu::mat4* world_from_parent_mat) { mathfu::mat4 parent_from_local_mat = CalculateTransformMatrix(local_sqt); if (world_from_parent_mat) { return (*world_from_parent_mat) * parent_from_local_mat; } else { return parent_from_local_mat; } } Sqt TransformSystem::CalculateLocalSqt( const mathfu::mat4& world_from_entity_mat, const mathfu::mat4* world_from_parent_mat) { mathfu::mat4 parent_from_local_mat(world_from_entity_mat); if (world_from_parent_mat) { parent_from_local_mat = world_from_parent_mat->Inverse() * world_from_entity_mat; } return CalculateSqtFromMatrix(parent_from_local_mat); } void TransformSystem::RecalculateWorldFromEntityMatrix(Entity child) { const auto* node = nodes_.Get(child); auto* world_transform = GetWorldTransform(child); if (!node || !world_transform) { return; } world_transform->world_from_entity_mat = node->world_from_entity_matrix_function( node->local_sqt, GetWorldFromEntityMatrix(node->parent)); for (const auto& grand_child : node->children) { RecalculateWorldFromEntityMatrix(grand_child); } } void TransformSystem::SetEnabled(Entity e, bool enabled) { auto node = nodes_.Get(e); if (node && node->enable_self != enabled) { node->enable_self = enabled; const bool parent_enabled = IsEnabled(node->parent); UpdateEnabled(e, parent_enabled); } } void TransformSystem::UpdateEnabled(Entity e, bool parent_enabled) { auto graph_node = nodes_.Get(e); if (!graph_node) { return; } const bool enabled = graph_node->enable_self; auto transform = world_transforms_.Get(e); bool changed = false; if (transform) { if (!enabled || !parent_enabled) { changed = true; disabled_transforms_.Emplace(std::move(*transform)); world_transforms_.Destroy(e); SendEvent(registry_, e, OnDisabledEvent(e)); } } else { transform = disabled_transforms_.Get(e); if (transform) { if (enabled && parent_enabled) { changed = true; world_transforms_.Emplace(std::move(*transform)); disabled_transforms_.Destroy(e); SendEvent(registry_, e, OnEnabledEvent(e)); } } } if (changed) { for (auto& child : graph_node->children) { UpdateEnabled(child, enabled && parent_enabled); } } } const TransformSystem::WorldTransform* TransformSystem::GetWorldTransform( Entity e) const { auto transform = world_transforms_.Get(e); if (!transform) { transform = disabled_transforms_.Get(e); } return transform; } TransformSystem::WorldTransform* TransformSystem::GetWorldTransform(Entity e) { auto transform = world_transforms_.Get(e); if (!transform) { transform = disabled_transforms_.Get(e); } return transform; } TransformSystem::TransformFlags TransformSystem::RequestFlag() { const int kNumBits = 8 * sizeof(TransformFlags); for (TransformFlags i = 0; i < kNumBits; ++i) { TransformFlags flag = 1 << i; if (!CheckBit(reserved_flags_, flag)) { reserved_flags_ = SetBit(reserved_flags_, flag); return flag; } } LOG(FATAL) << "Ran out of flags"; return kInvalidFlag; } void TransformSystem::ReleaseFlag(TransformFlags flag) { if (flag == kInvalidFlag) { LOG(DFATAL) << "Cannot release invalid flag."; return; } reserved_flags_ = ClearBit(reserved_flags_, flag); } std::string TransformSystem::GetEntityTreeDebugString(bool enabled_only) const { const auto& blueprints = registry_->Get<EntityFactory>()->GetEntityToBlueprintMap(); const auto get_blueprint_fn = [&blueprints](Entity e) { const auto r = blueprints.find(e); return r == blueprints.end() ? "anonymous entity" : r->second; }; std::stringstream str; str << "digraph {\n"; for (const auto& node : nodes_) { const Entity parent = node.GetEntity(); if (enabled_only && !IsEnabled(parent)) { continue; } for (const auto& child : node.children) { if (enabled_only && !IsEnabled(child)) { continue; } str << "\"[" << parent << "] " << get_blueprint_fn(parent) << "\"->\"[" << child << "] " << get_blueprint_fn(child) << "\";\n"; } } str << "}"; return str.str(); } } // namespace lull
33.243187
80
0.679321
dd181818
4d6b6e0b6ffd0f3e512a536cb057481079fd0918
5,613
cxx
C++
inetsrv/intlwb/thai2/wb/stemmer.cxx
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
inetsrv/intlwb/thai2/wb/stemmer.cxx
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
inetsrv/intlwb/thai2/wb/stemmer.cxx
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
//+--------------------------------------------------------------------------- // // Microsoft Windows // Copyright (C) Microsoft Corporation, 1997. // // File: stemmer.cxx // // Contents: Thai Stemmer // // History: weibz, 10-Nov-1997 created // //---------------------------------------------------------------------------- #include <pch.cxx> #include "stemmer.hxx" extern long gulcInstances; //+--------------------------------------------------------------------------- // // Member: CStemmer::CStemmer // // Synopsis: Constructor for the CStemmer class. // // Arguments: [lcid] -- locale id // //---------------------------------------------------------------------------- CStemmer::CStemmer( LCID lcid ) : _cRefs(1) { InterlockedIncrement( &gulcInstances ); } //+--------------------------------------------------------------------------- // // Member: CStemmer::~CStemmer // // Synopsis: Destructor for the CStemmer class. // // Notes: All termination/deallocation is done by embedded smart pointers // //---------------------------------------------------------------------------- CStemmer::~CStemmer() { InterlockedDecrement( &gulcInstances ); } //+------------------------------------------------------------------------- // // Method: CStemmer::QueryInterface // // Synopsis: Rebind to other interface // // Arguments: [riid] -- IID of new interface // [ppvObject] -- New interface * returned here // // Returns: S_OK if bind succeeded, E_NOINTERFACE if bind failed // //-------------------------------------------------------------------------- SCODE STDMETHODCALLTYPE CStemmer::QueryInterface( REFIID riid, void ** ppvObject) { if ( 0 == ppvObject ) return E_INVALIDARG; *ppvObject = 0; if ( IID_IStemmer == riid ) *ppvObject = (IUnknown *)(IStemmer *)this; else if ( IID_IUnknown == riid ) *ppvObject = (IUnknown *)this; else return E_NOINTERFACE; AddRef(); return S_OK; } //+------------------------------------------------------------------------- // // Method: CStemmer::AddRef // // Synopsis: Increments refcount // //-------------------------------------------------------------------------- ULONG STDMETHODCALLTYPE CStemmer::AddRef() { return InterlockedIncrement( &_cRefs ); } //+------------------------------------------------------------------------- // // Method: CStemmer::Release // // Synopsis: Decrement refcount. Delete if necessary. // //-------------------------------------------------------------------------- ULONG STDMETHODCALLTYPE CStemmer::Release() { unsigned long uTmp = InterlockedDecrement( &_cRefs ); if ( 0 == uTmp ) delete this; return(uTmp); } //+------------------------------------------------------------------------- // // Method: CStemmer::Init // // Synopsis: Initialize stemmer // // Arguments: [ulMaxTokenSize] -- Maximum size token stored by caller // [pfLicense] -- Set to true if use restricted // // Returns: Status code // //-------------------------------------------------------------------------- SCODE STDMETHODCALLTYPE CStemmer::Init( ULONG ulMaxTokenSize, BOOL *pfLicense ) { if ( NULL == pfLicense ) { return E_INVALIDARG; } if (IsBadWritePtr(pfLicense, sizeof(DWORD))) { return E_INVALIDARG; } *pfLicense = TRUE; _ulMaxTokenSize = ulMaxTokenSize; return S_OK; } //+--------------------------------------------------------------------------- // // Member: CStemmer::GetLicenseToUse // // Synopsis: Returns a pointer to vendors license information // // Arguments: [ppwcsLicense] -- ptr to ptr to which license info is returned // //---------------------------------------------------------------------------- SCODE STDMETHODCALLTYPE CStemmer::GetLicenseToUse( const WCHAR **ppwcsLicense ) { static WCHAR const * wcsCopyright = L"Copyright Microsoft, 1991-1998"; if ( NULL == ppwcsLicense ) { return E_INVALIDARG; } if (IsBadWritePtr(ppwcsLicense, sizeof(DWORD))) { return ( E_INVALIDARG ); } *ppwcsLicense = wcsCopyright; return( S_OK ); } //+--------------------------------------------------------------------------- // // Member: CStemmer::GenerateWordForms // // Synopsis: Stem a word into its inflected forms, eg swim to swims and swimming // // Arguments: [pwcInBuf] -- input Unicode word // [cwc] -- count of characters in word // [pWordFormSink] -- sink to collect inflected forms // //---------------------------------------------------------------------------- SCODE STDMETHODCALLTYPE CStemmer::GenerateWordForms( WCHAR const *pwcInBuf, ULONG cwc, IWordFormSink *pWordFormSink ) { INT nReturn; SCODE sc = S_OK; #ifdef THAIDBG ULONG i; OutputDebugString("\n Stemword\n"); for (i=0; i<cwc; i++) { WORD wtmp; char ctmp[80]; wtmp = pwcInBuf[i]; sprintf(ctmp, "%4x ", wtmp); OutputDebugString(ctmp); } #endif if ( NULL == pWordFormSink || NULL == pwcInBuf) { return E_FAIL; } // Currently, Thai stemmer doesn't make inflection form for tripolli. return pWordFormSink->PutWord (pwcInBuf, cwc); }
25.283784
84
0.441475
npocmaka
4d6cdafaade749c118cd6a6ef84cfd1af3abc49d
875
cpp
C++
SOLVER/src/core/source/elem_src/solid/SolidForce.cpp
nicklinyi/AxiSEM-3D
cd11299605cd6b92eb867d4109d2e6a8f15e6b4d
[ "MIT" ]
8
2020-06-05T01:13:20.000Z
2022-02-24T05:11:50.000Z
SOLVER/src/core/source/elem_src/solid/SolidForce.cpp
nicklinyi/AxiSEM-3D
cd11299605cd6b92eb867d4109d2e6a8f15e6b4d
[ "MIT" ]
24
2020-10-21T19:03:38.000Z
2021-11-17T21:32:02.000Z
SOLVER/src/core/source/elem_src/solid/SolidForce.cpp
nicklinyi/AxiSEM-3D
cd11299605cd6b92eb867d4109d2e6a8f15e6b4d
[ "MIT" ]
5
2020-06-21T11:54:22.000Z
2021-06-23T01:02:39.000Z
// // SolidForce.cpp // AxiSEM3D // // Created by Kuangdai Leng on 3/5/19. // Copyright © 2019 Kuangdai Leng. All rights reserved. // // force source on solid element #include "SolidForce.hpp" #include "SolidElement.hpp" // constructor SolidForce::SolidForce(std::unique_ptr<STF> &stf, const std::shared_ptr<SolidElement> &element, const eigen::CMatXN3 &pattern): SolidSource(stf, element), mPattern(pattern) { // prepare element->prepareForceSource(); // workspace if (sPattern.rows() < mPattern.rows()) { sPattern.resize(mPattern.rows(), spectral::nPEM * 3); } } // apply source at a time step void SolidForce::apply(double time) const { int nu_1 = (int)mPattern.rows(); sPattern.topRows(nu_1) = mPattern * mSTF->getValue(time); mElement->addForceSource(sPattern, nu_1); }
25.735294
68
0.645714
nicklinyi
4d6dd0144c5203b05354fff0a0fc36d19f466ab1
5,400
hpp
C++
src/context-traits.hpp
YutaroOrikasa/user-thread
2d82ee257115e67630f5743ceb169441854fac22
[ "MIT" ]
null
null
null
src/context-traits.hpp
YutaroOrikasa/user-thread
2d82ee257115e67630f5743ceb169441854fac22
[ "MIT" ]
2
2017-05-02T07:02:23.000Z
2017-05-20T09:32:52.000Z
src/context-traits.hpp
YutaroOrikasa/user-thread
2d82ee257115e67630f5743ceb169441854fac22
[ "MIT" ]
null
null
null
#ifndef USER_THREAD_CONTEXTTRAITS_HPP #define USER_THREAD_CONTEXTTRAITS_HPP #include "mysetjmp.h" #include "user-thread-debug.hpp" #include "splitstackapi.h" #include "stack-address-tools.hpp" #include "thread-data/thread-data.hpp" #include "thread-data/splitstack-thread-data.hpp" #include "call_with_alt_stack_arg3.h" #include "config.h" namespace orks { namespace userthread { namespace detail { namespace baddesign { inline void call_with_alt_stack_arg3(char* altstack, std::size_t altstack_size, void* func, void* arg1, void* arg2, void* arg3) __attribute__((no_split_stack)); inline void call_with_alt_stack_arg3(char* altstack, std::size_t altstack_size, void* func, void* arg1, void* arg2, void* arg3) { void* stack_base = altstack + altstack_size; #ifndef USE_SPLITSTACKS // stack boundary was already changed by caller. // debug output will make memory destorying. debug::printf("func %p\n", func); #endif orks_private_call_with_alt_stack_arg3_impl(arg1, arg2, arg3, stack_base, func); } struct BadDesignContextTraits { #ifdef USE_SPLITSTACKS using ThreadData = splitstack::ThreadData; #endif using Context = ThreadData*; template <typename Fn> static Context make_context(Fn fn) { return ThreadData::create(std::move(fn)); } static Context switch_context(Context next_thread, void* transfer_data = nullptr) { return &switch_context_impl(*next_thread, transfer_data); } static bool is_finished(Context ctx) { return ctx->state == ThreadState::ended; } static void destroy_context(Context ctx) { ThreadData::destroy((*ctx)); } void* get_transferred_data(Context ctx) { return ctx->transferred_data; } private: static ThreadData& switch_context_impl(ThreadData& next_thread, void* transfer_data = nullptr, ThreadData* finished_thread = nullptr) { ThreadData current_thread_ {nullptr, nullptr}; ThreadData* current_thread; if (finished_thread == nullptr) { current_thread = &current_thread_; debug::printf("save current thread at %p\n", current_thread); current_thread->state = ThreadState::running; } else { current_thread = finished_thread; debug::printf("current thread %p is finished\n", current_thread); } ThreadData* previous_thread = 0; next_thread.transferred_data = transfer_data; if (next_thread.state == ThreadState::before_launch) { debug::printf("launch user thread!\n"); previous_thread = &context_switch_new_context(*current_thread, next_thread); } else if (next_thread.state == ThreadState::running) { debug::printf("resume user thread %p!\n", &next_thread); previous_thread = &context_switch(*current_thread, next_thread); } else { debug::out << "next_thread " << &next_thread << " invalid state: " << static_cast<int>(next_thread.state) << "\n"; const auto NEVER_COME_HERE = false; assert(NEVER_COME_HERE); } return *previous_thread; } // always_inline for no split stack __attribute__((always_inline)) static ThreadData& context_switch(ThreadData& from, ThreadData& to) { from.save_extra_context(); if (mysetjmp(from.env)) { from.restore_extra_context(); return *from.pass_on_longjmp; } to.pass_on_longjmp = &from; mylongjmp(to.env); const auto NEVER_COME_HERE = false; assert(NEVER_COME_HERE); } // always_inline for no split stack __attribute__((always_inline)) static ThreadData& context_switch_new_context(ThreadData& from, ThreadData& new_ctx) { from.save_extra_context(); if (mysetjmp(from.env)) { from.restore_extra_context(); return *from.pass_on_longjmp; } new_ctx.pass_on_longjmp = &from; assert(new_ctx.get_stack() != 0); assert(new_ctx.get_stack_size() != 0); char* stack_frame = new_ctx.get_stack(); call_with_alt_stack_arg3(stack_frame, new_ctx.get_stack_size(), reinterpret_cast<void*>(entry_thread), &new_ctx, nullptr, nullptr); const auto NEVER_COME_HERE = false; assert(NEVER_COME_HERE); } __attribute__((no_split_stack)) static void entry_thread(ThreadData& thread_data); }; inline void BadDesignContextTraits::entry_thread(ThreadData& thread_data) { thread_data.initialize_extra_context_at_entry_point(); debug::printf("start thread in new stack frame\n"); debug::out << std::endl; thread_data.state = ThreadState::running; Context next = thread_data.call_func(thread_data.pass_on_longjmp); debug::printf("end thread\n"); thread_data.state = ThreadState::ended; debug::printf("end: %p\n", &thread_data); switch_context_impl(*next, thread_data.transferred_data, &thread_data); // no return // this thread context will be deleted by next thread } } } } } namespace orks { namespace userthread { namespace detail { using BadDesignContextTraits = baddesign::BadDesignContextTraits; } } } #endif //USER_THREAD_CONTEXTTRAITS_HPP
27.272727
153
0.663333
YutaroOrikasa
4d6e580c38cfb906fa4cb8a78141dd1970b0eca3
4,254
cpp
C++
src/glplayer.cpp
felixqin/gltest
51f0dab25700a3fdcfba29e61029d6a98c283747
[ "MIT" ]
null
null
null
src/glplayer.cpp
felixqin/gltest
51f0dab25700a3fdcfba29e61029d6a98c283747
[ "MIT" ]
null
null
null
src/glplayer.cpp
felixqin/gltest
51f0dab25700a3fdcfba29e61029d6a98c283747
[ "MIT" ]
null
null
null
#include <QPainter> #include <QOpenGLShader> #include <QTimerEvent> #include "glplayer.h" #define LOGI printf #define LOGE printf CGLPlayer::CGLPlayer(QWidget* parent, Qt::WindowFlags f) : QOpenGLWidget(parent, f) , mGLInitialized(false) , mProgram(NULL) , mVShader(NULL) , mFShader(NULL) , mTextureLocation(0) , mIdTexture(0) , mWidth(640) , mHeight(360) , mImage(NULL) { initImage(); } CGLPlayer::~CGLPlayer() { free(mImage); makeCurrent(); delete mVShader; delete mFShader; delete mProgram; doneCurrent(); } void CGLPlayer::initImage() { int w = mWidth; int h = mHeight; int bytes = w * h * 3; mImage = (char*)malloc(bytes); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { int r = 255, g = 255, b = 255; if (x % 100 != 0 && y % 100 != 0) { r = (x * y) % 255; g = (4 * x) % 255; b = (4 * y) % 255; } int index = (y * w + x) * 3; mImage[index+0] = (GLubyte)r; mImage[index+1] = (GLubyte)g; mImage[index+2] = (GLubyte)b; } } } void CGLPlayer::initializeGL() { initializeOpenGLFunctions(); initShaders(); QColor clearColor(Qt::blue); glClearColor(clearColor.redF(), clearColor.greenF(), clearColor.blueF(), clearColor.alphaF()); mGLInitialized = true; } //Init Shader void CGLPlayer::initShaders() { // https://blog.csdn.net/su_vast/article/details/52214642 // https://blog.csdn.net/ylbs110/article/details/52074826 // https://www.xuebuyuan.com/2119734.html mVShader = new QOpenGLShader(QOpenGLShader::Vertex, this); const char *vsrc = "#version 120\n" "attribute vec4 vertexIn;\n" "attribute vec2 textureIn;\n" "varying vec2 textureOut;\n" "void main(void)\n" "{\n" " gl_Position = vertexIn;\n" " textureOut = textureIn;\n" "}\n"; mVShader->compileSourceCode(vsrc); mFShader = new QOpenGLShader(QOpenGLShader::Fragment, this); const char *fsrc = "#version 120\n" "varying vec2 textureOut;\n" "uniform sampler2D rgb;\n" "void main(void)\n" "{\n" " gl_FragColor = texture2D(rgb, textureOut);\n" "}\n"; mFShader->compileSourceCode(fsrc); mProgram = new QOpenGLShaderProgram(); mProgram->addShader(mVShader); mProgram->addShader(mFShader); mProgram->link(); mProgram->bind(); GLint vetexInLocation = mProgram->attributeLocation("vertexIn"); GLint textureInLocation = mProgram->attributeLocation("textureIn"); mTextureLocation = mProgram->uniformLocation("rgb"); static const GLfloat vertexVertices[] = { // Triangle Strip -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f }; static const GLfloat textureVertices[] = { 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, }; glVertexAttribPointer(vetexInLocation, 2, GL_FLOAT, false, 0, vertexVertices); glEnableVertexAttribArray(vetexInLocation); glVertexAttribPointer(textureInLocation, 2, GL_FLOAT, false, 0, textureVertices); glEnableVertexAttribArray(textureInLocation); glGenTextures(1, &mIdTexture); glBindTexture(GL_TEXTURE_2D, mIdTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } void CGLPlayer::paintGL() { if (!mGLInitialized) { LOGE("is not initialized!\n"); return; } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //glClear(GL_COLOR_BUFFER_BIT); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, mIdTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, mWidth, mHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, mImage); glUniform1i(mTextureLocation, 0); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); }
26.754717
98
0.602257
felixqin
4d703856c91c7aa738c542f8079b22d00ed7ef83
1,337
hpp
C++
include/Entity/States.hpp
cristianglezm/AntFarm
df7551621ad6eda6dae43a2ede56222500be1ae1
[ "Apache-2.0" ]
null
null
null
include/Entity/States.hpp
cristianglezm/AntFarm
df7551621ad6eda6dae43a2ede56222500be1ae1
[ "Apache-2.0" ]
1
2016-03-13T10:55:21.000Z
2016-03-13T10:55:21.000Z
include/Entity/States.hpp
cristianglezm/AntFarm
df7551621ad6eda6dae43a2ede56222500be1ae1
[ "Apache-2.0" ]
null
null
null
//////////////////////////////////////////////////////////////// // Copyright 2014 Cristian Glez <Cristian.glez.m@gmail.com> // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. //////////////////////////////////////////////////////////////// #ifndef STATES_HPP #define STATES_HPP #include <bitset> /** * @brief Estados de las entidades * @author Cristian Glez <Cristian.glez.m@gmail.com> * @version 0.1 */ namespace States{ using Mask = std::bitset<32>; static constexpr Mask NONE = 0; static constexpr Mask GROUND = 1 << 0; static constexpr Mask FALLING = 1 << 1; static constexpr Mask CLIMBING = 1 << 2; static constexpr Mask BUILDING = 1 << 3; static constexpr Mask ONFIRE = 1 << 4; static constexpr Mask SAVED = 1 << 5; static constexpr Mask UNSAVED = 1 << 6; } #endif // STATES_HPP
33.425
75
0.635004
cristianglezm
4d707008debed064cfd47a76892b346cbc88968f
205,605
cc
C++
third_party/blink/renderer/core/layout/layout_block_flow.cc
zipated/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
2,151
2020-04-18T07:31:17.000Z
2022-03-31T08:39:18.000Z
third_party/blink/renderer/core/layout/layout_block_flow.cc
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
third_party/blink/renderer/core/layout/layout_block_flow.cc
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
338
2020-04-18T08:03:10.000Z
2022-03-29T12:33:22.000Z
/* * Copyright (C) 2013 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "third_party/blink/renderer/core/layout/layout_block_flow.h" #include <algorithm> #include <memory> #include <utility> #include "third_party/blink/renderer/core/editing/editor.h" #include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/local_frame_view.h" #include "third_party/blink/renderer/core/frame/use_counter.h" #include "third_party/blink/renderer/core/html/html_dialog_element.h" #include "third_party/blink/renderer/core/layout/hit_test_location.h" #include "third_party/blink/renderer/core/layout/layout_analyzer.h" #include "third_party/blink/renderer/core/layout/layout_flow_thread.h" #include "third_party/blink/renderer/core/layout/layout_inline.h" #include "third_party/blink/renderer/core/layout/layout_multi_column_flow_thread.h" #include "third_party/blink/renderer/core/layout/layout_multi_column_spanner_placeholder.h" #include "third_party/blink/renderer/core/layout/layout_paged_flow_thread.h" #include "third_party/blink/renderer/core/layout/layout_view.h" #include "third_party/blink/renderer/core/layout/line/glyph_overflow.h" #include "third_party/blink/renderer/core/layout/line/inline_iterator.h" #include "third_party/blink/renderer/core/layout/line/inline_text_box.h" #include "third_party/blink/renderer/core/layout/line/line_width.h" #include "third_party/blink/renderer/core/layout/ng/inline/ng_line_height_metrics.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_block_flow.h" #include "third_party/blink/renderer/core/layout/ng/ng_box_fragment.h" #include "third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.h" #include "third_party/blink/renderer/core/layout/ng/ng_layout_result.h" #include "third_party/blink/renderer/core/layout/ng/ng_physical_box_fragment.h" #include "third_party/blink/renderer/core/layout/ng/ng_unpositioned_float.h" #include "third_party/blink/renderer/core/layout/shapes/shape_outside_info.h" #include "third_party/blink/renderer/core/layout/text_autosizer.h" #include "third_party/blink/renderer/core/paint/block_flow_paint_invalidator.h" #include "third_party/blink/renderer/core/paint/ng/ng_paint_fragment.h" #include "third_party/blink/renderer/core/paint/paint_layer.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h" namespace blink { bool LayoutBlockFlow::can_propagate_float_into_sibling_ = false; struct SameSizeAsLayoutBlockFlow : public LayoutBlock { LineBoxList line_boxes; void* pointers[2]; }; static_assert(sizeof(LayoutBlockFlow) == sizeof(SameSizeAsLayoutBlockFlow), "LayoutBlockFlow should stay small"); struct SameSizeAsMarginInfo { uint16_t bitfields; LayoutUnit margins[2]; }; static_assert(sizeof(LayoutBlockFlow::MarginValues) == sizeof(LayoutUnit[4]), "MarginValues should stay small"); typedef HashMap<LayoutBlockFlow*, int> LayoutPassCountMap; static LayoutPassCountMap& GetLayoutPassCountMap() { DEFINE_STATIC_LOCAL(LayoutPassCountMap, map, ()); return map; } // Caches all our current margin collapsing state. class MarginInfo { // Collapsing flags for whether we can collapse our margins with our // children's margins. bool can_collapse_with_children_ : 1; bool can_collapse_margin_before_with_children_ : 1; bool can_collapse_margin_after_with_children_ : 1; bool can_collapse_margin_after_with_last_child_ : 1; // Whether or not we are a quirky container, i.e., do we collapse away top and // bottom margins in our container. Table cells and the body are the common // examples. We also have a custom style property for Safari RSS to deal with // TypePad blog articles. bool quirk_container_ : 1; // This flag tracks whether we are still looking at child margins that can all // collapse together at the beginning of a block. They may or may not collapse // with the top margin of the block (|m_canCollapseTopWithChildren| tells us // that), but they will always be collapsing with one another. This variable // can remain set to true through multiple iterations as long as we keep // encountering self-collapsing blocks. bool at_before_side_of_block_ : 1; // This flag is set when we know we're examining bottom margins and we know // we're at the bottom of the block. bool at_after_side_of_block_ : 1; // These variables are used to detect quirky margins that we need to collapse // away (in table cells // and in the body element). bool has_margin_before_quirk_ : 1; bool has_margin_after_quirk_ : 1; bool determined_margin_before_quirk_ : 1; bool discard_margin_ : 1; bool last_child_is_self_collapsing_block_with_clearance_ : 1; // These flags track the previous maximal positive and negative margins. LayoutUnit positive_margin_; LayoutUnit negative_margin_; public: MarginInfo(LayoutBlockFlow*, LayoutUnit before_border_padding, LayoutUnit after_border_padding); void SetAtBeforeSideOfBlock(bool b) { at_before_side_of_block_ = b; } void SetAtAfterSideOfBlock(bool b) { at_after_side_of_block_ = b; } void ClearMargin() { positive_margin_ = LayoutUnit(); negative_margin_ = LayoutUnit(); } void SetHasMarginBeforeQuirk(bool b) { has_margin_before_quirk_ = b; } void SetHasMarginAfterQuirk(bool b) { has_margin_after_quirk_ = b; } void SetDeterminedMarginBeforeQuirk(bool b) { determined_margin_before_quirk_ = b; } void SetPositiveMargin(LayoutUnit p) { DCHECK(!discard_margin_); positive_margin_ = p; } void SetNegativeMargin(LayoutUnit n) { DCHECK(!discard_margin_); negative_margin_ = n; } void SetPositiveMarginIfLarger(LayoutUnit p) { DCHECK(!discard_margin_); if (p > positive_margin_) positive_margin_ = p; } void SetNegativeMarginIfLarger(LayoutUnit n) { DCHECK(!discard_margin_); if (n > negative_margin_) negative_margin_ = n; } void SetMargin(LayoutUnit p, LayoutUnit n) { DCHECK(!discard_margin_); positive_margin_ = p; negative_margin_ = n; } void SetCanCollapseMarginAfterWithChildren(bool collapse) { can_collapse_margin_after_with_children_ = collapse; } void SetCanCollapseMarginAfterWithLastChild(bool collapse) { can_collapse_margin_after_with_last_child_ = collapse; } void SetDiscardMargin(bool value) { discard_margin_ = value; } bool AtBeforeSideOfBlock() const { return at_before_side_of_block_; } bool CanCollapseWithMarginBefore() const { return at_before_side_of_block_ && can_collapse_margin_before_with_children_; } bool CanCollapseWithMarginAfter() const { return at_after_side_of_block_ && can_collapse_margin_after_with_children_; } bool CanCollapseMarginBeforeWithChildren() const { return can_collapse_margin_before_with_children_; } bool CanCollapseMarginAfterWithChildren() const { return can_collapse_margin_after_with_children_; } bool CanCollapseMarginAfterWithLastChild() const { return can_collapse_margin_after_with_last_child_; } bool QuirkContainer() const { return quirk_container_; } bool DeterminedMarginBeforeQuirk() const { return determined_margin_before_quirk_; } bool HasMarginBeforeQuirk() const { return has_margin_before_quirk_; } bool HasMarginAfterQuirk() const { return has_margin_after_quirk_; } LayoutUnit PositiveMargin() const { return positive_margin_; } LayoutUnit NegativeMargin() const { return negative_margin_; } bool DiscardMargin() const { return discard_margin_; } LayoutUnit Margin() const { return positive_margin_ - negative_margin_; } void SetLastChildIsSelfCollapsingBlockWithClearance(bool value) { last_child_is_self_collapsing_block_with_clearance_ = value; } bool LastChildIsSelfCollapsingBlockWithClearance() const { return last_child_is_self_collapsing_block_with_clearance_; } }; // Some features, such as floats, margin collapsing and fragmentation, require // some knowledge about things that happened when laying out previous block // child siblings. Only looking at the object currently being laid out isn't // always enough. class BlockChildrenLayoutInfo { public: BlockChildrenLayoutInfo(LayoutBlockFlow* block_flow, LayoutUnit before_edge, LayoutUnit after_edge) : margin_info_(block_flow, before_edge, after_edge), previous_break_after_value_(EBreakBetween::kAuto), is_at_first_in_flow_child_(true) {} // Store multicol layout state before first layout of a block child. The child // may contain a column spanner. If we need to re-lay out the block child // because our initial logical top estimate was wrong, we need to roll back to // how things were before laying out the child. void StoreMultiColumnLayoutState(const LayoutFlowThread& flow_thread) { multi_column_layout_state_ = flow_thread.GetMultiColumnLayoutState(); } void RollBackToInitialMultiColumnLayoutState(LayoutFlowThread& flow_thread) { flow_thread.RestoreMultiColumnLayoutState(multi_column_layout_state_); } const MarginInfo& GetMarginInfo() const { return margin_info_; } MarginInfo& GetMarginInfo() { return margin_info_; } LayoutUnit& PreviousFloatLogicalBottom() { return previous_float_logical_bottom_; } EBreakBetween PreviousBreakAfterValue() const { return previous_break_after_value_; } void SetPreviousBreakAfterValue(EBreakBetween value) { previous_break_after_value_ = value; } bool IsAtFirstInFlowChild() const { return is_at_first_in_flow_child_; } void ClearIsAtFirstInFlowChild() { is_at_first_in_flow_child_ = false; } private: MultiColumnLayoutState multi_column_layout_state_; MarginInfo margin_info_; LayoutUnit previous_float_logical_bottom_; EBreakBetween previous_break_after_value_; bool is_at_first_in_flow_child_; }; LayoutBlockFlow::LayoutBlockFlow(ContainerNode* node) : LayoutBlock(node) { static_assert(sizeof(MarginInfo) == sizeof(SameSizeAsMarginInfo), "MarginInfo should stay small"); SetChildrenInline(true); } LayoutBlockFlow::~LayoutBlockFlow() = default; LayoutBlockFlow* LayoutBlockFlow::CreateAnonymous(Document* document) { // TODO(layout-ng): Find a way to check style.ForceLegacyLayout() Here LayoutBlockFlow* layout_block_flow = RuntimeEnabledFeatures::LayoutNGEnabled() ? new LayoutNGBlockFlow(nullptr) : new LayoutBlockFlow(nullptr); layout_block_flow->SetDocumentForAnonymous(document); return layout_block_flow; } LayoutObject* LayoutBlockFlow::LayoutSpecialExcludedChild( bool relayout_children, SubtreeLayoutScope& layout_scope) { LayoutMultiColumnFlowThread* flow_thread = MultiColumnFlowThread(); if (!flow_thread) return nullptr; SetLogicalTopForChild(*flow_thread, BorderBefore() + PaddingBefore()); flow_thread->LayoutColumns(layout_scope); DetermineLogicalLeftPositionForChild(*flow_thread); return flow_thread; } bool LayoutBlockFlow::UpdateLogicalWidthAndColumnWidth() { bool relayout_children = LayoutBlock::UpdateLogicalWidthAndColumnWidth(); if (LayoutMultiColumnFlowThread* flow_thread = MultiColumnFlowThread()) { if (flow_thread->NeedsNewWidth()) return true; } return relayout_children; } void LayoutBlockFlow::SetBreakAtLineToAvoidWidow(int line_to_break) { DCHECK_GE(line_to_break, 0); EnsureRareData(); DCHECK(!rare_data_->did_break_at_line_to_avoid_widow_); rare_data_->line_break_to_avoid_widow_ = line_to_break; } void LayoutBlockFlow::SetDidBreakAtLineToAvoidWidow() { DCHECK(!ShouldBreakAtLineToAvoidWidow()); // This function should be called only after a break was applied to avoid // widows so assert |m_rareData| exists. DCHECK(rare_data_); rare_data_->did_break_at_line_to_avoid_widow_ = true; } void LayoutBlockFlow::ClearDidBreakAtLineToAvoidWidow() { if (!rare_data_) return; rare_data_->did_break_at_line_to_avoid_widow_ = false; } void LayoutBlockFlow::ClearShouldBreakAtLineToAvoidWidow() const { DCHECK(ShouldBreakAtLineToAvoidWidow()); if (!rare_data_) return; rare_data_->line_break_to_avoid_widow_ = -1; } bool LayoutBlockFlow::IsSelfCollapsingBlock() const { if (NeedsLayout()) { // Sometimes we don't lay out objects in DOM order (column spanners being // one such relevant type of object right here). As long as the object in // question establishes a new formatting context, that's nothing to worry // about, though. DCHECK(CreatesNewFormattingContext()); return false; } DCHECK_EQ(!is_self_collapsing_, !CheckIfIsSelfCollapsingBlock()); return is_self_collapsing_; } bool LayoutBlockFlow::CheckIfIsSelfCollapsingBlock() const { // We are not self-collapsing if we // (a) have a non-zero height according to layout (an optimization to avoid // wasting time) // (b) have border/padding, // (c) have a min-height // (d) have specified that one of our margins can't collapse using a CSS // extension // (e) establish a new block formatting context. // The early exit must be done before we check for clean layout. // We should be able to give a quick answer if the box is a relayout boundary. // Being a relayout boundary implies a block formatting context, and also // our internal layout shouldn't affect our container in any way. if (CreatesNewFormattingContext()) return false; // Placeholder elements are not laid out until the dimensions of their parent // text control are known, so they don't get layout until their parent has had // layout - this is unique in the layout tree and means when we call // isSelfCollapsingBlock on them we find that they still need layout. DCHECK(!NeedsLayout() || (GetNode() && GetNode()->IsElementNode() && ToElement(GetNode())->ShadowPseudoId() == "-webkit-input-placeholder")); if (LogicalHeight() > LayoutUnit() || BorderAndPaddingLogicalHeight() || Style()->LogicalMinHeight().IsPositive() || Style()->MarginBeforeCollapse() == EMarginCollapse::kSeparate || Style()->MarginAfterCollapse() == EMarginCollapse::kSeparate) return false; Length logical_height_length = Style()->LogicalHeight(); bool has_auto_height = logical_height_length.IsAuto(); if (logical_height_length.IsPercentOrCalc() && !GetDocument().InQuirksMode()) { has_auto_height = true; for (LayoutBlock* cb = ContainingBlock(); !cb->IsLayoutView(); cb = cb->ContainingBlock()) { if (cb->Style()->LogicalHeight().IsFixed() || cb->IsTableCell()) has_auto_height = false; } } // If the height is 0 or auto, then whether or not we are a self-collapsing // block depends on whether we have content that is all self-collapsing. // TODO(alancutter): Make this work correctly for calc lengths. if (has_auto_height || ((logical_height_length.IsFixed() || logical_height_length.IsPercentOrCalc()) && logical_height_length.IsZero())) { // Marker_container should be a self-collapsing block. Marker_container is a // zero height anonymous block and marker is its only child. if (logical_height_length.IsFixed() && logical_height_length.IsZero() && IsAnonymous() && Parent() && Parent()->IsListItem()) { LayoutObject* first_child = FirstChild(); if (first_child && first_child->IsListMarker() && !first_child->NextSibling()) return true; } // If the block has inline children, see if we generated any line boxes. // If we have any line boxes, then we can't be self-collapsing, since we // have content. if (ChildrenInline()) return !FirstLineBox(); // Whether or not we collapse is dependent on whether all our normal flow // children are also self-collapsing. for (LayoutBox* child = FirstChildBox(); child; child = child->NextSiblingBox()) { if (child->IsFloatingOrOutOfFlowPositioned() || child->IsColumnSpanAll()) continue; if (!child->IsSelfCollapsingBlock()) return false; } return true; } return false; } DISABLE_CFI_PERF void LayoutBlockFlow::UpdateBlockLayout(bool relayout_children) { DCHECK(NeedsLayout()); DCHECK(IsInlineBlockOrInlineTable() || !IsInline()); if (RuntimeEnabledFeatures::TrackLayoutPassesPerBlockEnabled()) IncrementLayoutPassCount(); if (!relayout_children && SimplifiedLayout()) return; LayoutAnalyzer::BlockScope analyzer(*this); SubtreeLayoutScope layout_scope(*this); LayoutUnit previous_height = LogicalHeight(); LayoutUnit old_left = LogicalLeft(); bool logical_width_changed = UpdateLogicalWidthAndColumnWidth(); relayout_children |= logical_width_changed; TextAutosizer::LayoutScope text_autosizer_layout_scope(this, &layout_scope); bool pagination_state_changed = pagination_state_changed_; bool preferred_logical_widths_were_dirty = PreferredLogicalWidthsDirty(); // Multiple passes might be required for column based layout. // The number of passes could be as high as the number of columns. LayoutMultiColumnFlowThread* flow_thread = MultiColumnFlowThread(); do { LayoutState state(*this, logical_width_changed); if (pagination_state_changed_) { // We now need a deep layout to clean up struts after pagination, if we // just ceased to be paginated, or, if we just became paginated on the // other hand, we now need the deep layout, to insert pagination struts. pagination_state_changed_ = false; state.SetPaginationStateChanged(); } LayoutChildren(relayout_children, layout_scope); if (!preferred_logical_widths_were_dirty && PreferredLogicalWidthsDirty()) { // The only thing that should dirty preferred widths at this point is the // addition of overflow:auto scrollbars in a descendant. To avoid a // potential infinite loop, run layout again with auto scrollbars frozen // in their current state. PaintLayerScrollableArea::FreezeScrollbarsScope freeze_scrollbars; relayout_children |= UpdateLogicalWidthAndColumnWidth(); LayoutChildren(relayout_children, layout_scope); } if (flow_thread && !flow_thread->FinishLayout()) { SetChildNeedsLayout(kMarkOnlyThis); continue; } if (ShouldBreakAtLineToAvoidWidow()) { SetEverHadLayout(); continue; } break; } while (true); LayoutState state(*this, logical_width_changed); if (pagination_state_changed) { // We still haven't laid out positioned descendants, and we need to perform // a deep layout on those too if pagination state changed. state.SetPaginationStateChanged(); } // Remember the automatic logical height we got from laying out the children. LayoutUnit unconstrained_height = LogicalHeight(); LayoutUnit unconstrained_client_after_edge = ClientLogicalBottom(); // Adjust logical height to satisfy whatever computed style requires. UpdateLogicalHeight(); if (!ChildrenInline()) AddOverhangingFloatsFromChildren(unconstrained_height); if (LogicalHeight() != previous_height || IsDocumentElement()) relayout_children = true; PositionedLayoutBehavior behavior = kDefaultLayout; if (old_left != LogicalLeft()) behavior = kForcedLayoutAfterContainingBlockMoved; LayoutPositionedObjects(relayout_children, behavior); // Add overflow from children. ComputeOverflow(unconstrained_client_after_edge); descendants_with_floats_marked_for_layout_ = false; UpdateAfterLayout(); if (IsHTMLDialogElement(GetNode()) && IsOutOfFlowPositioned()) PositionDialog(); ClearNeedsLayout(); UpdateIsSelfCollapsing(); } DISABLE_CFI_PERF void LayoutBlockFlow::ResetLayout() { if (!FirstChild() && !IsAnonymousBlock()) SetChildrenInline(true); SetContainsInlineWithOutlineAndContinuation(false); // Text truncation kicks in if overflow isn't visible and text-overflow isn't // 'clip'. If this is an anonymous block, we have to examine the parent. // FIXME: CSS3 says that descendants that are clipped must also know how to // truncate. This is insanely difficult to figure out in general (especially // in the middle of doing layout), so we only handle the simple case of an // anonymous block truncating when its parent is clipped. // Walk all the lines and delete our ellipsis line boxes if they exist. if (ChildrenInline() && ShouldTruncateOverflowingText()) DeleteEllipsisLineBoxes(); RebuildFloatsFromIntruding(); // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, // to track our current maximal positive and negative margins. These values // are used when we are collapsed with adjacent blocks, so for example, if you // have block A and B collapsing together, then you'd take the maximal // positive margin from both A and B and subtract it from the maximal negative // margin from both A and B to get the true collapsed margin. This algorithm // is recursive, so when we finish layout() our block knows its current // maximal positive/negative values. // // Start out by setting our margin values to our current margins. Table cells // have no margins, so we don't fill in the values for table cells. if (!IsTableCell()) { InitMaxMarginValues(); SetHasMarginBeforeQuirk(Style()->HasMarginBeforeQuirk()); SetHasMarginAfterQuirk(Style()->HasMarginAfterQuirk()); } if (View()->GetLayoutState()->IsPaginated()) { SetPaginationStrutPropagatedFromChild(LayoutUnit()); SetFirstForcedBreakOffset(LayoutUnit()); // Start with any applicable computed break-after and break-before values // for this object. During child layout, breakBefore will be joined with the // breakBefore value of the first in-flow child, and breakAfter will be // joined with the breakAfter value of the last in-flow child. This is done // in order to honor the requirement that a class A break point [1] may only // exists *between* in-flow siblings (i.e. not before the first child and // not after the last child). // // [1] https://drafts.csswg.org/css-break/#possible-breaks SetBreakBefore(LayoutBlock::BreakBefore()); SetBreakAfter(LayoutBlock::BreakAfter()); } } DISABLE_CFI_PERF void LayoutBlockFlow::LayoutChildren(bool relayout_children, SubtreeLayoutScope& layout_scope) { ResetLayout(); LayoutUnit before_edge = BorderBefore() + PaddingBefore(); LayoutUnit after_edge = BorderAfter() + PaddingAfter() + ScrollbarLogicalHeight(); SetLogicalHeight(before_edge); if (ChildrenInline()) LayoutInlineChildren(relayout_children, after_edge); else LayoutBlockChildren(relayout_children, layout_scope, before_edge, after_edge); // Expand our intrinsic height to encompass floats. if (LowestFloatLogicalBottom() > (LogicalHeight() - after_edge) && CreatesNewFormattingContext()) SetLogicalHeight(LowestFloatLogicalBottom() + after_edge); } void LayoutBlockFlow::AddOverhangingFloatsFromChildren( LayoutUnit unconstrained_height) { LayoutBlockFlow* lowest_block = nullptr; bool added_overhanging_floats = false; // One of our children's floats may have become an overhanging float for us. for (LayoutObject* child = LastChild(); child; child = child->PreviousSibling()) { // TODO(robhogan): We should exclude blocks that create formatting // contexts, not just out of flow or floating blocks. if (child->IsLayoutBlockFlow() && !child->IsFloatingOrOutOfFlowPositioned()) { LayoutBlockFlow* block = ToLayoutBlockFlow(child); if (!block->ContainsFloats()) continue; lowest_block = block; if (unconstrained_height <= LogicalHeight()) break; LayoutUnit logical_bottom = block->LogicalTop() + block->LowestFloatLogicalBottom(); if (logical_bottom <= LogicalHeight()) break; AddOverhangingFloats(block, false); added_overhanging_floats = true; } } // If we have no overhanging floats we still pass a record of the lowest // non-overhanging float up the tree so we can enclose it if we are a // formatting context and allow siblings to avoid it if they have negative // margin and find themselves in its vicinity. if (!added_overhanging_floats) AddLowestFloatFromChildren(lowest_block); } void LayoutBlockFlow::AddLowestFloatFromChildren(LayoutBlockFlow* block) { // TODO(robhogan): Make createsNewFormattingContext an ASSERT. if (!block || !block->ContainsFloats() || block->CreatesNewFormattingContext()) return; FloatingObject* floating_object = block->floating_objects_->LowestFloatingObject(); if (!floating_object || ContainsFloat(floating_object->GetLayoutObject())) return; LayoutSize offset(-block->LogicalLeft(), -block->LogicalTop()); if (!IsHorizontalWritingMode()) offset = offset.TransposedSize(); if (!floating_objects_) CreateFloatingObjects(); FloatingObject* new_floating_object = floating_objects_->Add( floating_object->CopyToNewContainer(offset, false, true)); new_floating_object->SetIsLowestNonOverhangingFloatInChild(true); } DISABLE_CFI_PERF void LayoutBlockFlow::DetermineLogicalLeftPositionForChild(LayoutBox& child) { LayoutUnit start_position = BorderStart() + PaddingStart(); LayoutUnit initial_start_position = start_position; if (ShouldPlaceBlockDirectionScrollbarOnLogicalLeft()) start_position -= VerticalScrollbarWidthClampedToContentBox(); LayoutUnit total_available_logical_width = BorderAndPaddingLogicalWidth() + AvailableLogicalWidth(); LayoutUnit child_margin_start = MarginStartForChild(child); LayoutUnit new_position = start_position + child_margin_start; if (child.AvoidsFloats() && ContainsFloats()) { LayoutUnit position_to_avoid_floats = StartOffsetForAvoidingFloats( LogicalTopForChild(child), LogicalHeightForChild(child)); // If the child has an offset from the content edge to avoid floats then use // that, otherwise let any negative margin pull it back over the content // edge or any positive margin push it out. // If the child is being centred then the margin calculated to do that has // factored in any offset required to avoid floats, so use it if necessary. if (StyleRef().GetTextAlign() == ETextAlign::kWebkitCenter || child.Style()->MarginStartUsing(StyleRef()).IsAuto()) new_position = std::max(new_position, position_to_avoid_floats + child_margin_start); else if (position_to_avoid_floats > initial_start_position) new_position = std::max(new_position, position_to_avoid_floats); } SetLogicalLeftForChild(child, Style()->IsLeftToRightDirection() ? new_position : total_available_logical_width - new_position - LogicalWidthForChild(child)); } void LayoutBlockFlow::SetLogicalLeftForChild(LayoutBox& child, LayoutUnit logical_left) { LayoutPoint new_location(child.Location()); if (IsHorizontalWritingMode()) { new_location.SetX(logical_left); } else { new_location.SetY(logical_left); } child.SetLocationAndUpdateOverflowControlsIfNeeded(new_location); } void LayoutBlockFlow::SetLogicalTopForChild(LayoutBox& child, LayoutUnit logical_top) { if (IsHorizontalWritingMode()) { child.SetY(logical_top); } else { child.SetX(logical_top); } } void LayoutBlockFlow::MarkDescendantsWithFloatsForLayoutIfNeeded( LayoutBlockFlow& child, LayoutUnit new_logical_top, LayoutUnit previous_float_logical_bottom) { // TODO(mstensho): rework the code to return early when there is no need for // marking, instead of this |markDescendantsWithFloats| flag. bool mark_descendants_with_floats = false; if (new_logical_top != child.LogicalTop() && !child.AvoidsFloats() && child.ContainsFloats()) { mark_descendants_with_floats = true; } else if (UNLIKELY(new_logical_top.MightBeSaturated())) { // The logical top might be saturated for very large elements. Comparing // with the old logical top might then yield a false negative, as adding and // removing margins, borders etc. from a saturated number might yield // incorrect results. If this is the case, always mark for layout. mark_descendants_with_floats = true; } else if (!child.AvoidsFloats() || child.ShrinkToAvoidFloats()) { // If an element might be affected by the presence of floats, then always // mark it for layout. LayoutUnit lowest_float = std::max(previous_float_logical_bottom, LowestFloatLogicalBottom()); if (lowest_float > new_logical_top) mark_descendants_with_floats = true; } if (mark_descendants_with_floats) child.MarkAllDescendantsWithFloatsForLayout(); } bool LayoutBlockFlow::PositionAndLayoutOnceIfNeeded( LayoutBox& child, LayoutUnit new_logical_top, BlockChildrenLayoutInfo& layout_info) { if (LayoutFlowThread* flow_thread = FlowThreadContainingBlock()) layout_info.RollBackToInitialMultiColumnLayoutState(*flow_thread); if (child.IsLayoutBlockFlow()) { LayoutUnit& previous_float_logical_bottom = layout_info.PreviousFloatLogicalBottom(); LayoutBlockFlow& child_block_flow = ToLayoutBlockFlow(child); if (child_block_flow.ContainsFloats() || ContainsFloats()) MarkDescendantsWithFloatsForLayoutIfNeeded( child_block_flow, new_logical_top, previous_float_logical_bottom); // TODO(mstensho): A writing mode root is one thing, but we should be able // to skip anything that establishes a new block formatting context here. // Their floats don't affect us. if (!child_block_flow.IsWritingModeRoot()) previous_float_logical_bottom = std::max(previous_float_logical_bottom, child_block_flow.LogicalTop() + child_block_flow.LowestFloatLogicalBottom()); } LayoutUnit old_logical_top = LogicalTopForChild(child); SetLogicalTopForChild(child, new_logical_top); SubtreeLayoutScope layout_scope(child); if (!child.NeedsLayout()) { if (new_logical_top != old_logical_top && child.ShrinkToAvoidFloats()) { // The child's width is affected by adjacent floats. When the child shifts // to clear an item, its width can change (because it has more available // width). layout_scope.SetChildNeedsLayout(&child); } else { MarkChildForPaginationRelayoutIfNeeded(child, layout_scope); } } bool needed_layout = child.NeedsLayout(); if (needed_layout) child.UpdateLayout(); if (View()->GetLayoutState()->IsPaginated()) UpdateFragmentationInfoForChild(child); return needed_layout; } void LayoutBlockFlow::InsertForcedBreakBeforeChildIfNeeded( LayoutBox& child, BlockChildrenLayoutInfo& layout_info) { if (layout_info.IsAtFirstInFlowChild()) { // There's no class A break point before the first child (only *between* // siblings), so steal its break value and join it with what we already have // here. SetBreakBefore( JoinFragmentainerBreakValues(BreakBefore(), child.BreakBefore())); return; } // Figure out if a forced break should be inserted in front of the child. If // we insert a forced break, the margins on this child may not collapse with // those preceding the break. EBreakBetween class_a_break_point_value = child.ClassABreakPointValue(layout_info.PreviousBreakAfterValue()); if (IsForcedFragmentainerBreakValue(class_a_break_point_value)) { layout_info.GetMarginInfo().ClearMargin(); LayoutUnit old_logical_top = LogicalHeight(); LayoutUnit new_logical_top = ApplyForcedBreak(old_logical_top, class_a_break_point_value); SetLogicalHeight(new_logical_top); LayoutUnit pagination_strut = new_logical_top - old_logical_top; child.SetPaginationStrut(pagination_strut); } } void LayoutBlockFlow::LayoutBlockChild(LayoutBox& child, BlockChildrenLayoutInfo& layout_info) { MarginInfo& margin_info = layout_info.GetMarginInfo(); LayoutBlockFlow* child_layout_block_flow = child.IsLayoutBlockFlow() ? ToLayoutBlockFlow(&child) : nullptr; LayoutUnit old_pos_margin_before = MaxPositiveMarginBefore(); LayoutUnit old_neg_margin_before = MaxNegativeMarginBefore(); // The child is a normal flow object. Compute the margins we will use for // collapsing now. child.ComputeAndSetBlockDirectionMargins(this); // Try to guess our correct logical top position. In most cases this guess // will be correct. Only if we're wrong (when we compute the real logical top // position) will we have to potentially relayout. LayoutUnit estimate_without_pagination; LayoutUnit logical_top_estimate = EstimateLogicalTopPosition( child, layout_info, estimate_without_pagination); LayoutRect old_rect = child.FrameRect(); if (LayoutFlowThread* flow_thread = FlowThreadContainingBlock()) layout_info.StoreMultiColumnLayoutState(*flow_thread); // Use the estimated block position and lay out the child if needed. After // child layout, when we have enough information to perform proper margin // collapsing, float clearing and pagination, we may have to reposition and // lay out again if the estimate was wrong. bool child_needed_layout = PositionAndLayoutOnceIfNeeded(child, logical_top_estimate, layout_info); // Cache if we are at the top of the block right now. bool at_before_side_of_block = margin_info.AtBeforeSideOfBlock(); bool child_is_self_collapsing = child.IsSelfCollapsingBlock(); bool child_discard_margin_before = MustDiscardMarginBeforeForChild(child); bool child_discard_margin_after = MustDiscardMarginAfterForChild(child); bool paginated = View()->GetLayoutState()->IsPaginated(); // If there should be a forced break before the child, we need to insert it // before attempting to collapse margins or apply clearance. if (paginated) { // We will now insert the strut needed by any forced break. After this // operation, we will have calculated the offset where we can apply margin // collapsing and clearance. After having applied those things, we'll be at // the position where we can honor requirements of unbreakable content, // which may extend the strut further. child.ResetPaginationStrut(); InsertForcedBreakBeforeChildIfNeeded(child, layout_info); } // Now determine the correct ypos based off examination of collapsing margin // values. LayoutUnit logical_top_before_clear = CollapseMargins(child, layout_info, child_is_self_collapsing, child_discard_margin_before, child_discard_margin_after); // Now check for clear. bool child_discard_margin = child_discard_margin_before || child_discard_margin_after; LayoutUnit new_logical_top = ClearFloatsIfNeeded( child, margin_info, old_pos_margin_before, old_neg_margin_before, logical_top_before_clear, child_is_self_collapsing, child_discard_margin); // If there's a forced break in front of this child, its final position has // already been determined. Otherwise, see if there are other reasons for // breaking before it (break-inside:avoid, or not enough space for the first // piece of child content to fit in the current fragmentainer), and adjust the // position accordingly. if (paginated) { if (estimate_without_pagination != new_logical_top) { // We got a new position due to clearance or margin collapsing. Before we // attempt to paginate (which may result in the position changing again), // let's try again at the new position (since a new position may result in // a new logical height). PositionAndLayoutOnceIfNeeded(child, new_logical_top, layout_info); } // We have now applied forced breaks, margin collapsing and clearance, and // we're at the position where we can honor requirements of unbreakable // content. new_logical_top = AdjustBlockChildForPagination( new_logical_top, child, layout_info, at_before_side_of_block && logical_top_before_clear == new_logical_top); } // Clearance, margin collapsing or pagination may have given us a new logical // top, in which case we may have to reposition and possibly relayout as well. // If we determined during child layout that we need to insert a break to // honor widows, we also need to relayout. if (new_logical_top != logical_top_estimate || child.NeedsLayout() || (paginated && child_layout_block_flow && child_layout_block_flow->ShouldBreakAtLineToAvoidWidow())) { PositionAndLayoutOnceIfNeeded(child, new_logical_top, layout_info); } // If we previously encountered a self-collapsing sibling of this child that // had clearance then we set this bit to ensure we would not collapse the // child's margins, and those of any subsequent self-collapsing siblings, with // our parent. If this child is not self-collapsing then it can collapse its // margins with the parent so reset the bit. if (!margin_info.CanCollapseMarginAfterWithLastChild() && !child_is_self_collapsing) margin_info.SetCanCollapseMarginAfterWithLastChild(true); // We are no longer at the top of the block if we encounter a non-empty child. // This has to be done after checking for clear, so that margins can be reset // if a clear occurred. if (margin_info.AtBeforeSideOfBlock() && !child_is_self_collapsing) margin_info.SetAtBeforeSideOfBlock(false); // Now place the child in the correct left position DetermineLogicalLeftPositionForChild(child); LayoutSize child_offset = child.Location() - old_rect.Location(); // Update our height now that the child has been placed in the correct // position. SetLogicalHeight(LogicalHeight() + LogicalHeightForChild(child)); if (MustSeparateMarginAfterForChild(child)) { SetLogicalHeight(LogicalHeight() + MarginAfterForChild(child)); margin_info.ClearMargin(); } // If the child has overhanging floats that intrude into following siblings // (or possibly out of this block), then the parent gets notified of the // floats now. if (child_layout_block_flow) AddOverhangingFloats(child_layout_block_flow, !child_needed_layout); // If the child moved, we have to invalidate its paint as well as any // floating/positioned descendants. An exception is if we need a layout. // In this case, we know we're going to invalidate our paint (and the child) // anyway. if (!SelfNeedsLayout() && (child_offset.Width() || child_offset.Height()) && child.IsLayoutBlockFlow()) BlockFlowPaintInvalidator(ToLayoutBlockFlow(child)) .InvalidatePaintForOverhangingFloats(); if (paginated) { // Keep track of the break-after value of the child, so that it can be // joined with the break-before value of the next in-flow object at the next // class A break point. layout_info.SetPreviousBreakAfterValue(child.BreakAfter()); PaginatedContentWasLaidOut(child.LogicalBottom()); if (child_layout_block_flow) { // If a forced break was inserted inside the child, translate and // propagate the offset to this object. if (LayoutUnit offset = child_layout_block_flow->FirstForcedBreakOffset()) SetFirstForcedBreakOffset(offset + new_logical_top); } } if (child.IsLayoutMultiColumnSpannerPlaceholder()) { // The actual column-span:all element is positioned by this placeholder // child. PositionSpannerDescendant(ToLayoutMultiColumnSpannerPlaceholder(child)); } } LayoutUnit LayoutBlockFlow::AdjustBlockChildForPagination( LayoutUnit logical_top, LayoutBox& child, BlockChildrenLayoutInfo& layout_info, bool at_before_side_of_block) { LayoutBlockFlow* child_block_flow = child.IsLayoutBlockFlow() ? ToLayoutBlockFlow(&child) : nullptr; // See if we need a soft (unforced) break in front of this child, and set the // pagination strut in that case. An unforced break may come from two sources: // 1. The first piece of content inside the child doesn't fit in the current // page or column // 2. The child itself has breaking restrictions (break-inside:avoid, replaced // content, etc.) and doesn't fully fit in the current page or column. // // No matter which source, if we need to insert a strut, it should always take // us to the exact top of a page or column further ahead, or be zero. // The first piece of content inside the child may have set a strut during // layout. Currently, only block flows support strut propagation, but this may // (and should) change in the future. See crbug.com/539873 LayoutUnit strut_from_content = child_block_flow ? child_block_flow->PaginationStrutPropagatedFromChild() : LayoutUnit(); LayoutUnit logical_top_with_content_strut = logical_top + strut_from_content; LayoutUnit logical_top_after_unsplittable = AdjustForUnsplittableChild(child, logical_top); // Pick the largest offset. Tall unsplittable content may take us to a page or // column further ahead than the next one. LayoutUnit logical_top_after_pagination = std::max(logical_top_with_content_strut, logical_top_after_unsplittable); LayoutUnit new_logical_top = logical_top; // Forced breaks may already have caused a strut, and this needs to be added // together with any strut detected here in this method. LayoutUnit previous_strut = child.PaginationStrut(); if (LayoutUnit pagination_strut = logical_top_after_pagination - logical_top + previous_strut) { DCHECK_GT(pagination_strut, 0); // If we're not at the first in-flow child, there's a class A break point // before the child. If we *are* at the first in-flow child, but the child // isn't flush with the content edge of its container, due to e.g. // clearance, there's a class C break point before the child. Otherwise we // should propagate the strut to our parent block, and attempt to break // there instead. See https://drafts.csswg.org/css-break/#possible-breaks bool can_break = !layout_info.IsAtFirstInFlowChild() || !at_before_side_of_block; if (!can_break && child.GetPaginationBreakability() == kForbidBreaks && !AllowsPaginationStrut()) { // The child is monolithic content, e.g. an image. It is truly // unsplittable. Breaking inside it would be bad. Since this block doesn't // allow pagination struts to be propagated to it, we're left to handle it // on our own right here. Break before the child, even if we're currently // at the block start (i.e. there's no class A or C break point here). can_break = true; } if (can_break) { child.SetPaginationStrut(pagination_strut); // |previousStrut| was already baked into the logical top, so don't add // it again. new_logical_top += pagination_strut - previous_strut; } else { // No valid break point here. Propagate the strut from the child to this // block, but only if the block allows it. If the block doesn't allow it, // we'll just ignore the strut and carry on, without breaking. This // happens e.g. when a tall break-inside:avoid object with a top margin is // the first in-flow child in the fragmentation context. if (AllowsPaginationStrut()) { pagination_strut += logical_top; SetPaginationStrutPropagatedFromChild(pagination_strut); if (child_block_flow) child_block_flow->SetPaginationStrutPropagatedFromChild(LayoutUnit()); } child.ResetPaginationStrut(); } } // Similar to how we apply clearance. Go ahead and boost height() to be the // place where we're going to position the child. SetLogicalHeight(LogicalHeight() + (new_logical_top - logical_top)); // Return the final adjusted logical top. return new_logical_top; } LayoutUnit LayoutBlockFlow::AdjustFloatLogicalTopForPagination( LayoutBox& child, LayoutUnit logical_top_margin_edge) { // The first piece of content inside the child may have set a strut during // layout. LayoutUnit strut; if (child.IsLayoutBlockFlow()) strut = ToLayoutBlockFlow(child).PaginationStrutPropagatedFromChild(); LayoutUnit margin_before = MarginBeforeForChild(child); if (margin_before > LayoutUnit()) { // Avoid breaking inside the top margin of a float. if (strut) { // If we already had decided to break, just add the margin. The strut so // far only accounts for pushing the top border edge to the next // fragmentainer. We need to push the margin over as well, because // there's no break opportunity between margin and border. strut += margin_before; } else { // Even if we didn't break before the border box to the next // fragmentainer, we need to check if we can fit the margin before it. if (IsPageLogicalHeightKnown()) { LayoutUnit remaining_space = PageRemainingLogicalHeightForOffset( logical_top_margin_edge, kAssociateWithLatterPage); if (remaining_space <= margin_before) { strut += CalculatePaginationStrutToFitContent(logical_top_margin_edge, margin_before); } } } } if (!strut) { // If we are unsplittable and don't fit, move to the next page or column // if that helps the situation. LayoutUnit new_logical_top_margin_edge = AdjustForUnsplittableChild(child, logical_top_margin_edge); strut = new_logical_top_margin_edge - logical_top_margin_edge; } child.SetPaginationStrut(strut); return logical_top_margin_edge + strut; } static bool ShouldSetStrutOnBlock(const LayoutBlockFlow& block, const RootInlineBox& line_box, LayoutUnit line_logical_offset, int line_index, LayoutUnit page_logical_height) { if (line_box == block.FirstRootBox()) { // This is the first line in the block. We can take the whole block with us // to the next page or column, rather than keeping a content-less portion of // it in the previous one. Only do this if the line is flush with the // content edge of the block, though. If it isn't, it means that the line // was pushed downwards by preceding floats that didn't fit beside the line, // and we don't want to move all that, since it has already been established // that it fits nicely where it is. In this case we have a class "C" break // point [1] in front of this line. // // [1] https://drafts.csswg.org/css-break/#possible-breaks if (line_logical_offset > block.BorderAndPaddingBefore()) return false; LayoutUnit line_height = line_box.LineBottomWithLeading() - line_box.LineTopWithLeading(); LayoutUnit total_logical_height = line_height + line_logical_offset.ClampNegativeToZero(); // It's rather pointless to break before the block if the current line isn't // going to fit in the same column or page, so check that as well. if (total_logical_height > page_logical_height) return false; } else { if (line_index > block.Style()->Orphans()) return false; // Not enough orphans here. Push the entire block to the next column / page // as an attempt to better satisfy the orphans requirement. // // Note that we should ideally check if the first line in the block is flush // with the content edge of the block here, because if it isn't, we should // break at the class "C" break point in front of the first line, rather // than before the entire block. } return block.AllowsPaginationStrut(); } void LayoutBlockFlow::AdjustLinePositionForPagination(RootInlineBox& line_box, LayoutUnit& delta) { // TODO(mstensho): Pay attention to line overflow. It should be painted in the // same column as the rest of the line, possibly overflowing the column. We // currently only allow overflow above the first column. We clip at all other // column boundaries, and that's how it has to be for now. The paint we have // to do when a column has overflow has to be special. // We need to exclude content that paints in a previous column (and content // that paints in the following column). // // FIXME: Another problem with simply moving lines is that the available line // width may change (because of floats). Technically if the location we move // the line to has a different line width than our old position, then we need // to dirty the line and all following lines. LayoutUnit logical_offset = line_box.LineTopWithLeading(); LayoutUnit line_height = line_box.LineBottomWithLeading() - logical_offset; logical_offset += delta; line_box.SetPaginationStrut(LayoutUnit()); line_box.SetIsFirstAfterPageBreak(false); LayoutState* layout_state = View()->GetLayoutState(); if (!layout_state->IsPaginated()) return; if (!IsPageLogicalHeightKnown()) return; LayoutUnit page_logical_height = PageLogicalHeightForOffset(logical_offset); LayoutUnit remaining_logical_height = PageRemainingLogicalHeightForOffset( logical_offset, kAssociateWithLatterPage); int line_index = LineCount(&line_box); if (remaining_logical_height < line_height || (ShouldBreakAtLineToAvoidWidow() && LineBreakToAvoidWidow() == line_index)) { LayoutUnit pagination_strut = CalculatePaginationStrutToFitContent(logical_offset, line_height); LayoutUnit new_logical_offset = logical_offset + pagination_strut; // Moving to a different page or column may mean that its height is // different. page_logical_height = PageLogicalHeightForOffset(new_logical_offset); if (line_height > page_logical_height) { // Too tall to fit in one page / column. Give up. Don't push to the next // page / column. // TODO(mstensho): Get rid of this. This is just utter weirdness, but the // other browsers also do something slightly similar, although in much // more specific cases than we do here, and printing Google Docs depends // on it. PaginatedContentWasLaidOut(logical_offset + line_height); return; } // We need to insert a break now, either because there's no room for the // line in the current column / page, or because we have determined that we // need a break to satisfy widow requirements. if (ShouldBreakAtLineToAvoidWidow() && LineBreakToAvoidWidow() == line_index) { ClearShouldBreakAtLineToAvoidWidow(); SetDidBreakAtLineToAvoidWidow(); } if (ShouldSetStrutOnBlock(*this, line_box, logical_offset, line_index, page_logical_height)) { // Note that when setting the strut on a block, it may be propagated to // parent blocks later on, if a block's logical top is flush with that of // its parent. We don't want content-less portions (struts) at the // beginning of a block before a break, if it can be avoided. After all, // that's the reason for setting struts on blocks and not lines in the // first place. SetPaginationStrutPropagatedFromChild(pagination_strut + logical_offset); } else { delta += pagination_strut; line_box.SetPaginationStrut(pagination_strut); line_box.SetIsFirstAfterPageBreak(true); } PaginatedContentWasLaidOut(new_logical_offset + line_height); return; } LayoutUnit strut_to_propagate; if (remaining_logical_height == page_logical_height) { // We're at the very top of a page or column. if (line_box != FirstRootBox()) line_box.SetIsFirstAfterPageBreak(true); // If this is the first line in the block, and the block has a top border or // padding, we may want to set a strut on the block, so that everything ends // up in the next column or page. Setting a strut on the block is also // important when it comes to satisfying orphan requirements. if (ShouldSetStrutOnBlock(*this, line_box, logical_offset, line_index, page_logical_height)) { DCHECK(!IsTableCell()); strut_to_propagate = logical_offset + layout_state->HeightOffsetForTableHeaders(); } else if (LayoutUnit pagination_strut = layout_state->HeightOffsetForTableHeaders()) { delta += pagination_strut; line_box.SetPaginationStrut(pagination_strut); } } else if (line_box == FirstRootBox() && AllowsPaginationStrut()) { // This is the first line in the block. The block may still start in the // previous column or page, and if that's the case, attempt to pull it over // to where this line is, so that we don't split the top border or padding. LayoutUnit strut = remaining_logical_height + logical_offset + layout_state->HeightOffsetForTableHeaders() - page_logical_height; if (strut > LayoutUnit()) { // The block starts in a previous column or page. Set a strut on the block // if there's room for the top border, padding and the line in one column // or page. if (logical_offset + line_height <= page_logical_height) strut_to_propagate = strut; } } // If we found that some preceding content (lines, border and padding) belongs // together with this line, we should pull the entire block with us to the // fragmentainer we're currently in. We need to avoid this when the block // precedes the first fragmentainer, though. We shouldn't fragment content // there, but rather let it appear in the overflow area before the first // fragmentainer. if (strut_to_propagate && OffsetFromLogicalTopOfFirstPage() > LayoutUnit()) SetPaginationStrutPropagatedFromChild(strut_to_propagate); PaginatedContentWasLaidOut(logical_offset + line_height); } LayoutUnit LayoutBlockFlow::AdjustForUnsplittableChild( LayoutBox& child, LayoutUnit logical_offset) const { if (child.GetPaginationBreakability() == kAllowAnyBreaks) return logical_offset; LayoutUnit child_logical_height = LogicalHeightForChild(child); // Floats' margins do not collapse with page or column boundaries. if (child.IsFloating()) child_logical_height += MarginBeforeForChild(child) + MarginAfterForChild(child); if (!IsPageLogicalHeightKnown()) return logical_offset; LayoutUnit remaining_logical_height = PageRemainingLogicalHeightForOffset( logical_offset, kAssociateWithLatterPage); if (remaining_logical_height >= child_logical_height) return logical_offset; // It fits fine where it is. No need to break. LayoutUnit pagination_strut = CalculatePaginationStrutToFitContent( logical_offset, child_logical_height); if (pagination_strut == remaining_logical_height && remaining_logical_height == PageLogicalHeightForOffset(logical_offset)) { // Don't break if we were at the top of a page, and we failed to fit the // content completely. No point in leaving a page completely blank. return logical_offset; } if (child.IsLayoutBlockFlow()) { // If there's a forced break inside this object, figure out if we can fit // everything before that forced break in the current fragmentainer. If it // fits, we don't need to insert a break before the child. const LayoutBlockFlow& block_child = ToLayoutBlockFlow(child); if (LayoutUnit first_break_offset = block_child.FirstForcedBreakOffset()) { if (remaining_logical_height >= first_break_offset) return logical_offset; } } return logical_offset + pagination_strut; } DISABLE_CFI_PERF void LayoutBlockFlow::RebuildFloatsFromIntruding() { if (floating_objects_) floating_objects_->SetHorizontalWritingMode(IsHorizontalWritingMode()); HashSet<LayoutBox*> old_intruding_float_set; if (!ChildrenInline() && floating_objects_) { const FloatingObjectSet& floating_object_set = floating_objects_->Set(); FloatingObjectSetIterator end = floating_object_set.end(); for (FloatingObjectSetIterator it = floating_object_set.begin(); it != end; ++it) { const FloatingObject& floating_object = *it->get(); if (!floating_object.IsDescendant()) old_intruding_float_set.insert(floating_object.GetLayoutObject()); } } // Inline blocks are covered by the isAtomicInlineLevel() check in the // avoidFloats method. if (AvoidsFloats() || IsDocumentElement() || IsLayoutView() || IsFloatingOrOutOfFlowPositioned() || IsTableCell()) { if (floating_objects_) { floating_objects_->Clear(); } if (!old_intruding_float_set.IsEmpty()) MarkAllDescendantsWithFloatsForLayout(); return; } LayoutBoxToFloatInfoMap float_map; if (floating_objects_) { if (ChildrenInline()) floating_objects_->MoveAllToFloatInfoMap(float_map); else floating_objects_->Clear(); } // We should not process floats if the parent node is not a LayoutBlockFlow. // Otherwise, we will add floats in an invalid context. This will cause a // crash arising from a bad cast on the parent. // See <rdar://problem/8049753>, where float property is applied on a text // node in a SVG. if (!Parent() || !Parent()->IsLayoutBlockFlow()) return; // Attempt to locate a previous sibling with overhanging floats. We skip any // elements that may have shifted to avoid floats, and any objects whose // floats cannot interact with objects outside it (i.e. objects that create a // new block formatting context). LayoutBlockFlow* parent_block_flow = ToLayoutBlockFlow(Parent()); bool sibling_float_may_intrude = false; LayoutObject* prev = PreviousSibling(); while (prev && (!prev->IsBox() || !prev->IsLayoutBlock() || ToLayoutBlock(prev)->AvoidsFloats() || ToLayoutBlock(prev)->CreatesNewFormattingContext())) { if (prev->IsFloating()) sibling_float_may_intrude = true; prev = prev->PreviousSibling(); } // First add in floats from the parent. Self-collapsing blocks let their // parent track any floats that intrude into them (as opposed to floats they // contain themselves) so check for those here too. If margin collapsing has // moved us up past the top a previous sibling then we need to check for // floats from the parent too. bool parent_floats_may_intrude = !sibling_float_may_intrude && (!prev || ToLayoutBlockFlow(prev)->IsSelfCollapsingBlock() || ToLayoutBlock(prev)->LogicalTop() > LogicalTop()) && parent_block_flow->LowestFloatLogicalBottom() > LogicalTop(); if (sibling_float_may_intrude || parent_floats_may_intrude) AddIntrudingFloats(parent_block_flow, parent_block_flow->LogicalLeftOffsetForContent(), LogicalTop()); // Add overhanging floats from the previous LayoutBlockFlow, but only if it // has a float that intrudes into our space. if (prev) { LayoutBlockFlow* previous_block_flow = ToLayoutBlockFlow(prev); if (LogicalTop() < previous_block_flow->LogicalTop() + previous_block_flow->LowestFloatLogicalBottom()) AddIntrudingFloats(previous_block_flow, LayoutUnit(), LogicalTop() - previous_block_flow->LogicalTop()); } if (ChildrenInline()) { LayoutUnit change_logical_top = LayoutUnit::Max(); LayoutUnit change_logical_bottom = LayoutUnit::Min(); if (floating_objects_) { const FloatingObjectSet& floating_object_set = floating_objects_->Set(); FloatingObjectSetIterator end = floating_object_set.end(); for (FloatingObjectSetIterator it = floating_object_set.begin(); it != end; ++it) { const FloatingObject& floating_object = *it->get(); FloatingObject* old_floating_object = float_map.at(floating_object.GetLayoutObject()); LayoutUnit logical_bottom = LogicalBottomForFloat(floating_object); if (old_floating_object) { LayoutUnit old_logical_bottom = LogicalBottomForFloat(*old_floating_object); if (LogicalWidthForFloat(floating_object) != LogicalWidthForFloat(*old_floating_object) || LogicalLeftForFloat(floating_object) != LogicalLeftForFloat(*old_floating_object)) { change_logical_top = LayoutUnit(); change_logical_bottom = std::max(change_logical_bottom, std::max(logical_bottom, old_logical_bottom)); } else { if (logical_bottom != old_logical_bottom) { change_logical_top = std::min(change_logical_top, std::min(logical_bottom, old_logical_bottom)); change_logical_bottom = std::max(change_logical_bottom, std::max(logical_bottom, old_logical_bottom)); } LayoutUnit logical_top = LogicalTopForFloat(floating_object); LayoutUnit old_logical_top = LogicalTopForFloat(*old_floating_object); if (logical_top != old_logical_top) { change_logical_top = std::min( change_logical_top, std::min(logical_top, old_logical_top)); change_logical_bottom = std::max(change_logical_bottom, std::max(logical_top, old_logical_top)); } } if (old_floating_object->OriginatingLine() && !SelfNeedsLayout()) { DCHECK(old_floating_object->OriginatingLine() ->GetLineLayoutItem() .IsEqual(this)); old_floating_object->OriginatingLine()->MarkDirty(); } float_map.erase(floating_object.GetLayoutObject()); } else { change_logical_top = LayoutUnit(); change_logical_bottom = std::max(change_logical_bottom, logical_bottom); } } } LayoutBoxToFloatInfoMap::iterator end = float_map.end(); for (LayoutBoxToFloatInfoMap::iterator it = float_map.begin(); it != end; ++it) { std::unique_ptr<FloatingObject>& floating_object = it->value; if (!floating_object->IsDescendant()) { change_logical_top = LayoutUnit(); change_logical_bottom = std::max( change_logical_bottom, LogicalBottomForFloat(*floating_object)); } } MarkLinesDirtyInBlockRange(change_logical_top, change_logical_bottom); } else if (!old_intruding_float_set.IsEmpty()) { // If there are previously intruding floats that no longer intrude, then // children with floats should also get layout because they might need their // floating object lists cleared. if (floating_objects_->Set().size() < old_intruding_float_set.size()) { MarkAllDescendantsWithFloatsForLayout(); } else { const FloatingObjectSet& floating_object_set = floating_objects_->Set(); FloatingObjectSetIterator end = floating_object_set.end(); for (FloatingObjectSetIterator it = floating_object_set.begin(); it != end && !old_intruding_float_set.IsEmpty(); ++it) old_intruding_float_set.erase((*it)->GetLayoutObject()); if (!old_intruding_float_set.IsEmpty()) MarkAllDescendantsWithFloatsForLayout(); } } } void LayoutBlockFlow::LayoutBlockChildren(bool relayout_children, SubtreeLayoutScope& layout_scope, LayoutUnit before_edge, LayoutUnit after_edge) { DirtyForLayoutFromPercentageHeightDescendants(layout_scope); BlockChildrenLayoutInfo layout_info(this, before_edge, after_edge); MarginInfo& margin_info = layout_info.GetMarginInfo(); // Fieldsets need to find their legend and position it inside the border of // the object. // The legend then gets skipped during normal layout. The same is true for // ruby text. // It doesn't get included in the normal layout process but is instead skipped LayoutObject* child_to_exclude = LayoutSpecialExcludedChild(relayout_children, layout_scope); // TODO(foolip): Speculative CHECKs to crash if any non-LayoutBox // children ever appear, the childrenInline() check at the call site // should make this impossible. crbug.com/632848 LayoutObject* first_child = FirstChild(); CHECK(!first_child || first_child->IsBox()); LayoutBox* next = ToLayoutBox(first_child); LayoutBox* last_normal_flow_child = nullptr; while (next) { LayoutBox* child = next; LayoutObject* next_sibling = child->NextSibling(); CHECK(!next_sibling || next_sibling->IsBox()); next = ToLayoutBox(next_sibling); child->SetMayNeedPaintInvalidation(); if (child_to_exclude == child) continue; // Skip this child, since it will be positioned by the // specialized subclass (fieldsets and ruby runs). UpdateBlockChildDirtyBitsBeforeLayout(relayout_children, *child); if (child->IsOutOfFlowPositioned()) { child->ContainingBlock()->InsertPositionedObject(child); AdjustPositionedBlock(*child, layout_info); continue; } if (child->IsFloating()) { InsertFloatingObject(*child); AdjustFloatingBlock(margin_info); continue; } if (child->IsColumnSpanAll()) { // This is not the containing block of the spanner. The spanner's // placeholder will lay it out in due course. For now we just need to // consult our flow thread, so that the columns (if any) preceding and // following the spanner are laid out correctly. But first we apply the // pending margin, so that it's taken into consideration and doesn't end // up on the other side of the spanner. SetLogicalHeight(LogicalHeight() + margin_info.Margin()); margin_info.ClearMargin(); child->SpannerPlaceholder()->FlowThread()->SkipColumnSpanner( child, OffsetFromLogicalTopOfFirstPage() + LogicalHeight()); continue; } // Lay out the child. LayoutBlockChild(*child, layout_info); layout_info.ClearIsAtFirstInFlowChild(); last_normal_flow_child = child; } // Now do the handling of the bottom of the block, adding in our bottom // border/padding and determining the correct collapsed bottom margin // information. HandleAfterSideOfBlock(last_normal_flow_child, before_edge, after_edge, margin_info); } // Our MarginInfo state used when laying out block children. MarginInfo::MarginInfo(LayoutBlockFlow* block_flow, LayoutUnit before_border_padding, LayoutUnit after_border_padding) : can_collapse_margin_after_with_last_child_(true), at_before_side_of_block_(true), at_after_side_of_block_(false), has_margin_before_quirk_(false), has_margin_after_quirk_(false), determined_margin_before_quirk_(false), discard_margin_(false), last_child_is_self_collapsing_block_with_clearance_(false) { const ComputedStyle& block_style = block_flow->StyleRef(); DCHECK(block_flow->IsLayoutView() || block_flow->Parent()); can_collapse_with_children_ = !block_flow->CreatesNewFormattingContext() && !block_flow->IsLayoutFlowThread() && !block_flow->IsLayoutView(); can_collapse_margin_before_with_children_ = can_collapse_with_children_ && !before_border_padding && block_style.MarginBeforeCollapse() != EMarginCollapse::kSeparate; // If any height other than auto is specified in CSS, then we don't collapse // our bottom margins with our children's margins. To do otherwise would be to // risk odd visual effects when the children overflow out of the parent block // and yet still collapse with it. We also don't collapse if we have any // bottom border/padding. can_collapse_margin_after_with_children_ = can_collapse_with_children_ && !after_border_padding && (block_style.LogicalHeight().IsAuto() && !block_style.LogicalHeight().Value()) && block_style.MarginAfterCollapse() != EMarginCollapse::kSeparate; quirk_container_ = block_flow->IsTableCell() || block_flow->IsBody(); discard_margin_ = can_collapse_margin_before_with_children_ && block_flow->MustDiscardMarginBefore(); positive_margin_ = (can_collapse_margin_before_with_children_ && !block_flow->MustDiscardMarginBefore()) ? block_flow->MaxPositiveMarginBefore() : LayoutUnit(); negative_margin_ = (can_collapse_margin_before_with_children_ && !block_flow->MustDiscardMarginBefore()) ? block_flow->MaxNegativeMarginBefore() : LayoutUnit(); } LayoutBlockFlow::MarginValues LayoutBlockFlow::MarginValuesForChild( LayoutBox& child) const { LayoutUnit child_before_positive; LayoutUnit child_before_negative; LayoutUnit child_after_positive; LayoutUnit child_after_negative; LayoutUnit before_margin; LayoutUnit after_margin; LayoutBlockFlow* child_layout_block_flow = child.IsLayoutBlockFlow() ? ToLayoutBlockFlow(&child) : nullptr; // If the child has the same directionality as we do, then we can just return // its margins in the same direction. if (!child.IsWritingModeRoot()) { if (child_layout_block_flow) { child_before_positive = child_layout_block_flow->MaxPositiveMarginBefore(); child_before_negative = child_layout_block_flow->MaxNegativeMarginBefore(); child_after_positive = child_layout_block_flow->MaxPositiveMarginAfter(); child_after_negative = child_layout_block_flow->MaxNegativeMarginAfter(); } else { before_margin = child.MarginBefore(); after_margin = child.MarginAfter(); } } else if (child.IsHorizontalWritingMode() == IsHorizontalWritingMode()) { // The child has a different directionality. If the child is parallel, then // it's just flipped relative to us. We can use the margins for the opposite // edges. if (child_layout_block_flow) { child_before_positive = child_layout_block_flow->MaxPositiveMarginAfter(); child_before_negative = child_layout_block_flow->MaxNegativeMarginAfter(); child_after_positive = child_layout_block_flow->MaxPositiveMarginBefore(); child_after_negative = child_layout_block_flow->MaxNegativeMarginBefore(); } else { before_margin = child.MarginAfter(); after_margin = child.MarginBefore(); } } else { // The child is perpendicular to us, which means its margins don't collapse // but are on the "logical left/right" sides of the child box. We can just // return the raw margin in this case. before_margin = MarginBeforeForChild(child); after_margin = MarginAfterForChild(child); } // Resolve uncollapsing margins into their positive/negative buckets. if (before_margin) { if (before_margin > 0) child_before_positive = before_margin; else child_before_negative = -before_margin; } if (after_margin) { if (after_margin > 0) child_after_positive = after_margin; else child_after_negative = -after_margin; } return LayoutBlockFlow::MarginValues( child_before_positive, child_before_negative, child_after_positive, child_after_negative); } LayoutUnit LayoutBlockFlow::AdjustedMarginBeforeForPagination( const LayoutBox& child, LayoutUnit logical_top_margin_edge, LayoutUnit logical_top_border_edge, const BlockChildrenLayoutInfo& layout_info) const { LayoutUnit effective_margin = logical_top_border_edge - logical_top_margin_edge; DCHECK(IsPageLogicalHeightKnown()); if (effective_margin <= LayoutUnit()) return effective_margin; // If margins would pull us past the top of the next fragmentainer, then we // need to pull back and let the margins collapse into the fragmentainer // boundary. If we're at a fragmentainer boundary, and there's no forced break // involved, collapse the margin with the boundary we're at. Otherwise, // preserve the margin at the top of the fragmentainer, but collapse it with // the next fragmentainer boundary, since no margin should ever live in more // than one fragmentainer. PageBoundaryRule rule = kAssociateWithLatterPage; if (!child.NeedsForcedBreakBefore(layout_info.PreviousBreakAfterValue()) && OffsetFromLogicalTopOfFirstPage() + logical_top_margin_edge > LayoutUnit()) rule = kAssociateWithFormerPage; LayoutUnit remaining_space = PageRemainingLogicalHeightForOffset(logical_top_margin_edge, rule); return std::min(effective_margin, remaining_space); } static LayoutBlockFlow* PreviousBlockFlowInFormattingContext( const LayoutBox& child) { LayoutObject* prev = child.PreviousSibling(); while (prev && (!prev->IsLayoutBlockFlow() || ToLayoutBlockFlow(prev)->CreatesNewFormattingContext())) { prev = prev->PreviousSibling(); } if (prev) return ToLayoutBlockFlow(prev); return nullptr; } LayoutUnit LayoutBlockFlow::CollapseMargins( LayoutBox& child, BlockChildrenLayoutInfo& layout_info, bool child_is_self_collapsing, bool child_discard_margin_before, bool child_discard_margin_after) { MarginInfo& margin_info = layout_info.GetMarginInfo(); // The child discards the before margin when the the after margin has discard // in the case of a self collapsing block. child_discard_margin_before = child_discard_margin_before || (child_discard_margin_after && child_is_self_collapsing); // Get the four margin values for the child and cache them. const LayoutBlockFlow::MarginValues child_margins = MarginValuesForChild(child); // Get our max pos and neg top margins. LayoutUnit pos_top = child_margins.PositiveMarginBefore(); LayoutUnit neg_top = child_margins.NegativeMarginBefore(); // For self-collapsing blocks, collapse our bottom margins into our // top to get new posTop and negTop values. if (child_is_self_collapsing) { pos_top = std::max(pos_top, child_margins.PositiveMarginAfter()); neg_top = std::max(neg_top, child_margins.NegativeMarginAfter()); } // See if the top margin is quirky. We only care if this child has // margins that will collapse with us. bool top_quirk = HasMarginBeforeQuirk(&child); if (margin_info.CanCollapseWithMarginBefore()) { if (!child_discard_margin_before && !margin_info.DiscardMargin()) { // This child is collapsing with the top of the // block. If it has larger margin values, then we need to update // our own maximal values. if (!GetDocument().InQuirksMode() || !margin_info.QuirkContainer() || !top_quirk) SetMaxMarginBeforeValues(std::max(pos_top, MaxPositiveMarginBefore()), std::max(neg_top, MaxNegativeMarginBefore())); // The minute any of the margins involved isn't a quirk, don't // collapse it away, even if the margin is smaller (www.webreference.com // has an example of this, a <dt> with 0.8em author-specified inside // a <dl> inside a <td>. if (!margin_info.DeterminedMarginBeforeQuirk() && !top_quirk && (pos_top - neg_top)) { SetHasMarginBeforeQuirk(false); margin_info.SetDeterminedMarginBeforeQuirk(true); } if (!margin_info.DeterminedMarginBeforeQuirk() && top_quirk && !MarginBefore()) { // We have no top margin and our top child has a quirky margin. // We will pick up this quirky margin and pass it through. // This deals with the <td><div><p> case. // Don't do this for a block that split two inlines though. You do // still apply margins in this case. SetHasMarginBeforeQuirk(true); } } else { // The before margin of the container will also discard all the margins it // is collapsing with. SetMustDiscardMarginBefore(); } } // Once we find a child with discardMarginBefore all the margins collapsing // with us must also discard. if (child_discard_margin_before) { margin_info.SetDiscardMargin(true); margin_info.ClearMargin(); } if (margin_info.QuirkContainer() && margin_info.AtBeforeSideOfBlock() && (pos_top - neg_top)) margin_info.SetHasMarginBeforeQuirk(top_quirk); LayoutUnit before_collapse_logical_top = LogicalHeight(); LayoutUnit logical_top = before_collapse_logical_top; LayoutObject* prev = child.PreviousSibling(); LayoutBlockFlow* previous_block_flow = prev && prev->IsLayoutBlockFlow() ? ToLayoutBlockFlow(prev) : nullptr; bool previous_block_flow_can_self_collapse = previous_block_flow && !previous_block_flow->IsFloatingOrOutOfFlowPositioned(); // If the child's previous sibling is a self-collapsing block that cleared a // float then its top border edge has been set at the bottom border edge of // the float. Since we want to collapse the child's top margin with the self- // collapsing block's top and bottom margins we need to adjust our parent's // height to match the margin top of the self-collapsing block. If the // resulting collapsed margin leaves the child still intruding into the float // then we will want to clear it. if (!margin_info.CanCollapseWithMarginBefore() && previous_block_flow_can_self_collapse && margin_info.LastChildIsSelfCollapsingBlockWithClearance()) SetLogicalHeight( LogicalHeight() - MarginValuesForChild(*previous_block_flow).PositiveMarginBefore()); if (child_is_self_collapsing) { // For a self collapsing block both the before and after margins get // discarded. The block doesn't contribute anything to the height of the // block. Also, the child's top position equals the logical height of the // container. if (!child_discard_margin_before && !margin_info.DiscardMargin()) { // This child has no height. We need to compute our // position before we collapse the child's margins together, // so that we can get an accurate position for the zero-height block. LayoutUnit collapsed_before_pos = std::max( margin_info.PositiveMargin(), child_margins.PositiveMarginBefore()); LayoutUnit collapsed_before_neg = std::max( margin_info.NegativeMargin(), child_margins.NegativeMarginBefore()); margin_info.SetMargin(collapsed_before_pos, collapsed_before_neg); // Now collapse the child's margins together, which means examining our // bottom margin values as well. margin_info.SetPositiveMarginIfLarger( child_margins.PositiveMarginAfter()); margin_info.SetNegativeMarginIfLarger( child_margins.NegativeMarginAfter()); if (!margin_info.CanCollapseWithMarginBefore()) { // We need to make sure that the position of the self-collapsing block // is correct, since it could have overflowing content // that needs to be positioned correctly (e.g., a block that // had a specified height of 0 but that actually had subcontent). logical_top = LogicalHeight() + collapsed_before_pos - collapsed_before_neg; } } } else { if (MustSeparateMarginBeforeForChild(child)) { DCHECK(!margin_info.DiscardMargin() || (margin_info.DiscardMargin() && !margin_info.Margin())); // If we are at the before side of the block and we collapse, ignore the // computed margin and just add the child margin to the container height. // This will correctly position the child inside the container. LayoutUnit separate_margin = !margin_info.CanCollapseWithMarginBefore() ? margin_info.Margin() : LayoutUnit(); SetLogicalHeight(LogicalHeight() + separate_margin + MarginBeforeForChild(child)); logical_top = LogicalHeight(); } else if (!margin_info.DiscardMargin() && (!margin_info.AtBeforeSideOfBlock() || (!margin_info.CanCollapseMarginBeforeWithChildren() && (!GetDocument().InQuirksMode() || !margin_info.QuirkContainer() || !margin_info.HasMarginBeforeQuirk())))) { // We're collapsing with a previous sibling's margins and not // with the top of the block. SetLogicalHeight(LogicalHeight() + std::max(margin_info.PositiveMargin(), pos_top) - std::max(margin_info.NegativeMargin(), neg_top)); logical_top = LogicalHeight(); } margin_info.SetDiscardMargin(child_discard_margin_after); if (!margin_info.DiscardMargin()) { margin_info.SetPositiveMargin(child_margins.PositiveMarginAfter()); margin_info.SetNegativeMargin(child_margins.NegativeMarginAfter()); } else { margin_info.ClearMargin(); } if (margin_info.Margin()) margin_info.SetHasMarginAfterQuirk(HasMarginAfterQuirk(&child)); } if (View()->GetLayoutState()->IsPaginated() && IsPageLogicalHeightKnown()) { LayoutUnit old_logical_top = logical_top; LayoutUnit margin = AdjustedMarginBeforeForPagination( child, before_collapse_logical_top, logical_top, layout_info); logical_top = before_collapse_logical_top + margin; SetLogicalHeight(LogicalHeight() + (logical_top - old_logical_top)); } // If |child| has moved up into previous siblings it needs to avoid or clear // any floats they contain. if (logical_top < before_collapse_logical_top) { LayoutUnit old_logical_height = LogicalHeight(); SetLogicalHeight(logical_top); LayoutBlockFlow* previous_block_flow = PreviousBlockFlowInFormattingContext(child); while (previous_block_flow) { auto lowest_float = previous_block_flow->LogicalTop() + previous_block_flow->LowestFloatLogicalBottom(); if (lowest_float <= logical_top) break; AddOverhangingFloats(previous_block_flow, false); previous_block_flow = PreviousBlockFlowInFormattingContext(*previous_block_flow); } SetLogicalHeight(old_logical_height); } if (previous_block_flow_can_self_collapse) { // If |child|'s previous sibling is or contains a self-collapsing block that // cleared a float and margin collapsing resulted in |child| moving up // into the margin area of the self-collapsing block then the float it // clears is now intruding into |child|. Layout again so that we can look // for floats in the parent that overhang |child|'s new logical top. bool logical_top_intrudes_into_float = logical_top < before_collapse_logical_top; if (logical_top_intrudes_into_float && ContainsFloats() && !child.AvoidsFloats() && LowestFloatLogicalBottom() > logical_top) child.SetNeedsLayoutAndFullPaintInvalidation( LayoutInvalidationReason::kAncestorMarginCollapsing); } return logical_top; } void LayoutBlockFlow::AdjustPositionedBlock( LayoutBox& child, const BlockChildrenLayoutInfo& layout_info) { LayoutUnit logical_top = LogicalHeight(); // Forced breaks are only specified on in-flow objects, but auto-positioned // out-of-flow objects may be affected by a break-after value of the previous // in-flow object. if (View()->GetLayoutState()->IsPaginated()) logical_top = ApplyForcedBreak(logical_top, layout_info.PreviousBreakAfterValue()); UpdateStaticInlinePositionForChild(child, logical_top); const MarginInfo& margin_info = layout_info.GetMarginInfo(); if (!margin_info.CanCollapseWithMarginBefore()) { // Positioned blocks don't collapse margins, so add the margin provided by // the container now. The child's own margin is added later when calculating // its logical top. LayoutUnit collapsed_before_pos = margin_info.PositiveMargin(); LayoutUnit collapsed_before_neg = margin_info.NegativeMargin(); logical_top += collapsed_before_pos - collapsed_before_neg; } PaintLayer* child_layer = child.Layer(); if (child_layer->StaticBlockPosition() != logical_top) child_layer->SetStaticBlockPosition(logical_top); } LayoutUnit LayoutBlockFlow::ClearFloatsIfNeeded(LayoutBox& child, MarginInfo& margin_info, LayoutUnit old_top_pos_margin, LayoutUnit old_top_neg_margin, LayoutUnit y_pos, bool child_is_self_collapsing, bool child_discard_margin) { LayoutUnit height_increase = GetClearDelta(&child, y_pos); margin_info.SetLastChildIsSelfCollapsingBlockWithClearance(false); if (!height_increase) return y_pos; if (child_is_self_collapsing) { margin_info.SetLastChildIsSelfCollapsingBlockWithClearance(true); margin_info.SetDiscardMargin(child_discard_margin); // For self-collapsing blocks that clear, they can still collapse their // margins with following siblings. Reset the current margins to represent // the self-collapsing block's margins only. // If DISCARD is specified for -webkit-margin-collapse, reset the margin // values. LayoutBlockFlow::MarginValues child_margins = MarginValuesForChild(child); if (!child_discard_margin) { margin_info.SetPositiveMargin( std::max(child_margins.PositiveMarginBefore(), child_margins.PositiveMarginAfter())); margin_info.SetNegativeMargin( std::max(child_margins.NegativeMarginBefore(), child_margins.NegativeMarginAfter())); } else { margin_info.ClearMargin(); } // CSS2.1 states: // "If the top and bottom margins of an element with clearance are // adjoining, its margins collapse with the adjoining margins of following // siblings but that resulting margin does not collapse with the bottom // margin of the parent block." // So the parent's bottom margin cannot collapse through this block or any // subsequent self-collapsing blocks. Set a bit to ensure this happens; it // will get reset if we encounter an in-flow sibling that is not // self-collapsing. margin_info.SetCanCollapseMarginAfterWithLastChild(false); // For now set the border-top of |child| flush with the bottom border-edge // of the float so it can layout any floating or positioned children of its // own at the correct vertical position. If subsequent siblings attempt to // collapse with |child|'s margins in |collapseMargins| we will adjust the // height of the parent to |child|'s margin top (which if it is positive // sits up 'inside' the float it's clearing) so that all three margins can // collapse at the correct vertical position. // Per CSS2.1 we need to ensure that any negative margin-top clears |child| // beyond the bottom border-edge of the float so that the top border edge of // the child (i.e. its clearance) is at a position that satisfies the // equation: "the amount of clearance is set so that: // clearance + margin-top = [height of float], // i.e., clearance = [height of float] - margin-top". SetLogicalHeight(child.LogicalTop() + child_margins.NegativeMarginBefore()); } else { // Increase our height by the amount we had to clear. SetLogicalHeight(LogicalHeight() + height_increase); } if (margin_info.CanCollapseWithMarginBefore()) { // We can no longer collapse with the top of the block since a clear // occurred. The empty blocks collapse into the cleared block. SetMaxMarginBeforeValues(old_top_pos_margin, old_top_neg_margin); margin_info.SetAtBeforeSideOfBlock(false); // In case the child discarded the before margin of the block we need to // reset the mustDiscardMarginBefore flag to the initial value. SetMustDiscardMarginBefore(Style()->MarginBeforeCollapse() == EMarginCollapse::kDiscard); } return y_pos + height_increase; } void LayoutBlockFlow::SetCollapsedBottomMargin(const MarginInfo& margin_info) { if (margin_info.CanCollapseWithMarginAfter() && !margin_info.CanCollapseWithMarginBefore()) { // Update the after side margin of the container to discard if the after // margin of the last child also discards and we collapse with it. // Don't update the max margin values because we won't need them anyway. if (margin_info.DiscardMargin()) { SetMustDiscardMarginAfter(); return; } // Update our max pos/neg bottom margins, since we collapsed our bottom // margins with our children. SetMaxMarginAfterValues( std::max(MaxPositiveMarginAfter(), margin_info.PositiveMargin()), std::max(MaxNegativeMarginAfter(), margin_info.NegativeMargin())); if (!margin_info.HasMarginAfterQuirk()) SetHasMarginAfterQuirk(false); if (margin_info.HasMarginAfterQuirk() && !MarginAfter()) { // We have no bottom margin and our last child has a quirky margin. // We will pick up this quirky margin and pass it through. // This deals with the <td><div><p> case. SetHasMarginAfterQuirk(true); } } } DISABLE_CFI_PERF void LayoutBlockFlow::MarginBeforeEstimateForChild( LayoutBox& child, LayoutUnit& positive_margin_before, LayoutUnit& negative_margin_before, bool& discard_margin_before) const { // Give up if in quirks mode and we're a body/table cell and the top margin of // the child box is quirky. // Give up if the child specified -webkit-margin-collapse: separate that // prevents collapsing. // FIXME: Use writing mode independent accessor for marginBeforeCollapse. if ((GetDocument().InQuirksMode() && HasMarginBeforeQuirk(&child) && (IsTableCell() || IsBody())) || child.Style()->MarginBeforeCollapse() == EMarginCollapse::kSeparate) return; // The margins are discarded by a child that specified // -webkit-margin-collapse: discard. // FIXME: Use writing mode independent accessor for marginBeforeCollapse. if (child.Style()->MarginBeforeCollapse() == EMarginCollapse::kDiscard) { positive_margin_before = LayoutUnit(); negative_margin_before = LayoutUnit(); discard_margin_before = true; return; } LayoutUnit before_child_margin = MarginBeforeForChild(child); positive_margin_before = std::max(positive_margin_before, before_child_margin); negative_margin_before = std::max(negative_margin_before, -before_child_margin); if (!child.IsLayoutBlockFlow()) return; LayoutBlockFlow* child_block_flow = ToLayoutBlockFlow(&child); if (child_block_flow->ChildrenInline() || child_block_flow->IsWritingModeRoot()) return; MarginInfo child_margin_info( child_block_flow, child_block_flow->BorderBefore() + child_block_flow->PaddingBefore(), child_block_flow->BorderAfter() + child_block_flow->PaddingAfter()); if (!child_margin_info.CanCollapseMarginBeforeWithChildren()) return; LayoutBox* grandchild_box = child_block_flow->FirstChildBox(); for (; grandchild_box; grandchild_box = grandchild_box->NextSiblingBox()) { if (!grandchild_box->IsFloatingOrOutOfFlowPositioned() && !grandchild_box->IsColumnSpanAll()) break; } if (!grandchild_box) return; // Make sure to update the block margins now for the grandchild box so that // we're looking at current values. if (grandchild_box->NeedsLayout()) { grandchild_box->ComputeAndSetBlockDirectionMargins(this); if (grandchild_box->IsLayoutBlock()) { LayoutBlock* grandchild_block = ToLayoutBlock(grandchild_box); grandchild_block->SetHasMarginBeforeQuirk( grandchild_box->Style()->HasMarginBeforeQuirk()); grandchild_block->SetHasMarginAfterQuirk( grandchild_box->Style()->HasMarginAfterQuirk()); } } // If we have a 'clear' value but also have a margin we may not actually // require clearance to move past any floats. If that's the case we want to be // sure we estimate the correct position including margins after any floats // rather than use 'clearance' later which could give us the wrong position. if (grandchild_box->Style()->Clear() != EClear::kNone && child_block_flow->MarginBeforeForChild(*grandchild_box) == 0) return; // Collapse the margin of the grandchild box with our own to produce an // estimate. child_block_flow->MarginBeforeEstimateForChild( *grandchild_box, positive_margin_before, negative_margin_before, discard_margin_before); } LayoutUnit LayoutBlockFlow::EstimateLogicalTopPosition( LayoutBox& child, const BlockChildrenLayoutInfo& layout_info, LayoutUnit& estimate_without_pagination) { const MarginInfo& margin_info = layout_info.GetMarginInfo(); // FIXME: We need to eliminate the estimation of vertical position, because // when it's wrong we sometimes trigger a pathological // relayout if there are intruding floats. LayoutUnit logical_top_estimate = LogicalHeight(); LayoutUnit positive_margin_before; LayoutUnit negative_margin_before; bool discard_margin_before = false; if (!margin_info.CanCollapseWithMarginBefore()) { if (child.SelfNeedsLayout()) { // Try to do a basic estimation of how the collapse is going to go. MarginBeforeEstimateForChild(child, positive_margin_before, negative_margin_before, discard_margin_before); } else { // Use the cached collapsed margin values from a previous layout. Most of // the time they will be right. LayoutBlockFlow::MarginValues margin_values = MarginValuesForChild(child); positive_margin_before = std::max(positive_margin_before, margin_values.PositiveMarginBefore()); negative_margin_before = std::max(negative_margin_before, margin_values.NegativeMarginBefore()); discard_margin_before = MustDiscardMarginBeforeForChild(child); } // Collapse the result with our current margins. if (!discard_margin_before) logical_top_estimate += std::max(margin_info.PositiveMargin(), positive_margin_before) - std::max(margin_info.NegativeMargin(), negative_margin_before); } LayoutState* layout_state = View()->GetLayoutState(); if (layout_state->IsPaginated() && IsPageLogicalHeightKnown()) { LayoutUnit margin = AdjustedMarginBeforeForPagination( child, LogicalHeight(), logical_top_estimate, layout_info); logical_top_estimate = LogicalHeight() + margin; } logical_top_estimate += GetClearDelta(&child, logical_top_estimate); estimate_without_pagination = logical_top_estimate; if (layout_state->IsPaginated()) { if (!layout_info.IsAtFirstInFlowChild()) { // Estimate the need for a forced break in front of this child. The final // break policy at this class A break point isn't known until we have laid // out the children of |child|. There may be forced break-before values // set on first-children inside that get propagated up to the child. // Just make an estimate with what we know so far. EBreakBetween break_value = child.ClassABreakPointValue(layout_info.PreviousBreakAfterValue()); if (IsForcedFragmentainerBreakValue(break_value)) { logical_top_estimate = ApplyForcedBreak(LogicalHeight(), break_value); // Disregard previous margins, since they will collapse with the // fragmentainer boundary, due to the forced break. Only apply margins // that have been specified on the child or its descendants. if (!discard_margin_before) logical_top_estimate += positive_margin_before - negative_margin_before; // Clearance may already have taken us past the beginning of the next // fragmentainer. return std::max(estimate_without_pagination, logical_top_estimate); } logical_top_estimate = AdjustForUnsplittableChild(child, logical_top_estimate); } } return logical_top_estimate; } void LayoutBlockFlow::AdjustFloatingBlock(const MarginInfo& margin_info) { // The float should be positioned taking into account the bottom margin // of the previous flow. We add that margin into the height, get the // float positioned properly, and then subtract the margin out of the // height again. In the case of self-collapsing blocks, we always just // use the top margins, since the self-collapsing block collapsed its // own bottom margin into its top margin. // // Note also that the previous flow may collapse its margin into the top of // our block. If this is the case, then we do not add the margin in to our // height when computing the position of the float. This condition can be // tested for by simply calling canCollapseWithMarginBefore. See // http://www.hixie.ch/tests/adhoc/css/box/block/margin-collapse/046.html for // an example of this scenario. LayoutUnit logical_top = LogicalHeight(); if (!margin_info.CanCollapseWithMarginBefore()) logical_top += margin_info.Margin(); PlaceNewFloats(logical_top); } void LayoutBlockFlow::HandleAfterSideOfBlock(LayoutBox* last_child, LayoutUnit before_side, LayoutUnit after_side, MarginInfo& margin_info) { margin_info.SetAtAfterSideOfBlock(true); // If our last child was a self-collapsing block with clearance then our // logical height is flush with the bottom edge of the float that the child // clears. The correct vertical position for the margin-collapsing we want to // perform now is at the child's margin-top - so adjust our height to that // position. if (margin_info.LastChildIsSelfCollapsingBlockWithClearance()) { DCHECK(last_child); SetLogicalHeight(LogicalHeight() - MarginValuesForChild(*last_child).PositiveMarginBefore()); } if (margin_info.CanCollapseMarginAfterWithChildren() && !margin_info.CanCollapseMarginAfterWithLastChild()) margin_info.SetCanCollapseMarginAfterWithChildren(false); // If we can't collapse with children then go ahead and add in the bottom // margin. if (!margin_info.DiscardMargin() && (!margin_info.CanCollapseWithMarginAfter() && !margin_info.CanCollapseWithMarginBefore() && (!GetDocument().InQuirksMode() || !margin_info.QuirkContainer() || !margin_info.HasMarginAfterQuirk()))) SetLogicalHeight(LogicalHeight() + margin_info.Margin()); // Now add in our bottom border/padding. SetLogicalHeight(LogicalHeight() + after_side); // Negative margins can cause our height to shrink below our minimal height // (border/padding). If this happens, ensure that the computed height is // increased to the minimal height. SetLogicalHeight(std::max(LogicalHeight(), before_side + after_side)); // Update our bottom collapsed margin info. SetCollapsedBottomMargin(margin_info); // There's no class A break point right after the last child, only *between* // siblings. So propagate the break-after value, and keep looking for a class // A break point (at the next in-flow block-level object), where we'll join // this break-after value with the break-before value there. if (View()->GetLayoutState()->IsPaginated() && last_child) SetBreakAfter( JoinFragmentainerBreakValues(BreakAfter(), last_child->BreakAfter())); } void LayoutBlockFlow::SetMustDiscardMarginBefore(bool value) { if (Style()->MarginBeforeCollapse() == EMarginCollapse::kDiscard) { DCHECK(value); return; } if (!rare_data_ && !value) return; if (!rare_data_) rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this); rare_data_->discard_margin_before_ = value; } void LayoutBlockFlow::SetMustDiscardMarginAfter(bool value) { if (Style()->MarginAfterCollapse() == EMarginCollapse::kDiscard) { DCHECK(value); return; } if (!rare_data_ && !value) return; if (!rare_data_) rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this); rare_data_->discard_margin_after_ = value; } bool LayoutBlockFlow::MustDiscardMarginBefore() const { return Style()->MarginBeforeCollapse() == EMarginCollapse::kDiscard || (rare_data_ && rare_data_->discard_margin_before_); } bool LayoutBlockFlow::MustDiscardMarginAfter() const { return Style()->MarginAfterCollapse() == EMarginCollapse::kDiscard || (rare_data_ && rare_data_->discard_margin_after_); } bool LayoutBlockFlow::MustDiscardMarginBeforeForChild( const LayoutBox& child) const { DCHECK(!child.SelfNeedsLayout()); if (!child.IsWritingModeRoot()) { return child.IsLayoutBlockFlow() ? ToLayoutBlockFlow(&child)->MustDiscardMarginBefore() : (child.Style()->MarginBeforeCollapse() == EMarginCollapse::kDiscard); } if (child.IsHorizontalWritingMode() == IsHorizontalWritingMode()) { return child.IsLayoutBlockFlow() ? ToLayoutBlockFlow(&child)->MustDiscardMarginAfter() : (child.Style()->MarginAfterCollapse() == EMarginCollapse::kDiscard); } // FIXME: We return false here because the implementation is not geometrically // complete. We have values only for before/after, not start/end. // In case the boxes are perpendicular we assume the property is not // specified. return false; } bool LayoutBlockFlow::MustDiscardMarginAfterForChild( const LayoutBox& child) const { DCHECK(!child.SelfNeedsLayout()); if (!child.IsWritingModeRoot()) { return child.IsLayoutBlockFlow() ? ToLayoutBlockFlow(&child)->MustDiscardMarginAfter() : (child.Style()->MarginAfterCollapse() == EMarginCollapse::kDiscard); } if (child.IsHorizontalWritingMode() == IsHorizontalWritingMode()) { return child.IsLayoutBlockFlow() ? ToLayoutBlockFlow(&child)->MustDiscardMarginBefore() : (child.Style()->MarginBeforeCollapse() == EMarginCollapse::kDiscard); } // FIXME: See |mustDiscardMarginBeforeForChild| above. return false; } void LayoutBlockFlow::SetMaxMarginBeforeValues(LayoutUnit pos, LayoutUnit neg) { if (!rare_data_) { if (pos == LayoutBlockFlowRareData::PositiveMarginBeforeDefault(this) && neg == LayoutBlockFlowRareData::NegativeMarginBeforeDefault(this)) return; rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this); } rare_data_->margins_.SetPositiveMarginBefore(pos); rare_data_->margins_.SetNegativeMarginBefore(neg); } void LayoutBlockFlow::SetMaxMarginAfterValues(LayoutUnit pos, LayoutUnit neg) { if (!rare_data_) { if (pos == LayoutBlockFlowRareData::PositiveMarginAfterDefault(this) && neg == LayoutBlockFlowRareData::NegativeMarginAfterDefault(this)) return; rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this); } rare_data_->margins_.SetPositiveMarginAfter(pos); rare_data_->margins_.SetNegativeMarginAfter(neg); } bool LayoutBlockFlow::MustSeparateMarginBeforeForChild( const LayoutBox& child) const { DCHECK(!child.SelfNeedsLayout()); const ComputedStyle& child_style = child.StyleRef(); if (!child.IsWritingModeRoot()) return child_style.MarginBeforeCollapse() == EMarginCollapse::kSeparate; if (child.IsHorizontalWritingMode() == IsHorizontalWritingMode()) return child_style.MarginAfterCollapse() == EMarginCollapse::kSeparate; // FIXME: See |mustDiscardMarginBeforeForChild| above. return false; } bool LayoutBlockFlow::MustSeparateMarginAfterForChild( const LayoutBox& child) const { DCHECK(!child.SelfNeedsLayout()); const ComputedStyle& child_style = child.StyleRef(); if (!child.IsWritingModeRoot()) return child_style.MarginAfterCollapse() == EMarginCollapse::kSeparate; if (child.IsHorizontalWritingMode() == IsHorizontalWritingMode()) return child_style.MarginBeforeCollapse() == EMarginCollapse::kSeparate; // FIXME: See |mustDiscardMarginBeforeForChild| above. return false; } LayoutUnit LayoutBlockFlow::ApplyForcedBreak(LayoutUnit logical_offset, EBreakBetween break_value) { if (!IsForcedFragmentainerBreakValue(break_value)) return logical_offset; // TODO(mstensho): honor breakValue. There are different types of forced // breaks. We currently just assume that we want to break to the top of the // next fragmentainer of the fragmentation context we're in. However, we may // want to find the next left or right page - even if we're inside a multicol // container when printing. if (!IsPageLogicalHeightKnown()) { // Page height is still unknown, so we cannot insert forced breaks. return logical_offset; } LayoutUnit remaining_logical_height = PageRemainingLogicalHeightForOffset( logical_offset, kAssociateWithLatterPage); if (remaining_logical_height == PageLogicalHeightForOffset(logical_offset)) return logical_offset; // Don't break if we're already at the block start // of a fragmentainer. // If this is the first forced break inside this object, store the // location. We need this information later if there's a break-inside:avoid // object further up. We need to know if there are any forced breaks inside // such objects, in order to determine whether we need to push it to the next // fragmentainer or not. if (!FirstForcedBreakOffset()) SetFirstForcedBreakOffset(logical_offset); return logical_offset + remaining_logical_height; } void LayoutBlockFlow::SetBreakBefore(EBreakBetween break_value) { if (break_value != EBreakBetween::kAuto && !IsBreakBetweenControllable(break_value)) break_value = EBreakBetween::kAuto; if (break_value == EBreakBetween::kAuto && !rare_data_) return; EnsureRareData().break_before_ = static_cast<unsigned>(break_value); } void LayoutBlockFlow::SetBreakAfter(EBreakBetween break_value) { if (break_value != EBreakBetween::kAuto && !IsBreakBetweenControllable(break_value)) break_value = EBreakBetween::kAuto; if (break_value == EBreakBetween::kAuto && !rare_data_) return; EnsureRareData().break_after_ = static_cast<unsigned>(break_value); } EBreakBetween LayoutBlockFlow::BreakBefore() const { return rare_data_ ? static_cast<EBreakBetween>(rare_data_->break_before_) : EBreakBetween::kAuto; } EBreakBetween LayoutBlockFlow::BreakAfter() const { return rare_data_ ? static_cast<EBreakBetween>(rare_data_->break_after_) : EBreakBetween::kAuto; } void LayoutBlockFlow::AddOverflowFromFloats() { if (!floating_objects_) return; const FloatingObjectSet& floating_object_set = floating_objects_->Set(); FloatingObjectSetIterator end = floating_object_set.end(); for (FloatingObjectSetIterator it = floating_object_set.begin(); it != end; ++it) { const FloatingObject& floating_object = *it->get(); if (floating_object.IsDescendant()) AddOverflowFromChild( *floating_object.GetLayoutObject(), LayoutSize(XPositionForFloatIncludingMargin(floating_object), YPositionForFloatIncludingMargin(floating_object))); } } scoped_refptr<NGLayoutResult> LayoutBlockFlow::CachedLayoutResult( const NGConstraintSpace&, NGBreakToken*) const { return nullptr; } const NGConstraintSpace* LayoutBlockFlow::CachedConstraintSpace() const { return nullptr; } scoped_refptr<NGLayoutResult> LayoutBlockFlow::CachedLayoutResultForTesting() { return nullptr; } void LayoutBlockFlow::SetCachedLayoutResult(const NGConstraintSpace&, NGBreakToken*, scoped_refptr<NGLayoutResult>) {} void LayoutBlockFlow::SetPaintFragment( scoped_refptr<const NGPhysicalFragment>) {} void LayoutBlockFlow::ComputeOverflow(LayoutUnit old_client_after_edge, bool recompute_floats) { LayoutBlock::ComputeOverflow(old_client_after_edge, recompute_floats); if (recompute_floats || CreatesNewFormattingContext() || HasSelfPaintingLayer()) AddOverflowFromFloats(); } void LayoutBlockFlow::ComputeSelfHitTestRects( Vector<LayoutRect>& rects, const LayoutPoint& layer_offset) const { LayoutBlock::ComputeSelfHitTestRects(rects, layer_offset); if (!HasHorizontalLayoutOverflow() && !HasVerticalLayoutOverflow()) return; for (RootInlineBox* curr = FirstRootBox(); curr; curr = curr->NextRootBox()) { LayoutUnit top = std::max<LayoutUnit>(curr->LineTop(), curr->Y()); LayoutUnit bottom = std::min<LayoutUnit>(curr->LineBottom(), curr->Y() + curr->Height()); LayoutRect rect(layer_offset.X() + curr->X(), layer_offset.Y() + top, curr->Width(), bottom - top); // It's common for this rect to be entirely contained in our box, so exclude // that simple case. if (!rect.IsEmpty() && (rects.IsEmpty() || !rects[0].Contains(rect))) rects.push_back(rect); } } void LayoutBlockFlow::AbsoluteRects( Vector<IntRect>& rects, const LayoutPoint& accumulated_offset) const { if (!IsAnonymousBlockContinuation()) { LayoutBlock::AbsoluteRects(rects, accumulated_offset); return; } // For blocks inside inlines, we go ahead and include margins so that we run // right up to the inline boxes above and below us (thus getting merged with // them to form a single irregular shape). // FIXME: This is wrong for vertical writing-modes. // https://bugs.webkit.org/show_bug.cgi?id=46781 LayoutRect rect(accumulated_offset, Size()); rect.Expand(CollapsedMarginBoxLogicalOutsets()); rects.push_back(PixelSnappedIntRect(rect)); Continuation()->AbsoluteRects( rects, accumulated_offset - ToLayoutSize( Location() + InlineElementContinuation()->ContainingBlock()->Location())); } void LayoutBlockFlow::AbsoluteQuads(Vector<FloatQuad>& quads, MapCoordinatesFlags mode) const { if (!IsAnonymousBlockContinuation()) { LayoutBlock::AbsoluteQuads(quads, mode); return; } LayoutBoxModelObject::AbsoluteQuads(quads, mode); } void LayoutBlockFlow::AbsoluteQuadsForSelf(Vector<FloatQuad>& quads, MapCoordinatesFlags mode) const { // For blocks inside inlines, we go ahead and include margins so that we run // right up to the inline boxes above and below us (thus getting merged with // them to form a single irregular shape). // FIXME: This is wrong for vertical writing-modes. // https://bugs.webkit.org/show_bug.cgi?id=46781 LayoutRect local_rect(LayoutPoint(), Size()); local_rect.Expand(CollapsedMarginBoxLogicalOutsets()); quads.push_back(LocalToAbsoluteQuad(FloatRect(local_rect), mode)); } LayoutObject* LayoutBlockFlow::HoverAncestor() const { return IsAnonymousBlockContinuation() ? Continuation() : LayoutBlock::HoverAncestor(); } RootInlineBox* LayoutBlockFlow::CreateAndAppendRootInlineBox() { RootInlineBox* root_box = CreateRootInlineBox(); line_boxes_.AppendLineBox(root_box); return root_box; } void LayoutBlockFlow::DeleteLineBoxTree() { if (ContainsFloats()) floating_objects_->ClearLineBoxTreePointers(); line_boxes_.DeleteLineBoxTree(); } int LayoutBlockFlow::LineCount( const RootInlineBox* stop_root_inline_box) const { #ifndef NDEBUG DCHECK(!stop_root_inline_box || stop_root_inline_box->Block().DebugPointer() == this); #endif if (!ChildrenInline()) return 0; int count = 0; for (const RootInlineBox* box = FirstRootBox(); box; box = box->NextRootBox()) { count++; if (box == stop_root_inline_box) break; } return count; } LayoutUnit LayoutBlockFlow::FirstLineBoxBaseline() const { // Orthogonal grid items can participante in baseline alignment along column // axis. if (IsWritingModeRoot() && !IsRubyRun() && !IsGridItem()) return LayoutUnit(-1); if (!ChildrenInline()) return LayoutBlock::FirstLineBoxBaseline(); if (FirstLineBox()) { const SimpleFontData* font_data = Style(true)->GetFont().PrimaryFont(); DCHECK(font_data); if (!font_data) return LayoutUnit(-1); // fontMetrics 'ascent' is the distance above the baseline to the 'over' // edge, which is 'top' for horizontal and 'right' for vertical-lr and // vertical-rl. However, firstLineBox()->logicalTop() gives the offset from // the 'left' edge for vertical-lr, hence we need to use the Font Metrics // 'descent' instead. The result should be handled accordingly by the caller // as a 'descent' value, in order to compute properly the max baseline. if (StyleRef().IsFlippedLinesWritingMode()) { return FirstLineBox()->LogicalTop() + font_data->GetFontMetrics().Descent( FirstRootBox()->BaselineType()); } return FirstLineBox()->LogicalTop() + font_data->GetFontMetrics().Ascent(FirstRootBox()->BaselineType()); } if (RuntimeEnabledFeatures::LayoutNGEnabled()) { if (const NGPaintFragment* paint_fragment = PaintFragment()) { NGBoxFragment box_fragment( StyleRef().GetWritingMode(), ToNGPhysicalBoxFragment(paint_fragment->PhysicalFragment())); NGLineHeightMetrics metrics = box_fragment.BaselineMetricsWithoutSynthesize( {NGBaselineAlgorithmType::kFirstLine, StyleRef().GetFontBaseline()}); if (!metrics.IsEmpty()) return metrics.ascent; } } return LayoutUnit(-1); } LayoutUnit LayoutBlockFlow::InlineBlockBaseline( LineDirectionMode line_direction) const { if (UseLogicalBottomMarginEdgeForInlineBlockBaseline()) { // We are not calling baselinePosition here because the caller should add // the margin-top/margin-right, not us. return line_direction == kHorizontalLine ? Size().Height() + MarginBottom() : Size().Width() + MarginLeft(); } if (IsWritingModeRoot() && !IsRubyRun()) return LayoutUnit(-1); if (!ChildrenInline()) return LayoutBlock::InlineBlockBaseline(line_direction); if (LastLineBox()) { const SimpleFontData* font_data = Style(LastLineBox() == FirstLineBox())->GetFont().PrimaryFont(); DCHECK(font_data); if (!font_data) return LayoutUnit(-1); // InlineFlowBox::placeBoxesInBlockDirection will flip lines in // case of verticalLR mode, so we can assume verticalRL for now. if (Style()->IsFlippedLinesWritingMode()) { return LogicalHeight() - LastLineBox()->LogicalBottom() + font_data->GetFontMetrics().Ascent(LastRootBox()->BaselineType()); } return LastLineBox()->LogicalTop() + font_data->GetFontMetrics().Ascent(LastRootBox()->BaselineType()); } if (!HasLineIfEmpty()) return LayoutUnit(-1); const SimpleFontData* font_data = FirstLineStyle()->GetFont().PrimaryFont(); DCHECK(font_data); if (!font_data) return LayoutUnit(-1); const FontMetrics& font_metrics = font_data->GetFontMetrics(); return LayoutUnit( (font_metrics.Ascent() + (LineHeight(true, line_direction, kPositionOfInteriorLineBoxes) - font_metrics.Height()) / 2 + (line_direction == kHorizontalLine ? BorderTop() + PaddingTop() : BorderRight() + PaddingRight())) .ToInt()); } void LayoutBlockFlow::RemoveFloatingObjectsFromDescendants() { if (!ContainsFloats()) return; RemoveFloatingObjects(); SetChildNeedsLayout(kMarkOnlyThis); // If our children are inline, then the only boxes which could contain floats // are atomic inlines (e.g. inline-block, float etc.) and these create // formatting contexts, so can't pick up intruding floats from // ancestors/siblings - making them safe to skip. if (ChildrenInline()) return; for (LayoutObject* child = FirstChild(); child; child = child->NextSibling()) { // We don't skip blocks that create formatting contexts as they may have // only recently changed style and their float lists may still contain // floats from siblings and ancestors. if (child->IsLayoutBlockFlow()) ToLayoutBlockFlow(child)->RemoveFloatingObjectsFromDescendants(); } } void LayoutBlockFlow::MarkAllDescendantsWithFloatsForLayout( LayoutBox* float_to_remove, bool in_layout) { if (!EverHadLayout() && !ContainsFloats()) return; if (descendants_with_floats_marked_for_layout_ && !float_to_remove) return; descendants_with_floats_marked_for_layout_ |= !float_to_remove; MarkingBehavior mark_parents = in_layout ? kMarkOnlyThis : kMarkContainerChain; SetChildNeedsLayout(mark_parents); if (float_to_remove) RemoveFloatingObject(float_to_remove); // Iterate over our children and mark them as needed. If our children are // inline, then the only boxes which could contain floats are atomic inlines // (e.g. inline-block, float etc.) and these create formatting contexts, so // can't pick up intruding floats from ancestors/siblings - making them safe // to skip. if (!ChildrenInline()) { for (LayoutObject* child = FirstChild(); child; child = child->NextSibling()) { if ((!float_to_remove && child->IsFloatingOrOutOfFlowPositioned()) || !child->IsLayoutBlock()) continue; if (!child->IsLayoutBlockFlow()) { LayoutBlock* child_block = ToLayoutBlock(child); if (child_block->ShrinkToAvoidFloats() && child_block->EverHadLayout()) child_block->SetChildNeedsLayout(mark_parents); continue; } LayoutBlockFlow* child_block_flow = ToLayoutBlockFlow(child); if ((float_to_remove ? child_block_flow->ContainsFloat(float_to_remove) : child_block_flow->ContainsFloats()) || child_block_flow->ShrinkToAvoidFloats()) child_block_flow->MarkAllDescendantsWithFloatsForLayout(float_to_remove, in_layout); } } } void LayoutBlockFlow::MarkSiblingsWithFloatsForLayout( LayoutBox* float_to_remove) { if (!floating_objects_) return; const FloatingObjectSet& floating_object_set = floating_objects_->Set(); FloatingObjectSetIterator end = floating_object_set.end(); for (LayoutObject* next = NextSibling(); next; next = next->NextSibling()) { if (!next->IsLayoutBlockFlow() || (!float_to_remove && (next->IsFloatingOrOutOfFlowPositioned() || ToLayoutBlockFlow(next)->AvoidsFloats()))) continue; LayoutBlockFlow* next_block = ToLayoutBlockFlow(next); for (FloatingObjectSetIterator it = floating_object_set.begin(); it != end; ++it) { LayoutBox* floating_box = (*it)->GetLayoutObject(); if (float_to_remove && floating_box != float_to_remove) continue; if (next_block->ContainsFloat(floating_box)) next_block->MarkAllDescendantsWithFloatsForLayout(floating_box); } } } LayoutUnit LayoutBlockFlow::GetClearDelta(LayoutBox* child, LayoutUnit logical_top) { // There is no need to compute clearance if we have no floats. if (!ContainsFloats()) return LayoutUnit(); // At least one float is present. We need to perform the clearance // computation. EClear clear = child->Style()->Clear(); LayoutUnit logical_bottom = LowestFloatLogicalBottom(clear); // We also clear floats if we are too big to sit on the same line as a float // (and wish to avoid floats by default). LayoutUnit result = clear != EClear::kNone ? (logical_bottom - logical_top).ClampNegativeToZero() : LayoutUnit(); if (!result && child->AvoidsFloats()) { LayoutUnit new_logical_top = logical_top; LayoutRect border_box = child->BorderBoxRect(); LayoutUnit child_logical_width_at_old_logical_top_offset = IsHorizontalWritingMode() ? border_box.Width() : border_box.Height(); while (true) { LayoutUnit available_logical_width_at_new_logical_top_offset = AvailableLogicalWidthForAvoidingFloats(new_logical_top, LogicalHeightForChild(*child)); if (available_logical_width_at_new_logical_top_offset == AvailableLogicalWidthForContent()) return new_logical_top - logical_top; LogicalExtentComputedValues computed_values; child->LogicalExtentAfterUpdatingLogicalWidth(new_logical_top, computed_values); LayoutUnit child_logical_width_at_new_logical_top_offset = computed_values.extent_; if (child_logical_width_at_new_logical_top_offset <= available_logical_width_at_new_logical_top_offset) { // Even though we may not be moving, if the logical width did shrink // because of the presence of new floats, then we need to force a // relayout as though we shifted. This happens because of the dynamic // addition of overhanging floats from previous siblings when negative // margins exist on a child (see the addOverhangingFloats call at the // end of collapseMargins). if (child_logical_width_at_old_logical_top_offset != child_logical_width_at_new_logical_top_offset) child->SetChildNeedsLayout(kMarkOnlyThis); return new_logical_top - logical_top; } new_logical_top = NextFloatLogicalBottomBelowForBlock(new_logical_top); DCHECK_GE(new_logical_top, logical_top); if (new_logical_top < logical_top) break; } NOTREACHED(); } return result; } void LayoutBlockFlow::CreateFloatingObjects() { floating_objects_ = std::make_unique<FloatingObjects>(this, IsHorizontalWritingMode()); } void LayoutBlockFlow::WillBeDestroyed() { // Mark as being destroyed to avoid trouble with merges in removeChild(). being_destroyed_ = true; // Make sure to destroy anonymous children first while they are still // connected to the rest of the tree, so that they will properly dirty line // boxes that they are removed from. Effects that do :before/:after only on // hover could crash otherwise. Children()->DestroyLeftoverChildren(); // Destroy our continuation before anything other than anonymous children. // The reason we don't destroy it before anonymous children is that they may // have continuations of their own that are anonymous children of our // continuation. LayoutBoxModelObject* continuation = Continuation(); if (continuation) { continuation->Destroy(); SetContinuation(nullptr); } if (!DocumentBeingDestroyed()) { // TODO(mstensho): figure out if we need this. We have no test coverage for // it. It looks like all line boxes have been removed at this point. if (FirstLineBox()) { // We can't wait for LayoutBox::destroy to clear the selection, // because by then we will have nuked the line boxes. // FIXME: The FrameSelection should be responsible for this when it // is notified of DOM mutations. if (IsSelectionBorder()) View()->ClearSelection(); // If we are an anonymous block, then our line boxes might have children // that will outlast this block. In the non-anonymous block case those // children will be destroyed by the time we return from this function. if (IsAnonymousBlock()) { for (InlineFlowBox* box : *LineBoxes()) { while (InlineBox* child_box = box->FirstChild()) child_box->Remove(); } } } } line_boxes_.DeleteLineBoxes(); LayoutBlock::WillBeDestroyed(); } void LayoutBlockFlow::StyleWillChange(StyleDifference diff, const ComputedStyle& new_style) { const ComputedStyle* old_style = Style(); can_propagate_float_into_sibling_ = old_style ? !IsFloatingOrOutOfFlowPositioned() && !AvoidsFloats() : false; if (old_style && Parent() && diff.NeedsFullLayout() && old_style->GetPosition() != new_style.GetPosition() && ContainsFloats() && !IsFloating() && !IsOutOfFlowPositioned() && new_style.HasOutOfFlowPosition()) MarkAllDescendantsWithFloatsForLayout(); LayoutBlock::StyleWillChange(diff, new_style); } DISABLE_CFI_PERF void LayoutBlockFlow::StyleDidChange(StyleDifference diff, const ComputedStyle* old_style) { bool had_self_painting_layer = HasSelfPaintingLayer(); LayoutBlock::StyleDidChange(diff, old_style); // After our style changed, if we lose our ability to propagate floats into // next sibling blocks, then we need to find the top most parent containing // that overhanging float and then mark its descendants with floats for layout // and clear all floats from its next sibling blocks that exist in our // floating objects list. See crbug.com/56299 and crbug.com/62875. bool can_propagate_float_into_sibling = !IsFloatingOrOutOfFlowPositioned() && !AvoidsFloats(); bool sibling_float_propagation_changed = diff.NeedsFullLayout() && can_propagate_float_into_sibling_ && !can_propagate_float_into_sibling && HasOverhangingFloats(); // When this object's self-painting layer status changed, we should update // FloatingObjects::shouldPaint() flags for descendant overhanging floats in // ancestors. bool needs_update_ancestor_float_object_should_paint_flags = false; if (HasSelfPaintingLayer() != had_self_painting_layer && HasOverhangingFloats()) { SetNeedsLayout(LayoutInvalidationReason::kStyleChange); if (had_self_painting_layer) MarkAllDescendantsWithFloatsForLayout(); else needs_update_ancestor_float_object_should_paint_flags = true; } if (sibling_float_propagation_changed || needs_update_ancestor_float_object_should_paint_flags) { LayoutBlockFlow* parent_block_flow = this; const FloatingObjectSet& floating_object_set = floating_objects_->Set(); FloatingObjectSetIterator end = floating_object_set.end(); for (LayoutObject* curr = Parent(); curr && !curr->IsLayoutView(); curr = curr->Parent()) { if (curr->IsLayoutBlockFlow()) { LayoutBlockFlow* curr_block = ToLayoutBlockFlow(curr); if (curr_block->HasOverhangingFloats()) { for (FloatingObjectSetIterator it = floating_object_set.begin(); it != end; ++it) { LayoutBox* layout_box = (*it)->GetLayoutObject(); if (curr_block->HasOverhangingFloat(layout_box)) { parent_block_flow = curr_block; break; } } } } } parent_block_flow->MarkAllDescendantsWithFloatsForLayout(); if (sibling_float_propagation_changed) parent_block_flow->MarkSiblingsWithFloatsForLayout(); } if (diff.NeedsFullLayout() || !old_style) CreateOrDestroyMultiColumnFlowThreadIfNeeded(old_style); if (old_style) { if (LayoutMultiColumnFlowThread* flow_thread = MultiColumnFlowThread()) { if (!Style()->ColumnRuleEquivalent(*old_style)) { // Column rules are painted by anonymous column set children of the // multicol container. We need to notify them. flow_thread->ColumnRuleStyleDidChange(); } } } } void LayoutBlockFlow::UpdateBlockChildDirtyBitsBeforeLayout( bool relayout_children, LayoutBox& child) { if (child.IsLayoutMultiColumnSpannerPlaceholder()) ToLayoutMultiColumnSpannerPlaceholder(child) .MarkForLayoutIfObjectInFlowThreadNeedsLayout(); LayoutBlock::UpdateBlockChildDirtyBitsBeforeLayout(relayout_children, child); } void LayoutBlockFlow::UpdateStaticInlinePositionForChild( LayoutBox& child, LayoutUnit logical_top, IndentTextOrNot indent_text) { if (child.Style()->IsOriginalDisplayInlineType()) SetStaticInlinePositionForChild( child, StartAlignedOffsetForLine(logical_top, indent_text)); else SetStaticInlinePositionForChild(child, StartOffsetForContent()); } void LayoutBlockFlow::SetStaticInlinePositionForChild( LayoutBox& child, LayoutUnit inline_position) { child.Layer()->SetStaticInlinePosition(inline_position); } LayoutInline* LayoutBlockFlow::InlineElementContinuation() const { LayoutBoxModelObject* continuation = Continuation(); return continuation && continuation->IsInline() ? ToLayoutInline(continuation) : nullptr; } void LayoutBlockFlow::AddChild(LayoutObject* new_child, LayoutObject* before_child) { if (LayoutMultiColumnFlowThread* flow_thread = MultiColumnFlowThread()) { if (before_child == flow_thread) before_child = flow_thread->FirstChild(); DCHECK(!before_child || before_child->IsDescendantOf(flow_thread)); flow_thread->AddChild(new_child, before_child); return; } if (before_child && before_child->Parent() != this) { AddChildBeforeDescendant(new_child, before_child); return; } bool made_boxes_non_inline = false; // A block has to either have all of its children inline, or all of its // children as blocks. // So, if our children are currently inline and a block child has to be // inserted, we move all our inline children into anonymous block boxes. bool child_is_block_level; bool layout_ng_enabled = RuntimeEnabledFeatures::LayoutNGEnabled(); if (layout_ng_enabled && !FirstChild() && (new_child->IsFloating() || (new_child->IsOutOfFlowPositioned() && !new_child->StyleRef().IsOriginalDisplayInlineType()))) { // TODO(kojii): We once forced all floats and OOF to create a block // container in LayoutNG, which turned out to be not a great way, but // completely turning this off breaks too much. When an OOF is an inline // type, we need to disable this so that we can compute the inline static // position. crbug.com/734554 child_is_block_level = true; } else { child_is_block_level = !new_child->IsInline() && !new_child->IsFloatingOrOutOfFlowPositioned(); } if (ChildrenInline()) { if (child_is_block_level) { // Wrap the inline content in anonymous blocks, to allow for the new block // child to be inserted. MakeChildrenNonInline(before_child); made_boxes_non_inline = true; if (before_child && before_child->Parent() != this) { before_child = before_child->Parent(); DCHECK(before_child->IsAnonymousBlock()); DCHECK_EQ(before_child->Parent(), this); } } } else if (!child_is_block_level) { // This block has block children. We may want to put the new child into an // anomyous block. Floats and out-of-flow children may live among either // block or inline children, so for such children, only put them inside an // anonymous block if one already exists. If the child is inline, on the // other hand, we *have to* put it inside an anonymous block, so create a // new one if there is none for us there already. LayoutObject* after_child = before_child ? before_child->PreviousSibling() : LastChild(); if (after_child && after_child->IsAnonymousBlock()) { after_child->AddChild(new_child); return; } // LayoutNGListMarker is out-of-flow for the tree building purpose, and that // is not inline level, but IsInline(). if (new_child->IsInline() && !new_child->IsLayoutNGListMarker()) { // No suitable existing anonymous box - create a new one. LayoutBlockFlow* new_block = ToLayoutBlockFlow(CreateAnonymousBlock()); LayoutBox::AddChild(new_block, before_child); // Reparent adjacent floating or out-of-flow siblings to the new box. if (!layout_ng_enabled) new_block->ReparentPrecedingFloatingOrOutOfFlowSiblings(); new_block->AddChild(new_child); new_block->ReparentSubsequentFloatingOrOutOfFlowSiblings(); return; } } // Skip the LayoutBlock override, since that one deals with anonymous child // insertion in a way that isn't sufficient for us, and can only cause trouble // at this point. LayoutBox::AddChild(new_child, before_child); if (made_boxes_non_inline && Parent() && IsAnonymousBlock() && Parent()->IsLayoutBlock()) { ToLayoutBlock(Parent())->RemoveLeftoverAnonymousBlock(this); // |this| may be dead now. } } static bool IsMergeableAnonymousBlock(const LayoutBlockFlow* block) { return block->IsAnonymousBlock() && !block->Continuation() && !block->BeingDestroyed() && !block->IsRubyRun() && !block->IsRubyBase(); } void LayoutBlockFlow::RemoveChild(LayoutObject* old_child) { // No need to waste time in merging or removing empty anonymous blocks. // We can just bail out if our document is getting destroyed. if (DocumentBeingDestroyed()) { LayoutBox::RemoveChild(old_child); return; } // If this child is a block, and if our previous and next siblings are // both anonymous blocks with inline content, then we can go ahead and // fold the inline content back together. LayoutObject* prev = old_child->PreviousSibling(); LayoutObject* next = old_child->NextSibling(); bool merged_anonymous_blocks = false; if (prev && next && !old_child->IsInline() && !old_child->VirtualContinuation() && prev->IsLayoutBlockFlow() && next->IsLayoutBlockFlow()) { if (ToLayoutBlockFlow(prev)->MergeSiblingContiguousAnonymousBlock( ToLayoutBlockFlow(next))) { merged_anonymous_blocks = true; next = nullptr; } } LayoutBlock::RemoveChild(old_child); LayoutObject* child = prev ? prev : next; if (child && child->IsLayoutBlockFlow() && !child->PreviousSibling() && !child->NextSibling()) { // If the removal has knocked us down to containing only a single anonymous // box we can go ahead and pull the content right back up into our // box. if (merged_anonymous_blocks || IsMergeableAnonymousBlock(ToLayoutBlockFlow(child))) CollapseAnonymousBlockChild(ToLayoutBlockFlow(child)); } if (!FirstChild()) { // If this was our last child be sure to clear out our line boxes. if (ChildrenInline()) DeleteLineBoxTree(); // If we are an empty anonymous block in the continuation chain, // we need to remove ourself and fix the continuation chain. if (!BeingDestroyed() && IsAnonymousBlockContinuation() && !old_child->IsListMarker()) { LayoutObject* containing_block_ignoring_anonymous = ContainingBlock(); while (containing_block_ignoring_anonymous && containing_block_ignoring_anonymous->IsAnonymous()) containing_block_ignoring_anonymous = containing_block_ignoring_anonymous->ContainingBlock(); for (LayoutObject* curr = this; curr; curr = curr->PreviousInPreOrder(containing_block_ignoring_anonymous)) { if (curr->VirtualContinuation() != this) continue; // Found our previous continuation. We just need to point it to // |this|'s next continuation. LayoutBoxModelObject* next_continuation = Continuation(); if (curr->IsLayoutInline()) ToLayoutInline(curr)->SetContinuation(next_continuation); else if (curr->IsLayoutBlockFlow()) ToLayoutBlockFlow(curr)->SetContinuation(next_continuation); else NOTREACHED(); break; } SetContinuation(nullptr); Destroy(); } } else if (!BeingDestroyed() && !old_child->IsFloatingOrOutOfFlowPositioned() && !old_child->IsAnonymousBlock()) { // If the child we're removing means that we can now treat all children as // inline without the need for anonymous blocks, then do that. MakeChildrenInlineIfPossible(); } } void LayoutBlockFlow::MoveAllChildrenIncludingFloatsTo( LayoutBlock* to_block, bool full_remove_insert) { LayoutBlockFlow* to_block_flow = ToLayoutBlockFlow(to_block); // When a portion of the layout tree is being detached, anonymous blocks // will be combined as their children are deleted. In this process, the // anonymous block later in the tree is merged into the one preceding it. // It can happen that the later block (this) contains floats that the // previous block (toBlockFlow) did not contain, and thus are not in the // floating objects list for toBlockFlow. This can result in toBlockFlow // containing floats that are not in it's floating objects list, but are in // the floating objects lists of siblings and parents. This can cause problems // when the float itself is deleted, since the deletion code assumes that if a // float is not in it's containing block's floating objects list, it isn't in // any floating objects list. In order to preserve this condition (removing it // has serious performance implications), we need to copy the floating objects // from the old block (this) to the new block (toBlockFlow). // The float's metrics will likely all be wrong, but since toBlockFlow is // already marked for layout, this will get fixed before anything gets // displayed. // See bug https://code.google.com/p/chromium/issues/detail?id=230907 if (floating_objects_) { if (!to_block_flow->floating_objects_) to_block_flow->CreateFloatingObjects(); const FloatingObjectSet& from_floating_object_set = floating_objects_->Set(); FloatingObjectSetIterator end = from_floating_object_set.end(); for (FloatingObjectSetIterator it = from_floating_object_set.begin(); it != end; ++it) { const FloatingObject& floating_object = *it->get(); // Don't insert the object again if it's already in the list if (to_block_flow->ContainsFloat(floating_object.GetLayoutObject())) continue; to_block_flow->floating_objects_->Add(floating_object.UnsafeClone()); } } MoveAllChildrenTo(to_block_flow, full_remove_insert); } void LayoutBlockFlow::ChildBecameFloatingOrOutOfFlow(LayoutBox* child) { MakeChildrenInlineIfPossible(); // Reparent the child to an adjacent anonymous block if one is available. LayoutObject* prev = child->PreviousSibling(); if (prev && prev->IsAnonymousBlock() && prev->IsLayoutBlockFlow()) { LayoutBlockFlow* new_container = ToLayoutBlockFlow(prev); MoveChildTo(new_container, child, nullptr, false); // The anonymous block we've moved to may now be adjacent to former siblings // of ours that it can contain also. new_container->ReparentSubsequentFloatingOrOutOfFlowSiblings(); return; } LayoutObject* next = child->NextSibling(); if (next && next->IsAnonymousBlock() && next->IsLayoutBlockFlow()) { LayoutBlockFlow* new_container = ToLayoutBlockFlow(next); MoveChildTo(new_container, child, new_container->FirstChild(), false); } } void LayoutBlockFlow::CollapseAnonymousBlockChild(LayoutBlockFlow* child) { // It's possible that this block's destruction may have been triggered by the // child's removal. Just bail if the anonymous child block is already being // destroyed. See crbug.com/282088 if (child->BeingDestroyed()) return; if (child->Continuation()) return; // Ruby elements use anonymous wrappers for ruby runs and ruby bases by // design, so we don't remove them. if (child->IsRubyRun() || child->IsRubyBase()) return; SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( LayoutInvalidationReason::kChildAnonymousBlockChanged); child->MoveAllChildrenTo(this, child->NextSibling(), child->HasLayer()); // If we make an object's children inline we are going to frustrate any future // attempts to remove floats from its children's float-lists before the next // layout happens so clear down all the floatlists now - they will be rebuilt // at layout. if (child->ChildrenInline()) RemoveFloatingObjectsFromDescendants(); SetChildrenInline(child->ChildrenInline()); Children()->RemoveChildNode(this, child, child->HasLayer()); child->Destroy(); } bool LayoutBlockFlow::MergeSiblingContiguousAnonymousBlock( LayoutBlockFlow* sibling_that_may_be_deleted) { // Note: |this| and |siblingThatMayBeDeleted| may not be adjacent siblings at // this point. There may be an object between them which is about to be // removed. if (!IsMergeableAnonymousBlock(this) || !IsMergeableAnonymousBlock(sibling_that_may_be_deleted)) return false; SetNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( LayoutInvalidationReason::kAnonymousBlockChange); // If the inlineness of children of the two block don't match, we'd need // special code here (but there should be no need for it). DCHECK_EQ(sibling_that_may_be_deleted->ChildrenInline(), ChildrenInline()); // Take all the children out of the |next| block and put them in // the |prev| block. sibling_that_may_be_deleted->MoveAllChildrenIncludingFloatsTo( this, sibling_that_may_be_deleted->HasLayer() || HasLayer()); // Delete the now-empty block's lines and nuke it. sibling_that_may_be_deleted->DeleteLineBoxTree(); sibling_that_may_be_deleted->Destroy(); return true; } void LayoutBlockFlow::ReparentSubsequentFloatingOrOutOfFlowSiblings() { if (!Parent() || !Parent()->IsLayoutBlockFlow()) return; if (BeingDestroyed() || DocumentBeingDestroyed()) return; LayoutBlockFlow* parent_block_flow = ToLayoutBlockFlow(Parent()); LayoutObject* child = NextSibling(); while (child && child->IsFloatingOrOutOfFlowPositioned()) { LayoutObject* sibling = child->NextSibling(); parent_block_flow->MoveChildTo(this, child, nullptr, false); child = sibling; } if (LayoutObject* next = NextSibling()) { if (next->IsLayoutBlockFlow()) MergeSiblingContiguousAnonymousBlock(ToLayoutBlockFlow(next)); } } void LayoutBlockFlow::ReparentPrecedingFloatingOrOutOfFlowSiblings() { if (!Parent() || !Parent()->IsLayoutBlockFlow()) return; if (BeingDestroyed() || DocumentBeingDestroyed()) return; LayoutBlockFlow* parent_block_flow = ToLayoutBlockFlow(Parent()); LayoutObject* child = PreviousSibling(); while (child && child->IsFloatingOrOutOfFlowPositioned()) { LayoutObject* sibling = child->PreviousSibling(); parent_block_flow->MoveChildTo(this, child, FirstChild(), false); child = sibling; } } void LayoutBlockFlow::MakeChildrenInlineIfPossible() { // Collapsing away anonymous wrappers isn't relevant for the children of // anonymous blocks, unless they are ruby bases. if (IsAnonymousBlock() && !IsRubyBase()) return; Vector<LayoutBlockFlow*, 3> blocks_to_remove; for (LayoutObject* child = FirstChild(); child; child = child->NextSibling()) { if (child->IsFloating()) continue; if (child->IsOutOfFlowPositioned()) continue; // There are still block children in the container, so any anonymous // wrappers are still needed. if (!child->IsAnonymousBlock() || !child->IsLayoutBlockFlow()) return; // If one of the children is being destroyed then it is unsafe to clean up // anonymous wrappers as the // entire branch may be being destroyed. if (ToLayoutBlockFlow(child)->BeingDestroyed()) return; // We can't remove anonymous wrappers if they contain continuations as this // means there are block children present. if (ToLayoutBlockFlow(child)->Continuation()) return; // We are only interested in removing anonymous wrappers if there are inline // siblings underneath them. if (!child->ChildrenInline()) return; // Ruby elements use anonymous wrappers for ruby runs and ruby bases by // design, so we don't remove them. if (child->IsRubyRun() || child->IsRubyBase()) return; blocks_to_remove.push_back(ToLayoutBlockFlow(child)); } // If we make an object's children inline we are going to frustrate any future // attempts to remove floats from its children's float-lists before the next // layout happens so clear down all the floatlists now - they will be rebuilt // at layout. RemoveFloatingObjectsFromDescendants(); for (size_t i = 0; i < blocks_to_remove.size(); i++) CollapseAnonymousBlockChild(blocks_to_remove[i]); SetChildrenInline(true); } static void GetInlineRun(LayoutObject* start, LayoutObject* boundary, LayoutObject*& inline_run_start, LayoutObject*& inline_run_end) { // Beginning at |start| we find the largest contiguous run of inlines that // we can. We denote the run with start and end points, |inlineRunStart| // and |inlineRunEnd|. Note that these two values may be the same if // we encounter only one inline. // // We skip any non-inlines we encounter as long as we haven't found any // inlines yet. // // |boundary| indicates a non-inclusive boundary point. Regardless of whether // |boundary| is inline or not, we will not include it in a run with inlines // before it. It's as though we encountered a non-inline. // Start by skipping as many non-inlines as we can. LayoutObject* curr = start; // LayoutNGListMarker is out-of-flow for the tree building purpose. Skip here // because it's the first child. if (curr && curr->IsLayoutNGListMarker()) curr = curr->NextSibling(); bool saw_inline; do { while (curr && !(curr->IsInline() || curr->IsFloatingOrOutOfFlowPositioned())) curr = curr->NextSibling(); inline_run_start = inline_run_end = curr; if (!curr) return; // No more inline children to be found. saw_inline = curr->IsInline(); curr = curr->NextSibling(); while (curr && (curr->IsInline() || curr->IsFloatingOrOutOfFlowPositioned()) && (curr != boundary)) { inline_run_end = curr; if (curr->IsInline()) saw_inline = true; curr = curr->NextSibling(); } } while (!saw_inline); } void LayoutBlockFlow::MakeChildrenNonInline(LayoutObject* insertion_point) { // makeChildrenNonInline takes a block whose children are *all* inline and it // makes sure that inline children are coalesced under anonymous blocks. // If |insertionPoint| is defined, then it represents the insertion point for // the new block child that is causing us to have to wrap all the inlines. // This means that we cannot coalesce inlines before |insertionPoint| with // inlines following |insertionPoint|, because the new child is going to be // inserted in between the inlines, splitting them. DCHECK(!IsInline() || IsAtomicInlineLevel()); DCHECK(!insertion_point || insertion_point->Parent() == this); SetChildrenInline(false); LayoutObject* child = FirstChild(); if (!child) return; DeleteLineBoxTree(); while (child) { LayoutObject* inline_run_start; LayoutObject* inline_run_end; GetInlineRun(child, insertion_point, inline_run_start, inline_run_end); if (!inline_run_start) break; child = inline_run_end->NextSibling(); LayoutBlock* block = CreateAnonymousBlock(); Children()->InsertChildNode(this, block, inline_run_start); MoveChildrenTo(block, inline_run_start, child); } #if DCHECK_IS_ON() for (LayoutObject* c = FirstChild(); c; c = c->NextSibling()) DCHECK(!c->IsInline() || c->IsLayoutNGListMarker()); #endif SetShouldDoFullPaintInvalidation(); } void LayoutBlockFlow::ChildBecameNonInline(LayoutObject*) { MakeChildrenNonInline(); if (IsAnonymousBlock() && Parent() && Parent()->IsLayoutBlock()) ToLayoutBlock(Parent())->RemoveLeftoverAnonymousBlock(this); // |this| may be dead here } void LayoutBlockFlow::ClearFloats(EClear clear) { PlaceNewFloats(LogicalHeight()); // set y position LayoutUnit new_y = LowestFloatLogicalBottom(clear); if (Size().Height() < new_y) SetLogicalHeight(new_y); } bool LayoutBlockFlow::ContainsFloat(LayoutBox* layout_box) const { return floating_objects_ && floating_objects_->Set().Contains<FloatingObjectHashTranslator>( layout_box); } void LayoutBlockFlow::RemoveFloatingObjects() { if (!floating_objects_) return; MarkSiblingsWithFloatsForLayout(); floating_objects_->Clear(); } LayoutPoint LayoutBlockFlow::FlipFloatForWritingModeForChild( const FloatingObject& child, const LayoutPoint& point) const { if (!Style()->IsFlippedBlocksWritingMode()) return point; // This is similar to LayoutBox::flipForWritingModeForChild. We have to // subtract out our left offsets twice, since it's going to get added back in. // We hide this complication here so that the calling code looks normal for // the unflipped case. return LayoutPoint(point.X() + Size().Width() - child.GetLayoutObject()->Size().Width() - 2 * XPositionForFloatIncludingMargin(child), point.Y()); } LayoutUnit LayoutBlockFlow::LogicalLeftOffsetForPositioningFloat( LayoutUnit logical_top, LayoutUnit fixed_offset, LayoutUnit* height_remaining) const { LayoutUnit offset = fixed_offset; if (floating_objects_ && floating_objects_->HasLeftObjects()) offset = floating_objects_->LogicalLeftOffsetForPositioningFloat( fixed_offset, logical_top, height_remaining); return AdjustLogicalLeftOffsetForLine(offset, kDoNotIndentText); } LayoutUnit LayoutBlockFlow::LogicalRightOffsetForPositioningFloat( LayoutUnit logical_top, LayoutUnit fixed_offset, LayoutUnit* height_remaining) const { LayoutUnit offset = fixed_offset; if (floating_objects_ && floating_objects_->HasRightObjects()) offset = floating_objects_->LogicalRightOffsetForPositioningFloat( fixed_offset, logical_top, height_remaining); return AdjustLogicalRightOffsetForLine(offset, kDoNotIndentText); } LayoutUnit LayoutBlockFlow::AdjustLogicalLeftOffsetForLine( LayoutUnit offset_from_floats, IndentTextOrNot apply_text_indent) const { LayoutUnit left = offset_from_floats; if (apply_text_indent == kIndentText && Style()->IsLeftToRightDirection()) left += TextIndentOffset(); return left; } LayoutUnit LayoutBlockFlow::AdjustLogicalRightOffsetForLine( LayoutUnit offset_from_floats, IndentTextOrNot apply_text_indent) const { LayoutUnit right = offset_from_floats; if (apply_text_indent == kIndentText && !Style()->IsLeftToRightDirection()) right -= TextIndentOffset(); return right; } LayoutPoint LayoutBlockFlow::ComputeLogicalLocationForFloat( const FloatingObject& floating_object, LayoutUnit logical_top_offset) const { LayoutBox* child_box = floating_object.GetLayoutObject(); LayoutUnit logical_left_offset = LogicalLeftOffsetForContent(); // Constant part of left offset. LayoutUnit logical_right_offset; // Constant part of right offset. logical_right_offset = LogicalRightOffsetForContent(); LayoutUnit float_logical_width = std::min( LogicalWidthForFloat(floating_object), logical_right_offset - logical_left_offset); // The width we look for. LayoutUnit float_logical_left; if (child_box->Style()->Floating() == EFloat::kLeft) { LayoutUnit height_remaining_left = LayoutUnit(1); LayoutUnit height_remaining_right = LayoutUnit(1); float_logical_left = LogicalLeftOffsetForPositioningFloat( logical_top_offset, logical_left_offset, &height_remaining_left); while (LogicalRightOffsetForPositioningFloat(logical_top_offset, logical_right_offset, &height_remaining_right) - float_logical_left < float_logical_width) { logical_top_offset += std::min<LayoutUnit>(height_remaining_left, height_remaining_right); float_logical_left = LogicalLeftOffsetForPositioningFloat( logical_top_offset, logical_left_offset, &height_remaining_left); } float_logical_left = std::max(logical_left_offset - BorderAndPaddingLogicalLeft(), float_logical_left); } else { LayoutUnit height_remaining_left = LayoutUnit(1); LayoutUnit height_remaining_right = LayoutUnit(1); float_logical_left = LogicalRightOffsetForPositioningFloat( logical_top_offset, logical_right_offset, &height_remaining_right); while (float_logical_left - LogicalLeftOffsetForPositioningFloat( logical_top_offset, logical_left_offset, &height_remaining_left) < float_logical_width) { logical_top_offset += std::min(height_remaining_left, height_remaining_right); float_logical_left = LogicalRightOffsetForPositioningFloat( logical_top_offset, logical_right_offset, &height_remaining_right); } // Use the original width of the float here, since the local variable // |floatLogicalWidth| was capped to the available line width. See // fast/block/float/clamped-right-float.html. float_logical_left -= LogicalWidthForFloat(floating_object); } return LayoutPoint(float_logical_left, logical_top_offset); } FloatingObject* LayoutBlockFlow::InsertFloatingObject(LayoutBox& float_box) { DCHECK(float_box.IsFloating()); // Create the list of special objects if we don't aleady have one if (!floating_objects_) { CreateFloatingObjects(); } else { // Don't insert the object again if it's already in the list const FloatingObjectSet& floating_object_set = floating_objects_->Set(); FloatingObjectSetIterator it = floating_object_set.Find<FloatingObjectHashTranslator>(&float_box); if (it != floating_object_set.end()) return it->get(); } // Create the special object entry & append it to the list std::unique_ptr<FloatingObject> new_obj = FloatingObject::Create(&float_box); return floating_objects_->Add(std::move(new_obj)); } void LayoutBlockFlow::RemoveFloatingObject(LayoutBox* float_box) { if (floating_objects_) { const FloatingObjectSet& floating_object_set = floating_objects_->Set(); FloatingObjectSetIterator it = floating_object_set.Find<FloatingObjectHashTranslator>(float_box); if (it != floating_object_set.end()) { FloatingObject& floating_object = *it->get(); if (ChildrenInline()) { LayoutUnit logical_top = LogicalTopForFloat(floating_object); LayoutUnit logical_bottom = LogicalBottomForFloat(floating_object); // Fix for https://bugs.webkit.org/show_bug.cgi?id=54995. if (logical_bottom < 0 || logical_bottom < logical_top || logical_top == LayoutUnit::Max()) { logical_bottom = LayoutUnit::Max(); } else { // Special-case zero- and less-than-zero-height floats: those don't // touch the line that they're on, but it still needs to be dirtied. // This is accomplished by pretending they have a height of 1. logical_bottom = std::max(logical_bottom, logical_top + 1); } if (floating_object.OriginatingLine()) { if (!SelfNeedsLayout()) { DCHECK( floating_object.OriginatingLine()->GetLineLayoutItem().IsEqual( this)); floating_object.OriginatingLine()->MarkDirty(); } #if DCHECK_IS_ON() floating_object.SetOriginatingLine(nullptr); #endif } MarkLinesDirtyInBlockRange(LayoutUnit(), logical_bottom); } floating_objects_->Remove(&floating_object); } } } void LayoutBlockFlow::RemoveFloatingObjectsBelow(FloatingObject* last_float, LayoutUnit logical_offset) { if (!ContainsFloats()) return; const FloatingObjectSet& floating_object_set = floating_objects_->Set(); FloatingObject* curr = floating_object_set.back().get(); while (curr != last_float && (!curr->IsPlaced() || LogicalTopForFloat(*curr) >= logical_offset)) { floating_objects_->Remove(curr); if (floating_object_set.IsEmpty()) break; curr = floating_object_set.back().get(); } } bool LayoutBlockFlow::PlaceNewFloats(LayoutUnit logical_top_margin_edge, LineWidth* width) { if (!floating_objects_) return false; const FloatingObjectSet& floating_object_set = floating_objects_->Set(); if (floating_object_set.IsEmpty()) return false; // If all floats have already been positioned, then we have no work to do. if (floating_object_set.back()->IsPlaced()) return false; // Move backwards through our floating object list until we find a float that // has already been positioned. Then we'll be able to move forward, // positioning all of the new floats that need it. FloatingObjectSetIterator it = floating_object_set.end(); --it; // Go to last item. FloatingObjectSetIterator begin = floating_object_set.begin(); FloatingObject* last_placed_floating_object = nullptr; while (it != begin) { --it; if ((*it)->IsPlaced()) { last_placed_floating_object = it->get(); ++it; break; } } // The float cannot start above the top position of the last positioned float. if (last_placed_floating_object) { logical_top_margin_edge = std::max(logical_top_margin_edge, LogicalTopForFloat(*last_placed_floating_object)); } FloatingObjectSetIterator end = floating_object_set.end(); // Now walk through the set of unpositioned floats and place them. for (; it != end; ++it) { FloatingObject& floating_object = *it->get(); // The containing block is responsible for positioning floats, so if we have // unplaced floats in our list that come from somewhere else, we have a bug. DCHECK_EQ(floating_object.GetLayoutObject()->ContainingBlock(), this); logical_top_margin_edge = PositionAndLayoutFloat(floating_object, logical_top_margin_edge); floating_objects_->AddPlacedObject(floating_object); if (width) width->ShrinkAvailableWidthForNewFloatIfNeeded(floating_object); } return true; } LayoutUnit LayoutBlockFlow::PositionAndLayoutFloat( FloatingObject& floating_object, LayoutUnit logical_top_margin_edge) { // Once a float has been placed, we cannot update its position, or the float // interval tree will be out of sync with reality. This may in turn lead to // objects being used after they have been deleted. CHECK(!floating_object.IsPlaced()); LayoutBox& child = *floating_object.GetLayoutObject(); // FIXME Investigate if this can be removed. crbug.com/370006 child.SetMayNeedPaintInvalidation(); logical_top_margin_edge = std::max(logical_top_margin_edge, LowestFloatLogicalBottom(child.Style()->Clear())); bool is_paginated = View()->GetLayoutState()->IsPaginated(); if (is_paginated && !ChildrenInline()) { // Forced breaks are inserted at class A break points. Floats may be // affected by a break-after value on the previous in-flow sibling. if (LayoutBox* previous_in_flow_box = child.PreviousInFlowSiblingBox()) { logical_top_margin_edge = ApplyForcedBreak( logical_top_margin_edge, previous_in_flow_box->BreakAfter()); } } LayoutUnit old_logical_top = child.LogicalTop(); if (child.NeedsLayout()) { if (is_paginated) { // Before we can lay out the float, we need to estimate a position for // it. In order to do that, we first need to know its block start margin. child.ComputeAndSetBlockDirectionMargins(this); LayoutUnit margin_before = MarginBeforeForChild(child); // We have found the highest possible position for the float, so we'll // lay out right there. Later on, we may be pushed further down by // adjacent floats which we don't fit beside, or pushed by fragmentation // if we need to break before the top margin edge of the float. SetLogicalTopForChild(child, logical_top_margin_edge + margin_before); child.UpdateLayout(); // May need to push the float to the next fragmentainer before attempting // to place it. logical_top_margin_edge = AdjustFloatLogicalTopForPagination(child, logical_top_margin_edge); } else { child.UpdateLayout(); } } LayoutUnit margin_start = MarginStartForChild(child); LayoutUnit margin_end = MarginEndForChild(child); SetLogicalWidthForFloat( floating_object, LogicalWidthForChild(child) + margin_start + margin_end); // We have determined the logical width of the float. This is enough // information to fit it among other floats according to float positioning // rules. Note that logical *height* doesn't really matter yet (until we're // going to place subsequent floats or other objects that are affected by // floats), since no float may be positioned above the outer logical top edge // of any other earlier float in the block formatting context. LayoutUnit margin_before = MarginBeforeForChild(child); LayoutUnit margin_after = MarginAfterForChild(child); LayoutPoint float_logical_location = ComputeLogicalLocationForFloat(floating_object, logical_top_margin_edge); logical_top_margin_edge = float_logical_location.Y(); SetLogicalTopForChild(child, logical_top_margin_edge + margin_before); SubtreeLayoutScope layout_scope(child); // A new position may mean that we need to insert, move or remove breaks // inside the float. We may also need to lay out if we just ceased to be // fragmented, in order to remove pagination struts inside the child. MarkChildForPaginationRelayoutIfNeeded(child, layout_scope); child.LayoutIfNeeded(); // If negative margin pushes the child completely out of its old position // mark for layout siblings that may have it in its float lists. if (child.LogicalBottom() <= old_logical_top) { LayoutObject* next = child.NextSibling(); if (next && next->IsLayoutBlockFlow()) { LayoutBlockFlow* nextBlock = ToLayoutBlockFlow(next); if (!nextBlock->AvoidsFloats() || nextBlock->ShrinkToAvoidFloats()) nextBlock->MarkAllDescendantsWithFloatsForLayout(); } } if (is_paginated) { PaginatedContentWasLaidOut(child.LogicalBottom()); // We may have to insert a break before the float. LayoutUnit new_logical_top_margin_edge = AdjustFloatLogicalTopForPagination(child, logical_top_margin_edge); if (logical_top_margin_edge != new_logical_top_margin_edge) { // We had already found a location for the float, but a soft // fragmentainer break then made us push it further down. This may affect // the inline position of the float (since we may no longer be beside the // same floats anymore). Block position will remain unaffected, though. float_logical_location = ComputeLogicalLocationForFloat( floating_object, new_logical_top_margin_edge); DCHECK_EQ(float_logical_location.Y(), new_logical_top_margin_edge); logical_top_margin_edge = new_logical_top_margin_edge; SetLogicalTopForChild(child, logical_top_margin_edge + margin_before); // Pushing the child to the next fragmentainer most likely means that we // need to recalculate pagination struts inside it. if (child.IsLayoutBlock()) child.SetChildNeedsLayout(kMarkOnlyThis); child.LayoutIfNeeded(); PaginatedContentWasLaidOut(child.LogicalBottom()); } } LayoutUnit child_logical_left_margin = Style()->IsLeftToRightDirection() ? margin_start : margin_end; SetLogicalLeftForChild( child, float_logical_location.X() + child_logical_left_margin); SetLogicalLeftForFloat(floating_object, float_logical_location.X()); SetLogicalTopForFloat(floating_object, logical_top_margin_edge); SetLogicalHeightForFloat(floating_object, LogicalHeightForChild(child) + margin_before + margin_after); if (ShapeOutsideInfo* shape_outside = child.GetShapeOutsideInfo()) shape_outside->SetReferenceBoxLogicalSize(LogicalSizeForChild(child)); return logical_top_margin_edge; } bool LayoutBlockFlow::HasOverhangingFloat(LayoutBox* layout_box) { if (!floating_objects_ || !Parent()) return false; const FloatingObjectSet& floating_object_set = floating_objects_->Set(); FloatingObjectSetIterator it = floating_object_set.Find<FloatingObjectHashTranslator>(layout_box); if (it == floating_object_set.end()) return false; return IsOverhangingFloat(**it); } void LayoutBlockFlow::AddIntrudingFloats(LayoutBlockFlow* prev, LayoutUnit logical_left_offset, LayoutUnit logical_top_offset) { DCHECK(!AvoidsFloats()); // If we create our own block formatting context then our contents don't // interact with floats outside it, even those from our parent. if (CreatesNewFormattingContext()) return; // If the parent or previous sibling doesn't have any floats to add, don't // bother. if (!prev->floating_objects_) return; logical_left_offset += MarginLineLeft(); const FloatingObjectSet& prev_set = prev->floating_objects_->Set(); FloatingObjectSetIterator prev_end = prev_set.end(); for (FloatingObjectSetIterator prev_it = prev_set.begin(); prev_it != prev_end; ++prev_it) { FloatingObject& floating_object = *prev_it->get(); if (LogicalBottomForFloat(floating_object) > logical_top_offset) { if (!floating_objects_ || !floating_objects_->Set().Contains(&floating_object)) { // We create the floating object list lazily. if (!floating_objects_) CreateFloatingObjects(); // Applying the child's margin makes no sense in the case where the // child was passed in since this margin was added already through the // modification of the |logicalLeftOffset| variable above. // |logicalLeftOffset| will equal the margin in this case, so it's // already been taken into account. Only apply this code if prev is the // parent, since otherwise the left margin will get applied twice. LayoutSize offset = IsHorizontalWritingMode() ? LayoutSize(logical_left_offset - (prev != Parent() ? prev->MarginLeft() : LayoutUnit()), logical_top_offset) : LayoutSize(logical_top_offset, logical_left_offset - (prev != Parent() ? prev->MarginTop() : LayoutUnit())); floating_objects_->Add(floating_object.CopyToNewContainer(offset)); } } } } void LayoutBlockFlow::AddOverhangingFloats(LayoutBlockFlow* child, bool make_child_paint_other_floats) { // Prevent floats from being added to the canvas by the root element, e.g., // <html>. if (!child->ContainsFloats() || child->CreatesNewFormattingContext()) return; LayoutUnit child_logical_top = child->LogicalTop(); LayoutUnit child_logical_left = child->LogicalLeft(); // Floats that will remain the child's responsibility to paint should factor // into its overflow. FloatingObjectSetIterator child_end = child->floating_objects_->Set().end(); for (FloatingObjectSetIterator child_it = child->floating_objects_->Set().begin(); child_it != child_end; ++child_it) { FloatingObject& floating_object = *child_it->get(); LayoutUnit logical_bottom_for_float = std::min(LogicalBottomForFloat(floating_object), LayoutUnit::Max() - child_logical_top); LayoutUnit logical_bottom = child_logical_top + logical_bottom_for_float; if (logical_bottom > LogicalHeight()) { // If the object is not in the list, we add it now. if (!ContainsFloat(floating_object.GetLayoutObject())) { LayoutSize offset = IsHorizontalWritingMode() ? LayoutSize(-child_logical_left, -child_logical_top) : LayoutSize(-child_logical_top, -child_logical_left); bool should_paint = false; // The nearest enclosing layer always paints the float (so that zindex // and stacking behaves properly). We always want to propagate the // desire to paint the float as far out as we can, to the outermost // block that overlaps the float, stopping only if we hit a // self-painting layer boundary. if (floating_object.GetLayoutObject()->EnclosingFloatPaintingLayer() == EnclosingFloatPaintingLayer() && !floating_object.IsLowestNonOverhangingFloatInChild()) { floating_object.SetShouldPaint(false); should_paint = true; } // We create the floating object list lazily. if (!floating_objects_) CreateFloatingObjects(); floating_objects_->Add( floating_object.CopyToNewContainer(offset, should_paint, true)); } } else { if (make_child_paint_other_floats && !floating_object.ShouldPaint() && !floating_object.GetLayoutObject()->HasSelfPaintingLayer() && !floating_object.IsLowestNonOverhangingFloatInChild() && floating_object.GetLayoutObject()->IsDescendantOf(child) && floating_object.GetLayoutObject()->EnclosingFloatPaintingLayer() == child->EnclosingFloatPaintingLayer()) { // The float is not overhanging from this block, so if it is a // descendant of the child, the child should paint it (the other case is // that it is intruding into the child), unless it has its own layer or // enclosing layer. // If makeChildPaintOtherFloats is false, it means that the child must // already know about all the floats it should paint. floating_object.SetShouldPaint(true); } // Since the float doesn't overhang, it didn't get put into our list. We // need to go ahead and add its overflow in to the child now. if (floating_object.IsDescendant()) child->AddOverflowFromChild( *floating_object.GetLayoutObject(), LayoutSize(XPositionForFloatIncludingMargin(floating_object), YPositionForFloatIncludingMargin(floating_object))); } } } LayoutUnit LayoutBlockFlow::LowestFloatLogicalBottom(EClear clear) const { if (clear == EClear::kNone || !floating_objects_) return LayoutUnit(); FloatingObject::Type float_type = clear == EClear::kLeft ? FloatingObject::kFloatLeft : clear == EClear::kRight ? FloatingObject::kFloatRight : FloatingObject::kFloatLeftRight; return floating_objects_->LowestFloatLogicalBottom(float_type); } LayoutUnit LayoutBlockFlow::NextFloatLogicalBottomBelow( LayoutUnit logical_height) const { if (!floating_objects_) return logical_height; return floating_objects_->FindNextFloatLogicalBottomBelow(logical_height); } LayoutUnit LayoutBlockFlow::NextFloatLogicalBottomBelowForBlock( LayoutUnit logical_height) const { if (!floating_objects_) return logical_height; return floating_objects_->FindNextFloatLogicalBottomBelowForBlock( logical_height); } LayoutUnit LayoutBlockFlow::LogicalHeightWithVisibleOverflow() const { LayoutUnit logical_height = LayoutBlock::LogicalHeightWithVisibleOverflow(); return std::max(logical_height, LowestFloatLogicalBottom()); } Node* LayoutBlockFlow::NodeForHitTest() const { // If we are in the margins of block elements that are part of a // continuation we're actually still inside the enclosing element // that was split. Use the appropriate inner node. return IsAnonymousBlockContinuation() ? Continuation()->NodeForHitTest() : LayoutBlock::NodeForHitTest(); } bool LayoutBlockFlow::HitTestChildren( HitTestResult& result, const HitTestLocation& location_in_container, const LayoutPoint& accumulated_offset, HitTestAction hit_test_action) { LayoutPoint scrolled_offset(HasOverflowClip() ? accumulated_offset - ScrolledContentOffset() : accumulated_offset); if (hit_test_action == kHitTestFloat && HitTestFloats(result, location_in_container, scrolled_offset)) return true; if (ChildrenInline()) { if (line_boxes_.HitTest(LineLayoutBoxModel(this), result, location_in_container, scrolled_offset, hit_test_action)) { UpdateHitTestResult( result, FlipForWritingMode(ToLayoutPoint( location_in_container.Point() - accumulated_offset))); return true; } } else if (LayoutBlock::HitTestChildren(result, location_in_container, accumulated_offset, hit_test_action)) { return true; } return false; } bool LayoutBlockFlow::HitTestFloats( HitTestResult& result, const HitTestLocation& location_in_container, const LayoutPoint& accumulated_offset) { if (!floating_objects_) return false; LayoutPoint adjusted_location = accumulated_offset; if (IsLayoutView()) { ScrollOffset offset = ToLayoutView(this)->GetFrameView()->GetScrollOffset(); adjusted_location.Move(LayoutSize(offset)); } const FloatingObjectSet& floating_object_set = floating_objects_->Set(); FloatingObjectSetIterator begin = floating_object_set.begin(); for (FloatingObjectSetIterator it = floating_object_set.end(); it != begin;) { --it; const FloatingObject& floating_object = *it->get(); if (floating_object.ShouldPaint() && // TODO(wangxianzhu): Should this be a DCHECK? !floating_object.GetLayoutObject()->HasSelfPaintingLayer()) { LayoutUnit x_offset = XPositionForFloatIncludingMargin(floating_object) - floating_object.GetLayoutObject()->Location().X(); LayoutUnit y_offset = YPositionForFloatIncludingMargin(floating_object) - floating_object.GetLayoutObject()->Location().Y(); LayoutPoint child_point = FlipFloatForWritingModeForChild( floating_object, adjusted_location + LayoutSize(x_offset, y_offset)); if (floating_object.GetLayoutObject()->HitTestAllPhases( result, location_in_container, child_point)) { UpdateHitTestResult( result, location_in_container.Point() - ToLayoutSize(child_point)); return true; } } } return false; } LayoutSize LayoutBlockFlow::AccumulateInFlowPositionOffsets() const { if (!IsAnonymousBlock() || !IsInFlowPositioned()) return LayoutSize(); LayoutSize offset; for (const LayoutObject* p = InlineElementContinuation(); p && p->IsLayoutInline(); p = p->Parent()) { if (p->IsInFlowPositioned()) offset += ToLayoutInline(p)->OffsetForInFlowPosition(); } return offset; } LayoutUnit LayoutBlockFlow::LogicalLeftFloatOffsetForLine( LayoutUnit logical_top, LayoutUnit fixed_offset, LayoutUnit logical_height) const { if (floating_objects_ && floating_objects_->HasLeftObjects()) return floating_objects_->LogicalLeftOffset(fixed_offset, logical_top, logical_height); return fixed_offset; } LayoutUnit LayoutBlockFlow::LogicalRightFloatOffsetForLine( LayoutUnit logical_top, LayoutUnit fixed_offset, LayoutUnit logical_height) const { if (floating_objects_ && floating_objects_->HasRightObjects()) return floating_objects_->LogicalRightOffset(fixed_offset, logical_top, logical_height); return fixed_offset; } LayoutUnit LayoutBlockFlow::LogicalLeftFloatOffsetForAvoidingFloats( LayoutUnit logical_top, LayoutUnit fixed_offset, LayoutUnit logical_height) const { if (floating_objects_ && floating_objects_->HasLeftObjects()) { return floating_objects_->LogicalLeftOffsetForAvoidingFloats( fixed_offset, logical_top, logical_height); } return fixed_offset; } LayoutUnit LayoutBlockFlow::LogicalRightFloatOffsetForAvoidingFloats( LayoutUnit logical_top, LayoutUnit fixed_offset, LayoutUnit logical_height) const { if (floating_objects_ && floating_objects_->HasRightObjects()) { return floating_objects_->LogicalRightOffsetForAvoidingFloats( fixed_offset, logical_top, logical_height); } return fixed_offset; } void LayoutBlockFlow::UpdateAncestorShouldPaintFloatingObject( const LayoutBox& float_box) { // Normally, the ShouldPaint flags of FloatingObjects should have been set // during layout, based on overhaning, intruding, self-painting status, etc. // However, sometimes a layer's self painting status is affected by its // compositing status, so we need to call this method during compositing // update when we find a layer changes self painting status. This doesn't // apply to SPv2 in which a layer's self painting status no longer depends on // compositing status. DCHECK(!RuntimeEnabledFeatures::SlimmingPaintV2Enabled()); DCHECK(float_box.IsFloating()); bool float_box_is_self_painting_layer = float_box.HasLayer() && float_box.Layer()->IsSelfPaintingLayer(); bool found_painting_ancestor = false; for (LayoutObject* ancestor = float_box.Parent(); ancestor && ancestor->IsLayoutBlockFlow(); ancestor = ancestor->Parent()) { LayoutBlockFlow* ancestor_block = ToLayoutBlockFlow(ancestor); FloatingObjects* ancestor_floating_objects = ancestor_block->floating_objects_.get(); if (!ancestor_floating_objects) break; FloatingObjectSet::iterator it = ancestor_floating_objects->MutableSet() .Find<FloatingObjectHashTranslator>( const_cast<LayoutBox*>(&float_box)); if (it == ancestor_floating_objects->MutableSet().end()) break; FloatingObject& floating_object = **it; if (!found_painting_ancestor && !float_box_is_self_painting_layer) { // This tries to repeat the logic in AddOverhangingFloats() about // ShouldPaint flag with the following rules: // - The nearest enclosing block in which the float doesn't overhang // paints the float; // - Or even if the float overhangs, if the ancestor block has // self-painting layer, it paints the float. // However it is not fully consistent with AddOverhangingFloats() when // a float doesn't overhang in an ancestor but overhangs in an ancestor // of the ancestor. This results different ancestor painting the float, // but there seems no problem for now. if (ancestor_block->HasSelfPaintingLayer() || !ancestor_block->IsOverhangingFloat(floating_object)) { floating_object.SetShouldPaint(true); found_painting_ancestor = true; } } else { floating_object.SetShouldPaint(false); } } } bool LayoutBlockFlow::AllowsPaginationStrut() const { // The block needs to be contained by a LayoutBlockFlow (and not by e.g. a // flexbox, grid, or a table (the latter being the case for table cell or // table caption)). The reason for this limitation is simply that // LayoutBlockFlow child layout code is the only place where we pick up the // struts and handle them. We handle floats and regular in-flow children, and // that's all. We could handle this in other layout modes as well (and even // for out-of-flow children), but currently we don't. // TODO(mstensho): But we *should*. if (IsOutOfFlowPositioned()) return false; if (IsLayoutFlowThread()) { // Don't let the strut escape the fragmentation context and get lost. // TODO(mstensho): If we're in a nested fragmentation context, we should // ideally convert and propagate the strut to the outer fragmentation // context, so that the inner one is fully pushed to the next outer // fragmentainer, instead of taking up unusable space in the previous one. // But currently we have no mechanism in place to handle this. return false; } const LayoutBlock* containing_block = ContainingBlock(); if (!containing_block || !containing_block->IsLayoutBlockFlow()) return false; const LayoutBlockFlow* containing_block_flow = ToLayoutBlockFlow(containing_block); // If children are inline, allow the strut. We are probably a float. if (containing_block_flow->ChildrenInline()) return true; for (LayoutBox* sibling = PreviousSiblingBox(); sibling; sibling = sibling->PreviousSiblingBox()) { // What happens on the other side of a spanner is none of our concern, so // stop here. Since there's no in-flow box between the previous spanner and // us, there's no class A break point in front of us. We cannot even // re-propagate pagination struts to our containing block, since the // containing block starts in a different column row. if (sibling->IsColumnSpanAll()) return false; // If this isn't the first in-flow object, there's a break opportunity // before us, which means that we can allow the strut. if (!sibling->IsFloatingOrOutOfFlowPositioned()) return true; } // This is a first in-flow child. We'll still allow the strut if it can be // re-propagated to our containing block. return containing_block_flow->AllowsPaginationStrut(); } void LayoutBlockFlow::SetPaginationStrutPropagatedFromChild(LayoutUnit strut) { strut = std::max(strut, LayoutUnit()); if (!rare_data_) { if (!strut) return; rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this); } rare_data_->pagination_strut_propagated_from_child_ = strut; } void LayoutBlockFlow::SetFirstForcedBreakOffset(LayoutUnit block_offset) { if (!rare_data_) { if (!block_offset) return; rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this); } rare_data_->first_forced_break_offset_ = block_offset; } void LayoutBlockFlow::PositionSpannerDescendant( LayoutMultiColumnSpannerPlaceholder& child) { LayoutBox& spanner = *child.LayoutObjectInFlowThread(); // FIXME: |spanner| is a descendant, but never a direct child, so the names // here are bad, if nothing else. SetLogicalTopForChild(spanner, child.LogicalTop()); DetermineLogicalLeftPositionForChild(spanner); } DISABLE_CFI_PERF bool LayoutBlockFlow::CreatesNewFormattingContext() const { if (IsInline() || IsFloatingOrOutOfFlowPositioned() || HasOverflowClip() || IsFlexItemIncludingDeprecated() || IsTableCell() || IsTableCaption() || IsFieldset() || IsCustomItem() || IsDocumentElement() || IsGridItem() || IsWritingModeRoot() || Style()->Display() == EDisplay::kFlowRoot || Style()->ContainsPaint() || Style()->ContainsLayout() || Style()->SpecifiesColumns() || Style()->GetColumnSpan() == EColumnSpan::kAll) { // The specs require this object to establish a new formatting context. return true; } // The remaining checks here are not covered by any spec, but we still need to // establish new formatting contexts in some cases, for various reasons. if (IsRubyText()) { // Ruby text objects are pushed around after layout, to become flush with // the associated ruby base. As such, we cannot let floats leak out from // ruby text objects. return true; } if (IsLayoutFlowThread()) { // The spec requires multicol containers to establish new formatting // contexts. Blink uses an anonymous flow thread child of the multicol // container to actually perform layout inside. Therefore we need to // propagate the BFCness down to the flow thread, so that floats are fully // contained by the flow thread, and thereby the multicol container. return true; } if (IsRenderedLegend()) return true; if (IsTextControl()) { // INPUT and other replaced elements rendered by Blink itself should be // completely contained. return true; } if (IsSVGForeignObject()) { // This is the root of a foreign object. Don't let anything inside it escape // to our ancestors. return true; } // NGBlockNode cannot compute margin collapsing across NG/non-NG boundary. // Create a new formatting context for non-NG node to prevent margin // collapsing. if (RuntimeEnabledFeatures::LayoutNGEnabled()) { if (Node* node = GetNode()) { if (node->IsElementNode() && ToElement(*node).ShouldForceLegacyLayout()) return true; } return StyleRef().UserModify() != EUserModify::kReadOnly; } return false; } bool LayoutBlockFlow::AvoidsFloats() const { return ShouldBeConsideredAsReplaced() || CreatesNewFormattingContext(); } void LayoutBlockFlow::MoveChildrenTo(LayoutBoxModelObject* to_box_model_object, LayoutObject* start_child, LayoutObject* end_child, LayoutObject* before_child, bool full_remove_insert) { if (ChildrenInline()) DeleteLineBoxTree(); LayoutBoxModelObject::MoveChildrenTo(to_box_model_object, start_child, end_child, before_child, full_remove_insert); } LayoutUnit LayoutBlockFlow::LogicalLeftSelectionOffset( const LayoutBlock* root_block, LayoutUnit position) const { LayoutUnit logical_left = LogicalLeftOffsetForLine(position, kDoNotIndentText); if (logical_left == LogicalLeftOffsetForContent()) return LayoutBlock::LogicalLeftSelectionOffset(root_block, position); const LayoutBlock* cb = this; while (cb != root_block) { logical_left += cb->LogicalLeft(); cb = cb->ContainingBlock(); } return logical_left; } LayoutUnit LayoutBlockFlow::LogicalRightSelectionOffset( const LayoutBlock* root_block, LayoutUnit position) const { LayoutUnit logical_right = LogicalRightOffsetForLine(position, kDoNotIndentText); if (logical_right == LogicalRightOffsetForContent()) return LayoutBlock::LogicalRightSelectionOffset(root_block, position); const LayoutBlock* cb = this; while (cb != root_block) { logical_right += cb->LogicalLeft(); cb = cb->ContainingBlock(); } return logical_right; } RootInlineBox* LayoutBlockFlow::CreateRootInlineBox() { return new RootInlineBox(LineLayoutItem(this)); } bool LayoutBlockFlow::IsPagedOverflow(const ComputedStyle& style) { return style.IsOverflowPaged() && GetNode() != GetDocument().ViewportDefiningElement(); } LayoutBlockFlow::FlowThreadType LayoutBlockFlow::GetFlowThreadType( const ComputedStyle& style) { if (IsPagedOverflow(style)) return kPagedFlowThread; if (style.SpecifiesColumns()) return kMultiColumnFlowThread; return kNoFlowThread; } LayoutMultiColumnFlowThread* LayoutBlockFlow::CreateMultiColumnFlowThread( FlowThreadType type) { switch (type) { case kMultiColumnFlowThread: return LayoutMultiColumnFlowThread::CreateAnonymous(GetDocument(), StyleRef()); case kPagedFlowThread: // Paged overflow is currently done using the multicol implementation. UseCounter::Count(GetDocument(), WebFeature::kCSSOverflowPaged); return LayoutPagedFlowThread::CreateAnonymous(GetDocument(), StyleRef()); default: NOTREACHED(); return nullptr; } } void LayoutBlockFlow::CreateOrDestroyMultiColumnFlowThreadIfNeeded( const ComputedStyle* old_style) { // Paged overflow trumps multicol in this implementation. Ideally, it should // be possible to have both paged overflow and multicol on the same element, // but then we need two flow threads. Anyway, this is nothing to worry about // until we can actually nest multicol properly inside other fragmentation // contexts. FlowThreadType type = GetFlowThreadType(StyleRef()); if (MultiColumnFlowThread()) { DCHECK(old_style); if (type != GetFlowThreadType(*old_style)) { // If we're no longer to be multicol/paged, destroy the flow thread. Also // destroy it when switching between multicol and paged, since that // affects the column set structure (multicol containers may have // spanners, paged containers may not). MultiColumnFlowThread()->EvacuateAndDestroy(); DCHECK(!MultiColumnFlowThread()); pagination_state_changed_ = true; } } if (type == kNoFlowThread || MultiColumnFlowThread()) return; // Ruby elements manage child insertion in a special way, and would mess up // insertion of the flow thread. The flow thread needs to be a direct child of // the multicol block (|this|). if (IsRuby()) return; // Fieldsets look for a legend special child (layoutSpecialExcludedChild()). // We currently only support one special child per layout object, and the // flow thread would make for a second one. if (IsFieldset()) return; // Form controls are replaced content, and are therefore not supposed to // support multicol. if (IsFileUploadControl() || IsTextControl() || IsListBox()) return; LayoutMultiColumnFlowThread* flow_thread = CreateMultiColumnFlowThread(type); AddChild(flow_thread); pagination_state_changed_ = true; // Check that addChild() put the flow thread as a direct child, and didn't do // fancy things. DCHECK_EQ(flow_thread->Parent(), this); flow_thread->Populate(); LayoutBlockFlowRareData& rare_data = EnsureRareData(); DCHECK(!rare_data.multi_column_flow_thread_); rare_data.multi_column_flow_thread_ = flow_thread; } LayoutBlockFlow::LayoutBlockFlowRareData& LayoutBlockFlow::EnsureRareData() { if (rare_data_) return *rare_data_; rare_data_ = std::make_unique<LayoutBlockFlowRareData>(this); return *rare_data_; } void LayoutBlockFlow::PositionDialog() { HTMLDialogElement* dialog = ToHTMLDialogElement(GetNode()); if (dialog->GetCenteringMode() == HTMLDialogElement::kNotCentered) return; bool can_center_dialog = (Style()->GetPosition() == EPosition::kAbsolute || Style()->GetPosition() == EPosition::kFixed) && Style()->HasAutoTopAndBottom(); if (dialog->GetCenteringMode() == HTMLDialogElement::kCentered) { if (can_center_dialog) SetY(dialog->CenteredPosition()); return; } DCHECK_EQ(dialog->GetCenteringMode(), HTMLDialogElement::kNeedsCentering); if (!can_center_dialog) { dialog->SetNotCentered(); return; } auto* scrollable_area = GetDocument().View()->LayoutViewportScrollableArea(); LayoutUnit top = LayoutUnit((Style()->GetPosition() == EPosition::kFixed) ? 0 : scrollable_area->ScrollOffsetInt().Height()); int visible_height = GetDocument().View()->Height(); if (Size().Height() < visible_height) top += (visible_height - Size().Height()) / 2; SetY(top); dialog->SetCentered(top); } void LayoutBlockFlow::SimplifiedNormalFlowInlineLayout() { DCHECK(ChildrenInline()); ListHashSet<RootInlineBox*> line_boxes; for (InlineWalker walker(LineLayoutBlockFlow(this)); !walker.AtEnd(); walker.Advance()) { LayoutObject* o = walker.Current().GetLayoutObject(); if (!o->IsOutOfFlowPositioned() && (o->IsAtomicInlineLevel() || o->IsFloating())) { o->LayoutIfNeeded(); if (ToLayoutBox(o)->InlineBoxWrapper()) { RootInlineBox& box = ToLayoutBox(o)->InlineBoxWrapper()->Root(); line_boxes.insert(&box); } } else if (o->IsText() || (o->IsLayoutInline() && !walker.AtEndOfInline())) { o->ClearNeedsLayout(); } } // FIXME: Glyph overflow will get lost in this case, but not really a big // deal. GlyphOverflowAndFallbackFontsMap text_box_data_map; for (ListHashSet<RootInlineBox*>::const_iterator it = line_boxes.begin(); it != line_boxes.end(); ++it) { RootInlineBox* box = *it; box->ComputeOverflow(box->LineTop(), box->LineBottom(), text_box_data_map); } } bool LayoutBlockFlow::RecalcInlineChildrenOverflowAfterStyleChange() { DCHECK(ChildrenInline()); bool children_overflow_changed = false; ListHashSet<RootInlineBox*> line_boxes; for (InlineWalker walker(LineLayoutBlockFlow(this)); !walker.AtEnd(); walker.Advance()) { LayoutObject* layout_object = walker.Current().GetLayoutObject(); if (RecalcNormalFlowChildOverflowIfNeeded(layout_object)) { children_overflow_changed = true; if (layout_object->IsLayoutBlock()) { if (InlineBox* inline_box_wrapper = ToLayoutBlock(layout_object)->InlineBoxWrapper()) line_boxes.insert(&inline_box_wrapper->Root()); } } } // FIXME: Glyph overflow will get lost in this case, but not really a big // deal. GlyphOverflowAndFallbackFontsMap text_box_data_map; for (ListHashSet<RootInlineBox*>::const_iterator it = line_boxes.begin(); it != line_boxes.end(); ++it) { RootInlineBox* box = *it; box->ClearKnownToHaveNoOverflow(); box->ComputeOverflow(box->LineTop(), box->LineBottom(), text_box_data_map); } return children_overflow_changed; } PositionWithAffinity LayoutBlockFlow::PositionForPoint( const LayoutPoint& point) const { if (IsAtomicInlineLevel()) { PositionWithAffinity position = PositionForPointIfOutsideAtomicInlineLevel(point); if (!position.IsNull()) return position; } if (!ChildrenInline()) return LayoutBlock::PositionForPoint(point); LayoutPoint point_in_contents = point; OffsetForContents(point_in_contents); LayoutPoint point_in_logical_contents(point_in_contents); if (!IsHorizontalWritingMode()) point_in_logical_contents = point_in_logical_contents.TransposedPoint(); if (!FirstRootBox()) return CreatePositionWithAffinity(0); bool lines_are_flipped = Style()->IsFlippedLinesWritingMode(); bool blocks_are_flipped = Style()->IsFlippedBlocksWritingMode(); // look for the closest line box in the root box which is at the passed-in y // coordinate InlineBox* closest_box = nullptr; RootInlineBox* first_root_box_with_children = nullptr; RootInlineBox* last_root_box_with_children = nullptr; for (RootInlineBox* root = FirstRootBox(); root; root = root->NextRootBox()) { if (!root->FirstLeafChild()) continue; if (!first_root_box_with_children) first_root_box_with_children = root; if (!lines_are_flipped && root->IsFirstAfterPageBreak() && (point_in_logical_contents.Y() < root->LineTopWithLeading() || (blocks_are_flipped && point_in_logical_contents.Y() == root->LineTopWithLeading()))) break; last_root_box_with_children = root; // check if this root line box is located at this y coordinate if (point_in_logical_contents.Y() < root->SelectionBottom() || (blocks_are_flipped && point_in_logical_contents.Y() == root->SelectionBottom())) { if (lines_are_flipped) { RootInlineBox* next_root_box_with_children = root->NextRootBox(); while (next_root_box_with_children && !next_root_box_with_children->FirstLeafChild()) next_root_box_with_children = next_root_box_with_children->NextRootBox(); if (next_root_box_with_children && next_root_box_with_children->IsFirstAfterPageBreak() && (point_in_logical_contents.Y() > next_root_box_with_children->LineTopWithLeading() || (!blocks_are_flipped && point_in_logical_contents.Y() == next_root_box_with_children->LineTopWithLeading()))) continue; } closest_box = root->ClosestLeafChildForLogicalLeftPosition( point_in_logical_contents.X()); if (closest_box) break; } } bool move_caret_to_boundary = GetDocument() .GetFrame() ->GetEditor() .Behavior() .ShouldMoveCaretToHorizontalBoundaryWhenPastTopOrBottom(); if (!move_caret_to_boundary && !closest_box && last_root_box_with_children) { // y coordinate is below last root line box, pretend we hit it closest_box = last_root_box_with_children->ClosestLeafChildForLogicalLeftPosition( point_in_logical_contents.X()); } if (closest_box) { if (move_caret_to_boundary) { LayoutUnit first_root_box_with_children_top = std::min<LayoutUnit>(first_root_box_with_children->SelectionTop(), first_root_box_with_children->LogicalTop()); if (point_in_logical_contents.Y() < first_root_box_with_children_top || (blocks_are_flipped && point_in_logical_contents.Y() == first_root_box_with_children_top)) { InlineBox* box = first_root_box_with_children->FirstLeafChild(); if (box->IsLineBreak()) { if (InlineBox* new_box = box->NextLeafChildIgnoringLineBreak()) box = new_box; } // y coordinate is above first root line box, so return the start of the // first return PositionWithAffinity(PositionForBox(box, true)); } } // pass the box a top position that is inside it LayoutPoint point(point_in_logical_contents.X(), closest_box->Root().BlockDirectionPointInLine()); if (!IsHorizontalWritingMode()) point = point.TransposedPoint(); if (closest_box->GetLineLayoutItem().IsAtomicInlineLevel()) return PositionForPointRespectingEditingBoundaries( LineLayoutBox(closest_box->GetLineLayoutItem()), point); return closest_box->GetLineLayoutItem().PositionForPoint(point); } if (last_root_box_with_children) { // We hit this case for Mac behavior when the Y coordinate is below the last // box. DCHECK(move_caret_to_boundary); if (const InlineBox* logically_last_box = last_root_box_with_children->GetLogicalEndNonPseudoBox()) { // TODO(layout-dev): Change |PositionForBox()| to take |const InlineBox*|. return PositionWithAffinity( PositionForBox(const_cast<InlineBox*>(logically_last_box), false)); } } // Can't reach this. We have a root line box, but it has no kids. // FIXME: This should NOTREACHED(), but clicking on placeholder text // seems to hit this code path. return CreatePositionWithAffinity(0); } #ifndef NDEBUG void LayoutBlockFlow::ShowLineTreeAndMark(const InlineBox* marked_box1, const char* marked_label1, const InlineBox* marked_box2, const char* marked_label2, const LayoutObject* obj) const { StringBuilder string_blockflow; DumpLayoutObject(string_blockflow, true, kShowTreeCharacterOffset); for (const RootInlineBox* root = FirstRootBox(); root; root = root->NextRootBox()) { root->DumpLineTreeAndMark(string_blockflow, marked_box1, marked_label1, marked_box2, marked_label2, obj, 1); } DLOG(INFO) << "\n" << string_blockflow.ToString().Utf8().data(); } #endif void LayoutBlockFlow::AddOutlineRects( Vector<LayoutRect>& rects, const LayoutPoint& additional_offset, IncludeBlockVisualOverflowOrNot include_block_overflows) const { // For blocks inside inlines, we go ahead and include margins so that we run // right up to the inline boxes above and below us (thus getting merged with // them to form a single irregular shape). const LayoutInline* inline_element_continuation = InlineElementContinuation(); if (inline_element_continuation) { // FIXME: This check really isn't accurate. bool next_inline_has_line_box = inline_element_continuation->FirstLineBox(); // FIXME: This is wrong. The principal layoutObject may not be the // continuation preceding this block. // FIXME: This is wrong for vertical writing-modes. // https://bugs.webkit.org/show_bug.cgi?id=46781 bool prev_inline_has_line_box = ToLayoutInline( inline_element_continuation->GetNode()->GetLayoutObject()) ->FirstLineBox(); LayoutUnit top_margin = prev_inline_has_line_box ? CollapsedMarginBefore() : LayoutUnit(); LayoutUnit bottom_margin = next_inline_has_line_box ? CollapsedMarginAfter() : LayoutUnit(); if (top_margin || bottom_margin) { LayoutRect rect(additional_offset, Size()); rect.ExpandEdges(top_margin, LayoutUnit(), bottom_margin, LayoutUnit()); rects.push_back(rect); } } LayoutBlock::AddOutlineRects(rects, additional_offset, include_block_overflows); if (include_block_overflows == kIncludeBlockVisualOverflow && !HasOverflowClip() && !HasControlClip()) { for (RootInlineBox* curr = FirstRootBox(); curr; curr = curr->NextRootBox()) { LayoutUnit top = std::max<LayoutUnit>(curr->LineTop(), curr->Y()); LayoutUnit bottom = std::min<LayoutUnit>(curr->LineBottom(), curr->Y() + curr->Height()); LayoutRect rect(additional_offset.X() + curr->X(), additional_offset.Y() + top, curr->Width(), bottom - top); if (!rect.IsEmpty()) rects.push_back(rect); } } if (inline_element_continuation) inline_element_continuation->AddOutlineRects( rects, additional_offset + (inline_element_continuation->ContainingBlock()->Location() - Location()), include_block_overflows); } void LayoutBlockFlow::InvalidateDisplayItemClients( PaintInvalidationReason invalidation_reason) const { BlockFlowPaintInvalidator(*this).InvalidateDisplayItemClients( invalidation_reason); } void LayoutBlockFlow::IncrementLayoutPassCount() { int layout_pass_count = 0; HashMap<LayoutBlockFlow*, int>::iterator layout_count_iterator = GetLayoutPassCountMap().find(this); if (layout_count_iterator != GetLayoutPassCountMap().end()) layout_pass_count = layout_count_iterator->value; GetLayoutPassCountMap().Set(this, ++layout_pass_count); } int LayoutBlockFlow::GetLayoutPassCountForTesting() { return GetLayoutPassCountMap().find(this)->value; } } // namespace blink
42.003064
91
0.70938
zipated
4d70c50978d1d23df30eb43b1757f954637c226b
2,002
hpp
C++
include/mos/gfx/model.hpp
morganbengtsson/mo
c719ff6b35478b068988901d0bf7253cb672e87a
[ "MIT" ]
230
2016-02-15T20:46:01.000Z
2022-03-07T11:56:12.000Z
include/mos/gfx/model.hpp
morganbengtsson/mo
c719ff6b35478b068988901d0bf7253cb672e87a
[ "MIT" ]
79
2016-02-07T11:37:04.000Z
2021-09-29T09:14:27.000Z
include/mos/gfx/model.hpp
morganbengtsson/mo
c719ff6b35478b068988901d0bf7253cb672e87a
[ "MIT" ]
14
2018-05-16T13:10:22.000Z
2021-09-28T10:23:31.000Z
#pragma once #include <memory> #include <optional> #include <json.hpp> #include <mos/gfx/assets.hpp> #include <mos/gfx/material.hpp> #include <mos/gfx/mesh.hpp> #include <mos/gfx/models.hpp> #include <mos/gfx/texture_2d.hpp> namespace mos::gfx { class Assets; class Material; namespace gl { class Renderer; } /** Collection of properties for a renderable object. */ class Model final { public: static auto load(const nlohmann::json &json, Assets &assets = *std::make_unique<Assets>(), const glm::mat4 &parent_transform = glm::mat4(1.0f)) -> Model; Model(std::string name, Shared_mesh mesh, glm::mat4 transform = glm::mat4(1.0f), Material material = Material{glm::vec3(1.0f)}); Model() = default; auto name() const -> std::string; auto position() const -> glm::vec3; /** Set position. */ auto position(const glm::vec3 &position) -> void; /** Get centroid position. */ auto centroid() const -> glm::vec3; /** Get radious of bounding sphere */ auto radius() const -> float; /** Set emission of material recursively. */ auto emission(const glm::vec3 &emission) -> void; /** Set alpha of material recursively. */ auto alpha(float alpha) -> void; /** Set ambient occlusion of material recursively. */ auto ambient_occlusion(float ambient_occlusion) -> void; /** set index of refraction of material recursively. */ auto index_of_refraction(float index_of_refraction) -> void; /** set transmission of material recursively. */ auto transmission(float transmission) -> void; /** set roughness of material recursively. */ auto roughness(float roughness) -> void; /** set metallic of material recursively. */ auto metallic(float metallic) -> void; /** Mesh shape. */ Shared_mesh mesh; /** Material. */ Material material; /** Transform. */ glm::mat4 transform{0.0f}; /** Children models. */ Models models; private: std::string name_; }; } // namespace mos::gfx
23.011494
71
0.661339
morganbengtsson
4d737421f833e42bf6782edcf8d2210f1eb782c6
979
cpp
C++
Vijos/1776.cpp
HeRaNO/OI-ICPC-Codes
4a4639cd3e347b472520065ca6ab8caadde6906d
[ "MIT" ]
18
2019-01-01T13:16:59.000Z
2022-02-28T04:51:50.000Z
Vijos/1776.cpp
HeRaNO/OI-ICPC-Codes
4a4639cd3e347b472520065ca6ab8caadde6906d
[ "MIT" ]
null
null
null
Vijos/1776.cpp
HeRaNO/OI-ICPC-Codes
4a4639cd3e347b472520065ca6ab8caadde6906d
[ "MIT" ]
5
2019-09-13T08:48:17.000Z
2022-02-19T06:59:03.000Z
#include <cstdio> #include <algorithm> #include <cstdlib> #define MAXN 20010 #define MAXM 100010 using namespace std; struct thief { int first; int second; int anger; }; thief a[MAXM]; int father[2 * MAXN]; int i, n, m; int tmp1, tmp2, tmp3, tmp4; bool cmp(const thief &x, const thief &y) { return x.anger > y.anger; } int getfather(int v) { return father[v] == v ? v : getfather(father[v]); } int main() { scanf("%d%d", &n, &m); for (i = 1; i <= m; i++) scanf("%d %d %d", &a[i].first, &a[i].second, &a[i].anger); for (i = 1; i <= 2 * n; i++) father[i] = i; sort(a + 1, a + m + 1, cmp); for (i = 1; i <= m; i++) { tmp1 = getfather(a[i].first); tmp2 = getfather(a[i].second); if (tmp1 != tmp2) { tmp3 = getfather(a[i].first + n); if (tmp3 != tmp2) father[tmp3] = tmp2; tmp4 = getfather(a[i].second + n); if (tmp1 != tmp4) father[tmp1] = tmp4; } else { printf("%d", a[i].anger); exit(0); } } printf("0"); return 0; }
16.59322
60
0.551583
HeRaNO
4d74b1aa40359491cb37252c1186ba7298149e78
1,170
cpp
C++
server/sockchat/threadctx.cpp
sockchat/server-historical
34befc2f7c2e310a9b58071633c2da00f5e7e308
[ "Apache-2.0" ]
1
2019-02-10T17:46:27.000Z
2019-02-10T17:46:27.000Z
server/sockchat/threadctx.cpp
sockchat/server-historical
34befc2f7c2e310a9b58071633c2da00f5e7e308
[ "Apache-2.0" ]
null
null
null
server/sockchat/threadctx.cpp
sockchat/server-historical
34befc2f7c2e310a9b58071633c2da00f5e7e308
[ "Apache-2.0" ]
null
null
null
#include "cthread.h" ThreadContext::Connection::Connection(sc::Socket *sock) { this->sock = sock; } ThreadContext::ThreadContext(sc::Socket *sock) { this->pendingConns.push_back(Connection(sock)); } void ThreadContext::Finish() { for(auto i = this->conns.begin(); i != this->conns.end(); ) i = CloseConnection(i); this->done = true; } bool ThreadContext::IsDone() { return this->done; } void ThreadContext::PushSocket(sc::Socket *sock) { this->_pendingConns.lock(); this->pendingConns.push_back(sock); this->_pendingConns.unlock(); } void ThreadContext::HandlePendingConnections() { this->_pendingConns.lock(); for(auto i = this->pendingConns.begin(); i != this->pendingConns.end(); ) { i->sock->SetBlocking(false); this->conns.push_back(*i); i = pendingConns.erase(i); } this->_pendingConns.unlock(); } std::vector<ThreadContext::Connection>::iterator ThreadContext::CloseConnection(std::vector<Connection>::iterator i) { std::cout << i->sock->GetIPAddress() << " disconnected" << std::endl; i->sock->Close(); delete i->sock; return this->conns.erase(i); }
26.590909
118
0.648718
sockchat
4d74e17e57df21d6e4e746c2c207ea6ccdc0245b
191
hpp
C++
pypedream/array_col_reader.hpp
garywu/pipedream
d89a4031d5ee78c05c6845341607a59528f0bd75
[ "BSD-3-Clause" ]
8
2018-02-21T04:13:25.000Z
2020-04-24T20:05:47.000Z
pypedream/array_col_reader.hpp
garywu/pipedream
d89a4031d5ee78c05c6845341607a59528f0bd75
[ "BSD-3-Clause" ]
1
2019-05-13T13:14:32.000Z
2019-05-13T13:14:32.000Z
pypedream/array_col_reader.hpp
garywu/pypedream
d89a4031d5ee78c05c6845341607a59528f0bd75
[ "BSD-3-Clause" ]
null
null
null
#ifndef ARRAY_COL_READER_HPP #define ARRAY_COL_READER_HPP #include <Python.h> #include "parser_defs.hpp" extern PyTypeObject ArrayColReaderType; #endif // #ifndef ARRAY_COL_READER_HPP
13.642857
39
0.806283
garywu
4d76878a3351a438d5a729fd296c7b35a1ab2597
175,942
cpp
C++
jni/lua/packages/opengl.cpp
zchajax/WiEngine
ea2fa297f00aa5367bb5b819d6714ac84a8a8e25
[ "MIT" ]
1
2020-12-02T03:09:18.000Z
2020-12-02T03:09:18.000Z
jni/lua/packages/opengl.cpp
acremean/WiEngine
a8267bbb797b0d7326a06e1a02831a93edf007d6
[ "MIT" ]
null
null
null
jni/lua/packages/opengl.cpp
acremean/WiEngine
a8267bbb797b0d7326a06e1a02831a93edf007d6
[ "MIT" ]
1
2020-09-01T06:43:27.000Z
2020-09-01T06:43:27.000Z
/* ** Lua binding: opengl ** Generated automatically by tolua++-1.0.92 on Sat Dec 24 20:13:50 2011. */ #ifndef __cplusplus #include "stdlib.h" #endif #include "string.h" #include "tolua++.h" /* Exported function */ TOLUA_API int tolua_opengl_open (lua_State* tolua_S); #include "WiEngine.h" /* function to release collected object via destructor */ #ifdef __cplusplus static int tolua_collect_wyGLTexture2D (lua_State* tolua_S) { wyGLTexture2D* self = (wyGLTexture2D*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } static int tolua_collect_wyTextureAtlas (lua_State* tolua_S) { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } static int tolua_collect_wyCamera (lua_State* tolua_S) { wyCamera* self = (wyCamera*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } static int tolua_collect_wyTexture2D (lua_State* tolua_S) { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } static int tolua_collect_wyTextureManager (lua_State* tolua_S) { wyTextureManager* self = (wyTextureManager*) tolua_tousertype(tolua_S,1,0); Mtolua_delete(self); return 0; } #endif /* function to register type */ static void tolua_reg_types (lua_State* tolua_S) { tolua_usertype(tolua_S,"wyLagrangeConfig"); tolua_usertype(tolua_S,"wyGLTexture2D"); tolua_usertype(tolua_S,"wyCamera"); tolua_usertype(tolua_S,"wyFontStyle"); tolua_usertype(tolua_S,"wyTextureAtlas"); tolua_usertype(tolua_S,"wyTextureManager"); tolua_usertype(tolua_S,"wyTexture2D"); tolua_usertype(tolua_S,"size_t"); tolua_usertype(tolua_S,"wyQuad2D"); tolua_usertype(tolua_S,"wyColor4B"); tolua_usertype(tolua_S,"wyBezierConfig"); tolua_usertype(tolua_S,"wyQuad3D"); tolua_usertype(tolua_S,"wyEventDispatcher"); tolua_usertype(tolua_S,"wyObject"); tolua_usertype(tolua_S,"wyRect"); tolua_usertype(tolua_S,"wyColorFilter"); } /* method: getZEye of class wyCamera */ #ifndef TOLUA_DISABLE_tolua_opengl_wyCamera_getZEye00 static int tolua_opengl_wyCamera_getZEye00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyCamera",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { float tolua_ret = (float) wyCamera::getZEye(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getZEye'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: make of class wyCamera */ #ifndef TOLUA_DISABLE_tolua_opengl_wyCamera_make00 static int tolua_opengl_wyCamera_make00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyCamera",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { wyCamera* tolua_ret = (wyCamera*) wyCamera::make(); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyCamera"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'make'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: delete of class wyCamera */ #ifndef TOLUA_DISABLE_tolua_opengl_wyCamera_delete00 static int tolua_opengl_wyCamera_delete00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyCamera",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyCamera* self = (wyCamera*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL); #endif Mtolua_delete(self); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: restore of class wyCamera */ #ifndef TOLUA_DISABLE_tolua_opengl_wyCamera_restore00 static int tolua_opengl_wyCamera_restore00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyCamera",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyCamera* self = (wyCamera*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'restore'", NULL); #endif { self->restore(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'restore'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: locate of class wyCamera */ #ifndef TOLUA_DISABLE_tolua_opengl_wyCamera_locate00 static int tolua_opengl_wyCamera_locate00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyCamera",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyCamera* self = (wyCamera*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'locate'", NULL); #endif { self->locate(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'locate'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setEye of class wyCamera */ #ifndef TOLUA_DISABLE_tolua_opengl_wyCamera_setEye00 static int tolua_opengl_wyCamera_setEye00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyCamera",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { wyCamera* self = (wyCamera*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); float z = ((float) tolua_tonumber(tolua_S,4,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setEye'", NULL); #endif { self->setEye(x,y,z); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setEye'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setCenter of class wyCamera */ #ifndef TOLUA_DISABLE_tolua_opengl_wyCamera_setCenter00 static int tolua_opengl_wyCamera_setCenter00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyCamera",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { wyCamera* self = (wyCamera*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); float z = ((float) tolua_tonumber(tolua_S,4,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setCenter'", NULL); #endif { self->setCenter(x,y,z); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setCenter'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setUp of class wyCamera */ #ifndef TOLUA_DISABLE_tolua_opengl_wyCamera_setUp00 static int tolua_opengl_wyCamera_setUp00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyCamera",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { wyCamera* self = (wyCamera*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); float z = ((float) tolua_tonumber(tolua_S,4,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUp'", NULL); #endif { self->setUp(x,y,z); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setUp'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getEye of class wyCamera */ #ifndef TOLUA_DISABLE_tolua_opengl_wyCamera_getEye00 static int tolua_opengl_wyCamera_getEye00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyCamera",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyCamera* self = (wyCamera*) tolua_tousertype(tolua_S,1,0); float eye = ((float) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getEye'", NULL); #endif { self->getEye(&eye); tolua_pushnumber(tolua_S,(lua_Number)eye); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getEye'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getCenter of class wyCamera */ #ifndef TOLUA_DISABLE_tolua_opengl_wyCamera_getCenter00 static int tolua_opengl_wyCamera_getCenter00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyCamera",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyCamera* self = (wyCamera*) tolua_tousertype(tolua_S,1,0); float center = ((float) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCenter'", NULL); #endif { self->getCenter(&center); tolua_pushnumber(tolua_S,(lua_Number)center); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getCenter'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getUp of class wyCamera */ #ifndef TOLUA_DISABLE_tolua_opengl_wyCamera_getUp00 static int tolua_opengl_wyCamera_getUp00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyCamera",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyCamera* self = (wyCamera*) tolua_tousertype(tolua_S,1,0); float up = ((float) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getUp'", NULL); #endif { self->getUp(&up); tolua_pushnumber(tolua_S,(lua_Number)up); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getUp'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: isDirty of class wyCamera */ #ifndef TOLUA_DISABLE_tolua_opengl_wyCamera_isDirty00 static int tolua_opengl_wyCamera_isDirty00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyCamera",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyCamera* self = (wyCamera*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isDirty'", NULL); #endif { bool tolua_ret = (bool) self->isDirty(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isDirty'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setDirty of class wyCamera */ #ifndef TOLUA_DISABLE_tolua_opengl_wyCamera_setDirty00 static int tolua_opengl_wyCamera_setDirty00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyCamera",0,&tolua_err) || !tolua_isboolean(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyCamera* self = (wyCamera*) tolua_tousertype(tolua_S,1,0); bool dirty = ((bool) tolua_toboolean(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDirty'", NULL); #endif { self->setDirty(dirty); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setDirty'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeBMP00 static int tolua_opengl_wyTexture2D_makeBMP00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { int resId = ((int) tolua_tonumber(tolua_S,2,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeBMP(resId); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeBMP'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeBMP01 static int tolua_opengl_wyTexture2D_makeBMP01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { int resId = ((int) tolua_tonumber(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeBMP(resId,transparentColor); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeBMP00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeBMP02 static int tolua_opengl_wyTexture2D_makeBMP02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { int resId = ((int) tolua_tonumber(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeBMP(resId,transparentColor,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeBMP01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeBMP03 static int tolua_opengl_wyTexture2D_makeBMP03(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else { const char* assetPath = ((const char*) tolua_tostring(tolua_S,2,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeBMP(assetPath); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeBMP02(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeBMP04 static int tolua_opengl_wyTexture2D_makeBMP04(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { const char* assetPath = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeBMP(assetPath,transparentColor); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeBMP03(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeBMP05 static int tolua_opengl_wyTexture2D_makeBMP05(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { const char* assetPath = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeBMP(assetPath,transparentColor,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeBMP04(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeBMP06 static int tolua_opengl_wyTexture2D_makeBMP06(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { const char* assetPath = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); float inDensity = ((float) tolua_tonumber(tolua_S,5,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeBMP(assetPath,transparentColor,format,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeBMP05(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeRawBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRawBMP00 static int tolua_opengl_wyTexture2D_makeRawBMP00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"size_t",0,&tolua_err)) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRawBMP(data,length); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeRawBMP'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeRawBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRawBMP01 static int tolua_opengl_wyTexture2D_makeRawBMP01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"size_t",0,&tolua_err)) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,3,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRawBMP(data,length,transparentColor); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeRawBMP00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeRawBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRawBMP02 static int tolua_opengl_wyTexture2D_makeRawBMP02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"size_t",0,&tolua_err)) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,3,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,4,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,5,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRawBMP(data,length,transparentColor,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeRawBMP01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeRawBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRawBMP03 static int tolua_opengl_wyTexture2D_makeRawBMP03(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"size_t",0,&tolua_err)) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnumber(tolua_S,6,0,&tolua_err) || !tolua_isnoobj(tolua_S,7,&tolua_err) ) goto tolua_lerror; else { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,3,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,4,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,5,0)); float inDensity = ((float) tolua_tonumber(tolua_S,6,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRawBMP(data,length,transparentColor,format,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeRawBMP02(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeMemoryBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeMemoryBMP00 static int tolua_opengl_wyTexture2D_makeMemoryBMP00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const char* mfsName = ((const char*) tolua_tostring(tolua_S,2,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeMemoryBMP(mfsName); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeMemoryBMP'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeMemoryBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeMemoryBMP01 static int tolua_opengl_wyTexture2D_makeMemoryBMP01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { const char* mfsName = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeMemoryBMP(mfsName,transparentColor); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeMemoryBMP00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeMemoryBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeMemoryBMP02 static int tolua_opengl_wyTexture2D_makeMemoryBMP02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { const char* mfsName = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeMemoryBMP(mfsName,transparentColor,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeMemoryBMP01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeMemoryBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeMemoryBMP03 static int tolua_opengl_wyTexture2D_makeMemoryBMP03(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { const char* mfsName = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); float inDensity = ((float) tolua_tonumber(tolua_S,5,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeMemoryBMP(mfsName,transparentColor,format,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeMemoryBMP02(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeFileBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeFileBMP00 static int tolua_opengl_wyTexture2D_makeFileBMP00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const char* fsPath = ((const char*) tolua_tostring(tolua_S,2,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeFileBMP(fsPath); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeFileBMP'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeFileBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeFileBMP01 static int tolua_opengl_wyTexture2D_makeFileBMP01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { const char* fsPath = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeFileBMP(fsPath,transparentColor); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeFileBMP00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeFileBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeFileBMP02 static int tolua_opengl_wyTexture2D_makeFileBMP02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { const char* fsPath = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeFileBMP(fsPath,transparentColor,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeFileBMP01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeFileBMP of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeFileBMP03 static int tolua_opengl_wyTexture2D_makeFileBMP03(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { const char* fsPath = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); float inDensity = ((float) tolua_tonumber(tolua_S,5,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeFileBMP(fsPath,transparentColor,format,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeFileBMP02(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeJPG00 static int tolua_opengl_wyTexture2D_makeJPG00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { int resId = ((int) tolua_tonumber(tolua_S,2,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeJPG(resId); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeJPG'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeJPG01 static int tolua_opengl_wyTexture2D_makeJPG01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { int resId = ((int) tolua_tonumber(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeJPG(resId,transparentColor); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeJPG00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeJPG02 static int tolua_opengl_wyTexture2D_makeJPG02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { int resId = ((int) tolua_tonumber(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeJPG(resId,transparentColor,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeJPG01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeJPG03 static int tolua_opengl_wyTexture2D_makeJPG03(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else { const char* assetPath = ((const char*) tolua_tostring(tolua_S,2,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeJPG(assetPath); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeJPG02(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeJPG04 static int tolua_opengl_wyTexture2D_makeJPG04(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { const char* assetPath = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeJPG(assetPath,transparentColor); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeJPG03(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeJPG05 static int tolua_opengl_wyTexture2D_makeJPG05(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { const char* assetPath = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeJPG(assetPath,transparentColor,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeJPG04(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeJPG06 static int tolua_opengl_wyTexture2D_makeJPG06(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { const char* assetPath = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); float inDensity = ((float) tolua_tonumber(tolua_S,5,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeJPG(assetPath,transparentColor,format,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeJPG05(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeRawJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRawJPG00 static int tolua_opengl_wyTexture2D_makeRawJPG00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"size_t",0,&tolua_err)) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRawJPG(data,length); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeRawJPG'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeRawJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRawJPG01 static int tolua_opengl_wyTexture2D_makeRawJPG01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"size_t",0,&tolua_err)) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,3,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRawJPG(data,length,transparentColor); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeRawJPG00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeRawJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRawJPG02 static int tolua_opengl_wyTexture2D_makeRawJPG02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"size_t",0,&tolua_err)) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,3,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,4,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,5,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRawJPG(data,length,transparentColor,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeRawJPG01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeRawJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRawJPG03 static int tolua_opengl_wyTexture2D_makeRawJPG03(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"size_t",0,&tolua_err)) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnumber(tolua_S,6,0,&tolua_err) || !tolua_isnoobj(tolua_S,7,&tolua_err) ) goto tolua_lerror; else { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,3,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,4,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,5,0)); float inDensity = ((float) tolua_tonumber(tolua_S,6,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRawJPG(data,length,transparentColor,format,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeRawJPG02(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeMemoryJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeMemoryJPG00 static int tolua_opengl_wyTexture2D_makeMemoryJPG00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const char* mfsName = ((const char*) tolua_tostring(tolua_S,2,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeMemoryJPG(mfsName); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeMemoryJPG'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeMemoryJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeMemoryJPG01 static int tolua_opengl_wyTexture2D_makeMemoryJPG01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { const char* mfsName = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeMemoryJPG(mfsName,transparentColor); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeMemoryJPG00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeMemoryJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeMemoryJPG02 static int tolua_opengl_wyTexture2D_makeMemoryJPG02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { const char* mfsName = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeMemoryJPG(mfsName,transparentColor,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeMemoryJPG01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeMemoryJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeMemoryJPG03 static int tolua_opengl_wyTexture2D_makeMemoryJPG03(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { const char* mfsName = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); float inDensity = ((float) tolua_tonumber(tolua_S,5,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeMemoryJPG(mfsName,transparentColor,format,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeMemoryJPG02(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeFileJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeFileJPG00 static int tolua_opengl_wyTexture2D_makeFileJPG00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const char* fsPath = ((const char*) tolua_tostring(tolua_S,2,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeFileJPG(fsPath); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeFileJPG'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeFileJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeFileJPG01 static int tolua_opengl_wyTexture2D_makeFileJPG01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { const char* fsPath = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeFileJPG(fsPath,transparentColor); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeFileJPG00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeFileJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeFileJPG02 static int tolua_opengl_wyTexture2D_makeFileJPG02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { const char* fsPath = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeFileJPG(fsPath,transparentColor,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeFileJPG01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeFileJPG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeFileJPG03 static int tolua_opengl_wyTexture2D_makeFileJPG03(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { const char* fsPath = ((const char*) tolua_tostring(tolua_S,2,0)); int transparentColor = ((int) tolua_tonumber(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); float inDensity = ((float) tolua_tonumber(tolua_S,5,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeFileJPG(fsPath,transparentColor,format,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeFileJPG02(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makePNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makePNG00 static int tolua_opengl_wyTexture2D_makePNG00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { int resId = ((int) tolua_tonumber(tolua_S,2,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makePNG(resId); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makePNG'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makePNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makePNG01 static int tolua_opengl_wyTexture2D_makePNG01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { int resId = ((int) tolua_tonumber(tolua_S,2,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makePNG(resId,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makePNG00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makePNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makePNG02 static int tolua_opengl_wyTexture2D_makePNG02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else { const char* assetPath = ((const char*) tolua_tostring(tolua_S,2,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makePNG(assetPath); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makePNG01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makePNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makePNG03 static int tolua_opengl_wyTexture2D_makePNG03(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { const char* assetPath = ((const char*) tolua_tostring(tolua_S,2,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makePNG(assetPath,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makePNG02(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makePNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makePNG04 static int tolua_opengl_wyTexture2D_makePNG04(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { const char* assetPath = ((const char*) tolua_tostring(tolua_S,2,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,3,0)); float inDensity = ((float) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makePNG(assetPath,format,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makePNG03(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeRawPNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRawPNG00 static int tolua_opengl_wyTexture2D_makeRawPNG00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"size_t",0,&tolua_err)) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRawPNG(data,length); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeRawPNG'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeRawPNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRawPNG01 static int tolua_opengl_wyTexture2D_makeRawPNG01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"size_t",0,&tolua_err)) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRawPNG(data,length,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeRawPNG00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeRawPNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRawPNG02 static int tolua_opengl_wyTexture2D_makeRawPNG02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"size_t",0,&tolua_err)) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,3,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,4,0)); float inDensity = ((float) tolua_tonumber(tolua_S,5,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRawPNG(data,length,format,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeRawPNG01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeMemoryPNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeMemoryPNG00 static int tolua_opengl_wyTexture2D_makeMemoryPNG00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const char* mfsName = ((const char*) tolua_tostring(tolua_S,2,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeMemoryPNG(mfsName); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeMemoryPNG'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeMemoryPNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeMemoryPNG01 static int tolua_opengl_wyTexture2D_makeMemoryPNG01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { const char* mfsName = ((const char*) tolua_tostring(tolua_S,2,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeMemoryPNG(mfsName,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeMemoryPNG00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeMemoryPNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeMemoryPNG02 static int tolua_opengl_wyTexture2D_makeMemoryPNG02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { const char* mfsName = ((const char*) tolua_tostring(tolua_S,2,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,3,0)); float inDensity = ((float) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeMemoryPNG(mfsName,format,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeMemoryPNG01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeFilePNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeFilePNG00 static int tolua_opengl_wyTexture2D_makeFilePNG00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { const char* fsPath = ((const char*) tolua_tostring(tolua_S,2,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeFilePNG(fsPath); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeFilePNG'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeFilePNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeFilePNG01 static int tolua_opengl_wyTexture2D_makeFilePNG01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { const char* fsPath = ((const char*) tolua_tostring(tolua_S,2,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeFilePNG(fsPath,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeFilePNG00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeFilePNG of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeFilePNG02 static int tolua_opengl_wyTexture2D_makeFilePNG02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { const char* fsPath = ((const char*) tolua_tostring(tolua_S,2,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,3,0)); float inDensity = ((float) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeFilePNG(fsPath,format,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeFilePNG01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makePVR of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makePVR00 static int tolua_opengl_wyTexture2D_makePVR00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { int resId = ((int) tolua_tonumber(tolua_S,2,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makePVR(resId); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makePVR'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makePVR of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makePVR01 static int tolua_opengl_wyTexture2D_makePVR01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { const char* assetPath = ((const char*) tolua_tostring(tolua_S,2,0)); float inDensity = ((float) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makePVR(assetPath,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makePVR00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeRawPVR of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRawPVR00 static int tolua_opengl_wyTexture2D_makeRawPVR00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"size_t",0,&tolua_err)) || !tolua_isnumber(tolua_S,4,1,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,3,0)); float inDensity = ((float) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRawPVR(data,length,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeRawPVR'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeMemoryPVR of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeMemoryPVR00 static int tolua_opengl_wyTexture2D_makeMemoryPVR00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { const char* mfsName = ((const char*) tolua_tostring(tolua_S,2,0)); float inDensity = ((float) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeMemoryPVR(mfsName,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeMemoryPVR'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeFilePVR of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeFilePVR00 static int tolua_opengl_wyTexture2D_makeFilePVR00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { const char* fsPath = ((const char*) tolua_tostring(tolua_S,2,0)); float inDensity = ((float) tolua_tonumber(tolua_S,3,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeFilePVR(fsPath,inDensity); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeFilePVR'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeLabel of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeLabel00 static int tolua_opengl_wyTexture2D_makeLabel00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isstring(tolua_S,4,1,&tolua_err) || !tolua_isboolean(tolua_S,5,1,&tolua_err) || !tolua_isnumber(tolua_S,6,1,&tolua_err) || !tolua_isnumber(tolua_S,7,1,&tolua_err) || !tolua_isnoobj(tolua_S,8,&tolua_err) ) goto tolua_lerror; else #endif { const char* text = ((const char*) tolua_tostring(tolua_S,2,0)); float fontSize = ((float) tolua_tonumber(tolua_S,3,0)); const char* fontPath = ((const char*) tolua_tostring(tolua_S,4,NULL)); bool isFile = ((bool) tolua_toboolean(tolua_S,5,false)); float width = ((float) tolua_tonumber(tolua_S,6,0)); wyTexture2D::TextAlignment alignment = ((wyTexture2D::TextAlignment) (int) tolua_tonumber(tolua_S,7,wyTexture2D::LEFT)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeLabel(text,fontSize,fontPath,isFile,width,alignment); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeLabel'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeLabel of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeLabel01 static int tolua_opengl_wyTexture2D_makeLabel01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || (tolua_isvaluenil(tolua_S,4,&tolua_err) || !tolua_isusertype(tolua_S,4,"wyFontStyle",0,&tolua_err)) || !tolua_isstring(tolua_S,5,1,&tolua_err) || !tolua_isnumber(tolua_S,6,1,&tolua_err) || !tolua_isnumber(tolua_S,7,1,&tolua_err) || !tolua_isnoobj(tolua_S,8,&tolua_err) ) goto tolua_lerror; else { const char* text = ((const char*) tolua_tostring(tolua_S,2,0)); float fontSize = ((float) tolua_tonumber(tolua_S,3,0)); wyFontStyle style = *((wyFontStyle*) tolua_tousertype(tolua_S,4,0)); const char* fontName = ((const char*) tolua_tostring(tolua_S,5,NULL)); float width = ((float) tolua_tonumber(tolua_S,6,0)); wyTexture2D::TextAlignment alignment = ((wyTexture2D::TextAlignment) (int) tolua_tonumber(tolua_S,7,wyTexture2D::LEFT)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeLabel(text,fontSize,style,fontName,width,alignment); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeLabel00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: makeGL of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeGL00 static int tolua_opengl_wyTexture2D_makeGL00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { int texture = ((int) tolua_tonumber(tolua_S,2,0)); int w = ((int) tolua_tonumber(tolua_S,3,0)); int h = ((int) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeGL(texture,w,h); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeGL'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeRaw of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRaw00 static int tolua_opengl_wyTexture2D_makeRaw00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); int width = ((int) tolua_tonumber(tolua_S,3,0)); int height = ((int) tolua_tonumber(tolua_S,4,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRaw(data,width,height); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'makeRaw'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: makeRaw of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_makeRaw01 static int tolua_opengl_wyTexture2D_makeRaw01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { const char* data = ((const char*) tolua_tostring(tolua_S,2,0)); int width = ((int) tolua_tonumber(tolua_S,3,0)); int height = ((int) tolua_tonumber(tolua_S,4,0)); wyTexturePixelFormat format = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,5,0)); { wyTexture2D* tolua_ret = (wyTexture2D*) wyTexture2D::makeRaw(data,width,height,format); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; tolua_lerror: return tolua_opengl_wyTexture2D_makeRaw00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: new of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_new00 static int tolua_opengl_wyTexture2D_new00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { wyTexture2D* tolua_ret = (wyTexture2D*) Mtolua_new((wyTexture2D)()); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new_local of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_new00_local static int tolua_opengl_wyTexture2D_new00_local(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { wyTexture2D* tolua_ret = (wyTexture2D*) Mtolua_new((wyTexture2D)()); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: delete of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_delete00 static int tolua_opengl_wyTexture2D_delete00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL); #endif Mtolua_delete(self); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: load of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_load00 static int tolua_opengl_wyTexture2D_load00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'load'", NULL); #endif { self->load(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'load'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: updateLabel of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_updateLabel00 static int tolua_opengl_wyTexture2D_updateLabel00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); const char* text = ((const char*) tolua_tostring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'updateLabel'", NULL); #endif { self->updateLabel(text); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'updateLabel'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: updateLabel of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_updateLabel01 static int tolua_opengl_wyTexture2D_updateLabel01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isstring(tolua_S,4,1,&tolua_err) || !tolua_isboolean(tolua_S,5,1,&tolua_err) || !tolua_isnumber(tolua_S,6,1,&tolua_err) || !tolua_isnumber(tolua_S,7,1,&tolua_err) || !tolua_isnoobj(tolua_S,8,&tolua_err) ) goto tolua_lerror; else { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); const char* text = ((const char*) tolua_tostring(tolua_S,2,0)); float fontSize = ((float) tolua_tonumber(tolua_S,3,0)); const char* fontPath = ((const char*) tolua_tostring(tolua_S,4,NULL)); bool isFile = ((bool) tolua_toboolean(tolua_S,5,false)); float lineWidth = ((float) tolua_tonumber(tolua_S,6,0)); wyTexture2D::TextAlignment alignment = ((wyTexture2D::TextAlignment) (int) tolua_tonumber(tolua_S,7,wyTexture2D::LEFT)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'updateLabel'", NULL); #endif { self->updateLabel(text,fontSize,fontPath,isFile,lineWidth,alignment); } } return 0; tolua_lerror: return tolua_opengl_wyTexture2D_updateLabel00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: updateLabel of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_updateLabel02 static int tolua_opengl_wyTexture2D_updateLabel02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || (tolua_isvaluenil(tolua_S,4,&tolua_err) || !tolua_isusertype(tolua_S,4,"wyFontStyle",0,&tolua_err)) || !tolua_isstring(tolua_S,5,1,&tolua_err) || !tolua_isnumber(tolua_S,6,1,&tolua_err) || !tolua_isnumber(tolua_S,7,1,&tolua_err) || !tolua_isnoobj(tolua_S,8,&tolua_err) ) goto tolua_lerror; else { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); const char* text = ((const char*) tolua_tostring(tolua_S,2,0)); float fontSize = ((float) tolua_tonumber(tolua_S,3,0)); wyFontStyle style = *((wyFontStyle*) tolua_tousertype(tolua_S,4,0)); const char* fontName = ((const char*) tolua_tostring(tolua_S,5,NULL)); float lineWidth = ((float) tolua_tonumber(tolua_S,6,0)); wyTexture2D::TextAlignment alignment = ((wyTexture2D::TextAlignment) (int) tolua_tonumber(tolua_S,7,wyTexture2D::LEFT)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'updateLabel'", NULL); #endif { self->updateLabel(text,fontSize,style,fontName,lineWidth,alignment); } } return 0; tolua_lerror: return tolua_opengl_wyTexture2D_updateLabel01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: setAntiAlias of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_setAntiAlias00 static int tolua_opengl_wyTexture2D_setAntiAlias00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isboolean(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); bool on = ((bool) tolua_toboolean(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAntiAlias'", NULL); #endif { self->setAntiAlias(on); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setAntiAlias'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setRepeat of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_setRepeat00 static int tolua_opengl_wyTexture2D_setRepeat00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isboolean(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); bool on = ((bool) tolua_toboolean(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setRepeat'", NULL); #endif { self->setRepeat(on); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setRepeat'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setParameters of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_setParameters00 static int tolua_opengl_wyTexture2D_setParameters00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); int min = ((int) tolua_tonumber(tolua_S,2,0)); int mag = ((int) tolua_tonumber(tolua_S,3,0)); int wrapS = ((int) tolua_tonumber(tolua_S,4,0)); int wrapT = ((int) tolua_tonumber(tolua_S,5,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setParameters'", NULL); #endif { self->setParameters(min,mag,wrapS,wrapT); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setParameters'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: applyParameters of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_applyParameters00 static int tolua_opengl_wyTexture2D_applyParameters00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'applyParameters'", NULL); #endif { self->applyParameters(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'applyParameters'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: hasPremultipliedAlpha of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_hasPremultipliedAlpha00 static int tolua_opengl_wyTexture2D_hasPremultipliedAlpha00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'hasPremultipliedAlpha'", NULL); #endif { bool tolua_ret = (bool) self->hasPremultipliedAlpha(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'hasPremultipliedAlpha'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: draw of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_draw00 static int tolua_opengl_wyTexture2D_draw00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'draw'", NULL); #endif { self->draw(x,y); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'draw'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: draw of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_draw01 static int tolua_opengl_wyTexture2D_draw01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isboolean(tolua_S,4,0,&tolua_err) || !tolua_isboolean(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); bool flipX = ((bool) tolua_toboolean(tolua_S,4,0)); bool flipY = ((bool) tolua_toboolean(tolua_S,5,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'draw'", NULL); #endif { self->draw(x,y,flipX,flipY); } } return 0; tolua_lerror: return tolua_opengl_wyTexture2D_draw00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: draw of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_draw02 static int tolua_opengl_wyTexture2D_draw02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); float width = ((float) tolua_tonumber(tolua_S,4,0)); float height = ((float) tolua_tonumber(tolua_S,5,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'draw'", NULL); #endif { self->draw(x,y,width,height); } } return 0; tolua_lerror: return tolua_opengl_wyTexture2D_draw01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: draw of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_draw03 static int tolua_opengl_wyTexture2D_draw03(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isboolean(tolua_S,6,0,&tolua_err) || !tolua_isboolean(tolua_S,7,0,&tolua_err) || !tolua_isnoobj(tolua_S,8,&tolua_err) ) goto tolua_lerror; else { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); float width = ((float) tolua_tonumber(tolua_S,4,0)); float height = ((float) tolua_tonumber(tolua_S,5,0)); bool flipX = ((bool) tolua_toboolean(tolua_S,6,0)); bool flipY = ((bool) tolua_toboolean(tolua_S,7,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'draw'", NULL); #endif { self->draw(x,y,width,height,flipX,flipY); } } return 0; tolua_lerror: return tolua_opengl_wyTexture2D_draw02(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: draw of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_draw04 static int tolua_opengl_wyTexture2D_draw04(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isboolean(tolua_S,6,0,&tolua_err) || !tolua_isboolean(tolua_S,7,0,&tolua_err) || (tolua_isvaluenil(tolua_S,8,&tolua_err) || !tolua_isusertype(tolua_S,8,"wyRect",0,&tolua_err)) || !tolua_isnoobj(tolua_S,9,&tolua_err) ) goto tolua_lerror; else { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); float width = ((float) tolua_tonumber(tolua_S,4,0)); float height = ((float) tolua_tonumber(tolua_S,5,0)); bool flipX = ((bool) tolua_toboolean(tolua_S,6,0)); bool flipY = ((bool) tolua_toboolean(tolua_S,7,0)); wyRect texRect = *((wyRect*) tolua_tousertype(tolua_S,8,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'draw'", NULL); #endif { self->draw(x,y,width,height,flipX,flipY,texRect); } } return 0; tolua_lerror: return tolua_opengl_wyTexture2D_draw03(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: draw of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_draw05 static int tolua_opengl_wyTexture2D_draw05(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isboolean(tolua_S,6,0,&tolua_err) || !tolua_isboolean(tolua_S,7,0,&tolua_err) || (tolua_isvaluenil(tolua_S,8,&tolua_err) || !tolua_isusertype(tolua_S,8,"wyRect",0,&tolua_err)) || !tolua_isboolean(tolua_S,9,0,&tolua_err) || !tolua_isnoobj(tolua_S,10,&tolua_err) ) goto tolua_lerror; else { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); float width = ((float) tolua_tonumber(tolua_S,4,0)); float height = ((float) tolua_tonumber(tolua_S,5,0)); bool flipX = ((bool) tolua_toboolean(tolua_S,6,0)); bool flipY = ((bool) tolua_toboolean(tolua_S,7,0)); wyRect texRect = *((wyRect*) tolua_tousertype(tolua_S,8,0)); bool rotatedZwoptex = ((bool) tolua_toboolean(tolua_S,9,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'draw'", NULL); #endif { self->draw(x,y,width,height,flipX,flipY,texRect,rotatedZwoptex); } } return 0; tolua_lerror: return tolua_opengl_wyTexture2D_draw04(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: draw of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_draw06 static int tolua_opengl_wyTexture2D_draw06(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnumber(tolua_S,6,0,&tolua_err) || !tolua_isnumber(tolua_S,7,0,&tolua_err) || !tolua_isboolean(tolua_S,8,0,&tolua_err) || !tolua_isboolean(tolua_S,9,0,&tolua_err) || (tolua_isvaluenil(tolua_S,10,&tolua_err) || !tolua_isusertype(tolua_S,10,"wyRect",0,&tolua_err)) || !tolua_isboolean(tolua_S,11,0,&tolua_err) || !tolua_isnoobj(tolua_S,12,&tolua_err) ) goto tolua_lerror; else { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); float x = ((float) tolua_tonumber(tolua_S,2,0)); float y = ((float) tolua_tonumber(tolua_S,3,0)); float width = ((float) tolua_tonumber(tolua_S,4,0)); float height = ((float) tolua_tonumber(tolua_S,5,0)); float sourceWidth = ((float) tolua_tonumber(tolua_S,6,0)); float sourceHeight = ((float) tolua_tonumber(tolua_S,7,0)); bool flipX = ((bool) tolua_toboolean(tolua_S,8,0)); bool flipY = ((bool) tolua_toboolean(tolua_S,9,0)); wyRect texRect = *((wyRect*) tolua_tousertype(tolua_S,10,0)); bool rotatedZwoptex = ((bool) tolua_toboolean(tolua_S,11,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'draw'", NULL); #endif { self->draw(x,y,width,height,sourceWidth,sourceHeight,flipX,flipY,texRect,rotatedZwoptex); } } return 0; tolua_lerror: return tolua_opengl_wyTexture2D_draw05(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: getWidth of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_getWidth00 static int tolua_opengl_wyTexture2D_getWidth00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'", NULL); #endif { float tolua_ret = (float) self->getWidth(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getHeight of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_getHeight00 static int tolua_opengl_wyTexture2D_getHeight00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'", NULL); #endif { float tolua_ret = (float) self->getHeight(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getPixelWidth of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_getPixelWidth00 static int tolua_opengl_wyTexture2D_getPixelWidth00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelWidth'", NULL); #endif { int tolua_ret = (int) self->getPixelWidth(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getPixelWidth'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getPixelHeight of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_getPixelHeight00 static int tolua_opengl_wyTexture2D_getPixelHeight00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelHeight'", NULL); #endif { int tolua_ret = (int) self->getPixelHeight(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getPixelHeight'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getWidthScale of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_getWidthScale00 static int tolua_opengl_wyTexture2D_getWidthScale00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidthScale'", NULL); #endif { float tolua_ret = (float) self->getWidthScale(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getWidthScale'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getHeightScale of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_getHeightScale00 static int tolua_opengl_wyTexture2D_getHeightScale00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeightScale'", NULL); #endif { float tolua_ret = (float) self->getHeightScale(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getHeightScale'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getTexture of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_getTexture00 static int tolua_opengl_wyTexture2D_getTexture00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTexture'", NULL); #endif { int tolua_ret = (int) self->getTexture(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getTexture'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getText of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_getText00 static int tolua_opengl_wyTexture2D_getText00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getText'", NULL); #endif { const char* tolua_ret = (const char*) self->getText(); tolua_pushstring(tolua_S,(const char*)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getText'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getSource of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_getSource00 static int tolua_opengl_wyTexture2D_getSource00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getSource'", NULL); #endif { wyTextureSource tolua_ret = (wyTextureSource) self->getSource(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getSource'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: isFlipY of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_isFlipY00 static int tolua_opengl_wyTexture2D_isFlipY00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isFlipY'", NULL); #endif { bool tolua_ret = (bool) self->isFlipY(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isFlipY'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: isFlipX of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_isFlipX00 static int tolua_opengl_wyTexture2D_isFlipX00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isFlipX'", NULL); #endif { bool tolua_ret = (bool) self->isFlipX(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isFlipX'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setFlipX of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_setFlipX00 static int tolua_opengl_wyTexture2D_setFlipX00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isboolean(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); bool flipX = ((bool) tolua_toboolean(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFlipX'", NULL); #endif { self->setFlipX(flipX); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setFlipX'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setFlipY of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_setFlipY00 static int tolua_opengl_wyTexture2D_setFlipY00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isboolean(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); bool flipY = ((bool) tolua_toboolean(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setFlipY'", NULL); #endif { self->setFlipY(flipY); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setFlipY'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: updateRaw of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_updateRaw00 static int tolua_opengl_wyTexture2D_updateRaw00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); const char* raw = ((const char*) tolua_tostring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'updateRaw'", NULL); #endif { self->updateRaw(raw); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'updateRaw'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setColorFilter of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_setColorFilter00 static int tolua_opengl_wyTexture2D_setColorFilter00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"wyColorFilter",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); wyColorFilter* filter = ((wyColorFilter*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColorFilter'", NULL); #endif { self->setColorFilter(filter); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setColorFilter'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: applyFilter of class wyTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTexture2D_applyFilter00 static int tolua_opengl_wyTexture2D_applyFilter00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* self = (wyTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'applyFilter'", NULL); #endif { self->applyFilter(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'applyFilter'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: delete of class wyGLTexture2D */ #ifndef TOLUA_DISABLE_tolua_opengl_wyGLTexture2D_delete00 static int tolua_opengl_wyGLTexture2D_delete00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyGLTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyGLTexture2D* self = (wyGLTexture2D*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL); #endif Mtolua_delete(self); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawPoint */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawPoint00 static int tolua_opengl_wyDrawPoint00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { float x = ((float) tolua_tonumber(tolua_S,1,0)); float y = ((float) tolua_tonumber(tolua_S,2,0)); { wyDrawPoint(x,y); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawPoint'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawPoints */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawPoints00 static int tolua_opengl_wyDrawPoints00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"size_t",0,&tolua_err)) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { float p = ((float) tolua_tonumber(tolua_S,1,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,2,0)); { wyDrawPoints(&p,length); tolua_pushnumber(tolua_S,(lua_Number)p); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawPoints'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawLine */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawLine00 static int tolua_opengl_wyDrawLine00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { float x1 = ((float) tolua_tonumber(tolua_S,1,0)); float y1 = ((float) tolua_tonumber(tolua_S,2,0)); float x2 = ((float) tolua_tonumber(tolua_S,3,0)); float y2 = ((float) tolua_tonumber(tolua_S,4,0)); { wyDrawLine(x1,y1,x2,y2); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawLine'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawPath */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawPath00 static int tolua_opengl_wyDrawPath00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"size_t",0,&tolua_err)) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { float points = ((float) tolua_tonumber(tolua_S,1,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,2,0)); { wyDrawPath(&points,length); tolua_pushnumber(tolua_S,(lua_Number)points); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawPath'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawDashPath */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawDashPath00 static int tolua_opengl_wyDrawDashPath00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"size_t",0,&tolua_err)) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { float points = ((float) tolua_tonumber(tolua_S,1,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,2,0)); float dashLength = ((float) tolua_tonumber(tolua_S,3,0)); { wyDrawDashPath(&points,length,dashLength); tolua_pushnumber(tolua_S,(lua_Number)points); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawDashPath'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawDashLine */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawDashLine00 static int tolua_opengl_wyDrawDashLine00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnoobj(tolua_S,6,&tolua_err) ) goto tolua_lerror; else #endif { float x1 = ((float) tolua_tonumber(tolua_S,1,0)); float y1 = ((float) tolua_tonumber(tolua_S,2,0)); float x2 = ((float) tolua_tonumber(tolua_S,3,0)); float y2 = ((float) tolua_tonumber(tolua_S,4,0)); float dashLength = ((float) tolua_tonumber(tolua_S,5,0)); { wyDrawDashLine(x1,y1,x2,y2,dashLength); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawDashLine'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawPoly */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawPoly00 static int tolua_opengl_wyDrawPoly00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"size_t",0,&tolua_err)) || !tolua_isboolean(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { float p = ((float) tolua_tonumber(tolua_S,1,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,2,0)); bool close = ((bool) tolua_toboolean(tolua_S,3,0)); { wyDrawPoly(&p,length,close); tolua_pushnumber(tolua_S,(lua_Number)p); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawPoly'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawRect */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawRect00 static int tolua_opengl_wyDrawRect00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { float p = ((float) tolua_tonumber(tolua_S,1,0)); { wyDrawRect(&p); tolua_pushnumber(tolua_S,(lua_Number)p); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawRect'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawRect2 */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawRect200 static int tolua_opengl_wyDrawRect200(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( (tolua_isvaluenil(tolua_S,1,&tolua_err) || !tolua_isusertype(tolua_S,1,"wyRect",0,&tolua_err)) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyRect* r = ((wyRect*) tolua_tousertype(tolua_S,1,0)); { wyDrawRect2(*r); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawRect2'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawCircle */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawCircle00 static int tolua_opengl_wyDrawCircle00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isboolean(tolua_S,6,0,&tolua_err) || !tolua_isnoobj(tolua_S,7,&tolua_err) ) goto tolua_lerror; else #endif { float centerX = ((float) tolua_tonumber(tolua_S,1,0)); float centerY = ((float) tolua_tonumber(tolua_S,2,0)); float r = ((float) tolua_tonumber(tolua_S,3,0)); float radiusLineAngle = ((float) tolua_tonumber(tolua_S,4,0)); int segments = ((int) tolua_tonumber(tolua_S,5,0)); bool drawLineToCenter = ((bool) tolua_toboolean(tolua_S,6,0)); { wyDrawCircle(centerX,centerY,r,radiusLineAngle,segments,drawLineToCenter); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawCircle'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawBezier */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawBezier00 static int tolua_opengl_wyDrawBezier00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( (tolua_isvaluenil(tolua_S,1,&tolua_err) || !tolua_isusertype(tolua_S,1,"wyBezierConfig",0,&tolua_err)) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyBezierConfig* c = ((wyBezierConfig*) tolua_tousertype(tolua_S,1,0)); int segments = ((int) tolua_tonumber(tolua_S,2,0)); { wyDrawBezier(*c,segments); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawBezier'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawLagrange */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawLagrange00 static int tolua_opengl_wyDrawLagrange00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( (tolua_isvaluenil(tolua_S,1,&tolua_err) || !tolua_isusertype(tolua_S,1,"wyLagrangeConfig",0,&tolua_err)) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyLagrangeConfig* c = ((wyLagrangeConfig*) tolua_tousertype(tolua_S,1,0)); int segments = ((int) tolua_tonumber(tolua_S,2,0)); { wyDrawLagrange(*c,segments); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawLagrange'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawTexture */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawTexture00 static int tolua_opengl_wyDrawTexture00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnumber(tolua_S,6,0,&tolua_err) || !tolua_isnumber(tolua_S,7,0,&tolua_err) || !tolua_isboolean(tolua_S,8,0,&tolua_err) || !tolua_isboolean(tolua_S,9,0,&tolua_err) || !tolua_isnoobj(tolua_S,10,&tolua_err) ) goto tolua_lerror; else #endif { int texture = ((int) tolua_tonumber(tolua_S,1,0)); float texW = ((float) tolua_tonumber(tolua_S,2,0)); float texH = ((float) tolua_tonumber(tolua_S,3,0)); float x = ((float) tolua_tonumber(tolua_S,4,0)); float y = ((float) tolua_tonumber(tolua_S,5,0)); float w = ((float) tolua_tonumber(tolua_S,6,0)); float h = ((float) tolua_tonumber(tolua_S,7,0)); bool flipX = ((bool) tolua_toboolean(tolua_S,8,0)); bool flipY = ((bool) tolua_toboolean(tolua_S,9,0)); { wyDrawTexture(texture,texW,texH,x,y,w,h,flipX,flipY); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawTexture'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawTexture2 */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawTexture200 static int tolua_opengl_wyDrawTexture200(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"wyRect",0,&tolua_err)) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnumber(tolua_S,5,0,&tolua_err) || !tolua_isnumber(tolua_S,6,0,&tolua_err) || !tolua_isnumber(tolua_S,7,0,&tolua_err) || !tolua_isnumber(tolua_S,8,0,&tolua_err) || !tolua_isboolean(tolua_S,9,0,&tolua_err) || !tolua_isboolean(tolua_S,10,0,&tolua_err) || !tolua_isnoobj(tolua_S,11,&tolua_err) ) goto tolua_lerror; else #endif { int texture = ((int) tolua_tonumber(tolua_S,1,0)); wyRect texRect = *((wyRect*) tolua_tousertype(tolua_S,2,0)); float texW = ((float) tolua_tonumber(tolua_S,3,0)); float texH = ((float) tolua_tonumber(tolua_S,4,0)); float x = ((float) tolua_tonumber(tolua_S,5,0)); float y = ((float) tolua_tonumber(tolua_S,6,0)); float w = ((float) tolua_tonumber(tolua_S,7,0)); float h = ((float) tolua_tonumber(tolua_S,8,0)); bool flipX = ((bool) tolua_toboolean(tolua_S,9,0)); bool flipY = ((bool) tolua_toboolean(tolua_S,10,0)); { wyDrawTexture2(texture,texRect,texW,texH,x,y,w,h,flipX,flipY); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawTexture2'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawSolidPoly */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawSolidPoly00 static int tolua_opengl_wyDrawSolidPoly00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"size_t",0,&tolua_err)) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"wyColor4B",0,&tolua_err)) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { float p = ((float) tolua_tonumber(tolua_S,1,0)); size_t length = *((size_t*) tolua_tousertype(tolua_S,2,0)); wyColor4B color = *((wyColor4B*) tolua_tousertype(tolua_S,3,0)); { wyDrawSolidPoly(&p,length,color); tolua_pushnumber(tolua_S,(lua_Number)p); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawSolidPoly'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* function: wyDrawSolidRect */ #ifndef TOLUA_DISABLE_tolua_opengl_wyDrawSolidRect00 static int tolua_opengl_wyDrawSolidRect00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnumber(tolua_S,1,0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"wyColor4B",0,&tolua_err)) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { float p = ((float) tolua_tonumber(tolua_S,1,0)); wyColor4B color = *((wyColor4B*) tolua_tousertype(tolua_S,2,0)); { wyDrawSolidRect(&p,color); tolua_pushnumber(tolua_S,(lua_Number)p); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'wyDrawSolidRect'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getInstance of class wyTextureManager */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureManager_getInstance00 static int tolua_opengl_wyTextureManager_getInstance00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTextureManager",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { wyTextureManager* tolua_ret = (wyTextureManager*) wyTextureManager::getInstance(); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTextureManager"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getInstance'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: delete of class wyTextureManager */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureManager_delete00 static int tolua_opengl_wyTextureManager_delete00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureManager",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureManager* self = (wyTextureManager*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL); #endif Mtolua_delete(self); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: removeAllTextures of class wyTextureManager */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureManager_removeAllTextures00 static int tolua_opengl_wyTextureManager_removeAllTextures00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureManager",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureManager* self = (wyTextureManager*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeAllTextures'", NULL); #endif { self->removeAllTextures(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'removeAllTextures'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: removeTexture of class wyTextureManager */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureManager_removeTexture00 static int tolua_opengl_wyTextureManager_removeTexture00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureManager",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureManager* self = (wyTextureManager*) tolua_tousertype(tolua_S,1,0); int resId = ((int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeTexture'", NULL); #endif { self->removeTexture(resId); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'removeTexture'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: removeTexture of class wyTextureManager */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureManager_removeTexture01 static int tolua_opengl_wyTextureManager_removeTexture01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureManager",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else { wyTextureManager* self = (wyTextureManager*) tolua_tousertype(tolua_S,1,0); const char* name = ((const char*) tolua_tostring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeTexture'", NULL); #endif { self->removeTexture(name); } } return 0; tolua_lerror: return tolua_opengl_wyTextureManager_removeTexture00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: removeTexture of class wyTextureManager */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureManager_removeTexture02 static int tolua_opengl_wyTextureManager_removeTexture02(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureManager",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"wyTexture2D",0,&tolua_err) || !tolua_isboolean(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else { wyTextureManager* self = (wyTextureManager*) tolua_tousertype(tolua_S,1,0); wyTexture2D* tex = ((wyTexture2D*) tolua_tousertype(tolua_S,2,0)); bool removeHandle = ((bool) tolua_toboolean(tolua_S,3,false)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeTexture'", NULL); #endif { self->removeTexture(tex,removeHandle); } } return 0; tolua_lerror: return tolua_opengl_wyTextureManager_removeTexture01(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: setTexturePixelFormat of class wyTextureManager */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureManager_setTexturePixelFormat00 static int tolua_opengl_wyTextureManager_setTexturePixelFormat00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureManager",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureManager* self = (wyTextureManager*) tolua_tousertype(tolua_S,1,0); wyTexturePixelFormat pixelFormat = ((wyTexturePixelFormat) (int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTexturePixelFormat'", NULL); #endif { self->setTexturePixelFormat(pixelFormat); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setTexturePixelFormat'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getTexturePixelFormat of class wyTextureManager */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureManager_getTexturePixelFormat00 static int tolua_opengl_wyTextureManager_getTexturePixelFormat00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureManager",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureManager* self = (wyTextureManager*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTexturePixelFormat'", NULL); #endif { wyTexturePixelFormat tolua_ret = (wyTexturePixelFormat) self->getTexturePixelFormat(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getTexturePixelFormat'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: make of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_make00 static int tolua_opengl_wyTextureAtlas_make00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* tex = ((wyTexture2D*) tolua_tousertype(tolua_S,2,0)); { wyTextureAtlas* tolua_ret = (wyTextureAtlas*) wyTextureAtlas::make(tex); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTextureAtlas"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'make'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_new00 static int tolua_opengl_wyTextureAtlas_new00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* tex = ((wyTexture2D*) tolua_tousertype(tolua_S,2,0)); int capacity = ((int) tolua_tonumber(tolua_S,3,ATLAS_DEFAULT_CAPACITY)); { wyTextureAtlas* tolua_ret = (wyTextureAtlas*) Mtolua_new((wyTextureAtlas)(tex,capacity)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTextureAtlas"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: new_local of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_new00_local static int tolua_opengl_wyTextureAtlas_new00_local(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"wyTexture2D",0,&tolua_err) || !tolua_isnumber(tolua_S,3,1,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { wyTexture2D* tex = ((wyTexture2D*) tolua_tousertype(tolua_S,2,0)); int capacity = ((int) tolua_tonumber(tolua_S,3,ATLAS_DEFAULT_CAPACITY)); { wyTextureAtlas* tolua_ret = (wyTextureAtlas*) Mtolua_new((wyTextureAtlas)(tex,capacity)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTextureAtlas"); tolua_register_gc(tolua_S,lua_gettop(tolua_S)); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: delete of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_delete00 static int tolua_opengl_wyTextureAtlas_delete00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'delete'", NULL); #endif Mtolua_delete(self); } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'delete'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setTexture of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_setTexture00 static int tolua_opengl_wyTextureAtlas_setTexture00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isusertype(tolua_S,2,"wyTexture2D",0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); wyTexture2D* tex = ((wyTexture2D*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setTexture'", NULL); #endif { self->setTexture(tex); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setTexture'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getTexture of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_getTexture00 static int tolua_opengl_wyTextureAtlas_getTexture00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTexture'", NULL); #endif { wyTexture2D* tolua_ret = (wyTexture2D*) self->getTexture(); tolua_pushusertype(tolua_S,(void*)tolua_ret,"wyTexture2D"); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getTexture'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: resizeCapacity of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_resizeCapacity00 static int tolua_opengl_wyTextureAtlas_resizeCapacity00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); int newCapacity = ((int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'resizeCapacity'", NULL); #endif { self->resizeCapacity(newCapacity); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'resizeCapacity'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: removeAllQuads of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_removeAllQuads00 static int tolua_opengl_wyTextureAtlas_removeAllQuads00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeAllQuads'", NULL); #endif { self->removeAllQuads(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'removeAllQuads'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getNextAvailableIndex of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_getNextAvailableIndex00 static int tolua_opengl_wyTextureAtlas_getNextAvailableIndex00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getNextAvailableIndex'", NULL); #endif { int tolua_ret = (int) self->getNextAvailableIndex(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getNextAvailableIndex'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: updateQuad of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_updateQuad00 static int tolua_opengl_wyTextureAtlas_updateQuad00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"wyQuad2D",0,&tolua_err)) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"wyQuad3D",0,&tolua_err)) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); wyQuad2D* quadT = ((wyQuad2D*) tolua_tousertype(tolua_S,2,0)); wyQuad3D* quadV = ((wyQuad3D*) tolua_tousertype(tolua_S,3,0)); int index = ((int) tolua_tonumber(tolua_S,4,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'updateQuad'", NULL); #endif { self->updateQuad(*quadT,*quadV,index); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'updateQuad'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: updateColor of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_updateColor00 static int tolua_opengl_wyTextureAtlas_updateColor00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"wyColor4B",0,&tolua_err)) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); wyColor4B color = *((wyColor4B*) tolua_tousertype(tolua_S,2,0)); int index = ((int) tolua_tonumber(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'updateColor'", NULL); #endif { self->updateColor(color,index); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'updateColor'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: appendQuad of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_appendQuad00 static int tolua_opengl_wyTextureAtlas_appendQuad00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"wyQuad2D",0,&tolua_err)) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"wyQuad3D",0,&tolua_err)) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); wyQuad2D* quadT = ((wyQuad2D*) tolua_tousertype(tolua_S,2,0)); wyQuad3D* quadV = ((wyQuad3D*) tolua_tousertype(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'appendQuad'", NULL); #endif { int tolua_ret = (int) self->appendQuad(*quadT,*quadV); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'appendQuad'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: insertQuad of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_insertQuad00 static int tolua_opengl_wyTextureAtlas_insertQuad00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"wyQuad2D",0,&tolua_err)) || (tolua_isvaluenil(tolua_S,3,&tolua_err) || !tolua_isusertype(tolua_S,3,"wyQuad3D",0,&tolua_err)) || !tolua_isnumber(tolua_S,4,0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); wyQuad2D* quadT = ((wyQuad2D*) tolua_tousertype(tolua_S,2,0)); wyQuad3D* quadV = ((wyQuad3D*) tolua_tousertype(tolua_S,3,0)); int index = ((int) tolua_tonumber(tolua_S,4,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'insertQuad'", NULL); #endif { self->insertQuad(*quadT,*quadV,index); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'insertQuad'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: removeQuad of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_removeQuad00 static int tolua_opengl_wyTextureAtlas_removeQuad00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); int index = ((int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeQuad'", NULL); #endif { self->removeQuad(index); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'removeQuad'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: removeQuads of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_removeQuads00 static int tolua_opengl_wyTextureAtlas_removeQuads00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); int start = ((int) tolua_tonumber(tolua_S,2,0)); int count = ((int) tolua_tonumber(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'removeQuads'", NULL); #endif { self->removeQuads(start,count); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'removeQuads'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: copyTo of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_copyTo00 static int tolua_opengl_wyTextureAtlas_copyTo00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isusertype(tolua_S,3,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); int from = ((int) tolua_tonumber(tolua_S,2,0)); wyTextureAtlas* destAtlas = ((wyTextureAtlas*) tolua_tousertype(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'copyTo'", NULL); #endif { self->copyTo(from,destAtlas); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'copyTo'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: copyTo of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_copyTo01 static int tolua_opengl_wyTextureAtlas_copyTo01(lua_State* tolua_S) { tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isusertype(tolua_S,3,"wyQuad2D",0,&tolua_err) || !tolua_isusertype(tolua_S,4,"wyQuad3D",0,&tolua_err) || !tolua_isnoobj(tolua_S,5,&tolua_err) ) goto tolua_lerror; else { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); int from = ((int) tolua_tonumber(tolua_S,2,0)); wyQuad2D* quadT = ((wyQuad2D*) tolua_tousertype(tolua_S,3,0)); wyQuad3D* quadV = ((wyQuad3D*) tolua_tousertype(tolua_S,4,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'copyTo'", NULL); #endif { self->copyTo(from,quadT,quadV); } } return 0; tolua_lerror: return tolua_opengl_wyTextureAtlas_copyTo00(tolua_S); } #endif //#ifndef TOLUA_DISABLE /* method: drawOne of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_drawOne00 static int tolua_opengl_wyTextureAtlas_drawOne00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); int index = ((int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'drawOne'", NULL); #endif { self->drawOne(index); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawOne'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: draw of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_draw00 static int tolua_opengl_wyTextureAtlas_draw00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); int numOfQuads = ((int) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'draw'", NULL); #endif { self->draw(numOfQuads); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'draw'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: drawRange of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_drawRange00 static int tolua_opengl_wyTextureAtlas_drawRange00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnumber(tolua_S,3,0,&tolua_err) || !tolua_isnoobj(tolua_S,4,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); int start = ((int) tolua_tonumber(tolua_S,2,0)); int numOfQuads = ((int) tolua_tonumber(tolua_S,3,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'drawRange'", NULL); #endif { self->drawRange(start,numOfQuads); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawRange'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: drawAll of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_drawAll00 static int tolua_opengl_wyTextureAtlas_drawAll00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'drawAll'", NULL); #endif { self->drawAll(); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'drawAll'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getTotalQuads of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_getTotalQuads00 static int tolua_opengl_wyTextureAtlas_getTotalQuads00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getTotalQuads'", NULL); #endif { int tolua_ret = (int) self->getTotalQuads(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getTotalQuads'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: isWithColorArray of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_isWithColorArray00 static int tolua_opengl_wyTextureAtlas_isWithColorArray00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'isWithColorArray'", NULL); #endif { bool tolua_ret = (bool) self->isWithColorArray(); tolua_pushboolean(tolua_S,(bool)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'isWithColorArray'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getCapacity of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_getCapacity00 static int tolua_opengl_wyTextureAtlas_getCapacity00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getCapacity'", NULL); #endif { int tolua_ret = (int) self->getCapacity(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getCapacity'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getPixelHeight of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_getPixelHeight00 static int tolua_opengl_wyTextureAtlas_getPixelHeight00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelHeight'", NULL); #endif { int tolua_ret = (int) self->getPixelHeight(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getPixelHeight'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getPixelWidth of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_getPixelWidth00 static int tolua_opengl_wyTextureAtlas_getPixelWidth00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getPixelWidth'", NULL); #endif { int tolua_ret = (int) self->getPixelWidth(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getPixelWidth'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getWidth of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_getWidth00 static int tolua_opengl_wyTextureAtlas_getWidth00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidth'", NULL); #endif { float tolua_ret = (float) self->getWidth(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getWidth'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getHeight of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_getHeight00 static int tolua_opengl_wyTextureAtlas_getHeight00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeight'", NULL); #endif { float tolua_ret = (float) self->getHeight(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getHeight'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getWidthScale of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_getWidthScale00 static int tolua_opengl_wyTextureAtlas_getWidthScale00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getWidthScale'", NULL); #endif { float tolua_ret = (float) self->getWidthScale(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getWidthScale'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: getHeightScale of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_getHeightScale00 static int tolua_opengl_wyTextureAtlas_getHeightScale00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getHeightScale'", NULL); #endif { float tolua_ret = (float) self->getHeightScale(); tolua_pushnumber(tolua_S,(lua_Number)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getHeightScale'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: setColor of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_setColor00 static int tolua_opengl_wyTextureAtlas_setColor00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || (tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"wyColor4B",0,&tolua_err)) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); wyColor4B color = *((wyColor4B*) tolua_tousertype(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setColor'", NULL); #endif { self->setColor(color); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setColor'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* method: reduceAlpha of class wyTextureAtlas */ #ifndef TOLUA_DISABLE_tolua_opengl_wyTextureAtlas_reduceAlpha00 static int tolua_opengl_wyTextureAtlas_reduceAlpha00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"wyTextureAtlas",0,&tolua_err) || !tolua_isnumber(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { wyTextureAtlas* self = (wyTextureAtlas*) tolua_tousertype(tolua_S,1,0); float delta = ((float) tolua_tonumber(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'reduceAlpha'", NULL); #endif { self->reduceAlpha(delta); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'reduceAlpha'.",&tolua_err); return 0; #endif } #endif //#ifndef TOLUA_DISABLE /* Open function */ TOLUA_API int tolua_opengl_open (lua_State* tolua_S) { tolua_open(tolua_S); tolua_reg_types(tolua_S); tolua_module(tolua_S,NULL,0); tolua_beginmodule(tolua_S,NULL); tolua_constant(tolua_S,"wyTexture2D::LEFT",wyTexture2D::LEFT); tolua_constant(tolua_S,"wyTexture2D::CENTER",wyTexture2D::CENTER); tolua_constant(tolua_S,"wyTexture2D::RIGHT",wyTexture2D::RIGHT); #ifdef __cplusplus tolua_cclass(tolua_S,"wyCamera","wyCamera","wyObject",tolua_collect_wyCamera); #else tolua_cclass(tolua_S,"wyCamera","wyCamera","wyObject",NULL); #endif tolua_beginmodule(tolua_S,"wyCamera"); tolua_function(tolua_S,"getZEye",tolua_opengl_wyCamera_getZEye00); tolua_function(tolua_S,"make",tolua_opengl_wyCamera_make00); tolua_function(tolua_S,"delete",tolua_opengl_wyCamera_delete00); tolua_function(tolua_S,"restore",tolua_opengl_wyCamera_restore00); tolua_function(tolua_S,"locate",tolua_opengl_wyCamera_locate00); tolua_function(tolua_S,"setEye",tolua_opengl_wyCamera_setEye00); tolua_function(tolua_S,"setCenter",tolua_opengl_wyCamera_setCenter00); tolua_function(tolua_S,"setUp",tolua_opengl_wyCamera_setUp00); tolua_function(tolua_S,"getEye",tolua_opengl_wyCamera_getEye00); tolua_function(tolua_S,"getCenter",tolua_opengl_wyCamera_getCenter00); tolua_function(tolua_S,"getUp",tolua_opengl_wyCamera_getUp00); tolua_function(tolua_S,"isDirty",tolua_opengl_wyCamera_isDirty00); tolua_function(tolua_S,"setDirty",tolua_opengl_wyCamera_setDirty00); tolua_endmodule(tolua_S); #ifdef __cplusplus tolua_cclass(tolua_S,"wyTexture2D","wyTexture2D","wyObject",tolua_collect_wyTexture2D); #else tolua_cclass(tolua_S,"wyTexture2D","wyTexture2D","wyObject",NULL); #endif tolua_beginmodule(tolua_S,"wyTexture2D"); tolua_function(tolua_S,"makeBMP",tolua_opengl_wyTexture2D_makeBMP00); tolua_function(tolua_S,"makeBMP",tolua_opengl_wyTexture2D_makeBMP01); tolua_function(tolua_S,"makeBMP",tolua_opengl_wyTexture2D_makeBMP02); tolua_function(tolua_S,"makeBMP",tolua_opengl_wyTexture2D_makeBMP03); tolua_function(tolua_S,"makeBMP",tolua_opengl_wyTexture2D_makeBMP04); tolua_function(tolua_S,"makeBMP",tolua_opengl_wyTexture2D_makeBMP05); tolua_function(tolua_S,"makeBMP",tolua_opengl_wyTexture2D_makeBMP06); tolua_function(tolua_S,"makeRawBMP",tolua_opengl_wyTexture2D_makeRawBMP00); tolua_function(tolua_S,"makeRawBMP",tolua_opengl_wyTexture2D_makeRawBMP01); tolua_function(tolua_S,"makeRawBMP",tolua_opengl_wyTexture2D_makeRawBMP02); tolua_function(tolua_S,"makeRawBMP",tolua_opengl_wyTexture2D_makeRawBMP03); tolua_function(tolua_S,"makeMemoryBMP",tolua_opengl_wyTexture2D_makeMemoryBMP00); tolua_function(tolua_S,"makeMemoryBMP",tolua_opengl_wyTexture2D_makeMemoryBMP01); tolua_function(tolua_S,"makeMemoryBMP",tolua_opengl_wyTexture2D_makeMemoryBMP02); tolua_function(tolua_S,"makeMemoryBMP",tolua_opengl_wyTexture2D_makeMemoryBMP03); tolua_function(tolua_S,"makeFileBMP",tolua_opengl_wyTexture2D_makeFileBMP00); tolua_function(tolua_S,"makeFileBMP",tolua_opengl_wyTexture2D_makeFileBMP01); tolua_function(tolua_S,"makeFileBMP",tolua_opengl_wyTexture2D_makeFileBMP02); tolua_function(tolua_S,"makeFileBMP",tolua_opengl_wyTexture2D_makeFileBMP03); tolua_function(tolua_S,"makeJPG",tolua_opengl_wyTexture2D_makeJPG00); tolua_function(tolua_S,"makeJPG",tolua_opengl_wyTexture2D_makeJPG01); tolua_function(tolua_S,"makeJPG",tolua_opengl_wyTexture2D_makeJPG02); tolua_function(tolua_S,"makeJPG",tolua_opengl_wyTexture2D_makeJPG03); tolua_function(tolua_S,"makeJPG",tolua_opengl_wyTexture2D_makeJPG04); tolua_function(tolua_S,"makeJPG",tolua_opengl_wyTexture2D_makeJPG05); tolua_function(tolua_S,"makeJPG",tolua_opengl_wyTexture2D_makeJPG06); tolua_function(tolua_S,"makeRawJPG",tolua_opengl_wyTexture2D_makeRawJPG00); tolua_function(tolua_S,"makeRawJPG",tolua_opengl_wyTexture2D_makeRawJPG01); tolua_function(tolua_S,"makeRawJPG",tolua_opengl_wyTexture2D_makeRawJPG02); tolua_function(tolua_S,"makeRawJPG",tolua_opengl_wyTexture2D_makeRawJPG03); tolua_function(tolua_S,"makeMemoryJPG",tolua_opengl_wyTexture2D_makeMemoryJPG00); tolua_function(tolua_S,"makeMemoryJPG",tolua_opengl_wyTexture2D_makeMemoryJPG01); tolua_function(tolua_S,"makeMemoryJPG",tolua_opengl_wyTexture2D_makeMemoryJPG02); tolua_function(tolua_S,"makeMemoryJPG",tolua_opengl_wyTexture2D_makeMemoryJPG03); tolua_function(tolua_S,"makeFileJPG",tolua_opengl_wyTexture2D_makeFileJPG00); tolua_function(tolua_S,"makeFileJPG",tolua_opengl_wyTexture2D_makeFileJPG01); tolua_function(tolua_S,"makeFileJPG",tolua_opengl_wyTexture2D_makeFileJPG02); tolua_function(tolua_S,"makeFileJPG",tolua_opengl_wyTexture2D_makeFileJPG03); tolua_function(tolua_S,"makePNG",tolua_opengl_wyTexture2D_makePNG00); tolua_function(tolua_S,"makePNG",tolua_opengl_wyTexture2D_makePNG01); tolua_function(tolua_S,"makePNG",tolua_opengl_wyTexture2D_makePNG02); tolua_function(tolua_S,"makePNG",tolua_opengl_wyTexture2D_makePNG03); tolua_function(tolua_S,"makePNG",tolua_opengl_wyTexture2D_makePNG04); tolua_function(tolua_S,"makeRawPNG",tolua_opengl_wyTexture2D_makeRawPNG00); tolua_function(tolua_S,"makeRawPNG",tolua_opengl_wyTexture2D_makeRawPNG01); tolua_function(tolua_S,"makeRawPNG",tolua_opengl_wyTexture2D_makeRawPNG02); tolua_function(tolua_S,"makeMemoryPNG",tolua_opengl_wyTexture2D_makeMemoryPNG00); tolua_function(tolua_S,"makeMemoryPNG",tolua_opengl_wyTexture2D_makeMemoryPNG01); tolua_function(tolua_S,"makeMemoryPNG",tolua_opengl_wyTexture2D_makeMemoryPNG02); tolua_function(tolua_S,"makeFilePNG",tolua_opengl_wyTexture2D_makeFilePNG00); tolua_function(tolua_S,"makeFilePNG",tolua_opengl_wyTexture2D_makeFilePNG01); tolua_function(tolua_S,"makeFilePNG",tolua_opengl_wyTexture2D_makeFilePNG02); tolua_function(tolua_S,"makePVR",tolua_opengl_wyTexture2D_makePVR00); tolua_function(tolua_S,"makePVR",tolua_opengl_wyTexture2D_makePVR01); tolua_function(tolua_S,"makeRawPVR",tolua_opengl_wyTexture2D_makeRawPVR00); tolua_function(tolua_S,"makeMemoryPVR",tolua_opengl_wyTexture2D_makeMemoryPVR00); tolua_function(tolua_S,"makeFilePVR",tolua_opengl_wyTexture2D_makeFilePVR00); tolua_function(tolua_S,"makeLabel",tolua_opengl_wyTexture2D_makeLabel00); tolua_function(tolua_S,"makeLabel",tolua_opengl_wyTexture2D_makeLabel01); tolua_function(tolua_S,"makeGL",tolua_opengl_wyTexture2D_makeGL00); tolua_function(tolua_S,"makeRaw",tolua_opengl_wyTexture2D_makeRaw00); tolua_function(tolua_S,"makeRaw",tolua_opengl_wyTexture2D_makeRaw01); tolua_function(tolua_S,"new",tolua_opengl_wyTexture2D_new00); tolua_function(tolua_S,"new_local",tolua_opengl_wyTexture2D_new00_local); tolua_function(tolua_S,".call",tolua_opengl_wyTexture2D_new00_local); tolua_function(tolua_S,"delete",tolua_opengl_wyTexture2D_delete00); tolua_function(tolua_S,"load",tolua_opengl_wyTexture2D_load00); tolua_function(tolua_S,"updateLabel",tolua_opengl_wyTexture2D_updateLabel00); tolua_function(tolua_S,"updateLabel",tolua_opengl_wyTexture2D_updateLabel01); tolua_function(tolua_S,"updateLabel",tolua_opengl_wyTexture2D_updateLabel02); tolua_function(tolua_S,"setAntiAlias",tolua_opengl_wyTexture2D_setAntiAlias00); tolua_function(tolua_S,"setRepeat",tolua_opengl_wyTexture2D_setRepeat00); tolua_function(tolua_S,"setParameters",tolua_opengl_wyTexture2D_setParameters00); tolua_function(tolua_S,"applyParameters",tolua_opengl_wyTexture2D_applyParameters00); tolua_function(tolua_S,"hasPremultipliedAlpha",tolua_opengl_wyTexture2D_hasPremultipliedAlpha00); tolua_function(tolua_S,"draw",tolua_opengl_wyTexture2D_draw00); tolua_function(tolua_S,"draw",tolua_opengl_wyTexture2D_draw01); tolua_function(tolua_S,"draw",tolua_opengl_wyTexture2D_draw02); tolua_function(tolua_S,"draw",tolua_opengl_wyTexture2D_draw03); tolua_function(tolua_S,"draw",tolua_opengl_wyTexture2D_draw04); tolua_function(tolua_S,"draw",tolua_opengl_wyTexture2D_draw05); tolua_function(tolua_S,"draw",tolua_opengl_wyTexture2D_draw06); tolua_function(tolua_S,"getWidth",tolua_opengl_wyTexture2D_getWidth00); tolua_function(tolua_S,"getHeight",tolua_opengl_wyTexture2D_getHeight00); tolua_function(tolua_S,"getPixelWidth",tolua_opengl_wyTexture2D_getPixelWidth00); tolua_function(tolua_S,"getPixelHeight",tolua_opengl_wyTexture2D_getPixelHeight00); tolua_function(tolua_S,"getWidthScale",tolua_opengl_wyTexture2D_getWidthScale00); tolua_function(tolua_S,"getHeightScale",tolua_opengl_wyTexture2D_getHeightScale00); tolua_function(tolua_S,"getTexture",tolua_opengl_wyTexture2D_getTexture00); tolua_function(tolua_S,"getText",tolua_opengl_wyTexture2D_getText00); tolua_function(tolua_S,"getSource",tolua_opengl_wyTexture2D_getSource00); tolua_function(tolua_S,"isFlipY",tolua_opengl_wyTexture2D_isFlipY00); tolua_function(tolua_S,"isFlipX",tolua_opengl_wyTexture2D_isFlipX00); tolua_function(tolua_S,"setFlipX",tolua_opengl_wyTexture2D_setFlipX00); tolua_function(tolua_S,"setFlipY",tolua_opengl_wyTexture2D_setFlipY00); tolua_function(tolua_S,"updateRaw",tolua_opengl_wyTexture2D_updateRaw00); tolua_function(tolua_S,"setColorFilter",tolua_opengl_wyTexture2D_setColorFilter00); tolua_function(tolua_S,"applyFilter",tolua_opengl_wyTexture2D_applyFilter00); tolua_endmodule(tolua_S); tolua_cclass(tolua_S,"wyEventDispatcher","wyEventDispatcher","",NULL); tolua_beginmodule(tolua_S,"wyEventDispatcher"); tolua_endmodule(tolua_S); tolua_constant(tolua_S,"SOURCE_INVALID",SOURCE_INVALID); tolua_constant(tolua_S,"SOURCE_JPG",SOURCE_JPG); tolua_constant(tolua_S,"SOURCE_PNG",SOURCE_PNG); tolua_constant(tolua_S,"SOURCE_PVR",SOURCE_PVR); tolua_constant(tolua_S,"SOURCE_LABEL",SOURCE_LABEL); tolua_constant(tolua_S,"SOURCE_OPENGL",SOURCE_OPENGL); tolua_constant(tolua_S,"WY_TEXTURE_PIXEL_FORMAT_RGBA8888",WY_TEXTURE_PIXEL_FORMAT_RGBA8888); tolua_constant(tolua_S,"WY_TEXTURE_PIXEL_FORMAT_RGB565",WY_TEXTURE_PIXEL_FORMAT_RGB565); tolua_constant(tolua_S,"WY_TEXTURE_PIXEL_FORMAT_RGBA4444",WY_TEXTURE_PIXEL_FORMAT_RGBA4444); tolua_constant(tolua_S,"WY_TEXTURE_PIXEL_FORMAT_RGBA5551",WY_TEXTURE_PIXEL_FORMAT_RGBA5551); tolua_constant(tolua_S,"WY_TEXTURE_PIXEL_FORMAT_A8",WY_TEXTURE_PIXEL_FORMAT_A8); #ifdef __cplusplus tolua_cclass(tolua_S,"wyGLTexture2D","wyGLTexture2D","wyObject",tolua_collect_wyGLTexture2D); #else tolua_cclass(tolua_S,"wyGLTexture2D","wyGLTexture2D","wyObject",NULL); #endif tolua_beginmodule(tolua_S,"wyGLTexture2D"); tolua_function(tolua_S,"delete",tolua_opengl_wyGLTexture2D_delete00); tolua_endmodule(tolua_S); tolua_function(tolua_S,"wyDrawPoint",tolua_opengl_wyDrawPoint00); tolua_function(tolua_S,"wyDrawPoints",tolua_opengl_wyDrawPoints00); tolua_function(tolua_S,"wyDrawLine",tolua_opengl_wyDrawLine00); tolua_function(tolua_S,"wyDrawPath",tolua_opengl_wyDrawPath00); tolua_function(tolua_S,"wyDrawDashPath",tolua_opengl_wyDrawDashPath00); tolua_function(tolua_S,"wyDrawDashLine",tolua_opengl_wyDrawDashLine00); tolua_function(tolua_S,"wyDrawPoly",tolua_opengl_wyDrawPoly00); tolua_function(tolua_S,"wyDrawRect",tolua_opengl_wyDrawRect00); tolua_function(tolua_S,"wyDrawRect2",tolua_opengl_wyDrawRect200); tolua_function(tolua_S,"wyDrawCircle",tolua_opengl_wyDrawCircle00); tolua_function(tolua_S,"wyDrawBezier",tolua_opengl_wyDrawBezier00); tolua_function(tolua_S,"wyDrawLagrange",tolua_opengl_wyDrawLagrange00); tolua_function(tolua_S,"wyDrawTexture",tolua_opengl_wyDrawTexture00); tolua_function(tolua_S,"wyDrawTexture2",tolua_opengl_wyDrawTexture200); tolua_function(tolua_S,"wyDrawSolidPoly",tolua_opengl_wyDrawSolidPoly00); tolua_function(tolua_S,"wyDrawSolidRect",tolua_opengl_wyDrawSolidRect00); #ifdef __cplusplus tolua_cclass(tolua_S,"wyTextureManager","wyTextureManager","wyObject",tolua_collect_wyTextureManager); #else tolua_cclass(tolua_S,"wyTextureManager","wyTextureManager","wyObject",NULL); #endif tolua_beginmodule(tolua_S,"wyTextureManager"); tolua_function(tolua_S,"getInstance",tolua_opengl_wyTextureManager_getInstance00); tolua_function(tolua_S,"delete",tolua_opengl_wyTextureManager_delete00); tolua_function(tolua_S,"removeAllTextures",tolua_opengl_wyTextureManager_removeAllTextures00); tolua_function(tolua_S,"removeTexture",tolua_opengl_wyTextureManager_removeTexture00); tolua_function(tolua_S,"removeTexture",tolua_opengl_wyTextureManager_removeTexture01); tolua_function(tolua_S,"removeTexture",tolua_opengl_wyTextureManager_removeTexture02); tolua_function(tolua_S,"setTexturePixelFormat",tolua_opengl_wyTextureManager_setTexturePixelFormat00); tolua_function(tolua_S,"getTexturePixelFormat",tolua_opengl_wyTextureManager_getTexturePixelFormat00); tolua_endmodule(tolua_S); tolua_constant(tolua_S,"ATLAS_DEFAULT_CAPACITY",ATLAS_DEFAULT_CAPACITY); #ifdef __cplusplus tolua_cclass(tolua_S,"wyTextureAtlas","wyTextureAtlas","wyObject",tolua_collect_wyTextureAtlas); #else tolua_cclass(tolua_S,"wyTextureAtlas","wyTextureAtlas","wyObject",NULL); #endif tolua_beginmodule(tolua_S,"wyTextureAtlas"); tolua_function(tolua_S,"make",tolua_opengl_wyTextureAtlas_make00); tolua_function(tolua_S,"new",tolua_opengl_wyTextureAtlas_new00); tolua_function(tolua_S,"new_local",tolua_opengl_wyTextureAtlas_new00_local); tolua_function(tolua_S,".call",tolua_opengl_wyTextureAtlas_new00_local); tolua_function(tolua_S,"delete",tolua_opengl_wyTextureAtlas_delete00); tolua_function(tolua_S,"setTexture",tolua_opengl_wyTextureAtlas_setTexture00); tolua_function(tolua_S,"getTexture",tolua_opengl_wyTextureAtlas_getTexture00); tolua_function(tolua_S,"resizeCapacity",tolua_opengl_wyTextureAtlas_resizeCapacity00); tolua_function(tolua_S,"removeAllQuads",tolua_opengl_wyTextureAtlas_removeAllQuads00); tolua_function(tolua_S,"getNextAvailableIndex",tolua_opengl_wyTextureAtlas_getNextAvailableIndex00); tolua_function(tolua_S,"updateQuad",tolua_opengl_wyTextureAtlas_updateQuad00); tolua_function(tolua_S,"updateColor",tolua_opengl_wyTextureAtlas_updateColor00); tolua_function(tolua_S,"appendQuad",tolua_opengl_wyTextureAtlas_appendQuad00); tolua_function(tolua_S,"insertQuad",tolua_opengl_wyTextureAtlas_insertQuad00); tolua_function(tolua_S,"removeQuad",tolua_opengl_wyTextureAtlas_removeQuad00); tolua_function(tolua_S,"removeQuads",tolua_opengl_wyTextureAtlas_removeQuads00); tolua_function(tolua_S,"copyTo",tolua_opengl_wyTextureAtlas_copyTo00); tolua_function(tolua_S,"copyTo",tolua_opengl_wyTextureAtlas_copyTo01); tolua_function(tolua_S,"drawOne",tolua_opengl_wyTextureAtlas_drawOne00); tolua_function(tolua_S,"draw",tolua_opengl_wyTextureAtlas_draw00); tolua_function(tolua_S,"drawRange",tolua_opengl_wyTextureAtlas_drawRange00); tolua_function(tolua_S,"drawAll",tolua_opengl_wyTextureAtlas_drawAll00); tolua_function(tolua_S,"getTotalQuads",tolua_opengl_wyTextureAtlas_getTotalQuads00); tolua_function(tolua_S,"isWithColorArray",tolua_opengl_wyTextureAtlas_isWithColorArray00); tolua_function(tolua_S,"getCapacity",tolua_opengl_wyTextureAtlas_getCapacity00); tolua_function(tolua_S,"getPixelHeight",tolua_opengl_wyTextureAtlas_getPixelHeight00); tolua_function(tolua_S,"getPixelWidth",tolua_opengl_wyTextureAtlas_getPixelWidth00); tolua_function(tolua_S,"getWidth",tolua_opengl_wyTextureAtlas_getWidth00); tolua_function(tolua_S,"getHeight",tolua_opengl_wyTextureAtlas_getHeight00); tolua_function(tolua_S,"getWidthScale",tolua_opengl_wyTextureAtlas_getWidthScale00); tolua_function(tolua_S,"getHeightScale",tolua_opengl_wyTextureAtlas_getHeightScale00); tolua_function(tolua_S,"setColor",tolua_opengl_wyTextureAtlas_setColor00); tolua_function(tolua_S,"reduceAlpha",tolua_opengl_wyTextureAtlas_reduceAlpha00); tolua_endmodule(tolua_S); tolua_endmodule(tolua_S); return 1; } #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501 TOLUA_API int luaopen_opengl (lua_State* tolua_S) { return tolua_opengl_open(tolua_S); }; #endif
31.261905
123
0.750497
zchajax
4d7827ef6aaed40723c3bf8aba84df5e6b037875
986
cpp
C++
src/Score.cpp
Pyr0x1/Memory
e73f68554b1707bccd984e9d3725e597aee7c82a
[ "MIT" ]
1
2016-01-15T04:45:26.000Z
2016-01-15T04:45:26.000Z
src/Score.cpp
Pyr0x1/Memory
e73f68554b1707bccd984e9d3725e597aee7c82a
[ "MIT" ]
null
null
null
src/Score.cpp
Pyr0x1/Memory
e73f68554b1707bccd984e9d3725e597aee7c82a
[ "MIT" ]
null
null
null
#include <iostream> #include <sstream> #include "Score.h" Score::Score (std::string fontPath, SDL_Color fontColor, int size) { this->font = TTF_OpenFont (fontPath.c_str(), size); if(!this->font) printf("TTF_OpenFont: %s\n", TTF_GetError()); this->color = fontColor; this->value = 0; } void Score::write (SDL_Renderer* renderer, SDL_Point position) { std::ostringstream oStream; oStream << this->value; std::string valueStr = oStream.str (); this->surface = TTF_RenderText_Solid (this->font, valueStr.c_str (), this->color); this->texture = SDL_CreateTextureFromSurface (renderer, this->surface); SDL_Rect destRect = {position.x, position.y, this->surface->w, this->surface->h}; SDL_RenderCopy (renderer, this->texture, NULL, &destRect); SDL_FreeSurface (this->surface); return ; } void Score::increase () { this->value++; } void Score::reset () { this->value = 0; } Score::~Score () { TTF_CloseFont (this->font); SDL_DestroyTexture (this->texture); }
20.541667
83
0.691684
Pyr0x1
4d7efa0da1d3e666c546b9ac7a3b9361d9965cb9
19,300
hpp
C++
src/projects/lja/multi_graph.hpp
fedarko/LJA
f20c85395d741b0f94f6d0172c7451d72d7c8713
[ "BSD-3-Clause" ]
null
null
null
src/projects/lja/multi_graph.hpp
fedarko/LJA
f20c85395d741b0f94f6d0172c7451d72d7c8713
[ "BSD-3-Clause" ]
null
null
null
src/projects/lja/multi_graph.hpp
fedarko/LJA
f20c85395d741b0f94f6d0172c7451d72d7c8713
[ "BSD-3-Clause" ]
null
null
null
#pragma once #include <sequences/sequence.hpp> #include <unordered_set> #include <unordered_map> #include <experimental/filesystem> #include <fstream> #include <common/string_utils.hpp> #include <sequences/contigs.hpp> namespace multigraph { class Edge; struct Vertex { Sequence seq; int id; std::vector<Edge *> outgoing; Vertex *rc = nullptr; explicit Vertex(const Sequence &seq, int id) : seq(seq), id(id) { outgoing.reserve(4); } bool isCanonical() const { return seq <= !seq; } size_t inDeg() const { return rc->outgoing.size(); } size_t outDeg() const { return outgoing.size(); } }; struct Edge { private: Sequence seq; int id; size_t sz; bool canonical; public: Vertex *start = nullptr; Vertex *end = nullptr; Edge *rc = nullptr; explicit Edge(const Sequence &seq, int id = 0) : seq(seq), id(id), sz(seq.size()), canonical(seq <= !seq) { } Sequence getSeq() const { if(seq.empty()) return start->seq + end->seq.Subseq(sz); return seq; } int getId() const { return id; } size_t size() const { return sz; } size_t overlap() const { VERIFY(start->seq.size() + end->seq.size() > sz); return start->seq.size() + end->seq.size() - sz; } bool isCanonical() const { VERIFY(canonical == (id > 0)); return canonical; } }; struct MultiGraph { int maxVId = 0; int maxEId = 0; std::vector<Vertex *> vertices; std::vector<Edge *> edges; MultiGraph() = default; MultiGraph(MultiGraph &&other) = default; MultiGraph &operator=(MultiGraph &&other) = default; MultiGraph(const MultiGraph &) = delete; MultiGraph &LoadGFA(const std::experimental::filesystem::path &gfa_file, bool int_ids) { std::ifstream is; is.open(gfa_file); std::unordered_map<std::string, Vertex*> vmap; for( std::string line; getline(is, line); ) { std::vector<std::string> tokens = ::split(line); if(tokens[0] == "S") { std::string name = tokens[1]; Vertex &newV = int_ids ? addVertex(Sequence(tokens[2]), std::stoi(name)) : addVertex(Sequence(tokens[2])); VERIFY(vmap.find(name) == vmap.end()); vmap[name] = &newV; } else if(tokens[0] == "L") { Vertex *v1 = vmap[tokens[1]]; Vertex *v2 = vmap[tokens[3]]; if(tokens[2] == "-") v1 = v1->rc; if(tokens[4] == "-") v2 = v2->rc; size_t overlap = std::stoull(tokens[5].substr(0, tokens[5].size() - 1)); if(v1->seq.Subseq(v1->seq.size() - overlap) != v2->seq.Subseq(0, overlap)) { v1 = v1->rc; } VERIFY(v1->seq.Subseq(v1->seq.size() - overlap) == v2->seq.Subseq(0, overlap)); addEdge(*v1, *v2, v1->seq + v2->seq.Subseq(overlap)); } } is.close(); return *this; } MultiGraph DBG() const { MultiGraph dbg; std::unordered_map<Edge *, Vertex *> emap; for(Vertex * v : vertices) { if(v->outDeg() == 0 || emap.find(v->outgoing[0]) != emap.end()) { continue; } Vertex *newv = &dbg.addVertex(v->seq.Subseq(v->seq.size() - v->outgoing[0]->overlap())); for(Edge * edge : v->outgoing) { Vertex * right = edge->end; for(Edge * edge1 : right->rc->outgoing) { emap[edge1] = newv->rc; emap[edge1->rc] = newv; } } } for(Vertex * v : vertices) { if(!(v->seq <= !v->seq)) continue; Vertex * start = nullptr; Vertex * end = nullptr; if(v->inDeg() == 0) { start = &dbg.addVertex(v->seq.Subseq(0, 4001)); } else { start = emap[v->rc->outgoing[0]]->rc; } if(v->outDeg() == 0) { end = &dbg.addVertex(v->seq.Subseq(v->seq.size() - 4001)); } else { end = emap[v->outgoing[0]]; } dbg.addEdge(*start, *end, v->seq, v->id); } return std::move(dbg); } ~MultiGraph() { for(Vertex * &v : vertices) { delete v; v = nullptr; } for(Edge * &e : edges) { delete e; e = nullptr; } } MultiGraph DeleteEdges(const std::unordered_set<Edge *> &to_delete) const { MultiGraph mg; std::unordered_map<Vertex *, Vertex *> vmap; std::unordered_set<Edge *> visited; for(Vertex * v : vertices) { if(vmap.find(v) != vmap.end()) continue; vmap[v] = &mg.addVertex(v->seq, v->id); vmap[v->rc] = vmap[v]->rc; } for(Edge * edge : edges) { if(!edge->isCanonical() || to_delete.find(edge) != to_delete.end()) continue; mg.addEdge(*vmap[edge->start], *vmap[edge->end], edge->getSeq(), edge->getId()); } return std::move(mg); } MultiGraph BulgeSubgraph() const { std::unordered_set<Vertex *> good; std::unordered_set<Edge *> to_delete; size_t sz = 0; for(Vertex *v : vertices) { if(v->outDeg() != 2) { continue; } if(v->outgoing[0]->end == v->outgoing[1]->end) { good.emplace(v); good.emplace(v->rc); } } size_t bulges = 0; for(Vertex *v : vertices) { if(v->outDeg() != 2) { continue; } if(to_delete.find(v->outgoing[0]) != to_delete.end() || to_delete.find(v->outgoing[1]) != to_delete.end()) { continue; } Edge * todel = nullptr; if(v->outgoing[0]->end == v->outgoing[1]->end) { todel = v->outgoing[0]; bulges++; sz += v->outgoing[0]->size(); } else { if((good.find(v) == good.end() || v->outgoing[0]->size() < 1000000) && v->outgoing[0]->end->outDeg() == 0) { todel = v->outgoing[0]; } else if((good.find(v) == good.end() || v->outgoing[0]->size() < 1000000) && v->outgoing[1]->end->outDeg() == 0) { todel = v->outgoing[1]; } else if(good.find(v->outgoing[0]->end)== good.end()) { todel = v->outgoing[0]; } else if(good.find(v->outgoing[1]->end)== good.end()) { todel = v->outgoing[1]; } } if(todel != nullptr) { to_delete.emplace(todel); to_delete.emplace(todel->rc); sz += todel->size(); } } std::cout << "Deleting " << sz << " " << to_delete.size() / 2 << std::endl; std::cout << "Bulges " << bulges << std::endl; return DeleteEdges(to_delete); } void checkConsistency() const { std::unordered_set<Edge const *> eset; std::unordered_set<Vertex const *> vset; for(Edge const * edge: edges) { eset.emplace(edge); VERIFY(edge->rc->start == edge->end->rc); VERIFY(edge->rc->rc == edge); } for(Edge const *edge : edges) { VERIFY(eset.find(edge->rc) != eset.end()); } for(Vertex const * v: vertices) { vset.emplace(v); VERIFY(v->rc->rc == v); for(Edge *edge : v->outgoing) { VERIFY(eset.find(edge) != eset.end()); VERIFY(edge->start == v); } } for(Vertex const *v : vertices) { VERIFY(vset.find(v->rc) != vset.end()); } } Vertex &addVertex(const Sequence &seq, int id = 0) { if(id == 0) { id = maxVId + 1; } maxVId = std::max(std::abs(id), maxVId); vertices.emplace_back(new Vertex(seq, id)); Vertex *res = vertices.back(); Vertex *rc = res; if(seq != !seq) { vertices.emplace_back(new Vertex(!seq, -id)); rc = vertices.back(); } res->rc = rc; rc->rc = res; return *res; } Edge &addEdge(Vertex &from, Vertex &to, const Sequence &seq, int id = 0) { if(id == 0) { id = maxEId + 1; } maxEId = std::max(std::abs(id), maxEId); if(!(seq <= !seq)) { id = -id; } edges.emplace_back(new Edge(seq, id)); Edge *res = edges.back(); res->start = &from; res->end = &to; res->start->outgoing.emplace_back(res); if(seq != !seq) { edges.emplace_back(new Edge(!seq, -id)); Edge *rc = edges.back(); rc->start = to.rc; rc->end = from.rc; res->rc = rc; rc->rc = res; res->rc->start->outgoing.emplace_back(res->rc); } else { res->rc = res; } return *res; } std::vector<Edge *> uniquePathForward(Edge &edge) { std::vector<Edge *> res = {&edge}; Vertex *cur = edge.end; while(cur != edge.start && cur->inDeg() == 1 && cur->outDeg() == 1) { res.emplace_back(cur->outgoing[0]); cur = res.back()->end; } return std::move(res); } std::vector<Edge *> uniquePath(Edge &edge) { std::vector<Edge *> path = uniquePathForward(*edge.rc); return uniquePathForward(*path.back()->rc); } MultiGraph Merge() { MultiGraph res; std::unordered_set<Edge *> used; std::unordered_map<Vertex *, Vertex *> old_to_new; for(Edge *edge : edges) { if(used.find(edge) != used.end()) continue; std::vector<Edge *> unique = uniquePath(*edge); for(Edge *e : unique) { used.emplace(e); used.emplace(e->rc); } Vertex *old_start = unique.front()->start; Vertex *old_end = unique.back()->end; Vertex *new_start = nullptr; Vertex *new_end = nullptr; if(old_to_new.find(old_start) == old_to_new.end()) { old_to_new[old_start] = &res.addVertex(old_start->seq); old_to_new[old_start->rc] = old_to_new[old_start]->rc; } new_start = old_to_new[old_start]; if(old_to_new.find(old_end) == old_to_new.end()) { old_to_new[old_end] = &res.addVertex(old_end->seq); old_to_new[old_end->rc] = old_to_new[old_end]->rc; } new_end = old_to_new[old_end]; Sequence new_seq; if(unique.size() == 1) { new_seq = unique[0]->getSeq(); } else { SequenceBuilder sb; sb.append(old_start->seq); for(Edge *e : unique) { sb.append(e->getSeq().Subseq(e->start->seq.size())); } new_seq = sb.BuildSequence(); } res.addEdge(*new_start, *new_end, new_seq); } for(Vertex *vertex : vertices) { if(vertex->inDeg() == 0 && vertex->outDeg() == 0 && vertex->seq <= !vertex->seq) { res.addVertex(vertex->seq); } } res.checkConsistency(); return std::move(res); } std::vector<Contig> getEdges(bool cut_overlaps) { std::unordered_map<Vertex *, size_t> cut; for(Vertex *v : vertices) { if(v->seq <= !v->seq) { if(v->outDeg() == 1) { cut[v] = 0; } else { cut[v] = 1; } cut[v->rc] = 1 - cut[v]; } } std::vector<Contig> res; size_t cnt = 1; for(Edge *edge : edges) { if(edge->isCanonical()) { size_t cut_left = edge->start->seq.size() * cut[edge->start]; size_t cut_right = edge->end->seq.size() * (1 - cut[edge->end]); if(!cut_overlaps) { cut_left = 0; cut_right = 0; } if(cut_left + cut_right >= edge->size()) { continue; } res.emplace_back(edge->getSeq().Subseq(cut_left, edge->size() - cut_right), itos(edge->getId())); cnt++; } } return std::move(res); } void printEdges(const std::experimental::filesystem::path &f, bool cut_overlaps) { std::ofstream os; os.open(f); for(const Contig &contig : getEdges(cut_overlaps)) { os << ">" << contig.id << "\n" << contig.seq << "\n"; } os.close(); } void printDot(const std::experimental::filesystem::path &f) { std::ofstream os; os.open(f); os << "digraph {\nnodesep = 0.5;\n"; for(Vertex *vertex : vertices) { os << vertex->id << " [label=\"" << vertex->seq.size() << "\" style=filled fillcolor=\"white\"]\n"; } std::unordered_map<Edge *, std::string> eids; for (Edge *edge : edges) { os << "\"" << edge->start->id << "\" -> \"" << edge->end->id << "\" [label=\"" << edge->getId() << "(" << edge->size() << ")\" color = \"black\"]\n" ; } os << "}\n"; os.close(); } void printEdgeGFA(const std::experimental::filesystem::path &f, const std::vector<Vertex *> &component) const { std::ofstream os; os.open(f); os << "H\tVN:Z:1.0" << std::endl; std::unordered_map<Edge *, std::string> eids; for(Vertex *v : component) for (Edge *edge : v->outgoing) { if (edge->isCanonical()) { eids[edge] = itos(edge->getId()); eids[edge->rc] = itos(edge->getId()); os << "S\t" << eids[edge] << "\t" << edge->getSeq() << "\n"; } } for (Vertex *vertex : component) { if(!vertex->isCanonical()) continue; for (Edge *out_edge : vertex->outgoing) { std::string outid = eids[out_edge]; bool outsign = out_edge->isCanonical(); for (Edge *inc_edge : vertex->rc->outgoing) { std::string incid = eids[inc_edge]; bool incsign = inc_edge->rc->isCanonical(); os << "L\t" << incid << "\t" << (incsign ? "+" : "-") << "\t" << outid << "\t" << (outsign ? "+" : "-") << "\t" << vertex->seq.size() << "M" << "\n"; } } } os.close(); } void printEdgeGFA(const std::experimental::filesystem::path &f) const { printEdgeGFA(f, vertices); } void printVertexGFA(const std::experimental::filesystem::path &f, const std::vector<Vertex *> &component) const { std::ofstream os; os.open(f); os << "H\tVN:Z:1.0" << std::endl; size_t cnt = 1; std::unordered_map<Vertex *, std::string> vids; for(Vertex *v : component) if(v->seq <= !v->seq) { vids[v] = itos(v->id); vids[v->rc] = itos(v->id); os << "S\t" << vids[v] << "\t" << v->seq << "\n"; cnt++; } for(Vertex *v : component) for (Edge *edge : v->outgoing) { if (edge->isCanonical()) { bool incsign = v->seq <= !v->seq; bool outsign = edge->end->seq <= !edge->end->seq; os << "L\t" << vids[v] << "\t" << (incsign ? "+" : "-") << "\t" << vids[edge->end] << "\t" << (outsign ? "+" : "-") << "\t" << (v->seq.size() + edge->end->seq.size() - edge->size()) << "M" << "\n"; } } os.close(); } void printVertexGFA(const std::experimental::filesystem::path &f) const { printVertexGFA(f, vertices); } std::vector<std::vector<Vertex *>> split() const { std::vector<std::vector<Vertex *>> res; std::unordered_set<Vertex *> visited; for(Vertex *v : vertices) { if(visited.find(v) != visited.end()) continue; std::vector<Vertex *> stack = {v}; res.emplace_back(std::vector<Vertex *>()); while(!stack.empty()) { Vertex *p = stack.back(); stack.pop_back(); if(visited.find(p) != visited.end()) continue; visited.emplace(p); visited.emplace(p->rc); res.back().emplace_back(p); res.back().emplace_back(p->rc); for(Edge *e : p->outgoing) stack.emplace_back(e->end); for(Edge *e : p->rc->outgoing) stack.emplace_back(e->end); } } return std::move(res); } }; }
38.067061
135
0.412642
fedarko
4d7f0085ce495c58f5b980a403b741030b0fab38
274
cpp
C++
src/unit_tests/main.cpp
tyrbedarf/LumixEngine
0ec51d724abcc06f297c3e189282763a630f7eb5
[ "MIT" ]
3
2021-05-27T10:43:33.000Z
2021-05-27T10:44:02.000Z
src/unit_tests/main.cpp
tyrbedarf/LumixEngine
0ec51d724abcc06f297c3e189282763a630f7eb5
[ "MIT" ]
null
null
null
src/unit_tests/main.cpp
tyrbedarf/LumixEngine
0ec51d724abcc06f297c3e189282763a630f7eb5
[ "MIT" ]
3
2021-05-27T10:44:15.000Z
2021-11-18T09:20:10.000Z
#include "engine/lumix.h" #include "engine/debug/floating_points.h" #include "unit_tests/suite/unit_test_app.h" int main(int argc, const char * argv[]) { Lumix::enableFloatingPointTraps(true); Lumix::UnitTest::App app; app.init(); app.run(argc, argv); app.exit(); }
18.266667
43
0.715328
tyrbedarf
4d8118e6f98fdefb970263985e8e6be4cbdd5f19
396
hpp
C++
est/include/est/est_io_cb.hpp
dungeonsnd/lite-libs
38f84bd1cf6f1a43836f43e57fcd1d22b18d706b
[ "FSFAP" ]
null
null
null
est/include/est/est_io_cb.hpp
dungeonsnd/lite-libs
38f84bd1cf6f1a43836f43e57fcd1d22b18d706b
[ "FSFAP" ]
null
null
null
est/include/est/est_io_cb.hpp
dungeonsnd/lite-libs
38f84bd1cf6f1a43836f43e57fcd1d22b18d706b
[ "FSFAP" ]
null
null
null
#ifndef _HEADER_FILE_EST_IO_CB_HPP_ #define _HEADER_FILE_EST_IO_CB_HPP_ typedef void (*est_funcIocb) (bufferevent *bev, void *arg); typedef void (*est_funcErrorcb) (bufferevent *bev,short event, void *arg); typedef void (*est_funcTimecb) (int fd,short event, void *arg); typedef void (*est_funcAcceptcb) (evutil_socket_t listener, short event, void *arg); #endif // _HEADER_FILE_EST_IO_CB_HPP_
39.6
84
0.790404
dungeonsnd
4d871ec0231e6e547b55a7c9b30da5c58d55674f
3,125
cc
C++
CodeChef/SNACKDOWN/16/Pre-Elimination A/Problem F/F.cc
VastoLorde95/Competitive-Programming
6c990656178fb0cd33354cbe5508164207012f24
[ "MIT" ]
170
2017-07-25T14:47:29.000Z
2022-01-26T19:16:31.000Z
CodeChef/SNACKDOWN/16/Pre-Elimination A/Problem F/F.cc
navodit15/Competitive-Programming
6c990656178fb0cd33354cbe5508164207012f24
[ "MIT" ]
null
null
null
CodeChef/SNACKDOWN/16/Pre-Elimination A/Problem F/F.cc
navodit15/Competitive-Programming
6c990656178fb0cd33354cbe5508164207012f24
[ "MIT" ]
55
2017-07-28T06:17:33.000Z
2021-10-31T03:06:22.000Z
#include <bits/stdc++.h> #define sd(x) scanf("%d",&x) #define sd2(x,y) scanf("%d%d",&x,&y) #define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z) #define fi first #define se second #define pb push_back #define mp make_pair #define foreach(it, v) for(__typeof((v).begin()) it=(v).begin(); it != (v).end(); ++it) #define meta __FUNCTION__,__LINE__ #define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout); using namespace std; const long double PI = 3.1415926535897932384626433832795; template<typename S, typename T> ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;} template<typename T> ostream& operator<<(ostream& out,vector<T> const& v){ int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;} void tr(){cout << endl;} template<typename S, typename ... Strings> void tr(S x, const Strings&... rest){cout<<x<<' ';tr(rest...);} typedef long long ll; typedef pair<int,int> pii; const int N = 100100; const ll MOD = 1e9 + 7; int a[N]; ll s[N]; ll getAtZ(ll x, ll y, ll z, ll vx, ll vy, int cur, int m){ int jump = m - cur; if(x << jump == z) return vx; if(y << jump == z) return vy; jump--; x <<= 1; y <<= 1; ll mid = x+1; ll vm = (vx + vy) % MOD; if(z <= (mid << jump)) return getAtZ(x, mid, z, vx, vm, cur+1, m); else return getAtZ(mid, y, z, vm, vy, cur+1, m); } ll getSum(ll l, ll r, int cnt, ll px, ll py, ll vx, ll vy){ if(cnt == 0){ // tr(meta, l, r, cnt, px, py, vx, vy); if(l) return (s[r] - s[l-1] + MOD) % MOD; return s[r]; } ll ret = 0; if(r % 2){ ll v1 = getAtZ(px, py, l, vx, vy, 0, cnt); ll v2 = getAtZ(px, py, r-1, vx, vy, 0, cnt); ll v3 = getAtZ(px, py, r, vx, vy, 0, cnt); ret = getSum(l/2, r/2, cnt-1, px, py, vx, vy) * 3 % MOD; ret = (ret - v1 + MOD) % MOD; ret = (ret - v2 + MOD) % MOD; ret = (ret + v3) % MOD; } else{ ll v1 = getAtZ(px, py, l, vx, vy, 0, cnt); ll v2 = getAtZ(px, py, r, vx, vy, 0, cnt); ret = getSum(l/2, r/2, cnt-1, px, py, vx, vy) * 3 % MOD; ret = (ret - v1 + MOD) % MOD; ret = (ret - v2 + MOD) % MOD; } // tr(meta, l, r, cnt, px, py, vx, vy, "returning", ret); return ret; } int n, m; ll get(ll x){ if(x < 0) return 0; ll lo = 0, hi = n, mid; while(lo+1 < hi){ mid = (lo + hi) >> 1; ll pos = mid << m; if(pos <= x) lo = mid; else hi = mid; } ll l = lo, r = lo+1; ll sm = s[l]; for(int i = 0; i < m; i++){ sm = ((sm * 3) % MOD - a[0] - a[l] + MOD) % MOD; } ll ret = sm; if((l << m) == x) return ret; // tr(meta, x, l, l << m, ret); ret = ret + getSum((l << m), x, m, l, r, a[l], a[r]) % MOD; ret = (ret - a[l] + MOD) % MOD; assert(ret >= 0 and ret < MOD); return ret; } void solve(){ ll x, y; scanf("%d%d%lld%lld", &n, &m, &x, &y); x--, y--; for(int i = 0; i < n; i++){ sd(a[i]); } s[0] = a[0]; for(int i = 1; i < n; i++){ s[i] = s[i-1] + a[i] % MOD; } ll ans = (get(y) - get(x-1) + MOD) % MOD; printf("%lld\n", ans); } int main(){ int t; sd(t); while(t--) solve(); return 0; }
21.258503
97
0.52608
VastoLorde95
4d902c774febb89d40c247919b0b3fb95f63f778
584
cpp
C++
BOJ_CPP/22477.cpp
tnsgh9603/BOJ_CPP
432b1350f6c67cce83aec3e723e30a3c6b5dbfda
[ "MIT" ]
null
null
null
BOJ_CPP/22477.cpp
tnsgh9603/BOJ_CPP
432b1350f6c67cce83aec3e723e30a3c6b5dbfda
[ "MIT" ]
null
null
null
BOJ_CPP/22477.cpp
tnsgh9603/BOJ_CPP
432b1350f6c67cce83aec3e723e30a3c6b5dbfda
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> #define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0) using namespace std; int main() { fastio; int n, m; cin >> n; string s; map<string, int> mp; for (int i = 0; i < n; ++i) { cin >> s; mp[s] = 1; } cin >> m; bool flag = 1; for (int i = 0; i < m; ++i) { cin >> s; if (mp.count(s)) { cout << (flag ? "Opened by " : "Closed by "); flag = !flag; } else { cout << "Unknown "; } cout << s << "\n"; } return 0; }
20.137931
63
0.409247
tnsgh9603
4d94f198f30b3eafebb4779688b9ef5713d30f9a
406
cpp
C++
luogu/c++/P5727.cpp
Crabtime/cpp-project
1d79aab95be18d704e431efc5eff94d11e6096d3
[ "CC0-1.0" ]
1
2020-08-09T01:35:17.000Z
2020-08-09T01:35:17.000Z
luogu/c++/P5727.cpp
Crabtime/cpp-project
1d79aab95be18d704e431efc5eff94d11e6096d3
[ "CC0-1.0" ]
null
null
null
luogu/c++/P5727.cpp
Crabtime/cpp-project
1d79aab95be18d704e431efc5eff94d11e6096d3
[ "CC0-1.0" ]
null
null
null
#include<iostream> #pragma GCC optimize(3) using namespace std; void bingbao(long long n) { if (n == 1) { std:: cout << 1 << ' '; return; } if (n%2 == 0) { bingbao(n/2); } else { bingbao(n*3+1); } std:: cout << n << ' '; } int main() { long long n; std:: cin >> n; bingbao(n); return 0; }
14
32
0.399015
Crabtime
4d97a8916b1bf346f3c89869d6f1819a06d42ab7
648
hh
C++
include/ThreadRun.hh
phirippu/instrument-simulation
0a7cec84d8945a6f11e0ddca00f1e8fc0d32d7f8
[ "CC-BY-4.0" ]
null
null
null
include/ThreadRun.hh
phirippu/instrument-simulation
0a7cec84d8945a6f11e0ddca00f1e8fc0d32d7f8
[ "CC-BY-4.0" ]
null
null
null
include/ThreadRun.hh
phirippu/instrument-simulation
0a7cec84d8945a6f11e0ddca00f1e8fc0d32d7f8
[ "CC-BY-4.0" ]
1
2021-03-08T16:01:14.000Z
2021-03-08T16:01:14.000Z
// // Created by phil on 5/17/18. // #ifndef THREADRUN_HH #define THREADRUN_HH #include <G4Run.hh> #include <map> #include <G4ToolsAnalysisManager.hh> #include "SensitiveDetector.hh" #include "DetectorConstruction.hh" class ThreadRun : public G4Run { public: explicit ThreadRun(const G4String &rootFileName); ~ThreadRun() override; void RecordEvent(const G4Event *) override; void Merge(const G4Run *) override; G4ToolsAnalysisManager *analysisManager = nullptr; private: std::vector<SensitiveDetector *> sdCollection; const DetectorConstruction *dConstruction; G4int iNtupleIdx; }; #endif //THREADRUN_HH
18.514286
54
0.736111
phirippu
4d99cffcb437d087031789496c36ba21685621ea
5,851
cc
C++
jjOpenCLBasic.cc
ied206/NPKICracker
72052835fd97286525051036d6148a55bf594f72
[ "MIT" ]
10
2015-12-05T02:56:04.000Z
2020-05-28T02:41:32.000Z
jjOpenCLBasic.cc
ied206/NPKICracker
72052835fd97286525051036d6148a55bf594f72
[ "MIT" ]
null
null
null
jjOpenCLBasic.cc
ied206/NPKICracker
72052835fd97286525051036d6148a55bf594f72
[ "MIT" ]
4
2015-11-27T13:23:51.000Z
2021-07-22T08:32:48.000Z
#include "jjOpenCLBasic.hpp" cl_context createContext() { cl_int errNum; JJ_CL_PLATFORMS platformsInformations; cl_context context = NULL; errNum = jjOpenCLPlatformInitialize(&platformsInformations, true); cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platformsInformations.platforms[0].platformID, 0 }; context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU, NULL, NULL, &errNum); if(errNum != CL_SUCCESS) { cout << "This system has no OpenCL available GPU device" << endl; context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_CPU, NULL, NULL, &errNum); if(errNum != CL_SUCCESS) { cout << "This system has no OpenCL available CPU device" << endl; cout << "This system isn't available to run this application" << endl; exit(1); } else{ cout << "Application find OpenCL CPU device. Runnig on it...\n\n" << endl; } } else{ cout << "Application find OpenCL GPU device. Running on it...\n\n" << endl; } return context; } cl_command_queue createCommandqueue(cl_context context, cl_device_id* device) { cl_int errNum; cl_device_id* devices; cl_command_queue commandQueue = NULL; size_t deviceBufferSize = -1; errNum = clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &deviceBufferSize); if(errNum != CL_SUCCESS) { cerr << "Failed to call clGetContextInfo(..., CL_CONTEXT_DEVICES, ...)" << endl; exit(1); } if(deviceBufferSize <= 0) { cerr << "No available device" << endl; exit(1); } devices = new cl_device_id[deviceBufferSize / sizeof(cl_device_id)]; errNum = clGetContextInfo(context, CL_CONTEXT_DEVICES, deviceBufferSize, devices, NULL); if(errNum != CL_SUCCESS) { cerr << "Failed to get device id" << endl; exit(1); } commandQueue = clCreateCommandQueue(context, devices[0], 0, NULL); if(commandQueue == NULL) { cerr << "Failed to create command queue for device 0" << endl; exit(1); } *device = devices[0]; delete [] devices; return commandQueue; } cl_program CreateProgram(cl_context context, cl_device_id device, const char* filename) { cl_int errNum; cl_program program; ifstream kernelFile(filename, ios::in); ostringstream oss; if(!kernelFile.is_open()) { cerr << "kernel file " << filename << " isn't available to open." << endl; exit(1); } oss << kernelFile.rdbuf(); string srcStdStr = oss.str(); const char* srcStr = srcStdStr.c_str(); program = clCreateProgramWithSource(context, 1, (const char**)&srcStr, NULL, &errNum); if((errNum != CL_SUCCESS) || program == NULL) { cerr << "Failed to create OpenCL Program" << endl; exit(1); } errNum = clBuildProgram(program, 1, &device, NULL, NULL, NULL); if(errNum != CL_SUCCESS) { char *buildLog; size_t errLength; clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, (size_t)NULL, NULL, &errLength); buildLog = (char*)malloc(sizeof(char) * (errLength + 1)); errNum = clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, sizeof(char)*errLength, buildLog, NULL); cerr << "OpenCL kernel build Error! Errors are here:\nclGetProgramBuildInfo return errorcode: " << errNum << " is"; switch(errNum){ case CL_INVALID_DEVICE: cerr << "CL_INVALID_DEVICE. Device is not valid with this program object." << endl; break; case CL_INVALID_VALUE: cerr << "CL_INVALID_VALUE. Parameter to clBuildProgram was wrong." << endl << "If pfn_notify is NULL and user_data is not NULL, this can happen." << endl << "device_list is NULL and num_devices is greater than 0, or device_list is not NULL and num_devices is zero, this can also happen" << endl;break; case CL_INVALID_PROGRAM: cerr << "CL_INVALID_PROGRAM. Program object is not valid" << endl; break; case CL_INVALID_BINARY: cerr << "CL_INVALID_BINARY. Given device_list is not matching binary given to clCreateProgramWithBinary, this can happen" << endl; break; case CL_INVALID_BUILD_OPTIONS: cerr << "CL_INVALID_BUILD_OPTIONS. Build option string given to clBuildProgram's options argument is wrong." << endl; break; case CL_INVALID_OPERATION: cerr << "CL_INVALID_OPERATION. Previous clBuildProgram call has not ended or kernel object is attatching to program object." << endl; break; case CL_COMPILER_NOT_AVAILABLE: cerr <<"CL_COMPILER_NOT_AVAILABLE" << endl; break; case CL_OUT_OF_RESOURCES: cerr << "CL_OUT_OF_RESOURCES" << endl; break; case CL_OUT_OF_HOST_MEMORY: cerr << "CL_OUT_OF_HOST_MEMORY" << endl; break; default: break; } cerr << endl; cerr << buildLog << endl; free(buildLog); clReleaseProgram(program); exit(1); } cout << "OpenCL program successfully built" << endl; return program; } cl_kernel CreateKernel(cl_program program, const char* kernel_name) { cl_int errNum; cl_kernel kernel = NULL; kernel = clCreateKernel(program, kernel_name, &errNum); if(errNum != CL_SUCCESS){ cerr << "Error code is this: " << errNum << endl; switch(errNum){ case CL_INVALID_PROGRAM: cerr << "CL_INVALID_PROGRAM. Program object given first argument to CreateKernel is wrong." << endl; break; case CL_INVALID_PROGRAM_EXECUTABLE: cerr << "CL_INVALID_PROGRAM_EXECUTABLE." << endl; break; case CL_INVALID_KERNEL: cerr << "CL_INVALID_KERNEL_NAME. Kernel name given second argument CreateKernel is wrong." << endl; break; case CL_INVALID_KERNEL_DEFINITION: cerr << "CL_INVALID_KERNEL_DEFINITION. Kernel source code is not suitable for this OpenCL device" << endl; break; case CL_INVALID_VALUE: cerr << "CL_INVALID_VALUE. Are you sure you have not given NULL as second argument to CreateKernel?" << endl; break; case CL_OUT_OF_HOST_MEMORY: cerr << "CL_OUT_OF_HOST_MEMORY. There is no suitable memory for kernel memory allocation" << endl; break; default: break; } exit(1); } cout << "OpenCL kernel successfully built" << endl; return kernel; }
39.802721
170
0.727055
ied206
4d9afcc5f9be1c282d9b96e0a98c71865e63aedd
3,072
cpp
C++
CodeChef/IITI15.cpp
TISparta/competitive-programming-solutions
31987d4e67bb874bf15653565c6418b5605a20a8
[ "MIT" ]
1
2018-01-30T13:21:30.000Z
2018-01-30T13:21:30.000Z
CodeChef/IITI15.cpp
TISparta/competitive-programming-solutions
31987d4e67bb874bf15653565c6418b5605a20a8
[ "MIT" ]
null
null
null
CodeChef/IITI15.cpp
TISparta/competitive-programming-solutions
31987d4e67bb874bf15653565c6418b5605a20a8
[ "MIT" ]
1
2018-08-29T13:26:50.000Z
2018-08-29T13:26:50.000Z
/** * > Author : TISparta * > Date : 03-05-18 * > Tags : Mo algorithm, BIT * > Difficulty : 5 / 10 */ #include <bits/stdc++.h> using namespace std; const int MAX_N = 2e4, MAX_Q = 2e4, OFFSET = 10; int N, Q, BLOCK_SIZE, arr[MAX_N + OFFSET], FT[MAX_N + OFFSET]; unordered_map <int, int> order; long long number_inversions, ans[MAX_N + OFFSET]; struct Query { int left, right, idx; Query() {} Query(int left_, int right_, int idx_) : left(left_), right(right_), idx(idx_) {} bool operator < (const Query& other) const { int this_block = this -> left / BLOCK_SIZE; int other_block = other.left / BLOCK_SIZE; if (this_block != other_block) return this_block < other_block; return this -> right < other.right; } }query[MAX_Q + OFFSET]; namespace FenwickTree { const int LIMIT = MAX_N + 1; void update(int pos, const int& var) { while (pos < LIMIT) { FT[pos] += var; pos += pos bitand -pos; } } long long getLeftSum(int pos) { long long sum = 0; while (pos) { sum += FT[pos]; pos -= pos bitand -pos; } return sum; } long long getRightSum(int pos) { return getLeftSum(LIMIT - 1) - getLeftSum(pos); } } namespace Mo { inline void addRight(const int& pos) { FenwickTree::update(arr[pos], 1); number_inversions += FenwickTree::getRightSum(arr[pos]); } inline void addLeft(const int& pos) { FenwickTree::update(arr[pos], 1); number_inversions += FenwickTree::getLeftSum(arr[pos] - 1); } inline void reduceRight(const int& pos) { FenwickTree::update(arr[pos], -1); number_inversions -= FenwickTree::getRightSum(arr[pos]); } inline void reduceLeft(const int& pos) { FenwickTree::update(arr[pos], -1); number_inversions -= FenwickTree::getLeftSum(arr[pos] - 1); } }; void print() { for (int i = 0; i < Q; i++) cout << ans[i] << endl; } void MoAlgorithm() { BLOCK_SIZE = sqrt(N); sort(query, query + Q); int mo_left = 0, mo_right = -1; for (int i = 0; i < Q; i++) { while (mo_right < query[i].right) Mo::addRight(++mo_right); while (mo_right > query[i].right) Mo::reduceRight(mo_right--); while (mo_left < query[i].left) Mo::reduceLeft(mo_left++); while (mo_left > query[i].left) Mo::addLeft(--mo_left); ans[query[i].idx] = number_inversions; } } void read() { set <int> numbers; cin >> N; for (int i = 0; i < N; i++) { cin >> arr[i]; numbers.insert(arr[i]); } int id = 0; for (const int& num : numbers) order[num] = ++id; for (int i = 0; i < N; i++) arr[i] = order[arr[i]]; cin >> Q; for (int i = 0, left_, right_; i < Q; i++) { cin >> left_ >> right_; query[i] = Query(--left_, --right_, i); } } int main() { ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); read(); MoAlgorithm(); print(); return (0); }
25.180328
85
0.556315
TISparta
4d9b94c441c12910416148b948cea09e639df2a9
2,572
cpp
C++
src/Algorithm/bellman_ford.cpp
petuzk/PAMSI-2
473e7e57823a01de3464c0cac9f795f024c1c9bf
[ "MIT" ]
null
null
null
src/Algorithm/bellman_ford.cpp
petuzk/PAMSI-2
473e7e57823a01de3464c0cac9f795f024c1c9bf
[ "MIT" ]
null
null
null
src/Algorithm/bellman_ford.cpp
petuzk/PAMSI-2
473e7e57823a01de3464c0cac9f795f024c1c9bf
[ "MIT" ]
null
null
null
#include "inc/Algorithm/bellman_ford.hpp" template <typename VIT, typename EIT> void bellman_ford(const IVGraph<VIT, EIT>& graph, IVGraph<VIT, EIT>& tree, const Vertex<VIT>* start, EIT zero_cost, EIT max_cost) { // Pobierz tablicę wierzchołków const auto graph_vertices = graph.vertices(); std::size_t num_vertices = graph_vertices.size(); // Zaalokuj pamięć dla nowych krawędzi i wierzchołków tree.preallocateForVertices(num_vertices); tree.preallocateForEdges(num_vertices - 1); // Utwórz tablicę wierzchołków specjalnych BFVertex<VIT, EIT>* vertices = new BFVertex<VIT, EIT>[num_vertices]; // Dodaj wszystkie wierzchołki do drzewa i zainicjalizuj tablicę for (std::size_t i = 0; i < num_vertices; i++) { const Vertex<VIT>* gv = graph_vertices[i]; const Vertex<VIT>* tv = tree.insertVertex(gv->getItem()); vertices[i] = { tv, nullptr, gv == start ? zero_cost : max_cost // w. początkowy ma wagę 0, pozostałe - "nieskończoność" }; } // Pobierz tablicę krawędzi const auto graph_edges = graph.edges(); std::size_t num_edges = graph_edges.size(); // Utwórz tablicę krawędzi specjalnych BFEdge<VIT, EIT>* edges = new BFEdge<VIT, EIT>[num_edges]; // Dodaj krawędzie grafu do tablicy for (std::size_t i = 0; i < num_edges; i++) { const Edge<VIT, EIT>* ge = graph_edges[i]; edges[i] = { vertices + dynamic_cast<const IndexableVertex<VIT, EIT>*>(ge->getV())->getIndex(), vertices + dynamic_cast<const IndexableVertex<VIT, EIT>*>(ge->getW())->getIndex(), ge->getItem() }; } // Wykonaj relaksację krawędzi for (std::size_t i = 1; i < num_vertices; i++) { for (std::size_t j = 0; j < num_edges; j++) { BFEdge<VIT, EIT>& e = edges[j]; BFVertex<VIT, EIT>* min_v = e.v; BFVertex<VIT, EIT>* max_v = e.w; // Wybierz min_v i max_v if (max_v->cost < min_v->cost) { min_v = e.w; max_v = e.v; } // Jeśli waga wierzchołka min_v nie jest "nieskończonością" if (min_v->cost != max_cost) { EIT new_cost = min_v->cost + e.cost; // Jeśli nowa droga jest krótsza if (new_cost < max_v->cost) { // Zaktualizuj max_v max_v->cost = new_cost; max_v->predecessor = min_v; } } } } // Zapisz krawędzie do drzewa for (std::size_t i = 0; i < num_vertices; i++) { const BFVertex<VIT, EIT>& v = vertices[i]; if (v.predecessor) tree.insertEdge(v.tree_vertex, v.predecessor->tree_vertex, v.cost - v.predecessor->cost); } delete[] edges; delete[] vertices; } template void bellman_ford(const IVGraph<int, int>&, IVGraph<int, int>&, const Vertex<int>*, int, int);
30.987952
131
0.670684
petuzk
4d9e5a617c52495b7549a971f1780d0dccf99c48
296
cpp
C++
CPP/Tests/typelens.cpp
lkpetrich/Semisimple-Lie-Algebras
163a221c65cbd6f4caea34452007d01b6688b15d
[ "MIT" ]
null
null
null
CPP/Tests/typelens.cpp
lkpetrich/Semisimple-Lie-Algebras
163a221c65cbd6f4caea34452007d01b6688b15d
[ "MIT" ]
null
null
null
CPP/Tests/typelens.cpp
lkpetrich/Semisimple-Lie-Algebras
163a221c65cbd6f4caea34452007d01b6688b15d
[ "MIT" ]
null
null
null
#include <stdio.h> #define dumptype(name,type) printf("%s: %lu\n",name,sizeof(type)); int main() { printf("Dumps the lengths of various C++ integer data types.\n\n"); dumptype("char",char) dumptype("short",short) dumptype("int",int) dumptype("long",long) dumptype("long long",long long) }
22.769231
68
0.685811
lkpetrich
4da00025d02c6016049b4ae806c28fd07ea05119
1,139
cpp
C++
src/mesh.cpp
mfirmin/c5sc
66b06061bf0f1a53c435f4109cd7fa636466c353
[ "MIT" ]
1
2015-01-05T07:49:33.000Z
2015-01-05T07:49:33.000Z
src/mesh.cpp
mfirmin/c5sc
66b06061bf0f1a53c435f4109cd7fa636466c353
[ "MIT" ]
null
null
null
src/mesh.cpp
mfirmin/c5sc
66b06061bf0f1a53c435f4109cd7fa636466c353
[ "MIT" ]
null
null
null
#include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/multi/geometries/multi_point.hpp> #include <iostream> #include <vector> #include "mesh.h" #include "component.h" #include "vertex.h" void Mesh::createHull(int c_num) { using boost::geometry::append; using boost::geometry::make; using boost::geometry::model::d2::point_xy; boost::geometry::model::multi_point<point_xy<dReal> > pointset; for (int i = 0; i < components.at(c_num)->faces.size(); i++) { for (std::vector<int>::iterator vertIter = components.at(c_num)->faces.at(i)->vertices.begin(); vertIter != components.at(c_num)->faces.at(i)->vertices.end(); vertIter++) { append(pointset, make<point_xy<dReal> >(vertexPalette.at(*vertIter)->pos.x, vertexPalette.at(*vertIter)->pos.y)); } } boost::geometry::model::multi_point<point_xy<dReal> > hull; boost::geometry::convex_hull(pointset, hull); for (std::vector<point_xy<dReal> >::size_type i = 0; i < hull.size(); i++) { components.at(c_num)->hull.push_back(std::make_pair(boost::geometry::get<0>(hull[i]), boost::geometry::get<1>(hull[i]))); } }
27.780488
172
0.697981
mfirmin
4da1d3528ae1af961618792d29711b3ad89f55ff
2,352
cpp
C++
src/algos/tree.cpp
mhough/braingl
53e2078adc10731ee62feec11dcb767c4c6c0d35
[ "MIT" ]
5
2016-03-17T07:02:11.000Z
2021-12-12T14:43:58.000Z
src/algos/tree.cpp
mhough/braingl
53e2078adc10731ee62feec11dcb767c4c6c0d35
[ "MIT" ]
null
null
null
src/algos/tree.cpp
mhough/braingl
53e2078adc10731ee62feec11dcb767c4c6c0d35
[ "MIT" ]
3
2015-10-29T15:21:01.000Z
2020-11-25T09:41:21.000Z
/* * tree.cpp * * Created on: 17.09.2013 * Author: Ralph */ #include "tree.h" #include <QDebug> Tree::Tree( int id, float value ) : m_id( id ), m_value( value ), m_texturePosition( QVector3D( 0, 0, 0 ) ), m_parent( 0 ) { QColor color1( 255, 0, 0 ); QColor color2( 128, 128, 128 ); m_colors.push_back( color1 ); m_colors.push_back( color2 ); m_colors.push_back( color2 ); m_colors.push_back( color2 ); } Tree::~Tree() { } Tree* Tree::getParent() { return m_parent; } void Tree::setParent( Tree* parent ) { m_parent = parent; } void Tree::addChild( Tree* child ) { m_children.push_back( child ); } QList<Tree*> Tree::getChildren() { return m_children; } QColor Tree::getColor( int id ) { return m_colors[id]; } void Tree::setColor( int id, QColor& color, bool propagateUp, bool propagateDown ) { m_colors[id] = color; if ( propagateUp && m_parent ) { m_parent->setColor( id, color, true, false ); } if ( propagateDown ) { for ( int i = 0; i < m_children.size(); ++i ) { m_children[i]->setColor( id, color, false, true ); } } } void Tree::setColor( int id, int colorId, QColor& color ) { if ( id == m_id ) { m_colors[colorId] = color; for ( int i = 0; i < m_children.size(); ++i ) { m_children[i]->setColor( m_children[i]->getId(), colorId, color ); } } else { for ( int i = 0; i < m_children.size(); ++i ) { m_children[i]->setColor( id, colorId, color ); } } } int Tree::getId() { return m_id; } float Tree::getValue() { return m_value; } void Tree::setValue( float value ) { m_value = value; } int Tree::getNumLeaves() { int numLeaves = 0; if ( m_children.size() > 0 ) { for ( int i = 0; i < m_children.size(); ++i ) { numLeaves += m_children[i]->getNumLeaves(); } } else { numLeaves = 1; } return numLeaves; } QVector3D Tree::getTexturePosition() { return m_texturePosition; } void Tree::setTexturePosition( QVector3D value ) { m_texturePosition = value; }
17.684211
83
0.520833
mhough
4da20923bcfa8a49967d6d80ae93d584b57e07d4
3,425
cpp
C++
samples/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/remarks.cpp
hamarb123/dotnet-api-docs
6aeb55784944a2f1f5e773b657791cbd73a92dd4
[ "CC-BY-4.0", "MIT" ]
421
2018-04-01T01:57:50.000Z
2022-03-28T15:24:42.000Z
samples/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/remarks.cpp
hamarb123/dotnet-api-docs
6aeb55784944a2f1f5e773b657791cbd73a92dd4
[ "CC-BY-4.0", "MIT" ]
5,797
2018-04-02T21:12:23.000Z
2022-03-31T23:54:38.000Z
samples/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/remarks.cpp
hamarb123/dotnet-api-docs
6aeb55784944a2f1f5e773b657791cbd73a92dd4
[ "CC-BY-4.0", "MIT" ]
1,482
2018-03-31T11:26:20.000Z
2022-03-30T22:36:45.000Z
 using namespace System; using namespace System::Security; using namespace System::Security::Permissions; int main() { try { FileIOPermission^ fileIOPerm1; fileIOPerm1 = gcnew FileIOPermission(PermissionState::Unrestricted); // Tests for: SetPathList(FileIOPermissionAccess,String) // Test the Read list fileIOPerm1->SetPathList(FileIOPermissionAccess::Read, "C:\\documents"); Console::WriteLine("Read access before SetPathList = "); for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Read)) { Console::WriteLine("\t" + path); } //<Snippet12> fileIOPerm1->SetPathList(FileIOPermissionAccess::Read, "C:\\temp"); //</Snippet12> Console::WriteLine("Read access after SetPathList = "); for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Read)) { Console::WriteLine("\t" + path); } // Test the Write list fileIOPerm1->SetPathList(FileIOPermissionAccess::Write, "C:\\temp"); Console::WriteLine("Write access before SetPathList = "); for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Write)) { Console::WriteLine("\t" + path); } //<Snippet13> fileIOPerm1->SetPathList(FileIOPermissionAccess::Write, "C:\\documents"); //</Snippet13> Console::WriteLine("Write access after SetPathList = "); for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Write)) { Console::WriteLine("\t" + path); } // Tests for: SetPathList(FileIOPermissionAccess,String[]) // Test the Read list fileIOPerm1->SetPathList(FileIOPermissionAccess::Read, gcnew array<String^> {"C:\\pictures", "C:\\music"}); Console::WriteLine("Read access before SetPathList = "); for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Read)) { Console::WriteLine("\t" + path); } //<Snippet14> fileIOPerm1->SetPathList(FileIOPermissionAccess::Read, gcnew array<String^> {"C:\\temp", "C:\\Documents"}); //</Snippet14> Console::WriteLine("Read access after SetPathList = "); for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Read)) { Console::WriteLine("\t" + path); } // Test the Write list fileIOPerm1->SetPathList(FileIOPermissionAccess::Write, gcnew array<String^> {"C:\\temp", "C:\\Documents"}); Console::WriteLine("Write access before SetPathList = "); for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Write)) { Console::WriteLine("\t" + path); } //<Snippet15> fileIOPerm1->SetPathList(FileIOPermissionAccess::Write, gcnew array<String^> {"C:\\pictures", "C:\\music"}); //</Snippet15> Console::WriteLine("Write access after SetPathList = "); for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Write)) { Console::WriteLine("\t" + path); } } catch (Exception^ ex) { Console::WriteLine(ex->Message); } }
36.052632
117
0.597372
hamarb123
4da2ad46b72c9c6a89fba8cbf75af5eca1e0d36a
566
hxx
C++
Legolas/Matrix/tst/ArbitraryPrecision/APFloat.hxx
LaurentPlagne/Legolas
fdf533528baf7ab5fcb1db15d95d2387b3e3723c
[ "MIT" ]
null
null
null
Legolas/Matrix/tst/ArbitraryPrecision/APFloat.hxx
LaurentPlagne/Legolas
fdf533528baf7ab5fcb1db15d95d2387b3e3723c
[ "MIT" ]
null
null
null
Legolas/Matrix/tst/ArbitraryPrecision/APFloat.hxx
LaurentPlagne/Legolas
fdf533528baf7ab5fcb1db15d95d2387b3e3723c
[ "MIT" ]
1
2021-02-11T14:43:25.000Z
2021-02-11T14:43:25.000Z
/** * project DESCARTES * * @file APFloat.hxx * * @author Laurent PLAGNE * @date june 2004 - january 2005 * * @par Modifications * - author date object * * (c) Copyright EDF R&D - CEA 2001-2005 */ #ifndef __LEGOLAS_APFLOAT_HXX__ #define __LEGOLAS_APFLOAT_HXX__ #include "apfloat.h" #include "apcplx.h" template <int PRECISION> class APFloat : public apfloat { public: APFloat( void ):apfloat(0,PRECISION){}; template <class SOURCE> APFloat(const SOURCE & source):apfloat(source){ (*this).prec(PRECISION); }; }; #endif
15.722222
49
0.660777
LaurentPlagne
4da474db05c2e6b20c92184ccd98bc28b6686d82
415
hpp
C++
Etaler/Algorithms/Anomaly.hpp
mewpull/Etaler
fcc88a96ec05af34d7c1717beef0e35671015152
[ "BSD-3-Clause" ]
1
2020-04-19T17:23:49.000Z
2020-04-19T17:23:49.000Z
Etaler/Algorithms/Anomaly.hpp
mewpull/Etaler
fcc88a96ec05af34d7c1717beef0e35671015152
[ "BSD-3-Clause" ]
null
null
null
Etaler/Algorithms/Anomaly.hpp
mewpull/Etaler
fcc88a96ec05af34d7c1717beef0e35671015152
[ "BSD-3-Clause" ]
null
null
null
#pragma once #include <Etaler/Core/Tensor.hpp> namespace et { static float anomaly(const Tensor& pred, const Tensor& real) { et_assert(real.dtype() == DType::Bool); et_assert(pred.dtype() == DType::Bool); et_assert(real.shape() == pred.shape()); Tensor should_predict = sum(real); Tensor not_predicted = sum(!pred && real).cast(DType::Float); return (not_predicted/should_predict).toHost<float>()[0]; } }
21.842105
62
0.703614
mewpull
4da7af0c2b116e8de289895eb28ad22d34c79805
2,813
cpp
C++
base_engine/src/components/indexer/local_descriptor/sift_extractor.cpp
AiPratice/VideoAnalysisEngine
e6aa67e5b0d08d6b3ae1b63988982ef31e60bf7a
[ "Apache-2.0" ]
23
2018-09-12T10:04:32.000Z
2022-02-13T12:07:53.000Z
base_engine/src/components/indexer/local_descriptor/sift_extractor.cpp
AiPratice/VideoAnalysisTool
e6aa67e5b0d08d6b3ae1b63988982ef31e60bf7a
[ "Apache-2.0" ]
1
2021-03-24T03:37:28.000Z
2021-03-24T03:37:28.000Z
base_engine/src/components/indexer/local_descriptor/sift_extractor.cpp
AiPratice/VideoAnalysisTool
e6aa67e5b0d08d6b3ae1b63988982ef31e60bf7a
[ "Apache-2.0" ]
12
2018-09-12T10:04:33.000Z
2021-12-20T12:47:07.000Z
#include "sift_extractor.h" #include "sift_feat.h" #include "../../../common/utils/io_utils.h" #include <boost/log/trivial.hpp> #include <chrono> #include <ctime> #include <fstream> #include <cmath> #include <sys/stat.h> #include <thread> using namespace std; using namespace vrs::common; namespace vrs { namespace components{ void sift_extractor::process_images(unsigned int start_i, unsigned int num_images, const vector<string> &images, const char *in_folder_path, const char *out_folder_path, unsigned int thread_index, bool is_skip_existing) { unsigned int count_proc_thread = 0; unsigned int end_i = start_i + num_images; for (unsigned int i = start_i; i < end_i; i++) { string img_filename = images[i]; if ((count_proc_thread++ % PROGRESS_INTERVAL) == 0) { BOOST_LOG_TRIVIAL(info)<< "线程" << thread_index << "正在处理第" << i << "张图片。图片范围:" << start_i << "~" << end_i; } //生成新的文件名 int last_dot_index = img_filename.find_last_of('.'); string out_filename = img_filename.substr(0, last_dot_index) + ".siftb"; string out_file_path = string(out_folder_path) + "/" + out_filename; //检查文件是否已经存在 if (is_skip_existing && io_utils::is_file_exist(out_file_path)) { continue; } string image_path = string(in_folder_path) + "/" + img_filename; if(!sift_feat::image_to_feature(image_path.c_str(),out_file_path.c_str())){ BOOST_LOG_TRIVIAL(error) << "从图像文件生成特征文件"; } } } void sift_extractor::extract(const char *in_folder_path, const char *out_folder_path, unsigned int num_least_threads, bool is_skip_existing) { if (!in_folder_path) { BOOST_LOG_TRIVIAL(error)<< "sift_extractor:图像输入文件夹为NULL"; return; } vector<string> images; io_utils::get_dir_files(in_folder_path,".jpg",images); unsigned int num_images = images.size(); //每个线程需要处理的图像数量 unsigned int computations_per_thread = static_cast<unsigned int>(floor(num_images/num_least_threads)); unsigned int rest_computations = num_images % num_least_threads; if(rest_computations > 0) { num_least_threads++; //如果剩余处理数量不为0,那么多分配一个线程去完成剩余任务。 } thread extract_threads[num_least_threads]; unsigned int start_i = 0,i=0; if(rest_computations == 0) { for(;i<num_least_threads;i++) { extract_threads[i] = thread(process_images,start_i,computations_per_thread,images,in_folder_path,out_folder_path,i,is_skip_existing); start_i += computations_per_thread; } } else { for(;i<num_least_threads-1;i++) { extract_threads[i] = thread(process_images,start_i,computations_per_thread,images,in_folder_path,out_folder_path,i,is_skip_existing); start_i += computations_per_thread; } extract_threads[i] = thread(process_images,start_i,rest_computations,images,in_folder_path,out_folder_path,i,is_skip_existing); } for(i=0;i<num_least_threads;i++){ extract_threads[i].join(); } } } }
31.606742
136
0.742268
AiPratice
4da85f9f4aeae3f72f131919678d630c30d6e6cf
6,408
cpp
C++
QP/v5.4.2/qpcpp/examples/win32/comp_qm/alarm.cpp
hyller/GladiatorCots
36a69df68675bb40b562081c531e6674037192a8
[ "Unlicense" ]
null
null
null
QP/v5.4.2/qpcpp/examples/win32/comp_qm/alarm.cpp
hyller/GladiatorCots
36a69df68675bb40b562081c531e6674037192a8
[ "Unlicense" ]
null
null
null
QP/v5.4.2/qpcpp/examples/win32/comp_qm/alarm.cpp
hyller/GladiatorCots
36a69df68675bb40b562081c531e6674037192a8
[ "Unlicense" ]
null
null
null
//**************************************************************************** // Model: comp.qm // File: ./alarm.cpp // // This code has been generated by QM tool (see state-machine.com/qm). // DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost. // // This program is open source 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. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. //**************************************************************************** //${.::alarm.cpp} ............................................................ #include "qpcpp.h" #include "bsp.h" #include "alarm.h" #include "clock.h" Q_DEFINE_THIS_FILE // Alarm component -------------------- //${Components::Alarm} ....................................................... //${Components::Alarm::Alarm} ................................................ Alarm::Alarm() : QMsm(Q_STATE_CAST(&Alarm::initial)) {} //${Components::Alarm::SM} ................................................... QP::QState Alarm::initial(Alarm * const me, QP::QEvt const * const e) { static struct { QP::QMState const *target; QP::QActionHandler act[2]; } const tatbl_ = { // transition-action table &off_s, { Q_ACTION_CAST(&off_e), // entry Q_ACTION_CAST(0) // zero terminator } }; // ${Components::Alarm::SM::initial} me->m_alarm_time = 12U*60U; (void)e; // unused parameter return QM_TRAN_INIT(&tatbl_); } //${Components::Alarm::SM::off} .............................................. QP::QMState const Alarm::off_s = { static_cast<QP::QMState const *>(0), // superstate (top) Q_STATE_CAST(&off), Q_ACTION_CAST(&off_e), Q_ACTION_CAST(&off_x), Q_ACTION_CAST(0) // no intitial tran. }; // ${Components::Alarm::SM::off} QP::QState Alarm::off_e(Alarm * const me) { // while in the off state, the alarm is kept in decimal format me->m_alarm_time = (me->m_alarm_time/60)*100 + me->m_alarm_time%60; BSP_showTime24H("*** Alarm OFF ", me->m_alarm_time, 100U); return QM_ENTRY(&off_s); } // ${Components::Alarm::SM::off} QP::QState Alarm::off_x(Alarm * const me) { // upon exit, the alarm is converted to binary format me->m_alarm_time = (me->m_alarm_time/100U)*60U + me->m_alarm_time%100U; return QM_EXIT(&off_s); } // ${Components::Alarm::SM::off} QP::QState Alarm::off(Alarm * const me, QP::QEvt const * const e) { QP::QState status_; switch (e->sig) { // ${Components::Alarm::SM::off::ALARM_ON} case ALARM_ON_SIG: { // ${Components::Alarm::SM::off::ALARM_ON::[alarminrange?]} if ((me->m_alarm_time / 100U < 24U) && (me->m_alarm_time % 100U < 60U)) { static struct { QP::QMState const *target; QP::QActionHandler act[3]; } const tatbl_ = { // transition-action table &on_s, { Q_ACTION_CAST(&off_x), // exit Q_ACTION_CAST(&on_e), // entry Q_ACTION_CAST(0) // zero terminator } }; status_ = QM_TRAN(&tatbl_); } // ${Components::Alarm::SM::off::ALARM_ON::[else]} else { me->m_alarm_time = 0U; BSP_showTime24H("*** Alarm reset", me->m_alarm_time, 100U); status_ = QM_HANDLED(); } break; } // ${Components::Alarm::SM::off::ALARM_SET} case ALARM_SET_SIG: { // while setting, the alarm is kept in decimal format me->m_alarm_time = (10U * me->m_alarm_time + Q_EVT_CAST(SetEvt)->digit) % 10000U; BSP_showTime24H("*** Alarm reset ", me->m_alarm_time, 100U); status_ = QM_HANDLED(); break; } default: { status_ = QM_SUPER(); break; } } return status_; } //${Components::Alarm::SM::on} ............................................... QP::QMState const Alarm::on_s = { static_cast<QP::QMState const *>(0), // superstate (top) Q_STATE_CAST(&on), Q_ACTION_CAST(&on_e), Q_ACTION_CAST(0), // no exit action Q_ACTION_CAST(0) // no intitial tran. }; // ${Components::Alarm::SM::on} QP::QState Alarm::on_e(Alarm * const me) { BSP_showTime24H("*** Alarm ON ", me->m_alarm_time, 60U); return QM_ENTRY(&on_s); } // ${Components::Alarm::SM::on} QP::QState Alarm::on(Alarm * const me, QP::QEvt const * const e) { QP::QState status_; switch (e->sig) { // ${Components::Alarm::SM::on::ALARM_OFF} case ALARM_OFF_SIG: { static struct { QP::QMState const *target; QP::QActionHandler act[2]; } const tatbl_ = { // transition-action table &off_s, { Q_ACTION_CAST(&off_e), // entry Q_ACTION_CAST(0) // zero terminator } }; status_ = QM_TRAN(&tatbl_); break; } // ${Components::Alarm::SM::on::ALARM_SET} case ALARM_SET_SIG: { BSP_showMsg("*** Cannot set Alarm when it is ON"); status_ = QM_HANDLED(); break; } // ${Components::Alarm::SM::on::TIME} case TIME_SIG: { // ${Components::Alarm::SM::on::TIME::[Q_EVT_CAST(TimeEvt)->current_ti~} if (Q_EVT_CAST(TimeEvt)->current_time == me->m_alarm_time) { BSP_showMsg("ALARM!!!"); // asynchronously post the event to the container AO APP_alarmClock->POST(Q_NEW(QEvt, ALARM_SIG), this); status_ = QM_HANDLED(); } else { status_ = QM_UNHANDLED(); } break; } default: { status_ = QM_SUPER(); break; } } (void)me; // avoid compiler warning in case 'me' is not used return status_; }
35.798883
84
0.50515
hyller
4dacb045a253c4f5e928d1683fefea4bcfcb7711
2,838
cpp
C++
src/hdc1000/hdc1000.cpp
moredu/upm
d6f76ff8c231417666594214679c49399513112e
[ "MIT" ]
619
2015-01-14T23:50:18.000Z
2019-11-08T14:04:33.000Z
src/hdc1000/hdc1000.cpp
moredu/upm
d6f76ff8c231417666594214679c49399513112e
[ "MIT" ]
576
2015-01-02T09:55:14.000Z
2019-11-12T15:31:10.000Z
src/hdc1000/hdc1000.cpp
moredu/upm
d6f76ff8c231417666594214679c49399513112e
[ "MIT" ]
494
2015-01-14T18:33:56.000Z
2019-11-07T10:08:15.000Z
/* * Author: Norbert Wesp <nwesp@phytec.de> * Copyright (c) 2017 Phytec Messtechnik GmbH. * * based on: RIOT-driver hdc1000 by Johann Fischer <j.fischer@phytec.de> * * 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 */ #include <iostream> #include <string> #include <stdexcept> #include <unistd.h> #include <stdlib.h> #include <endian.h> #include "hdc1000.hpp" using namespace upm; HDC1000::HDC1000(int bus, int devAddr) : m_i2ControlCtx(bus) { m_temperature = 0; m_humidity = 0; m_name = HDC1000_NAME; m_controlAddr = devAddr; m_bus = bus; mraa::Result ret = m_i2ControlCtx.address(m_controlAddr); if (ret != mraa::SUCCESS) { throw std::invalid_argument(std::string(__FUNCTION__) + ": mraa_i2c_address() failed"); } if (checkID() != 0) { /* sensor_id does not match! maybe wrong sensor chosen? */ throw std::invalid_argument(std::string(__FUNCTION__) + ": checkID() failed"); } sampleData(); } int HDC1000::checkID(void) { uint8_t tmp[2]; uint16_t id; int re = 0; re = m_i2ControlCtx.readBytesReg(HDC1000_DEVICE_ID_REG, tmp, 2); if (re != 2) { /* not enough bytes were read! */ return -1; } id = ((uint16_t)tmp[0] << 8) | tmp[1]; if (id != HDC1000_DEVICE_ID) { return -1; } return 0; } void HDC1000::resetSensor(void) { mraa::Result ret = m_i2ControlCtx.writeByte(0); if (ret != mraa::SUCCESS) { throw std::invalid_argument(std::string(__FUNCTION__) + ": mraa_i2c_write_byte() failed"); } usleep(SLEEP_SEC); } void HDC1000::sampleData(void) { uint8_t itemp[4]; uint16_t traw, hraw; int re = 0; resetSensor(); re = m_i2ControlCtx.read(itemp, 4); if (re != 4) { /* not enough bytes were read! */ throw std::invalid_argument(std::string(__FUNCTION__) + ": mraa_i2c_read(4) failed"); } traw = ((uint16_t)itemp[0] << 8) | itemp[1]; m_temperature = ((((int32_t)traw * 16500) >> 16) -4000); hraw = ((uint16_t)itemp[2] << 8) | itemp[3]; m_humidity = (((int32_t)hraw * 10000) >> 16); } float HDC1000::getTemperature(int bSampleData) { if (bSampleData) { sampleData(); } return (float)(m_temperature * 0.01); } float HDC1000::getTemperature() { return getTemperature(false); } float HDC1000::getHumidity(int bSampleData) { if (bSampleData) { sampleData(); } return (float)(m_humidity * 0.01); } float HDC1000::getHumidity() { return getHumidity(false); }
21.022222
75
0.59549
moredu
4dad07d32ef5afd291098b79cbf7d4e087488044
747
hpp
C++
test/data-tests/include/common.hpp
zhaitianduo/libosmium
42fc3238f942baac47d8520425664376478718b1
[ "BSL-1.0" ]
4,526
2015-01-01T15:31:00.000Z
2022-03-31T17:33:49.000Z
test/data-tests/include/common.hpp
zhaitianduo/libosmium
42fc3238f942baac47d8520425664376478718b1
[ "BSL-1.0" ]
4,497
2015-01-01T15:29:12.000Z
2022-03-31T19:19:35.000Z
test/data-tests/include/common.hpp
zhaitianduo/libosmium
42fc3238f942baac47d8520425664376478718b1
[ "BSL-1.0" ]
3,023
2015-01-01T18:40:53.000Z
2022-03-30T13:30:46.000Z
#ifndef COMMON_HPP #define COMMON_HPP #include <osmium/index/map/dummy.hpp> #include <osmium/index/map/sparse_mem_array.hpp> #include <osmium/geom/wkt.hpp> #include <osmium/handler.hpp> #include <osmium/handler/node_locations_for_ways.hpp> #include <osmium/io/xml_input.hpp> #include <osmium/visitor.hpp> using index_neg_type = osmium::index::map::Dummy<osmium::unsigned_object_id_type, osmium::Location>; using index_pos_type = osmium::index::map::SparseMemArray<osmium::unsigned_object_id_type, osmium::Location>; using location_handler_type = osmium::handler::NodeLocationsForWays<index_pos_type, index_neg_type>; #include "check_basics_handler.hpp" #include "check_wkt_handler.hpp" #include "testdata-testcases.hpp" #endif // COMMON_HPP
32.478261
109
0.803213
zhaitianduo
4dae1d24938f250fb960ddb05d89a72f274f2652
5,755
cpp
C++
src/FeedController.cpp
JadedCtrl/rifen
eddbc45d987abe6524715a25ed56e09e8c349300
[ "MIT" ]
4
2021-03-22T06:38:33.000Z
2021-03-23T04:57:44.000Z
src/FeedController.cpp
JadedCtrl/rifen
eddbc45d987abe6524715a25ed56e09e8c349300
[ "MIT" ]
12
2021-02-25T22:13:36.000Z
2021-05-03T01:21:50.000Z
src/FeedController.cpp
JadedCtrl/rifen
eddbc45d987abe6524715a25ed56e09e8c349300
[ "MIT" ]
1
2021-10-11T06:40:06.000Z
2021-10-11T06:40:06.000Z
/* * Copyright 2020, Jaidyn Levesque <jadedctrl@teknik.io> * All rights reserved. Distributed under the terms of the MIT license. */ #include "FeedController.h" #include <iostream> #include <Catalog.h> #include <Directory.h> #include <FindDirectory.h> #include <Message.h> #include <MessageRunner.h> #include <Notification.h> #include <StringList.h> #include "Daemon.h" #include "Entry.h" #include "Preferences.h" #include "SourceManager.h" #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "FeedController" FeedController::FeedController() : fEnqueuedTotal(0), fMainThread(find_thread(NULL)), fDownloadThread(0), fParseThread(0), fDownloadQueue(new BObjectList<Feed>()), fMessageRunner(new BMessageRunner(be_app, BMessage(kControllerCheck), 50000, -1)) { fDownloadThread = spawn_thread(_DownloadLoop, "here, eat this", B_NORMAL_PRIORITY, &fMainThread); fParseThread = spawn_thread(_ParseLoop, "oki tnx nomnomnom", B_NORMAL_PRIORITY, &fMainThread); resume_thread(fDownloadThread); resume_thread(fParseThread); } FeedController::~FeedController() { kill_thread(fDownloadThread); kill_thread(fParseThread); } void FeedController::MessageReceived(BMessage* msg) { switch (msg->what) { case kEnqueueFeed: { int i = 0; BString feedID; BString feedSource; ssize_t size = sizeof(Feed); while (msg->HasString("feed_identifiers", i)) { msg->FindString("feed_identifiers", i, &feedID); msg->FindString("feed_sources", i, &feedSource); Feed* feed = SourceManager::GetFeed(feedID.String(), feedSource.String()); fDownloadQueue->AddItem(feed); _SendProgress(); i++; } fMessageRunner->SetCount(-1); break; } case kUpdateSubscribed: { BObjectList<Feed> list = SourceManager::Feeds(); fDownloadQueue->AddList(&list); _SendProgress(); break; } case kClearQueue: { fDownloadQueue->MakeEmpty(); break; } case kControllerCheck: { _ProcessQueueItem(); _ReceiveStatus(); break; } } } void FeedController::_SendProgress() { int32 dqCount = fDownloadQueue->CountItems(); if (fEnqueuedTotal < dqCount) fEnqueuedTotal = dqCount; BMessage progress(kProgress); progress.AddInt32("total", fEnqueuedTotal); progress.AddInt32("current", fEnqueuedTotal - dqCount); be_app->MessageReceived(&progress); if (dqCount == 0) fEnqueuedTotal = 0; } void FeedController::_ProcessQueueItem() { if (has_data(fDownloadThread) && !fDownloadQueue->IsEmpty()) { Feed* feed = fDownloadQueue->ItemAt(0); fDownloadQueue->RemoveItemAt(0); send_data(fDownloadThread, 0, (void*)feed, sizeof(Feed)); BMessage downloadInit = BMessage(kDownloadStart); downloadInit.AddString("feed_name", feed->Title()); downloadInit.AddString("feed_url", feed->Url().UrlString()); ((App*)be_app)->MessageReceived(&downloadInit); } } void FeedController::_ReceiveStatus() { thread_id sender; while (has_data(find_thread(NULL))) { Feed* feedBuffer = (Feed*)malloc(sizeof(Feed)); int32 code = receive_data(&sender, (void*)feedBuffer, sizeof(Feed)); switch (code) { case kDownloadComplete: { BMessage complete = BMessage(kDownloadComplete); complete.AddString("feed_name", feedBuffer->Title()); complete.AddString("feed_url", feedBuffer->Url().UrlString()); ((App*)be_app)->MessageReceived(&complete); send_data(fParseThread, 0, (void*)feedBuffer, sizeof(Feed)); break; } case kDownloadFail: { BMessage failure = BMessage(kDownloadFail); failure.AddString("feed_name", feedBuffer->Title()); failure.AddString("feed_url", feedBuffer->Url().UrlString()); ((App*)be_app)->MessageReceived(&failure); _SendProgress(); break; } case kParseFail: { BMessage failure = BMessage(kParseFail); failure.AddString("feed_name", feedBuffer->Title()); failure.AddString("feed_url", feedBuffer->Url().UrlString()); ((App*)be_app)->MessageReceived(&failure); _SendProgress(); break; } // If parse was successful, the code is the amount of new entries default: BMessage complete = BMessage(kParseComplete); complete.AddString("feed_name", feedBuffer->Title()); complete.AddString("feed_url", feedBuffer->Url().UrlString()); complete.AddInt32("entry_count", code); ((App*)be_app)->MessageReceived(&complete); _SendProgress(); break; } free(feedBuffer); } } int32 FeedController::_DownloadLoop(void* data) { thread_id main = *((thread_id*)data); thread_id sender; while (true) { Feed* feedBuffer = (Feed*)malloc(sizeof(Feed)); receive_data(&sender, (void*)feedBuffer, sizeof(Feed)); std::cout << B_TRANSLATE("Downloading feed from ") << feedBuffer->Url().UrlString() << "…\n"; if (SourceManager::Fetch(feedBuffer)) { send_data(main, kDownloadComplete, (void*)feedBuffer, sizeof(Feed)); } else { send_data(main, kDownloadFail, (void*)feedBuffer, sizeof(Feed)); } free(feedBuffer); } return 0; } int32 FeedController::_ParseLoop(void* data) { thread_id main = *((thread_id*)data); thread_id sender; while (true) { Feed* feedBuffer = (Feed*)malloc(sizeof(Feed)); receive_data(&sender, (void*)feedBuffer, sizeof(Feed)); BObjectList<Entry> entries; int32 entriesCount = 0; BString feedTitle; BUrl feedUrl = feedBuffer->Url(); SourceManager::Parse(feedBuffer); entries = feedBuffer->NewEntries(); entriesCount = entries.CountItems(); feedTitle = feedBuffer->Title(); for (int i = 0; i < entriesCount; i++) entries.ItemAt(i)->Filetize(((App*)be_app)->fPreferences->EntryDir()); entries.MakeEmpty(); SourceManager::EditFeed(feedBuffer); send_data(main, entriesCount, (void*)feedBuffer, sizeof(Feed)); free(feedBuffer); } return 0; }
23.205645
82
0.699913
JadedCtrl
4db0b6eeb82823b53363ac6c2a5cd5b8bce8c6d4
4,859
cpp
C++
toonz/sources/stdfx/igs_perlin_noise.cpp
wofogen/tahoma2d
ce5a89a7b1027b2c1769accb91184a2ee6442b4d
[ "BSD-3-Clause" ]
36
2020-05-18T22:26:35.000Z
2022-02-19T00:09:25.000Z
toonz/sources/stdfx/igs_perlin_noise.cpp
LibrePhone/opentoonz
cb95a29db4c47ab1f36a6e85a039c4c9c901f88a
[ "BSD-3-Clause" ]
22
2017-03-16T18:52:36.000Z
2019-09-09T06:02:53.000Z
toonz/sources/stdfx/igs_perlin_noise.cpp
LibrePhone/opentoonz
cb95a29db4c47ab1f36a6e85a039c4c9c901f88a
[ "BSD-3-Clause" ]
9
2019-05-27T02:48:16.000Z
2022-03-29T12:32:04.000Z
#include <cmath> // pow() #include "iwa_noise1234.h" namespace { double perlin_noise_3d_(const double x, const double y, const double z, const int octaves_start // 0<= , const int octaves_end // 0<= , const double persistence // Not 0 // 1/4 or 1/2 or 1/sqrt(3) or 1/sqrt(2) or 1 or ... ) { double total = 0; Noise1234 pn; for (int ii = octaves_start; ii <= octaves_end; ++ii) { const double frequency = pow(2.0, ii); // 1,2,4,8... const double amplitude = pow(persistence, ii); total += pn.noise(x * frequency, y * frequency, z * frequency) * amplitude; } return total; } double perlin_noise_minmax_(const int octaves_start // 0<= , const int octaves_end // 0<= , const double persistence // Not 0 // 1/4 or 1/2 or 1/sqrt(3) or 1/sqrt(2) or 1 or ... ) { double total = 0; for (int ii = octaves_start; ii <= octaves_end; ++ii) { total += pow(persistence, ii); } return total; } } //-------------------------------------------------------------------- #include <stdexcept> // std::domain_error(-) #include <limits> // std::numeric_limits #include "igs_ifx_common.h" /* igs::image::rgba */ #include "igs_perlin_noise.h" namespace { template <class T> void change_(T *image_array, const int height // pixel , const int width // pixel , const int channels, const bool alpha_rendering_sw, const double a11 // geometry of 2D affine transformation , const double a12, const double a13, const double a21, const double a22, const double a23, const double zz, const int octaves_start // 0<= , const int octaves_end // 0<= , const double persistence // Not 0 ) { const int max_div = std::numeric_limits<T>::max(); const int max_div_2 = max_div / 2; // 255 / 2 --> 127 // 65535 / 2 --> 32767 // const double max_mul = static_cast<double>(max_div_2+0.999999); // const double max_off = static_cast<double>(max_div_2+1); const double max_mul = static_cast<double>(max_div_2 + 0.499999); const double max_off = static_cast<double>(max_div_2 + 1.5); /* -1 .............. 0 ......... 1 x127+0.499999 ------------------------------------------ -127+0.499999 ... 0 ......... 127+0.499999 +127+1.5 ... 127+1.5 ... 127+1.5 ------------------------------------------ 1.000001 ........ 127+1.5 ... 255.999999 integer ------------------------------------------ 1 ............... 128 ....... 255 */ const double maxi = perlin_noise_minmax_(octaves_start, octaves_end, persistence); using namespace igs::image::rgba; T *image_crnt = image_array; for (int yy = 0; yy < height; ++yy) { for (int xx = 0; xx < width; ++xx, image_crnt += channels) { const T val = static_cast<T>( perlin_noise_3d_(xx * a11 + yy * a12 + a13, xx * a21 + yy * a22 + a23, zz, octaves_start, octaves_end, persistence) / maxi * max_mul + max_off); for (int zz = 0; zz < channels; ++zz) { if (!alpha_rendering_sw && (alp == zz)) { image_crnt[zz] = static_cast<T>(max_div); } else { image_crnt[zz] = val; } } } } } } // #include "igs_geometry2d.h" void igs::perlin_noise::change( unsigned char *image_array, const int height // pixel , const int width // pixel , const int channels, const int bits, const bool alpha_rendering_sw, const double a11 // geometry of 2D affine transformation , const double a12, const double a13, const double a21, const double a22, const double a23, const double zz, const int octaves_start // 0... , const int octaves_end // 0... , const double persistence // not 0 ) { // igs::geometry2d::affine af(a11 , a12 , a13 , a21 , a22 , a23); // igs::geometry2d::translate(); if (std::numeric_limits<unsigned char>::digits == bits) { change_(image_array, height, width, channels, alpha_rendering_sw, a11, a12, a13, a21, a22, a23, zz, octaves_start, octaves_end, persistence); } else if (std::numeric_limits<unsigned short>::digits == bits) { change_(reinterpret_cast<unsigned short *>(image_array), height, width, channels, alpha_rendering_sw, a11, a12, a13, a21, a22, a23, zz, octaves_start, octaves_end, persistence); } else { throw std::domain_error("Bad bits,Not uchar/ushort"); } }
36.810606
80
0.529739
wofogen
4db6989b183d07f065f757f7901cdeda556dacae
97
hpp
C++
Vega/Source/Vega/Vendor/Imgui.hpp
killdaNME/RyZen7m-3000apu
a5d2ce7966f2c9e5cc7f64d9d5bfaa5986cd7b48
[ "MIT" ]
1
2020-12-13T15:31:53.000Z
2020-12-13T15:31:53.000Z
Vega/Source/Vega/Vendor/Imgui.hpp
killdaNME/RyZen7m-3000apu
a5d2ce7966f2c9e5cc7f64d9d5bfaa5986cd7b48
[ "MIT" ]
null
null
null
Vega/Source/Vega/Vendor/Imgui.hpp
killdaNME/RyZen7m-3000apu
a5d2ce7966f2c9e5cc7f64d9d5bfaa5986cd7b48
[ "MIT" ]
null
null
null
#include <imgui.h> #include <examples/imgui_impl_glfw.h> #include <examples/imgui_impl_opengl3.h>
32.333333
40
0.804124
killdaNME
4dbaab39ff1bdd4141f38cbb132cabba06db39ec
1,468
cpp
C++
src/game/server/tf/bot/behavior/tf_bot_dead.cpp
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
6
2022-01-23T09:40:33.000Z
2022-03-20T20:53:25.000Z
src/game/server/tf/bot/behavior/tf_bot_dead.cpp
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
null
null
null
src/game/server/tf/bot/behavior/tf_bot_dead.cpp
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
1
2022-02-06T21:05:23.000Z
2022-02-06T21:05:23.000Z
//========= Copyright Valve Corporation, All rights reserved. ============// // tf_bot_dead.cpp // Push up daisies // Michael Booth, May 2009 #include "cbase.h" #include "tf_player.h" #include "tf_gamerules.h" #include "bot/tf_bot.h" #include "bot/behavior/tf_bot_dead.h" #include "bot/behavior/tf_bot_behavior.h" #include "nav_mesh.h" //--------------------------------------------------------------------------------------------- ActionResult< CTFBot > CTFBotDead::OnStart( CTFBot *me, Action< CTFBot > *priorAction ) { m_deadTimer.Start(); return Continue(); } //--------------------------------------------------------------------------------------------- ActionResult< CTFBot > CTFBotDead::Update( CTFBot *me, float interval ) { if ( me->IsAlive() ) { // how did this happen? return ChangeTo( new CTFBotMainAction, "This should not happen!" ); } if ( m_deadTimer.IsGreaterThen( 5.0f ) ) { if ( me->HasAttribute( CTFBot::REMOVE_ON_DEATH ) ) { // remove dead bots engine->ServerCommand( UTIL_VarArgs( "kickid %d\n", me->GetUserID() ) ); } else if ( me->HasAttribute( CTFBot::BECOME_SPECTATOR_ON_DEATH ) ) { me->ChangeTeam( TEAM_SPECTATOR, false, true ); return Done(); } } #ifdef TF_RAID_MODE if ( TFGameRules()->IsRaidMode() && me->GetTeamNumber() == TF_TEAM_RED ) { // dead defenders go to spectator for recycling me->ChangeTeam( TEAM_SPECTATOR, false, true ); } #endif // TF_RAID_MODE return Continue(); }
24.881356
95
0.586512
cstom4994
4dbb7b500506a772700d48c7bceae207b03479a1
1,597
cc
C++
src/word_align/ttablewithmax.cc
nrc-cnrc/Portage-SMT-TAS
73f5a65de4adfa13008ea9a01758385c97526059
[ "MIT" ]
null
null
null
src/word_align/ttablewithmax.cc
nrc-cnrc/Portage-SMT-TAS
73f5a65de4adfa13008ea9a01758385c97526059
[ "MIT" ]
null
null
null
src/word_align/ttablewithmax.cc
nrc-cnrc/Portage-SMT-TAS
73f5a65de4adfa13008ea9a01758385c97526059
[ "MIT" ]
null
null
null
/** * @author Aaron Tikuisis * @file ttablewithmax.cc Implementation of TTableWithMax. * * * COMMENTS: * * Technologies langagieres interactives / Interactive Language Technologies * Inst. de technologie de l'information / Institute for Information Technology * Conseil national de recherches Canada / National Research Council Canada * Copyright 2005, Sa Majeste la Reine du Chef du Canada / * Copyright 2005, Her Majesty in Right of Canada */ #include "ttablewithmax.h" using namespace std; using namespace Portage; TTableWithMax::TTableWithMax(const string &filename): TTable(filename) { maxBySrc.insert(maxBySrc.begin(), numSourceWords(), 0); maxByTgt.insert(maxByTgt.begin(), numTargetWords(), 0); for (Uint i = 0; i < numSourceWords(); i++) { for (SrcDistn::const_iterator it = getSourceDistn(i).begin(); it < getSourceDistn(i).end(); it++) { maxBySrc[i] = max(maxBySrc[i], it->second); maxByTgt[it->first] = max(maxByTgt[it->first], it->second); } // for } // for } // TTableWithMax double TTableWithMax::maxSourceProb(const string &src_word) { assert(numSourceWords() == maxBySrc.size()); Uint index = sourceIndex(src_word); if (index == numSourceWords()) { return 0; } else { return maxBySrc[index]; } // if } // maxSourceProb double TTableWithMax::maxTargetProb(const string &tgt_word) { assert(numTargetWords() == maxByTgt.size()); Uint index = targetIndex(tgt_word); if (index == numTargetWords()) { return 0; } else { return maxByTgt[index]; } // if } // maxTargetProb
26.616667
79
0.680651
nrc-cnrc
4dbc0c2ce513bc772629df94d9f629a56438e820
5,865
hpp
C++
src/_cmsis_rtos/memorypool.hpp
ombre5733/weos
2c3edef042fa80baa7c8fb968ba3104b7119cf2d
[ "BSD-2-Clause" ]
11
2015-10-06T21:00:30.000Z
2021-07-27T05:54:44.000Z
src/_cmsis_rtos/memorypool.hpp
ombre5733/weos
2c3edef042fa80baa7c8fb968ba3104b7119cf2d
[ "BSD-2-Clause" ]
null
null
null
src/_cmsis_rtos/memorypool.hpp
ombre5733/weos
2c3edef042fa80baa7c8fb968ba3104b7119cf2d
[ "BSD-2-Clause" ]
1
2015-10-03T03:51:28.000Z
2015-10-03T03:51:28.000Z
/******************************************************************************* WEOS - Wrapper for embedded operating systems Copyright (c) 2013-2016, Manuel Freiberger All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #ifndef WEOS_CMSIS_RTOS_MEMORYPOOL_HPP #define WEOS_CMSIS_RTOS_MEMORYPOOL_HPP #ifndef WEOS_CONFIG_HPP #error "Do not include this file directly." #endif // WEOS_CONFIG_HPP #include "_core.hpp" #include "../memorypool.hpp" #include "../atomic.hpp" WEOS_BEGIN_NAMESPACE //! A shared memory pool. //! A shared_memory_pool is a thread-safe alternative to the memory_pool. //! Like its non-threaded counterpart, it holds the memory for up to //! (\p TNumElem) elements of type \p TElement internally and does not //! allocate them on the heap. template <typename TElement, std::size_t TNumElem> class shared_memory_pool { public: //! The type of the elements in this pool. typedef TElement element_type; private: static_assert(TNumElem > 0, "The number of elements must be non-zero."); // Every chunk has to be aligned such that it can contain either a // void* or an element_type. static const std::size_t chunk_align = alignment_of<void*>::value > alignment_of<element_type>::value ? alignment_of<void*>::value : alignment_of<element_type>::value; // The chunk size has to be large enough to store a void* or an element. static const std::size_t chunk_size = sizeof(void*) > sizeof(element_type) ? sizeof(void*) : sizeof(element_type); // One chunk must be large enough for a void* or an element_type and it // must be aligned to the stricter of both. Furthermore, the alignment // must be a multiple of the size. The aligned_storage<> takes care // of this. typedef typename aligned_storage<chunk_size, chunk_align>::type chunk_type; // The control block of a memory box. Defined as OS_BM in // ${CMSIS-RTOS}/SRC/rt_TypeDef.h. static_assert(osCMSIS_RTX <= ((4<<16) | 80), "Check the layout of OS_BM."); struct ControlBlock { void* free; void* end; std::uint32_t chunkSize; }; public: //! Constructs a shared memory pool. shared_memory_pool() noexcept { m_controlBlock.free = weos_detail::FreeList( &m_chunks[0], sizeof(chunk_type), TNumElem).first(); m_controlBlock.end = &m_chunks[TNumElem]; m_controlBlock.chunkSize = sizeof(chunk_type); } shared_memory_pool(const shared_memory_pool&) = delete; shared_memory_pool& operator=(const shared_memory_pool&) = delete; //! Returns the number of pool elements. //! Returns the number of elements for which the pool provides memory. std::size_t capacity() const noexcept { return TNumElem; } //! Checks if the memory pool is empty. //! //! Returns \p true, if the memory pool is empty. bool empty() const noexcept { // TODO: what memory order to use here? atomic_thread_fence(memory_order_seq_cst); return m_controlBlock.free == 0; } //! Allocates a chunk from the pool. //! Allocates one chunk from the memory pool and returns a pointer to it. //! If the pool is already empty, a null-pointer is returned. //! //! \note This method may be called in an interrupt context. //! //! \sa free() void* try_allocate() noexcept { return osPoolAlloc(static_cast<osPoolId>( static_cast<void*>(&m_controlBlock))); } //! Frees a chunk of memory. //! Frees a \p chunk of memory which must have been allocated through //! this pool. //! //! \note This method may be called in an interrupt context. //! //! \sa try_allocate() void free(void* chunk) noexcept { osStatus ret = osPoolFree(static_cast<osPoolId>( static_cast<void*>(&m_controlBlock)), chunk); WEOS_ASSERT(ret == osOK); } private: //! The pool's control block. Note: It is important that the control //! block is placed before the chunk array. osPoolFree() makes a boundary //! check of the chunk to be freed, which involves the control block. ControlBlock m_controlBlock; //! The memory chunks for the elements and the free-list pointers. chunk_type m_chunks[TNumElem]; }; WEOS_END_NAMESPACE #endif // WEOS_CMSIS_RTOS_MEMORYPOOL_HPP
36.886792
86
0.665644
ombre5733
4dbd800d25a8dd4bc28e1185068f0870dde9120c
1,033
cpp
C++
src/engine/mt/asmjs/task.cpp
unrealeg4825/Test-engine
12ce46dbbfd9c738e015a2d549df46c7bb4ffad0
[ "MIT" ]
3
2021-05-27T10:43:33.000Z
2021-05-27T10:44:02.000Z
src/engine/mt/asmjs/task.cpp
unrealeg4825/Test-engine
12ce46dbbfd9c738e015a2d549df46c7bb4ffad0
[ "MIT" ]
null
null
null
src/engine/mt/asmjs/task.cpp
unrealeg4825/Test-engine
12ce46dbbfd9c738e015a2d549df46c7bb4ffad0
[ "MIT" ]
3
2021-05-27T10:44:15.000Z
2021-11-18T09:20:10.000Z
#include "engine/lumix.h" #include "engine/iallocator.h" #include "engine/mt/task.h" #include "engine/mt/thread.h" #include "engine/profiler.h" #if !LUMIX_SINGLE_THREAD() namespace Lumix { namespace MT { struct TaskImpl { IAllocator& allocator; }; Task::Task(IAllocator& allocator) { m_implementation = LUMIX_NEW(allocator, TaskImpl) {allocator}; } Task::~Task() { LUMIX_DELETE(m_implementation->allocator, m_implementation); } bool Task::create(const char* name) { ASSERT(false); return false; } bool Task::destroy() { ASSERT(false); return false; } void Task::setAffinityMask(uint32 affinity_mask) { ASSERT(false); } uint32 Task::getAffinityMask() const { ASSERT(false); return 0; } bool Task::isRunning() const { return false; } bool Task::isFinished() const { return false; } bool Task::isForceExit() const { return false; } IAllocator& Task::getAllocator() { return m_implementation->allocator; } void Task::forceExit(bool wait) { ASSERT(false); } } // namespace MT } // namespace Lumix #endif
12.297619
63
0.713456
unrealeg4825
4dbead97ce18698843602200b57a6ba32c9fb5d5
2,234
cpp
C++
wstep-do-programowania/zajecia-5/mini-game.cpp
kpagacz/software-engineering
6ac3965848919d7fe7350842ae9d59d65d213ef6
[ "MIT" ]
1
2022-01-17T07:50:54.000Z
2022-01-17T07:50:54.000Z
wstep-do-programowania/zajecia-5/mini-game.cpp
kpagacz/software-engineering
6ac3965848919d7fe7350842ae9d59d65d213ef6
[ "MIT" ]
null
null
null
wstep-do-programowania/zajecia-5/mini-game.cpp
kpagacz/software-engineering
6ac3965848919d7fe7350842ae9d59d65d213ef6
[ "MIT" ]
2
2021-02-02T18:13:35.000Z
2021-05-10T13:31:40.000Z
#include <iostream> #include <stdlib.h> bool single_round(int& correct_number) { int guess; std::cout << "What is your guess?\n"; std::cin >> guess; std::cout << "Your guess was: " << guess << ".\n"; if (correct_number == guess) { std::cout << "You guessed correctly!\n"; return true; } else if (correct_number > guess) { std::cout << "Your guess was too low!\n"; return false; } else { std::cout << "Your guess was too high!\n"; return false; } } int main(){ // input char choice; std::cout << "Guess the number between 1 and 100!!!!" << std::endl; std::cout << "Pick the game mode:" << std::endl; std::cout << "a - you have 8 tries" << std::endl; std::cout << "b - input number of tries" << std::endl; std::cout << "c - you have progressively fewer tries (strting from 32)" << std::endl; std::cout << "Input a single letter corresponding to a game mode:" << std::endl; std::cin >> choice; int number_of_tries; int guess; bool guessed = false; int correct_number; switch (choice) { case 'a': number_of_tries = 8; correct_number = (int)rand() % 100 + 1; while (number_of_tries > 0) { guessed = single_round(correct_number); if (guessed == true) { std::cout << "You won."; return 0; } number_of_tries--; } std::cout << "You lost.\n"; return 0; case 'b': do { std::cout << "Enter number of tries (positive integer): "; std::cin >> number_of_tries; } while (number_of_tries <= 0); correct_number = (int)rand() % 100 + 1; while (number_of_tries > 0) { guessed = single_round(correct_number); if (guessed == true) { std::cout << "You won."; return 0; } number_of_tries--; } std::cout << "You lost.\n"; return 0; case 'c': number_of_tries = 32; while (true) { correct_number = (int)rand() % 100 + 1; int inner_tries = number_of_tries; while (inner_tries > 0) { guessed = single_round(correct_number); if (guessed) { std::cout << "You won."; break; } inner_tries--; } number_of_tries = 1 > number_of_tries / 2 ? 1 : number_of_tries / 2; } default: std::cout << "Choose a game mode - a, b or c." << std::endl; } return 0; }
24.282609
86
0.590868
kpagacz
4dc0304f7b8e101917ccb84d856e3b3aeb88e361
4,406
cpp
C++
AudioKit/Common/Internals/CoreAudio/Apple Code/ParameterRamper.cpp
ethi1989/AudioKit
97acc8da6dfb75408b2276998073de7a4511d480
[ "MIT" ]
206
2020-10-28T12:47:49.000Z
2022-03-26T14:09:30.000Z
AudioKit/Common/Internals/CoreAudio/Apple Code/ParameterRamper.cpp
ethi1989/AudioKit
97acc8da6dfb75408b2276998073de7a4511d480
[ "MIT" ]
7
2020-10-29T10:29:23.000Z
2021-08-07T00:22:03.000Z
AudioKit/Common/Internals/CoreAudio/Apple Code/ParameterRamper.cpp
ethi1989/AudioKit
97acc8da6dfb75408b2276998073de7a4511d480
[ "MIT" ]
30
2020-10-28T16:11:40.000Z
2021-12-28T01:15:23.000Z
// // ParameterRamper.cpp // AudioKit // // Utility class to manage DSP parameters which can change value smoothly (be ramped) while rendering, without introducing clicks or other distortion into the signal. // // Originally based on Apple sample code, but significantly altered by Aurelius Prochazka // // Copyright © 2020 AudioKit. All rights reserved. // #import <cstdint> #include "ParameterRamper.hpp" #import <AudioToolbox/AUAudioUnit.h> #import <libkern/OSAtomic.h> #import <stdatomic.h> #include <math.h> struct ParameterRamper::InternalData { float clampLow, clampHigh; float uiValue; float taper = 1; float skew = 0; uint32_t offset = 0; float startingPoint; float goal; uint32_t duration; uint32_t samplesRemaining; volatile atomic_int changeCounter = 0; int32_t updateCounter = 0; }; ParameterRamper::ParameterRamper(float value) : data(new InternalData) { setImmediate(value); } ParameterRamper::~ParameterRamper() { delete data; } void ParameterRamper::setImmediate(float value) { // only to be called from the render thread or when resources are not allocated. data->goal = data->uiValue = data->startingPoint = value; data->samplesRemaining = 0; } void ParameterRamper::init() { /* Call this from the kernel init. Updates the internal value from the UI value. */ setImmediate(data->uiValue); } void ParameterRamper::reset() { data->changeCounter = data->updateCounter = 0; } void ParameterRamper::setTaper(float taper) { data->taper = taper; atomic_fetch_add(&data->changeCounter, 1); } float ParameterRamper::getTaper() const { return data->taper; } void ParameterRamper::setSkew(float skew) { if (skew > 1) { skew = 1.0; } if (skew < 0) { skew = 0.0; } data->skew = skew; atomic_fetch_add(&data->changeCounter, 1); } float ParameterRamper::getSkew() const { return data->skew; } void ParameterRamper::setOffset(uint32_t offset) { if (offset < 0) { offset = 0; } data->offset = offset; atomic_fetch_add(&data->changeCounter, 1); } uint32_t ParameterRamper::getOffset() const { return data->offset; } void ParameterRamper::setUIValue(float value) { data->uiValue = value; atomic_fetch_add(&data->changeCounter, 1); } float ParameterRamper::getUIValue() const { return data->uiValue; } void ParameterRamper::dezipperCheck(uint32_t rampDuration) { // check to see if the UI has changed and if so, start a ramp to dezipper it. int32_t changeCounterSnapshot = data->changeCounter; if (data->updateCounter != changeCounterSnapshot) { data->updateCounter = changeCounterSnapshot; startRamp(data->uiValue, rampDuration); } } void ParameterRamper::startRamp(float newGoal, uint32_t duration) { if (duration == 0) { setImmediate(newGoal); } else { data->startingPoint = data->uiValue; data->duration = duration; data->samplesRemaining = duration - data->offset; data->goal = data->uiValue = newGoal; } } float ParameterRamper::get() const { float x = float(data->duration - data->samplesRemaining) / float(data->duration); float taper1 = data->startingPoint + (data->goal - data->startingPoint) * pow(x, abs(data->taper)); float absxm1 = abs(float(data->duration - data->samplesRemaining) / float(data->duration) - 1.0); float taper2 = data->startingPoint + (data->goal - data->startingPoint) * (1.0 - pow(absxm1, 1.0 / abs(data->taper))); return taper1 * (1.0 - data->skew) + taper2 * data->skew; } void ParameterRamper::step() { // Do this in each inner loop iteration after getting the value. if (data->samplesRemaining != 0) { --data->samplesRemaining; } } float ParameterRamper::getAndStep() { // Combines get and step. Saves a multiply-add when not ramping. if (data->samplesRemaining != 0) { float value = get(); --data->samplesRemaining; return value; } else { return data->goal; } } void ParameterRamper::stepBy(uint32_t n) { /* When a parameter does not participate in the current inner loop, you will want to advance it after the end of the loop. */ if (n >= data->samplesRemaining) { data->samplesRemaining = 0; } else { data->samplesRemaining -= n; } }
23.816216
166
0.666364
ethi1989
4dc31fa2013a4e4f26d845ffc650475ae5c17a75
971
hpp
C++
include/RED4ext/Types/generated/move/SecureFootingResult.hpp
Cyberpunk-Extended-Development-Team/RED4ext.SDK
2dc828c761d87a1b4235ce9ca4fbdf9fb4312fae
[ "MIT" ]
1
2021-02-01T23:07:50.000Z
2021-02-01T23:07:50.000Z
include/RED4ext/Types/generated/move/SecureFootingResult.hpp
Cyberpunk-Extended-Development-Team/RED4ext.SDK
2dc828c761d87a1b4235ce9ca4fbdf9fb4312fae
[ "MIT" ]
null
null
null
include/RED4ext/Types/generated/move/SecureFootingResult.hpp
Cyberpunk-Extended-Development-Team/RED4ext.SDK
2dc828c761d87a1b4235ce9ca4fbdf9fb4312fae
[ "MIT" ]
null
null
null
#pragma once // This file is generated from the Game's Reflection data #include <cstdint> #include <RED4ext/Common.hpp> #include <RED4ext/REDhash.hpp> #include <RED4ext/Types/generated/Vector4.hpp> #include <RED4ext/Types/generated/move/SecureFootingFailureReason.hpp> #include <RED4ext/Types/generated/move/SecureFootingFailureType.hpp> namespace RED4ext { namespace move { struct SecureFootingResult { static constexpr const char* NAME = "moveSecureFootingResult"; static constexpr const char* ALIAS = "SecureFootingResult"; Vector4 slidingDirection; // 00 Vector4 normalDirection; // 10 Vector4 lowestLocalPosition; // 20 float staticGroundFactor; // 30 move::SecureFootingFailureReason reason; // 34 move::SecureFootingFailureType type; // 38 uint8_t unk3C[0x40 - 0x3C]; // 3C }; RED4EXT_ASSERT_SIZE(SecureFootingResult, 0x40); } // namespace move using SecureFootingResult = move::SecureFootingResult; } // namespace RED4ext
30.34375
70
0.763131
Cyberpunk-Extended-Development-Team
4dc84041d81d3b9596b1329997eea6ca6c632c99
836
cpp
C++
solutions/286.walls-and-gates.290509829.ac.cpp
satu0king/Leetcode-Solutions
2edff60d76c2898d912197044f6284efeeb34119
[ "MIT" ]
78
2020-10-22T11:31:53.000Z
2022-02-22T13:27:49.000Z
solutions/286.walls-and-gates.290509829.ac.cpp
satu0king/Leetcode-Solutions
2edff60d76c2898d912197044f6284efeeb34119
[ "MIT" ]
null
null
null
solutions/286.walls-and-gates.290509829.ac.cpp
satu0king/Leetcode-Solutions
2edff60d76c2898d912197044f6284efeeb34119
[ "MIT" ]
26
2020-10-23T15:10:44.000Z
2021-11-07T16:13:50.000Z
int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; class Solution { public: void wallsAndGates(vector<vector<int>> &rooms) { int n = rooms.size(); if (!n) return; int m = rooms[0].size(); int INF = 2147483647; queue<pair<int, int>> q; int dist = 1; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) { if (rooms[i][j] == 0) q.emplace(i, j); } while (q.size()) { int _t = q.size(); while (_t--) { auto p = q.front(); q.pop(); for (int k = 0; k < 4; k++) { int i = p.first + dx[k]; int j = p.second + dy[k]; if (i >= 0 && j >= 0 && i < n && j < m && rooms[i][j] == INF) { rooms[i][j] = dist; q.emplace(i, j); } } } dist++; } } };
19.904762
73
0.379187
satu0king
4dc9e8d23f7f7057ceed6069c74b022b4f460758
7,726
cc
C++
arcane/src/arcane/parallel/VariableParallelOperationBase.cc
cedricga91/framework
143eeccb5bf375df4a3f11b888681f84f60380c6
[ "Apache-2.0" ]
16
2021-09-20T12:37:01.000Z
2022-03-18T09:19:14.000Z
arcane/src/arcane/parallel/VariableParallelOperationBase.cc
cedricga91/framework
143eeccb5bf375df4a3f11b888681f84f60380c6
[ "Apache-2.0" ]
66
2021-09-17T13:49:39.000Z
2022-03-30T16:24:07.000Z
arcane/src/arcane/parallel/VariableParallelOperationBase.cc
cedricga91/framework
143eeccb5bf375df4a3f11b888681f84f60380c6
[ "Apache-2.0" ]
11
2021-09-27T16:48:55.000Z
2022-03-23T19:06:56.000Z
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*- //----------------------------------------------------------------------------- // Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com) // See the top-level COPYRIGHT file for details. // SPDX-License-Identifier: Apache-2.0 //----------------------------------------------------------------------------- /*---------------------------------------------------------------------------*/ /* VariableParallelOperationBase.cc (C) 2000-2021 */ /* */ /* Classe de base des opérations parallèles sur des variables. */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ #include "arcane/parallel/VariableParallelOperationBase.h" #include "arcane/utils/FatalErrorException.h" #include "arcane/utils/ScopedPtr.h" #include "arcane/IParallelMng.h" #include "arcane/ISerializer.h" #include "arcane/ISerializeMessage.h" #include "arcane/IParallelExchanger.h" #include "arcane/ISubDomain.h" #include "arcane/IVariable.h" #include "arcane/IItemFamily.h" #include "arcane/ItemInternal.h" #include "arcane/ItemGroup.h" #include "arcane/ParallelMngUtils.h" /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ namespace Arcane::Parallel { namespace { const Int64 SERIALIZE_MAGIC_NUMBER = 0x4cf92789; } /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ VariableParallelOperationBase:: VariableParallelOperationBase(IParallelMng* pm) : TraceAccessor(pm->traceMng()) , m_parallel_mng(pm) , m_item_family(nullptr) { } /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ void VariableParallelOperationBase:: setItemFamily(IItemFamily* family) { if (m_item_family) ARCANE_FATAL("family already set"); m_item_family = family; } /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ IItemFamily* VariableParallelOperationBase:: itemFamily() { return m_item_family; } /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ void VariableParallelOperationBase:: addVariable(IVariable* variable) { if (!m_item_family) ARCANE_FATAL("family not set. call setItemFamily()"); if (variable->itemGroup().itemFamily()!=m_item_family) ARCANE_FATAL("variable->itemFamily() and itemFamily() differ"); m_variables.add(variable); } /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ void VariableParallelOperationBase:: applyOperation(IDataOperation* operation) { if (m_variables.empty()) return; bool is_debug_print = false; #ifdef ARCANE_DEBUG is_debug_print = true; #endif IParallelMng* pm = m_parallel_mng; Integer nb_rank = pm->commSize(); m_items_to_send.clear(); m_items_to_send.resize(nb_rank); _buildItemsToSend(); UniqueArray<ISerializeMessage*> m_messages; m_messages.reserve(nb_rank); auto exchanger {ParallelMngUtils::createExchangerRef(pm)}; for( Integer i=0; i<nb_rank; ++i ) if (!m_items_to_send[i].empty()) exchanger->addSender(i); bool no_exchange = exchanger->initializeCommunicationsMessages(); if (no_exchange) return; // Génère les infos pour chaque processeur à qui on va envoyer des entités for( Integer i=0, is=exchanger->nbSender(); i<is; ++i ){ ISerializeMessage* comm = exchanger->messageToSend(i); Int32 dest_sub_domain = comm->destination().value(); ConstArrayView<ItemInternal*> dest_items_internal = m_items_to_send[dest_sub_domain]; Integer nb_item = dest_items_internal.size(); debug() << "Number of items to serialize: " << nb_item << " subdomain=" << dest_sub_domain; UniqueArray<Int32> dest_items_local_id(nb_item); UniqueArray<Int64> dest_items_unique_id(nb_item); for( Integer z=0; z<nb_item; ++z ){ ItemInternal* item = dest_items_internal[z]; dest_items_local_id[z] = item->localId(); dest_items_unique_id[z] = item->uniqueId().asInt64(); } ISerializer* sbuf = comm->serializer(); // Réserve la mémoire pour la sérialisation sbuf->setMode(ISerializer::ModeReserve); // Réserve pour le magic number sbuf->reserve(DT_Int64,1); // Réserve pour la liste uniqueId() des entités transférées sbuf->reserve(DT_Int64,1); sbuf->reserveSpan(dest_items_unique_id); // Réserve pour chaque variable for( VariableList::Enumerator i_var(m_variables); ++i_var; ){ IVariable* var = *i_var; debug(Trace::High) << "Serialize variable (reserve)" << var->name(); var->serialize(sbuf,dest_items_local_id); } sbuf->allocateBuffer(); // Sérialise les infos sbuf->setMode(ISerializer::ModePut); // Sérialise le magic number sbuf->putInt64(SERIALIZE_MAGIC_NUMBER); // Sérialise la liste des uniqueId() des entités transférées sbuf->putInt64(nb_item); sbuf->putSpan(dest_items_unique_id); for( VariableList::Enumerator i_var(m_variables); ++i_var; ){ IVariable* var = *i_var; debug(Trace::High) << "Serialise variable (put)" << var->name(); var->serialize(sbuf,dest_items_local_id); } } exchanger->processExchange(); { debug() << "VariableParallelOperationBase::readVariables()"; UniqueArray<Int64> items_unique_id; UniqueArray<Int32> items_local_id; // Récupère les infos pour les variables et les remplit for( Integer i=0, n=exchanger->nbReceiver(); i<n; ++i ){ ISerializeMessage* comm = exchanger->messageToReceive(i); ISerializer* sbuf = comm->serializer(); // Désérialize les variables { // Sérialise le magic number Int64 magic_number = sbuf->getInt64(); if (magic_number!=SERIALIZE_MAGIC_NUMBER) ARCANE_FATAL("Bad magic number actual={0} expected={1}. This is probably due to incoherent messaging", magic_number,SERIALIZE_MAGIC_NUMBER); // Récupère la liste des uniqueId() des entités transférées Int64 nb_item = sbuf->getInt64(); items_unique_id.resize(nb_item); sbuf->getSpan(items_unique_id); items_local_id.resize(nb_item); debug(Trace::High) << "Receiving " << nb_item << " items from " << comm->destination().value(); if (is_debug_print){ for( Integer iz=0; iz<nb_item; ++iz ) debug(Trace::Highest) << "Receiving uid=" << items_unique_id[iz]; } itemFamily()->itemsUniqueIdToLocalId(items_local_id,items_unique_id); for( VariableList::Enumerator ivar(m_variables); ++ivar; ){ IVariable* var = *ivar; var->serialize(sbuf,items_local_id,operation); } } } } } /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ } // End namespace Arcane::Parallel /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
34.959276
112
0.533653
cedricga91
4dcae401a0a9fd9e61c47e7b21e73ed4a66fe5a0
496
cpp
C++
ambiguity-resolution2.cpp
rsds8540/cpp-solved-problems
cbd63e0743d7653d8e06401026c16aa1dd5f775b
[ "Apache-2.0" ]
1
2021-04-27T18:23:05.000Z
2021-04-27T18:23:05.000Z
ambiguity-resolution2.cpp
rsds8540/cpp-solved-problems
cbd63e0743d7653d8e06401026c16aa1dd5f775b
[ "Apache-2.0" ]
null
null
null
ambiguity-resolution2.cpp
rsds8540/cpp-solved-problems
cbd63e0743d7653d8e06401026c16aa1dd5f775b
[ "Apache-2.0" ]
null
null
null
#include<bits/stdc++.h> using namespace std; class base { public: void greet() { cout<<"hello"<<endl; } }; class derived: public base { public: void greet() //this function will be overwritten after creation of the object of derived class { cout<<"Namaste"<<endl; } }; int main() { derived a; a.greet(); //here greet of derived class will be invoked base b; b.greet(); //here greet of base class will be invoked return 0; }
16.533333
99
0.59879
rsds8540
4dcb9316f4240fe4d35e9519ce700a08ccbf8bb9
64,874
cpp
C++
DiscImageCreator/outputScsiCmdLog.cpp
tungol/DiscImageCreator
0dbe5e86402848c56fa2aca7c993eabdaed2e0bb
[ "Apache-2.0" ]
null
null
null
DiscImageCreator/outputScsiCmdLog.cpp
tungol/DiscImageCreator
0dbe5e86402848c56fa2aca7c993eabdaed2e0bb
[ "Apache-2.0" ]
null
null
null
DiscImageCreator/outputScsiCmdLog.cpp
tungol/DiscImageCreator
0dbe5e86402848c56fa2aca7c993eabdaed2e0bb
[ "Apache-2.0" ]
null
null
null
/** * Copyright 2011-2018 sarami * * 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 "struct.h" #include "convert.h" #include "output.h" #include "outputScsiCmdLog.h" #include "set.h" VOID OutputInquiry( PINQUIRYDATA pInquiry ) { OutputDriveLogA( OUTPUT_DHYPHEN_PLUS_STR(InquiryData) "\t DeviceType: "); switch (pInquiry->DeviceType) { case DIRECT_ACCESS_DEVICE: OutputDriveLogA("DirectAccessDevice (Floppy etc)\n"); break; case READ_ONLY_DIRECT_ACCESS_DEVICE: OutputDriveLogA("ReadOnlyDirectAccessDevice (CD/DVD etc)\n"); break; case OPTICAL_DEVICE: OutputDriveLogA("OpticalDisk\n"); break; default: OutputDriveLogA("OtherDevice\n"); break; } OutputDriveLogA( "\t DeviceTypeQualifier: "); switch (pInquiry->DeviceTypeQualifier) { case DEVICE_QUALIFIER_ACTIVE: OutputDriveLogA("Active\n"); break; case DEVICE_QUALIFIER_NOT_ACTIVE: OutputDriveLogA("NotActive\n"); break; case DEVICE_QUALIFIER_NOT_SUPPORTED: OutputDriveLogA("NotSupported\n"); break; default: OutputDriveLogA("\n"); break; } OutputDriveLogA( "\t DeviceTypeModifier: %u\n" "\t RemovableMedia: %s\n" "\t Versions: %u\n" "\t ResponseDataFormat: %u\n" "\t HiSupport: %s\n" "\t NormACA: %s\n" "\t TerminateTask: %s\n" "\t AERC: %s\n" "\t AdditionalLength: %u\n" "\t MediumChanger: %s\n" "\t MultiPort: %s\n" "\t EnclosureServices: %s\n" "\t SoftReset: %s\n" "\t CommandQueue: %s\n" "\t LinkedCommands: %s\n" "\t RelativeAddressing: %s\n", pInquiry->DeviceTypeModifier, BOOLEAN_TO_STRING_YES_NO_A(pInquiry->RemovableMedia), pInquiry->Versions, pInquiry->ResponseDataFormat, BOOLEAN_TO_STRING_YES_NO_A(pInquiry->HiSupport), BOOLEAN_TO_STRING_YES_NO_A(pInquiry->NormACA), BOOLEAN_TO_STRING_YES_NO_A(pInquiry->TerminateTask), BOOLEAN_TO_STRING_YES_NO_A(pInquiry->AERC), pInquiry->AdditionalLength, BOOLEAN_TO_STRING_YES_NO_A(pInquiry->MediumChanger), BOOLEAN_TO_STRING_YES_NO_A(pInquiry->MultiPort), BOOLEAN_TO_STRING_YES_NO_A(pInquiry->EnclosureServices), BOOLEAN_TO_STRING_YES_NO_A(pInquiry->SoftReset), BOOLEAN_TO_STRING_YES_NO_A(pInquiry->CommandQueue), BOOLEAN_TO_STRING_YES_NO_A(pInquiry->LinkedCommands), BOOLEAN_TO_STRING_YES_NO_A(pInquiry->RelativeAddressing)); OutputDriveLogA( "\t VendorId: %.8s\n" "\t ProductId: %.16s\n" "\tProductRevisionLevel: %.4s\n" "\t VendorSpecific: %.20s\n", pInquiry->VendorId, pInquiry->ProductId, pInquiry->ProductRevisionLevel, pInquiry->VendorSpecific); } VOID OutputGetConfigurationHeader( PGET_CONFIGURATION_HEADER pConfigHeader ) { OutputDriveLogA( OUTPUT_DHYPHEN_PLUS_STR(GetConfiguration) "\t DataLength: %ld\n" "\tCurrentProfile: " , MAKELONG(MAKEWORD(pConfigHeader->DataLength[3], pConfigHeader->DataLength[2]), MAKEWORD(pConfigHeader->DataLength[1], pConfigHeader->DataLength[0]))); OutputGetConfigurationFeatureProfileType( MAKEWORD(pConfigHeader->CurrentProfile[1], pConfigHeader->CurrentProfile[0])); OutputDriveLogA("\n"); } VOID OutputGetConfigurationFeatureProfileType( WORD wFeatureProfileType ) { switch (wFeatureProfileType) { case ProfileInvalid: OutputDriveLogA("Invalid"); break; case ProfileNonRemovableDisk: OutputDriveLogA("NonRemovableDisk"); break; case ProfileRemovableDisk: OutputDriveLogA("RemovableDisk"); break; case ProfileMOErasable: OutputDriveLogA("MOErasable"); break; case ProfileMOWriteOnce: OutputDriveLogA("MOWriteOnce"); break; case ProfileAS_MO: OutputDriveLogA("AS_MO"); break; case ProfileCdrom: OutputDriveLogA("CD-ROM"); break; case ProfileCdRecordable: OutputDriveLogA("CD-R"); break; case ProfileCdRewritable: OutputDriveLogA("CD-RW"); break; case ProfileDvdRom: OutputDriveLogA("DVD-ROM"); break; case ProfileDvdRecordable: OutputDriveLogA("DVD-R"); break; case ProfileDvdRam: OutputDriveLogA("DVD-RAM"); break; case ProfileDvdRewritable: OutputDriveLogA("DVD-RW"); break; case ProfileDvdRWSequential: OutputDriveLogA("DVD-RW Sequential"); break; case ProfileDvdDashRDualLayer: OutputDriveLogA("DVD-R DL"); break; case ProfileDvdDashRLayerJump: OutputDriveLogA("DVD-R Layer Jump"); break; case ProfileDvdPlusRW: OutputDriveLogA("DVD+RW"); break; case ProfileDvdPlusR: OutputDriveLogA("DVD+R"); break; case ProfileDDCdrom: OutputDriveLogA("DDCD-ROM"); break; case ProfileDDCdRecordable: OutputDriveLogA("DDCD-R"); break; case ProfileDDCdRewritable: OutputDriveLogA("DDCD-RW"); break; case ProfileDvdPlusRWDualLayer: OutputDriveLogA("DVD+RW DL"); break; case ProfileDvdPlusRDualLayer: OutputDriveLogA("DVD+R DL"); break; case ProfileBDRom: OutputDriveLogA("BD-ROM"); break; case ProfileBDRSequentialWritable: OutputDriveLogA("BD-R Sequential Writable"); break; case ProfileBDRRandomWritable: OutputDriveLogA("BD-R Random Writable"); break; case ProfileBDRewritable: OutputDriveLogA("BD-R"); break; case ProfileHDDVDRom: OutputDriveLogA("HD DVD-ROM"); break; case ProfileHDDVDRecordable: OutputDriveLogA("HD DVD-R"); break; case ProfileHDDVDRam: OutputDriveLogA("HD DVD-RAM"); break; case ProfileHDDVDRewritable: OutputDriveLogA("HD-DVD-RW"); break; case ProfileHDDVDRDualLayer: OutputDriveLogA("HD-DVD-R DL"); break; case ProfileHDDVDRWDualLayer: OutputDriveLogA("HD-DVD-RW DL"); break; case ProfileNonStandard: OutputDriveLogA("NonStandard"); break; default: OutputDriveLogA("Reserved [%#x]", wFeatureProfileType); break; } } VOID OutputGetConfigurationFeatureProfileList( PFEATURE_DATA_PROFILE_LIST pList ) { OutputDriveLogA("\tFeatureProfileList\n"); for (UINT i = 0; i < pList->Header.AdditionalLength / sizeof(FEATURE_DATA_PROFILE_LIST_EX); i++) { OutputDriveLogA("\t\t"); OutputGetConfigurationFeatureProfileType( MAKEWORD(pList->Profiles[i].ProfileNumber[1], pList->Profiles[i].ProfileNumber[0])); OutputDriveLogA("\n"); } } VOID OutputGetConfigurationFeatureCore( PFEATURE_DATA_CORE pCore ) { OutputDriveLogA( "\tFeatureCore\n" "\t\tPhysicalInterface: "); LONG lVal = MAKELONG( MAKEWORD(pCore->PhysicalInterface[3], pCore->PhysicalInterface[2]), MAKEWORD(pCore->PhysicalInterface[1], pCore->PhysicalInterface[0])); switch (lVal) { case 0: OutputDriveLogA("Unspecified\n"); break; case 1: OutputDriveLogA("SCSI Family\n"); break; case 2: OutputDriveLogA("ATAPI\n"); break; case 3: OutputDriveLogA("IEEE 1394 - 1995\n"); break; case 4: OutputDriveLogA("IEEE 1394A\n"); break; case 5: OutputDriveLogA("Fibre Channel\n"); break; case 6: OutputDriveLogA("IEEE 1394B\n"); break; case 7: OutputDriveLogA("Serial ATAPI\n"); break; case 8: OutputDriveLogA("USB (both 1.1 and 2.0)\n"); break; case 0xffff: OutputDriveLogA("Vendor Unique\n"); break; default: OutputDriveLogA("Reserved: %08ld\n", lVal); break; } OutputDriveLogA( "\t\t DeviceBusyEvent: %s\n" "\t\t INQUIRY2: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pCore->DeviceBusyEvent), BOOLEAN_TO_STRING_YES_NO_A(pCore->INQUIRY2)); } VOID OutputGetConfigurationFeatureMorphing( PFEATURE_DATA_MORPHING pMorphing ) { OutputDriveLogA( "\tFeatureMorphing\n" "\t\tAsynchronous: %s\n" "\t\t OCEvent: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pMorphing->Asynchronous), BOOLEAN_TO_STRING_YES_NO_A(pMorphing->OCEvent)); } VOID OutputGetConfigurationFeatureRemovableMedium( PFEATURE_DATA_REMOVABLE_MEDIUM pRemovableMedium ) { OutputDriveLogA( "\tFeatureRemovableMedium\n" "\t\t Lockable: %s\n" "\t\tDefaultToPrevent: %s\n" "\t\t Eject: %s\n" "\t\tLoadingMechanism: ", BOOLEAN_TO_STRING_YES_NO_A(pRemovableMedium->Lockable), BOOLEAN_TO_STRING_YES_NO_A(pRemovableMedium->DefaultToPrevent), BOOLEAN_TO_STRING_YES_NO_A(pRemovableMedium->Eject)); switch (pRemovableMedium->LoadingMechanism) { case 0: OutputDriveLogA("Caddy/Slot type loading mechanism\n"); break; case 1: OutputDriveLogA("Tray type loading mechanism\n"); break; case 2: OutputDriveLogA("Pop-up type loading mechanism\n"); break; case 4: OutputDriveLogA( "Embedded changer with individually changeable discs\n"); break; case 5: OutputDriveLogA( "Embedded changer using a magazine mechanism\n"); break; default: OutputDriveLogA( "Reserved: %08d\n", pRemovableMedium->LoadingMechanism); break; } } VOID OutputGetConfigurationFeatureWriteProtect( PFEATURE_DATA_WRITE_PROTECT pWriteProtect ) { OutputDriveLogA( "\tFeatureWriteProtect\n" "\t\t SupportsSWPPBit: %s\n" "\t\tSupportsPersistentWriteProtect: %s\n" "\t\t WriteInhibitDCB: %s\n" "\t\t DiscWriteProtectPAC: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pWriteProtect->SupportsSWPPBit), BOOLEAN_TO_STRING_YES_NO_A(pWriteProtect->SupportsPersistentWriteProtect), BOOLEAN_TO_STRING_YES_NO_A(pWriteProtect->WriteInhibitDCB), BOOLEAN_TO_STRING_YES_NO_A(pWriteProtect->DiscWriteProtectPAC)); } VOID OutputGetConfigurationFeatureRandomReadable( PFEATURE_DATA_RANDOM_READABLE pRandomReadable ) { OutputDriveLogA( "\tFeatureRandomReadable\n" "\t\t LogicalBlockSize: %lu\n" "\t\t Blocking: %u\n" "\t\tErrorRecoveryPagePresent: %s\n", MAKELONG(MAKEWORD(pRandomReadable->LogicalBlockSize[3], pRandomReadable->LogicalBlockSize[2]), MAKEWORD(pRandomReadable->LogicalBlockSize[1], pRandomReadable->LogicalBlockSize[0])), MAKEWORD(pRandomReadable->Blocking[1], pRandomReadable->Blocking[0]), BOOLEAN_TO_STRING_YES_NO_A(pRandomReadable->ErrorRecoveryPagePresent)); } VOID OutputGetConfigurationFeatureMultiRead( PFEATURE_DATA_MULTI_READ pMultiRead ) { OutputDriveLogA( "\tFeatureMultiRead\n" "\t\t Current: %u\n" "\t\tPersistent: %u\n" "\t\t Version: %u\n", pMultiRead->Header.Current, pMultiRead->Header.Persistent, pMultiRead->Header.Version); } VOID OutputGetConfigurationFeatureCdRead( PFEATURE_DATA_CD_READ pCDRead ) { OutputDriveLogA( "\tFeatureCdRead\n" "\t\t CDText: %s\n" "\t\t C2ErrorData: %s\n" "\t\tDigitalAudioPlay: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pCDRead->CDText), BOOLEAN_TO_STRING_YES_NO_A(pCDRead->C2ErrorData), BOOLEAN_TO_STRING_YES_NO_A(pCDRead->DigitalAudioPlay)); } VOID OutputGetConfigurationFeatureDvdRead( PFEATURE_DATA_DVD_READ pDVDRead ) { OutputDriveLogA( "\tFeatureDvdRead\n" "\t\t Multi110: %s\n" "\t\t DualDashR: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pDVDRead->Multi110), BOOLEAN_TO_STRING_YES_NO_A(pDVDRead->DualDashR)); } VOID OutputGetConfigurationFeatureRandomWritable( PFEATURE_DATA_RANDOM_WRITABLE pRandomWritable ) { OutputDriveLogA( "\tFeatureRandomWritable\n" "\t\t LastLBA: %lu\n" "\t\t LogicalBlockSize: %lu\n" "\t\t Blocking: %u\n" "\t\tErrorRecoveryPagePresent: %s\n", MAKELONG(MAKEWORD(pRandomWritable->LastLBA[3], pRandomWritable->LastLBA[2]), MAKEWORD(pRandomWritable->LastLBA[1], pRandomWritable->LastLBA[0])), MAKELONG(MAKEWORD(pRandomWritable->LogicalBlockSize[3], pRandomWritable->LogicalBlockSize[2]), MAKEWORD(pRandomWritable->LogicalBlockSize[1], pRandomWritable->LogicalBlockSize[0])), MAKEWORD(pRandomWritable->Blocking[1], pRandomWritable->Blocking[0]), BOOLEAN_TO_STRING_YES_NO_A(pRandomWritable->ErrorRecoveryPagePresent)); } VOID OutputGetConfigurationFeatureIncrementalStreamingWritable( PFEATURE_DATA_INCREMENTAL_STREAMING_WRITABLE pIncremental ) { OutputDriveLogA( "\tFeatureIncrementalStreamingWritable\n" "\t\t DataTypeSupported: %u\n" "\t\t BufferUnderrunFree: %s\n" "\t\t AddressModeReservation: %s\n" "\t\tTrackRessourceInformation: %s\n" "\t\t NumberOfLinkSizes: %u\n", MAKEWORD(pIncremental->DataTypeSupported[1], pIncremental->DataTypeSupported[0]), BOOLEAN_TO_STRING_YES_NO_A(pIncremental->BufferUnderrunFree), BOOLEAN_TO_STRING_YES_NO_A(pIncremental->AddressModeReservation), BOOLEAN_TO_STRING_YES_NO_A(pIncremental->TrackRessourceInformation), pIncremental->NumberOfLinkSizes); for (INT i = 0; i < pIncremental->NumberOfLinkSizes; i++) { OutputDriveLogA( "\t\tLinkSize%u: %u\n", i, pIncremental->LinkSize[i]); } } VOID OutputGetConfigurationFeatureSectorErasable( PFEATURE_DATA_SECTOR_ERASABLE pSectorErasable ) { OutputDriveLogA( "\tFeatureSectorErasable\n" "\t\t Current: %u\n" "\t\tPersistent: %u\n" "\t\t Version: %u\n", pSectorErasable->Header.Current, pSectorErasable->Header.Persistent, pSectorErasable->Header.Version); } VOID OutputGetConfigurationFeatureFormattable( PFEATURE_DATA_FORMATTABLE pFormattable ) { OutputDriveLogA( "\tFeatureFormattable\n" "\t\t FullCertification: %s\n" "\t\tQuickCertification: %s\n" "\t\tSpareAreaExpansion: %s\n" "\t\tRENoSpareAllocated: %s\n" "\t\t RRandomWritable: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pFormattable->FullCertification), BOOLEAN_TO_STRING_YES_NO_A(pFormattable->QuickCertification), BOOLEAN_TO_STRING_YES_NO_A(pFormattable->SpareAreaExpansion), BOOLEAN_TO_STRING_YES_NO_A(pFormattable->RENoSpareAllocated), BOOLEAN_TO_STRING_YES_NO_A(pFormattable->RRandomWritable)); } VOID OutputGetConfigurationFeatureDefectManagement( PFEATURE_DATA_DEFECT_MANAGEMENT pDefect ) { OutputDriveLogA( "\tFeatureDefectManagement\n" "\t\tSupplimentalSpareArea: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pDefect->SupplimentalSpareArea)); } VOID OutputGetConfigurationFeatureWriteOnce( PFEATURE_DATA_WRITE_ONCE pWriteOnce ) { OutputDriveLogA( "\tFeatureWriteOnce\n" "\t\t LogicalBlockSize: %lu\n" "\t\t Blocking: %u\n" "\t\tErrorRecoveryPagePresent: %s\n", MAKELONG(MAKEWORD(pWriteOnce->LogicalBlockSize[3], pWriteOnce->LogicalBlockSize[2]), MAKEWORD(pWriteOnce->LogicalBlockSize[1], pWriteOnce->LogicalBlockSize[0])), MAKEWORD(pWriteOnce->Blocking[1], pWriteOnce->Blocking[0]), BOOLEAN_TO_STRING_YES_NO_A(pWriteOnce->ErrorRecoveryPagePresent)); } VOID OutputGetConfigurationFeatureRestrictedOverwrite( PFEATURE_DATA_RESTRICTED_OVERWRITE pRestricted ) { OutputDriveLogA( "\tFeatureRestrictedOverwrite\n" "\t\t Current: %u\n" "\t\tPersistent: %u\n" "\t\t Version: %u\n", pRestricted->Header.Current, pRestricted->Header.Persistent, pRestricted->Header.Version); } VOID OutputGetConfigurationFeatureCdrwCAVWrite( PFEATURE_DATA_CDRW_CAV_WRITE pCDRW ) { OutputDriveLogA( "\tFeatureCdrwCAVWrite\n" "\t\t Current: %u\n" "\t\tPersistent: %u\n" "\t\t Version: %u\n", pCDRW->Header.Current, pCDRW->Header.Persistent, pCDRW->Header.Version); } VOID OutputGetConfigurationFeatureMrw( PFEATURE_DATA_MRW pMrw ) { OutputDriveLogA( "\tFeatureMrw\n" "\t\t Write: %s\n" "\t\t DvdPlusRead: %s\n" "\t\tDvdPlusWrite: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pMrw->Write), BOOLEAN_TO_STRING_YES_NO_A(pMrw->DvdPlusRead), BOOLEAN_TO_STRING_YES_NO_A(pMrw->DvdPlusWrite)); } VOID OutputGetConfigurationFeatureEnhancedDefectReporting( PFEATURE_ENHANCED_DEFECT_REPORTING pEnhanced ) { OutputDriveLogA( "\tFeatureEnhancedDefectReporting\n" "\t\t DRTDMSupported: %s\n" "\t\tNumberOfDBICacheZones: %u\n" "\t\t NumberOfEntries: %u\n", BOOLEAN_TO_STRING_YES_NO_A(pEnhanced->DRTDMSupported), pEnhanced->NumberOfDBICacheZones, MAKEWORD(pEnhanced->NumberOfEntries[1], pEnhanced->NumberOfEntries[0])); } VOID OutputGetConfigurationFeatureDvdPlusRW( PFEATURE_DATA_DVD_PLUS_RW pDVDPLUSRW ) { OutputDriveLogA( "\tFeatureDvdPlusRW\n" "\t\t Write: %s\n" "\t\t CloseOnly: %s\n" "\t\tQuickStart: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pDVDPLUSRW->Write), BOOLEAN_TO_STRING_YES_NO_A(pDVDPLUSRW->CloseOnly), BOOLEAN_TO_STRING_YES_NO_A(pDVDPLUSRW->QuickStart)); } VOID OutputGetConfigurationFeatureDvdPlusR( PFEATURE_DATA_DVD_PLUS_R pDVDPLUSR ) { OutputDriveLogA( "\tFeatureDvdPlusR\n" "\t\tWrite: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pDVDPLUSR->Write)); } VOID OutputGetConfigurationFeatureRigidRestrictedOverwrite( PFEATURE_DATA_DVD_RW_RESTRICTED_OVERWRITE pDVDRWRestricted ) { OutputDriveLogA( "\tFeatureRigidRestrictedOverwrite\n" "\t\t Blank: %s\n" "\t\t Intermediate: %s\n" "\t\t DefectStatusDataRead: %s\n" "\t\tDefectStatusDataGenerate: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pDVDRWRestricted->Blank), BOOLEAN_TO_STRING_YES_NO_A(pDVDRWRestricted->Intermediate), BOOLEAN_TO_STRING_YES_NO_A(pDVDRWRestricted->DefectStatusDataRead), BOOLEAN_TO_STRING_YES_NO_A(pDVDRWRestricted->DefectStatusDataGenerate)); } VOID OutputGetConfigurationFeatureCdTrackAtOnce( PFEATURE_DATA_CD_TRACK_AT_ONCE pCDTrackAtOnce ) { OutputDriveLogA( "\tFeatureCdTrackAtOnce\n" "\t\tRWSubchannelsRecordable: %s\n" "\t\t CdRewritable: %s\n" "\t\t TestWriteOk: %s\n" "\t\t RWSubchannelPackedOk: %s\n" "\t\t RWSubchannelRawOk: %s\n" "\t\t BufferUnderrunFree: %s\n" "\t\t DataTypeSupported: %u\n", BOOLEAN_TO_STRING_YES_NO_A(pCDTrackAtOnce->RWSubchannelsRecordable), BOOLEAN_TO_STRING_YES_NO_A(pCDTrackAtOnce->CdRewritable), BOOLEAN_TO_STRING_YES_NO_A(pCDTrackAtOnce->TestWriteOk), BOOLEAN_TO_STRING_YES_NO_A(pCDTrackAtOnce->RWSubchannelPackedOk), BOOLEAN_TO_STRING_YES_NO_A(pCDTrackAtOnce->RWSubchannelRawOk), BOOLEAN_TO_STRING_YES_NO_A(pCDTrackAtOnce->BufferUnderrunFree), MAKEWORD(pCDTrackAtOnce->DataTypeSupported[1], pCDTrackAtOnce->DataTypeSupported[0])); } VOID OutputGetConfigurationFeatureCdMastering( PFEATURE_DATA_CD_MASTERING pCDMastering ) { OutputDriveLogA( "\tFeatureCdMastering\n" "\t\tRWSubchannelsRecordable: %s\n" "\t\t CdRewritable: %s\n" "\t\t TestWriteOk: %s\n" "\t\t RRawRecordingOk: %s\n" "\t\t RawMultiSessionOk: %s\n" "\t\t SessionAtOnceOk: %s\n" "\t\t BufferUnderrunFree: %s\n" "\t\t MaximumCueSheetLength: %lu\n", BOOLEAN_TO_STRING_YES_NO_A(pCDMastering->RWSubchannelsRecordable), BOOLEAN_TO_STRING_YES_NO_A(pCDMastering->CdRewritable), BOOLEAN_TO_STRING_YES_NO_A(pCDMastering->TestWriteOk), BOOLEAN_TO_STRING_YES_NO_A(pCDMastering->RawRecordingOk), BOOLEAN_TO_STRING_YES_NO_A(pCDMastering->RawMultiSessionOk), BOOLEAN_TO_STRING_YES_NO_A(pCDMastering->SessionAtOnceOk), BOOLEAN_TO_STRING_YES_NO_A(pCDMastering->BufferUnderrunFree), MAKELONG(MAKEWORD(0, pCDMastering->MaximumCueSheetLength[2]), MAKEWORD(pCDMastering->MaximumCueSheetLength[1], pCDMastering->MaximumCueSheetLength[0]))); } VOID OutputGetConfigurationFeatureDvdRecordableWrite( PFEATURE_DATA_DVD_RECORDABLE_WRITE pDVDRecordable ) { OutputDriveLogA( "\tFeatureDvdRecordableWrite\n" "\t\t DVD_RW: %s\n" "\t\t TestWrite: %s\n" "\t\t RDualLayer: %s\n" "\t\tBufferUnderrunFree: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pDVDRecordable->DVD_RW), BOOLEAN_TO_STRING_YES_NO_A(pDVDRecordable->TestWrite), BOOLEAN_TO_STRING_YES_NO_A(pDVDRecordable->RDualLayer), BOOLEAN_TO_STRING_YES_NO_A(pDVDRecordable->BufferUnderrunFree)); } VOID OutputGetConfigurationFeatureLayerJumpRecording( PFEATURE_DATA_LAYER_JUMP_RECORDING pLayerJumpRec ) { OutputDriveLogA( "\tFeatureLayerJumpRecording\n" "\t\tNumberOfLinkSizes: %u\n", pLayerJumpRec->NumberOfLinkSizes); for (INT i = 0; i < pLayerJumpRec->NumberOfLinkSizes; i++) { OutputDriveLogA( "\t\tLinkSize %u: %u\n", i, pLayerJumpRec->LinkSizes[i]); } } VOID OutputGetConfigurationFeatureCDRWMediaWriteSupport( PFEATURE_CD_RW_MEDIA_WRITE_SUPPORT pCDRWMediaWrite ) { OutputDriveLogA( "\tFeatureCDRWMediaWriteSupport\n" "\t\tSubtype 0: %s\n" "\t\tSubtype 1: %s\n" "\t\tSubtype 2: %s\n" "\t\tSubtype 3: %s\n" "\t\tSubtype 4: %s\n" "\t\tSubtype 5: %s\n" "\t\tSubtype 6: %s\n" "\t\tSubtype 7: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pCDRWMediaWrite->CDRWMediaSubtypeSupport.Subtype0), BOOLEAN_TO_STRING_YES_NO_A(pCDRWMediaWrite->CDRWMediaSubtypeSupport.Subtype1), BOOLEAN_TO_STRING_YES_NO_A(pCDRWMediaWrite->CDRWMediaSubtypeSupport.Subtype2), BOOLEAN_TO_STRING_YES_NO_A(pCDRWMediaWrite->CDRWMediaSubtypeSupport.Subtype3), BOOLEAN_TO_STRING_YES_NO_A(pCDRWMediaWrite->CDRWMediaSubtypeSupport.Subtype4), BOOLEAN_TO_STRING_YES_NO_A(pCDRWMediaWrite->CDRWMediaSubtypeSupport.Subtype5), BOOLEAN_TO_STRING_YES_NO_A(pCDRWMediaWrite->CDRWMediaSubtypeSupport.Subtype6), BOOLEAN_TO_STRING_YES_NO_A(pCDRWMediaWrite->CDRWMediaSubtypeSupport.Subtype7)); } VOID OutputGetConfigurationFeatureDvdPlusRWDualLayer( PFEATURE_DATA_DVD_PLUS_RW_DUAL_LAYER pDVDPlusRWDL ) { OutputDriveLogA( "\tFeatureDvdPlusRWDualLayer\n" "\t\t Write: %s\n" "\t\t CloseOnly: %s\n" "\t\tQuickStart: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pDVDPlusRWDL->Write), BOOLEAN_TO_STRING_YES_NO_A(pDVDPlusRWDL->CloseOnly), BOOLEAN_TO_STRING_YES_NO_A(pDVDPlusRWDL->QuickStart)); } VOID OutputGetConfigurationFeatureDvdPlusRDualLayer( PFEATURE_DATA_DVD_PLUS_R_DUAL_LAYER pDVDPlusRDL ) { OutputDriveLogA( "\tFeatureDvdPlusRDualLayer\n" "\t\tWrite: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pDVDPlusRDL->Write)); } VOID OutputGetConfigurationFeatureHybridDisc( PFEATURE_HYBRID_DISC pHybridDisc ) { OutputDriveLogA( "\tFeatureHybridDisc\n" "\t\tResetImmunity: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pHybridDisc->ResetImmunity)); } VOID OutputGetConfigurationFeaturePowerManagement( PFEATURE_DATA_POWER_MANAGEMENT pPower ) { OutputDriveLogA( "\tFeaturePowerManagement\n" "\t\t Current: %u\n" "\t\tPersistent: %u\n" "\t\t Version: %u\n", pPower->Header.Current, pPower->Header.Persistent, pPower->Header.Version); } VOID OutputGetConfigurationFeatureSMART( PFEATURE_DATA_SMART pSmart ) { OutputDriveLogA( "\tFeatureSMART\n" "\t\tFaultFailureReportingPagePresent: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pSmart->FaultFailureReportingPagePresent)); } VOID OutputGetConfigurationFeatureEmbeddedChanger( PFEATURE_DATA_EMBEDDED_CHANGER pEmbedded ) { OutputDriveLogA( "\tFeatureEmbeddedChanger\n" "\t\tSupportsDiscPresent: %s\n" "\t\t SideChangeCapable: %s\n" "\t\t HighestSlotNumber: %u\n", BOOLEAN_TO_STRING_YES_NO_A(pEmbedded->SupportsDiscPresent), BOOLEAN_TO_STRING_YES_NO_A(pEmbedded->SideChangeCapable), pEmbedded->HighestSlotNumber); } VOID OutputGetConfigurationFeatureCDAudioAnalogPlay( PFEATURE_DATA_CD_AUDIO_ANALOG_PLAY pCDAudio ) { OutputDriveLogA( "\tFeatureCDAudioAnalogPlay\n" "\t\t SeperateVolume: %s\n" "\t\tSeperateChannelMute: %s\n" "\t\t ScanSupported: %s\n" "\t\tNumerOfVolumeLevels: %u\n", BOOLEAN_TO_STRING_YES_NO_A(pCDAudio->SeperateVolume), BOOLEAN_TO_STRING_YES_NO_A(pCDAudio->SeperateChannelMute), BOOLEAN_TO_STRING_YES_NO_A(pCDAudio->ScanSupported), MAKEWORD(pCDAudio->NumerOfVolumeLevels[1], pCDAudio->NumerOfVolumeLevels[0])); } VOID OutputGetConfigurationFeatureMicrocodeUpgrade( PFEATURE_DATA_MICROCODE_UPDATE pMicrocode ) { OutputDriveLogA( "\tFeatureMicrocodeUpgrade\n" "\t\tM5: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pMicrocode->M5)); } VOID OutputGetConfigurationFeatureTimeout( PFEATURE_DATA_TIMEOUT pTimeOut ) { OutputDriveLogA( "\tFeatureTimeout\n" "\t\t Group3: %s\n" "\t\tUnitLength: %u\n", BOOLEAN_TO_STRING_YES_NO_A(pTimeOut->Group3), MAKEWORD(pTimeOut->UnitLength[1], pTimeOut->UnitLength[0])); } VOID OutputGetConfigurationFeatureDvdCSS( PFEATURE_DATA_DVD_CSS pDVDCss ) { OutputDriveLogA( "\tFeatureDvdCSS\n" "\t\tCssVersion: %u\n", pDVDCss->CssVersion); } VOID OutputGetConfigurationFeatureRealTimeStreaming( PFEATURE_DATA_REAL_TIME_STREAMING pRealTimeStreaming ) { OutputDriveLogA( "\tFeatureRealTimeStreaming\n" "\t\t StreamRecording: %s\n" "\t\t WriteSpeedInGetPerf: %s\n" "\t\t WriteSpeedInMP2A: %s\n" "\t\t SetCDSpeed: %s\n" "\t\tReadBufferCapacityBlock: %s\n", BOOLEAN_TO_STRING_YES_NO_A(pRealTimeStreaming->StreamRecording), BOOLEAN_TO_STRING_YES_NO_A(pRealTimeStreaming->WriteSpeedInGetPerf), BOOLEAN_TO_STRING_YES_NO_A(pRealTimeStreaming->WriteSpeedInMP2A), BOOLEAN_TO_STRING_YES_NO_A(pRealTimeStreaming->SetCDSpeed), BOOLEAN_TO_STRING_YES_NO_A(pRealTimeStreaming->ReadBufferCapacityBlock)); } VOID OutputGetConfigurationFeatureLogicalUnitSerialNumber( PFEATURE_DATA_LOGICAL_UNIT_SERIAL_NUMBER pLogical ) { OutputDriveLogA( "\tFeatureLogicalUnitSerialNumber\n" "\t\tSerialNumber: "); for (INT i = 0; i < pLogical->Header.AdditionalLength; i++) { OutputDriveLogA("%c", pLogical->SerialNumber[i]); } OutputDriveLogA("\n"); } VOID OutputGetConfigurationFeatureMediaSerialNumber( PFEATURE_MEDIA_SERIAL_NUMBER pMediaSerialNumber ) { OutputDriveLogA( "\tFeatureMediaSerialNumber\n" "\t\t Current: %u\n" "\t\tPersistent: %u\n" "\t\t Version: %u\n", pMediaSerialNumber->Header.Current, pMediaSerialNumber->Header.Persistent, pMediaSerialNumber->Header.Version); } VOID OutputGetConfigurationFeatureDiscControlBlocks( PFEATURE_DATA_DISC_CONTROL_BLOCKS pDiscCtrlBlk ) { OutputDriveLogA("\tFeatureDiscControlBlocks\n"); for (INT i = 0; i < pDiscCtrlBlk->Header.AdditionalLength; i++) { OutputDriveLogA( "\t\tContentDescriptor %02u: %08ld\n", i, MAKELONG( MAKEWORD(pDiscCtrlBlk->Data[i].ContentDescriptor[3], pDiscCtrlBlk->Data[i].ContentDescriptor[2]), MAKEWORD(pDiscCtrlBlk->Data[i].ContentDescriptor[1], pDiscCtrlBlk->Data[i].ContentDescriptor[0]))); } } VOID OutputGetConfigurationFeatureDvdCPRM( PFEATURE_DATA_DVD_CPRM pDVDCprm ) { OutputDriveLogA( "\tFeatureDvdCPRM\n" "\t\tCPRMVersion: %u\n", pDVDCprm->CPRMVersion); } VOID OutputGetConfigurationFeatureFirmwareDate( PFEATURE_DATA_FIRMWARE_DATE pFirmwareDate ) { OutputDriveLogA( "\tFeatureFirmwareDate: %.4s-%.2s-%.2s %.2s:%.2s:%.2s\n" , pFirmwareDate->Year, pFirmwareDate->Month, pFirmwareDate->Day , pFirmwareDate->Hour, pFirmwareDate->Minute, pFirmwareDate->Seconds); } VOID OutputGetConfigurationFeatureAACS( PFEATURE_DATA_AACS pAACS ) { OutputDriveLogA( "\tFeatureAACS\n" "\t\tBindingNonceGeneration: %s\n" "\t\tBindingNonceBlockCount: %u\n" "\t\t NumberOfAGIDs: %u\n" "\t\t AACSVersion: %u\n", BOOLEAN_TO_STRING_YES_NO_A(pAACS->BindingNonceGeneration), pAACS->BindingNonceBlockCount, pAACS->NumberOfAGIDs, pAACS->AACSVersion); } VOID OutputGetConfigurationFeatureVCPS( PFEATURE_VCPS pVcps ) { OutputDriveLogA( "\tFeatureVCPS\n" "\t\t Current: %u\n" "\t\tPersistent: %u\n" "\t\t Version: %u\n", pVcps->Header.Current, pVcps->Header.Persistent, pVcps->Header.Version); } VOID OutputGetConfigurationFeatureReserved( PFEATURE_DATA_RESERVED pReserved ) { OutputDriveLogA( "\tReserved (FeatureCode[%#04x])\n" "\t\tData: ", MAKEWORD(pReserved->Header.FeatureCode[1], pReserved->Header.FeatureCode[0])); for (INT i = 0; i < pReserved->Header.AdditionalLength; i++) { OutputDriveLogA("%02x", pReserved->Data[i]); } OutputDriveLogA("\n"); } VOID OutputGetConfigurationFeatureVendorSpecific( PFEATURE_DATA_VENDOR_SPECIFIC pVendorSpecific ) { OutputDriveLogA( "\tVendorSpecific (FeatureCode[%#04x])\n" "\t\tVendorSpecificData: ", MAKEWORD(pVendorSpecific->Header.FeatureCode[1], pVendorSpecific->Header.FeatureCode[0])); for (INT i = 0; i < pVendorSpecific->Header.AdditionalLength; i++) { OutputDriveLogA("%02x", pVendorSpecific->VendorSpecificData[i]); } OutputDriveLogA("\n"); } VOID OutputGetConfigurationFeatureNumber( PDEVICE pDevice, LPBYTE lpConf, DWORD dwAllLen ) { DWORD n = 0; while (n < dwAllLen) { WORD wCode = MAKEWORD(lpConf[n + 1], lpConf[n]); switch (wCode) { case FeatureProfileList: OutputGetConfigurationFeatureProfileList((PFEATURE_DATA_PROFILE_LIST)&lpConf[n]); break; case FeatureCore: OutputGetConfigurationFeatureCore((PFEATURE_DATA_CORE)&lpConf[n]); break; case FeatureMorphing: OutputGetConfigurationFeatureMorphing((PFEATURE_DATA_MORPHING)&lpConf[n]); break; case FeatureRemovableMedium: OutputGetConfigurationFeatureRemovableMedium((PFEATURE_DATA_REMOVABLE_MEDIUM)&lpConf[n]); break; case FeatureWriteProtect: OutputGetConfigurationFeatureWriteProtect((PFEATURE_DATA_WRITE_PROTECT)&lpConf[n]); break; case FeatureRandomReadable: OutputGetConfigurationFeatureRandomReadable((PFEATURE_DATA_RANDOM_READABLE)&lpConf[n]); break; case FeatureMultiRead: OutputGetConfigurationFeatureMultiRead((PFEATURE_DATA_MULTI_READ)&lpConf[n]); break; case FeatureCdRead: OutputGetConfigurationFeatureCdRead((PFEATURE_DATA_CD_READ)&lpConf[n]); SetFeatureCdRead((PFEATURE_DATA_CD_READ)&lpConf[n], pDevice); break; case FeatureDvdRead: OutputGetConfigurationFeatureDvdRead((PFEATURE_DATA_DVD_READ)&lpConf[n]); break; case FeatureRandomWritable: OutputGetConfigurationFeatureRandomWritable((PFEATURE_DATA_RANDOM_WRITABLE)&lpConf[n]); break; case FeatureIncrementalStreamingWritable: OutputGetConfigurationFeatureIncrementalStreamingWritable((PFEATURE_DATA_INCREMENTAL_STREAMING_WRITABLE)&lpConf[n]); break; case FeatureSectorErasable: OutputGetConfigurationFeatureSectorErasable((PFEATURE_DATA_SECTOR_ERASABLE)&lpConf[n]); break; case FeatureFormattable: OutputGetConfigurationFeatureFormattable((PFEATURE_DATA_FORMATTABLE)&lpConf[n]); break; case FeatureDefectManagement: OutputGetConfigurationFeatureDefectManagement((PFEATURE_DATA_DEFECT_MANAGEMENT)&lpConf[n]); break; case FeatureWriteOnce: OutputGetConfigurationFeatureWriteOnce((PFEATURE_DATA_WRITE_ONCE)&lpConf[n]); break; case FeatureRestrictedOverwrite: OutputGetConfigurationFeatureRestrictedOverwrite((PFEATURE_DATA_RESTRICTED_OVERWRITE)&lpConf[n]); break; case FeatureCdrwCAVWrite: OutputGetConfigurationFeatureCdrwCAVWrite((PFEATURE_DATA_CDRW_CAV_WRITE)&lpConf[n]); break; case FeatureMrw: OutputGetConfigurationFeatureMrw((PFEATURE_DATA_MRW)&lpConf[n]); break; case FeatureEnhancedDefectReporting: OutputGetConfigurationFeatureEnhancedDefectReporting((PFEATURE_ENHANCED_DEFECT_REPORTING)&lpConf[n]); break; case FeatureDvdPlusRW: OutputGetConfigurationFeatureDvdPlusRW((PFEATURE_DATA_DVD_PLUS_RW)&lpConf[n]); break; case FeatureDvdPlusR: OutputGetConfigurationFeatureDvdPlusR((PFEATURE_DATA_DVD_PLUS_R)&lpConf[n]); break; case FeatureRigidRestrictedOverwrite: OutputGetConfigurationFeatureRigidRestrictedOverwrite((PFEATURE_DATA_DVD_RW_RESTRICTED_OVERWRITE)&lpConf[n]); break; case FeatureCdTrackAtOnce: OutputGetConfigurationFeatureCdTrackAtOnce((PFEATURE_DATA_CD_TRACK_AT_ONCE)&lpConf[n]); break; case FeatureCdMastering: OutputGetConfigurationFeatureCdMastering((PFEATURE_DATA_CD_MASTERING)&lpConf[n]); break; case FeatureDvdRecordableWrite: OutputGetConfigurationFeatureDvdRecordableWrite((PFEATURE_DATA_DVD_RECORDABLE_WRITE)&lpConf[n]); break; case FeatureLayerJumpRecording: OutputGetConfigurationFeatureLayerJumpRecording((PFEATURE_DATA_LAYER_JUMP_RECORDING)&lpConf[n]); break; case FeatureCDRWMediaWriteSupport: OutputGetConfigurationFeatureCDRWMediaWriteSupport((PFEATURE_CD_RW_MEDIA_WRITE_SUPPORT)&lpConf[n]); break; case FeatureDvdPlusRWDualLayer: OutputGetConfigurationFeatureDvdPlusRWDualLayer((PFEATURE_DATA_DVD_PLUS_RW_DUAL_LAYER)&lpConf[n]); break; case FeatureDvdPlusRDualLayer: OutputGetConfigurationFeatureDvdPlusRDualLayer((PFEATURE_DATA_DVD_PLUS_R_DUAL_LAYER)&lpConf[n]); break; case FeatureHybridDisc: OutputGetConfigurationFeatureHybridDisc((PFEATURE_HYBRID_DISC)&lpConf[n]); break; case FeaturePowerManagement: OutputGetConfigurationFeaturePowerManagement((PFEATURE_DATA_POWER_MANAGEMENT)&lpConf[n]); break; case FeatureSMART: OutputGetConfigurationFeatureSMART((PFEATURE_DATA_SMART)&lpConf[n]); break; case FeatureEmbeddedChanger: OutputGetConfigurationFeatureEmbeddedChanger((PFEATURE_DATA_EMBEDDED_CHANGER)&lpConf[n]); break; case FeatureCDAudioAnalogPlay: OutputGetConfigurationFeatureCDAudioAnalogPlay((PFEATURE_DATA_CD_AUDIO_ANALOG_PLAY)&lpConf[n]); break; case FeatureMicrocodeUpgrade: OutputGetConfigurationFeatureMicrocodeUpgrade((PFEATURE_DATA_MICROCODE_UPDATE)&lpConf[n]); break; case FeatureTimeout: OutputGetConfigurationFeatureTimeout((PFEATURE_DATA_TIMEOUT)&lpConf[n]); break; case FeatureDvdCSS: OutputGetConfigurationFeatureDvdCSS((PFEATURE_DATA_DVD_CSS)&lpConf[n]); break; case FeatureRealTimeStreaming: OutputGetConfigurationFeatureRealTimeStreaming((PFEATURE_DATA_REAL_TIME_STREAMING)&lpConf[n]); SetFeatureRealTimeStreaming((PFEATURE_DATA_REAL_TIME_STREAMING)&lpConf[n], pDevice); break; case FeatureLogicalUnitSerialNumber: OutputGetConfigurationFeatureLogicalUnitSerialNumber((PFEATURE_DATA_LOGICAL_UNIT_SERIAL_NUMBER)&lpConf[n]); break; case FeatureMediaSerialNumber: OutputGetConfigurationFeatureMediaSerialNumber((PFEATURE_MEDIA_SERIAL_NUMBER)&lpConf[n]); break; case FeatureDiscControlBlocks: OutputGetConfigurationFeatureDiscControlBlocks((PFEATURE_DATA_DISC_CONTROL_BLOCKS)&lpConf[n]); break; case FeatureDvdCPRM: OutputGetConfigurationFeatureDvdCPRM((PFEATURE_DATA_DVD_CPRM)&lpConf[n]); break; case FeatureFirmwareDate: OutputGetConfigurationFeatureFirmwareDate((PFEATURE_DATA_FIRMWARE_DATE)&lpConf[n]); break; case FeatureAACS: OutputGetConfigurationFeatureAACS((PFEATURE_DATA_AACS)&lpConf[n]); break; case FeatureVCPS: OutputGetConfigurationFeatureVCPS((PFEATURE_VCPS)&lpConf[n]); break; default: if (0x0111 <= wCode && wCode <= 0xfeff) { OutputGetConfigurationFeatureReserved((PFEATURE_DATA_RESERVED)&lpConf[n]); } else if (0xff00 <= wCode && wCode <= 0xffff) { OutputGetConfigurationFeatureVendorSpecific((PFEATURE_DATA_VENDOR_SPECIFIC)&lpConf[n]); } break; } n += sizeof(FEATURE_HEADER) + lpConf[n + 3]; } } VOID OutputCDAtip( PCDROM_TOC_ATIP_DATA_BLOCK pAtip ) { OutputDiscLogA(OUTPUT_DHYPHEN_PLUS_STR(TOC ATIP) "\tCdrwReferenceSpeed: %u\n" "\t WritePower: %u\n" "\t UnrestrictedUse: %s\n" , pAtip->CdrwReferenceSpeed , pAtip->WritePower , BOOLEAN_TO_STRING_YES_NO_A(pAtip->UnrestrictedUse) ); switch (pAtip->IsCdrw) { case 0: OutputDiscLogA("\t DiscType: CD-R, DiscSubType: %u\n", pAtip->DiscSubType); break; case 1: OutputDiscLogA("\t DiscType: CD-RW, "); switch (pAtip->DiscSubType) { case 0: OutputDiscLogA("DiscSubType: Standard Speed\n"); break; case 1: OutputDiscLogA("DiscSubType: High Speed\n"); break; default: OutputDiscLogA("DiscSubType: Unknown\n"); break; } break; default: OutputDiscLogA(" DiscType: Unknown\n"); break; } OutputDiscLogA( "\t LeadInMsf: %02u:%02u:%02u\n" "\t LeadOutMsf: %02u:%02u:%02u\n" , pAtip->LeadInMsf[0], pAtip->LeadInMsf[1], pAtip->LeadInMsf[2] , pAtip->LeadOutMsf[0], pAtip->LeadOutMsf[1], pAtip->LeadOutMsf[2] ); if (pAtip->A1Valid) { OutputDiscLogA( "\t A1Values: %02u:%02u:%02u\n" , pAtip->A1Values[0], pAtip->A1Values[1], pAtip->A1Values[2] ); } if (pAtip->A2Valid) { OutputDiscLogA( "\t A2Values: %02u:%02u:%02u\n" , pAtip->A2Values[0], pAtip->A2Values[1], pAtip->A2Values[2] ); } if (pAtip->A3Valid) { OutputDiscLogA( "\t A3Values: %02u:%02u:%02u\n" , pAtip->A3Values[0], pAtip->A3Values[1], pAtip->A3Values[2] ); } } VOID OutputCDTextOther( PCDROM_TOC_CD_TEXT_DATA_BLOCK pDesc, WORD wTocTextEntries, BYTE bySizeInfoIdx, BYTE bySizeInfoCnt ) { INT nTocInfoCnt = 0; INT nSizeInfoCnt = 0; for (size_t z = 0; z <= bySizeInfoIdx; z++) { if (pDesc[z].PackType == CDROM_CD_TEXT_PACK_TOC_INFO) { // detail in Page 54-55 of EN 60908:1999 OutputDiscLogA("\tTocInfo\n"); if (nTocInfoCnt == 0) { OutputDiscLogA( "\t\t First track number: %u\n" "\t\t Last track number: %u\n" "\t\t Lead-out(msf): %u:%u:%u\n" , pDesc[z].Text[0], pDesc[z].Text[1], pDesc[z].Text[3] , pDesc[z].Text[4], pDesc[z].Text[5]); } if (nTocInfoCnt == 1) { for (INT i = 0, j = 0; i < 4; i++, j += 3) { OutputDiscLogA( "\t\t Track %d(msf): %u:%u:%u\n" , i + 1, pDesc[z].Text[j], pDesc[z].Text[j + 1], pDesc[z].Text[j + 2]); } } nTocInfoCnt++; } else if (pDesc[z].PackType == CDROM_CD_TEXT_PACK_TOC_INFO2) { OutputDiscLogA( "\tTocInfo2\n" "\t\t Priority number: %u\n" "\t\t Number of intervals: %u\n" "\t\t Start point(minutes): %u\n" "\t\t Start point(seconds): %u\n" "\t\t Start point(frames): %u\n" "\t\t End point(minutes): %u\n" "\t\t End point(seconds): %u\n" "\t\t End point(frames): %u\n" , pDesc[z].Text[0], pDesc[z].Text[1], pDesc[z].Text[6], pDesc[z].Text[7] , pDesc[z].Text[8], pDesc[z].Text[9], pDesc[z].Text[10], pDesc[z].Text[11]); } else if (pDesc[z].PackType == CDROM_CD_TEXT_PACK_SIZE_INFO) { // detail in Page 56 of EN 60908:1999 OutputDiscLogA("\tSizeInfo\n"); if (nSizeInfoCnt == 0) { OutputDiscLogA( "\t\t Charactor Code for this BLOCK: %u\n" "\t\t First track Number: %u\n" "\t\t Last track Number: %u\n" "\t\t Mode2 & copy protection flags: %u\n" "\t\tNumber of PACKS with ALBUM_NAME: %u\n" "\t\t Number of PACKS with PERFORMER: %u\n" "\t\tNumber of PACKS with SONGWRITER: %u\n" "\t\t Number of PACKS with COMPOSER: %u\n" "\t\t Number of PACKS with ARRANGER: %u\n" "\t\t Number of PACKS with MESSAGES: %u\n" "\t\t Number of PACKS with DISC_ID: %u\n" "\t\t Number of PACKS with GENRE: %u\n", pDesc[wTocTextEntries - bySizeInfoCnt].Text[0], pDesc[wTocTextEntries - bySizeInfoCnt].Text[1], pDesc[wTocTextEntries - bySizeInfoCnt].Text[2], pDesc[wTocTextEntries - bySizeInfoCnt].Text[3], pDesc[wTocTextEntries - bySizeInfoCnt].Text[4], pDesc[wTocTextEntries - bySizeInfoCnt].Text[5], pDesc[wTocTextEntries - bySizeInfoCnt].Text[6], pDesc[wTocTextEntries - bySizeInfoCnt].Text[7], pDesc[wTocTextEntries - bySizeInfoCnt].Text[8], pDesc[wTocTextEntries - bySizeInfoCnt].Text[9], pDesc[wTocTextEntries - bySizeInfoCnt].Text[10], pDesc[wTocTextEntries - bySizeInfoCnt].Text[11]); } else if (nSizeInfoCnt == 1) { OutputDiscLogA( "\t\t Number of PACKS with TOC_INFO: %u\n" "\t\t Number of PACKS with TOC_INFO2: %u\n" "\t\t Number of PACKS with $8a: %u\n" "\t\t Number of PACKS with $8b: %u\n" "\t\t Number of PACKS with $8c: %u\n" "\t\t Number of PACKS with $8d: %u\n" "\t\t Number of PACKS with UPC_EAN: %u\n" "\t\t Number of PACKS with SIZE_INFO: %u\n" "\t\tLast Sequence number of BLOCK 0: %u\n" "\t\tLast Sequence number of BLOCK 1: %u\n" "\t\tLast Sequence number of BLOCK 2: %u\n" "\t\tLast Sequence number of BLOCK 3: %u\n", pDesc[wTocTextEntries - bySizeInfoCnt + 1].Text[0], pDesc[wTocTextEntries - bySizeInfoCnt + 1].Text[1], pDesc[wTocTextEntries - bySizeInfoCnt + 1].Text[2], pDesc[wTocTextEntries - bySizeInfoCnt + 1].Text[3], pDesc[wTocTextEntries - bySizeInfoCnt + 1].Text[4], pDesc[wTocTextEntries - bySizeInfoCnt + 1].Text[5], pDesc[wTocTextEntries - bySizeInfoCnt + 1].Text[6], pDesc[wTocTextEntries - bySizeInfoCnt + 1].Text[7], pDesc[wTocTextEntries - bySizeInfoCnt + 1].Text[8], pDesc[wTocTextEntries - bySizeInfoCnt + 1].Text[9], pDesc[wTocTextEntries - bySizeInfoCnt + 1].Text[10], pDesc[wTocTextEntries - bySizeInfoCnt + 1].Text[11]); } else if (nSizeInfoCnt == 2) { OutputDiscLogA( "\t\tLast Sequence number of BLOCK 4: %u\n" "\t\tLast Sequence number of BLOCK 5: %u\n" "\t\tLast Sequence number of BLOCK 6: %u\n" "\t\tLast Sequence number of BLOCK 7: %u\n" "\t\t Language code BLOCK 0: %u\n" "\t\t Language code BLOCK 1: %u\n" "\t\t Language code BLOCK 2: %u\n" "\t\t Language code BLOCK 3: %u\n" "\t\t Language code BLOCK 4: %u\n" "\t\t Language code BLOCK 5: %u\n" "\t\t Language code BLOCK 6: %u\n" "\t\t Language code BLOCK 7: %u\n", pDesc[wTocTextEntries - bySizeInfoCnt + 2].Text[0], pDesc[wTocTextEntries - bySizeInfoCnt + 2].Text[1], pDesc[wTocTextEntries - bySizeInfoCnt + 2].Text[2], pDesc[wTocTextEntries - bySizeInfoCnt + 2].Text[3], pDesc[wTocTextEntries - bySizeInfoCnt + 2].Text[4], pDesc[wTocTextEntries - bySizeInfoCnt + 2].Text[5], pDesc[wTocTextEntries - bySizeInfoCnt + 2].Text[6], pDesc[wTocTextEntries - bySizeInfoCnt + 2].Text[7], pDesc[wTocTextEntries - bySizeInfoCnt + 2].Text[8], pDesc[wTocTextEntries - bySizeInfoCnt + 2].Text[9], pDesc[wTocTextEntries - bySizeInfoCnt + 2].Text[10], pDesc[wTocTextEntries - bySizeInfoCnt + 2].Text[11]); } nSizeInfoCnt++; } } } VOID OutputDiscInformation( PDISC_INFORMATION pDiscInformation ) { LPCSTR lpDiscStatus[] = { "Empty", "Incomplete", "Complete", "Others" }; LPCSTR lpStateOfLastSession[] = { "Empty", "Incomplete", "Reserved / Damaged", "Complete" }; LPCSTR lpBGFormatStatus[] = { "None", "Incomplete", "Running", "Complete" }; OutputDiscLogA( OUTPUT_DHYPHEN_PLUS_STR(DiscInformation) "\t DiscStatus: %s\n" "\t LastSessionStatus: %s\n" "\t Erasable: %s\n" "\t FirstTrackNumber: %u\n" "\t NumberOfSessionsLsb: %u\n" "\t LastSessionFirstTrackLsb: %u\n" "\t LastSessionLastTrackLsb: %u\n" "\t MrwStatus: %s\n" "\t MrwDirtyBit: %s\n" "\t UnrestrictedUse: %s\n" "\t DiscBarCodeValid: %s\n" "\t DiscIDValid: %s\n" "\t DiscType: " , lpDiscStatus[pDiscInformation->DiscStatus] , lpStateOfLastSession[pDiscInformation->LastSessionStatus] , BOOLEAN_TO_STRING_YES_NO_A(pDiscInformation->Erasable) , pDiscInformation->FirstTrackNumber , pDiscInformation->NumberOfSessionsLsb , pDiscInformation->LastSessionFirstTrackLsb , pDiscInformation->LastSessionLastTrackLsb , lpBGFormatStatus[pDiscInformation->MrwStatus] , BOOLEAN_TO_STRING_YES_NO_A(pDiscInformation->MrwDirtyBit) , BOOLEAN_TO_STRING_YES_NO_A(pDiscInformation->URU) , BOOLEAN_TO_STRING_YES_NO_A(pDiscInformation->DBC_V) , BOOLEAN_TO_STRING_YES_NO_A(pDiscInformation->DID_V)); switch (pDiscInformation->DiscType) { case DISK_TYPE_CDDA: OutputDiscLogA("CD-DA or CD-ROM Disc\n"); break; case DISK_TYPE_CDI: OutputDiscLogA("CD-I Disc\n"); break; case DISK_TYPE_XA: OutputDiscLogA("CD-ROM XA Disc\n"); break; case DISK_TYPE_UNDEFINED: OutputDiscLogA("Undefined\n"); break; default: OutputDiscLogA("Reserved\n"); break; } if (pDiscInformation->DID_V) { OutputDiscLogA( "\t DiscIdentification: %u%u%u%u\n", pDiscInformation->DiskIdentification[0], pDiscInformation->DiskIdentification[1], pDiscInformation->DiskIdentification[2], pDiscInformation->DiskIdentification[3]); } OutputDiscLogA( "\t LastSessionLeadIn: %02x:%02x:%02x:%02x\n" "\tLastPossibleLeadOutStartTime: %02x:%02x:%02x:%02x\n", pDiscInformation->LastSessionLeadIn[0], pDiscInformation->LastSessionLeadIn[1], pDiscInformation->LastSessionLeadIn[2], pDiscInformation->LastSessionLeadIn[3], pDiscInformation->LastPossibleLeadOutStartTime[0], pDiscInformation->LastPossibleLeadOutStartTime[1], pDiscInformation->LastPossibleLeadOutStartTime[2], pDiscInformation->LastPossibleLeadOutStartTime[3]); if (pDiscInformation->DBC_V) { OutputDiscLogA( "\t DiscBarCode: %u%u%u%u%u%u%u%u\n", pDiscInformation->DiskBarCode[0], pDiscInformation->DiskBarCode[1], pDiscInformation->DiskBarCode[2], pDiscInformation->DiskBarCode[3], pDiscInformation->DiskBarCode[4], pDiscInformation->DiskBarCode[5], pDiscInformation->DiskBarCode[6], pDiscInformation->DiskBarCode[7]); } OutputDiscLogA( "\t NumberOPCEntries: %u\n", pDiscInformation->NumberOPCEntries); if (pDiscInformation->NumberOPCEntries) { OutputDiscLogA( "\t OPCTable\n"); } for (INT i = 0; i < pDiscInformation->NumberOPCEntries; i++) { OutputDiscLogA( "\t\t Speed: %u%u\n" "\t\t OPCValues: %u%u%u%u%u%u\n", pDiscInformation->OPCTable[0].Speed[0], pDiscInformation->OPCTable[0].Speed[1], pDiscInformation->OPCTable[0].OPCValue[0], pDiscInformation->OPCTable[0].OPCValue[1], pDiscInformation->OPCTable[0].OPCValue[2], pDiscInformation->OPCTable[0].OPCValue[3], pDiscInformation->OPCTable[0].OPCValue[4], pDiscInformation->OPCTable[0].OPCValue[5]); } } VOID OutputModeParmeterHeader( PMODE_PARAMETER_HEADER pHeader ) { OutputDriveLogA( OUTPUT_DHYPHEN_PLUS_STR(ModeParmeterHeader) "\t ModeDataLength: %u\n" "\t MediumType: %u\n" "\tDeviceSpecificParameter: %u\n" "\t BlockDescriptorLength: %u\n" , pHeader->ModeDataLength , pHeader->MediumType , pHeader->DeviceSpecificParameter , pHeader->BlockDescriptorLength); } VOID OutputModeParmeterHeader10( PMODE_PARAMETER_HEADER10 pHeader ) { OutputDriveLogA( OUTPUT_DHYPHEN_PLUS_STR(ModeParmeterHeader10) "\t ModeDataLength: %u\n" "\t MediumType: %u\n" "\tDeviceSpecificParameter: %u\n" "\t BlockDescriptorLength: %u\n" , MAKEWORD(pHeader->ModeDataLength[1], pHeader->ModeDataLength[0]) , pHeader->MediumType , pHeader->DeviceSpecificParameter , MAKEWORD(pHeader->BlockDescriptorLength[1], pHeader->BlockDescriptorLength[0])); } VOID OutputCDVDCapabilitiesPage( PCDVD_CAPABILITIES_PAGE cdvd, INT perKb ) { OutputDriveLogA( OUTPUT_DHYPHEN_PLUS_STR(CDVD Capabilities & Mechanism Status Page) "\t PageCode: %#04x\n" "\t PSBit: %s\n" "\t PageLength: %u\n" "\t CDRRead: %s\n" "\t CDERead: %s\n" "\t Method2: %s\n" "\t DVDROMRead: %s\n" "\t DVDRRead: %s\n" "\t DVDRAMRead: %s\n" "\t CDRWrite: %s\n" "\t CDEWrite: %s\n" "\t TestWrite: %s\n" "\t DVDRWrite: %s\n" "\t DVDRAMWrite: %s\n" "\t AudioPlay: %s\n" "\t Composite: %s\n" "\t DigitalPortOne: %s\n" "\t DigitalPortTwo: %s\n" "\t Mode2Form1: %s\n" "\t Mode2Form2: %s\n" "\t MultiSession: %s\n" "\t BufferUnderrunFree: %s\n" "\t CDDA: %s\n" "\t CDDAAccurate: %s\n" "\t RWSupported: %s\n" "\t RWDeinterleaved: %s\n" "\t C2Pointers: %s\n" "\t ISRC: %s\n" "\t UPC: %s\n" "\t ReadBarCodeCapable: %s\n" "\t Lock: %s\n" "\t LockState: %s\n" "\t PreventJumper: %s\n" "\t Eject: %s\n" "\t LoadingMechanismType: " , cdvd->PageCode , BOOLEAN_TO_STRING_YES_NO_A(cdvd->PSBit) , cdvd->PageLength , BOOLEAN_TO_STRING_YES_NO_A(cdvd->CDRRead) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->CDERead) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->Method2) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->DVDROMRead) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->DVDRRead) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->DVDRAMRead) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->CDRWrite) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->CDEWrite) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->TestWrite) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->DVDRWrite) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->DVDRAMWrite) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->AudioPlay) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->Composite) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->DigitalPortOne) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->DigitalPortTwo) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->Mode2Form1) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->Mode2Form2) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->MultiSession) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->BufferUnderrunFree) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->CDDA) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->CDDAAccurate) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->RWSupported) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->RWDeinterleaved) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->C2Pointers) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->ISRC) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->UPC) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->ReadBarCodeCapable) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->Lock) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->LockState) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->PreventJumper) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->Eject)); switch (cdvd->LoadingMechanismType) { case LOADING_MECHANISM_CADDY: OutputDriveLogA("caddy\n") break; case LOADING_MECHANISM_TRAY: OutputDriveLogA("tray\n") break; case LOADING_MECHANISM_POPUP: OutputDriveLogA("popup\n") break; case LOADING_MECHANISM_INDIVIDUAL_CHANGER: OutputDriveLogA("individual changer\n") break; case LOADING_MECHANISM_CARTRIDGE_CHANGER: OutputDriveLogA("cartridge changer\n") break; default: OutputDriveLogA("unknown\n") break; } WORD rsm = MAKEWORD(cdvd->ReadSpeedMaximum[1], cdvd->ReadSpeedMaximum[0]); WORD rsc = MAKEWORD(cdvd->ReadSpeedCurrent[1], cdvd->ReadSpeedCurrent[0]); WORD wsm = MAKEWORD(cdvd->WriteSpeedMaximum[1], cdvd->WriteSpeedMaximum[0]); WORD wsc = MAKEWORD(cdvd->WriteSpeedCurrent[1], cdvd->WriteSpeedCurrent[0]); WORD bs = MAKEWORD(cdvd->BufferSize[1], cdvd->BufferSize[0]); OutputDriveLogA( "\t SeparateVolume: %s\n" "\t SeperateChannelMute: %s\n" "\t SupportsDiskPresent: %s\n" "\t SWSlotSelection: %s\n" "\t SideChangeCapable: %s\n" "\t RWInLeadInReadable: %s\n" "\t ReadSpeedMaximum: %uKB/sec (%ux)\n" "\t NumberVolumeLevels: %u\n" "\t BufferSize: %u\n" "\t ReadSpeedCurrent: %uKB/sec (%ux)\n" "\t BCK: %s\n" "\t RCK: %s\n" "\t LSBF: %s\n" "\t Length: %u\n" "\t WriteSpeedMaximum: %uKB/sec (%ux)\n" "\t WriteSpeedCurrent: %uKB/sec (%ux)\n" "\tCopyManagementRevision: %u\n" , BOOLEAN_TO_STRING_YES_NO_A(cdvd->SeparateVolume) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->SeperateChannelMute) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->SupportsDiskPresent) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->SWSlotSelection) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->SideChangeCapable) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->RWInLeadInReadable) , rsm, rsm / perKb , MAKEWORD(cdvd->NumberVolumeLevels[1], cdvd->NumberVolumeLevels[0]) , bs , rsc, rsc / perKb , BOOLEAN_TO_STRING_YES_NO_A(cdvd->BCK) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->RCK) , BOOLEAN_TO_STRING_YES_NO_A(cdvd->LSBF) , cdvd->Length , wsm, wsm / perKb , wsc, wsc / perKb , MAKEWORD(cdvd->CopyManagementRevision[1], cdvd->CopyManagementRevision[0])); } VOID OutputReadBufferCapacity( PREAD_BUFFER_CAPACITY_DATA pReadBufCapaData ) { OutputDriveLogA( OUTPUT_DHYPHEN_PLUS_STR(ReadBufferCapacity) "\t TotalBufferSize: %luKByte\n" "\tAvailableBufferSize: %luKByte\n", MAKELONG(MAKEWORD(pReadBufCapaData->TotalBufferSize[3], pReadBufCapaData->TotalBufferSize[2]), MAKEWORD(pReadBufCapaData->TotalBufferSize[1], pReadBufCapaData->TotalBufferSize[0])) / 1024, MAKELONG(MAKEWORD(pReadBufCapaData->AvailableBufferSize[3], pReadBufCapaData->AvailableBufferSize[2]), MAKEWORD(pReadBufCapaData->AvailableBufferSize[1], pReadBufCapaData->AvailableBufferSize[0])) / 1024); } VOID OutputSetSpeed( PCDROM_SET_SPEED pSetspeed ) { OutputDriveLogA( OUTPUT_DHYPHEN_PLUS_STR(SetSpeed) "\t RequestType: %s\n" "\t ReadSpeed: %uKB/sec\n" "\t WriteSpeed: %uKB/sec\n" "\tRotationControl: %s\n", pSetspeed->RequestType == 0 ? "CdromSetSpeed" : "CdromSetStreaming", pSetspeed->ReadSpeed, pSetspeed->WriteSpeed, pSetspeed->RotationControl == 0 ? "CdromDefaultRotation" : "CdromCAVRotation"); } VOID OutputEepromUnknownByte( LPBYTE pBuf, DWORD startIdx, DWORD endIdx ) { if (startIdx <= endIdx) { OutputDriveLogA("\t Unknown[%03ld]: ", startIdx); for (DWORD i = startIdx; i <= endIdx; i++) { OutputDriveLogA("%02x ", pBuf[i]); } OutputDriveLogA("\n"); } } VOID OutputEepromOverPX712( LPBYTE pBuf ) { OutputDriveLogA("\t Silent Mode: "); if (pBuf[0] == 1) { OutputDriveLogA( "Enabled\n" "\t\t Access Time: "); if (pBuf[1] == 0) { OutputDriveLogA("Fast\n"); } else if (pBuf[1] == 1) { OutputDriveLogA("Slow\n"); } OutputDriveLogA( "\t\t Max Read Speed: %dx\n" "\t\t Unknown: %dx\n" "\t\t Max Write Speed: %dx\n" "\t\t Unknown: %dx\n" "\t\t Unknown: %02x\n" "\t\t Tray Speed Eject: %02x (Low d0 - 80 High)\n" "\t\tTray Speed Loading: %02x (Low 2f - 7f High)\n", pBuf[2], pBuf[3], pBuf[4], pBuf[5], pBuf[6], pBuf[7], pBuf[8]); } else { OutputDriveLogA("Disable\n"); } DWORD tmp = 9; OutputDriveLogA("\t SecuRec: "); while (tmp < 29) { OutputDriveLogA("%02x ", pBuf[tmp]); tmp += 1; } OutputDriveLogA("\n\t SpeedRead: "); if (pBuf[29] == 0xf0 || pBuf[29] == 0) { OutputDriveLogA("Enable"); } else if (pBuf[29] == 0xff || pBuf[29] == 0x0f) { OutputDriveLogA("Disable"); } OutputDriveLogA("\n\t Unknown: %x\n", pBuf[30]); OutputDriveLogA("\t Spindown Time: "); switch (pBuf[31]) { case 0: OutputDriveLogA("Infinite\n"); break; case 1: OutputDriveLogA("125 ms\n"); break; case 2: OutputDriveLogA("250 ms\n"); break; case 3: OutputDriveLogA("500 ms\n"); break; case 4: OutputDriveLogA("1 second\n"); break; case 5: OutputDriveLogA("2 seconds\n"); break; case 6: OutputDriveLogA("4 seconds\n"); break; case 7: OutputDriveLogA("8 seconds\n"); break; case 8: OutputDriveLogA("16 seconds\n"); break; case 9: OutputDriveLogA("32 seconds\n"); break; case 10: OutputDriveLogA("1 minite\n"); break; case 11: OutputDriveLogA("2 minites\n"); break; case 12: OutputDriveLogA("4 minites\n"); break; case 13: OutputDriveLogA("8 minites\n"); break; case 14: OutputDriveLogA("16 minites\n"); break; case 15: OutputDriveLogA("32 minites\n"); break; default: OutputDriveLogA("Unset\n"); break; } LONG ucr = MAKELONG(MAKEWORD(pBuf[37], pBuf[36]), MAKEWORD(pBuf[35], pBuf[34])); LONG ucw = MAKELONG(MAKEWORD(pBuf[41], pBuf[40]), MAKEWORD(pBuf[39], pBuf[38])); LONG udr = MAKELONG(MAKEWORD(pBuf[45], pBuf[44]), MAKEWORD(pBuf[43], pBuf[42])); LONG udw = MAKELONG(MAKEWORD(pBuf[49], pBuf[48]), MAKEWORD(pBuf[47], pBuf[46])); OutputDriveLogA( "\tDisc load count: %u\n" "\t CD read time: %02lu:%02lu:%02lu\n" "\t CD write time: %02lu:%02lu:%02lu\n" "\t DVD read time: %02lu:%02lu:%02lu\n" "\t DVD write time: %02lu:%02lu:%02lu\n" , MAKEWORD(pBuf[33], pBuf[32]) , ucr / 3600, ucr / 60 % 60, ucr % 60 , ucw / 3600, ucw / 60 % 60, ucw % 60 , udr / 3600, udr / 60 % 60, udr % 60 , udw / 3600, udw / 60 % 60, udw % 60); OutputEepromUnknownByte(pBuf, 50, 114); OutputDriveLogA("\tChange BookType: "); switch (pBuf[115]) { case 0xfc: OutputDriveLogA("for DVD+R, DVD+R DL\n"); break; case 0xfd: OutputDriveLogA("for DVD+R\n"); break; case 0xfe: OutputDriveLogA("for DVD+R DL\n"); break; case 0xff: OutputDriveLogA("Disable\n"); break; default: OutputDriveLogA("Unknown[%02x]\n", pBuf[115]); break; } } VOID OutputEeprom( LPBYTE pBuf, INT nRoop, BOOL byPlxtrDrive ) { if (nRoop == 0) { OutputDriveLogA( "\t Signature: %02x %02x\n" "\t VendorId: %.8s\n" "\t ProductId: %.16s\n" "\t SerialNumber: %06lu\n" , pBuf[0], pBuf[1] , (LPCH)&pBuf[2] , (LPCH)&pBuf[10] , strtoul((LPCH)&pBuf[26], NULL, 16)); OutputEepromUnknownByte(pBuf, 31, 40); switch (byPlxtrDrive) { case PLXTR_DRIVE_TYPE::PX760A: case PLXTR_DRIVE_TYPE::PX755A: case PLXTR_DRIVE_TYPE::PX716AL: case PLXTR_DRIVE_TYPE::PX716A: case PLXTR_DRIVE_TYPE::PX714A: case PLXTR_DRIVE_TYPE::PX712A: OutputDriveLogA("\t TLA: %.4s\n", (LPCH)&pBuf[41]); break; default: OutputEepromUnknownByte(pBuf, 41, 44); break; } OutputEepromUnknownByte(pBuf, 45, 107); switch (byPlxtrDrive) { case PLXTR_DRIVE_TYPE::PX760A: case PLXTR_DRIVE_TYPE::PX755A: case PLXTR_DRIVE_TYPE::PX716AL: case PLXTR_DRIVE_TYPE::PX716A: case PLXTR_DRIVE_TYPE::PX714A: OutputEepromUnknownByte(pBuf, 108, 255); break; case PLXTR_DRIVE_TYPE::PX712A: OutputEepromUnknownByte(pBuf, 108, 255); OutputEepromOverPX712(&pBuf[256]); OutputEepromUnknownByte(pBuf, 372, 510); OutputDriveLogA( "\t Sum: %02x (SpeedRead: %02x + Spindown Time: %02x + BookType: %02x + Others)\n" , pBuf[511], pBuf[285], pBuf[287], pBuf[371]); break; case PLXTR_DRIVE_TYPE::PX708A2: case PLXTR_DRIVE_TYPE::PX708A: case PLXTR_DRIVE_TYPE::PX704A: { OutputEepromUnknownByte(pBuf, 108, 114); LONG ucr = MAKELONG(MAKEWORD(pBuf[120], pBuf[119]), MAKEWORD(pBuf[118], pBuf[117])); LONG ucw = MAKELONG(MAKEWORD(pBuf[125], pBuf[124]), MAKEWORD(pBuf[123], pBuf[122])); OutputDriveLogA( "\tDisc load count: %u\n" "\t CD read time: %02lu:%02lu:%02lu\n" "\t Unknown: %02x\n" "\t CD write time: %02lu:%02lu:%02lu\n" , MAKEWORD(pBuf[116], pBuf[115]) , ucr / 3600, ucr / 60 % 60, ucr % 60 , pBuf[121] , ucw / 3600, ucw / 60 % 60, ucw % 60); OutputEepromUnknownByte(pBuf, 126, 211); LONG udr = MAKELONG(MAKEWORD(pBuf[215], pBuf[214]), MAKEWORD(pBuf[213], pBuf[212])); LONG udw = MAKELONG(MAKEWORD(pBuf[219], pBuf[218]), MAKEWORD(pBuf[217], pBuf[216])); OutputDriveLogA( "\t DVD read time: %02lu:%02lu:%02lu\n" "\t DVD write time: %02lu:%02lu:%02lu\n" , udr / 3600, udr / 60 % 60, udr % 60 , udw / 3600, udw / 60 % 60, udw % 60); OutputEepromUnknownByte(pBuf, 220, 255); break; } case PLXTR_DRIVE_TYPE::PX320A: { OutputEepromUnknownByte(pBuf, 108, 123); LONG ucr = MAKELONG(MAKEWORD(pBuf[127], pBuf[126]), MAKEWORD(pBuf[125], pBuf[124])); OutputDriveLogA( "\t CD read time: %02lu:%02lu:%02lu\n" , ucr / 3600, ucr / 60 % 60, ucr % 60); OutputEepromUnknownByte(pBuf, 128, 187); LONG udr = MAKELONG(MAKEWORD(pBuf[191], pBuf[190]), MAKEWORD(pBuf[189], pBuf[188])); OutputDriveLogA( "\t DVD read time: %02lu:%02lu:%02lu\n" , udr / 3600, udr / 60 % 60, udr % 60); OutputEepromUnknownByte(pBuf, 192, 226); OutputDriveLogA( "\tDisc load count: %u\n" , MAKEWORD(pBuf[228], pBuf[227])); OutputEepromUnknownByte(pBuf, 229, 255); break; } case PLXTR_DRIVE_TYPE::PREMIUM2: case PLXTR_DRIVE_TYPE::PREMIUM: case PLXTR_DRIVE_TYPE::PXW5224A: case PLXTR_DRIVE_TYPE::PXW4824A: case PLXTR_DRIVE_TYPE::PXW4012A: case PLXTR_DRIVE_TYPE::PXW4012S: { LONG ucr = MAKELONG(MAKEWORD(pBuf[111], pBuf[110]), MAKEWORD(pBuf[109], pBuf[108])); LONG ucw = MAKELONG(MAKEWORD(pBuf[125], pBuf[124]), MAKEWORD(pBuf[123], pBuf[122])); OutputDriveLogA( "\t CD read time: %02lu:%02lu:%02lu\n" "\t Unknown: %02x %02x %02x %02x %02x %02x %02x %02x\n" "\tDisc load count: %u\n" "\t CD write time: %02lu:%02lu:%02lu\n" , ucr / 3600, ucr / 60 % 60, ucr % 60 , pBuf[112], pBuf[113], pBuf[114], pBuf[115], pBuf[116], pBuf[117], pBuf[118], pBuf[119] , MAKEWORD(pBuf[121], pBuf[120]) , ucw / 3600, ucw / 60 % 60, ucw % 60); OutputEepromUnknownByte(pBuf, 126, 127); break; } case PLXTR_DRIVE_TYPE::PXW2410A: case PLXTR_DRIVE_TYPE::PXS88T: case PLXTR_DRIVE_TYPE::PXW1610A: case PLXTR_DRIVE_TYPE::PXW1210A: case PLXTR_DRIVE_TYPE::PXW1210S: { OutputEepromUnknownByte(pBuf, 108, 119); LONG ucw = MAKELONG(MAKEWORD(pBuf[125], pBuf[124]), MAKEWORD(pBuf[123], pBuf[122])); OutputDriveLogA( "\tDisc load count: %u\n" "\t CD write time: %02lu:%02lu:%02lu\n" , MAKEWORD(pBuf[121], pBuf[120]) , ucw / 3600, ucw / 60 % 60, ucw % 60); OutputEepromUnknownByte(pBuf, 126, 127); break; } case PLXTR_DRIVE_TYPE::PXW124TS: case PLXTR_DRIVE_TYPE::PXW8432T: case PLXTR_DRIVE_TYPE::PXW8220T: case PLXTR_DRIVE_TYPE::PXW4220T: case PLXTR_DRIVE_TYPE::PXR820T: { OutputEepromUnknownByte(pBuf, 108, 121); LONG ucw = MAKELONG(MAKEWORD(pBuf[125], pBuf[124]), MAKEWORD(pBuf[123], pBuf[122])); OutputDriveLogA( "\t CD write time: %02lu:%02lu:%02lu\n" , ucw / 3600, ucw / 60 % 60, ucw % 60); OutputEepromUnknownByte(pBuf, 126, 127); break; } case PLXTR_DRIVE_TYPE::PXR412C: case PLXTR_DRIVE_TYPE::PX40TS: case PLXTR_DRIVE_TYPE::PX40TSUW: case PLXTR_DRIVE_TYPE::PX40TW: case PLXTR_DRIVE_TYPE::PX32TS: case PLXTR_DRIVE_TYPE::PX32CS: case PLXTR_DRIVE_TYPE::PX20TS: case PLXTR_DRIVE_TYPE::PX12TS: case PLXTR_DRIVE_TYPE::PX12CS: case PLXTR_DRIVE_TYPE::PX8XCS: OutputEepromUnknownByte(pBuf, 108, 127); break; } } else if (nRoop == 1 && byPlxtrDrive <= PLXTR_DRIVE_TYPE::PX714A) { OutputEepromOverPX712(pBuf); OutputDriveLogA("\t Auto Strategy: "); switch (pBuf[116]) { case 0x06: if (PLXTR_DRIVE_TYPE::PX716AL <= byPlxtrDrive && byPlxtrDrive <= PLXTR_DRIVE_TYPE::PX714A) { OutputDriveLogA("AS OFF\n"); } else { OutputDriveLogA("Unknown[%02x]\n", pBuf[116]); } break; case 0x07: if (PLXTR_DRIVE_TYPE::PX716AL <= byPlxtrDrive && byPlxtrDrive <= PLXTR_DRIVE_TYPE::PX714A) { OutputDriveLogA("Auto Selection\n"); } else { OutputDriveLogA("AS ON\n"); } break; case 0x0b: OutputDriveLogA("AS ON(Forced)\n"); break; case 0x0e: if (byPlxtrDrive <= PLXTR_DRIVE_TYPE::PX755A) { OutputDriveLogA("AS OFF\n"); } else { OutputDriveLogA("Unknown[%02x]\n", pBuf[116]); } break; case 0x0f: if (byPlxtrDrive <= PLXTR_DRIVE_TYPE::PX755A) { OutputDriveLogA("Auto Selection\n"); } else { OutputDriveLogA("Unknown[%02x]\n", pBuf[116]); } break; default: OutputDriveLogA("Unknown[%02x]\n", pBuf[116]); break; } OutputEepromUnknownByte(pBuf, 117, 254); OutputDriveLogA( "\t Sum: %02x (SpeedRead: %02x + Spindown Time: %02x + BookType: %02x + Auto Strategy: %02x + Others)\n" , pBuf[255], pBuf[29], pBuf[31], pBuf[115], pBuf[116]); } else { OutputEepromUnknownByte(pBuf, 0, 255); } }
33.268718
120
0.688735
tungol
4dce6c9ece96363ecd1f5bd5b0888a1db9332d9d
1,896
hpp
C++
include/type_tools.hpp
ne0ndrag0n/BlastBASIC
f38f05c27fe5532f9ea52f4599f72d6a5353e15c
[ "MIT" ]
2
2021-01-26T11:58:08.000Z
2021-05-26T22:12:19.000Z
include/type_tools.hpp
ne0ndrag0n/GoldScorpion
f38f05c27fe5532f9ea52f4599f72d6a5353e15c
[ "MIT" ]
null
null
null
include/type_tools.hpp
ne0ndrag0n/GoldScorpion
f38f05c27fe5532f9ea52f4599f72d6a5353e15c
[ "MIT" ]
null
null
null
#pragma once #include "token.hpp" #include "result_type.hpp" #include "symbol.hpp" #include "ast.hpp" #include <string> #include <optional> namespace GoldScorpion { struct SymbolTypeSettings { std::string fileId; SymbolResolver& symbols; }; using SymbolTypeResult = Result< SymbolType, std::string >; std::optional< TokenType > typeIdToTokenType( const std::string& id ); std::optional< std::string > tokenTypeToTypeId( const TokenType type ); std::optional< std::string > tokenToTypeId( const Token& token ); bool tokenIsPrimitiveType( const Token& token ); bool typesComparable( const SymbolType& lhs, const SymbolType& rhs ); bool typeIsArray( const SymbolType& type ); bool typeIsFunction( const SymbolType& type ); bool typeIsUdt( const SymbolType& type ); bool typeIsInteger( const SymbolType& type ); bool typeIsString( const SymbolType& type ); bool typesMatch( const SymbolType& lhs, const SymbolType& rhs, SymbolTypeSettings settings ); bool integerTypesMatch( const SymbolType& lhs, const SymbolType& rhs ); bool assignmentCoercible( const SymbolType& lhs, const SymbolType& rhs ); bool coercibleToString( const SymbolType& lhs, const SymbolType& rhs ); SymbolNativeType promotePrimitiveTypes( const SymbolNativeType& lhs, const SymbolNativeType& rhs ); // New symbol type stuff that will replace the type stuff immediately above SymbolTypeResult getType( const Primary& node, SymbolTypeSettings settings ); SymbolTypeResult getType( const CallExpression& node, SymbolTypeSettings settings ); SymbolTypeResult getType( const BinaryExpression& node, SymbolTypeSettings settings ); SymbolTypeResult getType( const AssignmentExpression& node, SymbolTypeSettings settings ); SymbolTypeResult getType( const Expression& node, SymbolTypeSettings settings ); }
34.472727
103
0.741561
ne0ndrag0n
4dd07922de7876cd071b5da6226a81cf228a26e7
3,938
cpp
C++
Simpscrp/simpscrp.cpp
mrob95/natlink
dc806ab62da89b7bb3d3683387af00c696601e16
[ "MIT" ]
2
2021-06-22T02:25:08.000Z
2021-08-16T23:35:02.000Z
Simpscrp/simpscrp.cpp
mrob95/natlink
dc806ab62da89b7bb3d3683387af00c696601e16
[ "MIT" ]
4
2020-12-18T16:51:05.000Z
2022-03-16T08:06:38.000Z
src/vocola2/Simpscrp/simpscrp.cpp
dictation-toolbox/Vocola
25b8bfdf8a7bf1495a950ac061e54fa3454f089d
[ "MIT" ]
2
2020-11-19T15:33:30.000Z
2021-12-07T02:09:04.000Z
// Made by Paulo Soares - psoares@consiste.pt // Use in whatever ways you want. #include "stdafx.h" #include "Python.h" #include "PlayKeys.h" BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) { char buf[300]; int rc = GetWindowText(hwnd, buf, sizeof(buf)); if (rc) { PyObject* list = (PyObject*)lParam; PyObject* tuple = PyTuple_New(2); PyTuple_SetItem(tuple, 0, PyInt_FromLong((long)hwnd)); PyTuple_SetItem(tuple, 1, PyString_FromString(buf)); PyList_Append(list, tuple); } return TRUE; } extern "C"{ static PyObject* send_keys(PyObject* self, PyObject* args) { char* buf; UINT d; UINT erro; if (!PyArg_ParseTuple(args, "s", &buf)) return NULL; Py_BEGIN_ALLOW_THREADS erro = PlayKeys(buf, &d); Py_END_ALLOW_THREADS return PyInt_FromLong((long)erro); } static PyObject* message_box(PyObject* self, PyObject* args) { char* buf; int result; UINT type = MB_OK; if (!PyArg_ParseTuple(args, "s|i", &buf, &type)) return NULL; Py_BEGIN_ALLOW_THREADS result = MessageBox(GetForegroundWindow(), buf, "Message", type); Py_END_ALLOW_THREADS return PyInt_FromLong((long)result); } static PyObject* enum_windows(PyObject* self, PyObject* args) { if (PyTuple_Size(args)) return NULL; PyObject* list = PyList_New(0); EnumWindows(EnumWindowsProc, (LPARAM)list); return list; } static PyObject* set_foreground_window(PyObject* self, PyObject* args) { long window; HWND hwnd; long result; if (!PyArg_ParseTuple(args, "i", &window)) return NULL; hwnd = (HWND)window; if (IsWindow(hwnd)) { SetForegroundWindow(hwnd); result = 0; } else result = 1; return PyInt_FromLong((long)result); } static PyObject* exec_app(PyObject* self, PyObject* args) { char* buf; long wait = 0; int error; if (!PyArg_ParseTuple(args, "s|i", &buf, &wait)) return NULL; Py_BEGIN_ALLOW_THREADS STARTUPINFO sui; PROCESS_INFORMATION pi; memset(&sui, 0, sizeof(sui)); sui.cb = sizeof (STARTUPINFO); /* This will hide the window */ sui.dwFlags = STARTF_USESHOWWINDOW; sui.wShowWindow = SW_HIDE; /*****************************/ if (error = CreateProcess (NULL, buf, NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &sui, &pi )) { WaitForInputIdle(pi.hProcess, 30000); if (wait) WaitForSingleObject(pi.hProcess, INFINITE); } CloseHandle(pi.hThread); CloseHandle(pi.hProcess); Py_END_ALLOW_THREADS return PyInt_FromLong((long)(error == 0)); } static PyMethodDef simpscrp_methods[] = { {"SendKeys", send_keys, 1, "SendKeys(keys)\nSend keys to the window with focus. The sintax is the same as VB.\nReturns 0 if successeful."}, {"MessageBox", message_box, 1, "MessageBox(message, type)\nShow a message box. See the win api for the values\nof type and return. Type defaults to MB_OK."}, {"EnumWindows", enum_windows, 1, "EnumWindows()\nReturns a list of the top windows in the format (hwnd, caption)."}, {"SetForegroundWindow", set_foreground_window, 1, "SetForegroundWindow(hwnd)\nMake a window the focus window. Returns 0 if successeful."}, {"Exec", exec_app, 1, "Exec(command,wait)\nExecutes a command and optionally waits for it's completion.\nWait defaults to 0. Returns 0 if successeful."}, {NULL, NULL} }; __declspec(dllexport) void initsimpscrp() { Py_InitModule3("simpscrp", simpscrp_methods, "Module simpscrp - Simple scripting functions.\n" "Made by Paulo Soares - psoares@consiste.pt\n" "Use in whatever ways you want.\n"); } }
28.128571
161
0.642712
mrob95
4dd0fe514094f2a11e71db7d7051e1d553bbf0e5
876
cpp
C++
src/gb-lib/mem/mirrorbank.cpp
johannes51/GBEmu
bb85debc8191d7eaa3917c2d441172f97731374c
[ "MIT" ]
null
null
null
src/gb-lib/mem/mirrorbank.cpp
johannes51/GBEmu
bb85debc8191d7eaa3917c2d441172f97731374c
[ "MIT" ]
null
null
null
src/gb-lib/mem/mirrorbank.cpp
johannes51/GBEmu
bb85debc8191d7eaa3917c2d441172f97731374c
[ "MIT" ]
null
null
null
#include "mirrorbank.h" #include <stdexcept> #include "location/location.h" #include "mem_tools.h" MirrorBank::MirrorBank(const MemoryArea& mirrorArea, const MemoryArea& originalArea, IMemoryManagerSP mirrored) : SingleAreaManager(mirrorArea) , offset_(originalArea.from - mirrorArea.from) , mirrored_(std::move(mirrored)) { if (mirrorArea.to - mirrorArea.from > originalArea.to - originalArea.from) { throw std::invalid_argument("Mirror bigger than original"); } } auto MirrorBank::getByte(address_type address) -> Location<uint8_t> { return mirrored_->getByte(mem_tools::translateAddressSafe(address, singleArea(), offset_)); } auto MirrorBank::getWord(address_type address) -> Location<uint16_t> { mem_tools::assertSafe(address + 1, singleArea()); return mirrored_->getWord(mem_tools::translateAddressSafe(address, singleArea(), offset_)); }
31.285714
111
0.756849
johannes51
4dd3a1cd09f0812fe436090c41b6f88e69478e24
1,231
cc
C++
fbstab/components/dense_data.cc
tcunis/fbstab
25d5259f683427867f140567d739a55ed7359aca
[ "BSD-3-Clause" ]
16
2019-08-09T18:43:17.000Z
2022-01-07T12:38:27.000Z
fbstab/components/dense_data.cc
tcunis/fbstab
25d5259f683427867f140567d739a55ed7359aca
[ "BSD-3-Clause" ]
12
2019-08-14T17:33:29.000Z
2021-02-01T12:03:36.000Z
fbstab/components/dense_data.cc
tcunis/fbstab
25d5259f683427867f140567d739a55ed7359aca
[ "BSD-3-Clause" ]
3
2019-08-09T19:03:23.000Z
2020-05-07T23:03:33.000Z
#include "fbstab/components/dense_data.h" #include <Eigen/Dense> #include <cmath> #include <stdexcept> namespace fbstab { using MatrixXd = Eigen::MatrixXd; using VectorXd = Eigen::VectorXd; void DenseData::gemvH(const Eigen::VectorXd &x, double a, double b, Eigen::VectorXd *y) const { *y = a * H_ * x + b * (*y); } void DenseData::gemvG(const Eigen::VectorXd &x, double a, double b, Eigen::VectorXd *y) const { *y = a * G_ * x + b * (*y); } void DenseData::gemvGT(const Eigen::VectorXd &x, double a, double b, Eigen::VectorXd *y) const { *y = a * G_.transpose() * x + b * (*y); } void DenseData::gemvA(const Eigen::VectorXd &x, double a, double b, Eigen::VectorXd *y) const { *y = a * A_ * x + b * (*y); } void DenseData::gemvAT(const Eigen::VectorXd &x, double a, double b, Eigen::VectorXd *y) const { *y = a * A_.transpose() * x + b * (*y); } void DenseData::axpyf(double a, Eigen::VectorXd *y) const { *y += a * f_; } void DenseData::axpyh(double a, Eigen::VectorXd *y) const { *y += a * h_; } void DenseData::axpyb(double a, Eigen::VectorXd *y) const { *y += a * b_; } } // namespace fbstab
27.977273
75
0.576767
tcunis
4dd441fd93d7ec0f5533639612df4b552c50b987
2,661
cpp
C++
gueepo2D/engine/core/GameObject/GameWorld.cpp
guilhermepo2/gueepo2D
deb03ff39c871710c07d36c366b53b34dbfebf08
[ "MIT" ]
1
2022-02-03T19:24:47.000Z
2022-02-03T19:24:47.000Z
gueepo2D/engine/core/GameObject/GameWorld.cpp
guilhermepo2/gueepo2D
deb03ff39c871710c07d36c366b53b34dbfebf08
[ "MIT" ]
4
2021-10-30T19:03:07.000Z
2022-02-10T01:06:02.000Z
gueepo2D/engine/core/GameObject/GameWorld.cpp
guilhermepo2/gueepo2D
deb03ff39c871710c07d36c366b53b34dbfebf08
[ "MIT" ]
1
2021-10-01T03:08:21.000Z
2021-10-01T03:08:21.000Z
#include "gueepo2Dpch.h" #include "GameWorld.h" #include "Entity.h" #include "GameObject.h" namespace gueepo { GameWorld* GameWorld::s_instance = nullptr; GameWorld::GameWorld() { if (s_instance != nullptr) { LOG_ERROR("trying to create a second instance of the game world?!"); return; } s_instance = this; } GameWorld::~GameWorld() {} void GameWorld::BeginPlay() { for (auto entity : m_AllEntities) { entity->BeginPlay(); } } void GameWorld::ProcessInput(const InputState& CurrentInputState) { for (auto entity : m_AllEntities) { entity->ProcessInput(CurrentInputState); } } void GameWorld::Update(float DeltaTime) { for (auto entity : m_AllEntities) { entity->Update(DeltaTime); } Internal_Update(DeltaTime); } void GameWorld::Render(SpriteBatcher* batch) { for (auto entity : m_AllEntities) { entity->Render(batch); } } void GameWorld::Destroy() { for (auto entity : m_AllEntities) { entity->Destroy(); } } Entity* GameWorld::CreateEntity(const std::string& name) { Entity* newEntity = new Entity(name); m_EntitiesToBeAdded.push_back(newEntity); return newEntity; } gueepo::GameObject* GameWorld::CreateGameObject(Texture* tex, const std::string& name /*= "GameObject"*/) { GameObject* newGameObject = new GameObject(tex, name); m_EntitiesToBeAdded.push_back(newGameObject); return newGameObject; } void GameWorld::KillEntity(Entity* entity) { m_entitiesToBeRemoved.push_back(entity); } void GameWorld::Internal_Update(float DeltaTime) { for(auto entity: m_EntitiesToBeAdded) { m_AllEntities.push_back(entity); } m_EntitiesToBeAdded.clear(); for (auto entity : m_entitiesToBeRemoved) { if (!entity->IsActive()) { // it was already removed! LOG_WARN("trying to remove entity that was already removed..."); continue; } auto toRemove = std::find(m_AllEntities.begin(), m_AllEntities.end(), entity); if (toRemove != m_AllEntities.end()) { std::iter_swap(toRemove, m_AllEntities.end() - 1); entity->Destroy(); delete entity; m_AllEntities.pop_back(); } } m_entitiesToBeRemoved.clear(); } // ================================================= // // static implementations // // ================================================= Entity* GameWorld::Create(const std::string& name) { g2dassert(s_instance != nullptr, "can't create an entity without creating a game world!"); return s_instance->CreateEntity(name); } void GameWorld::Kill(Entity* entity) { g2dassert(s_instance != nullptr, "can't destroy an entity without creating a game world!"); s_instance->KillEntity(entity); } }
23.972973
108
0.668546
guilhermepo2
4dd48978ce7b6d77a579bc94675ba8937c4c8aee
148,518
cpp
C++
src/source.cpp
jlangvand/jucipp
0a3102f13e62d78a329d488fb1eb8812181e448e
[ "MIT" ]
null
null
null
src/source.cpp
jlangvand/jucipp
0a3102f13e62d78a329d488fb1eb8812181e448e
[ "MIT" ]
null
null
null
src/source.cpp
jlangvand/jucipp
0a3102f13e62d78a329d488fb1eb8812181e448e
[ "MIT" ]
null
null
null
#include "source.hpp" #include "config.hpp" #include "ctags.hpp" #include "directories.hpp" #include "filesystem.hpp" #include "git.hpp" #include "info.hpp" #include "json.hpp" #include "menu.hpp" #include "selection_dialog.hpp" #include "terminal.hpp" #include "utility.hpp" #include <algorithm> #include <boost/spirit/home/qi/char.hpp> #include <boost/spirit/home/qi/operator.hpp> #include <boost/spirit/home/qi/string.hpp> #include <iostream> #include <limits> #include <map> #include <numeric> #include <regex> #include <set> #ifdef _WIN32 #include <windows.h> inline DWORD get_current_process_id() { return GetCurrentProcessId(); } #else #include <unistd.h> inline pid_t get_current_process_id() { return getpid(); } #endif std::unique_ptr<TinyProcessLib::Process> Source::View::prettier_background_process = {}; Glib::RefPtr<Gsv::LanguageManager> Source::LanguageManager::get_default() { static auto instance = Gsv::LanguageManager::create(); return instance; } Glib::RefPtr<Gsv::StyleSchemeManager> Source::StyleSchemeManager::get_default() { static auto instance = Gsv::StyleSchemeManager::create(); static bool first = true; if(first) { instance->prepend_search_path((Config::get().home_juci_path / "styles").string()); first = false; } return instance; } Glib::RefPtr<Gsv::Language> Source::guess_language(const boost::filesystem::path &file_path) { auto language_manager = LanguageManager::get_default(); bool result_uncertain = false; auto filename = file_path.filename().string(); auto content_type = Gio::content_type_guess(filename, nullptr, 0, result_uncertain); if(result_uncertain) content_type.clear(); auto language = language_manager->guess_language(filename, content_type); if(!language) { auto extension = file_path.extension().string(); if(filename == "CMakeLists.txt") language = language_manager->get_language("cmake"); else if(filename == "meson.build") language = language_manager->get_language("meson"); else if(filename == "Makefile") language = language_manager->get_language("makefile"); else if(extension == ".tcc") language = language_manager->get_language("cpphdr"); else if(extension == ".ts" || extension == ".tsx" || extension == ".jsx" || extension == ".flow") language = language_manager->get_language("js"); else if(extension == ".vert" || // listed on https://github.com/KhronosGroup/glslang extension == ".frag" || extension == ".tesc" || extension == ".tese" || extension == ".geom" || extension == ".comp") language = language_manager->get_language("glsl"); else if(!file_path.has_extension()) { for(auto &part : file_path) { if(part == "include") { language = language_manager->get_language("cpphdr"); break; } } } } else if(language->get_id() == "cuda") { if(file_path.extension() == ".cuh") language = language_manager->get_language("cpphdr"); else language = language_manager->get_language("cpp"); } else if(language->get_id() == "opencl") language = language_manager->get_language("cpp"); return language; } Source::FixIt::FixIt(std::string source_, std::string path_, std::pair<Offset, Offset> offsets_) : source(std::move(source_)), path(std::move(path_)), offsets(std::move(offsets_)) { if(this->source.size() == 0) type = Type::erase; else { if(this->offsets.first == this->offsets.second) type = Type::insert; else type = Type::replace; } } std::string Source::FixIt::string(BaseView &view) { bool in_current_view = path == view.file_path; auto from_pos = (!in_current_view ? boost::filesystem::path(path).filename().string() + ':' : "") + std::to_string(offsets.first.line + 1) + ':' + std::to_string(offsets.first.index + 1); std::string to_pos, text; if(type != Type::insert) { to_pos = std::to_string(offsets.second.line + 1) + ':' + std::to_string(offsets.second.index + 1); if(in_current_view) { text = view.get_buffer()->get_text(view.get_iter_at_line_index(offsets.first.line, offsets.first.index), view.get_iter_at_line_index(offsets.second.line, offsets.second.index)); } } if(type == Type::insert) return "Insert " + source + " at " + from_pos; else if(type == Type::replace) return "Replace " + (!text.empty() ? text + " at " : "") + from_pos + " - " + to_pos + " with " + source; else return "Erase " + (!text.empty() ? text + " at " : "") + from_pos + " - " + to_pos; } ////////////// //// View //// ////////////// std::set<Source::View *> Source::View::non_deleted_views; std::set<Source::View *> Source::View::views; Source::View::View(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language, bool is_generic_view) : BaseView(file_path, language), SpellCheckView(file_path, language), DiffView(file_path, language) { non_deleted_views.emplace(this); views.emplace(this); similar_symbol_tag = get_buffer()->create_tag(); similar_symbol_tag->property_weight() = Pango::WEIGHT_ULTRAHEAVY; similar_symbol_tag->property_background_rgba() = Gdk::RGBA("rgba(255, 255, 255, 0.075)"); clickable_tag = get_buffer()->create_tag(); clickable_tag->property_underline() = Pango::Underline::UNDERLINE_SINGLE; clickable_tag->property_underline_set() = true; get_buffer()->create_tag("def:warning_underline"); get_buffer()->create_tag("def:error_underline"); auto mark_attr_debug_breakpoint = Gsv::MarkAttributes::create(); Gdk::RGBA rgba; rgba.set_red(1.0); rgba.set_green(0.5); rgba.set_blue(0.5); rgba.set_alpha(0.3); mark_attr_debug_breakpoint->set_background(rgba); set_mark_attributes("debug_breakpoint", mark_attr_debug_breakpoint, 100); auto mark_attr_debug_stop = Gsv::MarkAttributes::create(); rgba.set_red(0.5); rgba.set_green(0.5); rgba.set_blue(1.0); mark_attr_debug_stop->set_background(rgba); set_mark_attributes("debug_stop", mark_attr_debug_stop, 101); auto mark_attr_debug_breakpoint_and_stop = Gsv::MarkAttributes::create(); rgba.set_red(0.75); rgba.set_green(0.5); rgba.set_blue(0.75); mark_attr_debug_breakpoint_and_stop->set_background(rgba); set_mark_attributes("debug_breakpoint_and_stop", mark_attr_debug_breakpoint_and_stop, 102); hide_tag = get_buffer()->create_tag(); hide_tag->property_scale() = 0.25; if(is_c || is_cpp) { use_fixed_continuation_indenting = false; // TODO 2019: check if clang-format has improved... // boost::filesystem::path clang_format_file; // auto search_path=file_path.parent_path(); // boost::system::error_code ec; // while(true) { // clang_format_file=search_path/".clang-format"; // if(boost::filesystem::exists(clang_format_file, ec)) // break; // clang_format_file=search_path/"_clang-format"; // if(boost::filesystem::exists(clang_format_file, ec)) // break; // clang_format_file.clear(); // if(search_path==search_path.root_directory()) // break; // search_path=search_path.parent_path(); // } // if(!clang_format_file.empty()) { // auto lines=filesystem::read_lines(clang_format_file); // for(auto &line: lines) { // std::cout << "1" << std::endl; // if(!line.empty() && line.compare(0, 23, "ContinuationIndentWidth")==0) { // std::cout << "2" << std::endl; // use_continuation_indenting=true; // break; // } // } // } } setup_signals(); setup_format_style(is_generic_view); std::string comment_characters; if(is_bracket_language) comment_characters = "//"; else { if(is_language({"cmake", "makefile", "python", "python3", "sh", "perl", "ruby", "r", "asm", "automake", "yaml", "docker", "julia"})) comment_characters = "#"; else if(is_language({"latex", "matlab", "octave", "bibtex"})) comment_characters = "%"; else if(language_id == "fortran") comment_characters = "!"; else if(language_id == "pascal") comment_characters = "//"; else if(language_id == "lua") comment_characters = "--"; } if(!comment_characters.empty()) { toggle_comments = [this, comment_characters = std::move(comment_characters)] { std::vector<int> lines; Gtk::TextIter selection_start, selection_end; get_buffer()->get_selection_bounds(selection_start, selection_end); auto line_start = selection_start.get_line(); auto line_end = selection_end.get_line(); if(line_start != line_end && selection_end.starts_line()) --line_end; bool lines_commented = true; bool extra_spaces = true; int min_indentation = std::numeric_limits<int>::max(); for(auto line = line_start; line <= line_end; ++line) { auto iter = get_buffer()->get_iter_at_line(line); bool line_added = false; bool line_commented = false; bool extra_space = false; int indentation = 0; for(;;) { if(iter.ends_line()) break; else if(*iter == ' ' || *iter == '\t') { ++indentation; iter.forward_char(); continue; } else { lines.emplace_back(line); line_added = true; for(size_t c = 0; c < comment_characters.size(); ++c) { if(iter.ends_line()) { break; } else if(*iter == static_cast<unsigned int>(comment_characters[c])) { if(c < comment_characters.size() - 1) { iter.forward_char(); continue; } else { line_commented = true; if(!iter.ends_line()) { iter.forward_char(); if(*iter == ' ') extra_space = true; } break; } } else break; } break; } } if(line_added) { lines_commented &= line_commented; extra_spaces &= extra_space; min_indentation = std::min(min_indentation, indentation); } } if(lines.size()) { auto comment_characters_and_space = comment_characters + ' '; get_buffer()->begin_user_action(); for(auto &line : lines) { auto iter = get_buffer()->get_iter_at_line(line); if(min_indentation != std::numeric_limits<int>::max()) iter.forward_chars(min_indentation); if(lines_commented) { auto end_iter = iter; end_iter.forward_chars(comment_characters.size() + static_cast<int>(extra_spaces)); while(*iter == ' ' || *iter == '\t') { iter.forward_char(); end_iter.forward_char(); } get_buffer()->erase(iter, end_iter); } else get_buffer()->insert(iter, comment_characters_and_space); } get_buffer()->end_user_action(); } }; } get_methods = [this]() { std::vector<std::pair<Offset, std::string>> methods; boost::filesystem::path file_path; boost::system::error_code ec; bool use_tmp_file = false; bool is_cpp_standard_header = is_cpp && this->file_path.extension().empty(); if(this->get_buffer()->get_modified() || is_cpp_standard_header) { use_tmp_file = true; file_path = boost::filesystem::temp_directory_path(ec); if(ec) { Terminal::get().print("\e[31mError\e[m: could not get temporary directory folder\n", true); return methods; } file_path /= "jucipp_get_methods" + std::to_string(get_current_process_id()); boost::filesystem::create_directory(file_path, ec); if(ec) { Terminal::get().print("\e[31mError\e[m: could not create temporary folder\n", true); return methods; } file_path /= this->file_path.filename().string() + (is_cpp_standard_header ? ".hpp" : ""); filesystem::write(file_path, this->get_buffer()->get_text().raw()); } else file_path = this->file_path; Ctags ctags(file_path, true, true); if(use_tmp_file) boost::filesystem::remove_all(file_path.parent_path(), ec); if(!ctags) { Info::get().print("No methods found in current buffer"); return methods; } std::string line; while(std::getline(ctags.output, line)) { auto location = ctags.get_location(line, true, is_cpp); std::transform(location.kind.begin(), location.kind.end(), location.kind.begin(), [](char c) { return std::tolower(c); }); std::vector<std::string> ignore_kinds = {"variable", "local", "constant", "global", "property", "member", "enum", "class", "struct", "namespace", "macro", "param", "header", "typedef", "using", "alias", "project", "option"}; if(std::none_of(ignore_kinds.begin(), ignore_kinds.end(), [&location](const std::string &e) { return location.kind.find(e) != std::string::npos; }) && location.source.find("<b>") != std::string::npos) { std::string scope = !location.scope.empty() ? Glib::Markup::escape_text(location.scope) : ""; if(is_cpp && !scope.empty()) { // Remove namespace from location.source in C++ source files auto pos = location.source.find(scope + "::<b>"); if(pos != std::string::npos) location.source.erase(pos, scope.size() + 2); } methods.emplace_back(Offset(location.line, location.index), (!scope.empty() ? scope + ":" : "") + std::to_string(location.line + 1) + ": " + location.source); } } std::sort(methods.begin(), methods.end(), [](const std::pair<Offset, std::string> &e1, const std::pair<Offset, std::string> &e2) { return e1.first < e2.first; }); if(methods.empty()) Info::get().print("No methods found in current buffer"); return methods; }; } Gsv::DrawSpacesFlags Source::View::parse_show_whitespace_characters(const std::string &text) { namespace qi = boost::spirit::qi; qi::symbols<char, Gsv::DrawSpacesFlags> options; options.add("space", Gsv::DRAW_SPACES_SPACE)("tab", Gsv::DRAW_SPACES_TAB)("newline", Gsv::DRAW_SPACES_NEWLINE)("nbsp", Gsv::DRAW_SPACES_NBSP)("leading", Gsv::DRAW_SPACES_LEADING)("text", Gsv::DRAW_SPACES_TEXT)("trailing", Gsv::DRAW_SPACES_TRAILING)("all", Gsv::DRAW_SPACES_ALL); std::set<Gsv::DrawSpacesFlags> out; // parse comma-separated list of options qi::phrase_parse(text.begin(), text.end(), options % ',', qi::space, out); return out.count(Gsv::DRAW_SPACES_ALL) > 0 ? Gsv::DRAW_SPACES_ALL : static_cast<Gsv::DrawSpacesFlags>(std::accumulate(out.begin(), out.end(), 0)); } bool Source::View::save() { if(file_path.empty() || !get_buffer()->get_modified()) return false; if(Config::get().source.cleanup_whitespace_characters) cleanup_whitespace_characters(); if(format_style && file_path.filename() != "package.json") { if(Config::get().source.format_style_on_save) format_style(true, true); else if(Config::get().source.format_style_on_save_if_style_file_found) format_style(false, true); hide_tooltips(); } try { auto io_channel = Glib::IOChannel::create_from_file(file_path.string(), "w"); auto start_iter = get_buffer()->begin(); auto end_iter = start_iter; while(start_iter) { end_iter.forward_chars(131072); io_channel->write(get_buffer()->get_text(start_iter, end_iter)); start_iter = end_iter; } } catch(const Glib::Error &error) { Terminal::get().print("\e[31mError\e[m: could not save file " + filesystem::get_short_path(file_path).string() + ": " + error.what() + '\n', true); return false; } boost::system::error_code ec; last_write_time = boost::filesystem::last_write_time(file_path, ec); if(ec) last_write_time.reset(); // Remonitor file in case it did not exist before monitor_file(); get_buffer()->set_modified(false); Directories::get().on_save_file(file_path); return true; } void Source::View::configure() { SpellCheckView::configure(); DiffView::configure(); if(Config::get().source.style.size() > 0) { auto scheme = StyleSchemeManager::get_default()->get_scheme(Config::get().source.style); if(scheme) get_source_buffer()->set_style_scheme(scheme); } set_draw_spaces(parse_show_whitespace_characters(Config::get().source.show_whitespace_characters)); { // Set Word Wrap namespace qi = boost::spirit::qi; std::set<std::string> word_wrap_language_ids; qi::phrase_parse(Config::get().source.word_wrap.begin(), Config::get().source.word_wrap.end(), (+(~qi::char_(','))) % ',', qi::space, word_wrap_language_ids); if(std::any_of(word_wrap_language_ids.begin(), word_wrap_language_ids.end(), [this](const std::string &word_wrap_language_id) { return word_wrap_language_id == language_id || word_wrap_language_id == "all"; })) set_wrap_mode(Gtk::WrapMode::WRAP_WORD_CHAR); else set_wrap_mode(Gtk::WrapMode::WRAP_NONE); } property_highlight_current_line() = Config::get().source.highlight_current_line; line_renderer->set_visible(Config::get().source.show_line_numbers); #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION >= 20) Gdk::Rectangle rectangle; get_iter_location(get_buffer()->begin(), rectangle); set_bottom_margin((rectangle.get_height() + get_pixels_above_lines() + get_pixels_below_lines()) * 10); #endif if(Config::get().source.show_background_pattern) gtk_source_view_set_background_pattern(this->gobj(), GTK_SOURCE_BACKGROUND_PATTERN_TYPE_GRID); else gtk_source_view_set_background_pattern(this->gobj(), GTK_SOURCE_BACKGROUND_PATTERN_TYPE_NONE); if((property_show_right_margin() = Config::get().source.show_right_margin)) property_right_margin_position() = Config::get().source.right_margin_position; //Create tags for diagnostic warnings and errors: auto scheme = get_source_buffer()->get_style_scheme(); auto tag_table = get_buffer()->get_tag_table(); auto style = scheme->get_style("def:warning"); auto diagnostic_tag_underline = get_buffer()->get_tag_table()->lookup("def:warning_underline"); if(style && (style->property_foreground_set() || style->property_background_set())) { Glib::ustring warning_property; if(style->property_foreground_set()) warning_property = style->property_foreground().get_value(); else if(style->property_background_set()) warning_property = style->property_background().get_value(); diagnostic_tag_underline->property_underline() = Pango::Underline::UNDERLINE_ERROR; auto tag_class = G_OBJECT_GET_CLASS(diagnostic_tag_underline->gobj()); //For older GTK+ 3 versions: auto param_spec = g_object_class_find_property(tag_class, "underline-rgba"); if(param_spec) diagnostic_tag_underline->set_property("underline-rgba", Gdk::RGBA(warning_property)); } style = scheme->get_style("def:error"); diagnostic_tag_underline = get_buffer()->get_tag_table()->lookup("def:error_underline"); if(style && (style->property_foreground_set() || style->property_background_set())) { Glib::ustring error_property; if(style->property_foreground_set()) error_property = style->property_foreground().get_value(); else if(style->property_background_set()) error_property = style->property_background().get_value(); diagnostic_tag_underline->property_underline() = Pango::Underline::UNDERLINE_ERROR; diagnostic_tag_underline->set_property("underline-rgba", Gdk::RGBA(error_property)); } //TODO: clear tag_class and param_spec? style = scheme->get_style("selection"); if(style && style->property_foreground_set()) extra_cursor_selection->property_foreground() = style->property_foreground().get_value(); else extra_cursor_selection->property_foreground_rgba() = get_style_context()->get_color(Gtk::StateFlags::STATE_FLAG_SELECTED); if(style && style->property_background_set()) extra_cursor_selection->property_background() = style->property_background().get_value(); else extra_cursor_selection->property_background_rgba() = get_style_context()->get_background_color(Gtk::StateFlags::STATE_FLAG_SELECTED); if(Config::get().menu.keys["source_show_completion"].empty()) { get_completion()->unblock_interactive(); interactive_completion = true; } else { get_completion()->block_interactive(); interactive_completion = false; } } void Source::View::setup_signals() { get_buffer()->signal_changed().connect([this]() { if(update_status_location) update_status_location(this); hide_tooltips(); if(similar_symbol_tag_applied) { get_buffer()->remove_tag(similar_symbol_tag, get_buffer()->begin(), get_buffer()->end()); similar_symbol_tag_applied = false; } if(clickable_tag_applied) { get_buffer()->remove_tag(clickable_tag, get_buffer()->begin(), get_buffer()->end()); clickable_tag_applied = false; } previous_extended_selections.clear(); }); // Line numbers line_renderer = Gtk::manage(new Gsv::GutterRendererText()); auto gutter = get_gutter(Gtk::TextWindowType::TEXT_WINDOW_LEFT); line_renderer->set_alignment_mode(Gsv::GutterRendererAlignmentMode::GUTTER_RENDERER_ALIGNMENT_MODE_FIRST); line_renderer->set_alignment(1.0, -1); line_renderer->set_padding(3, -1); gutter->insert(line_renderer, GTK_SOURCE_VIEW_GUTTER_POSITION_LINES); auto set_line_renderer_width = [this] { int width, height; line_renderer->measure(std::to_string(get_buffer()->get_line_count()), width, height); line_renderer->set_size(width); }; set_line_renderer_width(); get_buffer()->signal_changed().connect([set_line_renderer_width] { set_line_renderer_width(); }); signal_style_updated().connect([set_line_renderer_width] { set_line_renderer_width(); }); line_renderer->signal_query_data().connect([this](const Gtk::TextIter &start, const Gtk::TextIter &end, Gsv::GutterRendererState state) { if(!start.begins_tag(hide_tag) && !start.has_tag(hide_tag)) { if(start.get_line() == get_buffer()->get_insert()->get_iter().get_line()) line_renderer->set_text(Gsv::Markup("<b>" + std::to_string(start.get_line() + 1) + "</b>")); else line_renderer->set_text(Gsv::Markup(std::to_string(start.get_line() + 1))); } }); line_renderer->signal_query_activatable().connect([](const Gtk::TextIter &, const Gdk::Rectangle &, GdkEvent *) { return true; }); line_renderer->signal_activate().connect([this](const Gtk::TextIter &iter, const Gdk::Rectangle &, GdkEvent *) { if(toggle_breakpoint) toggle_breakpoint(iter.get_line()); }); type_tooltips.on_motion = [this] { delayed_tooltips_connection.disconnect(); }; diagnostic_tooltips.on_motion = [this] { delayed_tooltips_connection.disconnect(); }; signal_motion_notify_event().connect([this](GdkEventMotion *event) { if(on_motion_last_x != event->x || on_motion_last_y != event->y) { delayed_tooltips_connection.disconnect(); if((event->state & GDK_BUTTON1_MASK) == 0) { delayed_tooltips_connection = Glib::signal_timeout().connect( [this, x = event->x, y = event->y]() { type_tooltips.hide(); diagnostic_tooltips.hide(); Tooltips::init(); Gdk::Rectangle rectangle(x, y, 1, 1); if(parsed) { show_type_tooltips(rectangle); show_diagnostic_tooltips(rectangle); } return false; }, 100); } if(clickable_tag_applied) { get_buffer()->remove_tag(clickable_tag, get_buffer()->begin(), get_buffer()->end()); clickable_tag_applied = false; } if((event->state & primary_modifier_mask) && !(event->state & GDK_SHIFT_MASK) && !(event->state & GDK_BUTTON1_MASK)) { delayed_tag_clickable_connection.disconnect(); delayed_tag_clickable_connection = Glib::signal_timeout().connect( [this, x = event->x, y = event->y]() { int buffer_x, buffer_y; window_to_buffer_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, x, y, buffer_x, buffer_y); Gtk::TextIter iter; get_iter_at_location(iter, buffer_x, buffer_y); apply_clickable_tag(iter); clickable_tag_applied = true; return false; }, 100); } auto last_mouse_pos = std::make_pair<int, int>(on_motion_last_x, on_motion_last_y); auto mouse_pos = std::make_pair<int, int>(event->x, event->y); type_tooltips.hide(last_mouse_pos, mouse_pos); diagnostic_tooltips.hide(last_mouse_pos, mouse_pos); } on_motion_last_x = event->x; on_motion_last_y = event->y; return false; }); get_buffer()->signal_mark_set().connect([this](const Gtk::TextIter &iterator, const Glib::RefPtr<Gtk::TextBuffer::Mark> &mark) { auto mark_name = mark->get_name(); if(mark_name == "selection_bound") { if(get_buffer()->get_has_selection()) delayed_tooltips_connection.disconnect(); if(update_status_location) update_status_location(this); if(!keep_previous_extended_selections) previous_extended_selections.clear(); } else if(mark_name == "insert") { hide_tooltips(); delayed_tooltips_connection.disconnect(); delayed_tooltips_connection = Glib::signal_timeout().connect( [this]() { Tooltips::init(); Gdk::Rectangle rectangle; get_iter_location(get_buffer()->get_insert()->get_iter(), rectangle); int location_window_x, location_window_y; buffer_to_window_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, rectangle.get_x(), rectangle.get_y(), location_window_x, location_window_y); rectangle.set_x(location_window_x - 2); rectangle.set_y(location_window_y); rectangle.set_width(5); if(parsed) { show_type_tooltips(rectangle); show_diagnostic_tooltips(rectangle); } return false; }, 500); delayed_tag_similar_symbols_connection.disconnect(); delayed_tag_similar_symbols_connection = Glib::signal_timeout().connect( [this] { apply_similar_symbol_tag(); similar_symbol_tag_applied = true; return false; }, 100); if(SelectionDialog::get()) SelectionDialog::get()->hide(); if(CompletionDialog::get()) CompletionDialog::get()->hide(); if(update_status_location) update_status_location(this); if(!keep_previous_extended_selections) previous_extended_selections.clear(); } }); signal_key_release_event().connect([this](GdkEventKey *event) { if((event->state & primary_modifier_mask) && clickable_tag_applied) { get_buffer()->remove_tag(clickable_tag, get_buffer()->begin(), get_buffer()->end()); clickable_tag_applied = false; } return false; }); signal_scroll_event().connect([this](GdkEventScroll *event) { hide_tooltips(); hide_dialogs(); return false; }); signal_focus_out_event().connect([this](GdkEventFocus *event) { hide_tooltips(); if(clickable_tag_applied) { get_buffer()->remove_tag(clickable_tag, get_buffer()->begin(), get_buffer()->end()); clickable_tag_applied = false; } return false; }); signal_leave_notify_event().connect([this](GdkEventCrossing *) { delayed_tooltips_connection.disconnect(); return false; }); } void Source::View::setup_format_style(bool is_generic_view) { static auto prettier = filesystem::find_executable("prettier"); auto prefer_prettier = is_language({"js", "json", "css", "html", "markdown", "yaml"}); if(prettier.empty() && prefer_prettier && !filesystem::file_in_path(file_path, Config::get().home_juci_path)) { static bool shown = false; if(!shown) { Terminal::get().print("\e[33mWarning\e[m: could not find Prettier code formatter.\n"); Terminal::get().print("To install Prettier, run the following command in a terminal: "); #if defined(__APPLE__) Terminal::get().print("brew install prettier"); #elif defined(__linux) if(!filesystem::find_executable("pacman").empty()) Terminal::get().print("sudo pacman -S prettier"); else Terminal::get().print("npm i -g prettier"); #else Terminal::get().print("npm i -g prettier"); #endif Terminal::get().print("\n"); } shown = true; } if(!prettier.empty() && prefer_prettier) { if(is_generic_view) { goto_next_diagnostic = [this] { place_cursor_at_next_diagnostic(); }; get_buffer()->signal_changed().connect([this] { clear_diagnostic_tooltips(); status_diagnostics = std::make_tuple<size_t, size_t, size_t>(0, 0, 0); if(update_status_diagnostics) update_status_diagnostics(this); }); } format_style = [this, is_generic_view](bool continue_without_style_file, bool ignore_selection) { if(!continue_without_style_file) { auto search_path = file_path.parent_path(); while(true) { static std::vector<boost::filesystem::path> files = {".prettierrc", ".prettierrc.yaml", ".prettierrc.yml", ".prettierrc.json", ".prettierrc.toml", ".prettierrc.js", "prettier.config.js"}; boost::system::error_code ec; bool found = false; for(auto &file : files) { if(boost::filesystem::exists(search_path / file, ec)) { found = true; break; } } if(found) break; auto package_json = search_path / "package.json"; if(boost::filesystem::exists(package_json, ec)) { try { if(JSON(package_json).child_optional("prettier")) break; } catch(...) { } } if(search_path == search_path.root_directory()) return; search_path = search_path.parent_path(); } } size_t num_warnings = 0, num_errors = 0, num_fix_its = 0; if(is_generic_view) clear_diagnostic_tooltips(); static auto get_prettier_library = [] { std::string library; TinyProcessLib::Process process( "npm root -g", "", [&library](const char *buffer, size_t length) { library += std::string(buffer, length); }, [](const char *, size_t) {}); if(process.get_exit_status() == 0) { while(!library.empty() && (library.back() == '\n' || library.back() == '\r')) library.pop_back(); library += "/prettier"; boost::system::error_code ec; if(boost::filesystem::is_directory(library, ec)) return library; else { auto parent_path = prettier.parent_path(); if(parent_path.filename() == "bin") { auto path = parent_path.parent_path() / "lib" / "prettier"; if(boost::filesystem::is_directory(path, ec)) return path.string(); } // Try find prettier library installed with homebrew on MacOS boost::filesystem::path path = "/usr/local/opt/prettier/libexec/lib/node_modules/prettier"; if(boost::filesystem::is_directory(path, ec)) return path.string(); path = "/opt/homebrew/opt/prettier/libexec/lib/node_modules/prettier"; if(boost::filesystem::is_directory(path, ec)) return path.string(); } } return std::string(); }; static auto prettier_library = get_prettier_library(); if(!prettier_library.empty()) { struct Error { std::string message; int line = -1, index = -1; }; struct Result { std::string text; int cursor_offset; }; static Mutex mutex; static boost::optional<Result> result GUARDED_BY(mutex); static boost::optional<Error> error GUARDED_BY(mutex); { LockGuard lock(mutex); result = {}; error = {}; } static std::stringstream stdout_buffer; static int curly_count = 0; static bool key_or_value = false; if(prettier_background_process) { int exit_status; if(prettier_background_process->try_get_exit_status(exit_status)) prettier_background_process = {}; } if(!prettier_background_process) { stdout_buffer = std::stringstream(); curly_count = 0; key_or_value = false; prettier_background_process = std::make_unique<TinyProcessLib::Process>( "node -e \"const repl = require('repl');repl.start({prompt: '', ignoreUndefined: true, preview: false});\"", "", [](const char *bytes, size_t n) { for(size_t i = 0; i < n; ++i) { if(!key_or_value) { if(bytes[i] == '{') ++curly_count; else if(bytes[i] == '}') --curly_count; else if(bytes[i] == '"') key_or_value = true; } else { if(bytes[i] == '\\') ++i; else if(bytes[i] == '"') key_or_value = false; } } stdout_buffer.write(bytes, n); if(curly_count == 0) { try { JSON json(stdout_buffer); LockGuard lock(mutex); result = Result{json.string("formatted"), static_cast<int>(json.integer_or("cursorOffset", -1))}; } catch(const std::exception &e) { LockGuard lock(mutex); error = Error{std::string(e.what()) + "\nOutput from prettier: " + stdout_buffer.str()}; } stdout_buffer = std::stringstream(); key_or_value = false; } }, [](const char *bytes, size_t n) { size_t i = 0; for(; i < n; ++i) { if(bytes[i] == '\n') break; } std::string first_line(bytes, i); std::string message; int line = -1, line_index = -1; if(starts_with(first_line, "ConfigError: ")) message = std::string(bytes + 13, n - 13); else if(starts_with(first_line, "ParseError: ")) { const static std::regex regex(R"(^(.*) \(([0-9]*):([0-9]*)\)$)", std::regex::optimize); std::smatch sm; first_line.erase(0, 12); if(std::regex_match(first_line, sm, regex)) { message = sm[1].str(); try { line = std::stoi(sm[2].str()); line_index = std::stoi(sm[3].str()); } catch(...) { line = -1; line_index = -1; } } else message = std::string(bytes + 12, n - 12); } else message = std::string(bytes, n); LockGuard lock(mutex); error = Error{std::move(message), line, line_index}; }, true, TinyProcessLib::Config{1048576}); prettier_background_process->write("const prettier = require(\"" + escape(prettier_library, {'"'}) + "\");\n"); } std::string options = "filepath: \"" + escape(file_path.string(), {'"'}) + "\""; if(!ignore_selection && get_buffer()->get_has_selection()) { // Cannot be used together with cursorOffset Gtk::TextIter start, end; get_buffer()->get_selection_bounds(start, end); options += ", rangeStart: " + std::to_string(start.get_offset()) + ", rangeEnd: " + std::to_string(end.get_offset()); } else options += ", cursorOffset: " + std::to_string(get_buffer()->get_insert()->get_iter().get_offset()); prettier_background_process->write("{prettier.clearConfigCache();let _ = prettier.resolveConfig(\"" + escape(file_path.string(), {'"'}) + "\").then(options => {try{let _ = process.stdout.write(JSON.stringify(prettier.formatWithCursor(Buffer.from('"); prettier_background_process->write(to_hex_string(get_buffer()->get_text().raw())); prettier_background_process->write("', 'hex').toString(), {...options, " + options + "})));}catch(error){let _ = process.stderr.write('ParseError: ' + error.message);}}).catch(error => {let _ = process.stderr.write('ConfigError: ' + error.message);});}\n"); int exit_status = -1; while(true) { std::this_thread::sleep_for(std::chrono::milliseconds(10)); if(prettier_background_process->try_get_exit_status(exit_status)) break; LockGuard lock(mutex); if(result || error) break; } { LockGuard lock(mutex); if(result) { replace_text(result->text); if(result->cursor_offset >= 0 && result->cursor_offset < get_buffer()->size()) { get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(result->cursor_offset)); hide_tooltips(); } } else if(error) { if(error->line != -1 && error->index != -1) { if(is_generic_view) { auto start = get_iter_at_line_offset(error->line - 1, error->index - 1); ++num_errors; while(start.ends_line() && start.backward_char()) { } auto end = start; end.forward_char(); if(start == end) start.backward_char(); add_diagnostic_tooltip(start, end, true, [error_message = std::move(error->message)](Tooltip &tooltip) { tooltip.insert_with_links_tagged(error_message); }); } } else Terminal::get().print("\e[31mError (prettier)\e[m: " + error->message + '\n', true); } else if(exit_status >= 0) Terminal::get().print("\e[31mError (prettier)\e[m: process exited with exit status " + std::to_string(exit_status) + '\n', true); } } else { auto command = prettier.string(); command += " --stdin-filepath " + filesystem::escape_argument(this->file_path.string()); if(!ignore_selection && get_buffer()->get_has_selection()) { // Cannot be used together with --cursor-offset Gtk::TextIter start, end; get_buffer()->get_selection_bounds(start, end); command += " --range-start " + std::to_string(start.get_offset()); command += " --range-end " + std::to_string(end.get_offset()); } else command += " --cursor-offset " + std::to_string(get_buffer()->get_insert()->get_iter().get_offset()); std::stringstream stdin_stream(get_buffer()->get_text().raw()), stdout_stream, stderr_stream; auto exit_status = Terminal::get().process(stdin_stream, stdout_stream, command, this->file_path.parent_path(), &stderr_stream); if(exit_status == 0) { replace_text(stdout_stream.str()); std::string line; std::getline(stderr_stream, line); if(!line.empty() && line != "NaN") { try { auto offset = std::stoi(line); if(offset < get_buffer()->size()) { get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(offset)); hide_tooltips(); } } catch(...) { } } } else { const static std::regex regex(R"(^\[.*error.*\] [^:]*: (.*) \(([0-9]*):([0-9]*)\)$)", std::regex::optimize); std::string line; std::getline(stderr_stream, line); std::smatch sm; if(std::regex_match(line, sm, regex)) { if(is_generic_view) { try { auto start = get_iter_at_line_offset(std::stoi(sm[2].str()) - 1, std::stoi(sm[3].str()) - 1); ++num_errors; while(start.ends_line() && start.backward_char()) { } auto end = start; end.forward_char(); if(start == end) start.backward_char(); add_diagnostic_tooltip(start, end, true, [error_message = sm[1].str()](Tooltip &tooltip) { tooltip.insert_with_links_tagged(error_message); }); } catch(...) { } } } else Terminal::get().print("\e[31mError (prettier)\e[m: " + stderr_stream.str(), true); } } if(is_generic_view) { status_diagnostics = std::make_tuple(num_warnings, num_errors, num_fix_its); if(update_status_diagnostics) update_status_diagnostics(this); } }; } else if(is_bracket_language) { format_style = [this](bool continue_without_style_file, bool ignore_selection) { static auto clang_format_command = filesystem::get_executable("clang-format").string(); auto command = clang_format_command + " -output-replacements-xml -assume-filename=" + filesystem::escape_argument(this->file_path.string()); if(!ignore_selection && get_buffer()->get_has_selection()) { Gtk::TextIter start, end; get_buffer()->get_selection_bounds(start, end); command += " -lines=" + std::to_string(start.get_line() + 1) + ':' + std::to_string(end.get_line() + 1); } bool use_style_file = false; auto style_file_search_path = this->file_path.parent_path(); boost::system::error_code ec; while(true) { if(boost::filesystem::exists(style_file_search_path / ".clang-format", ec) || boost::filesystem::exists(style_file_search_path / "_clang-format", ec)) { use_style_file = true; break; } if(style_file_search_path == style_file_search_path.root_directory()) break; style_file_search_path = style_file_search_path.parent_path(); } if(use_style_file) command += " -style=file"; else { if(!continue_without_style_file) return; unsigned indent_width; std::string tab_style; if(tab_char == '\t') { indent_width = tab_size * 8; tab_style = "UseTab: Always"; } else { indent_width = tab_size; tab_style = "UseTab: Never"; } command += " -style=\"{IndentWidth: " + std::to_string(indent_width); command += ", " + tab_style; command += ", " + std::string("AccessModifierOffset: -") + std::to_string(indent_width); if(Config::get().source.clang_format_style != "") command += ", " + Config::get().source.clang_format_style; command += "}\""; } std::stringstream stdin_stream(get_buffer()->get_text()), stdout_stream; auto exit_status = Terminal::get().process(stdin_stream, stdout_stream, command, this->file_path.parent_path()); if(exit_status == 0) { // The following code is complex due to clang-format returning offsets in byte offsets instead of char offsets // Create bytes_in_lines cache to significantly speed up the processing of finding iterators from byte offsets std::vector<size_t> bytes_in_lines; auto line_count = get_buffer()->get_line_count(); for(int line_nr = 0; line_nr < line_count; ++line_nr) { auto iter = get_buffer()->get_iter_at_line(line_nr); bytes_in_lines.emplace_back(iter.get_bytes_in_line()); } get_buffer()->begin_user_action(); try { boost::property_tree::ptree pt; boost::property_tree::xml_parser::read_xml(stdout_stream, pt); auto replacements_pt = pt.get_child("replacements", boost::property_tree::ptree()); for(auto it = replacements_pt.rbegin(); it != replacements_pt.rend(); ++it) { if(it->first == "replacement") { auto offset = it->second.get<size_t>("<xmlattr>.offset"); auto length = it->second.get<size_t>("<xmlattr>.length"); auto replacement_str = it->second.get<std::string>(""); size_t bytes = 0; for(size_t c = 0; c < bytes_in_lines.size(); ++c) { auto previous_bytes = bytes; bytes += bytes_in_lines[c]; if(offset < bytes || (c == bytes_in_lines.size() - 1 && offset == bytes)) { std::pair<size_t, size_t> line_index(c, offset - previous_bytes); auto start = get_buffer()->get_iter_at_line_index(line_index.first, line_index.second); // Use left gravity insert to avoid moving cursor from end of line bool left_gravity_insert = false; if(get_buffer()->get_insert()->get_iter() == start) { auto iter = start; do { if(*iter != ' ' && *iter != '\t') { left_gravity_insert = iter.ends_line(); break; } } while(iter.forward_char()); } if(length > 0) { auto offset_end = offset + length; size_t bytes = 0; for(size_t c = 0; c < bytes_in_lines.size(); ++c) { auto previous_bytes = bytes; bytes += bytes_in_lines[c]; if(offset_end < bytes || (c == bytes_in_lines.size() - 1 && offset_end == bytes)) { auto end = get_buffer()->get_iter_at_line_index(c, offset_end - previous_bytes); get_buffer()->erase(start, end); start = get_buffer()->get_iter_at_line_index(line_index.first, line_index.second); break; } } } if(left_gravity_insert) { Mark mark(start); get_buffer()->insert(start, replacement_str); get_buffer()->place_cursor(mark->get_iter()); } else get_buffer()->insert(start, replacement_str); break; } } } } } catch(const std::exception &e) { Terminal::get().print(std::string("\e[31mError\e[m: error parsing clang-format output: ") + e.what() + '\n', true); } get_buffer()->end_user_action(); } }; } else if(language_id == "python") { static auto yapf = filesystem::find_executable("yapf"); if(!yapf.empty()) { format_style = [this](bool continue_without_style_file, bool ignore_selection) { std::string command = "yapf"; if(!ignore_selection && get_buffer()->get_has_selection()) { Gtk::TextIter start, end; get_buffer()->get_selection_bounds(start, end); command += " -l " + std::to_string(start.get_line() + 1) + '-' + std::to_string(end.get_line() + 1); } if(!continue_without_style_file) { auto search_path = file_path.parent_path(); while(true) { boost::system::error_code ec; if(boost::filesystem::exists(search_path / ".python-format", ec) || boost::filesystem::exists(search_path / ".style.yapf", ec)) break; if(search_path == search_path.root_directory()) return; search_path = search_path.parent_path(); } } std::stringstream stdin_stream(get_buffer()->get_text()), stdout_stream; auto exit_status = Terminal::get().process(stdin_stream, stdout_stream, command, this->file_path.parent_path()); if(exit_status == 0) replace_text(stdout_stream.str()); }; } } } Source::View::~View() { delayed_tooltips_connection.disconnect(); delayed_tag_similar_symbols_connection.disconnect(); delayed_tag_clickable_connection.disconnect(); non_deleted_views.erase(this); views.erase(this); } void Source::View::hide_tooltips() { delayed_tooltips_connection.disconnect(); type_tooltips.hide(); diagnostic_tooltips.hide(); } void Source::View::hide_dialogs() { SpellCheckView::hide_dialogs(); if(SelectionDialog::get()) SelectionDialog::get()->hide(); if(CompletionDialog::get()) CompletionDialog::get()->hide(); } void Source::View::scroll_to_cursor_delayed(bool center, bool show_tooltips) { if(!show_tooltips) hide_tooltips(); Glib::signal_idle().connect([this, center] { if(views.find(this) != views.end()) { if(center) scroll_to(get_buffer()->get_insert(), 0.0, 1.0, 0.5); else scroll_to(get_buffer()->get_insert()); } return false; }); } void Source::View::extend_selection() { // Have tried to generalize this function as much as possible due to the complexity of this task, // but some further workarounds for edge cases might be needed // It is impossible to identify <> used for templates by syntax alone, but // this function works in most cases. auto is_template_arguments = [this](Gtk::TextIter start, Gtk::TextIter end) { if(*start != '<' || *end != '>' || start.get_line() != end.get_line()) return false; auto prev = start; if(!prev.backward_char()) return false; if(!is_token_char(*prev)) return false; auto next = end; next.forward_char(); if(*next != '(' && *next != ' ') return false; return true; }; // Extends expression from 'here' in for instance: test->here(...), test.test(here) or here.test(test) auto extend_expression = [&](Gtk::TextIter &start, Gtk::TextIter &end) { auto start_stored = start; auto end_stored = end; bool extend_token_forward = true, extend_token_backward = true; auto iter = start; auto prev = iter; if(prev.backward_char() && ((*prev == '(' && *end == ')') || (*prev == '[' && *end == ']') || (*prev == '<' && *end == '>') || (*prev == '{' && *end == '}'))) { if(*prev == '<' && !is_template_arguments(prev, end)) return false; iter = start = prev; end.forward_char(); extend_token_forward = false; } else if(is_token_char(*iter)) { auto token = get_token_iters(iter); if(start != token.first || end != token.second) return false; extend_token_forward = false; extend_token_backward = false; } else return false; // Extend expression forward passed for instance member function { auto iter = end; bool extend_token = extend_token_forward; while(forward_to_code(iter)) { if(extend_token && is_token_char(*iter)) { auto token = get_token_iters(iter); iter = end = token.second; extend_token = false; continue; } if(!extend_token && *iter == '(' && iter.forward_char() && find_close_symbol_forward(iter, iter, '(', ')')) { iter.forward_char(); end = iter; extend_token = false; continue; } if(!extend_token && *iter == '[' && iter.forward_char() && find_close_symbol_forward(iter, iter, '[', ']')) { iter.forward_char(); end = iter; extend_token = false; continue; } auto prev = iter; if(!extend_token && *iter == '<' && iter.forward_char() && find_close_symbol_forward(iter, iter, '<', '>') && is_template_arguments(prev, iter)) { // Only extend for instance std::max<int>(1, 2) iter.forward_char(); end = iter; extend_token = false; continue; } if(!extend_token && *iter == '.') { iter.forward_char(); extend_token = true; continue; } auto next = iter; if(!extend_token && next.forward_char() && ((*iter == ':' && *next == ':') || (*iter == '-' && *next == '>'))) { iter = next; iter.forward_char(); extend_token = true; continue; } break; } // Extend through {} auto prev = iter = end; prev.backward_char(); if(*prev != '}' && forward_to_code(iter) && *iter == '{' && iter.forward_char() && find_close_symbol_forward(iter, iter, '{', '}')) { iter.forward_char(); end = iter; } } // Extend backward iter = start; bool extend_token = extend_token_backward; while(true) { if(!iter.backward_char() || !backward_to_code(iter)) break; if(extend_token && is_token_char(*iter)) { auto token = get_token_iters(iter); start = iter = token.first; extend_token = false; continue; } if(extend_token && *iter == ')' && iter.backward_char() && find_open_symbol_backward(iter, iter, '(', ')')) { start = iter; extend_token = true; continue; } if(extend_token && *iter == ']' && iter.backward_char() && find_open_symbol_backward(iter, iter, '[', ']')) { start = iter; extend_token = true; continue; } auto angle_end = iter; if(extend_token && *iter == '>' && iter.backward_char() && find_open_symbol_backward(iter, iter, '<', '>') && is_template_arguments(iter, angle_end)) { // Only extend for instance std::max<int>(1, 2) start = iter; continue; } if(*iter == '.') { extend_token = true; continue; } if(angle_end.backward_char() && ((*angle_end == ':' && *iter == ':') || (*angle_end == '-' && *iter == '>'))) { iter = angle_end; extend_token = true; continue; } break; } if(start != start_stored || end != end_stored) return true; return false; }; Gtk::TextIter start, end; get_buffer()->get_selection_bounds(start, end); // If entire buffer is selected, do nothing if(start == get_buffer()->begin() && end == get_buffer()->end()) return; auto start_stored = start; auto end_stored = end; previous_extended_selections.emplace_back(start, end); keep_previous_extended_selections = true; ScopeGuard guard{[this] { keep_previous_extended_selections = false; }}; // Select token if(!get_buffer()->get_has_selection()) { auto iter = get_buffer()->get_insert()->get_iter(); if(is_token_char(*iter)) { auto token = get_token_iters(iter); get_buffer()->select_range(token.first, token.second); return; } } else { // Complete token selection Gtk::TextIter start, end; get_buffer()->get_selection_bounds(start, end); auto start_token = get_token_iters(start); auto end_token = get_token_iters(end); if(start_token.first < start || end_token.second > end) { get_buffer()->select_range(start_token.first, end_token.second); return; } } // Select string or comment block auto before_start = start; if(!is_code_iter(start) && !(before_start.backward_char() && is_code_iter(before_start) && is_code_iter(end))) { bool no_code_iter = true; for(auto iter = start; iter.forward_char() && iter < end;) { if(is_code_iter(iter)) { no_code_iter = false; break; } } if(no_code_iter) { if(backward_to_code(start)) { while(start.forward_char() && (*start == ' ' || *start == '\t' || start.ends_line())) { } } if(forward_to_code(end)) { while(end.backward_char() && (*end == ' ' || *end == '\t' || end.ends_line())) { } end.forward_char(); } if(start != start_stored || end != end_stored) { get_buffer()->select_range(start, end); return; } start = start_stored; end = end_stored; } } // Select expression from token if(get_buffer()->get_has_selection() && is_token_char(*start) && start.get_line() == end.get_line() && extend_expression(start, end)) { get_buffer()->select_range(start, end); return; } before_start = start; auto before_end = end; bool ignore_comma = false; auto start_sentence_iter = get_buffer()->end(); auto end_sentence_iter = get_buffer()->end(); if(is_code_iter(start) && is_code_iter(end) && before_start.backward_char() && before_end.backward_char()) { if((*before_start == '(' && *end == ')') || (*before_start == '[' && *end == ']') || (*before_start == '<' && *end == '>') || (*before_start == '{' && *end == '}')) { // Select expression from selected brackets if(!(*before_start == '<' && *end == '>' && is_js) && extend_expression(start, end)) { get_buffer()->select_range(start, end); return; } start = before_start; end.forward_char(); } else if((*before_start == ',' && *end == ',') || (*before_start == ',' && *end == ')') || (*before_start == ',' && *end == ']') || (*before_start == ',' && *end == '>') || (*before_start == ',' && *end == '}') || (*before_start == '(' && *end == ',') || (*before_start == '[' && *end == ',') || (*before_start == '<' && *end == ',') || (*before_start == '{' && *end == ',')) ignore_comma = true; else if(start != end && (*before_end == ';' || *before_end == '}')) { auto iter = end; if(*before_end == '}' && forward_to_code(iter) && *iter == ';') end_sentence_iter = iter; else end_sentence_iter = before_end; } } int para_count = 0; int square_count = 0; int angle_count = 0; int curly_count = 0; auto start_comma_iter = get_buffer()->end(); auto start_angle_iter = get_buffer()->end(); auto start_angle_reversed_iter = get_buffer()->end(); while(start.backward_char()) { if(*start == '(' && is_code_iter(start)) para_count++; else if(*start == ')' && is_code_iter(start)) para_count--; else if(*start == '[' && is_code_iter(start)) square_count++; else if(*start == ']' && is_code_iter(start)) square_count--; else if(*start == '<' && is_code_iter(start)) { if(!start_angle_iter && para_count == 0 && square_count == 0 && angle_count == 0 && curly_count == 0) start_angle_iter = start; angle_count++; } else if(*start == '>' && is_code_iter(start)) { auto prev = start; if(!(prev.backward_char() && (*prev == '=' || *prev == '-'))) { if(!start_angle_reversed_iter && para_count == 0 && square_count == 0 && angle_count == 0 && curly_count == 0) start_angle_reversed_iter = start; angle_count--; } } else if(*start == '{' && is_code_iter(start)) { if(!start_sentence_iter && para_count == 0 && square_count == 0 && curly_count == 0) { start_sentence_iter = start; } curly_count++; } else if(*start == '}' && is_code_iter(start)) { if(!start_sentence_iter && para_count == 0 && square_count == 0 && curly_count == 0) { auto next = start; if(next.forward_char() && forward_to_code(next) && *next != ';') start_sentence_iter = start; } curly_count--; } else if(!ignore_comma && !start_comma_iter && para_count == 0 && square_count == 0 && curly_count == 0 && *start == ',' && is_code_iter(start)) start_comma_iter = start; else if(!start_sentence_iter && para_count == 0 && square_count == 0 && curly_count == 0 && *start == ';' && is_code_iter(start)) start_sentence_iter = start; if(*start == ';' && is_code_iter(start)) { ignore_comma = true; start_comma_iter = get_buffer()->end(); } if(para_count > 0 || square_count > 0 || curly_count > 0) break; } para_count = 0; square_count = 0; angle_count = 0; curly_count = 0; auto end_comma_iter = get_buffer()->end(); auto end_angle_iter = get_buffer()->end(); auto end_angle_reversed_iter = get_buffer()->end(); do { if(*end == '(' && is_code_iter(end)) para_count++; else if(*end == ')' && is_code_iter(end)) para_count--; else if(*end == '[' && is_code_iter(end)) square_count++; else if(*end == ']' && is_code_iter(end)) square_count--; else if(*end == '<' && is_code_iter(end)) { if(!end_angle_reversed_iter && para_count == 0 && square_count == 0 && angle_count == 0 && curly_count == 0) end_angle_reversed_iter = end; angle_count++; } else if(*end == '>' && is_code_iter(end)) { auto prev = end; if(!(prev.backward_char() && (*prev == '=' || *prev == '-'))) { if(!end_angle_iter && para_count == 0 && square_count == 0 && angle_count == 0 && curly_count == 0) end_angle_iter = end; angle_count--; } } else if(*end == '{' && is_code_iter(end)) curly_count++; else if(*end == '}' && is_code_iter(end)) { curly_count--; if(!end_sentence_iter && para_count == 0 && square_count == 0 && curly_count == 0) { auto next = end_sentence_iter = end; if(next.forward_char() && forward_to_code(next) && *next == ';') end_sentence_iter = next; else if(is_js && *next == '>') end_sentence_iter = get_buffer()->end(); } } else if(!ignore_comma && !end_comma_iter && para_count == 0 && square_count == 0 && curly_count == 0 && *end == ',' && is_code_iter(end)) end_comma_iter = end; else if(!end_sentence_iter && para_count == 0 && square_count == 0 && curly_count == 0 && *end == ';' && is_code_iter(end)) end_sentence_iter = end; if(*end == ';' && is_code_iter(end)) { ignore_comma = true; start_comma_iter = get_buffer()->end(); end_comma_iter = get_buffer()->end(); } if(para_count < 0 || square_count < 0 || curly_count < 0) break; } while(end.forward_char()); // Extend HTML/JSX if(is_js) { static std::vector<std::string> void_elements = {"area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"}; auto get_element = [this](Gtk::TextIter iter) { auto start = iter; auto end = iter; while(iter.backward_char() && (is_token_char(*iter) || *iter == '.')) start = iter; while((is_token_char(*end) || *end == '.') && end.forward_char()) { } return get_buffer()->get_text(start, end); }; Gtk::TextIter start_backward_search = get_buffer()->end(), start_forward_search = get_buffer()->end(); auto start_stored_prev = start_stored; if(start_angle_iter && end_angle_iter) { // If inside angle brackets in for instance <selection here> auto next = start_angle_iter; next.forward_char(); auto prev = end_angle_iter; prev.backward_char(); auto element = get_element(next); if(*next == '/') { start_backward_search = start_forward_search = start_angle_iter; start_backward_search.backward_char(); } else if(*prev == '/' || std::any_of(void_elements.begin(), void_elements.end(), [&element](const std::string &e) { return e == element; })) { end_angle_iter.forward_char(); get_buffer()->select_range(start_angle_iter, end_angle_iter); return; } else { start_backward_search = start_forward_search = end_angle_iter; start_forward_search.forward_char(); } } else if(start_stored_prev.backward_char() && *start_stored_prev == '<' && *end_stored == '>') { // Matches for instance <div>, where div is selected auto element = get_element(start_stored); if(std::any_of(void_elements.begin(), void_elements.end(), [&element](const std::string &e) { return e == element; })) { auto next = end_stored; next.forward_char(); get_buffer()->select_range(start_stored_prev, next); return; } start_backward_search = start_forward_search = end_stored; start_forward_search.forward_char(); } else if(start_angle_reversed_iter && end_angle_reversed_iter) { // If not inside angle brackets, for instance <>selection here</> start_backward_search = start_angle_reversed_iter; start_forward_search = end_angle_reversed_iter; } if(start_backward_search && start_forward_search) { Gtk::TextIter start_children, end_children; auto iter = start_backward_search; int depth = 0; // Search backward for opening element while(find_open_symbol_backward(iter, iter, '>', '<') && iter.backward_char()) { // Backward to > (end of opening element) start_children = iter; start_children.forward_chars(2); auto prev = iter; prev.backward_char(); bool no_child_element = *iter == '/' && *prev != '<'; // Excludes </> as it is always closing element of <> if(find_open_symbol_backward(iter, iter, '<', '>')) { // Backward to < if(!no_child_element) { iter.forward_char(); if(*iter == '/') { if(!iter.backward_chars(2)) break; --depth; continue; } auto element = get_element(iter); if(std::any_of(void_elements.begin(), void_elements.end(), [&element](const std::string &e) { return e == element; })) { if(!iter.backward_chars(2)) break; continue; } else if(depth == 0) { iter.backward_char(); auto start_selection = iter; iter = start_forward_search; // Search forward for closing element int depth = 0; while(find_close_symbol_forward(iter, iter, '>', '<') && iter.forward_char()) { // Forward to < (start of closing element) end_children = iter; end_children.backward_char(); if(*iter == '/') { if(iter.forward_char() && find_close_symbol_forward(iter, iter, '<', '>') && iter.forward_char()) { // Forward to > if(depth == 0) { if(start_children <= start_stored && end_children >= end_stored && (start_children != start_stored || end_children != end_stored)) // Select children get_buffer()->select_range(start_children, end_children); else get_buffer()->select_range(start_selection, iter); return; } else --depth; } else break; } else { auto element = get_element(iter); if(std::any_of(void_elements.begin(), void_elements.end(), [&element](const std::string &e) { return e == element; })) { if(!(find_close_symbol_forward(iter, iter, '<', '>') && iter.forward_char())) // Forward to > break; } else if(find_close_symbol_forward(iter, iter, '<', '>') && iter.backward_char()) { // Forward to > if(*iter == '/') iter.forward_chars(2); else { ++depth; iter.forward_chars(2); } } else break; } } break; } else if(!iter.backward_chars(2)) break; ++depth; } else if(!iter.backward_char()) break; } else break; } } } // Test for <> used for template arguments if(start_angle_iter && end_angle_iter && is_template_arguments(start_angle_iter, end_angle_iter)) { start_angle_iter.forward_char(); get_buffer()->select_range(start_angle_iter, end_angle_iter); return; } // Test for matching brackets and try select regions within brackets separated by ',' bool comma_used = false; bool select_matching_brackets = false; if((*start == '(' && *end == ')') || (*start == '[' && *end == ']') || (*start == '<' && *end == '>') || (*start == '{' && *end == '}')) { if(start_comma_iter && start < start_comma_iter) { start = start_comma_iter; comma_used = true; } if(end_comma_iter && end > end_comma_iter) { end = end_comma_iter; comma_used = true; } select_matching_brackets = true; } // Attempt to select a sentence, for instance: int a = 2; if(!is_bracket_language) { // If for instance cmake, meson or python if(!select_matching_brackets) { bool select_end_block = is_language({"cmake", "meson", "julia", "xml"}); auto get_tabs = [this](Gtk::TextIter iter) -> boost::optional<int> { iter = get_buffer()->get_iter_at_line(iter.get_line()); int tabs = 0; while(!iter.ends_line() && (*iter == ' ' || *iter == '\t')) { tabs++; if(!iter.forward_char()) break; } if(iter.ends_line()) return {}; return tabs; }; start = start_stored; end = end_stored; // Select following line with code (for instance when inside comment) // Forward start to non-empty line forward_to_code(start); start = get_buffer()->get_iter_at_line(start.get_line()); while(!start.is_end() && (*start == ' ' || *start == '\t') && start.forward_char()) { } // Forward end of line if(start > end) end = start; end = get_iter_at_line_end(end.get_line()); while(end.backward_char() && (*end == ' ' || *end == '\t' || end.ends_line())) { } end.forward_char(); if(end == end_stored) // Cancel line selection if the line is already selected start = start_stored; if(start != start_stored || end != end_stored) { get_buffer()->select_range(start, end); return; } // Select current line // Backward to line start start = get_buffer()->get_iter_at_line(start.get_line()); auto start_tabs = get_tabs(start); while((*start == ' ' || *start == '\t' || start.ends_line()) && start.forward_char()) { } // Forward to line end end = get_iter_at_line_end(end.get_line()); bool include_children = false; if(start_tabs) { while(end.forward_char()) { auto tabs = get_tabs(end); if(tabs) { if(tabs > start_tabs) include_children = true; else if(tabs == start_tabs) { if(include_children && select_end_block) end = get_iter_at_line_end(end.get_line()); break; } else break; } end = get_iter_at_line_end(end.get_line()); } } // Backward end to non-empty line while(end.backward_char() && (*end == ' ' || *end == '\t' || end.ends_line())) { } end.forward_char(); if(start != start_stored || end != end_stored) { // Forward to closing symbol if open symbol is found between start and end auto iter = start; para_count = 0; square_count = 0; curly_count = 0; do { if(*iter == '(' && is_code_iter(iter)) para_count++; else if(*iter == ')' && is_code_iter(iter)) para_count--; else if(*iter == '[' && is_code_iter(iter)) square_count++; else if(*iter == ']' && is_code_iter(iter)) square_count--; else if(*iter == '{' && is_code_iter(iter)) curly_count++; else if(*iter == '}' && is_code_iter(iter)) curly_count--; if(para_count < 0 || square_count < 0 || curly_count < 0) break; } while(iter.forward_char() && iter < end); if(iter == end && (para_count > 0 || square_count > 0 || curly_count > 0)) { do { if(*iter == '(' && is_code_iter(iter)) para_count++; else if(*iter == ')' && is_code_iter(iter)) para_count--; else if(*iter == '[' && is_code_iter(iter)) square_count++; else if(*iter == ']' && is_code_iter(iter)) square_count--; else if(*iter == '{' && is_code_iter(iter)) curly_count++; else if(*iter == '}' && is_code_iter(iter)) curly_count--; if(para_count == 0 && square_count == 0 && curly_count == 0) break; } while(iter.forward_char()); if(iter) { end = iter; end.forward_char(); } } get_buffer()->select_range(start, end); return; } // Select block that cursor is within // Backward start block start if(start_tabs > 0) { start = get_buffer()->get_iter_at_line(start.get_line()); while(start.backward_char()) { auto tabs = get_tabs(start); if(tabs && tabs < start_tabs) break; start = get_buffer()->get_iter_at_line(start.get_line()); } while((*start == ' ' || *start == '\t' || start.ends_line()) && start.forward_char()) { } // Forward to block end end = get_iter_at_line_end(end.get_line()); while(end.forward_char()) { auto tabs = get_tabs(end); if(tabs && tabs < start_tabs) break; end = get_iter_at_line_end(end.get_line()); } // Backward end to non-empty line while(end.backward_char() && (*end == ' ' || *end == '\t' || end.ends_line())) { } end.forward_char(); if(start != start_stored || end != end_stored) { get_buffer()->select_range(start, end); return; } // Select expression surrounding block // Backward to expression starting block if(start.backward_char()) { backward_to_code(start); if(start_tabs > get_tabs(start)) { start = get_buffer()->get_iter_at_line(start.get_line()); while((*start == ' ' || *start == '\t' || start.ends_line()) && start.forward_char()) { } } else start = start_stored; } // Forward to expression ending block if(select_end_block) { forward_to_code(end); if(start_tabs > get_tabs(end)) { end = get_iter_at_line_end(end.get_line()); while(end.backward_char() && (*end == ' ' || *end == '\t' || end.ends_line())) { } end.forward_char(); } else end = end_stored; } if(start != start_stored || end != end_stored) { get_buffer()->select_range(start, end); return; } } // Select no_spellcheck_tag block if markdown if(language_id == "markdown" && no_spellcheck_tag && start.has_tag(no_spellcheck_tag) && end.has_tag(no_spellcheck_tag)) { if(!start.starts_tag(no_spellcheck_tag)) start.backward_to_tag_toggle(no_spellcheck_tag); if(!end.ends_tag(no_spellcheck_tag)) end.forward_to_tag_toggle(no_spellcheck_tag); auto prev = start; while(*start == '`' && start.forward_char()) { } if(start.get_offset() - prev.get_offset() > 1) { start.forward_to_line_end(); start.forward_char(); } while(end.backward_char() && *end == '`') { } if(!end.ends_line()) end.forward_char(); if(start != start_stored || end != end_stored) { get_buffer()->select_range(start, end); return; } } get_buffer()->select_range(get_buffer()->begin(), get_buffer()->end()); return; } } else if(!comma_used && end_sentence_iter && end > end_sentence_iter) { if(!start_sentence_iter) start_sentence_iter = start; else start_sentence_iter.forward_char(); // Forward to code iter (move passed macros) while(forward_to_code(start_sentence_iter) && *start_sentence_iter == '#' && start_sentence_iter.forward_to_line_end()) { auto prev = start_sentence_iter; if(prev.backward_char() && *prev == '\\' && start_sentence_iter.forward_char()) { while(start_sentence_iter.forward_to_line_end()) { prev = start_sentence_iter; if(prev.backward_char() && *prev == '\\' && start_sentence_iter.forward_char()) continue; break; } } } // Select sentence end_sentence_iter.forward_char(); if((start_sentence_iter != start_stored || end_sentence_iter != end_stored) && ((*start == '{' && *end == '}') || (start.is_start() && end.is_end()))) { get_buffer()->select_range(start_sentence_iter, end_sentence_iter); return; } } if(select_matching_brackets) start.forward_char(); if(start != start_stored || end != end_stored) { get_buffer()->select_range(start, end); return; } // In case of no change due to inbalanced brackets previous_extended_selections.pop_back(); if(!start.backward_char() && !end.forward_char()) return; get_buffer()->select_range(start, end); extend_selection(); } void Source::View::shrink_selection() { if(previous_extended_selections.empty()) { Info::get().print("No previous extended selections found"); return; } auto selection = previous_extended_selections.back(); keep_previous_extended_selections = true; get_buffer()->select_range(selection.first, selection.second); hide_tooltips(); keep_previous_extended_selections = false; previous_extended_selections.pop_back(); } void Source::View::show_or_hide() { Gtk::TextIter start, end; get_buffer()->get_selection_bounds(start, end); if(start == end && !(start.starts_line() && start.ends_line())) { // Select code block instead if no current selection start = get_buffer()->get_iter_at_line(start.get_line()); auto tabs_end = get_tabs_end_iter(start); auto start_tabs = tabs_end.get_line_offset() - start.get_line_offset(); if(!end.ends_line()) end.forward_to_line_end(); auto last_empty = get_buffer()->end(); auto last_tabs_end = get_buffer()->end(); while(true) { if(end.ends_line()) { auto line_start = get_buffer()->get_iter_at_line(end.get_line()); auto tabs_end = get_tabs_end_iter(line_start); if(end.starts_line() || tabs_end.ends_line()) { // Empty line if(!last_empty) last_empty = end; } else { auto tabs = tabs_end.get_line_offset() - line_start.get_line_offset(); if((is_c || is_cpp) && tabs == 0 && *line_start == '#') { // C/C++ defines can be at the first line if(end.get_line() == start.get_line()) // Do not try to find define blocks since these rarely are indented break; } else if(tabs < start_tabs) { end = get_buffer()->get_iter_at_line(end.get_line()); break; } else if(tabs == start_tabs) { // Check for block continuation keywords std::string text = get_buffer()->get_text(tabs_end, end); if(end.get_line() != start.get_line()) { if(text.empty()) { end = get_buffer()->get_iter_at_line(end.get_line()); break; } static std::vector<std::string> starts_with_symbols = {"}", ")", "]", ">", "</"}; static std::vector<std::string> exact_tokens = {"else", "end", "endif", "elseif", "elif", "catch", "case", "default", "private", "public", "protected"}; if(text == "{") { // C/C++ sometimes starts a block with a standalone { if(!is_token_char(*last_tabs_end)) { end = get_buffer()->get_iter_at_line(end.get_line()); break; } else { // Check for ; at the end of last line auto iter = tabs_end; while(iter.backward_char() && iter > last_tabs_end && (*iter == ' ' || *iter == '\t' || iter.ends_line() || !is_code_iter(iter))) { } if(*iter == ';') { end = get_buffer()->get_iter_at_line(end.get_line()); break; } } } else if(std::none_of(starts_with_symbols.begin(), starts_with_symbols.end(), [&text](const std::string &symbol) { return starts_with(text, symbol); }) && std::none_of(exact_tokens.begin(), exact_tokens.end(), [this, &text](const std::string &token) { return starts_with(text, token) && (text.size() <= token.size() || !is_token_char(text[token.size()])); })) { end = get_buffer()->get_iter_at_line(end.get_line()); break; } } last_tabs_end = tabs_end; } last_empty = get_buffer()->end(); } } if(end.is_end()) break; end.forward_char(); } if(last_empty) end = get_buffer()->get_iter_at_line(last_empty.get_line()); } if(start == end) end.forward_char(); // Select empty line if(!start.starts_line()) start = get_buffer()->get_iter_at_line(start.get_line()); if(!end.ends_line() && !end.starts_line()) end.forward_to_line_end(); if((start.begins_tag(hide_tag) || start.has_tag(hide_tag)) && (end.ends_tag(hide_tag) || end.has_tag(hide_tag))) { get_buffer()->remove_tag(hide_tag, start, end); return; } auto iter = start; if(iter.forward_to_tag_toggle(hide_tag) && iter < end) { get_buffer()->remove_tag(hide_tag, start, end); return; } get_buffer()->apply_tag(hide_tag, start, end); } void Source::View::add_diagnostic_tooltip(const Gtk::TextIter &start, const Gtk::TextIter &end, bool error, std::function<void(Tooltip &)> &&set_buffer) { diagnostic_offsets.emplace(start.get_offset()); std::string severity_tag_name = error ? "def:error" : "def:warning"; diagnostic_tooltips.emplace_back(this, start, end, [error, severity_tag_name, set_buffer = std::move(set_buffer)](Tooltip &tooltip) { tooltip.buffer->insert_with_tag(tooltip.buffer->get_insert()->get_iter(), error ? "Error" : "Warning", severity_tag_name); tooltip.buffer->insert(tooltip.buffer->get_insert()->get_iter(), ":\n"); set_buffer(tooltip); }); get_buffer()->apply_tag_by_name(severity_tag_name + "_underline", start, end); auto iter = get_buffer()->get_insert()->get_iter(); if(iter.ends_line()) { auto next_iter = iter; if(next_iter.forward_char()) get_buffer()->remove_tag_by_name(severity_tag_name + "_underline", iter, next_iter); } } void Source::View::clear_diagnostic_tooltips() { diagnostic_offsets.clear(); diagnostic_tooltips.clear(); get_buffer()->remove_tag_by_name("def:warning_underline", get_buffer()->begin(), get_buffer()->end()); get_buffer()->remove_tag_by_name("def:error_underline", get_buffer()->begin(), get_buffer()->end()); } void Source::View::place_cursor_at_next_diagnostic() { auto insert_offset = get_buffer()->get_insert()->get_iter().get_offset(); for(auto offset : diagnostic_offsets) { if(offset > insert_offset) { get_buffer()->place_cursor(get_buffer()->get_iter_at_offset(offset)); scroll_to(get_buffer()->get_insert(), 0.0, 1.0, 0.5); return; } } if(diagnostic_offsets.size() == 0) Info::get().print("No diagnostics found in current buffer"); else { auto iter = get_buffer()->get_iter_at_offset(*diagnostic_offsets.begin()); get_buffer()->place_cursor(iter); scroll_to(get_buffer()->get_insert(), 0.0, 1.0, 0.5); } } bool Source::View::backward_to_code(Gtk::TextIter &iter) { while((*iter == ' ' || *iter == '\t' || iter.ends_line() || !is_code_iter(iter)) && iter.backward_char()) { } return !iter.is_start() || is_code_iter(iter); } bool Source::View::forward_to_code(Gtk::TextIter &iter) { while((*iter == ' ' || *iter == '\t' || iter.ends_line() || !is_code_iter(iter)) && iter.forward_char()) { } return !iter.is_end(); } bool Source::View::backward_to_code_or_line_start(Gtk::TextIter &iter) { while(!iter.starts_line() && (*iter == ' ' || *iter == '\t' || iter.ends_line() || !is_code_iter(iter)) && iter.backward_char()) { } return !iter.is_start() || is_code_iter(iter); } bool Source::View::forward_to_code_or_line_end(Gtk::TextIter &iter) { while(!iter.ends_line() && (*iter == ' ' || *iter == '\t' || !is_code_iter(iter)) && iter.forward_char()) { } return !iter.is_end(); } Gtk::TextIter Source::View::get_start_of_expression(Gtk::TextIter iter) { backward_to_code_or_line_start(iter); if(iter.starts_line()) return iter; bool has_semicolon = false; bool has_open_curly = false; if(is_bracket_language) { if(*iter == ';' && is_code_iter(iter)) has_semicolon = true; else if(*iter == '{' && is_code_iter(iter)) { iter.backward_char(); has_open_curly = true; } } int para_count = 0; int square_count = 0; long curly_count = 0; do { if(*iter == '(' && is_code_iter(iter)) para_count++; else if(*iter == ')' && is_code_iter(iter)) para_count--; else if(*iter == '[' && is_code_iter(iter)) square_count++; else if(*iter == ']' && is_code_iter(iter)) square_count--; else if(*iter == '{' && is_code_iter(iter)) curly_count++; else if(*iter == '}' && is_code_iter(iter)) { curly_count--; if(iter.starts_line()) break; } if(para_count > 0 || square_count > 0 || curly_count > 0) break; if(iter.starts_line() && para_count == 0 && square_count == 0) { if(!is_bracket_language) return iter; // Handle << at the beginning of the sentence if iter initially started with ; if(has_semicolon) { auto test_iter = get_tabs_end_iter(iter); if(!test_iter.starts_line() && *test_iter == '<' && is_code_iter(test_iter) && test_iter.forward_char() && *test_iter == '<') continue; } // Handle for instance: test\n .test(); if(has_semicolon && use_fixed_continuation_indenting) { auto test_iter = get_tabs_end_iter(iter); if(!test_iter.starts_line() && *test_iter == '.' && is_code_iter(test_iter)) continue; } // Handle : at the beginning of the sentence if iter initially started with { if(has_open_curly) { auto test_iter = get_tabs_end_iter(iter); if(!test_iter.starts_line() && *test_iter == ':' && is_code_iter(test_iter)) continue; } // Handle ',', ':', or operators that can be used between two lines, on previous line // Return if previous line is empty auto previous_iter = iter; previous_iter.backward_char(); backward_to_code_or_line_start(previous_iter); if(previous_iter.starts_line()) return iter; // Handle for instance: Test::Test():\n test(2) { if(has_open_curly && *previous_iter == ':') { previous_iter.backward_char(); backward_to_code_or_line_start(previous_iter); if(*previous_iter == ')') { auto token = get_token(get_tabs_end_iter(previous_iter)); if(token != "case") continue; } return iter; } // Handle for instance: int a =\n b; if(*previous_iter == '=' || *previous_iter == '+' || *previous_iter == '-' || *previous_iter == '*' || *previous_iter == '/' || *previous_iter == '%' || *previous_iter == '<' || *previous_iter == '>' || *previous_iter == '&' || *previous_iter == '|') { if(has_semicolon) continue; return iter; } if(*previous_iter != ',') return iter; else { // Return if , is followed by }, for instance: {\n 1,\n 2,\n} auto next_iter = iter; if(forward_to_code_or_line_end(next_iter) && *next_iter == '}') return iter; } } } while(iter.backward_char()); return iter; } bool Source::View::find_close_symbol_forward(Gtk::TextIter iter, Gtk::TextIter &found_iter, unsigned int positive_char, unsigned int negative_char) { long count = 0; if(positive_char == '{' && negative_char == '}') { do { if(*iter == positive_char && is_code_iter(iter)) count++; else if(*iter == negative_char && is_code_iter(iter)) { if(count == 0) { found_iter = iter; return true; } count--; } } while(iter.forward_char()); return false; } else { long curly_count = 0; do { if(curly_count == 0 && *iter == positive_char && is_code_iter(iter)) { if((is_c || is_cpp) && positive_char == '>') { auto prev = iter; if(prev.backward_char() && *prev == '-') continue; } else if(is_js && positive_char == '>') { auto prev = iter; if(prev.backward_char() && *prev == '=') continue; } count++; } else if(curly_count == 0 && *iter == negative_char && is_code_iter(iter)) { if((is_c || is_cpp) && negative_char == '>') { auto prev = iter; if(prev.backward_char() && *prev == '-') continue; } else if(is_js && negative_char == '>') { auto prev = iter; if(prev.backward_char() && *prev == '=') continue; } if(count == 0) { found_iter = iter; return true; } count--; } else if(*iter == '{' && is_code_iter(iter)) curly_count++; else if(*iter == '}' && is_code_iter(iter)) { if(curly_count == 0) return false; curly_count--; } } while(iter.forward_char()); return false; } } bool Source::View::find_open_symbol_backward(Gtk::TextIter iter, Gtk::TextIter &found_iter, unsigned int positive_char, unsigned int negative_char) { long count = 0; if(positive_char == '{' && negative_char == '}') { do { if(*iter == positive_char && is_code_iter(iter)) { if(count == 0) { found_iter = iter; return true; } count++; } else if(*iter == negative_char && is_code_iter(iter)) count--; } while(iter.backward_char()); return false; } else { long curly_count = 0; do { if(curly_count == 0 && *iter == positive_char && is_code_iter(iter)) { if((is_c || is_cpp) && positive_char == '>') { auto prev = iter; if(prev.backward_char() && *prev == '-') continue; } else if(is_js && positive_char == '>') { auto prev = iter; if(prev.backward_char() && *prev == '=') continue; } if(count == 0) { found_iter = iter; return true; } count++; } else if(curly_count == 0 && *iter == negative_char && is_code_iter(iter)) { if((is_c || is_cpp) && negative_char == '>') { auto prev = iter; if(prev.backward_char() && *prev == '-') continue; } else if(is_js && negative_char == '>') { auto prev = iter; if(prev.backward_char() && *prev == '=') continue; } count--; } else if(*iter == '{' && is_code_iter(iter)) { if(curly_count == 0) return false; curly_count++; } else if(*iter == '}' && is_code_iter(iter)) curly_count--; } while(iter.backward_char()); return false; } } long Source::View::symbol_count(Gtk::TextIter iter, unsigned int positive_char, unsigned int negative_char) { auto iter_stored = iter; long symbol_count = 0; if(positive_char == '{' && negative_char == '}') { // If checking top-level curly brackets, check whole buffer auto previous_iter = iter; if(iter.starts_line() || (previous_iter.backward_char() && previous_iter.starts_line() && *previous_iter == '{')) { auto iter = get_buffer()->begin(); do { if(*iter == '{' && is_code_iter(iter)) ++symbol_count; else if(*iter == '}' && is_code_iter(iter)) --symbol_count; } while(iter.forward_char()); return symbol_count; } // Can stop when text is found at top-level indentation else { do { if(*iter == '{' && is_code_iter(iter)) ++symbol_count; else if(*iter == '}' && is_code_iter(iter)) --symbol_count; if(iter.starts_line() && !iter.ends_line() && *iter != '#' && *iter != ' ' && *iter != '\t') break; } while(iter.backward_char()); iter = iter_stored; if(!iter.forward_char()) return symbol_count; do { if(*iter == '{' && is_code_iter(iter)) ++symbol_count; else if(*iter == '}' && is_code_iter(iter)) --symbol_count; if(iter.starts_line() && !iter.ends_line() && *iter != '#' && *iter != ' ' && *iter != '\t') { if(*iter == 'p') { auto token = get_token(iter); if(token == "public" || token == "protected" || token == "private") continue; } break; } } while(iter.forward_char()); return symbol_count; } } long curly_count = 0; do { if(*iter == positive_char && is_code_iter(iter)) symbol_count++; else if(*iter == negative_char && is_code_iter(iter)) symbol_count--; else if(*iter == '{' && is_code_iter(iter)) { if(curly_count == 0) break; curly_count++; } else if(*iter == '}' && is_code_iter(iter)) curly_count--; } while(iter.backward_char()); iter = iter_stored; if(!iter.forward_char()) return symbol_count; curly_count = 0; do { if(*iter == positive_char && is_code_iter(iter)) symbol_count++; else if(*iter == negative_char && is_code_iter(iter)) symbol_count--; else if(*iter == '{' && is_code_iter(iter)) curly_count++; else if(*iter == '}' && is_code_iter(iter)) { if(curly_count == 0) break; curly_count--; } } while(iter.forward_char()); return symbol_count; } bool Source::View::is_templated_function(Gtk::TextIter iter, Gtk::TextIter &parenthesis_end_iter) { auto iter_stored = iter; long bracket_count = 0; long curly_count = 0; if(!(iter.backward_char() && *iter == '>' && *iter_stored == '(')) return false; do { if(*iter == '<' && is_code_iter(iter)) bracket_count++; else if(*iter == '>' && is_code_iter(iter)) bracket_count--; else if(*iter == '{' && is_code_iter(iter)) curly_count++; else if(*iter == '}' && is_code_iter(iter)) curly_count--; if(bracket_count == 0) break; if(curly_count > 0) break; } while(iter.backward_char()); if(bracket_count != 0) return false; iter = iter_stored; bracket_count = 0; curly_count = 0; do { if(*iter == '(' && is_code_iter(iter)) bracket_count++; else if(*iter == ')' && is_code_iter(iter)) bracket_count--; else if(*iter == '{' && is_code_iter(iter)) curly_count++; else if(*iter == '}' && is_code_iter(iter)) curly_count--; if(bracket_count == 0) { parenthesis_end_iter = iter; return true; } if(curly_count < 0) return false; } while(iter.forward_char()); return false; } bool Source::View::is_possible_argument() { auto iter = get_buffer()->get_insert()->get_iter(); if(iter.backward_char() && (!interactive_completion || last_keyval == '(' || last_keyval == ',' || last_keyval == ' ' || last_keyval == GDK_KEY_Return || last_keyval == GDK_KEY_KP_Enter)) { if(backward_to_code(iter) && (*iter == '(' || *iter == ',')) return true; } return false; } bool Source::View::on_key_press_event(GdkEventKey *event) { enable_multiple_cursors = true; ScopeGuard guard{[this] { enable_multiple_cursors = false; }}; if(SelectionDialog::get() && SelectionDialog::get()->is_visible()) { if(SelectionDialog::get()->on_key_press(event)) return true; } if(CompletionDialog::get() && CompletionDialog::get()->is_visible()) { if(CompletionDialog::get()->on_key_press(event)) return true; } if(last_keyval < GDK_KEY_Shift_L || last_keyval > GDK_KEY_Hyper_R) previous_non_modifier_keyval = last_keyval; last_keyval = event->keyval; if((event->keyval == GDK_KEY_Tab || event->keyval == GDK_KEY_ISO_Left_Tab) && (event->state & GDK_SHIFT_MASK) == 0 && select_snippet_parameter()) return true; if(on_key_press_event_extra_cursors(event)) return true; { LockGuard lock(snippets_mutex); if(snippets) { guint keyval_without_state; gdk_keymap_translate_keyboard_state(gdk_keymap_get_default(), event->hardware_keycode, (GdkModifierType)0, 0, &keyval_without_state, nullptr, nullptr, nullptr); for(auto &snippet : *snippets) { if(snippet.key == keyval_without_state && (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK | GDK_META_MASK)) == snippet.modifier) { insert_snippet(get_buffer()->get_insert()->get_iter(), snippet.body); return true; } } } } get_buffer()->begin_user_action(); // Shift+enter: go to end of line and enter if((event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_KP_Enter) && (event->state & GDK_SHIFT_MASK) > 0) { auto iter = get_buffer()->get_insert()->get_iter(); if(!iter.ends_line()) { iter.forward_to_line_end(); get_buffer()->place_cursor(iter); } } if(Config::get().source.smart_brackets && on_key_press_event_smart_brackets(event)) { get_buffer()->end_user_action(); return true; } if(Config::get().source.smart_inserts && on_key_press_event_smart_inserts(event)) { get_buffer()->end_user_action(); return true; } if(is_bracket_language && on_key_press_event_bracket_language(event)) { get_buffer()->end_user_action(); return true; } else if(on_key_press_event_basic(event)) { get_buffer()->end_user_action(); return true; } else { get_buffer()->end_user_action(); return BaseView::on_key_press_event(event); } } // Basic indentation bool Source::View::on_key_press_event_basic(GdkEventKey *event) { auto iter = get_buffer()->get_insert()->get_iter(); // Indent as in current or next line if((event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_KP_Enter) && !get_buffer()->get_has_selection() && !iter.starts_line()) { cleanup_whitespace_characters(iter); iter = get_buffer()->get_insert()->get_iter(); auto condition_iter = iter; condition_iter.backward_char(); backward_to_code_or_line_start(condition_iter); auto start_iter = get_start_of_expression(condition_iter); auto tabs_end_iter = get_tabs_end_iter(start_iter); auto tabs = get_line_before(tabs_end_iter); // Python indenting after : if(*condition_iter == ':' && language_id == "python") { get_buffer()->insert_at_cursor('\n' + tabs + tab); scroll_to(get_buffer()->get_insert()); return true; } // Indent as in current or next line int line_nr = iter.get_line(); if(iter.ends_line() && (line_nr + 1) < get_buffer()->get_line_count()) { auto next_tabs_end_iter = get_tabs_end_iter(line_nr + 1); if(next_tabs_end_iter.get_line_offset() > tabs_end_iter.get_line_offset()) { get_buffer()->insert_at_cursor('\n' + get_line_before(next_tabs_end_iter)); scroll_to(get_buffer()->get_insert()); return true; } } get_buffer()->insert_at_cursor('\n' + tabs); scroll_to(get_buffer()->get_insert()); return true; } // Indent as in next or previous line else if(event->keyval == GDK_KEY_Tab && (event->state & GDK_SHIFT_MASK) == 0) { // Special case if insert is at beginning of empty line: if(iter.starts_line() && iter.ends_line() && !get_buffer()->get_has_selection()) { auto prev_line_iter = iter; while(prev_line_iter.starts_line() && prev_line_iter.backward_char()) { } auto start_iter = get_start_of_expression(prev_line_iter); auto prev_line_tabs_end_iter = get_tabs_end_iter(start_iter); auto next_line_iter = iter; while(next_line_iter.starts_line() && next_line_iter.forward_char()) { } auto next_line_tabs_end_iter = get_tabs_end_iter(next_line_iter); Gtk::TextIter tabs_end_iter; if(next_line_tabs_end_iter.get_line_offset() > prev_line_tabs_end_iter.get_line_offset()) tabs_end_iter = next_line_tabs_end_iter; else tabs_end_iter = prev_line_tabs_end_iter; auto tabs = get_line_before(tabs_end_iter); get_buffer()->insert_at_cursor(tabs.size() >= tab_size ? tabs : tab); return true; } if(!Config::get().source.tab_indents_line && !get_buffer()->get_has_selection()) { get_buffer()->insert_at_cursor(tab); return true; } // Indent right when clicking tab, no matter where in the line the cursor is. Also works on selected text. Gtk::TextIter selection_start, selection_end; get_buffer()->get_selection_bounds(selection_start, selection_end); Mark selection_end_mark(selection_end); int line_start = selection_start.get_line(); int line_end = selection_end.get_line(); for(int line = line_start; line <= line_end; line++) { auto line_it = get_buffer()->get_iter_at_line(line); if(!get_buffer()->get_has_selection() || line_it != selection_end_mark->get_iter()) get_buffer()->insert(line_it, tab); } return true; } // Indent left when clicking shift-tab, no matter where in the line the cursor is. Also works on selected text. else if((event->keyval == GDK_KEY_ISO_Left_Tab || event->keyval == GDK_KEY_Tab) && (event->state & GDK_SHIFT_MASK) > 0) { Gtk::TextIter selection_start, selection_end; get_buffer()->get_selection_bounds(selection_start, selection_end); int line_start = selection_start.get_line(); int line_end = selection_end.get_line(); unsigned indent_left_steps = tab_size; std::vector<bool> ignore_line; for(int line_nr = line_start; line_nr <= line_end; line_nr++) { auto line_it = get_buffer()->get_iter_at_line(line_nr); if(!get_buffer()->get_has_selection() || line_it != selection_end) { auto tabs_end_iter = get_tabs_end_iter(line_nr); if(tabs_end_iter.starts_line() && tabs_end_iter.ends_line()) ignore_line.push_back(true); else { auto line_tabs = get_line_before(tabs_end_iter); if(line_tabs.size() > 0) { indent_left_steps = std::min(indent_left_steps, static_cast<unsigned>(line_tabs.size())); ignore_line.push_back(false); } else return true; } } } for(int line_nr = line_start; line_nr <= line_end; line_nr++) { Gtk::TextIter line_it = get_buffer()->get_iter_at_line(line_nr); Gtk::TextIter line_plus_it = line_it; if(!get_buffer()->get_has_selection() || line_it != selection_end) { line_plus_it.forward_chars(indent_left_steps); if(!ignore_line.at(line_nr - line_start)) get_buffer()->erase(line_it, line_plus_it); } } return true; } // "Smart" backspace key else if(event->keyval == GDK_KEY_BackSpace && !get_buffer()->get_has_selection()) { auto line = get_line_before(); bool do_smart_backspace = true; for(auto &chr : line) { if(chr != ' ' && chr != '\t') { do_smart_backspace = false; break; } } if(iter.get_line() == 0) // Special case since there are no previous line do_smart_backspace = false; if(do_smart_backspace) { auto previous_line_end_iter = iter; if(previous_line_end_iter.backward_chars(line.size() + 1)) { if(!previous_line_end_iter.ends_line()) // For CR+LF previous_line_end_iter.backward_char(); if(previous_line_end_iter.starts_line()) // When previous line is empty, keep tabs in current line get_buffer()->erase(previous_line_end_iter, get_buffer()->get_iter_at_line(iter.get_line())); else get_buffer()->erase(previous_line_end_iter, iter); return true; } } } // "Smart" delete key else if(event->keyval == GDK_KEY_Delete && !get_buffer()->get_has_selection()) { auto insert_iter = iter; bool do_smart_delete = true; do { if(*iter != ' ' && *iter != '\t' && !iter.ends_line()) { do_smart_delete = false; break; } if(iter.ends_line()) { if(!iter.forward_char()) do_smart_delete = false; break; } } while(iter.forward_char()); if(do_smart_delete) { if(!insert_iter.starts_line()) { while((*iter == ' ' || *iter == '\t') && iter.forward_char()) { } } get_buffer()->erase(insert_iter, iter); return true; } } // Workaround for TextView::on_key_press_event bug sometimes causing segmentation faults // TODO: figure out the bug and create pull request to gtk // Have only experienced this on OS X // Note: valgrind reports issues on TextView::on_key_press_event as well auto unicode = gdk_keyval_to_unicode(event->keyval); if((event->state & (GDK_CONTROL_MASK | GDK_META_MASK)) == 0 && unicode >= 32 && unicode != 127 && (previous_non_modifier_keyval < GDK_KEY_dead_grave || previous_non_modifier_keyval > GDK_KEY_dead_greek)) { if(get_buffer()->get_has_selection()) { Gtk::TextIter selection_start, selection_end; get_buffer()->get_selection_bounds(selection_start, selection_end); get_buffer()->erase(selection_start, selection_end); } get_buffer()->insert_at_cursor(Glib::ustring(1, unicode)); scroll_to(get_buffer()->get_insert()); // Trick to make the cursor visible right after insertion: set_cursor_visible(false); set_cursor_visible(); return true; } return false; } //Bracket language indentation bool Source::View::on_key_press_event_bracket_language(GdkEventKey *event) { const static std::regex no_bracket_statement_regex("^[ \t]*(if( +constexpr)?|for|while) *\\(.*[^;}{] *$|" "^[ \t]*[}]? *else if( +constexpr)? *\\(.*[^;}{] *$|" "^[ \t]*[}]? *else *$", std::regex::extended | std::regex::optimize); auto iter = get_buffer()->get_insert()->get_iter(); if(get_buffer()->get_has_selection()) return false; if(!is_code_iter(iter)) { // Add * at start of line in comment blocks if(event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_KP_Enter) { if(!iter.starts_line() && (!string_tag || (!iter.has_tag(string_tag) && !iter.ends_tag(string_tag)))) { cleanup_whitespace_characters(iter); iter = get_buffer()->get_insert()->get_iter(); auto start_iter = get_tabs_end_iter(iter.get_line()); if(!is_code_iter(start_iter)) { auto end_iter = start_iter; end_iter.forward_chars(2); auto start_of_sentence = get_buffer()->get_text(start_iter, end_iter); if(!start_of_sentence.empty() && (start_of_sentence == "/*" || start_of_sentence[0] == '*')) { auto tabs = get_line_before(start_iter); auto insert_str = '\n' + tabs; if(start_of_sentence[0] == '/') insert_str += ' '; insert_str += "* "; get_buffer()->insert_at_cursor(insert_str); return true; } } } else if(!comment_tag || !iter.ends_tag(comment_tag)) return false; } else return false; } // Indent depending on if/else/etc and brackets if((event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_KP_Enter) && !iter.starts_line()) { cleanup_whitespace_characters(iter); iter = get_buffer()->get_insert()->get_iter(); auto previous_iter = iter; previous_iter.backward_char(); // Remove matching bracket highlights that get extended when inserting text in between the brackets ScopeGuard guard; if((*previous_iter == '{' && *iter == '}') || (*previous_iter == '(' && *iter == ')') || (*previous_iter == '[' && *iter == ']') || (*previous_iter == '<' && *iter == '>')) { get_source_buffer()->set_highlight_matching_brackets(false); guard.on_exit = [this] { get_source_buffer()->set_highlight_matching_brackets(true); }; } auto condition_iter = previous_iter; backward_to_code_or_line_start(condition_iter); auto start_iter = get_start_of_expression(condition_iter); auto tabs_end_iter = get_tabs_end_iter(start_iter); auto tabs = get_line_before(tabs_end_iter); /* * Change tabs after ending comment block with an extra space (as in this case) */ if(tabs.size() % tab_size == 1 && !start_iter.ends_line() && !is_code_iter(start_iter)) { auto end_of_line_iter = start_iter; end_of_line_iter.forward_to_line_end(); if(starts_with(get_buffer()->get_text(tabs_end_iter, end_of_line_iter).raw(), "*/")) { tabs.pop_back(); get_buffer()->insert_at_cursor('\n' + tabs); scroll_to(get_buffer()->get_insert()); return true; } } // Indent enter inside HTML or JSX elements, for instance: // <div>CURSOR</div> // to: // <div> // CURSOR // </div> // and // <div>CURSORtest // to // <div> // CURSORtest if(*condition_iter == '>' && is_js) { auto prev = condition_iter; Gtk::TextIter open_element_iter; if(prev.backward_char() && backward_to_code(prev) && *prev != '/' && find_open_symbol_backward(prev, open_element_iter, '<', '>') && open_element_iter.forward_char() && forward_to_code(open_element_iter) && *open_element_iter != '/') { auto get_element = [this](Gtk::TextIter iter) { auto start = iter; auto end = iter; while(iter.backward_char() && (is_token_char(*iter) || *iter == '.')) start = iter; while((is_token_char(*end) || *end == '.') && end.forward_char()) { } return get_buffer()->get_text(start, end); }; auto open_element_token = get_element(open_element_iter); static std::vector<std::string> void_elements = {"area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"}; if(std::none_of(void_elements.begin(), void_elements.end(), [&open_element_token](const std::string &e) { return e == open_element_token; })) { auto close_element_iter = iter; // If cursor is placed between open and close tag if(*close_element_iter == '<' && close_element_iter.forward_char() && forward_to_code(close_element_iter) && *close_element_iter == '/' && close_element_iter.forward_char() && forward_to_code(close_element_iter) && open_element_token == get_element(close_element_iter)) { get_buffer()->insert_at_cursor('\n' + tabs + tab + '\n' + tabs); auto insert_it = get_buffer()->get_insert()->get_iter(); if(insert_it.backward_chars(tabs.size() + 1)) { scroll_to(get_buffer()->get_insert()); get_buffer()->place_cursor(insert_it); } return true; } close_element_iter = iter; // Add closing tag if missing if(close_element_iter.ends_line()) { forward_to_code(close_element_iter); auto close_element_tabs_size = static_cast<size_t>(get_tabs_end_iter(close_element_iter).get_line_offset()); if(!close_element_iter || close_element_tabs_size < tabs.size() || (close_element_tabs_size == tabs.size() && (*close_element_iter == '{' || (*close_element_iter == '<' && close_element_iter.forward_char() && forward_to_code(close_element_iter) && !(*close_element_iter == '/' && close_element_iter.forward_char() && forward_to_code(close_element_iter) && get_element(close_element_iter) == open_element_token))))) { get_buffer()->insert_at_cursor('\n' + tabs + tab + '\n' + tabs + "</" + open_element_token + '>'); auto insert_it = get_buffer()->get_insert()->get_iter(); if(insert_it.backward_chars(tabs.size() + 1 + open_element_token.size() + 3)) { scroll_to(get_buffer()->get_insert()); get_buffer()->place_cursor(insert_it); } return true; } } // If line ends with closing element, move content after open to new line, and closing tag on the next line thereafter close_element_iter = iter; if(!close_element_iter.ends_line()) close_element_iter.forward_to_line_end(); if(close_element_iter.backward_char() && *close_element_iter == '>' && close_element_iter.backward_char() && find_open_symbol_backward(close_element_iter, close_element_iter, '<', '>')) { auto start_close_element_iter = close_element_iter; auto content_size = start_close_element_iter.get_offset() - iter.get_offset(); if(close_element_iter.forward_char() && forward_to_code(close_element_iter) && *close_element_iter == '/' && close_element_iter.forward_char() && forward_to_code(close_element_iter) && get_element(close_element_iter) == open_element_token) { get_buffer()->insert_at_cursor('\n' + tabs + tab); auto close_element_start_iter = get_buffer()->get_insert()->get_iter(); close_element_start_iter.forward_chars(content_size); get_buffer()->insert(close_element_start_iter, '\n' + tabs); scroll_to(get_buffer()->get_insert()); return true; } } get_buffer()->insert_at_cursor('\n' + tabs + tab); scroll_to(get_buffer()->get_insert()); return true; } } } // Special indentation of {, [ and ( for for instance JavaScript, JSON, Rust if(use_fixed_continuation_indenting) { unsigned int open_symbol = 0, close_symbol = 0; if(*condition_iter == '[') { open_symbol = '['; close_symbol = ']'; } else if(*condition_iter == '(') { open_symbol = '('; close_symbol = ')'; } else if(*condition_iter == '{') { open_symbol = '{'; close_symbol = '}'; } if(open_symbol != 0 && is_code_iter(condition_iter)) { Gtk::TextIter found_iter; // Check if an ), ] or } is needed bool has_right_bracket = false; if(find_close_symbol_forward(iter, found_iter, open_symbol, close_symbol)) { auto found_tabs_end_iter = get_tabs_end_iter(found_iter); if(found_tabs_end_iter.get_line_offset() == tabs_end_iter.get_line_offset()) has_right_bracket = true; } if(*iter == close_symbol) { get_buffer()->insert_at_cursor('\n' + tabs + tab + '\n' + tabs); auto insert_it = get_buffer()->get_insert()->get_iter(); if(insert_it.backward_chars(tabs.size() + 1)) { scroll_to(get_buffer()->get_insert()); get_buffer()->place_cursor(insert_it); } return true; } else if(!has_right_bracket) { // If line does not end with: (,[, or {, move contents after the left bracket to next line inside brackets if(!iter.ends_line() && *iter != ')' && *iter != ']' && *iter != '}') { get_buffer()->insert_at_cursor('\n' + tabs + tab); auto iter = get_buffer()->get_insert()->get_iter(); Mark mark(iter); iter.forward_to_line_end(); get_buffer()->insert(iter, '\n' + tabs + static_cast<char>(close_symbol)); scroll_to(get_buffer()->get_insert()); get_buffer()->place_cursor(mark->get_iter()); return true; } else { //Insert new lines with bracket end get_buffer()->insert_at_cursor('\n' + tabs + tab + '\n' + tabs + static_cast<char>(close_symbol)); auto insert_it = get_buffer()->get_insert()->get_iter(); if(insert_it.backward_chars(tabs.size() + 2)) { scroll_to(get_buffer()->get_insert()); get_buffer()->place_cursor(insert_it); } return true; } } else { get_buffer()->insert_at_cursor('\n' + tabs + tab); scroll_to(get_buffer()->get_insert()); return true; } } // JavaScript: simplified indentations inside brackets, after for example: // [\n 1, 2, 3,\n // return (\n // ReactDOM.render(\n <div>\n Gtk::TextIter found_iter; auto after_start_iter = start_iter; after_start_iter.forward_char(); if((*start_iter == '[' && (!find_close_symbol_forward(after_start_iter, found_iter, '[', ']') || found_iter > iter)) || (*start_iter == '(' && (!find_close_symbol_forward(after_start_iter, found_iter, '(', ')') || found_iter > iter)) || (*start_iter == '{' && (!find_close_symbol_forward(after_start_iter, found_iter, '{', '}') || found_iter > iter))) { get_buffer()->insert_at_cursor('\n' + tabs + tab); scroll_to(get_buffer()->get_insert()); return true; } } else { if(*condition_iter == '{' && is_code_iter(condition_iter)) { Gtk::TextIter close_iter; // Check if an '}' is needed bool has_right_curly_bracket = false; if(find_close_symbol_forward(iter, close_iter, '{', '}')) { auto found_tabs_end_iter = get_tabs_end_iter(close_iter); if(found_tabs_end_iter.get_line_offset() == tabs_end_iter.get_line_offset()) { has_right_curly_bracket = true; // Special case for functions and classes with no indentation after: namespace { if(is_cpp && tabs_end_iter.starts_line()) { auto iter = condition_iter; Gtk::TextIter open_iter; if(iter.backward_char() && find_open_symbol_backward(iter, open_iter, '{', '}')) { if(open_iter.starts_line()) // in case of: namespace test\n{ open_iter.backward_char(); auto iter = get_buffer()->get_iter_at_line(open_iter.get_line()); if(get_token(iter) == "namespace") has_right_curly_bracket = close_iter.forward_char() && find_close_symbol_forward(close_iter, close_iter, '{', '}'); } } } /** * Handle pressing enter after '{' in special expressions like: * enum class A { a, * b } */ else if(close_iter.get_line() > condition_iter.get_line() && close_iter.get_line_offset() > condition_iter.get_line_offset()) { get_buffer()->insert_at_cursor('\n' + get_line_before(get_tabs_end_iter(condition_iter.get_line() + 1))); scroll_to(get_buffer()->get_insert()); return true; } /** * Handle pressing enter after '{' in special expressions like: * test(2, * []() { * func(); * }); */ else if(close_iter.get_line() > condition_iter.get_line() && close_iter.get_line_offset() == get_tabs_end_iter(condition_iter).get_line_offset()) { get_buffer()->insert_at_cursor('\n' + get_line_before(get_tabs_end_iter(condition_iter)) + tab); scroll_to(get_buffer()->get_insert()); return true; } } // Check if one should add semicolon after '}' bool add_semicolon = false; if(is_c || is_cpp) { // add semicolon after class or struct? auto token = get_token(tabs_end_iter); if(token == "class" || token == "struct") add_semicolon = true; // Add semicolon after lambda unless it's an argument else if(*start_iter != '(' && *start_iter != '{' && *start_iter != '[') { auto it = condition_iter; long para_count = 0; long square_count = 0; bool square_outside_para_found = false; while(it.backward_char()) { if(*it == ']' && is_code_iter(it)) { --square_count; if(para_count == 0) square_outside_para_found = true; } else if(*it == '[' && is_code_iter(it)) ++square_count; else if(*it == ')' && is_code_iter(it)) --para_count; else if(*it == '(' && is_code_iter(it)) ++para_count; if(square_outside_para_found && square_count == 0 && para_count == 0) { // Look for equal sign while(it.backward_char() && (*it == ' ' || *it == '\t' || it.ends_line())) { } if(*it == '=') add_semicolon = true; break; } if(it == start_iter) break; if(!square_outside_para_found && square_count == 0 && para_count == 0) { if(is_token_char(*it) || *it == '-' || *it == ' ' || *it == '\t' || *it == '<' || *it == '>' || *it == '(' || *it == ':' || *it == '*' || *it == '&' || *it == '/' || it.ends_line() || !is_code_iter(it)) { continue; } else break; } } } } if(*iter == '}') { get_buffer()->insert_at_cursor('\n' + tabs + tab + '\n' + tabs); if(add_semicolon) { // Check if semicolon exists auto next_iter = get_buffer()->get_insert()->get_iter(); next_iter.forward_char(); if(*next_iter != ';') get_buffer()->insert(next_iter, ";"); } auto insert_it = get_buffer()->get_insert()->get_iter(); if(insert_it.backward_chars(tabs.size() + 1)) { scroll_to(get_buffer()->get_insert()); get_buffer()->place_cursor(insert_it); } return true; } else if(!has_right_curly_bracket) { // If line does not end with: {, move contents after { to next line inside brackets if(!iter.ends_line() && *iter != ')' && *iter != ']') { get_buffer()->insert_at_cursor('\n' + tabs + tab); auto iter = get_buffer()->get_insert()->get_iter(); Mark mark(iter); iter.forward_to_line_end(); get_buffer()->insert(iter, '\n' + tabs + '}'); scroll_to(get_buffer()->get_insert()); get_buffer()->place_cursor(mark->get_iter()); return true; } else { get_buffer()->insert_at_cursor('\n' + tabs + tab + '\n' + tabs + (add_semicolon ? "};" : "}")); auto insert_it = get_buffer()->get_insert()->get_iter(); if(insert_it.backward_chars(tabs.size() + (add_semicolon ? 3 : 2))) { scroll_to(get_buffer()->get_insert()); get_buffer()->place_cursor(insert_it); } return true; } } else { get_buffer()->insert_at_cursor('\n' + tabs + tab); scroll_to(get_buffer()->get_insert()); return true; } } // Indent multiline expressions if(*start_iter == '(' || *start_iter == '[') { auto iter = get_tabs_end_iter(start_iter); auto tabs = get_line_before(iter); while(iter <= start_iter) { tabs += ' '; iter.forward_char(); } get_buffer()->insert_at_cursor('\n' + tabs); scroll_to(get_buffer()->get_insert()); return true; } } auto after_condition_iter = condition_iter; after_condition_iter.forward_char(); std::string sentence = get_buffer()->get_text(start_iter, after_condition_iter); std::smatch sm; // Indenting after for instance: if(...)\n if(std::regex_match(sentence, sm, no_bracket_statement_regex)) { get_buffer()->insert_at_cursor('\n' + tabs + tab); scroll_to(get_buffer()->get_insert()); return true; } // Indenting after for instance: if(...)\n...;\n else if(*condition_iter == ';' && condition_iter.get_line() > 0 && is_code_iter(condition_iter)) { auto previous_end_iter = start_iter; while(previous_end_iter.backward_char() && !previous_end_iter.ends_line()) { } backward_to_code_or_line_start(previous_end_iter); auto previous_start_iter = get_tabs_end_iter(get_buffer()->get_iter_at_line(get_start_of_expression(previous_end_iter).get_line())); auto previous_tabs = get_line_before(previous_start_iter); if(!previous_end_iter.ends_line()) previous_end_iter.forward_char(); std::string previous_sentence = get_buffer()->get_text(previous_start_iter, previous_end_iter); std::smatch sm2; if(std::regex_match(previous_sentence, sm2, no_bracket_statement_regex)) { get_buffer()->insert_at_cursor('\n' + previous_tabs); scroll_to(get_buffer()->get_insert()); return true; } } // Indenting after ':' else if(*condition_iter == ':' && is_code_iter(condition_iter)) { bool perform_indent = true; auto iter = condition_iter; if(!iter.starts_line()) iter.backward_char(); backward_to_code_or_line_start(iter); if(*iter == ')') { auto token = get_token(get_tabs_end_iter(get_buffer()->get_iter_at_line(iter.get_line()))); if(token != "case") // Do not move left for instance: void Test::Test(): perform_indent = false; } if(perform_indent) { Gtk::TextIter found_curly_iter; if(find_open_symbol_backward(iter, found_curly_iter, '{', '}')) { auto tabs_end_iter = get_tabs_end_iter(get_buffer()->get_iter_at_line(found_curly_iter.get_line())); auto tabs_start_of_sentence = get_line_before(tabs_end_iter); if(tabs.size() == (tabs_start_of_sentence.size() + tab_size)) { auto start_line_iter = get_buffer()->get_iter_at_line(iter.get_line()); auto start_line_plus_tab_size = start_line_iter; for(size_t c = 0; c < tab_size; c++) start_line_plus_tab_size.forward_char(); get_buffer()->erase(start_line_iter, start_line_plus_tab_size); get_buffer()->insert_at_cursor('\n' + tabs); scroll_to(get_buffer()->get_insert()); return true; } else { get_buffer()->insert_at_cursor('\n' + tabs + tab); scroll_to(get_buffer()->get_insert()); return true; } } } } // Indent as in current or next line int line_nr = iter.get_line(); if(iter.ends_line() && (line_nr + 1) < get_buffer()->get_line_count()) { auto next_tabs_end_iter = get_tabs_end_iter(line_nr + 1); if(next_tabs_end_iter.get_line_offset() > tabs_end_iter.get_line_offset()) { get_buffer()->insert_at_cursor('\n' + get_line_before(next_tabs_end_iter)); scroll_to(get_buffer()->get_insert()); return true; } } get_buffer()->insert_at_cursor('\n' + tabs); scroll_to(get_buffer()->get_insert()); return true; } // Indent left when writing }, ) or ] on a new line else if(event->keyval == GDK_KEY_braceright || (use_fixed_continuation_indenting && (event->keyval == GDK_KEY_bracketright || event->keyval == GDK_KEY_parenright))) { std::string bracket; if(event->keyval == GDK_KEY_braceright) bracket = "}"; if(event->keyval == GDK_KEY_bracketright) bracket = "]"; else if(event->keyval == GDK_KEY_parenright) bracket = ")"; std::string line = get_line_before(); if(line.size() >= tab_size && iter.ends_line()) { bool indent_left = true; for(auto c : line) { if(c != tab_char) { indent_left = false; break; } } if(indent_left) { auto line_it = get_buffer()->get_iter_at_line(iter.get_line()); auto line_plus_it = line_it; line_plus_it.forward_chars(tab_size); get_buffer()->erase(line_it, line_plus_it); get_buffer()->insert_at_cursor(bracket); return true; } } } // Indent left when writing { on a new line after for instance if(...)\n... else if(event->keyval == GDK_KEY_braceleft) { auto tabs_end_iter = get_tabs_end_iter(); auto tabs = get_line_before(tabs_end_iter); size_t line_nr = iter.get_line(); if(line_nr > 0 && tabs.size() >= tab_size && iter == tabs_end_iter) { auto previous_end_iter = iter; while(previous_end_iter.backward_char() && !previous_end_iter.ends_line()) { } auto condition_iter = previous_end_iter; backward_to_code_or_line_start(condition_iter); auto previous_start_iter = get_tabs_end_iter(get_buffer()->get_iter_at_line(get_start_of_expression(condition_iter).get_line())); auto previous_tabs = get_line_before(previous_start_iter); auto after_condition_iter = condition_iter; after_condition_iter.forward_char(); if((tabs.size() - tab_size) == previous_tabs.size()) { std::string previous_sentence = get_buffer()->get_text(previous_start_iter, after_condition_iter); std::smatch sm; if(std::regex_match(previous_sentence, sm, no_bracket_statement_regex)) { auto start_iter = iter; start_iter.backward_chars(tab_size); get_buffer()->erase(start_iter, iter); get_buffer()->insert_at_cursor("{"); scroll_to(get_buffer()->get_insert()); return true; } } } } // Mark parameters of templated functions after pressing tab and after writing template argument else if(event->keyval == GDK_KEY_Tab && (event->state & GDK_SHIFT_MASK) == 0) { if(*iter == '>') { iter.forward_char(); Gtk::TextIter parenthesis_end_iter; if(*iter == '(' && is_templated_function(iter, parenthesis_end_iter)) { iter.forward_char(); get_buffer()->select_range(iter, parenthesis_end_iter); scroll_to(get_buffer()->get_insert()); return true; } } // Special case if insert is at beginning of empty line: else if(iter.starts_line() && iter.ends_line() && !get_buffer()->get_has_selection()) { // Indenting after for instance: if(...)\n...;\n auto condition_iter = iter; while(condition_iter.starts_line() && condition_iter.backward_char()) { } backward_to_code_or_line_start(condition_iter); if(*condition_iter == ';' && condition_iter.get_line() > 0 && is_code_iter(condition_iter)) { auto start_iter = get_start_of_expression(condition_iter); auto previous_end_iter = start_iter; while(previous_end_iter.backward_char() && !previous_end_iter.ends_line()) { } backward_to_code_or_line_start(previous_end_iter); auto previous_start_iter = get_tabs_end_iter(get_buffer()->get_iter_at_line(get_start_of_expression(previous_end_iter).get_line())); auto previous_tabs = get_line_before(previous_start_iter); if(!previous_end_iter.ends_line()) previous_end_iter.forward_char(); std::string previous_sentence = get_buffer()->get_text(previous_start_iter, previous_end_iter); std::smatch sm2; if(std::regex_match(previous_sentence, sm2, no_bracket_statement_regex)) { get_buffer()->insert_at_cursor(previous_tabs); scroll_to(get_buffer()->get_insert()); return true; } } } } return false; } bool Source::View::on_key_press_event_smart_brackets(GdkEventKey *event) { if(get_buffer()->get_has_selection()) return false; auto iter = get_buffer()->get_insert()->get_iter(); auto previous_iter = iter; previous_iter.backward_char(); if(is_code_iter(iter)) { //Move after ')' if closed expression if(event->keyval == GDK_KEY_parenright) { if(*iter == ')' && symbol_count(iter, '(', ')') <= 0) { iter.forward_char(); get_buffer()->place_cursor(iter); scroll_to(get_buffer()->get_insert()); return true; } } //Move after '>' if >( and closed expression else if(event->keyval == GDK_KEY_greater) { if(*iter == '>') { iter.forward_char(); Gtk::TextIter parenthesis_end_iter; if(*iter == '(' && is_templated_function(iter, parenthesis_end_iter)) { get_buffer()->place_cursor(iter); scroll_to(get_buffer()->get_insert()); return true; } } } //Move after '(' if >( and select text inside parentheses else if(event->keyval == GDK_KEY_parenleft) { auto previous_iter = iter; previous_iter.backward_char(); if(*previous_iter == '>') { Gtk::TextIter parenthesis_end_iter; if(*iter == '(' && is_templated_function(iter, parenthesis_end_iter)) { iter.forward_char(); get_buffer()->select_range(iter, parenthesis_end_iter); scroll_to(iter); return true; } } } } return false; } bool Source::View::on_key_press_event_smart_inserts(GdkEventKey *event) { keep_snippet_marks = true; ScopeGuard guard{[this] { keep_snippet_marks = false; }}; if(get_buffer()->get_has_selection()) { if(is_bracket_language) { // Remove /**/ around selection if(event->keyval == GDK_KEY_slash) { Gtk::TextIter start, end; get_buffer()->get_selection_bounds(start, end); auto before_start = start; auto after_end = end; if(before_start.backward_char() && *before_start == '*' && before_start.backward_char() && *before_start == '/' && *after_end == '*' && after_end.forward_char() && *after_end == '/') { Mark start_mark(start); Mark end_mark(end); get_buffer()->erase(before_start, start); after_end = end_mark->get_iter(); after_end.forward_chars(2); get_buffer()->erase(end_mark->get_iter(), after_end); get_buffer()->select_range(start_mark->get_iter(), end_mark->get_iter()); return true; } } } Glib::ustring left, right; // Insert () around selection if(event->keyval == GDK_KEY_parenleft) { left = '('; right = ')'; } // Insert [] around selection else if(event->keyval == GDK_KEY_bracketleft) { left = '['; right = ']'; } // Insert {} around selection else if(event->keyval == GDK_KEY_braceleft) { left = '{'; right = '}'; } // Insert <> around selection else if(event->keyval == GDK_KEY_less) { left = '<'; right = '>'; } // Insert '' around selection else if(event->keyval == GDK_KEY_apostrophe) { left = '\''; right = '\''; } // Insert "" around selection else if(event->keyval == GDK_KEY_quotedbl) { left = '"'; right = '"'; } // Insert /**/ around selection else if(is_bracket_language && event->keyval == GDK_KEY_slash) { left = "/*"; right = "*/"; } else if(language_id == "markdown" || !is_code_iter(get_buffer()->get_insert()->get_iter()) || !is_code_iter(get_buffer()->get_selection_bound()->get_iter())) { // Insert `` around selection if(event->keyval == GDK_KEY_dead_grave) { left = '`'; right = '`'; } // Insert ** around selection else if(event->keyval == GDK_KEY_asterisk) { left = '*'; right = '*'; } // Insert __ around selection else if(event->keyval == GDK_KEY_underscore) { left = '_'; right = '_'; } // Insert ~~ around selection else if(event->keyval == GDK_KEY_dead_tilde) { left = '~'; right = '~'; } } if(!left.empty() && !right.empty()) { Gtk::TextIter start, end; get_buffer()->get_selection_bounds(start, end); Mark start_mark(start); Mark end_mark(end); get_buffer()->insert(start, left); get_buffer()->insert(end_mark->get_iter(), right); auto start_mark_next_iter = start_mark->get_iter(); start_mark_next_iter.forward_chars(left.size()); get_buffer()->select_range(start_mark_next_iter, end_mark->get_iter()); return true; } return false; } auto iter = get_buffer()->get_insert()->get_iter(); auto previous_iter = iter; previous_iter.backward_char(); auto next_iter = iter; next_iter.forward_char(); auto allow_insertion = [](const Gtk::TextIter &iter) { if(iter.ends_line() || *iter == ' ' || *iter == '\t' || *iter == ';' || *iter == ',' || *iter == ')' || *iter == ']' || *iter == '}' || *iter == '<' || *iter == '>' || *iter == '/') return true; return false; }; if(is_code_iter(iter)) { // Insert () if(event->keyval == GDK_KEY_parenleft && allow_insertion(iter)) { if(symbol_count(iter, '(', ')') >= 0) { get_buffer()->insert_at_cursor(")"); auto iter = get_buffer()->get_insert()->get_iter(); iter.backward_char(); get_buffer()->place_cursor(iter); scroll_to(get_buffer()->get_insert()); return false; } } // Insert [] else if(event->keyval == GDK_KEY_bracketleft && allow_insertion(iter)) { if(symbol_count(iter, '[', ']') >= 0) { get_buffer()->insert_at_cursor("]"); auto iter = get_buffer()->get_insert()->get_iter(); iter.backward_char(); get_buffer()->place_cursor(iter); scroll_to(get_buffer()->get_insert()); return false; } } // Move right on ] in [] else if(event->keyval == GDK_KEY_bracketright) { if(*iter == ']' && symbol_count(iter, '[', ']') <= 0) { iter.forward_char(); get_buffer()->place_cursor(iter); scroll_to(get_buffer()->get_insert()); return true; } } // Insert {} else if(event->keyval == GDK_KEY_braceleft && allow_insertion(iter)) { auto start_iter = get_start_of_expression(iter); // Do not add } if { is at end of line and next line has a higher indentation auto test_iter = iter; while(!test_iter.ends_line() && (*test_iter == ' ' || *test_iter == '\t' || !is_code_iter(test_iter)) && test_iter.forward_char()) { } if(test_iter.ends_line()) { if(iter.get_line() + 1 < get_buffer()->get_line_count() && *start_iter != '(' && *start_iter != '[' && *start_iter != '{') { auto tabs_end_iter = (get_tabs_end_iter(get_buffer()->get_iter_at_line(start_iter.get_line()))); auto next_line_iter = get_buffer()->get_iter_at_line(iter.get_line() + 1); auto next_line_tabs_end_iter = (get_tabs_end_iter(get_buffer()->get_iter_at_line(next_line_iter.get_line()))); if(next_line_tabs_end_iter.get_line_offset() > tabs_end_iter.get_line_offset()) return false; } } Gtk::TextIter close_iter; bool has_right_curly_bracket = false; auto tabs_end_iter = get_tabs_end_iter(start_iter); if(find_close_symbol_forward(iter, close_iter, '{', '}')) { auto found_tabs_end_iter = get_tabs_end_iter(close_iter); if(found_tabs_end_iter.get_line_offset() == tabs_end_iter.get_line_offset()) { has_right_curly_bracket = true; // Special case for functions and classes with no indentation after: namespace {: if(is_cpp && tabs_end_iter.starts_line()) { Gtk::TextIter open_iter; if(find_open_symbol_backward(iter, open_iter, '{', '}')) { if(open_iter.starts_line()) // in case of: namespace test\n{ open_iter.backward_char(); auto iter = get_buffer()->get_iter_at_line(open_iter.get_line()); if(get_token(iter) == "namespace") has_right_curly_bracket = close_iter.forward_char() && find_close_symbol_forward(close_iter, close_iter, '{', '}'); } } // Inside for example {}: else if(found_tabs_end_iter.get_line() == tabs_end_iter.get_line()) has_right_curly_bracket = symbol_count(iter, '{', '}') < 0; } } if(!has_right_curly_bracket) { get_buffer()->insert_at_cursor("}"); auto iter = get_buffer()->get_insert()->get_iter(); iter.backward_char(); get_buffer()->place_cursor(iter); scroll_to(get_buffer()->get_insert()); } return false; } // Move right on } in {} else if(event->keyval == GDK_KEY_braceright) { if(*iter == '}' && symbol_count(iter, '{', '}') <= 0) { iter.forward_char(); get_buffer()->place_cursor(iter); scroll_to(get_buffer()->get_insert()); return true; } } // Insert '' else if(event->keyval == GDK_KEY_apostrophe && allow_insertion(iter) && symbol_count(iter, '\'') % 2 == 0) { get_buffer()->insert_at_cursor("''"); auto iter = get_buffer()->get_insert()->get_iter(); iter.backward_char(); get_buffer()->place_cursor(iter); scroll_to(get_buffer()->get_insert()); return true; } // Insert "" else if(event->keyval == GDK_KEY_quotedbl && allow_insertion(iter) && symbol_count(iter, '"') % 2 == 0) { get_buffer()->insert_at_cursor("\"\""); auto iter = get_buffer()->get_insert()->get_iter(); iter.backward_char(); get_buffer()->place_cursor(iter); scroll_to(get_buffer()->get_insert()); return true; } // Move right on last ' in '', or last " in "" else if(((event->keyval == GDK_KEY_apostrophe && *iter == '\'') || (event->keyval == GDK_KEY_quotedbl && *iter == '\"')) && is_spellcheck_iter(iter)) { get_buffer()->place_cursor(next_iter); scroll_to(get_buffer()->get_insert()); return true; } // Insert ; at the end of line, if iter is at the last ) else if(event->keyval == GDK_KEY_semicolon) { if(*iter == ')' && symbol_count(iter, '(', ')') <= 0 && next_iter.ends_line()) { auto start_iter = get_start_of_expression(previous_iter); if(*start_iter == '(') { start_iter.backward_char(); if(*start_iter == ' ') start_iter.backward_char(); auto token = get_token(start_iter); if(token != "for" && token != "if" && token != "while" && token != "else") { iter.forward_char(); get_buffer()->place_cursor(iter); get_buffer()->insert_at_cursor(";"); scroll_to(get_buffer()->get_insert()); return true; } } } } // Delete () else if(event->keyval == GDK_KEY_BackSpace) { if(*previous_iter == '(' && *iter == ')' && symbol_count(iter, '(', ')') <= 0) { auto next_iter = iter; next_iter.forward_char(); get_buffer()->erase(previous_iter, next_iter); scroll_to(get_buffer()->get_insert()); return true; } // Delete [] else if(*previous_iter == '[' && *iter == ']' && symbol_count(iter, '[', ']') <= 0) { auto next_iter = iter; next_iter.forward_char(); get_buffer()->erase(previous_iter, next_iter); scroll_to(get_buffer()->get_insert()); return true; } // Delete {} else if(*previous_iter == '{' && *iter == '}' && symbol_count(iter, '{', '}') <= 0) { auto next_iter = iter; next_iter.forward_char(); get_buffer()->erase(previous_iter, next_iter); scroll_to(get_buffer()->get_insert()); return true; } // Delete '' or "" else if(event->keyval == GDK_KEY_BackSpace) { if((*previous_iter == '\'' && *iter == '\'') || (*previous_iter == '"' && *iter == '"')) { get_buffer()->erase(previous_iter, next_iter); scroll_to(get_buffer()->get_insert()); return true; } } } } return false; } bool Source::View::on_button_press_event(GdkEventButton *event) { // Select range when double clicking if(event->type == GDK_2BUTTON_PRESS) { Gtk::TextIter start, end; get_buffer()->get_selection_bounds(start, end); auto iter = start; while((*iter >= 48 && *iter <= 57) || (*iter >= 65 && *iter <= 90) || (*iter >= 97 && *iter <= 122) || *iter == 95) { start = iter; if(!iter.backward_char()) break; } while((*end >= 48 && *end <= 57) || (*end >= 65 && *end <= 90) || (*end >= 97 && *end <= 122) || *end == 95) { if(!end.forward_char()) break; } get_buffer()->select_range(start, end); return true; } // Go to implementation or declaration if((event->type == GDK_BUTTON_PRESS) && (event->button == 1)) { if(event->state & primary_modifier_mask) { int x, y; window_to_buffer_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, event->x, event->y, x, y); Gtk::TextIter iter; get_iter_at_location(iter, x, y); if(iter) get_buffer()->place_cursor(iter); Menu::get().actions["source_goto_declaration_or_implementation"]->activate(); return true; } } // Open right click menu if((event->type == GDK_BUTTON_PRESS) && (event->button == 3)) { hide_tooltips(); if(!get_buffer()->get_has_selection()) { int x, y; window_to_buffer_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, event->x, event->y, x, y); Gtk::TextIter iter; get_iter_at_location(iter, x, y); if(iter) get_buffer()->place_cursor(iter); Menu::get().right_click_line_menu->popup(event->button, event->time); } else { Menu::get().right_click_selected_menu->popup(event->button, event->time); } return true; } return Gsv::View::on_button_press_event(event); }
38.706802
280
0.583916
jlangvand
4dd89e1e13ed9ecf6e1f145768efcccd5f1ee277
3,052
cpp
C++
examples/desktop/navigationarrow/main.cpp
Qt-Widgets/qtmwidgets-mobile
24b77c25c286215539098ba569eee938882bb9d4
[ "MIT" ]
10
2015-03-22T07:35:48.000Z
2022-02-23T15:49:01.000Z
examples/desktop/navigationarrow/main.cpp
Qt-Widgets/qtmwidgets
24b77c25c286215539098ba569eee938882bb9d4
[ "MIT" ]
9
2020-10-22T09:25:52.000Z
2022-02-14T08:59:13.000Z
examples/desktop/navigationarrow/main.cpp
Qt-Widgets/qtmwidgets
24b77c25c286215539098ba569eee938882bb9d4
[ "MIT" ]
9
2018-01-22T06:47:40.000Z
2022-01-30T16:50:57.000Z
/*! \file \author Igor Mironchik (igor.mironchik at gmail dot com). Copyright (c) 2014 Igor Mironchik 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. */ // Qt include. #include <QApplication> #include <QWidget> #include <QVBoxLayout> #include <QPushButton> #include <QHBoxLayout> // QtMWidgets include. #include <QtMWidgets/NavigationArrow> class Widget : public QWidget { Q_OBJECT public: Widget() { layout = new QVBoxLayout( this ); QHBoxLayout * h = new QHBoxLayout; arrow = new QtMWidgets::NavigationArrow( QtMWidgets::NavigationArrow::Right, this ); arrow2 = new QtMWidgets::NavigationArrow( QtMWidgets::NavigationArrow::Bottom, this ); h->addWidget( arrow ); h->addWidget( arrow2 ); layout->addLayout( h ); QHBoxLayout * hbox = new QHBoxLayout; QPushButton * change = new QPushButton( tr( "Change Direction" ), this ); hbox->addWidget( change ); connect( change, SIGNAL( clicked() ), this, SLOT( changeDirection() ) ); QPushButton * ani = new QPushButton( tr( "Animate" ), this ); hbox->addWidget( ani ); connect( ani, SIGNAL( clicked() ), this, SLOT( animate() ) ); layout->addLayout( hbox ); resize( 300, 150 ); } private slots: void changeDirection() { if( arrow->direction() == QtMWidgets::NavigationArrow::Left ) arrow->setDirection( QtMWidgets::NavigationArrow::Right ); else arrow->setDirection( QtMWidgets::NavigationArrow::Left ); if( arrow2->direction() == QtMWidgets::NavigationArrow::Top ) arrow2->setDirection( QtMWidgets::NavigationArrow::Bottom ); else arrow2->setDirection( QtMWidgets::NavigationArrow::Top ); } void animate() { arrow->animate(); arrow2->animate(); } private: QtMWidgets::NavigationArrow * arrow; QtMWidgets::NavigationArrow * arrow2; QVBoxLayout * layout; }; int main( int argc, char ** argv ) { QApplication app( argc, argv ); Widget w; w.show(); return app.exec(); } #include "main.moc"
25.647059
76
0.694954
Qt-Widgets
4de16548767f0fc644ae9870d1b136d59b816def
484
cxx
C++
src/ThreadEddyMotionCorrect.cxx
dzenanz/DTIPrep
38fe0b6f5461dc83af22f24033caa3d5f005e94b
[ "Apache-2.0" ]
12
2015-07-24T15:33:15.000Z
2020-10-19T23:13:28.000Z
src/ThreadEddyMotionCorrect.cxx
scalphunters/DTIPrep
5fea149c2c5deb13bc71507640a4645326778bb1
[ "Apache-2.0" ]
31
2015-01-02T18:50:46.000Z
2020-12-01T16:51:00.000Z
src/ThreadEddyMotionCorrect.cxx
scalphunters/DTIPrep
5fea149c2c5deb13bc71507640a4645326778bb1
[ "Apache-2.0" ]
11
2015-08-05T15:07:17.000Z
2019-12-13T19:32:19.000Z
#include "ThreadEddyMotionCorrect.h" #include <iostream> #include <string> #include <math.h> CThreadEddyMotionCorrect::CThreadEddyMotionCorrect(QObject *parentLocal) : QThread(parentLocal) { } CThreadEddyMotionCorrect::~CThreadEddyMotionCorrect() { } void CThreadEddyMotionCorrect::run() { emit allDone("transform begings"); for( int i = 0; i < 10000; i++ ) { emit kkk( ( i + 1 ) / 100 ); std::cout << i << std::endl; } emit allDone("Transform ends"); }
17.285714
74
0.67562
dzenanz
4de1da92261274e068b00ac79c4a1fdf2a1d640e
368
cpp
C++
answers/leetcode/Excel Sheet Column Number/Excel Sheet Column Number.cpp
FeiZhan/Algo-Collection
708c4a38112e0b381864809788b9e44ac5ae4d05
[ "MIT" ]
3
2015-09-04T21:32:31.000Z
2020-12-06T00:37:32.000Z
answers/leetcode/Excel Sheet Column Number/Excel Sheet Column Number.cpp
FeiZhan/Algo-Collection
708c4a38112e0b381864809788b9e44ac5ae4d05
[ "MIT" ]
null
null
null
answers/leetcode/Excel Sheet Column Number/Excel Sheet Column Number.cpp
FeiZhan/Algo-Collection
708c4a38112e0b381864809788b9e44ac5ae4d05
[ "MIT" ]
null
null
null
//@result 1000 / 1000 test cases passed. Status: Accepted Runtime: 12 ms Submitted: 0 minutes ago You are here! Your runtime beats 8.80% of cpp submissions. class Solution { public: int titleToNumber(string s) { size_t pos = 0; int title = 0; while (pos < s.length()) { title = title * 26 + static_cast<int> (s[pos ++] - 'A') + 1; } return title; } };
26.285714
156
0.646739
FeiZhan
4de1e6ea25fb7a5f8a2ac2988c1414c88e5a2021
4,504
cpp
C++
tdmq/src/v20200217/model/ModifyRocketMQNamespaceRequest.cpp
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
1
2022-01-27T09:27:34.000Z
2022-01-27T09:27:34.000Z
tdmq/src/v20200217/model/ModifyRocketMQNamespaceRequest.cpp
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
null
null
null
tdmq/src/v20200217/model/ModifyRocketMQNamespaceRequest.cpp
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <tencentcloud/tdmq/v20200217/model/ModifyRocketMQNamespaceRequest.h> #include <tencentcloud/core/utils/rapidjson/document.h> #include <tencentcloud/core/utils/rapidjson/writer.h> #include <tencentcloud/core/utils/rapidjson/stringbuffer.h> using namespace TencentCloud::Tdmq::V20200217::Model; using namespace std; ModifyRocketMQNamespaceRequest::ModifyRocketMQNamespaceRequest() : m_clusterIdHasBeenSet(false), m_namespaceIdHasBeenSet(false), m_ttlHasBeenSet(false), m_retentionTimeHasBeenSet(false), m_remarkHasBeenSet(false) { } string ModifyRocketMQNamespaceRequest::ToJsonString() const { rapidjson::Document d; d.SetObject(); rapidjson::Document::AllocatorType& allocator = d.GetAllocator(); if (m_clusterIdHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "ClusterId"; iKey.SetString(key.c_str(), allocator); d.AddMember(iKey, rapidjson::Value(m_clusterId.c_str(), allocator).Move(), allocator); } if (m_namespaceIdHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "NamespaceId"; iKey.SetString(key.c_str(), allocator); d.AddMember(iKey, rapidjson::Value(m_namespaceId.c_str(), allocator).Move(), allocator); } if (m_ttlHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "Ttl"; iKey.SetString(key.c_str(), allocator); d.AddMember(iKey, m_ttl, allocator); } if (m_retentionTimeHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "RetentionTime"; iKey.SetString(key.c_str(), allocator); d.AddMember(iKey, m_retentionTime, allocator); } if (m_remarkHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "Remark"; iKey.SetString(key.c_str(), allocator); d.AddMember(iKey, rapidjson::Value(m_remark.c_str(), allocator).Move(), allocator); } rapidjson::StringBuffer buffer; rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); d.Accept(writer); return buffer.GetString(); } string ModifyRocketMQNamespaceRequest::GetClusterId() const { return m_clusterId; } void ModifyRocketMQNamespaceRequest::SetClusterId(const string& _clusterId) { m_clusterId = _clusterId; m_clusterIdHasBeenSet = true; } bool ModifyRocketMQNamespaceRequest::ClusterIdHasBeenSet() const { return m_clusterIdHasBeenSet; } string ModifyRocketMQNamespaceRequest::GetNamespaceId() const { return m_namespaceId; } void ModifyRocketMQNamespaceRequest::SetNamespaceId(const string& _namespaceId) { m_namespaceId = _namespaceId; m_namespaceIdHasBeenSet = true; } bool ModifyRocketMQNamespaceRequest::NamespaceIdHasBeenSet() const { return m_namespaceIdHasBeenSet; } uint64_t ModifyRocketMQNamespaceRequest::GetTtl() const { return m_ttl; } void ModifyRocketMQNamespaceRequest::SetTtl(const uint64_t& _ttl) { m_ttl = _ttl; m_ttlHasBeenSet = true; } bool ModifyRocketMQNamespaceRequest::TtlHasBeenSet() const { return m_ttlHasBeenSet; } uint64_t ModifyRocketMQNamespaceRequest::GetRetentionTime() const { return m_retentionTime; } void ModifyRocketMQNamespaceRequest::SetRetentionTime(const uint64_t& _retentionTime) { m_retentionTime = _retentionTime; m_retentionTimeHasBeenSet = true; } bool ModifyRocketMQNamespaceRequest::RetentionTimeHasBeenSet() const { return m_retentionTimeHasBeenSet; } string ModifyRocketMQNamespaceRequest::GetRemark() const { return m_remark; } void ModifyRocketMQNamespaceRequest::SetRemark(const string& _remark) { m_remark = _remark; m_remarkHasBeenSet = true; } bool ModifyRocketMQNamespaceRequest::RemarkHasBeenSet() const { return m_remarkHasBeenSet; }
26.494118
96
0.732682
suluner
4de31b71452a6d5c691aae0e7af3f36e6ee435b6
34,119
cpp
C++
src/AmpleObject.cpp
elmindreda/Ample
7366b8591d8cd1f09ae03a6dd728130769891ba5
[ "BSD-3-Clause" ]
4
2015-02-25T17:43:10.000Z
2016-07-29T14:14:02.000Z
src/AmpleObject.cpp
elmindreda/Ample
7366b8591d8cd1f09ae03a6dd728130769891ba5
[ "BSD-3-Clause" ]
null
null
null
src/AmpleObject.cpp
elmindreda/Ample
7366b8591d8cd1f09ae03a6dd728130769891ba5
[ "BSD-3-Clause" ]
null
null
null
//--------------------------------------------------------------------- // Simple C++ retained mode library for Verse // Copyright (c) PDC, KTH // Written by Camilla Berglund <elmindreda@elmindreda.org> //--------------------------------------------------------------------- #include <verse.h> #include <Ample.h> namespace verse { namespace ample { //--------------------------------------------------------------------- MethodParam::MethodParam(const std::string& name, VNOParamType type): mName(name), mType(type) { } size_t MethodParam::getSize(void) const { switch (mType) { case VN_O_METHOD_PTYPE_INT8: case VN_O_METHOD_PTYPE_UINT8: return sizeof(uint8); case VN_O_METHOD_PTYPE_INT16: case VN_O_METHOD_PTYPE_UINT16: return sizeof(uint16); case VN_O_METHOD_PTYPE_INT32: case VN_O_METHOD_PTYPE_UINT32: return sizeof(uint32); case VN_O_METHOD_PTYPE_REAL32: return sizeof(real32); case VN_O_METHOD_PTYPE_REAL64: return sizeof(real64); case VN_O_METHOD_PTYPE_REAL32_VEC2: return sizeof(real32) * 2; case VN_O_METHOD_PTYPE_REAL32_VEC3: return sizeof(real32) * 3; case VN_O_METHOD_PTYPE_REAL32_VEC4: return sizeof(real32) * 4; case VN_O_METHOD_PTYPE_REAL64_VEC2: return sizeof(real64) * 2; case VN_O_METHOD_PTYPE_REAL64_VEC3: return sizeof(real64) * 3; case VN_O_METHOD_PTYPE_REAL64_VEC4: return sizeof(real64) * 4; case VN_O_METHOD_PTYPE_REAL32_MAT4: return sizeof(real32) * 4; case VN_O_METHOD_PTYPE_REAL32_MAT9: return sizeof(real32) * 9; case VN_O_METHOD_PTYPE_REAL32_MAT16: return sizeof(real32) * 16; case VN_O_METHOD_PTYPE_REAL64_MAT4: return sizeof(real64) * 4; case VN_O_METHOD_PTYPE_REAL64_MAT9: return sizeof(real64) * 9; case VN_O_METHOD_PTYPE_REAL64_MAT16: return sizeof(real64) * 16; case VN_O_METHOD_PTYPE_STRING: return 500; case VN_O_METHOD_PTYPE_NODE: return sizeof(VNodeID); case VN_O_METHOD_PTYPE_LAYER: return sizeof(VLayerID); } } //--------------------------------------------------------------------- void Method::destroy(void) { mGroup.getNode().getSession().push(); verse_send_o_method_destroy(mGroup.getNode().getID(), mGroup.getID(), mID); mGroup.getNode().getSession().pop(); } bool Method::call(const MethodArgumentList& arguments, VNodeID senderID) { if (arguments.size() != mParams.size()) return false; // NOTE: This call isn't strictly portable, as we're assuming // that &v[0] on an STL vector leads to a regular array. // In other words; this is bad, don't do this. VNOPackedParams* packedArguments = verse_method_call_pack(mTypes.size(), &mTypes[0], &arguments[0]); mGroup.getNode().getSession().push(); verse_send_o_method_call(mGroup.getNode().getID(), mGroup.getID(), mID, senderID, packedArguments); mGroup.getNode().getSession().pop(); free(packedArguments); } uint16 Method::getID(void) const { return mID; } const std::string& Method::getName(void) const { return mName; } uint8 Method::getParamCount(void) const { return mParams.size(); } const MethodParam& Method::getParam(uint8 index) { return mParams[index]; } MethodGroup& Method::getGroup(void) const { return mGroup; } Method::Method(uint16 ID, const std::string& name, MethodGroup& group): mID(ID), mName(name), mGroup(group) { } void Method::initialize(void) { verse_callback_set((void*) verse_send_o_method_call, (void*) receiveMethodCall, NULL); } void Method::receiveMethodCall(void* user, VNodeID nodeID, uint16 groupID, uint16 methodID, VNodeID senderID, const VNOPackedParams* arguments) { Session* session = Session::getCurrent(); ObjectNode* node = dynamic_cast<ObjectNode*>(session->getNodeByID(nodeID)); if (!node) return; MethodGroup* group = node->getMethodGroupByID(groupID); if (!group) return; Method* method = group->getMethodByID(methodID); if (!method) return; MethodArgumentList unpackedArguments; unpackedArguments.resize(method->mParams.size()); verse_method_call_unpack(arguments, method->mParams.size(), &(method->mTypes[0]), &unpackedArguments[0]); const ObserverList& observers = method->getObservers(); for (ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) (*i)->onCall(*method, unpackedArguments); } //--------------------------------------------------------------------- void MethodObserver::onCall(Method& method, const MethodArgumentList& arguments) { } void MethodObserver::onSetName(Method& method, const std::string& name) { } void MethodObserver::onDestroy(Method& method) { } //--------------------------------------------------------------------- void MethodGroup::destroy(void) { mNode.getSession().push(); verse_send_o_method_group_destroy(mNode.getID(), mID); mNode.getSession().pop(); } void MethodGroup::createMethod(const std::string& name, const MethodParamList& parameters) { const char** names; VNOParamType* types; names = (const char**) new char* [parameters.size()]; types = new VNOParamType [parameters.size()]; for (unsigned int i = 0; i < parameters.size(); i++) { types[i] = parameters[i].mType; names[i] = parameters[i].mName.c_str(); } mNode.getSession().push(); verse_send_o_method_create(mNode.getID(), mID, (uint16) ~0, name.c_str(), parameters.size(), types, names); mNode.getSession().pop(); delete types; delete names; } Method* MethodGroup::getMethodByID(uint16 methodID) { for (MethodList::iterator i = mMethods.begin(); i != mMethods.end(); i++) if ((*i)->getID() == methodID) return *i; return NULL; } const Method* MethodGroup::getMethodByID(uint16 methodID) const { for (MethodList::const_iterator i = mMethods.begin(); i != mMethods.end(); i++) if ((*i)->getID() == methodID) return *i; return NULL; } Method* MethodGroup::getMethodByIndex(unsigned int index) { return mMethods[index]; } const Method* MethodGroup::getMethodByIndex(unsigned int index) const { return mMethods[index]; } Method* MethodGroup::getMethodByName(const std::string& name) { for (MethodList::iterator i = mMethods.begin(); i != mMethods.end(); i++) if ((*i)->getName() == name) return *i; return NULL; } const Method* MethodGroup::getMethodByName(const std::string& name) const { for (MethodList::const_iterator i = mMethods.begin(); i != mMethods.end(); i++) if ((*i)->getName() == name) return *i; return NULL; } unsigned int MethodGroup::getMethodCount(void) const { return mMethods.size(); } const uint16 MethodGroup::getID(void) const { return mID; } const std::string& MethodGroup::getName(void) const { return mName; } ObjectNode& MethodGroup::getNode(void) const { return mNode; } MethodGroup::MethodGroup(uint16 ID, const std::string& name, ObjectNode& node): mID(ID), mName(name), mNode(node) { } MethodGroup::~MethodGroup(void) { while (mMethods.size()) { delete mMethods.back(); mMethods.pop_back(); } } void MethodGroup::initialize(void) { Method::initialize(); verse_callback_set((void*) verse_send_o_method_create, (void*) receiveMethodCreate, NULL); verse_callback_set((void*) verse_send_o_method_destroy, (void*) receiveMethodDestroy, NULL); } void MethodGroup::receiveMethodCreate(void* user, VNodeID nodeID, uint16 groupID, uint16 methodID, const char* name, uint8 paramCount, const VNOParamType* paramTypes, const char** paramNames) { Session* session = Session::getCurrent(); ObjectNode* node = dynamic_cast<ObjectNode*>(session->getNodeByID(nodeID)); if (!node) return; MethodGroup* group = node->getMethodGroupByID(groupID); if (!group) return; Method* method = group->getMethodByID(methodID); if (method) { if (method->mName != name) { const Method::ObserverList& observers = method->getObservers(); for (Method::ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) (*i)->onSetName(*method, name); method->mName = name; method->updateDataVersion(); } // TODO: Notify observers of parameter changes. } else { method = new Method(methodID, name, *group); for (unsigned int i = 0; i < paramCount; i++) { method->mParams.push_back(MethodParam(paramNames[i], paramTypes[i])); method->mTypes.push_back(paramTypes[i]); } group->mMethods.push_back(method); group->updateStructureVersion(); const MethodGroup::ObserverList& observers = group->getObservers(); for (MethodGroup::ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) (*i)->onCreateMethod(*group, *method); } } void MethodGroup::receiveMethodDestroy(void* user, VNodeID nodeID, uint16 groupID, uint16 methodID) { Session* session = Session::getCurrent(); ObjectNode* node = dynamic_cast<ObjectNode*>(session->getNodeByID(nodeID)); if (!node) return; MethodGroup* group = node->getMethodGroupByID(groupID); if (!group) return; MethodList& methods = group->mMethods; for (MethodList::iterator method = methods.begin(); method != methods.end(); method++) { if ((*method)->getID() == methodID) { // Notify method observers. { const Method::ObserverList& observers = (*method)->getObservers(); for (Method::ObserverList::const_iterator observer = observers.begin(); observer != observers.end(); observer++) (*observer)->onDestroy(*(*method)); } // Notify method group observers. { const ObserverList& observers = group->getObservers(); for (ObserverList::const_iterator observer = observers.begin(); observer != observers.end(); observer++) (*observer)->onDestroyMethod(*group, *(*method)); } delete *method; methods.erase(method); group->updateStructureVersion(); break; } } } //--------------------------------------------------------------------- void MethodGroupObserver::onCreateMethod(MethodGroup& group, Method& method) { } void MethodGroupObserver::onDestroyMethod(MethodGroup& group, Method& method) { } void MethodGroupObserver::onSetName(MethodGroup& group, const std::string& name) { } void MethodGroupObserver::onDestroy(MethodGroup& group) { } //--------------------------------------------------------------------- void Link::destroy(void) { mNode.getSession().push(); verse_send_o_link_destroy(mNode.getID(), mID); mNode.getSession().pop(); } uint16 Link::getID(void) const { return mID; } VNodeID Link::getLinkedNodeID(void) const { return mState.mNodeID; } Node* Link::getLinkedNode(void) const { return mNode.getSession().getNodeByID(mState.mNodeID); } void Link::setLinkedNode(VNodeID nodeID) { mCache.mNodeID = nodeID; sendData(); } VNodeID Link::getTargetNodeID(void) const { return mState.mTargetID; } Node* Link::getTargetNode(void) const { return mNode.getSession().getNodeByID(mState.mTargetID); } void Link::setTargetNode(VNodeID nodeID) { mCache.mTargetID = nodeID; sendData(); } const std::string& Link::getName(void) const { return mState.mName; } void Link::setName(const std::string& name) { mCache.mName = name; sendData(); } ObjectNode& Link::getNode(void) const { return mNode; } Link::Link(uint16 ID, const std::string& name, VNodeID nodeID, VNodeID targetID, ObjectNode& node): mID(ID), mNode(node) { mCache.mName = mState.mName = name; mCache.mNodeID = mState.mNodeID = nodeID; mCache.mTargetID = mState.mTargetID = targetID; } void Link::sendData(void) { mNode.getSession().push(); verse_send_o_link_set(mNode.getID(), mID, mCache.mNodeID, mCache.mName.c_str(), mCache.mTargetID); mNode.getSession().pop(); } void Link::receiveLinkSet(void* user, VNodeID nodeID, uint16 linkID, VNodeID linkedNodeID, const char* name, uint32 targetNodeID) { if (mState.mName != name) { const Link::ObserverList& observers = getObservers(); for (Link::ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) (*i)->onSetName(*this, name); mCache.mName = mState.mName = name; updateDataVersion(); } if (mState.mNodeID != linkedNodeID) { const Link::ObserverList& observers = getObservers(); for (Link::ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) (*i)->onSetLinkedNode(*this, linkedNodeID); mCache.mNodeID = mState.mNodeID = linkedNodeID; updateDataVersion(); } if (mState.mTargetID != targetNodeID) { const Link::ObserverList& observers = getObservers(); for (Link::ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) (*i)->onSetTargetNode(*this, targetNodeID); mCache.mTargetID = mState.mTargetID = targetNodeID; updateDataVersion(); } } //--------------------------------------------------------------------- void LinkObserver::onSetLinkedNode(Link& link, VNodeID nodeID) { } void LinkObserver::onSetTargetNode(Link& link, VNodeID targetID) { } void LinkObserver::onSetName(Link& link, const std::string name) { } void LinkObserver::onDestroy(Link& link) { } //--------------------------------------------------------------------- void ObjectNode::createMethodGroup(const std::string& name) { getSession().push(); verse_send_o_method_group_create(getID(), (uint16) ~0, name.c_str()); getSession().pop(); } void ObjectNode::createLink(const std::string& name, VNodeID nodeID, VNodeID targetID) { getSession().push(); verse_send_o_link_set(getID(), (uint16) ~0, nodeID, name.c_str(), targetID); getSession().pop(); } bool ObjectNode::isLight(void) const { return mIntensity.r == 0.f && mIntensity.g == 0.f && mIntensity.b == 0.f; } void ObjectNode::setLightIntensity(const ColorRGB& intensity) { getSession().push(); verse_send_o_light_set(getID(), intensity.r, intensity.g, intensity.b); getSession().pop(); } const ColorRGB& ObjectNode::getLightIntensity(void) const { return mIntensity; } MethodGroup* ObjectNode::getMethodGroupByID(uint16 groupID) { for (MethodGroupList::iterator i = mGroups.begin(); i != mGroups.end(); i++) if ((*i)->getID() == groupID) return *i; return NULL; } const MethodGroup* ObjectNode::getMethodGroupByID(uint16 groupID) const { for (MethodGroupList::const_iterator i = mGroups.begin(); i != mGroups.end(); i++) if ((*i)->getID() == groupID) return *i; return NULL; } MethodGroup* ObjectNode::getMethodGroupByIndex(unsigned int index) { return mGroups[index]; } const MethodGroup* ObjectNode::getMethodGroupByIndex(unsigned int index) const { return mGroups[index]; } MethodGroup* ObjectNode::getMethodGroupByName(const std::string& name) { for (MethodGroupList::iterator i = mGroups.begin(); i != mGroups.end(); i++) if ((*i)->getName() == name) return *i; return NULL; } const MethodGroup* ObjectNode::getMethodGroupByName(const std::string& name) const { for (MethodGroupList::const_iterator i = mGroups.begin(); i != mGroups.end(); i++) if ((*i)->getName() == name) return *i; return NULL; } unsigned int ObjectNode::getMethodGroupCount(void) const { return mGroups.size(); } Link* ObjectNode::getLinkByID(uint16 linkID) { for (LinkList::iterator i = mLinks.begin(); i != mLinks.end(); i++) if ((*i)->getID() == linkID) return *i; return NULL; } const Link* ObjectNode::getLinkByID(uint16 linkID) const { for (LinkList::const_iterator i = mLinks.begin(); i != mLinks.end(); i++) if ((*i)->getID() == linkID) return *i; return NULL; } Link* ObjectNode::getLinkByIndex(unsigned int index) { return mLinks[index]; } const Link* ObjectNode::getLinkByIndex(unsigned int index) const { return mLinks[index]; } Link* ObjectNode::getLinkByName(const std::string& name) { for (LinkList::iterator i = mLinks.begin(); i != mLinks.end(); i++) if ((*i)->getName() == name) return *i; return NULL; } const Link* ObjectNode::getLinkByName(const std::string& name) const { for (LinkList::const_iterator i = mLinks.begin(); i != mLinks.end(); i++) if ((*i)->getName() == name) return *i; return NULL; } unsigned int ObjectNode::getLinkCount(void) const { return mLinks.size(); } Node* ObjectNode::getNodeByLinkName(const std::string& name) const { const Link* link = getLinkByName(name); if (!link) return NULL; return link->getLinkedNode(); } void ObjectNode::setTranslation(const Translation& translation) { mTranslationCache = translation; sendTranslation(); } void ObjectNode::setRotation(const Rotation& rotation) { mRotationCache = rotation; sendRotation(); } const Vector3d& ObjectNode::getPosition(void) const { return mTranslation.mPosition; } void ObjectNode::setPosition(const Vector3d& position) { mTranslationCache.mPosition = position; sendTranslation(); } const Vector3d& ObjectNode::getSpeed(void) const { return mTranslation.mSpeed; } void ObjectNode::setSpeed(const Vector3d& speed) { mTranslationCache.mSpeed = speed; sendTranslation(); } const Vector3d& ObjectNode::getAccel(void) const { return mTranslation.mAccel; } void ObjectNode::setAccel(const Vector3d& accel) { mTranslationCache.mAccel = accel; sendTranslation(); } const Quaternion64& ObjectNode::getRotation(void) const { return mRotation.mRotation; } void ObjectNode::setRotation(const Quaternion64& rotation) { mRotationCache.mRotation = rotation; sendRotation(); } const Quaternion64& ObjectNode::getRotationSpeed(void) const { return mRotation.mSpeed; } void ObjectNode::setRotationSpeed(const Quaternion64& speed) { mRotationCache.mSpeed = speed; sendRotation(); } const Quaternion64& ObjectNode::getRotationAccel(void) const { return mRotation.mAccel; } void ObjectNode::setRotationAccel(const Quaternion64& accel) { mRotationCache.mAccel = accel; sendRotation(); } const Vector3d& ObjectNode::getScale(void) const { return mScale; } void ObjectNode::setScale(const Vector3d& scale) { getSession().push(); verse_send_o_transform_scale_real64(getID(), scale.x, scale.y, scale.z); getSession().pop(); } ObjectNode::ObjectNode(VNodeID ID, VNodeOwner owner, Session& session): Node(ID, V_NT_OBJECT, owner, session) { } ObjectNode::~ObjectNode(void) { while (mLinks.size()) { delete mLinks.back(); mLinks.pop_back(); } while (mGroups.size()) { delete mGroups.back(); mGroups.pop_back(); } } void ObjectNode::sendTranslation(void) { getSession().push(); verse_send_o_transform_pos_real64(getID(), mTranslationCache.mSeconds, mTranslationCache.mFraction, mTranslationCache.mPosition, mTranslationCache.mSpeed, mTranslationCache.mAccel, mTranslationCache.mDragNormal, mTranslationCache.mDrag); getSession().pop(); } void ObjectNode::sendRotation(void) { getSession().push(); verse_send_o_transform_rot_real64(getID(), mRotationCache.mSeconds, mRotationCache.mFraction, &mRotationCache.mRotation, &mRotationCache.mSpeed, &mRotationCache.mAccel, &mRotationCache.mDragNormal, mRotationCache.mDrag); getSession().pop(); } void ObjectNode::initialize(void) { MethodGroup::initialize(); verse_callback_set((void*) verse_send_o_transform_pos_real32, (void*) receiveTransformPosReal32, NULL); verse_callback_set((void*) verse_send_o_transform_rot_real32, (void*) receiveTransformRotReal32, NULL); verse_callback_set((void*) verse_send_o_transform_scale_real32, (void*) receiveTransformScaleReal32, NULL); verse_callback_set((void*) verse_send_o_transform_pos_real64, (void*) receiveTransformPosReal64, NULL); verse_callback_set((void*) verse_send_o_transform_rot_real64, (void*) receiveTransformRotReal64, NULL); verse_callback_set((void*) verse_send_o_transform_scale_real64, (void*) receiveTransformScaleReal64, NULL); verse_callback_set((void*) verse_send_o_light_set, (void*) receiveLightSet, NULL); verse_callback_set((void*) verse_send_o_link_set, (void*) receiveLinkSet, NULL); verse_callback_set((void*) verse_send_o_link_destroy, (void*) receiveLinkDestroy, NULL); verse_callback_set((void*) verse_send_o_method_group_create, (void*) receiveMethodGroupCreate, NULL); verse_callback_set((void*) verse_send_o_method_group_destroy, (void*) receiveMethodGroupDestroy, NULL); verse_callback_set((void*) verse_send_o_anim_run, (void*) receiveAnimRun, NULL); } void ObjectNode::receiveTransformPosReal32(void* user, VNodeID nodeID, uint32 seconds, uint32 fraction, const real32* position, const real32* speed, const real32* accel, const real32* dragNormal, real32 drag) { } void ObjectNode::receiveTransformRotReal32(void* user, VNodeID nodeID, uint32 seconds, uint32 fraction, const VNQuat32* rotation, const VNQuat32* speed, const VNQuat32* accelerate, const VNQuat32* dragNormal, real32 drag) { } void ObjectNode::receiveTransformScaleReal32(void* user, VNodeID nodeID, real32 scaleX, real32 scaleY, real32 scaleZ) { } void ObjectNode::receiveTransformPosReal64(void* user, VNodeID nodeID, uint32 seconds, uint32 fraction, const real64* position, const real64* speed, const real64* accel, const real64* dragNormal, real64 drag) { Session* session = Session::getCurrent(); ObjectNode* node = dynamic_cast<ObjectNode*>(session->getNodeByID(nodeID)); if (!node) return; // TODO: Add observer notifications. if (position) { Vector3d pos(position[0], position[1], position[2]); const ObserverList& observers = node->getObservers(); for (ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) { if (ObjectNodeObserver* observer = dynamic_cast<ObjectNodeObserver*>(*i)) observer->onSetPosition(*node, pos); } node->mTranslation.mPosition.set(position[0], position[1], position[2]); node->mTranslationCache.mPosition = node->mTranslation.mPosition; } if (speed) { node->mTranslation.mSpeed.set(speed[0], speed[1], speed[2]); node->mTranslationCache.mSpeed = node->mTranslation.mSpeed; } if (accel) { node->mTranslation.mAccel.set(accel[0], accel[1], accel[2]); node->mTranslationCache.mAccel = node->mTranslation.mAccel; } if (dragNormal) { node->mTranslation.mDragNormal.set(dragNormal[0], dragNormal[1], dragNormal[2]); node->mTranslationCache.mDragNormal = node->mTranslation.mDragNormal; node->mTranslationCache.mDrag = node->mTranslation.mDrag = drag; } node->mTranslationCache.mSeconds = node->mTranslation.mSeconds = seconds; node->mTranslationCache.mFraction = node->mTranslation.mFraction = fraction; node->updateDataVersion(); } void ObjectNode::receiveTransformRotReal64(void* user, VNodeID nodeID, uint32 seconds, uint32 fraction, const VNQuat64* rotation, const VNQuat64* speed, const VNQuat64* accel, const VNQuat64* dragNormal, real64 drag) { Session* session = Session::getCurrent(); ObjectNode* node = dynamic_cast<ObjectNode*>(session->getNodeByID(nodeID)); if (!node) return; // TODO: Add observer notifications. if (rotation) { Quaternion64 rot(rotation->x, rotation->y, rotation->z, rotation->w); const ObserverList& observers = node->getObservers(); for (ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) { if (ObjectNodeObserver* observer = dynamic_cast<ObjectNodeObserver*>(*i)) observer->onSetRotation(*node, rot); } node->mRotation.mRotation = *rotation; node->mRotationCache.mRotation = *rotation; } if (speed) { node->mRotation.mSpeed = *speed; node->mRotationCache.mSpeed = *speed; } if (accel) { node->mRotation.mAccel = *accel; node->mRotationCache.mAccel = *accel; } if (dragNormal) { node->mRotation.mDragNormal = *dragNormal; node->mRotationCache.mDragNormal = *dragNormal; node->mRotationCache.mDrag = node->mRotation.mDrag = drag; } node->mRotationCache.mSeconds = node->mRotation.mSeconds = seconds; node->mRotationCache.mFraction = node->mRotation.mFraction = fraction; node->updateDataVersion(); } void ObjectNode::receiveTransformScaleReal64(void* user, VNodeID nodeID, real64 scaleX, real64 scaleY, real64 scaleZ) { Session* session = Session::getCurrent(); ObjectNode* node = dynamic_cast<ObjectNode*>(session->getNodeByID(nodeID)); if (!node) return; Vector3d scale(scaleX, scaleY, scaleZ); const ObserverList& observers = node->getObservers(); for (ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) { if (ObjectNodeObserver* observer = dynamic_cast<ObjectNodeObserver*>(*i)) observer->onSetScale(*node, scale); } node->mScale = scale; node->updateDataVersion(); } void ObjectNode::receiveLightSet(void* user, VNodeID nodeID, real64 lightR, real64 lightG, real64 lightB) { Session* session = Session::getCurrent(); ObjectNode* node = dynamic_cast<ObjectNode*>(session->getNodeByID(nodeID)); if (!node) return; ColorRGB intensity(lightR, lightG, lightB); const ObserverList& observers = node->getObservers(); for (ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) { if (ObjectNodeObserver* observer = dynamic_cast<ObjectNodeObserver*>(*i)) observer->onSetLightIntensity(*node, intensity); } node->mIntensity = intensity; node->updateDataVersion(); } void ObjectNode::receiveLinkSet(void* user, VNodeID nodeID, uint16 linkID, VNodeID linkedNodeID, const char* name, uint32 targetNodeID) { Session* session = Session::getCurrent(); ObjectNode* node = dynamic_cast<ObjectNode*>(session->getNodeByID(nodeID)); if (!node) return; Link* link = node->getLinkByID(linkID); if (link) link->receiveLinkSet(user, nodeID, linkID, linkedNodeID, name, targetNodeID); else { link = new Link(linkID, name, linkedNodeID, targetNodeID, *node); node->mLinks.push_back(link); node->updateStructureVersion(); const ObserverList& observers = node->getObservers(); for (ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) { if (ObjectNodeObserver* observer = dynamic_cast<ObjectNodeObserver*>(*i)) observer->onCreateLink(*node, *link); } } } void ObjectNode::receiveLinkDestroy(void* user, VNodeID nodeID, uint16 linkID) { Session* session = Session::getCurrent(); ObjectNode* node = dynamic_cast<ObjectNode*>(session->getNodeByID(nodeID)); if (!node) return; for (LinkList::iterator link = node->mLinks.begin(); link != node->mLinks.end(); link++) { if ((*link)->getID() == linkID) { // Notify link observers. { const Link::ObserverList& observers = (*link)->getObservers(); for (Link::ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) (*i)->onDestroy(*(*link)); } // Notify node observers. { const ObserverList& observers = node->getObservers(); for (ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) { if (ObjectNodeObserver* observer = dynamic_cast<ObjectNodeObserver*>(*i)) observer->onDestroyLink(*node, *(*link)); } } delete *link; node->mLinks.erase(link); node->updateStructureVersion(); break; } } } void ObjectNode::receiveMethodGroupCreate(void* user, VNodeID nodeID, uint16 groupID, const char* name) { Session* session = Session::getCurrent(); ObjectNode* node = dynamic_cast<ObjectNode*>(session->getNodeByID(nodeID)); if (!node) return; MethodGroup* group = node->getMethodGroupByID(groupID); if (group) { if (group->getName() != name) { // TODO: Move this into MethodGroup. const MethodGroup::ObserverList& observers = group->getObservers(); for (MethodGroup::ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) (*i)->onSetName(*group, name); group->mName = name; group->updateDataVersion(); } } else { group = new MethodGroup(groupID, name, *node); node->mGroups.push_back(group); node->updateStructureVersion(); const ObserverList& observers = node->getObservers(); for (ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) { if (ObjectNodeObserver* observer = dynamic_cast<ObjectNodeObserver*>(*i)) observer->onCreateMethodGroup(*node, *group); } verse_send_o_method_group_subscribe(node->getID(), groupID); } } void ObjectNode::receiveMethodGroupDestroy(void* user, VNodeID nodeID, uint16 groupID) { Session* session = Session::getCurrent(); ObjectNode* node = dynamic_cast<ObjectNode*>(session->getNodeByID(nodeID)); if (!node) return; MethodGroupList& groups = node->mGroups; for (MethodGroupList::iterator group = groups.begin(); group != groups.end(); group++) { if ((*group)->getID() == groupID) { // Notify method group observers. { const MethodGroup::ObserverList& observers = (*group)->getObservers(); for (MethodGroup::ObserverList::const_iterator observer = observers.begin(); observer != observers.end(); observer++) (*observer)->onDestroy(**group); } // Notify node observers. { const Node::ObserverList& observers = node->getObservers(); for (Node::ObserverList::const_iterator i = observers.begin(); i != observers.end(); i++) { if (ObjectNodeObserver* observer = dynamic_cast<ObjectNodeObserver*>(*i)) observer->onDestroyMethodGroup(*node, **group); } } delete *group; groups.erase(group); node->updateStructureVersion(); break; } } } void ObjectNode::receiveAnimRun(void* user, VNodeID nodeID, uint16 linkID, uint32 seconds, uint32 fraction, real64 pos, real64 speed, real64 accel, real64 scale, real64 scaleSpeed) { } //--------------------------------------------------------------------- void ObjectNodeObserver::onSetPosition(ObjectNode& node, Vector3d& position) { } void ObjectNodeObserver::onSetRotation(ObjectNode& node, Quaternion64& rotation) { } void ObjectNodeObserver::onSetScale(ObjectNode& node, Vector3d& scale) { } void ObjectNodeObserver::onCreateMethodGroup(ObjectNode& node, MethodGroup& group) { } void ObjectNodeObserver::onDestroyMethodGroup(ObjectNode& node, MethodGroup& group) { } void ObjectNodeObserver::onCreateLink(ObjectNode& node, Link& link) { } void ObjectNodeObserver::onDestroyLink(ObjectNode& node, Link& link) { } void ObjectNodeObserver::onSetLightIntensity(ObjectNode& node, const ColorRGB& color) { } //--------------------------------------------------------------------- } /*namespace ample*/ } /*namespace verse*/
27.100079
191
0.615698
elmindreda
4de4791d620ad8902b39165381e29c3b64ce4bf4
1,944
cc
C++
dragon/core/operator_schema.cc
seetaresearch/Dragon
494774d3a545f807d483fd9e6e4563cedec6dda5
[ "BSD-2-Clause" ]
81
2018-03-13T13:08:37.000Z
2020-06-13T14:36:29.000Z
dragon/core/operator_schema.cc
seetaresearch/Dragon
494774d3a545f807d483fd9e6e4563cedec6dda5
[ "BSD-2-Clause" ]
2
2019-08-07T09:26:07.000Z
2019-08-26T07:33:55.000Z
dragon/core/operator_schema.cc
seetaresearch/Dragon
494774d3a545f807d483fd9e6e4563cedec6dda5
[ "BSD-2-Clause" ]
13
2018-03-13T13:08:50.000Z
2020-05-28T08:20:22.000Z
#include "dragon/core/operator_schema.h" namespace dragon { bool OpSchema::Verify(const OperatorDef& def) const { auto header = "[" + def.name() + ", " + def.type() + "]\n"; if (def.input_size() < min_input_ || def.input_size() > max_input_) { LOG(FATAL) << header << "Input size: " << def.input_size() << " is not in range [min=" << min_input_ << ", max=" << max_input_ << "]"; } if (def.output_size() < min_output_ || def.output_size() > max_output_) { LOG(FATAL) << header << "Output size: " << def.output_size() << " is not in range [min=" << min_output_ << ", max=" << max_output_ << "]"; } for (int i = 0; i < def.input_size(); ++i) { if (def.input(i).empty()) continue; for (int j = 0; j < def.output_size(); ++j) { if (def.output(j).empty()) continue; if (def.input(i) == def.output(j) && !CheckInplace(i, j)) { LOG(FATAL) << header << "Input(" << i << ") and Output(" << j << ") " << "can not be set to inplace."; } } } return true; } OpSchema& OpSchema::NumInputs(int n) { return NumInputs(n, n); } OpSchema& OpSchema::NumOutputs(int n) { return NumOutputs(n, n); } OpSchema& OpSchema::NumInputs(int min_num, int max_num) { min_input_ = min_num; max_input_ = max_num; return *this; } OpSchema& OpSchema::NumOutputs(int min_num, int max_num) { min_output_ = min_num; max_output_ = max_num; return *this; } OpSchema& OpSchema::AllowInplace(std::function<bool(int, int)> inplace) { CheckInplace = inplace; return *this; } OpSchema& OpSchema::AllowInplace(set<pair<int, int>> inplace) { CheckInplace = [inplace](int in, int out) -> bool { return (inplace.count(std::make_pair(in, out)) > 0); }; return *this; } Map<string, OpSchema>& OpSchemaRegistry::schema_map() { static Map<string, OpSchema> schema_map_; return schema_map_; } } // namespace dragon
28.588235
77
0.594136
seetaresearch
4e28575e6f07c8d00f3d3a237f554983a51cb6bb
567,368
cpp
C++
cisco-ios-xe/ydk/models/cisco_ios_xe/fragmented/Cisco_IOS_XE_native_174.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-xe/ydk/models/cisco_ios_xe/fragmented/Cisco_IOS_XE_native_174.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-xe/ydk/models/cisco_ios_xe/fragmented/Cisco_IOS_XE_native_174.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_XE_native_174.hpp" #include "Cisco_IOS_XE_native_175.hpp" using namespace ydk; namespace cisco_ios_xe { namespace Cisco_IOS_XE_native { Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::BestRange() : range{YType::uint8, "range"}, group_best{YType::empty, "group-best"} { yang_name = "best-range"; yang_parent_name = "best"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::~BestRange() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::has_data() const { if (is_presence_container) return true; return range.is_set || group_best.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::has_operation() const { return is_set(yfilter) || ydk::is_set(range.yfilter) || ydk::is_set(group_best.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "best-range"; ADD_KEY_TOKEN(range, "range"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (range.is_set || is_set(range.yfilter)) leaf_name_data.push_back(range.get_name_leafdata()); if (group_best.is_set || is_set(group_best.yfilter)) leaf_name_data.push_back(group_best.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::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 == "range") { range = value; range.value_namespace = name_space; range.value_namespace_prefix = name_space_prefix; } if(value_path == "group-best") { group_best = value; group_best.value_namespace = name_space; group_best.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "range") { range.yfilter = yfilter; } if(value_path == "group-best") { group_best.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::has_leaf_or_child_of_name(const std::string & name) const { if(name == "range" || name == "group-best") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::GroupBest::GroupBest() : best{YType::uint8, "best"} { yang_name = "group-best"; yang_parent_name = "all"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::GroupBest::~GroupBest() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::GroupBest::has_data() const { if (is_presence_container) return true; return best.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::GroupBest::has_operation() const { return is_set(yfilter) || ydk::is_set(best.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::GroupBest::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "group-best"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::GroupBest::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (best.is_set || is_set(best.yfilter)) leaf_name_data.push_back(best.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::GroupBest::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::GroupBest::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::GroupBest::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 == "best") { best = value; best.value_namespace = name_space; best.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::GroupBest::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "best") { best.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::All::GroupBest::has_leaf_or_child_of_name(const std::string & name) const { if(name == "best") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::Best() : best_range(this, {"range"}) { yang_name = "best"; yang_parent_name = "additional-paths"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::~Best() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<best_range.len(); index++) { if(best_range[index]->has_data()) return true; } return false; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::has_operation() const { for (std::size_t index=0; index<best_range.len(); index++) { if(best_range[index]->has_operation()) return true; } return is_set(yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "best"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "best-range") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange>(); ent_->parent = this; best_range.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : best_range.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::has_leaf_or_child_of_name(const std::string & name) const { if(name == "best-range") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::BestRange() : range{YType::uint8, "range"}, all{YType::empty, "all"} , group_best(nullptr) // presence node { yang_name = "best-range"; yang_parent_name = "best"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::~BestRange() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::has_data() const { if (is_presence_container) return true; return range.is_set || all.is_set || (group_best != nullptr && group_best->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::has_operation() const { return is_set(yfilter) || ydk::is_set(range.yfilter) || ydk::is_set(all.yfilter) || (group_best != nullptr && group_best->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "best-range"; ADD_KEY_TOKEN(range, "range"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (range.is_set || is_set(range.yfilter)) leaf_name_data.push_back(range.get_name_leafdata()); if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "group-best") { if(group_best == nullptr) { group_best = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest>(); } return group_best; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(group_best != nullptr) { _children["group-best"] = group_best; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::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 == "range") { range = value; range.value_namespace = name_space; range.value_namespace_prefix = name_space_prefix; } if(value_path == "all") { all = value; all.value_namespace = name_space; all.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "range") { range.yfilter = yfilter; } if(value_path == "all") { all.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::has_leaf_or_child_of_name(const std::string & name) const { if(name == "group-best" || name == "range" || name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::GroupBest() : all{YType::empty, "all"} { yang_name = "group-best"; yang_parent_name = "best-range"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::~GroupBest() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::has_data() const { if (is_presence_container) return true; return all.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::has_operation() const { return is_set(yfilter) || ydk::is_set(all.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "group-best"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::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 == "all") { all = value; all.value_namespace = name_space; all.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "all") { all.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::GroupBest::GroupBest() : all{YType::empty, "all"}, best{YType::uint8, "best"} { yang_name = "group-best"; yang_parent_name = "additional-paths"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::GroupBest::~GroupBest() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::GroupBest::has_data() const { if (is_presence_container) return true; return all.is_set || best.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::GroupBest::has_operation() const { return is_set(yfilter) || ydk::is_set(all.yfilter) || ydk::is_set(best.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::GroupBest::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "group-best"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::GroupBest::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata()); if (best.is_set || is_set(best.yfilter)) leaf_name_data.push_back(best.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::GroupBest::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::GroupBest::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::GroupBest::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 == "all") { all = value; all.value_namespace = name_space; all.value_namespace_prefix = name_space_prefix; } if(value_path == "best") { best = value; best.value_namespace = name_space; best.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::GroupBest::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "all") { all.yfilter = yfilter; } if(value_path == "best") { best.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::AdditionalPaths::GroupBest::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all" || name == "best") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::DiversePath() : mpath{YType::empty, "mpath"} , backup(nullptr) // presence node { yang_name = "diverse-path"; yang_parent_name = "advertise"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::~DiversePath() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::has_data() const { if (is_presence_container) return true; return mpath.is_set || (backup != nullptr && backup->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::has_operation() const { return is_set(yfilter) || ydk::is_set(mpath.yfilter) || (backup != nullptr && backup->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "diverse-path"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (mpath.is_set || is_set(mpath.yfilter)) leaf_name_data.push_back(mpath.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "backup") { if(backup == nullptr) { backup = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::Backup>(); } return backup; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(backup != nullptr) { _children["backup"] = backup; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::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 == "mpath") { mpath = value; mpath.value_namespace = name_space; mpath.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "mpath") { mpath.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::has_leaf_or_child_of_name(const std::string & name) const { if(name == "backup" || name == "mpath") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::Backup::Backup() : mpath{YType::empty, "mpath"} { yang_name = "backup"; yang_parent_name = "diverse-path"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::Backup::~Backup() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::Backup::has_data() const { if (is_presence_container) return true; return mpath.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::Backup::has_operation() const { return is_set(yfilter) || ydk::is_set(mpath.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::Backup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "backup"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::Backup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (mpath.is_set || is_set(mpath.yfilter)) leaf_name_data.push_back(mpath.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::Backup::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::Backup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::Backup::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 == "mpath") { mpath = value; mpath.value_namespace = name_space; mpath.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::Backup::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "mpath") { mpath.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Advertise::DiversePath::Backup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "mpath") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::AllowasIn::AllowasIn() : as_number{YType::uint8, "as-number"} { yang_name = "allowas-in"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::AllowasIn::~AllowasIn() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::AllowasIn::has_data() const { if (is_presence_container) return true; return as_number.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::AllowasIn::has_operation() const { return is_set(yfilter) || ydk::is_set(as_number.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::AllowasIn::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "allowas-in"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::AllowasIn::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (as_number.is_set || is_set(as_number.yfilter)) leaf_name_data.push_back(as_number.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::AllowasIn::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::AllowasIn::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::AllowasIn::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 == "as-number") { as_number = value; as_number.value_namespace = name_space; as_number.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::AllowasIn::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "as-number") { as_number.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::AllowasIn::has_leaf_or_child_of_name(const std::string & name) const { if(name == "as-number") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::DistributeList::DistributeList() : inout{YType::enumeration, "inout"}, accesslist{YType::str, "accesslist"} { yang_name = "distribute-list"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::DistributeList::~DistributeList() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::DistributeList::has_data() const { if (is_presence_container) return true; return inout.is_set || accesslist.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::DistributeList::has_operation() const { return is_set(yfilter) || ydk::is_set(inout.yfilter) || ydk::is_set(accesslist.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::DistributeList::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "distribute-list"; ADD_KEY_TOKEN(inout, "inout"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::DistributeList::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (inout.is_set || is_set(inout.yfilter)) leaf_name_data.push_back(inout.get_name_leafdata()); if (accesslist.is_set || is_set(accesslist.yfilter)) leaf_name_data.push_back(accesslist.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::DistributeList::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::DistributeList::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::DistributeList::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 == "inout") { inout = value; inout.value_namespace = name_space; inout.value_namespace_prefix = name_space_prefix; } if(value_path == "accesslist") { accesslist = value; accesslist.value_namespace = name_space; accesslist.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::DistributeList::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "inout") { inout.yfilter = yfilter; } if(value_path == "accesslist") { accesslist.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::DistributeList::has_leaf_or_child_of_name(const std::string & name) const { if(name == "inout" || name == "accesslist") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Encap::Encap() : mpls{YType::empty, "mpls"}, vxlan{YType::empty, "vxlan"} { yang_name = "encap"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Encap::~Encap() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Encap::has_data() const { if (is_presence_container) return true; return mpls.is_set || vxlan.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Encap::has_operation() const { return is_set(yfilter) || ydk::is_set(mpls.yfilter) || ydk::is_set(vxlan.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Encap::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "encap"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Encap::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (mpls.is_set || is_set(mpls.yfilter)) leaf_name_data.push_back(mpls.get_name_leafdata()); if (vxlan.is_set || is_set(vxlan.yfilter)) leaf_name_data.push_back(vxlan.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Encap::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Encap::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Encap::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 == "mpls") { mpls = value; mpls.value_namespace = name_space; mpls.value_namespace_prefix = name_space_prefix; } if(value_path == "vxlan") { vxlan = value; vxlan.value_namespace = name_space; vxlan.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Encap::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "mpls") { mpls.yfilter = yfilter; } if(value_path == "vxlan") { vxlan.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Encap::has_leaf_or_child_of_name(const std::string & name) const { if(name == "mpls" || name == "vxlan") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::FilterList::FilterList() : inout{YType::enumeration, "inout"}, as_path_list{YType::uint16, "as-path-list"} { yang_name = "filter-list"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::FilterList::~FilterList() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::FilterList::has_data() const { if (is_presence_container) return true; return inout.is_set || as_path_list.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::FilterList::has_operation() const { return is_set(yfilter) || ydk::is_set(inout.yfilter) || ydk::is_set(as_path_list.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::FilterList::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "filter-list"; ADD_KEY_TOKEN(inout, "inout"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::FilterList::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (inout.is_set || is_set(inout.yfilter)) leaf_name_data.push_back(inout.get_name_leafdata()); if (as_path_list.is_set || is_set(as_path_list.yfilter)) leaf_name_data.push_back(as_path_list.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::FilterList::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::FilterList::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::FilterList::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 == "inout") { inout = value; inout.value_namespace = name_space; inout.value_namespace_prefix = name_space_prefix; } if(value_path == "as-path-list") { as_path_list = value; as_path_list.value_namespace = name_space; as_path_list.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::FilterList::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "inout") { inout.yfilter = yfilter; } if(value_path == "as-path-list") { as_path_list.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::FilterList::has_leaf_or_child_of_name(const std::string & name) const { if(name == "inout" || name == "as-path-list") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Inherit::Inherit() : peer_policy{YType::str, "peer-policy"}, peer_session{YType::str, "peer-session"} { yang_name = "inherit"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Inherit::~Inherit() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Inherit::has_data() const { if (is_presence_container) return true; return peer_policy.is_set || peer_session.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Inherit::has_operation() const { return is_set(yfilter) || ydk::is_set(peer_policy.yfilter) || ydk::is_set(peer_session.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Inherit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "inherit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Inherit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (peer_policy.is_set || is_set(peer_policy.yfilter)) leaf_name_data.push_back(peer_policy.get_name_leafdata()); if (peer_session.is_set || is_set(peer_session.yfilter)) leaf_name_data.push_back(peer_session.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Inherit::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Inherit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Inherit::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 == "peer-policy") { peer_policy = value; peer_policy.value_namespace = name_space; peer_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "peer-session") { peer_session = value; peer_session.value_namespace = name_space; peer_session.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Inherit::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "peer-policy") { peer_policy.yfilter = yfilter; } if(value_path == "peer-session") { peer_session.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::Inherit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "peer-policy" || name == "peer-session") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::MaximumPrefix::MaximumPrefix() : max_prefix_no{YType::uint32, "max-prefix-no"}, threshold{YType::uint8, "threshold"}, restart{YType::uint16, "restart"}, warning_only{YType::empty, "warning-only"} { yang_name = "maximum-prefix"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::MaximumPrefix::~MaximumPrefix() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::MaximumPrefix::has_data() const { if (is_presence_container) return true; return max_prefix_no.is_set || threshold.is_set || restart.is_set || warning_only.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::MaximumPrefix::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefix_no.yfilter) || ydk::is_set(threshold.yfilter) || ydk::is_set(restart.yfilter) || ydk::is_set(warning_only.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::MaximumPrefix::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "maximum-prefix"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::MaximumPrefix::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefix_no.is_set || is_set(max_prefix_no.yfilter)) leaf_name_data.push_back(max_prefix_no.get_name_leafdata()); if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); if (restart.is_set || is_set(restart.yfilter)) leaf_name_data.push_back(restart.get_name_leafdata()); if (warning_only.is_set || is_set(warning_only.yfilter)) leaf_name_data.push_back(warning_only.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::MaximumPrefix::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::MaximumPrefix::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::MaximumPrefix::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 == "max-prefix-no") { max_prefix_no = value; max_prefix_no.value_namespace = name_space; max_prefix_no.value_namespace_prefix = name_space_prefix; } if(value_path == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } if(value_path == "restart") { restart = value; restart.value_namespace = name_space; restart.value_namespace_prefix = name_space_prefix; } if(value_path == "warning-only") { warning_only = value; warning_only.value_namespace = name_space; warning_only.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::MaximumPrefix::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefix-no") { max_prefix_no.yfilter = yfilter; } if(value_path == "threshold") { threshold.yfilter = yfilter; } if(value_path == "restart") { restart.yfilter = yfilter; } if(value_path == "warning-only") { warning_only.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::MaximumPrefix::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefix-no" || name == "threshold" || name == "restart" || name == "warning-only") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::NextHopSelf::NextHopSelf() : all{YType::empty, "all"} { yang_name = "next-hop-self"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::NextHopSelf::~NextHopSelf() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::NextHopSelf::has_data() const { if (is_presence_container) return true; return all.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::NextHopSelf::has_operation() const { return is_set(yfilter) || ydk::is_set(all.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::NextHopSelf::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "next-hop-self"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::NextHopSelf::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::NextHopSelf::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::NextHopSelf::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::NextHopSelf::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 == "all") { all = value; all.value_namespace = name_space; all.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::NextHopSelf::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "all") { all.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::NextHopSelf::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::PrefixList::PrefixList() : inout{YType::enumeration, "inout"}, prefix_list_name{YType::str, "prefix-list-name"} { yang_name = "prefix-list"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::PrefixList::~PrefixList() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::PrefixList::has_data() const { if (is_presence_container) return true; return inout.is_set || prefix_list_name.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::PrefixList::has_operation() const { return is_set(yfilter) || ydk::is_set(inout.yfilter) || ydk::is_set(prefix_list_name.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::PrefixList::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-list"; ADD_KEY_TOKEN(inout, "inout"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::PrefixList::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (inout.is_set || is_set(inout.yfilter)) leaf_name_data.push_back(inout.get_name_leafdata()); if (prefix_list_name.is_set || is_set(prefix_list_name.yfilter)) leaf_name_data.push_back(prefix_list_name.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::PrefixList::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::PrefixList::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::PrefixList::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 == "inout") { inout = value; inout.value_namespace = name_space; inout.value_namespace_prefix = name_space_prefix; } if(value_path == "prefix-list-name") { prefix_list_name = value; prefix_list_name.value_namespace = name_space; prefix_list_name.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::PrefixList::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "inout") { inout.yfilter = yfilter; } if(value_path == "prefix-list-name") { prefix_list_name.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::PrefixList::has_leaf_or_child_of_name(const std::string & name) const { if(name == "inout" || name == "prefix-list-name") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::RemovePrivateAs() : all(nullptr) // presence node { yang_name = "remove-private-as"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::~RemovePrivateAs() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::has_data() const { if (is_presence_container) return true; return (all != nullptr && all->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::has_operation() const { return is_set(yfilter) || (all != nullptr && all->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "remove-private-as"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "all") { if(all == nullptr) { all = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::All>(); } return all; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(all != nullptr) { _children["all"] = all; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::All::All() : replace_as{YType::empty, "replace-as"} { yang_name = "all"; yang_parent_name = "remove-private-as"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::All::~All() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::All::has_data() const { if (is_presence_container) return true; return replace_as.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::All::has_operation() const { return is_set(yfilter) || ydk::is_set(replace_as.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::All::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "all"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::All::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (replace_as.is_set || is_set(replace_as.yfilter)) leaf_name_data.push_back(replace_as.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::All::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::All::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::All::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 == "replace-as") { replace_as = value; replace_as.value_namespace = name_space; replace_as.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::All::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "replace-as") { replace_as.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RemovePrivateAs::All::has_leaf_or_child_of_name(const std::string & name) const { if(name == "replace-as") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RouteMap::RouteMap() : inout{YType::enumeration, "inout"}, route_map_name{YType::str, "route-map-name"} { yang_name = "route-map"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RouteMap::~RouteMap() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RouteMap::has_data() const { if (is_presence_container) return true; return inout.is_set || route_map_name.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RouteMap::has_operation() const { return is_set(yfilter) || ydk::is_set(inout.yfilter) || ydk::is_set(route_map_name.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RouteMap::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "route-map"; ADD_KEY_TOKEN(inout, "inout"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RouteMap::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (inout.is_set || is_set(inout.yfilter)) leaf_name_data.push_back(inout.get_name_leafdata()); if (route_map_name.is_set || is_set(route_map_name.yfilter)) leaf_name_data.push_back(route_map_name.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RouteMap::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RouteMap::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RouteMap::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 == "inout") { inout = value; inout.value_namespace = name_space; inout.value_namespace_prefix = name_space_prefix; } if(value_path == "route-map-name") { route_map_name = value; route_map_name.value_namespace = name_space; route_map_name.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RouteMap::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "inout") { inout.yfilter = yfilter; } if(value_path == "route-map-name") { route_map_name.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RouteMap::has_leaf_or_child_of_name(const std::string & name) const { if(name == "inout" || name == "route-map-name") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::SendCommunity() : send_community_where{YType::enumeration, "send-community-where"} { yang_name = "send-community"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::~SendCommunity() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::has_data() const { if (is_presence_container) return true; return send_community_where.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::has_operation() const { return is_set(yfilter) || ydk::is_set(send_community_where.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "send-community"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_community_where.is_set || is_set(send_community_where.yfilter)) leaf_name_data.push_back(send_community_where.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::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 == "send-community-where") { send_community_where = value; send_community_where.value_namespace = name_space; send_community_where.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-community-where") { send_community_where.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-community-where") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SlowPeer() : detection(nullptr) // presence node , split_update_group(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup>()) { split_update_group->parent = this; yang_name = "slow-peer"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::~SlowPeer() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::has_data() const { if (is_presence_container) return true; return (detection != nullptr && detection->has_data()) || (split_update_group != nullptr && split_update_group->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::has_operation() const { return is_set(yfilter) || (detection != nullptr && detection->has_operation()) || (split_update_group != nullptr && split_update_group->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "slow-peer"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "detection") { if(detection == nullptr) { detection = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::Detection>(); } return detection; } if(child_yang_name == "split-update-group") { if(split_update_group == nullptr) { split_update_group = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup>(); } return split_update_group; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(detection != nullptr) { _children["detection"] = detection; } if(split_update_group != nullptr) { _children["split-update-group"] = split_update_group; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::has_leaf_or_child_of_name(const std::string & name) const { if(name == "detection" || name == "split-update-group") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::Detection::Detection() : threshold{YType::uint16, "threshold"} { yang_name = "detection"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::Detection::~Detection() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::Detection::has_data() const { if (is_presence_container) return true; return threshold.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::Detection::has_operation() const { return is_set(yfilter) || ydk::is_set(threshold.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::Detection::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "detection"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::Detection::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::Detection::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::Detection::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::Detection::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 == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::Detection::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "threshold") { threshold.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::Detection::has_leaf_or_child_of_name(const std::string & name) const { if(name == "threshold") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::SplitUpdateGroup() : dynamic(nullptr) // presence node { yang_name = "split-update-group"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::~SplitUpdateGroup() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::has_data() const { if (is_presence_container) return true; return (dynamic != nullptr && dynamic->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::has_operation() const { return is_set(yfilter) || (dynamic != nullptr && dynamic->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "split-update-group"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "dynamic") { if(dynamic == nullptr) { dynamic = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic>(); } return dynamic; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(dynamic != nullptr) { _children["dynamic"] = dynamic; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "dynamic") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::Dynamic() : permanent{YType::empty, "permanent"} { yang_name = "dynamic"; yang_parent_name = "split-update-group"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::~Dynamic() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_data() const { if (is_presence_container) return true; return permanent.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_operation() const { return is_set(yfilter) || ydk::is_set(permanent.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "dynamic"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (permanent.is_set || is_set(permanent.yfilter)) leaf_name_data.push_back(permanent.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::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 == "permanent") { permanent = value; permanent.value_namespace = name_space; permanent.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "permanent") { permanent.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_leaf_or_child_of_name(const std::string & name) const { if(name == "permanent") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Neighbor() : id{YType::str, "id"}, activate{YType::empty, "activate"}, advertisement_interval{YType::uint16, "advertisement-interval"}, allow_policy{YType::empty, "allow-policy"}, dmzlink_bw{YType::empty, "dmzlink-bw"}, next_hop_unchanged{YType::empty, "next-hop-unchanged"}, route_reflector_client{YType::empty, "route-reflector-client"}, soft_reconfiguration{YType::enumeration, "soft-reconfiguration"}, soo{YType::str, "soo"}, unsuppress_map{YType::str, "unsuppress-map"}, weight{YType::uint16, "weight"} , additional_paths(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths>()) , advertise(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise>()) , allowas_in(nullptr) // presence node , distribute_list(this, {"inout"}) , encap(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Encap>()) , filter_list(this, {"inout"}) , inherit(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Inherit>()) , maximum_prefix(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::MaximumPrefix>()) , next_hop_self(nullptr) // presence node , prefix_list(this, {"inout"}) , remove_private_as(nullptr) // presence node , route_map(this, {"inout"}) , send_community(nullptr) // presence node , slow_peer(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer>()) { additional_paths->parent = this; advertise->parent = this; encap->parent = this; inherit->parent = this; maximum_prefix->parent = this; slow_peer->parent = this; yang_name = "neighbor"; yang_parent_name = "l2vpn-evpn"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::~Neighbor() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<distribute_list.len(); index++) { if(distribute_list[index]->has_data()) return true; } for (std::size_t index=0; index<filter_list.len(); index++) { if(filter_list[index]->has_data()) return true; } for (std::size_t index=0; index<prefix_list.len(); index++) { if(prefix_list[index]->has_data()) return true; } for (std::size_t index=0; index<route_map.len(); index++) { if(route_map[index]->has_data()) return true; } return id.is_set || activate.is_set || advertisement_interval.is_set || allow_policy.is_set || dmzlink_bw.is_set || next_hop_unchanged.is_set || route_reflector_client.is_set || soft_reconfiguration.is_set || soo.is_set || unsuppress_map.is_set || weight.is_set || (additional_paths != nullptr && additional_paths->has_data()) || (advertise != nullptr && advertise->has_data()) || (allowas_in != nullptr && allowas_in->has_data()) || (encap != nullptr && encap->has_data()) || (inherit != nullptr && inherit->has_data()) || (maximum_prefix != nullptr && maximum_prefix->has_data()) || (next_hop_self != nullptr && next_hop_self->has_data()) || (remove_private_as != nullptr && remove_private_as->has_data()) || (send_community != nullptr && send_community->has_data()) || (slow_peer != nullptr && slow_peer->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::has_operation() const { for (std::size_t index=0; index<distribute_list.len(); index++) { if(distribute_list[index]->has_operation()) return true; } for (std::size_t index=0; index<filter_list.len(); index++) { if(filter_list[index]->has_operation()) return true; } for (std::size_t index=0; index<prefix_list.len(); index++) { if(prefix_list[index]->has_operation()) return true; } for (std::size_t index=0; index<route_map.len(); index++) { if(route_map[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(id.yfilter) || ydk::is_set(activate.yfilter) || ydk::is_set(advertisement_interval.yfilter) || ydk::is_set(allow_policy.yfilter) || ydk::is_set(dmzlink_bw.yfilter) || ydk::is_set(next_hop_unchanged.yfilter) || ydk::is_set(route_reflector_client.yfilter) || ydk::is_set(soft_reconfiguration.yfilter) || ydk::is_set(soo.yfilter) || ydk::is_set(unsuppress_map.yfilter) || ydk::is_set(weight.yfilter) || (additional_paths != nullptr && additional_paths->has_operation()) || (advertise != nullptr && advertise->has_operation()) || (allowas_in != nullptr && allowas_in->has_operation()) || (encap != nullptr && encap->has_operation()) || (inherit != nullptr && inherit->has_operation()) || (maximum_prefix != nullptr && maximum_prefix->has_operation()) || (next_hop_self != nullptr && next_hop_self->has_operation()) || (remove_private_as != nullptr && remove_private_as->has_operation()) || (send_community != nullptr && send_community->has_operation()) || (slow_peer != nullptr && slow_peer->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "neighbor"; ADD_KEY_TOKEN(id, "id"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (id.is_set || is_set(id.yfilter)) leaf_name_data.push_back(id.get_name_leafdata()); if (activate.is_set || is_set(activate.yfilter)) leaf_name_data.push_back(activate.get_name_leafdata()); if (advertisement_interval.is_set || is_set(advertisement_interval.yfilter)) leaf_name_data.push_back(advertisement_interval.get_name_leafdata()); if (allow_policy.is_set || is_set(allow_policy.yfilter)) leaf_name_data.push_back(allow_policy.get_name_leafdata()); if (dmzlink_bw.is_set || is_set(dmzlink_bw.yfilter)) leaf_name_data.push_back(dmzlink_bw.get_name_leafdata()); if (next_hop_unchanged.is_set || is_set(next_hop_unchanged.yfilter)) leaf_name_data.push_back(next_hop_unchanged.get_name_leafdata()); if (route_reflector_client.is_set || is_set(route_reflector_client.yfilter)) leaf_name_data.push_back(route_reflector_client.get_name_leafdata()); if (soft_reconfiguration.is_set || is_set(soft_reconfiguration.yfilter)) leaf_name_data.push_back(soft_reconfiguration.get_name_leafdata()); if (soo.is_set || is_set(soo.yfilter)) leaf_name_data.push_back(soo.get_name_leafdata()); if (unsuppress_map.is_set || is_set(unsuppress_map.yfilter)) leaf_name_data.push_back(unsuppress_map.get_name_leafdata()); if (weight.is_set || is_set(weight.yfilter)) leaf_name_data.push_back(weight.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "additional-paths") { if(additional_paths == nullptr) { additional_paths = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths>(); } return additional_paths; } if(child_yang_name == "advertise") { if(advertise == nullptr) { advertise = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise>(); } return advertise; } if(child_yang_name == "allowas-in") { if(allowas_in == nullptr) { allowas_in = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AllowasIn>(); } return allowas_in; } if(child_yang_name == "distribute-list") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList>(); ent_->parent = this; distribute_list.append(ent_); return ent_; } if(child_yang_name == "encap") { if(encap == nullptr) { encap = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Encap>(); } return encap; } if(child_yang_name == "filter-list") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList>(); ent_->parent = this; filter_list.append(ent_); return ent_; } if(child_yang_name == "inherit") { if(inherit == nullptr) { inherit = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Inherit>(); } return inherit; } if(child_yang_name == "maximum-prefix") { if(maximum_prefix == nullptr) { maximum_prefix = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::MaximumPrefix>(); } return maximum_prefix; } if(child_yang_name == "next-hop-self") { if(next_hop_self == nullptr) { next_hop_self = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::NextHopSelf>(); } return next_hop_self; } if(child_yang_name == "prefix-list") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList>(); ent_->parent = this; prefix_list.append(ent_); return ent_; } if(child_yang_name == "remove-private-as") { if(remove_private_as == nullptr) { remove_private_as = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs>(); } return remove_private_as; } if(child_yang_name == "route-map") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap>(); ent_->parent = this; route_map.append(ent_); return ent_; } if(child_yang_name == "send-community") { if(send_community == nullptr) { send_community = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity>(); } return send_community; } if(child_yang_name == "slow-peer") { if(slow_peer == nullptr) { slow_peer = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer>(); } return slow_peer; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(additional_paths != nullptr) { _children["additional-paths"] = additional_paths; } if(advertise != nullptr) { _children["advertise"] = advertise; } if(allowas_in != nullptr) { _children["allowas-in"] = allowas_in; } count_ = 0; for (auto ent_ : distribute_list.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } if(encap != nullptr) { _children["encap"] = encap; } count_ = 0; for (auto ent_ : filter_list.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } if(inherit != nullptr) { _children["inherit"] = inherit; } if(maximum_prefix != nullptr) { _children["maximum-prefix"] = maximum_prefix; } if(next_hop_self != nullptr) { _children["next-hop-self"] = next_hop_self; } count_ = 0; for (auto ent_ : prefix_list.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } if(remove_private_as != nullptr) { _children["remove-private-as"] = remove_private_as; } count_ = 0; for (auto ent_ : route_map.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } if(send_community != nullptr) { _children["send-community"] = send_community; } if(slow_peer != nullptr) { _children["slow-peer"] = slow_peer; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::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 == "id") { id = value; id.value_namespace = name_space; id.value_namespace_prefix = name_space_prefix; } if(value_path == "activate") { activate = value; activate.value_namespace = name_space; activate.value_namespace_prefix = name_space_prefix; } if(value_path == "advertisement-interval") { advertisement_interval = value; advertisement_interval.value_namespace = name_space; advertisement_interval.value_namespace_prefix = name_space_prefix; } if(value_path == "allow-policy") { allow_policy = value; allow_policy.value_namespace = name_space; allow_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "dmzlink-bw") { dmzlink_bw = value; dmzlink_bw.value_namespace = name_space; dmzlink_bw.value_namespace_prefix = name_space_prefix; } if(value_path == "next-hop-unchanged") { next_hop_unchanged = value; next_hop_unchanged.value_namespace = name_space; next_hop_unchanged.value_namespace_prefix = name_space_prefix; } if(value_path == "route-reflector-client") { route_reflector_client = value; route_reflector_client.value_namespace = name_space; route_reflector_client.value_namespace_prefix = name_space_prefix; } if(value_path == "soft-reconfiguration") { soft_reconfiguration = value; soft_reconfiguration.value_namespace = name_space; soft_reconfiguration.value_namespace_prefix = name_space_prefix; } if(value_path == "soo") { soo = value; soo.value_namespace = name_space; soo.value_namespace_prefix = name_space_prefix; } if(value_path == "unsuppress-map") { unsuppress_map = value; unsuppress_map.value_namespace = name_space; unsuppress_map.value_namespace_prefix = name_space_prefix; } if(value_path == "weight") { weight = value; weight.value_namespace = name_space; weight.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "id") { id.yfilter = yfilter; } if(value_path == "activate") { activate.yfilter = yfilter; } if(value_path == "advertisement-interval") { advertisement_interval.yfilter = yfilter; } if(value_path == "allow-policy") { allow_policy.yfilter = yfilter; } if(value_path == "dmzlink-bw") { dmzlink_bw.yfilter = yfilter; } if(value_path == "next-hop-unchanged") { next_hop_unchanged.yfilter = yfilter; } if(value_path == "route-reflector-client") { route_reflector_client.yfilter = yfilter; } if(value_path == "soft-reconfiguration") { soft_reconfiguration.yfilter = yfilter; } if(value_path == "soo") { soo.yfilter = yfilter; } if(value_path == "unsuppress-map") { unsuppress_map.yfilter = yfilter; } if(value_path == "weight") { weight.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::has_leaf_or_child_of_name(const std::string & name) const { if(name == "additional-paths" || name == "advertise" || name == "allowas-in" || name == "distribute-list" || name == "encap" || name == "filter-list" || name == "inherit" || name == "maximum-prefix" || name == "next-hop-self" || name == "prefix-list" || name == "remove-private-as" || name == "route-map" || name == "send-community" || name == "slow-peer" || name == "id" || name == "activate" || name == "advertisement-interval" || name == "allow-policy" || name == "dmzlink-bw" || name == "next-hop-unchanged" || name == "route-reflector-client" || name == "soft-reconfiguration" || name == "soo" || name == "unsuppress-map" || name == "weight") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::AdditionalPaths() : disable{YType::empty, "disable"}, receive{YType::empty, "receive"} , send(nullptr) // presence node { yang_name = "additional-paths"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::~AdditionalPaths() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::has_data() const { if (is_presence_container) return true; return disable.is_set || receive.is_set || (send != nullptr && send->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::has_operation() const { return is_set(yfilter) || ydk::is_set(disable.yfilter) || ydk::is_set(receive.yfilter) || (send != nullptr && send->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "additional-paths"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (disable.is_set || is_set(disable.yfilter)) leaf_name_data.push_back(disable.get_name_leafdata()); if (receive.is_set || is_set(receive.yfilter)) leaf_name_data.push_back(receive.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "send") { if(send == nullptr) { send = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::Send>(); } return send; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(send != nullptr) { _children["send"] = send; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::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 == "disable") { disable = value; disable.value_namespace = name_space; disable.value_namespace_prefix = name_space_prefix; } if(value_path == "receive") { receive = value; receive.value_namespace = name_space; receive.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "disable") { disable.yfilter = yfilter; } if(value_path == "receive") { receive.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send" || name == "disable" || name == "receive") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::Send::Send() : receive{YType::empty, "receive"} { yang_name = "send"; yang_parent_name = "additional-paths"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::Send::~Send() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::Send::has_data() const { if (is_presence_container) return true; return receive.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::Send::has_operation() const { return is_set(yfilter) || ydk::is_set(receive.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::Send::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "send"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::Send::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (receive.is_set || is_set(receive.yfilter)) leaf_name_data.push_back(receive.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::Send::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::Send::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::Send::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 == "receive") { receive = value; receive.value_namespace = name_space; receive.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::Send::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "receive") { receive.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AdditionalPaths::Send::has_leaf_or_child_of_name(const std::string & name) const { if(name == "receive") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::Advertise() : best_external{YType::empty, "best-external"} , additional_paths(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths>()) , diverse_path(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath>()) { additional_paths->parent = this; diverse_path->parent = this; yang_name = "advertise"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::~Advertise() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::has_data() const { if (is_presence_container) return true; return best_external.is_set || (additional_paths != nullptr && additional_paths->has_data()) || (diverse_path != nullptr && diverse_path->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::has_operation() const { return is_set(yfilter) || ydk::is_set(best_external.yfilter) || (additional_paths != nullptr && additional_paths->has_operation()) || (diverse_path != nullptr && diverse_path->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "advertise"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (best_external.is_set || is_set(best_external.yfilter)) leaf_name_data.push_back(best_external.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "additional-paths") { if(additional_paths == nullptr) { additional_paths = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths>(); } return additional_paths; } if(child_yang_name == "diverse-path") { if(diverse_path == nullptr) { diverse_path = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath>(); } return diverse_path; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(additional_paths != nullptr) { _children["additional-paths"] = additional_paths; } if(diverse_path != nullptr) { _children["diverse-path"] = diverse_path; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::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 == "best-external") { best_external = value; best_external.value_namespace = name_space; best_external.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "best-external") { best_external.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::has_leaf_or_child_of_name(const std::string & name) const { if(name == "additional-paths" || name == "diverse-path" || name == "best-external") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::AdditionalPaths() : all(nullptr) // presence node , best(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best>()) , group_best(nullptr) // presence node { best->parent = this; yang_name = "additional-paths"; yang_parent_name = "advertise"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::~AdditionalPaths() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::has_data() const { if (is_presence_container) return true; return (all != nullptr && all->has_data()) || (best != nullptr && best->has_data()) || (group_best != nullptr && group_best->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::has_operation() const { return is_set(yfilter) || (all != nullptr && all->has_operation()) || (best != nullptr && best->has_operation()) || (group_best != nullptr && group_best->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "additional-paths"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "all") { if(all == nullptr) { all = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All>(); } return all; } if(child_yang_name == "best") { if(best == nullptr) { best = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best>(); } return best; } if(child_yang_name == "group-best") { if(group_best == nullptr) { group_best = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::GroupBest>(); } return group_best; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(all != nullptr) { _children["all"] = all; } if(best != nullptr) { _children["best"] = best; } if(group_best != nullptr) { _children["group-best"] = group_best; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all" || name == "best" || name == "group-best") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::All() : best(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best>()) , group_best(nullptr) // presence node { best->parent = this; yang_name = "all"; yang_parent_name = "additional-paths"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::~All() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::has_data() const { if (is_presence_container) return true; return (best != nullptr && best->has_data()) || (group_best != nullptr && group_best->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::has_operation() const { return is_set(yfilter) || (best != nullptr && best->has_operation()) || (group_best != nullptr && group_best->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "all"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "best") { if(best == nullptr) { best = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best>(); } return best; } if(child_yang_name == "group-best") { if(group_best == nullptr) { group_best = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::GroupBest>(); } return group_best; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(best != nullptr) { _children["best"] = best; } if(group_best != nullptr) { _children["group-best"] = group_best; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::has_leaf_or_child_of_name(const std::string & name) const { if(name == "best" || name == "group-best") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::Best() : best_range(this, {"range"}) { yang_name = "best"; yang_parent_name = "all"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::~Best() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<best_range.len(); index++) { if(best_range[index]->has_data()) return true; } return false; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::has_operation() const { for (std::size_t index=0; index<best_range.len(); index++) { if(best_range[index]->has_operation()) return true; } return is_set(yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "best"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "best-range") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange>(); ent_->parent = this; best_range.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : best_range.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::has_leaf_or_child_of_name(const std::string & name) const { if(name == "best-range") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::BestRange() : range{YType::uint8, "range"}, group_best{YType::empty, "group-best"} { yang_name = "best-range"; yang_parent_name = "best"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::~BestRange() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::has_data() const { if (is_presence_container) return true; return range.is_set || group_best.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::has_operation() const { return is_set(yfilter) || ydk::is_set(range.yfilter) || ydk::is_set(group_best.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "best-range"; ADD_KEY_TOKEN(range, "range"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (range.is_set || is_set(range.yfilter)) leaf_name_data.push_back(range.get_name_leafdata()); if (group_best.is_set || is_set(group_best.yfilter)) leaf_name_data.push_back(group_best.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::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 == "range") { range = value; range.value_namespace = name_space; range.value_namespace_prefix = name_space_prefix; } if(value_path == "group-best") { group_best = value; group_best.value_namespace = name_space; group_best.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "range") { range.yfilter = yfilter; } if(value_path == "group-best") { group_best.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::Best::BestRange::has_leaf_or_child_of_name(const std::string & name) const { if(name == "range" || name == "group-best") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::GroupBest::GroupBest() : best{YType::uint8, "best"} { yang_name = "group-best"; yang_parent_name = "all"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::GroupBest::~GroupBest() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::GroupBest::has_data() const { if (is_presence_container) return true; return best.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::GroupBest::has_operation() const { return is_set(yfilter) || ydk::is_set(best.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::GroupBest::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "group-best"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::GroupBest::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (best.is_set || is_set(best.yfilter)) leaf_name_data.push_back(best.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::GroupBest::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::GroupBest::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::GroupBest::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 == "best") { best = value; best.value_namespace = name_space; best.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::GroupBest::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "best") { best.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::All::GroupBest::has_leaf_or_child_of_name(const std::string & name) const { if(name == "best") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::Best() : best_range(this, {"range"}) { yang_name = "best"; yang_parent_name = "additional-paths"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::~Best() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<best_range.len(); index++) { if(best_range[index]->has_data()) return true; } return false; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::has_operation() const { for (std::size_t index=0; index<best_range.len(); index++) { if(best_range[index]->has_operation()) return true; } return is_set(yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "best"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "best-range") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange>(); ent_->parent = this; best_range.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : best_range.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::has_leaf_or_child_of_name(const std::string & name) const { if(name == "best-range") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::BestRange() : range{YType::uint8, "range"}, all{YType::empty, "all"} , group_best(nullptr) // presence node { yang_name = "best-range"; yang_parent_name = "best"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::~BestRange() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::has_data() const { if (is_presence_container) return true; return range.is_set || all.is_set || (group_best != nullptr && group_best->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::has_operation() const { return is_set(yfilter) || ydk::is_set(range.yfilter) || ydk::is_set(all.yfilter) || (group_best != nullptr && group_best->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "best-range"; ADD_KEY_TOKEN(range, "range"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (range.is_set || is_set(range.yfilter)) leaf_name_data.push_back(range.get_name_leafdata()); if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "group-best") { if(group_best == nullptr) { group_best = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest>(); } return group_best; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(group_best != nullptr) { _children["group-best"] = group_best; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::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 == "range") { range = value; range.value_namespace = name_space; range.value_namespace_prefix = name_space_prefix; } if(value_path == "all") { all = value; all.value_namespace = name_space; all.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "range") { range.yfilter = yfilter; } if(value_path == "all") { all.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::has_leaf_or_child_of_name(const std::string & name) const { if(name == "group-best" || name == "range" || name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::GroupBest() : all{YType::empty, "all"} { yang_name = "group-best"; yang_parent_name = "best-range"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::~GroupBest() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::has_data() const { if (is_presence_container) return true; return all.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::has_operation() const { return is_set(yfilter) || ydk::is_set(all.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "group-best"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::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 == "all") { all = value; all.value_namespace = name_space; all.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "all") { all.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::Best::BestRange::GroupBest::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::GroupBest::GroupBest() : all{YType::empty, "all"}, best{YType::uint8, "best"} { yang_name = "group-best"; yang_parent_name = "additional-paths"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::GroupBest::~GroupBest() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::GroupBest::has_data() const { if (is_presence_container) return true; return all.is_set || best.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::GroupBest::has_operation() const { return is_set(yfilter) || ydk::is_set(all.yfilter) || ydk::is_set(best.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::GroupBest::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "group-best"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::GroupBest::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata()); if (best.is_set || is_set(best.yfilter)) leaf_name_data.push_back(best.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::GroupBest::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::GroupBest::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::GroupBest::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 == "all") { all = value; all.value_namespace = name_space; all.value_namespace_prefix = name_space_prefix; } if(value_path == "best") { best = value; best.value_namespace = name_space; best.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::GroupBest::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "all") { all.yfilter = yfilter; } if(value_path == "best") { best.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::AdditionalPaths::GroupBest::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all" || name == "best") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::DiversePath() : mpath{YType::empty, "mpath"} , backup(nullptr) // presence node { yang_name = "diverse-path"; yang_parent_name = "advertise"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::~DiversePath() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::has_data() const { if (is_presence_container) return true; return mpath.is_set || (backup != nullptr && backup->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::has_operation() const { return is_set(yfilter) || ydk::is_set(mpath.yfilter) || (backup != nullptr && backup->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "diverse-path"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (mpath.is_set || is_set(mpath.yfilter)) leaf_name_data.push_back(mpath.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "backup") { if(backup == nullptr) { backup = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::Backup>(); } return backup; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(backup != nullptr) { _children["backup"] = backup; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::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 == "mpath") { mpath = value; mpath.value_namespace = name_space; mpath.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "mpath") { mpath.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::has_leaf_or_child_of_name(const std::string & name) const { if(name == "backup" || name == "mpath") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::Backup::Backup() : mpath{YType::empty, "mpath"} { yang_name = "backup"; yang_parent_name = "diverse-path"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::Backup::~Backup() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::Backup::has_data() const { if (is_presence_container) return true; return mpath.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::Backup::has_operation() const { return is_set(yfilter) || ydk::is_set(mpath.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::Backup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "backup"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::Backup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (mpath.is_set || is_set(mpath.yfilter)) leaf_name_data.push_back(mpath.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::Backup::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::Backup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::Backup::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 == "mpath") { mpath = value; mpath.value_namespace = name_space; mpath.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::Backup::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "mpath") { mpath.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Advertise::DiversePath::Backup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "mpath") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AllowasIn::AllowasIn() : as_number{YType::uint8, "as-number"} { yang_name = "allowas-in"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AllowasIn::~AllowasIn() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AllowasIn::has_data() const { if (is_presence_container) return true; return as_number.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AllowasIn::has_operation() const { return is_set(yfilter) || ydk::is_set(as_number.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AllowasIn::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "allowas-in"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AllowasIn::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (as_number.is_set || is_set(as_number.yfilter)) leaf_name_data.push_back(as_number.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AllowasIn::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AllowasIn::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AllowasIn::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 == "as-number") { as_number = value; as_number.value_namespace = name_space; as_number.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AllowasIn::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "as-number") { as_number.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::AllowasIn::has_leaf_or_child_of_name(const std::string & name) const { if(name == "as-number") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList::DistributeList() : inout{YType::enumeration, "inout"}, accesslist{YType::str, "accesslist"} { yang_name = "distribute-list"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList::~DistributeList() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList::has_data() const { if (is_presence_container) return true; return inout.is_set || accesslist.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList::has_operation() const { return is_set(yfilter) || ydk::is_set(inout.yfilter) || ydk::is_set(accesslist.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "distribute-list"; ADD_KEY_TOKEN(inout, "inout"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (inout.is_set || is_set(inout.yfilter)) leaf_name_data.push_back(inout.get_name_leafdata()); if (accesslist.is_set || is_set(accesslist.yfilter)) leaf_name_data.push_back(accesslist.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList::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 == "inout") { inout = value; inout.value_namespace = name_space; inout.value_namespace_prefix = name_space_prefix; } if(value_path == "accesslist") { accesslist = value; accesslist.value_namespace = name_space; accesslist.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "inout") { inout.yfilter = yfilter; } if(value_path == "accesslist") { accesslist.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList::has_leaf_or_child_of_name(const std::string & name) const { if(name == "inout" || name == "accesslist") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Encap::Encap() : mpls{YType::empty, "mpls"}, vxlan{YType::empty, "vxlan"} { yang_name = "encap"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Encap::~Encap() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Encap::has_data() const { if (is_presence_container) return true; return mpls.is_set || vxlan.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Encap::has_operation() const { return is_set(yfilter) || ydk::is_set(mpls.yfilter) || ydk::is_set(vxlan.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Encap::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "encap"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Encap::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (mpls.is_set || is_set(mpls.yfilter)) leaf_name_data.push_back(mpls.get_name_leafdata()); if (vxlan.is_set || is_set(vxlan.yfilter)) leaf_name_data.push_back(vxlan.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Encap::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Encap::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Encap::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 == "mpls") { mpls = value; mpls.value_namespace = name_space; mpls.value_namespace_prefix = name_space_prefix; } if(value_path == "vxlan") { vxlan = value; vxlan.value_namespace = name_space; vxlan.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Encap::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "mpls") { mpls.yfilter = yfilter; } if(value_path == "vxlan") { vxlan.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Encap::has_leaf_or_child_of_name(const std::string & name) const { if(name == "mpls" || name == "vxlan") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList::FilterList() : inout{YType::enumeration, "inout"}, as_path_list{YType::uint16, "as-path-list"} { yang_name = "filter-list"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList::~FilterList() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList::has_data() const { if (is_presence_container) return true; return inout.is_set || as_path_list.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList::has_operation() const { return is_set(yfilter) || ydk::is_set(inout.yfilter) || ydk::is_set(as_path_list.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "filter-list"; ADD_KEY_TOKEN(inout, "inout"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (inout.is_set || is_set(inout.yfilter)) leaf_name_data.push_back(inout.get_name_leafdata()); if (as_path_list.is_set || is_set(as_path_list.yfilter)) leaf_name_data.push_back(as_path_list.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList::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 == "inout") { inout = value; inout.value_namespace = name_space; inout.value_namespace_prefix = name_space_prefix; } if(value_path == "as-path-list") { as_path_list = value; as_path_list.value_namespace = name_space; as_path_list.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "inout") { inout.yfilter = yfilter; } if(value_path == "as-path-list") { as_path_list.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList::has_leaf_or_child_of_name(const std::string & name) const { if(name == "inout" || name == "as-path-list") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Inherit::Inherit() : peer_policy{YType::str, "peer-policy"}, peer_session{YType::str, "peer-session"} { yang_name = "inherit"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Inherit::~Inherit() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Inherit::has_data() const { if (is_presence_container) return true; return peer_policy.is_set || peer_session.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Inherit::has_operation() const { return is_set(yfilter) || ydk::is_set(peer_policy.yfilter) || ydk::is_set(peer_session.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Inherit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "inherit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Inherit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (peer_policy.is_set || is_set(peer_policy.yfilter)) leaf_name_data.push_back(peer_policy.get_name_leafdata()); if (peer_session.is_set || is_set(peer_session.yfilter)) leaf_name_data.push_back(peer_session.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Inherit::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Inherit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Inherit::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 == "peer-policy") { peer_policy = value; peer_policy.value_namespace = name_space; peer_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "peer-session") { peer_session = value; peer_session.value_namespace = name_space; peer_session.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Inherit::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "peer-policy") { peer_policy.yfilter = yfilter; } if(value_path == "peer-session") { peer_session.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::Inherit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "peer-policy" || name == "peer-session") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::MaximumPrefix::MaximumPrefix() : max_prefix_no{YType::uint32, "max-prefix-no"}, threshold{YType::uint8, "threshold"}, restart{YType::uint16, "restart"}, warning_only{YType::empty, "warning-only"} { yang_name = "maximum-prefix"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::MaximumPrefix::~MaximumPrefix() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::MaximumPrefix::has_data() const { if (is_presence_container) return true; return max_prefix_no.is_set || threshold.is_set || restart.is_set || warning_only.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::MaximumPrefix::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefix_no.yfilter) || ydk::is_set(threshold.yfilter) || ydk::is_set(restart.yfilter) || ydk::is_set(warning_only.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::MaximumPrefix::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "maximum-prefix"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::MaximumPrefix::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefix_no.is_set || is_set(max_prefix_no.yfilter)) leaf_name_data.push_back(max_prefix_no.get_name_leafdata()); if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); if (restart.is_set || is_set(restart.yfilter)) leaf_name_data.push_back(restart.get_name_leafdata()); if (warning_only.is_set || is_set(warning_only.yfilter)) leaf_name_data.push_back(warning_only.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::MaximumPrefix::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::MaximumPrefix::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::MaximumPrefix::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 == "max-prefix-no") { max_prefix_no = value; max_prefix_no.value_namespace = name_space; max_prefix_no.value_namespace_prefix = name_space_prefix; } if(value_path == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } if(value_path == "restart") { restart = value; restart.value_namespace = name_space; restart.value_namespace_prefix = name_space_prefix; } if(value_path == "warning-only") { warning_only = value; warning_only.value_namespace = name_space; warning_only.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::MaximumPrefix::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefix-no") { max_prefix_no.yfilter = yfilter; } if(value_path == "threshold") { threshold.yfilter = yfilter; } if(value_path == "restart") { restart.yfilter = yfilter; } if(value_path == "warning-only") { warning_only.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::MaximumPrefix::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefix-no" || name == "threshold" || name == "restart" || name == "warning-only") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::NextHopSelf::NextHopSelf() : all{YType::empty, "all"} { yang_name = "next-hop-self"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::NextHopSelf::~NextHopSelf() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::NextHopSelf::has_data() const { if (is_presence_container) return true; return all.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::NextHopSelf::has_operation() const { return is_set(yfilter) || ydk::is_set(all.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::NextHopSelf::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "next-hop-self"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::NextHopSelf::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::NextHopSelf::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::NextHopSelf::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::NextHopSelf::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 == "all") { all = value; all.value_namespace = name_space; all.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::NextHopSelf::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "all") { all.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::NextHopSelf::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList::PrefixList() : inout{YType::enumeration, "inout"}, prefix_list_name{YType::str, "prefix-list-name"} { yang_name = "prefix-list"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList::~PrefixList() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList::has_data() const { if (is_presence_container) return true; return inout.is_set || prefix_list_name.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList::has_operation() const { return is_set(yfilter) || ydk::is_set(inout.yfilter) || ydk::is_set(prefix_list_name.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prefix-list"; ADD_KEY_TOKEN(inout, "inout"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (inout.is_set || is_set(inout.yfilter)) leaf_name_data.push_back(inout.get_name_leafdata()); if (prefix_list_name.is_set || is_set(prefix_list_name.yfilter)) leaf_name_data.push_back(prefix_list_name.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList::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 == "inout") { inout = value; inout.value_namespace = name_space; inout.value_namespace_prefix = name_space_prefix; } if(value_path == "prefix-list-name") { prefix_list_name = value; prefix_list_name.value_namespace = name_space; prefix_list_name.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "inout") { inout.yfilter = yfilter; } if(value_path == "prefix-list-name") { prefix_list_name.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList::has_leaf_or_child_of_name(const std::string & name) const { if(name == "inout" || name == "prefix-list-name") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::RemovePrivateAs() : all(nullptr) // presence node { yang_name = "remove-private-as"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::~RemovePrivateAs() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::has_data() const { if (is_presence_container) return true; return (all != nullptr && all->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::has_operation() const { return is_set(yfilter) || (all != nullptr && all->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "remove-private-as"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "all") { if(all == nullptr) { all = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::All>(); } return all; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(all != nullptr) { _children["all"] = all; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::All::All() : replace_as{YType::empty, "replace-as"} { yang_name = "all"; yang_parent_name = "remove-private-as"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::All::~All() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::All::has_data() const { if (is_presence_container) return true; return replace_as.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::All::has_operation() const { return is_set(yfilter) || ydk::is_set(replace_as.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::All::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "all"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::All::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (replace_as.is_set || is_set(replace_as.yfilter)) leaf_name_data.push_back(replace_as.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::All::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::All::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::All::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 == "replace-as") { replace_as = value; replace_as.value_namespace = name_space; replace_as.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::All::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "replace-as") { replace_as.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RemovePrivateAs::All::has_leaf_or_child_of_name(const std::string & name) const { if(name == "replace-as") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap::RouteMap() : inout{YType::enumeration, "inout"}, route_map_name{YType::str, "route-map-name"} { yang_name = "route-map"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap::~RouteMap() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap::has_data() const { if (is_presence_container) return true; return inout.is_set || route_map_name.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap::has_operation() const { return is_set(yfilter) || ydk::is_set(inout.yfilter) || ydk::is_set(route_map_name.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "route-map"; ADD_KEY_TOKEN(inout, "inout"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (inout.is_set || is_set(inout.yfilter)) leaf_name_data.push_back(inout.get_name_leafdata()); if (route_map_name.is_set || is_set(route_map_name.yfilter)) leaf_name_data.push_back(route_map_name.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap::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 == "inout") { inout = value; inout.value_namespace = name_space; inout.value_namespace_prefix = name_space_prefix; } if(value_path == "route-map-name") { route_map_name = value; route_map_name.value_namespace = name_space; route_map_name.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "inout") { inout.yfilter = yfilter; } if(value_path == "route-map-name") { route_map_name.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap::has_leaf_or_child_of_name(const std::string & name) const { if(name == "inout" || name == "route-map-name") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::SendCommunity() : send_community_where{YType::enumeration, "send-community-where"} { yang_name = "send-community"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::~SendCommunity() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::has_data() const { if (is_presence_container) return true; return send_community_where.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::has_operation() const { return is_set(yfilter) || ydk::is_set(send_community_where.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "send-community"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_community_where.is_set || is_set(send_community_where.yfilter)) leaf_name_data.push_back(send_community_where.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::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 == "send-community-where") { send_community_where = value; send_community_where.value_namespace = name_space; send_community_where.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-community-where") { send_community_where.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-community-where") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SlowPeer() : detection(nullptr) // presence node , split_update_group(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup>()) { split_update_group->parent = this; yang_name = "slow-peer"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::~SlowPeer() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::has_data() const { if (is_presence_container) return true; return (detection != nullptr && detection->has_data()) || (split_update_group != nullptr && split_update_group->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::has_operation() const { return is_set(yfilter) || (detection != nullptr && detection->has_operation()) || (split_update_group != nullptr && split_update_group->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "slow-peer"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "detection") { if(detection == nullptr) { detection = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::Detection>(); } return detection; } if(child_yang_name == "split-update-group") { if(split_update_group == nullptr) { split_update_group = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup>(); } return split_update_group; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(detection != nullptr) { _children["detection"] = detection; } if(split_update_group != nullptr) { _children["split-update-group"] = split_update_group; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::has_leaf_or_child_of_name(const std::string & name) const { if(name == "detection" || name == "split-update-group") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::Detection::Detection() : threshold{YType::uint16, "threshold"} { yang_name = "detection"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::Detection::~Detection() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::Detection::has_data() const { if (is_presence_container) return true; return threshold.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::Detection::has_operation() const { return is_set(yfilter) || ydk::is_set(threshold.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::Detection::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "detection"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::Detection::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::Detection::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::Detection::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::Detection::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 == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::Detection::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "threshold") { threshold.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::Detection::has_leaf_or_child_of_name(const std::string & name) const { if(name == "threshold") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::SplitUpdateGroup() : dynamic(nullptr) // presence node { yang_name = "split-update-group"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::~SplitUpdateGroup() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::has_data() const { if (is_presence_container) return true; return (dynamic != nullptr && dynamic->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::has_operation() const { return is_set(yfilter) || (dynamic != nullptr && dynamic->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "split-update-group"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "dynamic") { if(dynamic == nullptr) { dynamic = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic>(); } return dynamic; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(dynamic != nullptr) { _children["dynamic"] = dynamic; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "dynamic") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::Dynamic() : permanent{YType::empty, "permanent"} { yang_name = "dynamic"; yang_parent_name = "split-update-group"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::~Dynamic() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_data() const { if (is_presence_container) return true; return permanent.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_operation() const { return is_set(yfilter) || ydk::is_set(permanent.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "dynamic"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (permanent.is_set || is_set(permanent.yfilter)) leaf_name_data.push_back(permanent.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::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 == "permanent") { permanent = value; permanent.value_namespace = name_space; permanent.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "permanent") { permanent.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_leaf_or_child_of_name(const std::string & name) const { if(name == "permanent") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::AllowasIn::AllowasIn() : as_number{YType::uint8, "as-number"} { yang_name = "allowas-in"; yang_parent_name = "l2vpn-evpn"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::AllowasIn::~AllowasIn() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::AllowasIn::has_data() const { if (is_presence_container) return true; return as_number.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::AllowasIn::has_operation() const { return is_set(yfilter) || ydk::is_set(as_number.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::AllowasIn::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "allowas-in"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::AllowasIn::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (as_number.is_set || is_set(as_number.yfilter)) leaf_name_data.push_back(as_number.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::AllowasIn::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::AllowasIn::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::AllowasIn::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 == "as-number") { as_number = value; as_number.value_namespace = name_space; as_number.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::AllowasIn::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "as-number") { as_number.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::AllowasIn::has_leaf_or_child_of_name(const std::string & name) const { if(name == "as-number") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Capability() : orf(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf>()) { orf->parent = this; yang_name = "capability"; yang_parent_name = "l2vpn-evpn"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::~Capability() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::has_data() const { if (is_presence_container) return true; return (orf != nullptr && orf->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::has_operation() const { return is_set(yfilter) || (orf != nullptr && orf->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "capability"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "orf") { if(orf == nullptr) { orf = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf>(); } return orf; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(orf != nullptr) { _children["orf"] = orf; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::has_leaf_or_child_of_name(const std::string & name) const { if(name == "orf") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::Orf() : prefix_list{YType::enumeration, "prefix-list"} { yang_name = "orf"; yang_parent_name = "capability"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::~Orf() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::has_data() const { if (is_presence_container) return true; for (auto const & leaf : prefix_list.getYLeafs()) { if(leaf.is_set) return true; } return false; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::has_operation() const { for (auto const & leaf : prefix_list.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(prefix_list.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "orf"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; auto prefix_list_name_datas = prefix_list.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::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 == "prefix-list") { prefix_list.append(value); } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "prefix-list") { prefix_list.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-list") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Inherit::Inherit() : peer_policy{YType::str, "peer-policy"}, peer_session{YType::str, "peer-session"} { yang_name = "inherit"; yang_parent_name = "l2vpn-evpn"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Inherit::~Inherit() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Inherit::has_data() const { if (is_presence_container) return true; return peer_policy.is_set || peer_session.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Inherit::has_operation() const { return is_set(yfilter) || ydk::is_set(peer_policy.yfilter) || ydk::is_set(peer_session.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Inherit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "inherit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Inherit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (peer_policy.is_set || is_set(peer_policy.yfilter)) leaf_name_data.push_back(peer_policy.get_name_leafdata()); if (peer_session.is_set || is_set(peer_session.yfilter)) leaf_name_data.push_back(peer_session.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Inherit::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Inherit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Inherit::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 == "peer-policy") { peer_policy = value; peer_policy.value_namespace = name_space; peer_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "peer-session") { peer_session = value; peer_session.value_namespace = name_space; peer_session.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Inherit::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "peer-policy") { peer_policy.yfilter = yfilter; } if(value_path == "peer-session") { peer_session.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Inherit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "peer-policy" || name == "peer-session") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::MaximumPrefix::MaximumPrefix() : max_prefix_no{YType::uint32, "max-prefix-no"}, threshold{YType::uint8, "threshold"}, restart{YType::uint16, "restart"}, warning_only{YType::empty, "warning-only"} { yang_name = "maximum-prefix"; yang_parent_name = "l2vpn-evpn"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::MaximumPrefix::~MaximumPrefix() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::MaximumPrefix::has_data() const { if (is_presence_container) return true; return max_prefix_no.is_set || threshold.is_set || restart.is_set || warning_only.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::MaximumPrefix::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefix_no.yfilter) || ydk::is_set(threshold.yfilter) || ydk::is_set(restart.yfilter) || ydk::is_set(warning_only.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::MaximumPrefix::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "maximum-prefix"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::MaximumPrefix::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefix_no.is_set || is_set(max_prefix_no.yfilter)) leaf_name_data.push_back(max_prefix_no.get_name_leafdata()); if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); if (restart.is_set || is_set(restart.yfilter)) leaf_name_data.push_back(restart.get_name_leafdata()); if (warning_only.is_set || is_set(warning_only.yfilter)) leaf_name_data.push_back(warning_only.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::MaximumPrefix::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::MaximumPrefix::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::MaximumPrefix::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 == "max-prefix-no") { max_prefix_no = value; max_prefix_no.value_namespace = name_space; max_prefix_no.value_namespace_prefix = name_space_prefix; } if(value_path == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } if(value_path == "restart") { restart = value; restart.value_namespace = name_space; restart.value_namespace_prefix = name_space_prefix; } if(value_path == "warning-only") { warning_only = value; warning_only.value_namespace = name_space; warning_only.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::MaximumPrefix::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefix-no") { max_prefix_no.yfilter = yfilter; } if(value_path == "threshold") { threshold.yfilter = yfilter; } if(value_path == "restart") { restart.yfilter = yfilter; } if(value_path == "warning-only") { warning_only.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::MaximumPrefix::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefix-no" || name == "threshold" || name == "restart" || name == "warning-only") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::NextHopSelf::NextHopSelf() : all{YType::empty, "all"} { yang_name = "next-hop-self"; yang_parent_name = "l2vpn-evpn"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::NextHopSelf::~NextHopSelf() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::NextHopSelf::has_data() const { if (is_presence_container) return true; return all.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::NextHopSelf::has_operation() const { return is_set(yfilter) || ydk::is_set(all.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::NextHopSelf::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "next-hop-self"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::NextHopSelf::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::NextHopSelf::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::NextHopSelf::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::NextHopSelf::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 == "all") { all = value; all.value_namespace = name_space; all.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::NextHopSelf::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "all") { all.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::NextHopSelf::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::RemovePrivateAs() : all(nullptr) // presence node { yang_name = "remove-private-as"; yang_parent_name = "l2vpn-evpn"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::~RemovePrivateAs() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::has_data() const { if (is_presence_container) return true; return (all != nullptr && all->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::has_operation() const { return is_set(yfilter) || (all != nullptr && all->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "remove-private-as"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "all") { if(all == nullptr) { all = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::All>(); } return all; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(all != nullptr) { _children["all"] = all; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::All::All() : replace_as{YType::empty, "replace-as"} { yang_name = "all"; yang_parent_name = "remove-private-as"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::All::~All() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::All::has_data() const { if (is_presence_container) return true; return replace_as.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::All::has_operation() const { return is_set(yfilter) || ydk::is_set(replace_as.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::All::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "all"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::All::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (replace_as.is_set || is_set(replace_as.yfilter)) leaf_name_data.push_back(replace_as.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::All::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::All::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::All::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 == "replace-as") { replace_as = value; replace_as.value_namespace = name_space; replace_as.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::All::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "replace-as") { replace_as.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RemovePrivateAs::All::has_leaf_or_child_of_name(const std::string & name) const { if(name == "replace-as") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RouteMap::RouteMap() : inout{YType::enumeration, "inout"}, route_map_name{YType::str, "route-map-name"} { yang_name = "route-map"; yang_parent_name = "l2vpn-evpn"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RouteMap::~RouteMap() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RouteMap::has_data() const { if (is_presence_container) return true; return inout.is_set || route_map_name.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RouteMap::has_operation() const { return is_set(yfilter) || ydk::is_set(inout.yfilter) || ydk::is_set(route_map_name.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RouteMap::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "route-map"; ADD_KEY_TOKEN(inout, "inout"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RouteMap::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (inout.is_set || is_set(inout.yfilter)) leaf_name_data.push_back(inout.get_name_leafdata()); if (route_map_name.is_set || is_set(route_map_name.yfilter)) leaf_name_data.push_back(route_map_name.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RouteMap::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RouteMap::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RouteMap::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 == "inout") { inout = value; inout.value_namespace = name_space; inout.value_namespace_prefix = name_space_prefix; } if(value_path == "route-map-name") { route_map_name = value; route_map_name.value_namespace = name_space; route_map_name.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RouteMap::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "inout") { inout.yfilter = yfilter; } if(value_path == "route-map-name") { route_map_name.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RouteMap::has_leaf_or_child_of_name(const std::string & name) const { if(name == "inout" || name == "route-map-name") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::SendCommunity() : send_community_where{YType::enumeration, "send-community-where"} { yang_name = "send-community"; yang_parent_name = "l2vpn-evpn"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::~SendCommunity() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::has_data() const { if (is_presence_container) return true; return send_community_where.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::has_operation() const { return is_set(yfilter) || ydk::is_set(send_community_where.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "send-community"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_community_where.is_set || is_set(send_community_where.yfilter)) leaf_name_data.push_back(send_community_where.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::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 == "send-community-where") { send_community_where = value; send_community_where.value_namespace = name_space; send_community_where.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-community-where") { send_community_where.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-community-where") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SlowPeer() : detection(nullptr) // presence node , split_update_group(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup>()) { split_update_group->parent = this; yang_name = "slow-peer"; yang_parent_name = "l2vpn-evpn"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::~SlowPeer() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::has_data() const { if (is_presence_container) return true; return (detection != nullptr && detection->has_data()) || (split_update_group != nullptr && split_update_group->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::has_operation() const { return is_set(yfilter) || (detection != nullptr && detection->has_operation()) || (split_update_group != nullptr && split_update_group->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "slow-peer"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "detection") { if(detection == nullptr) { detection = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::Detection>(); } return detection; } if(child_yang_name == "split-update-group") { if(split_update_group == nullptr) { split_update_group = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup>(); } return split_update_group; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(detection != nullptr) { _children["detection"] = detection; } if(split_update_group != nullptr) { _children["split-update-group"] = split_update_group; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::has_leaf_or_child_of_name(const std::string & name) const { if(name == "detection" || name == "split-update-group") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::Detection::Detection() : threshold{YType::uint16, "threshold"} { yang_name = "detection"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::Detection::~Detection() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::Detection::has_data() const { if (is_presence_container) return true; return threshold.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::Detection::has_operation() const { return is_set(yfilter) || ydk::is_set(threshold.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::Detection::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "detection"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::Detection::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::Detection::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::Detection::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::Detection::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 == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::Detection::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "threshold") { threshold.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::Detection::has_leaf_or_child_of_name(const std::string & name) const { if(name == "threshold") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::SplitUpdateGroup() : dynamic(nullptr) // presence node { yang_name = "split-update-group"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::~SplitUpdateGroup() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::has_data() const { if (is_presence_container) return true; return (dynamic != nullptr && dynamic->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::has_operation() const { return is_set(yfilter) || (dynamic != nullptr && dynamic->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "split-update-group"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "dynamic") { if(dynamic == nullptr) { dynamic = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::Dynamic>(); } return dynamic; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(dynamic != nullptr) { _children["dynamic"] = dynamic; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "dynamic") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::Dynamic::Dynamic() : permanent{YType::empty, "permanent"} { yang_name = "dynamic"; yang_parent_name = "split-update-group"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::Dynamic::~Dynamic() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::Dynamic::has_data() const { if (is_presence_container) return true; return permanent.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::Dynamic::has_operation() const { return is_set(yfilter) || ydk::is_set(permanent.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::Dynamic::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "dynamic"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::Dynamic::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (permanent.is_set || is_set(permanent.yfilter)) leaf_name_data.push_back(permanent.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::Dynamic::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::Dynamic::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::Dynamic::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 == "permanent") { permanent = value; permanent.value_namespace = name_space; permanent.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::Dynamic::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "permanent") { permanent.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SlowPeer::SplitUpdateGroup::Dynamic::has_leaf_or_child_of_name(const std::string & name) const { if(name == "permanent") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::Network() : with_mask(this, {"number", "mask"}) , no_mask(this, {"number"}) { yang_name = "network"; yang_parent_name = "l2vpn-evpn"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::~Network() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<with_mask.len(); index++) { if(with_mask[index]->has_data()) return true; } for (std::size_t index=0; index<no_mask.len(); index++) { if(no_mask[index]->has_data()) return true; } return false; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::has_operation() const { for (std::size_t index=0; index<with_mask.len(); index++) { if(with_mask[index]->has_operation()) return true; } for (std::size_t index=0; index<no_mask.len(); index++) { if(no_mask[index]->has_operation()) return true; } return is_set(yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "network"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "with-mask") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::WithMask>(); ent_->parent = this; with_mask.append(ent_); return ent_; } if(child_yang_name == "no-mask") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::NoMask>(); ent_->parent = this; no_mask.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : with_mask.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } count_ = 0; for (auto ent_ : no_mask.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::has_leaf_or_child_of_name(const std::string & name) const { if(name == "with-mask" || name == "no-mask") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::WithMask::WithMask() : number{YType::str, "number"}, mask{YType::str, "mask"}, route_map{YType::str, "route-map"}, backdoor{YType::empty, "backdoor"} { yang_name = "with-mask"; yang_parent_name = "network"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::WithMask::~WithMask() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::WithMask::has_data() const { if (is_presence_container) return true; return number.is_set || mask.is_set || route_map.is_set || backdoor.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::WithMask::has_operation() const { return is_set(yfilter) || ydk::is_set(number.yfilter) || ydk::is_set(mask.yfilter) || ydk::is_set(route_map.yfilter) || ydk::is_set(backdoor.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::WithMask::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "with-mask"; ADD_KEY_TOKEN(number, "number"); ADD_KEY_TOKEN(mask, "mask"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::WithMask::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (number.is_set || is_set(number.yfilter)) leaf_name_data.push_back(number.get_name_leafdata()); if (mask.is_set || is_set(mask.yfilter)) leaf_name_data.push_back(mask.get_name_leafdata()); if (route_map.is_set || is_set(route_map.yfilter)) leaf_name_data.push_back(route_map.get_name_leafdata()); if (backdoor.is_set || is_set(backdoor.yfilter)) leaf_name_data.push_back(backdoor.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::WithMask::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::WithMask::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::WithMask::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 == "number") { number = value; number.value_namespace = name_space; number.value_namespace_prefix = name_space_prefix; } if(value_path == "mask") { mask = value; mask.value_namespace = name_space; mask.value_namespace_prefix = name_space_prefix; } if(value_path == "route-map") { route_map = value; route_map.value_namespace = name_space; route_map.value_namespace_prefix = name_space_prefix; } if(value_path == "backdoor") { backdoor = value; backdoor.value_namespace = name_space; backdoor.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::WithMask::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "number") { number.yfilter = yfilter; } if(value_path == "mask") { mask.yfilter = yfilter; } if(value_path == "route-map") { route_map.yfilter = yfilter; } if(value_path == "backdoor") { backdoor.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::WithMask::has_leaf_or_child_of_name(const std::string & name) const { if(name == "number" || name == "mask" || name == "route-map" || name == "backdoor") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::NoMask::NoMask() : number{YType::str, "number"}, route_map{YType::str, "route-map"}, backdoor{YType::empty, "backdoor"} { yang_name = "no-mask"; yang_parent_name = "network"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::NoMask::~NoMask() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::NoMask::has_data() const { if (is_presence_container) return true; return number.is_set || route_map.is_set || backdoor.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::NoMask::has_operation() const { return is_set(yfilter) || ydk::is_set(number.yfilter) || ydk::is_set(route_map.yfilter) || ydk::is_set(backdoor.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::NoMask::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "no-mask"; ADD_KEY_TOKEN(number, "number"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::NoMask::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (number.is_set || is_set(number.yfilter)) leaf_name_data.push_back(number.get_name_leafdata()); if (route_map.is_set || is_set(route_map.yfilter)) leaf_name_data.push_back(route_map.get_name_leafdata()); if (backdoor.is_set || is_set(backdoor.yfilter)) leaf_name_data.push_back(backdoor.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::NoMask::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::NoMask::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::NoMask::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 == "number") { number = value; number.value_namespace = name_space; number.value_namespace_prefix = name_space_prefix; } if(value_path == "route-map") { route_map = value; route_map.value_namespace = name_space; route_map.value_namespace_prefix = name_space_prefix; } if(value_path == "backdoor") { backdoor = value; backdoor.value_namespace = name_space; backdoor.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::NoMask::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "number") { number.yfilter = yfilter; } if(value_path == "route-map") { route_map.yfilter = yfilter; } if(value_path == "backdoor") { backdoor.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Network::NoMask::has_leaf_or_child_of_name(const std::string & name) const { if(name == "number" || name == "route-map" || name == "backdoor") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Snmp() : context(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context>()) { context->parent = this; yang_name = "snmp"; yang_parent_name = "l2vpn-evpn"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::~Snmp() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::has_data() const { if (is_presence_container) return true; return (context != nullptr && context->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::has_operation() const { return is_set(yfilter) || (context != nullptr && context->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "snmp"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "context") { if(context == nullptr) { context = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context>(); } return context; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(context != nullptr) { _children["context"] = context; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::has_leaf_or_child_of_name(const std::string & name) const { if(name == "context") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::Context() : context_word(this, {"context_word"}) { yang_name = "context"; yang_parent_name = "snmp"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::~Context() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<context_word.len(); index++) { if(context_word[index]->has_data()) return true; } return false; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::has_operation() const { for (std::size_t index=0; index<context_word.len(); index++) { if(context_word[index]->has_operation()) return true; } return is_set(yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "context"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "context_word") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::ContextWord>(); ent_->parent = this; context_word.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : context_word.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::has_leaf_or_child_of_name(const std::string & name) const { if(name == "context_word") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::ContextWord::ContextWord() : context_word{YType::str, "context_word"} { yang_name = "context_word"; yang_parent_name = "context"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::ContextWord::~ContextWord() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::ContextWord::has_data() const { if (is_presence_container) return true; return context_word.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::ContextWord::has_operation() const { return is_set(yfilter) || ydk::is_set(context_word.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::ContextWord::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "context_word"; ADD_KEY_TOKEN(context_word, "context_word"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::ContextWord::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (context_word.is_set || is_set(context_word.yfilter)) leaf_name_data.push_back(context_word.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::ContextWord::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::ContextWord::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::ContextWord::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 == "context_word") { context_word = value; context_word.value_namespace = name_space; context_word.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::ContextWord::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "context_word") { context_word.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Snmp::Context::ContextWord::has_leaf_or_child_of_name(const std::string & name) const { if(name == "context_word") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::L2vpnVpls() : bgp(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_>()) , default_information(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::DefaultInformation>()) , peer_group(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup>()) , neighbor(this, {"id"}) , snmp(nullptr) // presence node { bgp->parent = this; default_information->parent = this; peer_group->parent = this; yang_name = "l2vpn-vpls"; yang_parent_name = "l2vpn"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::~L2vpnVpls() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<neighbor.len(); index++) { if(neighbor[index]->has_data()) return true; } return (bgp != nullptr && bgp->has_data()) || (default_information != nullptr && default_information->has_data()) || (peer_group != nullptr && peer_group->has_data()) || (snmp != nullptr && snmp->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::has_operation() const { for (std::size_t index=0; index<neighbor.len(); index++) { if(neighbor[index]->has_operation()) return true; } return is_set(yfilter) || (bgp != nullptr && bgp->has_operation()) || (default_information != nullptr && default_information->has_operation()) || (peer_group != nullptr && peer_group->has_operation()) || (snmp != nullptr && snmp->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "l2vpn-vpls"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "bgp") { if(bgp == nullptr) { bgp = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_>(); } return bgp; } if(child_yang_name == "default-information") { if(default_information == nullptr) { default_information = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::DefaultInformation>(); } return default_information; } if(child_yang_name == "peer-group") { if(peer_group == nullptr) { peer_group = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup>(); } return peer_group; } if(child_yang_name == "neighbor") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor>(); ent_->parent = this; neighbor.append(ent_); return ent_; } if(child_yang_name == "snmp") { if(snmp == nullptr) { snmp = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp>(); } return snmp; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(bgp != nullptr) { _children["bgp"] = bgp; } if(default_information != nullptr) { _children["default-information"] = default_information; } if(peer_group != nullptr) { _children["peer-group"] = peer_group; } count_ = 0; for (auto ent_ : neighbor.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } if(snmp != nullptr) { _children["snmp"] = snmp; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::has_leaf_or_child_of_name(const std::string & name) const { if(name == "bgp" || name == "default-information" || name == "peer-group" || name == "neighbor" || name == "snmp") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Bgp_() : scan_time{YType::uint8, "scan-time"} , default_(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default>()) , nexthop(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop>()) , slow_peer(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer>()) { default_->parent = this; nexthop->parent = this; slow_peer->parent = this; yang_name = "bgp"; yang_parent_name = "l2vpn-vpls"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::~Bgp_() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::has_data() const { if (is_presence_container) return true; return scan_time.is_set || (default_ != nullptr && default_->has_data()) || (nexthop != nullptr && nexthop->has_data()) || (slow_peer != nullptr && slow_peer->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::has_operation() const { return is_set(yfilter) || ydk::is_set(scan_time.yfilter) || (default_ != nullptr && default_->has_operation()) || (nexthop != nullptr && nexthop->has_operation()) || (slow_peer != nullptr && slow_peer->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "bgp"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (scan_time.is_set || is_set(scan_time.yfilter)) leaf_name_data.push_back(scan_time.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "default") { if(default_ == nullptr) { default_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default>(); } return default_; } if(child_yang_name == "nexthop") { if(nexthop == nullptr) { nexthop = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop>(); } return nexthop; } if(child_yang_name == "slow-peer") { if(slow_peer == nullptr) { slow_peer = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer>(); } return slow_peer; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(default_ != nullptr) { _children["default"] = default_; } if(nexthop != nullptr) { _children["nexthop"] = nexthop; } if(slow_peer != nullptr) { _children["slow-peer"] = slow_peer; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::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 == "scan-time") { scan_time = value; scan_time.value_namespace = name_space; scan_time.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "scan-time") { scan_time.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::has_leaf_or_child_of_name(const std::string & name) const { if(name == "default" || name == "nexthop" || name == "slow-peer" || name == "scan-time") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default::Default() : route_target{YType::enumeration, "route-target"} { yang_name = "default"; yang_parent_name = "bgp"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default::~Default() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default::has_data() const { if (is_presence_container) return true; return route_target.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default::has_operation() const { return is_set(yfilter) || ydk::is_set(route_target.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "default"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (route_target.is_set || is_set(route_target.yfilter)) leaf_name_data.push_back(route_target.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default::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 == "route-target") { route_target = value; route_target.value_namespace = name_space; route_target.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "route-target") { route_target.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default::has_leaf_or_child_of_name(const std::string & name) const { if(name == "route-target") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Nexthop() : route_map{YType::str, "route-map"} , trigger(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Trigger>()) { trigger->parent = this; yang_name = "nexthop"; yang_parent_name = "bgp"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::~Nexthop() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::has_data() const { if (is_presence_container) return true; return route_map.is_set || (trigger != nullptr && trigger->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::has_operation() const { return is_set(yfilter) || ydk::is_set(route_map.yfilter) || (trigger != nullptr && trigger->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "nexthop"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (route_map.is_set || is_set(route_map.yfilter)) leaf_name_data.push_back(route_map.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "trigger") { if(trigger == nullptr) { trigger = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Trigger>(); } return trigger; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(trigger != nullptr) { _children["trigger"] = trigger; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::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 == "route-map") { route_map = value; route_map.value_namespace = name_space; route_map.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "route-map") { route_map.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::has_leaf_or_child_of_name(const std::string & name) const { if(name == "trigger" || name == "route-map") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Trigger::Trigger() : delay{YType::uint8, "delay"}, enable{YType::boolean, "enable"} { yang_name = "trigger"; yang_parent_name = "nexthop"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Trigger::~Trigger() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Trigger::has_data() const { if (is_presence_container) return true; return delay.is_set || enable.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Trigger::has_operation() const { return is_set(yfilter) || ydk::is_set(delay.yfilter) || ydk::is_set(enable.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Trigger::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "trigger"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Trigger::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (delay.is_set || is_set(delay.yfilter)) leaf_name_data.push_back(delay.get_name_leafdata()); if (enable.is_set || is_set(enable.yfilter)) leaf_name_data.push_back(enable.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Trigger::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Trigger::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Trigger::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 == "delay") { delay = value; delay.value_namespace = name_space; delay.value_namespace_prefix = name_space_prefix; } if(value_path == "enable") { enable = value; enable.value_namespace = name_space; enable.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Trigger::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "delay") { delay.yfilter = yfilter; } if(value_path == "enable") { enable.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Nexthop::Trigger::has_leaf_or_child_of_name(const std::string & name) const { if(name == "delay" || name == "enable") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SlowPeer() : detection(nullptr) // presence node , split_update_group(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup>()) { split_update_group->parent = this; yang_name = "slow-peer"; yang_parent_name = "bgp"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::~SlowPeer() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::has_data() const { if (is_presence_container) return true; return (detection != nullptr && detection->has_data()) || (split_update_group != nullptr && split_update_group->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::has_operation() const { return is_set(yfilter) || (detection != nullptr && detection->has_operation()) || (split_update_group != nullptr && split_update_group->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "slow-peer"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "detection") { if(detection == nullptr) { detection = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::Detection>(); } return detection; } if(child_yang_name == "split-update-group") { if(split_update_group == nullptr) { split_update_group = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup>(); } return split_update_group; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(detection != nullptr) { _children["detection"] = detection; } if(split_update_group != nullptr) { _children["split-update-group"] = split_update_group; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::has_leaf_or_child_of_name(const std::string & name) const { if(name == "detection" || name == "split-update-group") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::Detection::Detection() : disable{YType::empty, "disable"}, threshold{YType::uint16, "threshold"} { yang_name = "detection"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::Detection::~Detection() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::Detection::has_data() const { if (is_presence_container) return true; return disable.is_set || threshold.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::Detection::has_operation() const { return is_set(yfilter) || ydk::is_set(disable.yfilter) || ydk::is_set(threshold.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::Detection::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "detection"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::Detection::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (disable.is_set || is_set(disable.yfilter)) leaf_name_data.push_back(disable.get_name_leafdata()); if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::Detection::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::Detection::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::Detection::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 == "disable") { disable = value; disable.value_namespace = name_space; disable.value_namespace_prefix = name_space_prefix; } if(value_path == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::Detection::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "disable") { disable.yfilter = yfilter; } if(value_path == "threshold") { threshold.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::Detection::has_leaf_or_child_of_name(const std::string & name) const { if(name == "disable" || name == "threshold") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::SplitUpdateGroup() : dynamic(nullptr) // presence node { yang_name = "split-update-group"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::~SplitUpdateGroup() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::has_data() const { if (is_presence_container) return true; return (dynamic != nullptr && dynamic->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::has_operation() const { return is_set(yfilter) || (dynamic != nullptr && dynamic->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "split-update-group"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "dynamic") { if(dynamic == nullptr) { dynamic = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic>(); } return dynamic; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(dynamic != nullptr) { _children["dynamic"] = dynamic; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "dynamic") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::Dynamic() : permanent{YType::empty, "permanent"} { yang_name = "dynamic"; yang_parent_name = "split-update-group"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::~Dynamic() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::has_data() const { if (is_presence_container) return true; return permanent.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::has_operation() const { return is_set(yfilter) || ydk::is_set(permanent.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "dynamic"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (permanent.is_set || is_set(permanent.yfilter)) leaf_name_data.push_back(permanent.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::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 == "permanent") { permanent = value; permanent.value_namespace = name_space; permanent.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "permanent") { permanent.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::has_leaf_or_child_of_name(const std::string & name) const { if(name == "permanent") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::DefaultInformation::DefaultInformation() : originate{YType::empty, "originate"} { yang_name = "default-information"; yang_parent_name = "l2vpn-vpls"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::DefaultInformation::~DefaultInformation() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::DefaultInformation::has_data() const { if (is_presence_container) return true; return originate.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::DefaultInformation::has_operation() const { return is_set(yfilter) || ydk::is_set(originate.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::DefaultInformation::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "default-information"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::DefaultInformation::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (originate.is_set || is_set(originate.yfilter)) leaf_name_data.push_back(originate.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::DefaultInformation::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::DefaultInformation::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::DefaultInformation::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 == "originate") { originate = value; originate.value_namespace = name_space; originate.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::DefaultInformation::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "originate") { originate.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::DefaultInformation::has_leaf_or_child_of_name(const std::string & name) const { if(name == "originate") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::PeerGroup() : neighbor(this, {"id"}) { yang_name = "peer-group"; yang_parent_name = "l2vpn-vpls"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::~PeerGroup() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<neighbor.len(); index++) { if(neighbor[index]->has_data()) return true; } return false; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::has_operation() const { for (std::size_t index=0; index<neighbor.len(); index++) { if(neighbor[index]->has_operation()) return true; } return is_set(yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "peer-group"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "neighbor") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor>(); ent_->parent = this; neighbor.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : neighbor.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "neighbor") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Neighbor() : id{YType::str, "id"}, activate{YType::empty, "activate"}, advertisement_interval{YType::uint16, "advertisement-interval"}, allow_policy{YType::empty, "allow-policy"}, next_hop_unchanged{YType::empty, "next-hop-unchanged"}, route_reflector_client{YType::empty, "route-reflector-client"}, soft_reconfiguration{YType::enumeration, "soft-reconfiguration"}, soo{YType::str, "soo"}, unsuppress_map{YType::str, "unsuppress-map"}, weight{YType::uint16, "weight"} , allowas_in(nullptr) // presence node , capability(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability>()) , inherit(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Inherit>()) , maximum_prefix(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::MaximumPrefix>()) , next_hop_self(nullptr) // presence node , remove_private_as(nullptr) // presence node , route_map(this, {"inout"}) , send_community(nullptr) // presence node , slow_peer(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer>()) { capability->parent = this; inherit->parent = this; maximum_prefix->parent = this; slow_peer->parent = this; yang_name = "neighbor"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::~Neighbor() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<route_map.len(); index++) { if(route_map[index]->has_data()) return true; } return id.is_set || activate.is_set || advertisement_interval.is_set || allow_policy.is_set || next_hop_unchanged.is_set || route_reflector_client.is_set || soft_reconfiguration.is_set || soo.is_set || unsuppress_map.is_set || weight.is_set || (allowas_in != nullptr && allowas_in->has_data()) || (capability != nullptr && capability->has_data()) || (inherit != nullptr && inherit->has_data()) || (maximum_prefix != nullptr && maximum_prefix->has_data()) || (next_hop_self != nullptr && next_hop_self->has_data()) || (remove_private_as != nullptr && remove_private_as->has_data()) || (send_community != nullptr && send_community->has_data()) || (slow_peer != nullptr && slow_peer->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::has_operation() const { for (std::size_t index=0; index<route_map.len(); index++) { if(route_map[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(id.yfilter) || ydk::is_set(activate.yfilter) || ydk::is_set(advertisement_interval.yfilter) || ydk::is_set(allow_policy.yfilter) || ydk::is_set(next_hop_unchanged.yfilter) || ydk::is_set(route_reflector_client.yfilter) || ydk::is_set(soft_reconfiguration.yfilter) || ydk::is_set(soo.yfilter) || ydk::is_set(unsuppress_map.yfilter) || ydk::is_set(weight.yfilter) || (allowas_in != nullptr && allowas_in->has_operation()) || (capability != nullptr && capability->has_operation()) || (inherit != nullptr && inherit->has_operation()) || (maximum_prefix != nullptr && maximum_prefix->has_operation()) || (next_hop_self != nullptr && next_hop_self->has_operation()) || (remove_private_as != nullptr && remove_private_as->has_operation()) || (send_community != nullptr && send_community->has_operation()) || (slow_peer != nullptr && slow_peer->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "neighbor"; ADD_KEY_TOKEN(id, "id"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (id.is_set || is_set(id.yfilter)) leaf_name_data.push_back(id.get_name_leafdata()); if (activate.is_set || is_set(activate.yfilter)) leaf_name_data.push_back(activate.get_name_leafdata()); if (advertisement_interval.is_set || is_set(advertisement_interval.yfilter)) leaf_name_data.push_back(advertisement_interval.get_name_leafdata()); if (allow_policy.is_set || is_set(allow_policy.yfilter)) leaf_name_data.push_back(allow_policy.get_name_leafdata()); if (next_hop_unchanged.is_set || is_set(next_hop_unchanged.yfilter)) leaf_name_data.push_back(next_hop_unchanged.get_name_leafdata()); if (route_reflector_client.is_set || is_set(route_reflector_client.yfilter)) leaf_name_data.push_back(route_reflector_client.get_name_leafdata()); if (soft_reconfiguration.is_set || is_set(soft_reconfiguration.yfilter)) leaf_name_data.push_back(soft_reconfiguration.get_name_leafdata()); if (soo.is_set || is_set(soo.yfilter)) leaf_name_data.push_back(soo.get_name_leafdata()); if (unsuppress_map.is_set || is_set(unsuppress_map.yfilter)) leaf_name_data.push_back(unsuppress_map.get_name_leafdata()); if (weight.is_set || is_set(weight.yfilter)) leaf_name_data.push_back(weight.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "allowas-in") { if(allowas_in == nullptr) { allowas_in = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::AllowasIn>(); } return allowas_in; } if(child_yang_name == "capability") { if(capability == nullptr) { capability = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability>(); } return capability; } if(child_yang_name == "inherit") { if(inherit == nullptr) { inherit = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Inherit>(); } return inherit; } if(child_yang_name == "maximum-prefix") { if(maximum_prefix == nullptr) { maximum_prefix = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::MaximumPrefix>(); } return maximum_prefix; } if(child_yang_name == "next-hop-self") { if(next_hop_self == nullptr) { next_hop_self = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::NextHopSelf>(); } return next_hop_self; } if(child_yang_name == "remove-private-as") { if(remove_private_as == nullptr) { remove_private_as = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs>(); } return remove_private_as; } if(child_yang_name == "route-map") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap>(); ent_->parent = this; route_map.append(ent_); return ent_; } if(child_yang_name == "send-community") { if(send_community == nullptr) { send_community = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity>(); } return send_community; } if(child_yang_name == "slow-peer") { if(slow_peer == nullptr) { slow_peer = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer>(); } return slow_peer; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(allowas_in != nullptr) { _children["allowas-in"] = allowas_in; } if(capability != nullptr) { _children["capability"] = capability; } if(inherit != nullptr) { _children["inherit"] = inherit; } if(maximum_prefix != nullptr) { _children["maximum-prefix"] = maximum_prefix; } if(next_hop_self != nullptr) { _children["next-hop-self"] = next_hop_self; } if(remove_private_as != nullptr) { _children["remove-private-as"] = remove_private_as; } count_ = 0; for (auto ent_ : route_map.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } if(send_community != nullptr) { _children["send-community"] = send_community; } if(slow_peer != nullptr) { _children["slow-peer"] = slow_peer; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::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 == "id") { id = value; id.value_namespace = name_space; id.value_namespace_prefix = name_space_prefix; } if(value_path == "activate") { activate = value; activate.value_namespace = name_space; activate.value_namespace_prefix = name_space_prefix; } if(value_path == "advertisement-interval") { advertisement_interval = value; advertisement_interval.value_namespace = name_space; advertisement_interval.value_namespace_prefix = name_space_prefix; } if(value_path == "allow-policy") { allow_policy = value; allow_policy.value_namespace = name_space; allow_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "next-hop-unchanged") { next_hop_unchanged = value; next_hop_unchanged.value_namespace = name_space; next_hop_unchanged.value_namespace_prefix = name_space_prefix; } if(value_path == "route-reflector-client") { route_reflector_client = value; route_reflector_client.value_namespace = name_space; route_reflector_client.value_namespace_prefix = name_space_prefix; } if(value_path == "soft-reconfiguration") { soft_reconfiguration = value; soft_reconfiguration.value_namespace = name_space; soft_reconfiguration.value_namespace_prefix = name_space_prefix; } if(value_path == "soo") { soo = value; soo.value_namespace = name_space; soo.value_namespace_prefix = name_space_prefix; } if(value_path == "unsuppress-map") { unsuppress_map = value; unsuppress_map.value_namespace = name_space; unsuppress_map.value_namespace_prefix = name_space_prefix; } if(value_path == "weight") { weight = value; weight.value_namespace = name_space; weight.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "id") { id.yfilter = yfilter; } if(value_path == "activate") { activate.yfilter = yfilter; } if(value_path == "advertisement-interval") { advertisement_interval.yfilter = yfilter; } if(value_path == "allow-policy") { allow_policy.yfilter = yfilter; } if(value_path == "next-hop-unchanged") { next_hop_unchanged.yfilter = yfilter; } if(value_path == "route-reflector-client") { route_reflector_client.yfilter = yfilter; } if(value_path == "soft-reconfiguration") { soft_reconfiguration.yfilter = yfilter; } if(value_path == "soo") { soo.yfilter = yfilter; } if(value_path == "unsuppress-map") { unsuppress_map.yfilter = yfilter; } if(value_path == "weight") { weight.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allowas-in" || name == "capability" || name == "inherit" || name == "maximum-prefix" || name == "next-hop-self" || name == "remove-private-as" || name == "route-map" || name == "send-community" || name == "slow-peer" || name == "id" || name == "activate" || name == "advertisement-interval" || name == "allow-policy" || name == "next-hop-unchanged" || name == "route-reflector-client" || name == "soft-reconfiguration" || name == "soo" || name == "unsuppress-map" || name == "weight") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::AllowasIn::AllowasIn() : as_number{YType::uint8, "as-number"} { yang_name = "allowas-in"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::AllowasIn::~AllowasIn() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::AllowasIn::has_data() const { if (is_presence_container) return true; return as_number.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::AllowasIn::has_operation() const { return is_set(yfilter) || ydk::is_set(as_number.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::AllowasIn::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "allowas-in"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::AllowasIn::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (as_number.is_set || is_set(as_number.yfilter)) leaf_name_data.push_back(as_number.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::AllowasIn::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::AllowasIn::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::AllowasIn::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 == "as-number") { as_number = value; as_number.value_namespace = name_space; as_number.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::AllowasIn::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "as-number") { as_number.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::AllowasIn::has_leaf_or_child_of_name(const std::string & name) const { if(name == "as-number") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Capability() : orf(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf>()) { orf->parent = this; yang_name = "capability"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::~Capability() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::has_data() const { if (is_presence_container) return true; return (orf != nullptr && orf->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::has_operation() const { return is_set(yfilter) || (orf != nullptr && orf->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "capability"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "orf") { if(orf == nullptr) { orf = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf>(); } return orf; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(orf != nullptr) { _children["orf"] = orf; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::has_leaf_or_child_of_name(const std::string & name) const { if(name == "orf") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::Orf() : prefix_list{YType::enumeration, "prefix-list"} { yang_name = "orf"; yang_parent_name = "capability"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::~Orf() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::has_data() const { if (is_presence_container) return true; for (auto const & leaf : prefix_list.getYLeafs()) { if(leaf.is_set) return true; } return false; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::has_operation() const { for (auto const & leaf : prefix_list.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(prefix_list.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "orf"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; auto prefix_list_name_datas = prefix_list.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::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 == "prefix-list") { prefix_list.append(value); } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "prefix-list") { prefix_list.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-list") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Inherit::Inherit() : peer_policy{YType::str, "peer-policy"}, peer_session{YType::str, "peer-session"} { yang_name = "inherit"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Inherit::~Inherit() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Inherit::has_data() const { if (is_presence_container) return true; return peer_policy.is_set || peer_session.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Inherit::has_operation() const { return is_set(yfilter) || ydk::is_set(peer_policy.yfilter) || ydk::is_set(peer_session.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Inherit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "inherit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Inherit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (peer_policy.is_set || is_set(peer_policy.yfilter)) leaf_name_data.push_back(peer_policy.get_name_leafdata()); if (peer_session.is_set || is_set(peer_session.yfilter)) leaf_name_data.push_back(peer_session.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Inherit::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Inherit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Inherit::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 == "peer-policy") { peer_policy = value; peer_policy.value_namespace = name_space; peer_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "peer-session") { peer_session = value; peer_session.value_namespace = name_space; peer_session.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Inherit::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "peer-policy") { peer_policy.yfilter = yfilter; } if(value_path == "peer-session") { peer_session.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Inherit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "peer-policy" || name == "peer-session") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::MaximumPrefix::MaximumPrefix() : max_prefix_no{YType::uint32, "max-prefix-no"}, threshold{YType::uint8, "threshold"}, restart{YType::uint16, "restart"}, warning_only{YType::empty, "warning-only"} { yang_name = "maximum-prefix"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::MaximumPrefix::~MaximumPrefix() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::MaximumPrefix::has_data() const { if (is_presence_container) return true; return max_prefix_no.is_set || threshold.is_set || restart.is_set || warning_only.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::MaximumPrefix::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefix_no.yfilter) || ydk::is_set(threshold.yfilter) || ydk::is_set(restart.yfilter) || ydk::is_set(warning_only.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::MaximumPrefix::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "maximum-prefix"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::MaximumPrefix::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefix_no.is_set || is_set(max_prefix_no.yfilter)) leaf_name_data.push_back(max_prefix_no.get_name_leafdata()); if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); if (restart.is_set || is_set(restart.yfilter)) leaf_name_data.push_back(restart.get_name_leafdata()); if (warning_only.is_set || is_set(warning_only.yfilter)) leaf_name_data.push_back(warning_only.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::MaximumPrefix::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::MaximumPrefix::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::MaximumPrefix::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 == "max-prefix-no") { max_prefix_no = value; max_prefix_no.value_namespace = name_space; max_prefix_no.value_namespace_prefix = name_space_prefix; } if(value_path == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } if(value_path == "restart") { restart = value; restart.value_namespace = name_space; restart.value_namespace_prefix = name_space_prefix; } if(value_path == "warning-only") { warning_only = value; warning_only.value_namespace = name_space; warning_only.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::MaximumPrefix::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefix-no") { max_prefix_no.yfilter = yfilter; } if(value_path == "threshold") { threshold.yfilter = yfilter; } if(value_path == "restart") { restart.yfilter = yfilter; } if(value_path == "warning-only") { warning_only.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::MaximumPrefix::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefix-no" || name == "threshold" || name == "restart" || name == "warning-only") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::NextHopSelf::NextHopSelf() : all{YType::empty, "all"} { yang_name = "next-hop-self"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::NextHopSelf::~NextHopSelf() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::NextHopSelf::has_data() const { if (is_presence_container) return true; return all.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::NextHopSelf::has_operation() const { return is_set(yfilter) || ydk::is_set(all.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::NextHopSelf::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "next-hop-self"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::NextHopSelf::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::NextHopSelf::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::NextHopSelf::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::NextHopSelf::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 == "all") { all = value; all.value_namespace = name_space; all.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::NextHopSelf::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "all") { all.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::NextHopSelf::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::RemovePrivateAs() : all(nullptr) // presence node { yang_name = "remove-private-as"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::~RemovePrivateAs() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::has_data() const { if (is_presence_container) return true; return (all != nullptr && all->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::has_operation() const { return is_set(yfilter) || (all != nullptr && all->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "remove-private-as"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "all") { if(all == nullptr) { all = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::All>(); } return all; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(all != nullptr) { _children["all"] = all; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::All::All() : replace_as{YType::empty, "replace-as"} { yang_name = "all"; yang_parent_name = "remove-private-as"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::All::~All() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::All::has_data() const { if (is_presence_container) return true; return replace_as.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::All::has_operation() const { return is_set(yfilter) || ydk::is_set(replace_as.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::All::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "all"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::All::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (replace_as.is_set || is_set(replace_as.yfilter)) leaf_name_data.push_back(replace_as.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::All::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::All::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::All::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 == "replace-as") { replace_as = value; replace_as.value_namespace = name_space; replace_as.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::All::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "replace-as") { replace_as.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RemovePrivateAs::All::has_leaf_or_child_of_name(const std::string & name) const { if(name == "replace-as") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap::RouteMap() : inout{YType::enumeration, "inout"}, route_map_name{YType::str, "route-map-name"} { yang_name = "route-map"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap::~RouteMap() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap::has_data() const { if (is_presence_container) return true; return inout.is_set || route_map_name.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap::has_operation() const { return is_set(yfilter) || ydk::is_set(inout.yfilter) || ydk::is_set(route_map_name.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "route-map"; ADD_KEY_TOKEN(inout, "inout"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (inout.is_set || is_set(inout.yfilter)) leaf_name_data.push_back(inout.get_name_leafdata()); if (route_map_name.is_set || is_set(route_map_name.yfilter)) leaf_name_data.push_back(route_map_name.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap::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 == "inout") { inout = value; inout.value_namespace = name_space; inout.value_namespace_prefix = name_space_prefix; } if(value_path == "route-map-name") { route_map_name = value; route_map_name.value_namespace = name_space; route_map_name.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "inout") { inout.yfilter = yfilter; } if(value_path == "route-map-name") { route_map_name.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap::has_leaf_or_child_of_name(const std::string & name) const { if(name == "inout" || name == "route-map-name") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::SendCommunity() : send_community_where{YType::enumeration, "send-community-where"} { yang_name = "send-community"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::~SendCommunity() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::has_data() const { if (is_presence_container) return true; return send_community_where.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::has_operation() const { return is_set(yfilter) || ydk::is_set(send_community_where.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "send-community"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_community_where.is_set || is_set(send_community_where.yfilter)) leaf_name_data.push_back(send_community_where.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::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 == "send-community-where") { send_community_where = value; send_community_where.value_namespace = name_space; send_community_where.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-community-where") { send_community_where.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-community-where") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SlowPeer() : detection(nullptr) // presence node , split_update_group(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup>()) { split_update_group->parent = this; yang_name = "slow-peer"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::~SlowPeer() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::has_data() const { if (is_presence_container) return true; return (detection != nullptr && detection->has_data()) || (split_update_group != nullptr && split_update_group->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::has_operation() const { return is_set(yfilter) || (detection != nullptr && detection->has_operation()) || (split_update_group != nullptr && split_update_group->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "slow-peer"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "detection") { if(detection == nullptr) { detection = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::Detection>(); } return detection; } if(child_yang_name == "split-update-group") { if(split_update_group == nullptr) { split_update_group = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup>(); } return split_update_group; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(detection != nullptr) { _children["detection"] = detection; } if(split_update_group != nullptr) { _children["split-update-group"] = split_update_group; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::has_leaf_or_child_of_name(const std::string & name) const { if(name == "detection" || name == "split-update-group") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::Detection::Detection() : threshold{YType::uint16, "threshold"} { yang_name = "detection"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::Detection::~Detection() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::Detection::has_data() const { if (is_presence_container) return true; return threshold.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::Detection::has_operation() const { return is_set(yfilter) || ydk::is_set(threshold.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::Detection::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "detection"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::Detection::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::Detection::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::Detection::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::Detection::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 == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::Detection::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "threshold") { threshold.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::Detection::has_leaf_or_child_of_name(const std::string & name) const { if(name == "threshold") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::SplitUpdateGroup() : dynamic(nullptr) // presence node { yang_name = "split-update-group"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::~SplitUpdateGroup() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::has_data() const { if (is_presence_container) return true; return (dynamic != nullptr && dynamic->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::has_operation() const { return is_set(yfilter) || (dynamic != nullptr && dynamic->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "split-update-group"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "dynamic") { if(dynamic == nullptr) { dynamic = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic>(); } return dynamic; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(dynamic != nullptr) { _children["dynamic"] = dynamic; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "dynamic") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::Dynamic() : permanent{YType::empty, "permanent"} { yang_name = "dynamic"; yang_parent_name = "split-update-group"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::~Dynamic() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_data() const { if (is_presence_container) return true; return permanent.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_operation() const { return is_set(yfilter) || ydk::is_set(permanent.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "dynamic"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (permanent.is_set || is_set(permanent.yfilter)) leaf_name_data.push_back(permanent.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::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 == "permanent") { permanent = value; permanent.value_namespace = name_space; permanent.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "permanent") { permanent.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_leaf_or_child_of_name(const std::string & name) const { if(name == "permanent") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Neighbor() : id{YType::str, "id"}, activate{YType::empty, "activate"}, advertisement_interval{YType::uint16, "advertisement-interval"}, allow_policy{YType::empty, "allow-policy"}, next_hop_unchanged{YType::empty, "next-hop-unchanged"}, route_reflector_client{YType::empty, "route-reflector-client"}, soft_reconfiguration{YType::enumeration, "soft-reconfiguration"}, soo{YType::str, "soo"}, unsuppress_map{YType::str, "unsuppress-map"}, weight{YType::uint16, "weight"} , allowas_in(nullptr) // presence node , capability(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability>()) , inherit(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Inherit>()) , maximum_prefix(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::MaximumPrefix>()) , next_hop_self(nullptr) // presence node , remove_private_as(nullptr) // presence node , route_map(this, {"inout"}) , send_community(nullptr) // presence node , slow_peer(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer>()) { capability->parent = this; inherit->parent = this; maximum_prefix->parent = this; slow_peer->parent = this; yang_name = "neighbor"; yang_parent_name = "l2vpn-vpls"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::~Neighbor() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<route_map.len(); index++) { if(route_map[index]->has_data()) return true; } return id.is_set || activate.is_set || advertisement_interval.is_set || allow_policy.is_set || next_hop_unchanged.is_set || route_reflector_client.is_set || soft_reconfiguration.is_set || soo.is_set || unsuppress_map.is_set || weight.is_set || (allowas_in != nullptr && allowas_in->has_data()) || (capability != nullptr && capability->has_data()) || (inherit != nullptr && inherit->has_data()) || (maximum_prefix != nullptr && maximum_prefix->has_data()) || (next_hop_self != nullptr && next_hop_self->has_data()) || (remove_private_as != nullptr && remove_private_as->has_data()) || (send_community != nullptr && send_community->has_data()) || (slow_peer != nullptr && slow_peer->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::has_operation() const { for (std::size_t index=0; index<route_map.len(); index++) { if(route_map[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(id.yfilter) || ydk::is_set(activate.yfilter) || ydk::is_set(advertisement_interval.yfilter) || ydk::is_set(allow_policy.yfilter) || ydk::is_set(next_hop_unchanged.yfilter) || ydk::is_set(route_reflector_client.yfilter) || ydk::is_set(soft_reconfiguration.yfilter) || ydk::is_set(soo.yfilter) || ydk::is_set(unsuppress_map.yfilter) || ydk::is_set(weight.yfilter) || (allowas_in != nullptr && allowas_in->has_operation()) || (capability != nullptr && capability->has_operation()) || (inherit != nullptr && inherit->has_operation()) || (maximum_prefix != nullptr && maximum_prefix->has_operation()) || (next_hop_self != nullptr && next_hop_self->has_operation()) || (remove_private_as != nullptr && remove_private_as->has_operation()) || (send_community != nullptr && send_community->has_operation()) || (slow_peer != nullptr && slow_peer->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "neighbor"; ADD_KEY_TOKEN(id, "id"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (id.is_set || is_set(id.yfilter)) leaf_name_data.push_back(id.get_name_leafdata()); if (activate.is_set || is_set(activate.yfilter)) leaf_name_data.push_back(activate.get_name_leafdata()); if (advertisement_interval.is_set || is_set(advertisement_interval.yfilter)) leaf_name_data.push_back(advertisement_interval.get_name_leafdata()); if (allow_policy.is_set || is_set(allow_policy.yfilter)) leaf_name_data.push_back(allow_policy.get_name_leafdata()); if (next_hop_unchanged.is_set || is_set(next_hop_unchanged.yfilter)) leaf_name_data.push_back(next_hop_unchanged.get_name_leafdata()); if (route_reflector_client.is_set || is_set(route_reflector_client.yfilter)) leaf_name_data.push_back(route_reflector_client.get_name_leafdata()); if (soft_reconfiguration.is_set || is_set(soft_reconfiguration.yfilter)) leaf_name_data.push_back(soft_reconfiguration.get_name_leafdata()); if (soo.is_set || is_set(soo.yfilter)) leaf_name_data.push_back(soo.get_name_leafdata()); if (unsuppress_map.is_set || is_set(unsuppress_map.yfilter)) leaf_name_data.push_back(unsuppress_map.get_name_leafdata()); if (weight.is_set || is_set(weight.yfilter)) leaf_name_data.push_back(weight.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "allowas-in") { if(allowas_in == nullptr) { allowas_in = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::AllowasIn>(); } return allowas_in; } if(child_yang_name == "capability") { if(capability == nullptr) { capability = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability>(); } return capability; } if(child_yang_name == "inherit") { if(inherit == nullptr) { inherit = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Inherit>(); } return inherit; } if(child_yang_name == "maximum-prefix") { if(maximum_prefix == nullptr) { maximum_prefix = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::MaximumPrefix>(); } return maximum_prefix; } if(child_yang_name == "next-hop-self") { if(next_hop_self == nullptr) { next_hop_self = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::NextHopSelf>(); } return next_hop_self; } if(child_yang_name == "remove-private-as") { if(remove_private_as == nullptr) { remove_private_as = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs>(); } return remove_private_as; } if(child_yang_name == "route-map") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap>(); ent_->parent = this; route_map.append(ent_); return ent_; } if(child_yang_name == "send-community") { if(send_community == nullptr) { send_community = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity>(); } return send_community; } if(child_yang_name == "slow-peer") { if(slow_peer == nullptr) { slow_peer = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer>(); } return slow_peer; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(allowas_in != nullptr) { _children["allowas-in"] = allowas_in; } if(capability != nullptr) { _children["capability"] = capability; } if(inherit != nullptr) { _children["inherit"] = inherit; } if(maximum_prefix != nullptr) { _children["maximum-prefix"] = maximum_prefix; } if(next_hop_self != nullptr) { _children["next-hop-self"] = next_hop_self; } if(remove_private_as != nullptr) { _children["remove-private-as"] = remove_private_as; } count_ = 0; for (auto ent_ : route_map.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } if(send_community != nullptr) { _children["send-community"] = send_community; } if(slow_peer != nullptr) { _children["slow-peer"] = slow_peer; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::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 == "id") { id = value; id.value_namespace = name_space; id.value_namespace_prefix = name_space_prefix; } if(value_path == "activate") { activate = value; activate.value_namespace = name_space; activate.value_namespace_prefix = name_space_prefix; } if(value_path == "advertisement-interval") { advertisement_interval = value; advertisement_interval.value_namespace = name_space; advertisement_interval.value_namespace_prefix = name_space_prefix; } if(value_path == "allow-policy") { allow_policy = value; allow_policy.value_namespace = name_space; allow_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "next-hop-unchanged") { next_hop_unchanged = value; next_hop_unchanged.value_namespace = name_space; next_hop_unchanged.value_namespace_prefix = name_space_prefix; } if(value_path == "route-reflector-client") { route_reflector_client = value; route_reflector_client.value_namespace = name_space; route_reflector_client.value_namespace_prefix = name_space_prefix; } if(value_path == "soft-reconfiguration") { soft_reconfiguration = value; soft_reconfiguration.value_namespace = name_space; soft_reconfiguration.value_namespace_prefix = name_space_prefix; } if(value_path == "soo") { soo = value; soo.value_namespace = name_space; soo.value_namespace_prefix = name_space_prefix; } if(value_path == "unsuppress-map") { unsuppress_map = value; unsuppress_map.value_namespace = name_space; unsuppress_map.value_namespace_prefix = name_space_prefix; } if(value_path == "weight") { weight = value; weight.value_namespace = name_space; weight.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "id") { id.yfilter = yfilter; } if(value_path == "activate") { activate.yfilter = yfilter; } if(value_path == "advertisement-interval") { advertisement_interval.yfilter = yfilter; } if(value_path == "allow-policy") { allow_policy.yfilter = yfilter; } if(value_path == "next-hop-unchanged") { next_hop_unchanged.yfilter = yfilter; } if(value_path == "route-reflector-client") { route_reflector_client.yfilter = yfilter; } if(value_path == "soft-reconfiguration") { soft_reconfiguration.yfilter = yfilter; } if(value_path == "soo") { soo.yfilter = yfilter; } if(value_path == "unsuppress-map") { unsuppress_map.yfilter = yfilter; } if(value_path == "weight") { weight.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allowas-in" || name == "capability" || name == "inherit" || name == "maximum-prefix" || name == "next-hop-self" || name == "remove-private-as" || name == "route-map" || name == "send-community" || name == "slow-peer" || name == "id" || name == "activate" || name == "advertisement-interval" || name == "allow-policy" || name == "next-hop-unchanged" || name == "route-reflector-client" || name == "soft-reconfiguration" || name == "soo" || name == "unsuppress-map" || name == "weight") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::AllowasIn::AllowasIn() : as_number{YType::uint8, "as-number"} { yang_name = "allowas-in"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::AllowasIn::~AllowasIn() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::AllowasIn::has_data() const { if (is_presence_container) return true; return as_number.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::AllowasIn::has_operation() const { return is_set(yfilter) || ydk::is_set(as_number.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::AllowasIn::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "allowas-in"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::AllowasIn::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (as_number.is_set || is_set(as_number.yfilter)) leaf_name_data.push_back(as_number.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::AllowasIn::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::AllowasIn::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::AllowasIn::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 == "as-number") { as_number = value; as_number.value_namespace = name_space; as_number.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::AllowasIn::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "as-number") { as_number.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::AllowasIn::has_leaf_or_child_of_name(const std::string & name) const { if(name == "as-number") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Capability() : orf(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf>()) { orf->parent = this; yang_name = "capability"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::~Capability() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::has_data() const { if (is_presence_container) return true; return (orf != nullptr && orf->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::has_operation() const { return is_set(yfilter) || (orf != nullptr && orf->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "capability"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "orf") { if(orf == nullptr) { orf = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf>(); } return orf; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(orf != nullptr) { _children["orf"] = orf; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::has_leaf_or_child_of_name(const std::string & name) const { if(name == "orf") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::Orf() : prefix_list{YType::enumeration, "prefix-list"} { yang_name = "orf"; yang_parent_name = "capability"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::~Orf() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::has_data() const { if (is_presence_container) return true; for (auto const & leaf : prefix_list.getYLeafs()) { if(leaf.is_set) return true; } return false; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::has_operation() const { for (auto const & leaf : prefix_list.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(prefix_list.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "orf"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; auto prefix_list_name_datas = prefix_list.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::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 == "prefix-list") { prefix_list.append(value); } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "prefix-list") { prefix_list.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-list") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Inherit::Inherit() : peer_policy{YType::str, "peer-policy"}, peer_session{YType::str, "peer-session"} { yang_name = "inherit"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Inherit::~Inherit() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Inherit::has_data() const { if (is_presence_container) return true; return peer_policy.is_set || peer_session.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Inherit::has_operation() const { return is_set(yfilter) || ydk::is_set(peer_policy.yfilter) || ydk::is_set(peer_session.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Inherit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "inherit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Inherit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (peer_policy.is_set || is_set(peer_policy.yfilter)) leaf_name_data.push_back(peer_policy.get_name_leafdata()); if (peer_session.is_set || is_set(peer_session.yfilter)) leaf_name_data.push_back(peer_session.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Inherit::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Inherit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Inherit::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 == "peer-policy") { peer_policy = value; peer_policy.value_namespace = name_space; peer_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "peer-session") { peer_session = value; peer_session.value_namespace = name_space; peer_session.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Inherit::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "peer-policy") { peer_policy.yfilter = yfilter; } if(value_path == "peer-session") { peer_session.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Inherit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "peer-policy" || name == "peer-session") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::MaximumPrefix::MaximumPrefix() : max_prefix_no{YType::uint32, "max-prefix-no"}, threshold{YType::uint8, "threshold"}, restart{YType::uint16, "restart"}, warning_only{YType::empty, "warning-only"} { yang_name = "maximum-prefix"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::MaximumPrefix::~MaximumPrefix() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::MaximumPrefix::has_data() const { if (is_presence_container) return true; return max_prefix_no.is_set || threshold.is_set || restart.is_set || warning_only.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::MaximumPrefix::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefix_no.yfilter) || ydk::is_set(threshold.yfilter) || ydk::is_set(restart.yfilter) || ydk::is_set(warning_only.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::MaximumPrefix::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "maximum-prefix"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::MaximumPrefix::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefix_no.is_set || is_set(max_prefix_no.yfilter)) leaf_name_data.push_back(max_prefix_no.get_name_leafdata()); if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); if (restart.is_set || is_set(restart.yfilter)) leaf_name_data.push_back(restart.get_name_leafdata()); if (warning_only.is_set || is_set(warning_only.yfilter)) leaf_name_data.push_back(warning_only.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::MaximumPrefix::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::MaximumPrefix::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::MaximumPrefix::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 == "max-prefix-no") { max_prefix_no = value; max_prefix_no.value_namespace = name_space; max_prefix_no.value_namespace_prefix = name_space_prefix; } if(value_path == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } if(value_path == "restart") { restart = value; restart.value_namespace = name_space; restart.value_namespace_prefix = name_space_prefix; } if(value_path == "warning-only") { warning_only = value; warning_only.value_namespace = name_space; warning_only.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::MaximumPrefix::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefix-no") { max_prefix_no.yfilter = yfilter; } if(value_path == "threshold") { threshold.yfilter = yfilter; } if(value_path == "restart") { restart.yfilter = yfilter; } if(value_path == "warning-only") { warning_only.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::MaximumPrefix::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefix-no" || name == "threshold" || name == "restart" || name == "warning-only") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::NextHopSelf::NextHopSelf() : all{YType::empty, "all"} { yang_name = "next-hop-self"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::NextHopSelf::~NextHopSelf() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::NextHopSelf::has_data() const { if (is_presence_container) return true; return all.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::NextHopSelf::has_operation() const { return is_set(yfilter) || ydk::is_set(all.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::NextHopSelf::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "next-hop-self"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::NextHopSelf::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::NextHopSelf::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::NextHopSelf::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::NextHopSelf::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 == "all") { all = value; all.value_namespace = name_space; all.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::NextHopSelf::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "all") { all.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::NextHopSelf::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::RemovePrivateAs() : all(nullptr) // presence node { yang_name = "remove-private-as"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::~RemovePrivateAs() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::has_data() const { if (is_presence_container) return true; return (all != nullptr && all->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::has_operation() const { return is_set(yfilter) || (all != nullptr && all->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "remove-private-as"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "all") { if(all == nullptr) { all = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::All>(); } return all; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(all != nullptr) { _children["all"] = all; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::All::All() : replace_as{YType::empty, "replace-as"} { yang_name = "all"; yang_parent_name = "remove-private-as"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::All::~All() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::All::has_data() const { if (is_presence_container) return true; return replace_as.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::All::has_operation() const { return is_set(yfilter) || ydk::is_set(replace_as.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::All::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "all"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::All::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (replace_as.is_set || is_set(replace_as.yfilter)) leaf_name_data.push_back(replace_as.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::All::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::All::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::All::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 == "replace-as") { replace_as = value; replace_as.value_namespace = name_space; replace_as.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::All::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "replace-as") { replace_as.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RemovePrivateAs::All::has_leaf_or_child_of_name(const std::string & name) const { if(name == "replace-as") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap::RouteMap() : inout{YType::enumeration, "inout"}, route_map_name{YType::str, "route-map-name"} { yang_name = "route-map"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap::~RouteMap() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap::has_data() const { if (is_presence_container) return true; return inout.is_set || route_map_name.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap::has_operation() const { return is_set(yfilter) || ydk::is_set(inout.yfilter) || ydk::is_set(route_map_name.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "route-map"; ADD_KEY_TOKEN(inout, "inout"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (inout.is_set || is_set(inout.yfilter)) leaf_name_data.push_back(inout.get_name_leafdata()); if (route_map_name.is_set || is_set(route_map_name.yfilter)) leaf_name_data.push_back(route_map_name.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap::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 == "inout") { inout = value; inout.value_namespace = name_space; inout.value_namespace_prefix = name_space_prefix; } if(value_path == "route-map-name") { route_map_name = value; route_map_name.value_namespace = name_space; route_map_name.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "inout") { inout.yfilter = yfilter; } if(value_path == "route-map-name") { route_map_name.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap::has_leaf_or_child_of_name(const std::string & name) const { if(name == "inout" || name == "route-map-name") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::SendCommunity() : send_community_where{YType::enumeration, "send-community-where"} { yang_name = "send-community"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::~SendCommunity() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::has_data() const { if (is_presence_container) return true; return send_community_where.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::has_operation() const { return is_set(yfilter) || ydk::is_set(send_community_where.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "send-community"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_community_where.is_set || is_set(send_community_where.yfilter)) leaf_name_data.push_back(send_community_where.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::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 == "send-community-where") { send_community_where = value; send_community_where.value_namespace = name_space; send_community_where.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-community-where") { send_community_where.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-community-where") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SlowPeer() : detection(nullptr) // presence node , split_update_group(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup>()) { split_update_group->parent = this; yang_name = "slow-peer"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::~SlowPeer() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::has_data() const { if (is_presence_container) return true; return (detection != nullptr && detection->has_data()) || (split_update_group != nullptr && split_update_group->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::has_operation() const { return is_set(yfilter) || (detection != nullptr && detection->has_operation()) || (split_update_group != nullptr && split_update_group->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "slow-peer"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "detection") { if(detection == nullptr) { detection = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::Detection>(); } return detection; } if(child_yang_name == "split-update-group") { if(split_update_group == nullptr) { split_update_group = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup>(); } return split_update_group; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(detection != nullptr) { _children["detection"] = detection; } if(split_update_group != nullptr) { _children["split-update-group"] = split_update_group; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::has_leaf_or_child_of_name(const std::string & name) const { if(name == "detection" || name == "split-update-group") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::Detection::Detection() : threshold{YType::uint16, "threshold"} { yang_name = "detection"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::Detection::~Detection() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::Detection::has_data() const { if (is_presence_container) return true; return threshold.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::Detection::has_operation() const { return is_set(yfilter) || ydk::is_set(threshold.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::Detection::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "detection"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::Detection::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::Detection::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::Detection::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::Detection::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 == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::Detection::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "threshold") { threshold.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::Detection::has_leaf_or_child_of_name(const std::string & name) const { if(name == "threshold") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::SplitUpdateGroup() : dynamic(nullptr) // presence node { yang_name = "split-update-group"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::~SplitUpdateGroup() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::has_data() const { if (is_presence_container) return true; return (dynamic != nullptr && dynamic->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::has_operation() const { return is_set(yfilter) || (dynamic != nullptr && dynamic->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "split-update-group"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "dynamic") { if(dynamic == nullptr) { dynamic = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic>(); } return dynamic; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(dynamic != nullptr) { _children["dynamic"] = dynamic; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "dynamic") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::Dynamic() : permanent{YType::empty, "permanent"} { yang_name = "dynamic"; yang_parent_name = "split-update-group"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::~Dynamic() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_data() const { if (is_presence_container) return true; return permanent.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_operation() const { return is_set(yfilter) || ydk::is_set(permanent.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "dynamic"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (permanent.is_set || is_set(permanent.yfilter)) leaf_name_data.push_back(permanent.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::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 == "permanent") { permanent = value; permanent.value_namespace = name_space; permanent.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "permanent") { permanent.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_leaf_or_child_of_name(const std::string & name) const { if(name == "permanent") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Snmp() : context(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context>()) { context->parent = this; yang_name = "snmp"; yang_parent_name = "l2vpn-vpls"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::~Snmp() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::has_data() const { if (is_presence_container) return true; return (context != nullptr && context->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::has_operation() const { return is_set(yfilter) || (context != nullptr && context->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "snmp"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "context") { if(context == nullptr) { context = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context>(); } return context; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(context != nullptr) { _children["context"] = context; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::has_leaf_or_child_of_name(const std::string & name) const { if(name == "context") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::Context() : context_word(this, {"context_word"}) { yang_name = "context"; yang_parent_name = "snmp"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::~Context() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<context_word.len(); index++) { if(context_word[index]->has_data()) return true; } return false; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::has_operation() const { for (std::size_t index=0; index<context_word.len(); index++) { if(context_word[index]->has_operation()) return true; } return is_set(yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "context"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "context_word") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::ContextWord>(); ent_->parent = this; context_word.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : context_word.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::has_leaf_or_child_of_name(const std::string & name) const { if(name == "context_word") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::ContextWord::ContextWord() : context_word{YType::str, "context_word"} { yang_name = "context_word"; yang_parent_name = "context"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::ContextWord::~ContextWord() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::ContextWord::has_data() const { if (is_presence_container) return true; return context_word.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::ContextWord::has_operation() const { return is_set(yfilter) || ydk::is_set(context_word.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::ContextWord::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "context_word"; ADD_KEY_TOKEN(context_word, "context_word"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::ContextWord::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (context_word.is_set || is_set(context_word.yfilter)) leaf_name_data.push_back(context_word.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::ContextWord::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::ContextWord::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::ContextWord::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 == "context_word") { context_word = value; context_word.value_namespace = name_space; context_word.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::ContextWord::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "context_word") { context_word.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Snmp::Context::ContextWord::has_leaf_or_child_of_name(const std::string & name) const { if(name == "context_word") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter() : af_name{YType::enumeration, "af-name"} , rtfilter(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_>()) { rtfilter->parent = this; yang_name = "rtfilter"; yang_parent_name = "no-vrf"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::~Rtfilter() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::has_data() const { if (is_presence_container) return true; return af_name.is_set || (rtfilter != nullptr && rtfilter->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::has_operation() const { return is_set(yfilter) || ydk::is_set(af_name.yfilter) || (rtfilter != nullptr && rtfilter->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "rtfilter"; ADD_KEY_TOKEN(af_name, "af-name"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (af_name.is_set || is_set(af_name.yfilter)) leaf_name_data.push_back(af_name.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "rtfilter") { if(rtfilter == nullptr) { rtfilter = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_>(); } return rtfilter; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(rtfilter != nullptr) { _children["rtfilter"] = rtfilter; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::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 == "af-name") { af_name = value; af_name.value_namespace = name_space; af_name.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "af-name") { af_name.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::has_leaf_or_child_of_name(const std::string & name) const { if(name == "rtfilter" || name == "af-name") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Rtfilter_() : bgp(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_>()) , maximum_paths(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths>()) , peer_group(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup>()) , neighbor(this, {"id"}) , snmp(nullptr) // presence node { bgp->parent = this; maximum_paths->parent = this; peer_group->parent = this; yang_name = "rtfilter"; yang_parent_name = "rtfilter"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::~Rtfilter_() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<neighbor.len(); index++) { if(neighbor[index]->has_data()) return true; } return (bgp != nullptr && bgp->has_data()) || (maximum_paths != nullptr && maximum_paths->has_data()) || (peer_group != nullptr && peer_group->has_data()) || (snmp != nullptr && snmp->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::has_operation() const { for (std::size_t index=0; index<neighbor.len(); index++) { if(neighbor[index]->has_operation()) return true; } return is_set(yfilter) || (bgp != nullptr && bgp->has_operation()) || (maximum_paths != nullptr && maximum_paths->has_operation()) || (peer_group != nullptr && peer_group->has_operation()) || (snmp != nullptr && snmp->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "rtfilter"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "bgp") { if(bgp == nullptr) { bgp = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_>(); } return bgp; } if(child_yang_name == "maximum-paths") { if(maximum_paths == nullptr) { maximum_paths = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths>(); } return maximum_paths; } if(child_yang_name == "peer-group") { if(peer_group == nullptr) { peer_group = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup>(); } return peer_group; } if(child_yang_name == "neighbor") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor>(); ent_->parent = this; neighbor.append(ent_); return ent_; } if(child_yang_name == "snmp") { if(snmp == nullptr) { snmp = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Snmp>(); } return snmp; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(bgp != nullptr) { _children["bgp"] = bgp; } if(maximum_paths != nullptr) { _children["maximum-paths"] = maximum_paths; } if(peer_group != nullptr) { _children["peer-group"] = peer_group; } count_ = 0; for (auto ent_ : neighbor.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } if(snmp != nullptr) { _children["snmp"] = snmp; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::has_leaf_or_child_of_name(const std::string & name) const { if(name == "bgp" || name == "maximum-paths" || name == "peer-group" || name == "neighbor" || name == "snmp") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Bgp_() : nexthop(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop>()) , slow_peer(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer>()) { nexthop->parent = this; slow_peer->parent = this; yang_name = "bgp"; yang_parent_name = "rtfilter"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::~Bgp_() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::has_data() const { if (is_presence_container) return true; return (nexthop != nullptr && nexthop->has_data()) || (slow_peer != nullptr && slow_peer->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::has_operation() const { return is_set(yfilter) || (nexthop != nullptr && nexthop->has_operation()) || (slow_peer != nullptr && slow_peer->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "bgp"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "nexthop") { if(nexthop == nullptr) { nexthop = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop>(); } return nexthop; } if(child_yang_name == "slow-peer") { if(slow_peer == nullptr) { slow_peer = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer>(); } return slow_peer; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(nexthop != nullptr) { _children["nexthop"] = nexthop; } if(slow_peer != nullptr) { _children["slow-peer"] = slow_peer; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::has_leaf_or_child_of_name(const std::string & name) const { if(name == "nexthop" || name == "slow-peer") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Nexthop() : route_map{YType::str, "route-map"} , trigger(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Trigger>()) { trigger->parent = this; yang_name = "nexthop"; yang_parent_name = "bgp"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::~Nexthop() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::has_data() const { if (is_presence_container) return true; return route_map.is_set || (trigger != nullptr && trigger->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::has_operation() const { return is_set(yfilter) || ydk::is_set(route_map.yfilter) || (trigger != nullptr && trigger->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "nexthop"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (route_map.is_set || is_set(route_map.yfilter)) leaf_name_data.push_back(route_map.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "trigger") { if(trigger == nullptr) { trigger = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Trigger>(); } return trigger; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(trigger != nullptr) { _children["trigger"] = trigger; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::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 == "route-map") { route_map = value; route_map.value_namespace = name_space; route_map.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "route-map") { route_map.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::has_leaf_or_child_of_name(const std::string & name) const { if(name == "trigger" || name == "route-map") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Trigger::Trigger() : delay{YType::uint8, "delay"}, enable{YType::boolean, "enable"} { yang_name = "trigger"; yang_parent_name = "nexthop"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Trigger::~Trigger() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Trigger::has_data() const { if (is_presence_container) return true; return delay.is_set || enable.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Trigger::has_operation() const { return is_set(yfilter) || ydk::is_set(delay.yfilter) || ydk::is_set(enable.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Trigger::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "trigger"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Trigger::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (delay.is_set || is_set(delay.yfilter)) leaf_name_data.push_back(delay.get_name_leafdata()); if (enable.is_set || is_set(enable.yfilter)) leaf_name_data.push_back(enable.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Trigger::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Trigger::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Trigger::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 == "delay") { delay = value; delay.value_namespace = name_space; delay.value_namespace_prefix = name_space_prefix; } if(value_path == "enable") { enable = value; enable.value_namespace = name_space; enable.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Trigger::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "delay") { delay.yfilter = yfilter; } if(value_path == "enable") { enable.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::Nexthop::Trigger::has_leaf_or_child_of_name(const std::string & name) const { if(name == "delay" || name == "enable") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SlowPeer() : detection(nullptr) // presence node , split_update_group(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup>()) { split_update_group->parent = this; yang_name = "slow-peer"; yang_parent_name = "bgp"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::~SlowPeer() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::has_data() const { if (is_presence_container) return true; return (detection != nullptr && detection->has_data()) || (split_update_group != nullptr && split_update_group->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::has_operation() const { return is_set(yfilter) || (detection != nullptr && detection->has_operation()) || (split_update_group != nullptr && split_update_group->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "slow-peer"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "detection") { if(detection == nullptr) { detection = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::Detection>(); } return detection; } if(child_yang_name == "split-update-group") { if(split_update_group == nullptr) { split_update_group = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup>(); } return split_update_group; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(detection != nullptr) { _children["detection"] = detection; } if(split_update_group != nullptr) { _children["split-update-group"] = split_update_group; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::has_leaf_or_child_of_name(const std::string & name) const { if(name == "detection" || name == "split-update-group") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::Detection::Detection() : disable{YType::empty, "disable"}, threshold{YType::uint16, "threshold"} { yang_name = "detection"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::Detection::~Detection() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::Detection::has_data() const { if (is_presence_container) return true; return disable.is_set || threshold.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::Detection::has_operation() const { return is_set(yfilter) || ydk::is_set(disable.yfilter) || ydk::is_set(threshold.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::Detection::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "detection"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::Detection::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (disable.is_set || is_set(disable.yfilter)) leaf_name_data.push_back(disable.get_name_leafdata()); if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::Detection::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::Detection::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::Detection::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 == "disable") { disable = value; disable.value_namespace = name_space; disable.value_namespace_prefix = name_space_prefix; } if(value_path == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::Detection::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "disable") { disable.yfilter = yfilter; } if(value_path == "threshold") { threshold.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::Detection::has_leaf_or_child_of_name(const std::string & name) const { if(name == "disable" || name == "threshold") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::SplitUpdateGroup() : dynamic(nullptr) // presence node { yang_name = "split-update-group"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::~SplitUpdateGroup() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::has_data() const { if (is_presence_container) return true; return (dynamic != nullptr && dynamic->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::has_operation() const { return is_set(yfilter) || (dynamic != nullptr && dynamic->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "split-update-group"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "dynamic") { if(dynamic == nullptr) { dynamic = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic>(); } return dynamic; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(dynamic != nullptr) { _children["dynamic"] = dynamic; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "dynamic") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::Dynamic() : permanent{YType::empty, "permanent"} { yang_name = "dynamic"; yang_parent_name = "split-update-group"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::~Dynamic() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::has_data() const { if (is_presence_container) return true; return permanent.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::has_operation() const { return is_set(yfilter) || ydk::is_set(permanent.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "dynamic"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (permanent.is_set || is_set(permanent.yfilter)) leaf_name_data.push_back(permanent.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::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 == "permanent") { permanent = value; permanent.value_namespace = name_space; permanent.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "permanent") { permanent.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Bgp_::SlowPeer::SplitUpdateGroup::Dynamic::has_leaf_or_child_of_name(const std::string & name) const { if(name == "permanent") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::MaximumPaths() : ebgp{YType::uint16, "ebgp"}, eibgp{YType::uint16, "eibgp"} , ibgp(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::Ibgp>()) , external_rtfilter(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::ExternalRtfilter>()) { ibgp->parent = this; external_rtfilter->parent = this; yang_name = "maximum-paths"; yang_parent_name = "rtfilter"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::~MaximumPaths() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::has_data() const { if (is_presence_container) return true; return ebgp.is_set || eibgp.is_set || (ibgp != nullptr && ibgp->has_data()) || (external_rtfilter != nullptr && external_rtfilter->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::has_operation() const { return is_set(yfilter) || ydk::is_set(ebgp.yfilter) || ydk::is_set(eibgp.yfilter) || (ibgp != nullptr && ibgp->has_operation()) || (external_rtfilter != nullptr && external_rtfilter->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "maximum-paths"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (ebgp.is_set || is_set(ebgp.yfilter)) leaf_name_data.push_back(ebgp.get_name_leafdata()); if (eibgp.is_set || is_set(eibgp.yfilter)) leaf_name_data.push_back(eibgp.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "ibgp") { if(ibgp == nullptr) { ibgp = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::Ibgp>(); } return ibgp; } if(child_yang_name == "external-rtfilter") { if(external_rtfilter == nullptr) { external_rtfilter = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::ExternalRtfilter>(); } return external_rtfilter; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(ibgp != nullptr) { _children["ibgp"] = ibgp; } if(external_rtfilter != nullptr) { _children["external-rtfilter"] = external_rtfilter; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::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 == "ebgp") { ebgp = value; ebgp.value_namespace = name_space; ebgp.value_namespace_prefix = name_space_prefix; } if(value_path == "eibgp") { eibgp = value; eibgp.value_namespace = name_space; eibgp.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "ebgp") { ebgp.yfilter = yfilter; } if(value_path == "eibgp") { eibgp.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::has_leaf_or_child_of_name(const std::string & name) const { if(name == "ibgp" || name == "external-rtfilter" || name == "ebgp" || name == "eibgp") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::Ibgp::Ibgp() : unequal_cost{YType::uint16, "unequal-cost"}, max{YType::uint16, "max"} { yang_name = "ibgp"; yang_parent_name = "maximum-paths"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::Ibgp::~Ibgp() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::Ibgp::has_data() const { if (is_presence_container) return true; return unequal_cost.is_set || max.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::Ibgp::has_operation() const { return is_set(yfilter) || ydk::is_set(unequal_cost.yfilter) || ydk::is_set(max.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::Ibgp::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ibgp"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::Ibgp::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (unequal_cost.is_set || is_set(unequal_cost.yfilter)) leaf_name_data.push_back(unequal_cost.get_name_leafdata()); if (max.is_set || is_set(max.yfilter)) leaf_name_data.push_back(max.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::Ibgp::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::Ibgp::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::Ibgp::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 == "unequal-cost") { unequal_cost = value; unequal_cost.value_namespace = name_space; unequal_cost.value_namespace_prefix = name_space_prefix; } if(value_path == "max") { max = value; max.value_namespace = name_space; max.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::Ibgp::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "unequal-cost") { unequal_cost.yfilter = yfilter; } if(value_path == "max") { max.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::Ibgp::has_leaf_or_child_of_name(const std::string & name) const { if(name == "unequal-cost" || name == "max") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::ExternalRtfilter::ExternalRtfilter() : max{YType::uint16, "max"} { yang_name = "external-rtfilter"; yang_parent_name = "maximum-paths"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::ExternalRtfilter::~ExternalRtfilter() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::ExternalRtfilter::has_data() const { if (is_presence_container) return true; return max.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::ExternalRtfilter::has_operation() const { return is_set(yfilter) || ydk::is_set(max.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::ExternalRtfilter::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "external-rtfilter"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::ExternalRtfilter::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max.is_set || is_set(max.yfilter)) leaf_name_data.push_back(max.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::ExternalRtfilter::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::ExternalRtfilter::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::ExternalRtfilter::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 == "max") { max = value; max.value_namespace = name_space; max.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::ExternalRtfilter::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max") { max.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::MaximumPaths::ExternalRtfilter::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::PeerGroup() : neighbor(this, {"id"}) { yang_name = "peer-group"; yang_parent_name = "rtfilter"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::~PeerGroup() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<neighbor.len(); index++) { if(neighbor[index]->has_data()) return true; } return false; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::has_operation() const { for (std::size_t index=0; index<neighbor.len(); index++) { if(neighbor[index]->has_operation()) return true; } return is_set(yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "peer-group"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "neighbor") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor>(); ent_->parent = this; neighbor.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : neighbor.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "neighbor") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Neighbor() : id{YType::str, "id"}, activate{YType::empty, "activate"}, advertisement_interval{YType::uint16, "advertisement-interval"}, allow_policy{YType::empty, "allow-policy"}, next_hop_unchanged{YType::empty, "next-hop-unchanged"}, route_reflector_client{YType::empty, "route-reflector-client"}, soft_reconfiguration{YType::enumeration, "soft-reconfiguration"}, soo{YType::str, "soo"}, weight{YType::uint16, "weight"} , allowas_in(nullptr) // presence node , capability(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability>()) , default_originate(nullptr) // presence node , inherit(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Inherit>()) , maximum_prefix(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::MaximumPrefix>()) , next_hop_self(nullptr) // presence node , remove_private_as(nullptr) // presence node , route_map(this, {"inout"}) , send_community(nullptr) // presence node , slow_peer(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer>()) { capability->parent = this; inherit->parent = this; maximum_prefix->parent = this; slow_peer->parent = this; yang_name = "neighbor"; yang_parent_name = "peer-group"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::~Neighbor() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<route_map.len(); index++) { if(route_map[index]->has_data()) return true; } return id.is_set || activate.is_set || advertisement_interval.is_set || allow_policy.is_set || next_hop_unchanged.is_set || route_reflector_client.is_set || soft_reconfiguration.is_set || soo.is_set || weight.is_set || (allowas_in != nullptr && allowas_in->has_data()) || (capability != nullptr && capability->has_data()) || (default_originate != nullptr && default_originate->has_data()) || (inherit != nullptr && inherit->has_data()) || (maximum_prefix != nullptr && maximum_prefix->has_data()) || (next_hop_self != nullptr && next_hop_self->has_data()) || (remove_private_as != nullptr && remove_private_as->has_data()) || (send_community != nullptr && send_community->has_data()) || (slow_peer != nullptr && slow_peer->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::has_operation() const { for (std::size_t index=0; index<route_map.len(); index++) { if(route_map[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(id.yfilter) || ydk::is_set(activate.yfilter) || ydk::is_set(advertisement_interval.yfilter) || ydk::is_set(allow_policy.yfilter) || ydk::is_set(next_hop_unchanged.yfilter) || ydk::is_set(route_reflector_client.yfilter) || ydk::is_set(soft_reconfiguration.yfilter) || ydk::is_set(soo.yfilter) || ydk::is_set(weight.yfilter) || (allowas_in != nullptr && allowas_in->has_operation()) || (capability != nullptr && capability->has_operation()) || (default_originate != nullptr && default_originate->has_operation()) || (inherit != nullptr && inherit->has_operation()) || (maximum_prefix != nullptr && maximum_prefix->has_operation()) || (next_hop_self != nullptr && next_hop_self->has_operation()) || (remove_private_as != nullptr && remove_private_as->has_operation()) || (send_community != nullptr && send_community->has_operation()) || (slow_peer != nullptr && slow_peer->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "neighbor"; ADD_KEY_TOKEN(id, "id"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (id.is_set || is_set(id.yfilter)) leaf_name_data.push_back(id.get_name_leafdata()); if (activate.is_set || is_set(activate.yfilter)) leaf_name_data.push_back(activate.get_name_leafdata()); if (advertisement_interval.is_set || is_set(advertisement_interval.yfilter)) leaf_name_data.push_back(advertisement_interval.get_name_leafdata()); if (allow_policy.is_set || is_set(allow_policy.yfilter)) leaf_name_data.push_back(allow_policy.get_name_leafdata()); if (next_hop_unchanged.is_set || is_set(next_hop_unchanged.yfilter)) leaf_name_data.push_back(next_hop_unchanged.get_name_leafdata()); if (route_reflector_client.is_set || is_set(route_reflector_client.yfilter)) leaf_name_data.push_back(route_reflector_client.get_name_leafdata()); if (soft_reconfiguration.is_set || is_set(soft_reconfiguration.yfilter)) leaf_name_data.push_back(soft_reconfiguration.get_name_leafdata()); if (soo.is_set || is_set(soo.yfilter)) leaf_name_data.push_back(soo.get_name_leafdata()); if (weight.is_set || is_set(weight.yfilter)) leaf_name_data.push_back(weight.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "allowas-in") { if(allowas_in == nullptr) { allowas_in = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::AllowasIn>(); } return allowas_in; } if(child_yang_name == "capability") { if(capability == nullptr) { capability = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability>(); } return capability; } if(child_yang_name == "default-originate") { if(default_originate == nullptr) { default_originate = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::DefaultOriginate>(); } return default_originate; } if(child_yang_name == "inherit") { if(inherit == nullptr) { inherit = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Inherit>(); } return inherit; } if(child_yang_name == "maximum-prefix") { if(maximum_prefix == nullptr) { maximum_prefix = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::MaximumPrefix>(); } return maximum_prefix; } if(child_yang_name == "next-hop-self") { if(next_hop_self == nullptr) { next_hop_self = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::NextHopSelf>(); } return next_hop_self; } if(child_yang_name == "remove-private-as") { if(remove_private_as == nullptr) { remove_private_as = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs>(); } return remove_private_as; } if(child_yang_name == "route-map") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap>(); ent_->parent = this; route_map.append(ent_); return ent_; } if(child_yang_name == "send-community") { if(send_community == nullptr) { send_community = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity>(); } return send_community; } if(child_yang_name == "slow-peer") { if(slow_peer == nullptr) { slow_peer = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer>(); } return slow_peer; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(allowas_in != nullptr) { _children["allowas-in"] = allowas_in; } if(capability != nullptr) { _children["capability"] = capability; } if(default_originate != nullptr) { _children["default-originate"] = default_originate; } if(inherit != nullptr) { _children["inherit"] = inherit; } if(maximum_prefix != nullptr) { _children["maximum-prefix"] = maximum_prefix; } if(next_hop_self != nullptr) { _children["next-hop-self"] = next_hop_self; } if(remove_private_as != nullptr) { _children["remove-private-as"] = remove_private_as; } count_ = 0; for (auto ent_ : route_map.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } if(send_community != nullptr) { _children["send-community"] = send_community; } if(slow_peer != nullptr) { _children["slow-peer"] = slow_peer; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::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 == "id") { id = value; id.value_namespace = name_space; id.value_namespace_prefix = name_space_prefix; } if(value_path == "activate") { activate = value; activate.value_namespace = name_space; activate.value_namespace_prefix = name_space_prefix; } if(value_path == "advertisement-interval") { advertisement_interval = value; advertisement_interval.value_namespace = name_space; advertisement_interval.value_namespace_prefix = name_space_prefix; } if(value_path == "allow-policy") { allow_policy = value; allow_policy.value_namespace = name_space; allow_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "next-hop-unchanged") { next_hop_unchanged = value; next_hop_unchanged.value_namespace = name_space; next_hop_unchanged.value_namespace_prefix = name_space_prefix; } if(value_path == "route-reflector-client") { route_reflector_client = value; route_reflector_client.value_namespace = name_space; route_reflector_client.value_namespace_prefix = name_space_prefix; } if(value_path == "soft-reconfiguration") { soft_reconfiguration = value; soft_reconfiguration.value_namespace = name_space; soft_reconfiguration.value_namespace_prefix = name_space_prefix; } if(value_path == "soo") { soo = value; soo.value_namespace = name_space; soo.value_namespace_prefix = name_space_prefix; } if(value_path == "weight") { weight = value; weight.value_namespace = name_space; weight.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "id") { id.yfilter = yfilter; } if(value_path == "activate") { activate.yfilter = yfilter; } if(value_path == "advertisement-interval") { advertisement_interval.yfilter = yfilter; } if(value_path == "allow-policy") { allow_policy.yfilter = yfilter; } if(value_path == "next-hop-unchanged") { next_hop_unchanged.yfilter = yfilter; } if(value_path == "route-reflector-client") { route_reflector_client.yfilter = yfilter; } if(value_path == "soft-reconfiguration") { soft_reconfiguration.yfilter = yfilter; } if(value_path == "soo") { soo.yfilter = yfilter; } if(value_path == "weight") { weight.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allowas-in" || name == "capability" || name == "default-originate" || name == "inherit" || name == "maximum-prefix" || name == "next-hop-self" || name == "remove-private-as" || name == "route-map" || name == "send-community" || name == "slow-peer" || name == "id" || name == "activate" || name == "advertisement-interval" || name == "allow-policy" || name == "next-hop-unchanged" || name == "route-reflector-client" || name == "soft-reconfiguration" || name == "soo" || name == "weight") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::AllowasIn::AllowasIn() : as_number{YType::uint8, "as-number"} { yang_name = "allowas-in"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::AllowasIn::~AllowasIn() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::AllowasIn::has_data() const { if (is_presence_container) return true; return as_number.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::AllowasIn::has_operation() const { return is_set(yfilter) || ydk::is_set(as_number.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::AllowasIn::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "allowas-in"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::AllowasIn::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (as_number.is_set || is_set(as_number.yfilter)) leaf_name_data.push_back(as_number.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::AllowasIn::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::AllowasIn::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::AllowasIn::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 == "as-number") { as_number = value; as_number.value_namespace = name_space; as_number.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::AllowasIn::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "as-number") { as_number.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::AllowasIn::has_leaf_or_child_of_name(const std::string & name) const { if(name == "as-number") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Capability() : orf(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf>()) { orf->parent = this; yang_name = "capability"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::~Capability() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::has_data() const { if (is_presence_container) return true; return (orf != nullptr && orf->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::has_operation() const { return is_set(yfilter) || (orf != nullptr && orf->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "capability"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "orf") { if(orf == nullptr) { orf = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf>(); } return orf; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(orf != nullptr) { _children["orf"] = orf; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::has_leaf_or_child_of_name(const std::string & name) const { if(name == "orf") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::Orf() : prefix_list{YType::enumeration, "prefix-list"} { yang_name = "orf"; yang_parent_name = "capability"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::~Orf() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::has_data() const { if (is_presence_container) return true; for (auto const & leaf : prefix_list.getYLeafs()) { if(leaf.is_set) return true; } return false; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::has_operation() const { for (auto const & leaf : prefix_list.getYLeafs()) { if(is_set(leaf.yfilter)) return true; } return is_set(yfilter) || ydk::is_set(prefix_list.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "orf"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; auto prefix_list_name_datas = prefix_list.get_name_leafdata(); leaf_name_data.insert(leaf_name_data.end(), prefix_list_name_datas.begin(), prefix_list_name_datas.end()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::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 == "prefix-list") { prefix_list.append(value); } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "prefix-list") { prefix_list.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prefix-list") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::DefaultOriginate::DefaultOriginate() : route_map{YType::str, "route-map"} { yang_name = "default-originate"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::DefaultOriginate::~DefaultOriginate() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::DefaultOriginate::has_data() const { if (is_presence_container) return true; return route_map.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::DefaultOriginate::has_operation() const { return is_set(yfilter) || ydk::is_set(route_map.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::DefaultOriginate::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "default-originate"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::DefaultOriginate::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (route_map.is_set || is_set(route_map.yfilter)) leaf_name_data.push_back(route_map.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::DefaultOriginate::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::DefaultOriginate::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::DefaultOriginate::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 == "route-map") { route_map = value; route_map.value_namespace = name_space; route_map.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::DefaultOriginate::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "route-map") { route_map.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::DefaultOriginate::has_leaf_or_child_of_name(const std::string & name) const { if(name == "route-map") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Inherit::Inherit() : peer_policy{YType::str, "peer-policy"}, peer_session{YType::str, "peer-session"} { yang_name = "inherit"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Inherit::~Inherit() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Inherit::has_data() const { if (is_presence_container) return true; return peer_policy.is_set || peer_session.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Inherit::has_operation() const { return is_set(yfilter) || ydk::is_set(peer_policy.yfilter) || ydk::is_set(peer_session.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Inherit::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "inherit"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Inherit::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (peer_policy.is_set || is_set(peer_policy.yfilter)) leaf_name_data.push_back(peer_policy.get_name_leafdata()); if (peer_session.is_set || is_set(peer_session.yfilter)) leaf_name_data.push_back(peer_session.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Inherit::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Inherit::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Inherit::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 == "peer-policy") { peer_policy = value; peer_policy.value_namespace = name_space; peer_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "peer-session") { peer_session = value; peer_session.value_namespace = name_space; peer_session.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Inherit::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "peer-policy") { peer_policy.yfilter = yfilter; } if(value_path == "peer-session") { peer_session.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Inherit::has_leaf_or_child_of_name(const std::string & name) const { if(name == "peer-policy" || name == "peer-session") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::MaximumPrefix::MaximumPrefix() : max_prefix_no{YType::uint32, "max-prefix-no"}, threshold{YType::uint8, "threshold"}, restart{YType::uint16, "restart"}, warning_only{YType::empty, "warning-only"} { yang_name = "maximum-prefix"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::MaximumPrefix::~MaximumPrefix() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::MaximumPrefix::has_data() const { if (is_presence_container) return true; return max_prefix_no.is_set || threshold.is_set || restart.is_set || warning_only.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::MaximumPrefix::has_operation() const { return is_set(yfilter) || ydk::is_set(max_prefix_no.yfilter) || ydk::is_set(threshold.yfilter) || ydk::is_set(restart.yfilter) || ydk::is_set(warning_only.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::MaximumPrefix::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "maximum-prefix"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::MaximumPrefix::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (max_prefix_no.is_set || is_set(max_prefix_no.yfilter)) leaf_name_data.push_back(max_prefix_no.get_name_leafdata()); if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); if (restart.is_set || is_set(restart.yfilter)) leaf_name_data.push_back(restart.get_name_leafdata()); if (warning_only.is_set || is_set(warning_only.yfilter)) leaf_name_data.push_back(warning_only.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::MaximumPrefix::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::MaximumPrefix::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::MaximumPrefix::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 == "max-prefix-no") { max_prefix_no = value; max_prefix_no.value_namespace = name_space; max_prefix_no.value_namespace_prefix = name_space_prefix; } if(value_path == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } if(value_path == "restart") { restart = value; restart.value_namespace = name_space; restart.value_namespace_prefix = name_space_prefix; } if(value_path == "warning-only") { warning_only = value; warning_only.value_namespace = name_space; warning_only.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::MaximumPrefix::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "max-prefix-no") { max_prefix_no.yfilter = yfilter; } if(value_path == "threshold") { threshold.yfilter = yfilter; } if(value_path == "restart") { restart.yfilter = yfilter; } if(value_path == "warning-only") { warning_only.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::MaximumPrefix::has_leaf_or_child_of_name(const std::string & name) const { if(name == "max-prefix-no" || name == "threshold" || name == "restart" || name == "warning-only") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::NextHopSelf::NextHopSelf() : all{YType::empty, "all"} { yang_name = "next-hop-self"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::NextHopSelf::~NextHopSelf() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::NextHopSelf::has_data() const { if (is_presence_container) return true; return all.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::NextHopSelf::has_operation() const { return is_set(yfilter) || ydk::is_set(all.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::NextHopSelf::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "next-hop-self"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::NextHopSelf::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (all.is_set || is_set(all.yfilter)) leaf_name_data.push_back(all.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::NextHopSelf::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::NextHopSelf::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::NextHopSelf::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 == "all") { all = value; all.value_namespace = name_space; all.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::NextHopSelf::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "all") { all.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::NextHopSelf::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::RemovePrivateAs() : all(nullptr) // presence node { yang_name = "remove-private-as"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::~RemovePrivateAs() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::has_data() const { if (is_presence_container) return true; return (all != nullptr && all->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::has_operation() const { return is_set(yfilter) || (all != nullptr && all->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "remove-private-as"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "all") { if(all == nullptr) { all = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::All>(); } return all; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(all != nullptr) { _children["all"] = all; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::has_leaf_or_child_of_name(const std::string & name) const { if(name == "all") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::All::All() : replace_as{YType::empty, "replace-as"} { yang_name = "all"; yang_parent_name = "remove-private-as"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::All::~All() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::All::has_data() const { if (is_presence_container) return true; return replace_as.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::All::has_operation() const { return is_set(yfilter) || ydk::is_set(replace_as.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::All::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "all"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::All::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (replace_as.is_set || is_set(replace_as.yfilter)) leaf_name_data.push_back(replace_as.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::All::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::All::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::All::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 == "replace-as") { replace_as = value; replace_as.value_namespace = name_space; replace_as.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::All::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "replace-as") { replace_as.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RemovePrivateAs::All::has_leaf_or_child_of_name(const std::string & name) const { if(name == "replace-as") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap::RouteMap() : inout{YType::enumeration, "inout"}, route_map_name{YType::str, "route-map-name"} { yang_name = "route-map"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap::~RouteMap() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap::has_data() const { if (is_presence_container) return true; return inout.is_set || route_map_name.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap::has_operation() const { return is_set(yfilter) || ydk::is_set(inout.yfilter) || ydk::is_set(route_map_name.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "route-map"; ADD_KEY_TOKEN(inout, "inout"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (inout.is_set || is_set(inout.yfilter)) leaf_name_data.push_back(inout.get_name_leafdata()); if (route_map_name.is_set || is_set(route_map_name.yfilter)) leaf_name_data.push_back(route_map_name.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap::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 == "inout") { inout = value; inout.value_namespace = name_space; inout.value_namespace_prefix = name_space_prefix; } if(value_path == "route-map-name") { route_map_name = value; route_map_name.value_namespace = name_space; route_map_name.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "inout") { inout.yfilter = yfilter; } if(value_path == "route-map-name") { route_map_name.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap::has_leaf_or_child_of_name(const std::string & name) const { if(name == "inout" || name == "route-map-name") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::SendCommunity() : send_community_where{YType::enumeration, "send-community-where"} { yang_name = "send-community"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::~SendCommunity() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::has_data() const { if (is_presence_container) return true; return send_community_where.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::has_operation() const { return is_set(yfilter) || ydk::is_set(send_community_where.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "send-community"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (send_community_where.is_set || is_set(send_community_where.yfilter)) leaf_name_data.push_back(send_community_where.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::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 == "send-community-where") { send_community_where = value; send_community_where.value_namespace = name_space; send_community_where.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "send-community-where") { send_community_where.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "send-community-where") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SlowPeer() : detection(nullptr) // presence node , split_update_group(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup>()) { split_update_group->parent = this; yang_name = "slow-peer"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::~SlowPeer() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::has_data() const { if (is_presence_container) return true; return (detection != nullptr && detection->has_data()) || (split_update_group != nullptr && split_update_group->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::has_operation() const { return is_set(yfilter) || (detection != nullptr && detection->has_operation()) || (split_update_group != nullptr && split_update_group->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "slow-peer"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "detection") { if(detection == nullptr) { detection = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::Detection>(); } return detection; } if(child_yang_name == "split-update-group") { if(split_update_group == nullptr) { split_update_group = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup>(); } return split_update_group; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(detection != nullptr) { _children["detection"] = detection; } if(split_update_group != nullptr) { _children["split-update-group"] = split_update_group; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::has_leaf_or_child_of_name(const std::string & name) const { if(name == "detection" || name == "split-update-group") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::Detection::Detection() : threshold{YType::uint16, "threshold"} { yang_name = "detection"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::Detection::~Detection() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::Detection::has_data() const { if (is_presence_container) return true; return threshold.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::Detection::has_operation() const { return is_set(yfilter) || ydk::is_set(threshold.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::Detection::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "detection"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::Detection::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (threshold.is_set || is_set(threshold.yfilter)) leaf_name_data.push_back(threshold.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::Detection::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::Detection::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::Detection::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 == "threshold") { threshold = value; threshold.value_namespace = name_space; threshold.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::Detection::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "threshold") { threshold.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::Detection::has_leaf_or_child_of_name(const std::string & name) const { if(name == "threshold") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::SplitUpdateGroup() : dynamic(nullptr) // presence node { yang_name = "split-update-group"; yang_parent_name = "slow-peer"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::~SplitUpdateGroup() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::has_data() const { if (is_presence_container) return true; return (dynamic != nullptr && dynamic->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::has_operation() const { return is_set(yfilter) || (dynamic != nullptr && dynamic->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "split-update-group"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "dynamic") { if(dynamic == nullptr) { dynamic = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic>(); } return dynamic; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(dynamic != nullptr) { _children["dynamic"] = dynamic; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::set_filter(const std::string & value_path, YFilter yfilter) { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "dynamic") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::Dynamic() : permanent{YType::empty, "permanent"} { yang_name = "dynamic"; yang_parent_name = "split-update-group"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::~Dynamic() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_data() const { if (is_presence_container) return true; return permanent.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_operation() const { return is_set(yfilter) || ydk::is_set(permanent.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "dynamic"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (permanent.is_set || is_set(permanent.yfilter)) leaf_name_data.push_back(permanent.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::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 == "permanent") { permanent = value; permanent.value_namespace = name_space; permanent.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "permanent") { permanent.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SlowPeer::SplitUpdateGroup::Dynamic::has_leaf_or_child_of_name(const std::string & name) const { if(name == "permanent") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::Neighbor() : id{YType::str, "id"}, activate{YType::empty, "activate"}, advertisement_interval{YType::uint16, "advertisement-interval"}, allow_policy{YType::empty, "allow-policy"}, next_hop_unchanged{YType::empty, "next-hop-unchanged"}, route_reflector_client{YType::empty, "route-reflector-client"}, soft_reconfiguration{YType::enumeration, "soft-reconfiguration"}, soo{YType::str, "soo"}, weight{YType::uint16, "weight"} , allowas_in(nullptr) // presence node , capability(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::Capability>()) , default_originate(nullptr) // presence node , inherit(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::Inherit>()) , maximum_prefix(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::MaximumPrefix>()) , next_hop_self(nullptr) // presence node , remove_private_as(nullptr) // presence node , route_map(this, {"inout"}) , send_community(nullptr) // presence node , slow_peer(std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::SlowPeer>()) { capability->parent = this; inherit->parent = this; maximum_prefix->parent = this; slow_peer->parent = this; yang_name = "neighbor"; yang_parent_name = "rtfilter"; is_top_level_class = false; has_list_ancestor = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::~Neighbor() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<route_map.len(); index++) { if(route_map[index]->has_data()) return true; } return id.is_set || activate.is_set || advertisement_interval.is_set || allow_policy.is_set || next_hop_unchanged.is_set || route_reflector_client.is_set || soft_reconfiguration.is_set || soo.is_set || weight.is_set || (allowas_in != nullptr && allowas_in->has_data()) || (capability != nullptr && capability->has_data()) || (default_originate != nullptr && default_originate->has_data()) || (inherit != nullptr && inherit->has_data()) || (maximum_prefix != nullptr && maximum_prefix->has_data()) || (next_hop_self != nullptr && next_hop_self->has_data()) || (remove_private_as != nullptr && remove_private_as->has_data()) || (send_community != nullptr && send_community->has_data()) || (slow_peer != nullptr && slow_peer->has_data()); } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::has_operation() const { for (std::size_t index=0; index<route_map.len(); index++) { if(route_map[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(id.yfilter) || ydk::is_set(activate.yfilter) || ydk::is_set(advertisement_interval.yfilter) || ydk::is_set(allow_policy.yfilter) || ydk::is_set(next_hop_unchanged.yfilter) || ydk::is_set(route_reflector_client.yfilter) || ydk::is_set(soft_reconfiguration.yfilter) || ydk::is_set(soo.yfilter) || ydk::is_set(weight.yfilter) || (allowas_in != nullptr && allowas_in->has_operation()) || (capability != nullptr && capability->has_operation()) || (default_originate != nullptr && default_originate->has_operation()) || (inherit != nullptr && inherit->has_operation()) || (maximum_prefix != nullptr && maximum_prefix->has_operation()) || (next_hop_self != nullptr && next_hop_self->has_operation()) || (remove_private_as != nullptr && remove_private_as->has_operation()) || (send_community != nullptr && send_community->has_operation()) || (slow_peer != nullptr && slow_peer->has_operation()); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "neighbor"; ADD_KEY_TOKEN(id, "id"); return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (id.is_set || is_set(id.yfilter)) leaf_name_data.push_back(id.get_name_leafdata()); if (activate.is_set || is_set(activate.yfilter)) leaf_name_data.push_back(activate.get_name_leafdata()); if (advertisement_interval.is_set || is_set(advertisement_interval.yfilter)) leaf_name_data.push_back(advertisement_interval.get_name_leafdata()); if (allow_policy.is_set || is_set(allow_policy.yfilter)) leaf_name_data.push_back(allow_policy.get_name_leafdata()); if (next_hop_unchanged.is_set || is_set(next_hop_unchanged.yfilter)) leaf_name_data.push_back(next_hop_unchanged.get_name_leafdata()); if (route_reflector_client.is_set || is_set(route_reflector_client.yfilter)) leaf_name_data.push_back(route_reflector_client.get_name_leafdata()); if (soft_reconfiguration.is_set || is_set(soft_reconfiguration.yfilter)) leaf_name_data.push_back(soft_reconfiguration.get_name_leafdata()); if (soo.is_set || is_set(soo.yfilter)) leaf_name_data.push_back(soo.get_name_leafdata()); if (weight.is_set || is_set(weight.yfilter)) leaf_name_data.push_back(weight.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "allowas-in") { if(allowas_in == nullptr) { allowas_in = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::AllowasIn>(); } return allowas_in; } if(child_yang_name == "capability") { if(capability == nullptr) { capability = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::Capability>(); } return capability; } if(child_yang_name == "default-originate") { if(default_originate == nullptr) { default_originate = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::DefaultOriginate>(); } return default_originate; } if(child_yang_name == "inherit") { if(inherit == nullptr) { inherit = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::Inherit>(); } return inherit; } if(child_yang_name == "maximum-prefix") { if(maximum_prefix == nullptr) { maximum_prefix = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::MaximumPrefix>(); } return maximum_prefix; } if(child_yang_name == "next-hop-self") { if(next_hop_self == nullptr) { next_hop_self = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::NextHopSelf>(); } return next_hop_self; } if(child_yang_name == "remove-private-as") { if(remove_private_as == nullptr) { remove_private_as = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::RemovePrivateAs>(); } return remove_private_as; } if(child_yang_name == "route-map") { auto ent_ = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::RouteMap>(); ent_->parent = this; route_map.append(ent_); return ent_; } if(child_yang_name == "send-community") { if(send_community == nullptr) { send_community = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::SendCommunity>(); } return send_community; } if(child_yang_name == "slow-peer") { if(slow_peer == nullptr) { slow_peer = std::make_shared<Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::SlowPeer>(); } return slow_peer; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(allowas_in != nullptr) { _children["allowas-in"] = allowas_in; } if(capability != nullptr) { _children["capability"] = capability; } if(default_originate != nullptr) { _children["default-originate"] = default_originate; } if(inherit != nullptr) { _children["inherit"] = inherit; } if(maximum_prefix != nullptr) { _children["maximum-prefix"] = maximum_prefix; } if(next_hop_self != nullptr) { _children["next-hop-self"] = next_hop_self; } if(remove_private_as != nullptr) { _children["remove-private-as"] = remove_private_as; } count_ = 0; for (auto ent_ : route_map.entities()) { if(_children.find(ent_->get_segment_path()) == _children.end()) _children[ent_->get_segment_path()] = ent_; else _children[ent_->get_segment_path()+count_++] = ent_; } if(send_community != nullptr) { _children["send-community"] = send_community; } if(slow_peer != nullptr) { _children["slow-peer"] = slow_peer; } return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::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 == "id") { id = value; id.value_namespace = name_space; id.value_namespace_prefix = name_space_prefix; } if(value_path == "activate") { activate = value; activate.value_namespace = name_space; activate.value_namespace_prefix = name_space_prefix; } if(value_path == "advertisement-interval") { advertisement_interval = value; advertisement_interval.value_namespace = name_space; advertisement_interval.value_namespace_prefix = name_space_prefix; } if(value_path == "allow-policy") { allow_policy = value; allow_policy.value_namespace = name_space; allow_policy.value_namespace_prefix = name_space_prefix; } if(value_path == "next-hop-unchanged") { next_hop_unchanged = value; next_hop_unchanged.value_namespace = name_space; next_hop_unchanged.value_namespace_prefix = name_space_prefix; } if(value_path == "route-reflector-client") { route_reflector_client = value; route_reflector_client.value_namespace = name_space; route_reflector_client.value_namespace_prefix = name_space_prefix; } if(value_path == "soft-reconfiguration") { soft_reconfiguration = value; soft_reconfiguration.value_namespace = name_space; soft_reconfiguration.value_namespace_prefix = name_space_prefix; } if(value_path == "soo") { soo = value; soo.value_namespace = name_space; soo.value_namespace_prefix = name_space_prefix; } if(value_path == "weight") { weight = value; weight.value_namespace = name_space; weight.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "id") { id.yfilter = yfilter; } if(value_path == "activate") { activate.yfilter = yfilter; } if(value_path == "advertisement-interval") { advertisement_interval.yfilter = yfilter; } if(value_path == "allow-policy") { allow_policy.yfilter = yfilter; } if(value_path == "next-hop-unchanged") { next_hop_unchanged.yfilter = yfilter; } if(value_path == "route-reflector-client") { route_reflector_client.yfilter = yfilter; } if(value_path == "soft-reconfiguration") { soft_reconfiguration.yfilter = yfilter; } if(value_path == "soo") { soo.yfilter = yfilter; } if(value_path == "weight") { weight.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::has_leaf_or_child_of_name(const std::string & name) const { if(name == "allowas-in" || name == "capability" || name == "default-originate" || name == "inherit" || name == "maximum-prefix" || name == "next-hop-self" || name == "remove-private-as" || name == "route-map" || name == "send-community" || name == "slow-peer" || name == "id" || name == "activate" || name == "advertisement-interval" || name == "allow-policy" || name == "next-hop-unchanged" || name == "route-reflector-client" || name == "soft-reconfiguration" || name == "soo" || name == "weight") return true; return false; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::AllowasIn::AllowasIn() : as_number{YType::uint8, "as-number"} { yang_name = "allowas-in"; yang_parent_name = "neighbor"; is_top_level_class = false; has_list_ancestor = true; is_presence_container = true; } Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::AllowasIn::~AllowasIn() { } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::AllowasIn::has_data() const { if (is_presence_container) return true; return as_number.is_set; } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::AllowasIn::has_operation() const { return is_set(yfilter) || ydk::is_set(as_number.yfilter); } std::string Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::AllowasIn::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "allowas-in"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::AllowasIn::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (as_number.is_set || is_set(as_number.yfilter)) leaf_name_data.push_back(as_number.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::AllowasIn::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>> Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::AllowasIn::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::AllowasIn::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 == "as-number") { as_number = value; as_number.value_namespace = name_space; as_number.value_namespace_prefix = name_space_prefix; } } void Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::AllowasIn::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "as-number") { as_number.yfilter = yfilter; } } bool Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::AllowasIn::has_leaf_or_child_of_name(const std::string & name) const { if(name == "as-number") return true; return false; } const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::DistributeList::Inout::in {0, "in"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::DistributeList::Inout::out {1, "out"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::FilterList::Inout::in {0, "in"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::FilterList::Inout::out {1, "out"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::PrefixList::Inout::in {0, "in"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::PrefixList::Inout::out {1, "out"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RouteMap::Inout::in {0, "in"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::RouteMap::Inout::out {1, "out"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::SendCommunityWhere::both {0, "both"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::SendCommunityWhere::extended {1, "extended"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::PeerGroup::Neighbor::SendCommunity::SendCommunityWhere::standard {2, "standard"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SoftReconfiguration::inbound {0, "inbound"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList::Inout::in {0, "in"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::DistributeList::Inout::out {1, "out"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList::Inout::in {0, "in"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::FilterList::Inout::out {1, "out"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList::Inout::in {0, "in"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::PrefixList::Inout::out {1, "out"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap::Inout::in {0, "in"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::RouteMap::Inout::out {1, "out"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::SendCommunityWhere::both {0, "both"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::SendCommunityWhere::extended {1, "extended"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Neighbor::SendCommunity::SendCommunityWhere::standard {2, "standard"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::PrefixList::both {0, "both"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::PrefixList::receive {1, "receive"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::Capability::Orf::PrefixList::send {2, "send"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RouteMap::Inout::in {0, "in"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::RouteMap::Inout::out {1, "out"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::SendCommunityWhere::both {0, "both"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::SendCommunityWhere::extended {1, "extended"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnEvpn::SendCommunity::SendCommunityWhere::standard {2, "standard"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Bgp_::Default::RouteTarget::filter {0, "filter"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SoftReconfiguration::inbound {0, "inbound"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::PrefixList::both {0, "both"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::PrefixList::receive {1, "receive"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::Capability::Orf::PrefixList::send {2, "send"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap::Inout::in {0, "in"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::RouteMap::Inout::out {1, "out"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::SendCommunityWhere::both {0, "both"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::SendCommunityWhere::extended {1, "extended"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::PeerGroup::Neighbor::SendCommunity::SendCommunityWhere::standard {2, "standard"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SoftReconfiguration::inbound {0, "inbound"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::PrefixList::both {0, "both"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::PrefixList::receive {1, "receive"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::Capability::Orf::PrefixList::send {2, "send"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap::Inout::in {0, "in"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::RouteMap::Inout::out {1, "out"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::SendCommunityWhere::both {0, "both"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::SendCommunityWhere::extended {1, "extended"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::L2vpn::L2vpnVpls::Neighbor::SendCommunity::SendCommunityWhere::standard {2, "standard"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::AfName::unicast {0, "unicast"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SoftReconfiguration::inbound {0, "inbound"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::PrefixList::both {0, "both"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::PrefixList::receive {1, "receive"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::Capability::Orf::PrefixList::send {2, "send"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap::Inout::in {0, "in"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::RouteMap::Inout::out {1, "out"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::SendCommunityWhere::both {0, "both"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::SendCommunityWhere::extended {1, "extended"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::PeerGroup::Neighbor::SendCommunity::SendCommunityWhere::standard {2, "standard"}; const Enum::YLeaf Native::Router::Bgp::Scope::Vrf::AddressFamily::NoVrf::Rtfilter::Rtfilter_::Neighbor::SoftReconfiguration::inbound {0, "inbound"}; } }
37.376021
651
0.700491
CiscoDevNet
4e2e3d639888fdbe1725897136f1919eb1da7d9f
2,806
cpp
C++
WS01/w1_p2.cpp
Rainbow1nTheDark/OOP345
1d56e8875ab2c1c8b31b5c520add799ebf8d8ec5
[ "Apache-2.0" ]
null
null
null
WS01/w1_p2.cpp
Rainbow1nTheDark/OOP345
1d56e8875ab2c1c8b31b5c520add799ebf8d8ec5
[ "Apache-2.0" ]
null
null
null
WS01/w1_p2.cpp
Rainbow1nTheDark/OOP345
1d56e8875ab2c1c8b31b5c520add799ebf8d8ec5
[ "Apache-2.0" ]
null
null
null
// Workshop 1 - Linkage, Storage Duration, Namespaces, and OS Interface // Cornel - 2020/01/08 #include <iostream> #include <fstream> #include "event.h" #include "event.h" /* input file format: a coma separated set of fields; some fields have a single parameter T175,SComputer Starting,P, codes T - time (parameter: a number representing the time--measured in seconds--when the following codes apply) S - start event (parameter: a string representing the description for the event that starts) E - end the event P - print to screen A - archive */ // TODO: write the prototype for the main function // to accept command line arguments int main(int argc, char* argv[]) { std::cout << "Command Line:\n"; // TODO: print the command line here, in the format // 1: first argument // 2: second argument // 3: third argument for (auto i = 0; i < argc; i++) { std::cout << i + 1 << ": " << argv[i] << std::endl; } std::cout << std::endl; // the archive can store maximum 10 events sdds::Event archive[10]; // the index of the next available position in the archive size_t idxArchive = 0; sdds::Event currentEvent; const size_t secInDay = 60u * 60u * 24u;// day has 86400 seconds for (auto day = 1; day < argc; ++day) { // each parameter for an application contains the events from one day // process each one std::cout << "--------------------\n"; std::cout << " Day " << day << '\n'; std::cout << "--------------------\n"; std::ifstream in(argv[day]); char opcode = '\0'; size_t time = secInDay + 1; in >> opcode >> time; // starting at midnight, until the end of the day for (::g_sysClock = 0u; ::g_sysClock < secInDay; ::g_sysClock++) { // what should happen this second while (time == ::g_sysClock) { // skip the delimiter in.ignore(); // read the next opcode in >> opcode; // end of the file if (in.fail()) break; // handle the operation code switch (opcode) { case 'T': // a new time code, this is exit the while loop in >> time; break; case 'S': // start a new event, the old event is automatically finished char buffer[1024]; in.get(buffer, 1024, ','); currentEvent.setDescription(buffer); break; case 'E': // end the current event currentEvent.setDescription(nullptr); break; case 'P': // print to scren the information about the current event currentEvent.display(); break; case 'A': // add a copy of the current event to the archive sdds::Event copy(currentEvent); archive[idxArchive++] = copy; break; } } } } // print the archive std::cout << "--------------------\n"; std::cout << " Archive\n"; std::cout << "--------------------\n"; for (auto i = 0u; i < idxArchive; ++i) archive[i].display(); std::cout << "--------------------\n"; }
26.471698
106
0.619031
Rainbow1nTheDark
4e31b99e19d6466c959326b4537a188bc2e19c4d
1,678
cc
C++
sdk/android/src/jni/wrapped_native_i420_buffer.cc
gpolitis/webrtc
e26456a4ed4158aa3c65314ccab502fd633eef77
[ "DOC", "BSD-3-Clause" ]
null
null
null
sdk/android/src/jni/wrapped_native_i420_buffer.cc
gpolitis/webrtc
e26456a4ed4158aa3c65314ccab502fd633eef77
[ "DOC", "BSD-3-Clause" ]
null
null
null
sdk/android/src/jni/wrapped_native_i420_buffer.cc
gpolitis/webrtc
e26456a4ed4158aa3c65314ccab502fd633eef77
[ "DOC", "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "sdk/android/src/jni/wrapped_native_i420_buffer.h" #include "sdk/android/generated_video_jni/jni/WrappedNativeI420Buffer_jni.h" #include "sdk/android/src/jni/jni_helpers.h" namespace webrtc { namespace jni { // TODO(magjed): Write a test for this function. jobject WrapI420Buffer( JNIEnv* jni, const rtc::scoped_refptr<I420BufferInterface>& i420_buffer) { jobject y_buffer = jni->NewDirectByteBuffer(const_cast<uint8_t*>(i420_buffer->DataY()), i420_buffer->StrideY() * i420_buffer->height()); jobject u_buffer = jni->NewDirectByteBuffer( const_cast<uint8_t*>(i420_buffer->DataU()), i420_buffer->StrideU() * i420_buffer->ChromaHeight()); jobject v_buffer = jni->NewDirectByteBuffer( const_cast<uint8_t*>(i420_buffer->DataV()), i420_buffer->StrideV() * i420_buffer->ChromaHeight()); jobject j_wrapped_native_i420_buffer = Java_WrappedNativeI420Buffer_Constructor( jni, i420_buffer->width(), i420_buffer->height(), y_buffer, i420_buffer->StrideY(), u_buffer, i420_buffer->StrideU(), v_buffer, i420_buffer->StrideV(), jlongFromPointer(i420_buffer.get())); return j_wrapped_native_i420_buffer; } } // namespace jni } // namespace webrtc
38.136364
79
0.718117
gpolitis
4e32ab1e4d494dbca1f82cc38c383ae0abad06fe
761
hpp
C++
include/react/sandbox/requirements_of.hpp
ldionne/react
57b51d179661a9c21bc1f987d124722ac36399ac
[ "BSL-1.0" ]
6
2015-06-05T17:48:12.000Z
2020-10-04T03:45:18.000Z
include/react/sandbox/requirements_of.hpp
ldionne/react
57b51d179661a9c21bc1f987d124722ac36399ac
[ "BSL-1.0" ]
1
2021-06-23T05:51:46.000Z
2021-06-23T05:51:46.000Z
include/react/sandbox/requirements_of.hpp
ldionne/react
57b51d179661a9c21bc1f987d124722ac36399ac
[ "BSL-1.0" ]
2
2016-05-06T06:55:40.000Z
2020-03-25T19:19:14.000Z
/*! * @file * Defines `react::requirements_of`. */ #ifndef REACT_REQUIREMENTS_OF_HPP #define REACT_REQUIREMENTS_OF_HPP #include <react/sandbox/detail/fetch_nested.hpp> #include <boost/mpl/set.hpp> namespace react { #ifdef REACT_DOXYGEN_INVOKED /*! * Returns the requirements of a computation. * * If the computation does not have a nested `requirements` type, * the computation has no requirements. * * @return A Boost.MPL AssociativeSequence of * @ref Requirement "Requirements" */ template <typename Computation> struct requirements_of { }; #else REACT_FETCH_NESTED(requirements_of, requirements, boost::mpl::set0<>) #endif } // end namespace react #endif // !REACT_REQUIREMENTS_OF_HPP
23.060606
73
0.701708
ldionne
4e34a6899ffd8a6bc8f021318f42eb10f1be54e0
11,206
cpp
C++
source/code/scxsystemlib/common/scxsmbios.cpp
snchennapragada/pal
9ee3e116dc2fadb44efa0938de7f0b737784fe16
[ "MIT" ]
37
2016-04-14T20:06:15.000Z
2019-05-06T17:30:17.000Z
source/code/scxsystemlib/common/scxsmbios.cpp
snchennapragada/pal
9ee3e116dc2fadb44efa0938de7f0b737784fe16
[ "MIT" ]
37
2016-03-11T20:47:11.000Z
2019-04-01T22:53:04.000Z
source/code/scxsystemlib/common/scxsmbios.cpp
snchennapragada/pal
9ee3e116dc2fadb44efa0938de7f0b737784fe16
[ "MIT" ]
20
2016-05-26T23:53:01.000Z
2019-05-06T08:54:08.000Z
/*-------------------------------------------------------------------------------- Copyright (c) Microsoft Corporation. All rights reserved. See license.txt for license information. */ /** \file \brief This file contains the abstraction of the smbios on Linux and Solaris x86. \date 2011-03-21 16:51:51 */ #include <scxcorelib/scxcmn.h> #include <scxcorelib/scxfile.h> #include <scxsystemlib/scxsmbios.h> namespace SCXSystemLib { /*----------------------------------------------------------------------------*/ /** Default constructor. */ SMBIOSPALDependencies::SMBIOSPALDependencies() { #if (defined(sun) && !defined(sparc)) m_deviceName = L"/dev/xsvc"; #elif defined(linux) m_deviceName = L"/dev/mem"; #endif m_log = SCXLogHandleFactory::GetLogHandle(std::wstring(L"scx.core.common.pal.system.common.scxsmbios")); } /*----------------------------------------------------------------------------*/ /** Read Smbios Table Entry Point on non-EFI system,from 0xF0000 to 0xFFFFF in device file. */ bool SMBIOSPALDependencies::ReadSpecialMemory(MiddleData &buf) const { if(1 > buf.size()) return false; SCXFilePath devicePath(m_deviceName); size_t length = cEndAddress - cStartAddress + 1; size_t offsetStart = cStartAddress; SCX_LOGTRACE(m_log, StrAppend(L"SMBIOSPALDependencies ReadSpecialMemory() - device name: ", m_deviceName)); SCX_LOGTRACE(m_log, StrAppend(L"SMBIOSPALDependencies ReadSpecialMemory() - length: ", length)); SCX_LOGTRACE(m_log, StrAppend(L"SMBIOSPALDependencies ReadSpecialMemory() - offsetStart: ", offsetStart)); int readReturnCode = SCXFile::ReadAvailableBytesAsUnsigned(devicePath,&(buf[0]),length,offsetStart); if(readReturnCode == 0) { SCX_LOGTRACE(m_log, L"ReadSpecialMemory() - status of reading is: success"); } else { SCX_LOGTRACE(m_log, L"ReadSpecialMemory() - status of reading is: failure"); SCX_LOGTRACE(m_log, StrAppend(L"ReadSpecialMemory() - reason for read failure: ", readReturnCode)); return false; } return true; } /*----------------------------------------------------------------------------*/ /** Read Smbios Table Entry Point on EFI system. We will implement this function on EFI system later. */ bool SMBIOSPALDependencies::ReadSpecialmemoryEFI(MiddleData &buf) const { //Just to avoid warning here bool bRet = true; buf.size(); return bRet; } /*----------------------------------------------------------------------------*/ /** Get SMBIOS Table content. */ bool SMBIOSPALDependencies::GetSmbiosTable(const struct SmbiosEntry& entryPoint, MiddleData &buf) const { if(1 > buf.size()) return false; // //Read Smbios Table from device system file according to info inside SmbiosEntry. // SCXFilePath devicePath(m_deviceName); int readReturnCode = SCXFile::ReadAvailableBytesAsUnsigned(devicePath,&(buf[0]), entryPoint.tableLength,entryPoint.tableAddress); if(readReturnCode == 0) { SCX_LOGTRACE(m_log, L"GetSmbiosTable() -the status of reading is : success"); } else { SCX_LOGTRACE(m_log, L"GetSmbiosTable() -the status of reading is : failure"); SCX_LOGTRACE(m_log, StrAppend(L"GetSmbiosTable() - reason for read failure: ", readReturnCode)); return false; } return true; } /*----------------------------------------------------------------------------*/ /** Default constructor. */ SCXSmbios::SCXSmbios(SCXCoreLib::SCXHandle<SMBIOSPALDependencies> deps): m_deps(deps) { m_log = SCXLogHandleFactory::GetLogHandle(std::wstring(L"scx.core.common.pal.system.common.scxsmbios")); } /*----------------------------------------------------------------------------*/ /** Parse SMBIOS Structure Table Entry Point. Parameter[out]: smbiosEntry- Part fields value of SMBIOS Structure Table Entry Point. Returns: whether it's successful to parse it. */ bool SCXSmbios::ParseSmbiosEntryStructure(struct SmbiosEntry &smbiosEntry)const { bool fRet = false; try { // //Read Smbios Table Entry Point on non-EFI system,from 0xF0000 to 0xFFFFF in device file. // size_t ilength = cEndAddress - cStartAddress + 1; MiddleData entryPoint(ilength); fRet = m_deps->ReadSpecialMemory(entryPoint); if (!fRet) { std::wstring sMsg(L"ParseSmbiosEntryStructure - Failed to read special memory."); SCX_LOGINFO(m_log, sMsg); smbiosEntry.smbiosPresent = false; } // //Searching for the anchor-string "_SM_" on paragraph (16-byte) boundaries mentioned in doc DSP0134_2.7.0.pdf // unsigned char* pbuf = &(entryPoint[0]); for(size_t i = 0; fRet && ((i + cParagraphLength) <= ilength); i += cParagraphLength) { if (memcmp(pbuf+i,"_SM_", cAnchorString) == 0) { unsigned char *pcurBuf = pbuf+i; // Before proceeding, verify that the SMBIOS is present. // (Reference: (dmidecode.c ver 2.1: http://download.savannah.gnu.org/releases/dmidecode/) if ( CheckSum(pcurBuf, pcurBuf[0x05]) && memcmp(pcurBuf+0x10, "_DMI_", cDMIAnchorString) == 0 && CheckSum(pcurBuf+0x10, 15)) { SCX_LOGTRACE(m_log, std::wstring(L"SMBIOS is present.")); SCX_LOGTRACE(m_log, std::wstring(L"ParseSmbiosEntryStructure -anchor: _SM_")); // //Length of the Entry Point Structure. // size_t tmpLength = pcurBuf[cLengthEntry]; if(!CheckSum(pcurBuf,tmpLength)) { throw SCXCoreLib::SCXInternalErrorException(L"Failed to CheckSum in ParseSmbiosEntryStructure().", SCXSRCLOCATION); } // //Read the address,length and SMBIOS structure number of SMBIOS Structure Table. // unsigned int address = MAKELONG(MAKEWORD(pcurBuf+cAddressTable,pcurBuf+cAddressTable+1),MAKEWORD(pcurBuf+cAddressTable+2,pcurBuf+cAddressTable+3)); unsigned short length = MAKEWORD(pcurBuf+cLengthTable,pcurBuf+cLengthTable+1); unsigned short number = MAKEWORD(pcurBuf+cNumberStructures,pcurBuf+cNumberStructures+1); unsigned short majorVersion = pcurBuf[cMajorVersion]; unsigned short minorVersion = pcurBuf[cMiniorVersion]; smbiosEntry.majorVersion = majorVersion; smbiosEntry.minorVersion = minorVersion; smbiosEntry.smbiosPresent = true; smbiosEntry.tableAddress = address; SCX_LOGTRACE(m_log, StrAppend(L"ParseSmbiosEntryStructure - address: ", address)); smbiosEntry.tableLength = length; SCX_LOGTRACE(m_log, StrAppend(L"ParseSmbiosEntryStructure - length: ", length)); smbiosEntry.structureNumber = number; SCX_LOGTRACE(m_log, StrAppend(L"ParseSmbiosEntryStructure - number: ", number)); } break; } else if (memcmp(pbuf+i, "_DMI_", cDMIAnchorString) == 0) { SCX_LOGTRACE(m_log, std::wstring(L"Legacy DMI is present.")); } } } catch(const SCXException& e) { throw SCXCoreLib::SCXInternalErrorException(L"Failed to parse Smbios Entry Structure." + e.What(), SCXSRCLOCATION); } return fRet; } /*----------------------------------------------------------------------------*/ /** Check the checksum of the Entry Point Structure. Checksum of the Entry Point Structure,added to all other bytes in the Entry Point Structure, results in the value 00h(using 8-bit addition calculations). Checksum is the value of the 4th byte, so the above algorithm is equal to add all the bytes in the Entry Point Structure. Parameter[in]: pEntry- the address of Entry Point Structure. Parameter[in]: length- the length of Entry Point Structure. Returns: true,the checksum is 0;otherwise,false. */ bool SCXSmbios::CheckSum(const unsigned char* pEntry,const size_t& length)const { unsigned char sum = 0; for(size_t i=0;i<length;++i) { sum = static_cast<unsigned char>(sum + pEntry[i]); } return (0 == sum); } /*----------------------------------------------------------------------------*/ /** Read specified index string. Parameter[in]: buf- SMBIOS Structure Table. Parameter[in]: length- offset to the start address of SMBIOS Structure Table. Parameter[in]: index- index of string. Returns: The string which the program read. */ std::wstring SCXSmbios::ReadSpecifiedString(const MiddleData& buf,const size_t& length,const size_t& index)const { std::wstring strRet = L""; if(1 > buf.size()) return strRet; unsigned char* ptablebuf = const_cast<unsigned char*>(&(buf[0])); size_t curLength = length; size_t numstr = 1; while(numstr < index) { char *pcurstr = reinterpret_cast<char*>(ptablebuf+curLength); curLength = curLength + strlen(pcurstr); // // At last add 1 for the terminal char '\0' // curLength += 1; numstr++; } std::string curString = reinterpret_cast<char*>(ptablebuf + curLength); strRet = StrFromUTF8(curString); SCX_LOGTRACE(m_log, StrAppend(L"ReadSpecifiedString() - ParsedStr is : ", strRet)); return strRet; } /*----------------------------------------------------------------------------*/ /** Get SMBIOS Table content. Parameter[in]: entryPoint- EntryPoint Structure. Parameter[out]: buf- Smbios Table. Returns: whether it's successful to get smbios table. */ bool SCXSmbios::GetSmbiosTable(const struct SmbiosEntry& entryPoint,MiddleData &buf) const { return m_deps->GetSmbiosTable(entryPoint,buf); } } /*----------------------------E-N-D---O-F---F-I-L-E---------------------------*/
38.245734
172
0.536766
snchennapragada
4e35573c19bec7f5bd10741f0051c8e1b420f94e
2,307
hxx
C++
main/cui/source/options/optaccessibility.hxx
Grosskopf/openoffice
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
[ "Apache-2.0" ]
679
2015-01-06T06:34:58.000Z
2022-03-30T01:06:03.000Z
main/cui/source/options/optaccessibility.hxx
Grosskopf/openoffice
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
[ "Apache-2.0" ]
102
2017-11-07T08:51:31.000Z
2022-03-17T12:13:49.000Z
main/cui/source/options/optaccessibility.hxx
Grosskopf/openoffice
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
[ "Apache-2.0" ]
331
2015-01-06T11:40:55.000Z
2022-03-14T04:07:51.000Z
/************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * *************************************************************/ #ifndef _SVX_OPTACCESSIBILITY_HXX #define _SVX_OPTACCESSIBILITY_HXX #include <sfx2/tabdlg.hxx> #include <vcl/fixed.hxx> #include <vcl/field.hxx> struct SvxAccessibilityOptionsTabPage_Impl; class SvxAccessibilityOptionsTabPage : public SfxTabPage { FixedLine m_aMiscellaneousLabel; // FL_MISCELLANEOUS CheckBox m_aAccessibilityTool; // CB_ACCESSIBILITY_TOOL CheckBox m_aTextSelectionInReadonly; // CB_TEXTSELECTION CheckBox m_aAnimatedGraphics; // CB_ANIMATED_GRAPHICS CheckBox m_aAnimatedTexts; // CB_ANIMATED_TEXTS CheckBox m_aTipHelpCB; // CB_TIPHELP NumericField m_aTipHelpNF; // NF_TIPHELP FixedText m_aTipHelpFT; // FT_TIPHELP FixedLine m_aHCOptionsLabel; // FL_HC_OPTIONS CheckBox m_aAutoDetectHC; // CB_AUTO_DETECT_HC CheckBox m_aAutomaticFontColor; // CB_AUTOMATIC_FONT_COLOR CheckBox m_aPagePreviews; // CB_PAGEPREVIEWS DECL_LINK(TipHelpHdl, CheckBox*); void EnableTipHelp(sal_Bool bCheck); SvxAccessibilityOptionsTabPage_Impl* m_pImpl; SvxAccessibilityOptionsTabPage( Window* pParent, const SfxItemSet& rSet ); public: virtual ~SvxAccessibilityOptionsTabPage(); static SfxTabPage* Create( Window* pParent, const SfxItemSet& rAttrSet ); virtual sal_Bool FillItemSet( SfxItemSet& rSet ); virtual void Reset( const SfxItemSet& rSet ); }; #endif
37.209677
75
0.718249
Grosskopf
4e37ef49b7148400b6417ea85f769e43e8c40861
3,950
cpp
C++
Source/Motor2D/j1TextUI.cpp
Needlesslord/PaintWars_by_BrainDeadStudios
578985b1a41ab9f0b8c5dd087ba3bc3d3ffd2edf
[ "MIT" ]
2
2020-03-06T11:32:40.000Z
2020-03-20T12:17:30.000Z
Source/Motor2D/j1TextUI.cpp
Needlesslord/Heathen_Games
578985b1a41ab9f0b8c5dd087ba3bc3d3ffd2edf
[ "MIT" ]
2
2020-03-03T09:56:57.000Z
2020-05-02T15:50:45.000Z
Source/Motor2D/j1TextUI.cpp
Needlesslord/Heathen_Games
578985b1a41ab9f0b8c5dd087ba3bc3d3ffd2edf
[ "MIT" ]
1
2020-03-17T18:50:53.000Z
2020-03-17T18:50:53.000Z
#include "j1UIElements.h" #include "j1UI_Manager.h" #include "j1App.h" #include "j1FontsUI.h" #include "j1Render.h" #include "j1Textures.h" #include "j1Input.h" #include "j1Window.h" #include "j1TextUI.h" j1TextUI::j1TextUI() { this->type = TypeOfUI::GUI_LABEL; } j1TextUI::~j1TextUI() { } bool j1TextUI::Start() { font_name_black = App->fonts->Load("textures/fonts/font_black.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef ghijklmnopqrstuvwxyz0123456789=/-", 2); font_name_white = App->fonts->Load("textures/fonts/font_white.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef ghijklmnopqrstuvwxyz0123456789=/-", 2); font_name_black_small = App->fonts->Load("textures/fonts/font_black_small.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef ghijklmnopqrstuvwxyz0123456789=/-", 2); font_name_white_small = App->fonts->Load("textures/fonts/font_white_small.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef ghijklmnopqrstuvwxyz0123456789=/-", 2); font_name_black_extra_small = App->fonts->Load("textures/fonts/font_black_extra_small.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef ghijklmnopqrstuvwxyz0123456789=/-", 2); font_name_white_extra_small = App->fonts->Load("textures/fonts/font_white_extra_small.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef ghijklmnopqrstuvwxyz0123456789=/-", 2); font_name_red = App->fonts->Load("textures/fonts/font_red_extra_small.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef ghijklmnopqrstuvwxyz0123456789=/-", 2); font_name_red_small = App->fonts->Load("textures/fonts/font_red_small.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef ghijklmnopqrstuvwxyz0123456789=/-", 2); font_name_red_extra_small = App->fonts->Load("textures/fonts/font_red.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef ghijklmnopqrstuvwxyz0123456789=/-", 2); return true; } bool j1TextUI::PreUpdate() { return true; } bool j1TextUI::Update(float dt) { if (enabled) { switch (fontType) { case FONT::FONT_MEDIUM: App->fonts->BlitText(map_position.x + inside_position.x, map_position.y + inside_position.y, font_name_black, text, layer); break; case FONT::FONT_MEDIUM_WHITE: App->fonts->BlitText(map_position.x + inside_position.x, map_position.y + inside_position.y, font_name_white, text, layer); break; case FONT::FONT_SMALL: App->fonts->BlitText(map_position.x + inside_position.x, map_position.y + inside_position.y, font_name_black_small, text, layer); break; case FONT::FONT_SMALL_WHITE: App->fonts->BlitText(map_position.x + inside_position.x, map_position.y + inside_position.y, font_name_white_small, text, layer); break; case FONT::FONT_EXTRA_SMALL: App->fonts->BlitText(map_position.x + inside_position.x, map_position.y + inside_position.y, font_name_black_extra_small, text, layer); break; case FONT::FONT_EXTRA_SMALL_WHITE: App->fonts->BlitText(map_position.x + inside_position.x, map_position.y + inside_position.y, font_name_white_extra_small, text, layer); break; case FONT::FONT_EXTRA_SMALL_RED: App->fonts->BlitText(map_position.x + inside_position.x, map_position.y + inside_position.y, font_name_red, text, layer); break; case FONT::FONT_SMALL_RED: App->fonts->BlitText(map_position.x + inside_position.x, map_position.y + inside_position.y, font_name_red_small, text, layer); break; case FONT::FONT_MEDIUM_RED: App->fonts->BlitText(map_position.x + inside_position.x, map_position.y + inside_position.y, font_name_red_extra_small, text, layer); break; } } return true; } bool j1TextUI::PostUpdate() { return true; } bool j1TextUI::CleanUp() { App->fonts->UnLoad(font_name_black); App->fonts->UnLoad(font_name_black_small); App->fonts->UnLoad(font_name_black_extra_small); App->fonts->UnLoad(font_name_white); App->fonts->UnLoad(font_name_white_small); App->fonts->UnLoad(font_name_white_extra_small); App->fonts->UnLoad(font_name_red); App->fonts->UnLoad(font_name_red_small); App->fonts->UnLoad(font_name_red_extra_small); text = " "; return true; }
33.193277
167
0.766076
Needlesslord
4e38ef6b45cc75bf31b45bc92b4d0cfa418be83c
573
cpp
C++
src/prod/src/ServiceModel/modelV2/IndependentVolumeRef.cpp
gridgentoo/ServiceFabricAzure
c3e7a07617e852322d73e6cc9819d266146866a4
[ "MIT" ]
2,542
2018-03-14T21:56:12.000Z
2019-05-06T01:18:20.000Z
src/prod/src/ServiceModel/modelV2/IndependentVolumeRef.cpp
gridgentoo/ServiceFabricAzure
c3e7a07617e852322d73e6cc9819d266146866a4
[ "MIT" ]
994
2019-05-07T02:39:30.000Z
2022-03-31T13:23:04.000Z
src/prod/src/ServiceModel/modelV2/IndependentVolumeRef.cpp
gridgentoo/ServiceFabricAzure
c3e7a07617e852322d73e6cc9819d266146866a4
[ "MIT" ]
300
2018-03-14T21:57:17.000Z
2019-05-06T20:07:00.000Z
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------ #include "stdafx.h" using namespace Common; using namespace ServiceModel::ModelV2; INITIALIZE_SIZE_ESTIMATION(IndependentVolumeRef) bool IndependentVolumeRef::operator==(IndependentVolumeRef const & other) const { return ContainerVolumeRef::operator==(other); } bool IndependentVolumeRef::operator!=(IndependentVolumeRef const & other) const { return !(*this == other); }
27.285714
79
0.603839
gridgentoo
4e3a2e1ca58ec7177791aa66f967f238e10d6a71
44,301
cpp
C++
src/QMCWaveFunctions/RotatedSPOs.cpp
djstaros/qmcpack
280f67e638bae280448b47fa618f05b848c530d2
[ "NCSA" ]
null
null
null
src/QMCWaveFunctions/RotatedSPOs.cpp
djstaros/qmcpack
280f67e638bae280448b47fa618f05b848c530d2
[ "NCSA" ]
null
null
null
src/QMCWaveFunctions/RotatedSPOs.cpp
djstaros/qmcpack
280f67e638bae280448b47fa618f05b848c530d2
[ "NCSA" ]
null
null
null
////////////////////////////////////////////////////////////////////////////////////// //// This file is distributed under the University of Illinois/NCSA Open Source License. //// See LICENSE file in top directory for details. //// //// Copyright (c) QMCPACK developers. //// //// File developed by: Sergio D. Pineda Flores, sergio_pinedaflores@berkeley.edu, University of California, Berkeley //// Eric Neuscamman, eneuscamman@berkeley.edu, University of California, Berkeley //// Ye Luo, yeluo@anl.gov, Argonne National Laboratory //// //// File created by: Sergio D. Pineda Flores, sergio_pinedaflores@berkeley.edu, University of California, Berkeley //////////////////////////////////////////////////////////////////////////////////////// #include "QMCWaveFunctions/RotatedSPOs.h" #include <Numerics/MatrixOperators.h> #include "Numerics/DeterminantOperators.h" #include "CPU/BLAS.hpp" namespace qmcplusplus { RotatedSPOs::RotatedSPOs(SPOSet* spos) : SPOSet(spos->isOMPoffload(), spos->hasIonDerivs(), true), Phi(spos), params_supplied(false), IsCloned(false), nel_major_(0) { className = "RotatedSPOs"; OrbitalSetSize = Phi->getOrbitalSetSize(); } RotatedSPOs::~RotatedSPOs() {} void RotatedSPOs::buildOptVariables(const size_t nel) { #if !defined(QMC_COMPLEX) /* Only rebuild optimized variables if more after-rotation orbitals are needed * Consider ROHF, there is only one set of SPO for both spin up and down Nup > Ndown. * nel_major_ will be set Nup. */ if (nel > nel_major_) { nel_major_ = nel; const size_t nmo = Phi->getOrbitalSetSize(); // create active rotation parameter indices std::vector<std::pair<int, int>> created_m_act_rot_inds; // only core->active rotations created for (int i = 0; i < nel; i++) for (int j = nel; j < nmo; j++) created_m_act_rot_inds.push_back(std::pair<int, int>(i, j)); buildOptVariables(created_m_act_rot_inds); } #endif } void RotatedSPOs::buildOptVariables(const std::vector<std::pair<int, int>>& rotations) { #if !defined(QMC_COMPLEX) const size_t nmo = Phi->getOrbitalSetSize(); const size_t nb = Phi->getBasisSetSize(); // create active rotations m_act_rot_inds = rotations; // This will add the orbital rotation parameters to myVars // and will also read in initial parameter values supplied in input file int p, q; int nparams_active = m_act_rot_inds.size(); app_log() << "nparams_active: " << nparams_active << " params2.size(): " << params.size() << std::endl; if (params_supplied) if (nparams_active != params.size()) APP_ABORT("The number of supplied orbital rotation parameters does not match number prdouced by the slater " "expansion. \n"); myVars.clear(); for (int i = 0; i < nparams_active; i++) { p = m_act_rot_inds[i].first; q = m_act_rot_inds[i].second; std::stringstream sstr; sstr << Phi->objectName << "_orb_rot_" << (p < 10 ? "0" : "") << (p < 100 ? "0" : "") << (p < 1000 ? "0" : "") << p << "_" << (q < 10 ? "0" : "") << (q < 100 ? "0" : "") << (q < 1000 ? "0" : "") << q; // If the user input parameteres, use those. Otherwise, initialize the parameters to zero if (params_supplied) { myVars.insert(sstr.str(), params[i]); } else { myVars.insert(sstr.str(), 0.0); } } //Printing the parameters if (true) { app_log() << std::string(16, ' ') << "Parameter name" << std::string(15, ' ') << "Value\n"; myVars.print(app_log()); } std::vector<RealType> param(m_act_rot_inds.size()); for (int i = 0; i < m_act_rot_inds.size(); i++) param[i] = myVars[i]; apply_rotation(param, false); if (!Optimizable) { //THIS ALLOWS FOR ORBITAL PARAMETERS TO BE READ IN EVEN WHEN THOSE PARAMETERS ARE NOT BEING OPTIMIZED //this assumes there are only CI coefficients ahead of the M_orb_coefficients myVars.Index.erase(myVars.Index.begin(), myVars.Index.end()); myVars.NameAndValue.erase(myVars.NameAndValue.begin(), myVars.NameAndValue.end()); myVars.ParameterType.erase(myVars.ParameterType.begin(), myVars.ParameterType.end()); myVars.Recompute.erase(myVars.Recompute.begin(), myVars.Recompute.end()); } #endif } void RotatedSPOs::apply_rotation(const std::vector<RealType>& param, bool use_stored_copy) { assert(param.size() == m_act_rot_inds.size()); const size_t nmo = Phi->getOrbitalSetSize(); ValueMatrix_t rot_mat(nmo, nmo); rot_mat = ValueType(0); // read out the parameters that define the rotation into an antisymmetric matrix for (int i = 0; i < m_act_rot_inds.size(); i++) { const int p = m_act_rot_inds[i].first; const int q = m_act_rot_inds[i].second; const RealType x = param[i]; rot_mat[q][p] = x; rot_mat[p][q] = -x; } exponentiate_antisym_matrix(rot_mat); Phi->applyRotation(rot_mat, use_stored_copy); } // compute exponential of a real, antisymmetric matrix by diagonalizing and exponentiating eigenvalues void RotatedSPOs::exponentiate_antisym_matrix(ValueMatrix_t& mat) { const int n = mat.rows(); std::vector<std::complex<RealType>> mat_h(n * n, 0); std::vector<RealType> eval(n, 0); std::vector<std::complex<RealType>> work(2 * n, 0); std::vector<RealType> rwork(3 * n, 0); std::vector<std::complex<RealType>> mat_d(n * n, 0); std::vector<std::complex<RealType>> mat_t(n * n, 0); // exponentiating e^X = e^iY (Y hermitian) // i(-iX) = X, so -iX is hermitian // diagonalize -iX = UDU^T, exponentiate e^iD, and return U e^iD U^T // construct hermitian analogue of mat by multiplying by -i for (int i = 0; i < n; ++i) { for (int j = i; j < n; ++j) { mat_h[i + n * j] = std::complex<RealType>(0, -1.0 * mat[j][i]); mat_h[j + n * i] = std::complex<RealType>(0, 1.0 * mat[j][i]); } } // diagonalize the matrix char JOBZ('V'); char UPLO('U'); int N(n); int LDA(n); int LWORK(2 * n); int info = 0; LAPACK::heev(JOBZ, UPLO, N, &mat_h.at(0), LDA, &eval.at(0), &work.at(0), LWORK, &rwork.at(0), info); if (info != 0) { std::ostringstream msg; msg << "heev failed with info = " << info << " in MultiSlaterDeterminantFast::exponentiate_antisym_matrix"; app_log() << msg.str() << std::endl; APP_ABORT(msg.str()); } // iterate through diagonal matrix, exponentiate terms for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { mat_d[i + j * n] = (i == j) ? std::exp(std::complex<RealType>(0.0, eval[i])) : std::complex<RealType>(0.0, 0.0); } } // perform matrix multiplication // assume row major BLAS::gemm('N', 'C', n, n, n, std::complex<RealType>(1.0, 0), &mat_d.at(0), n, &mat_h.at(0), n, std::complex<RealType>(0.0, 0.0), &mat_t.at(0), n); BLAS::gemm('N', 'N', n, n, n, std::complex<RealType>(1.0, 0), &mat_h.at(0), n, &mat_t.at(0), n, std::complex<RealType>(0.0, 0.0), &mat_d.at(0), n); for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) { if (mat_d[i + n * j].imag() > 1e-12) { app_log() << "warning: large imaginary value in orbital rotation matrix: (i,j) = (" << i << "," << j << "), im = " << mat_d[i + n * j].imag() << std::endl; } mat[j][i] = mat_d[i + n * j].real(); } } void RotatedSPOs::evaluateDerivatives(ParticleSet& P, const opt_variables_type& optvars, std::vector<ValueType>& dlogpsi, std::vector<ValueType>& dhpsioverpsi, const int& FirstIndex, const int& LastIndex) { const size_t nel = LastIndex - FirstIndex; const size_t nmo = Phi->getOrbitalSetSize(); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PART1 myG_temp.resize(nel); myG_J.resize(nel); myL_temp.resize(nel); myL_J.resize(nel); myG_temp = 0; myG_J = 0; myL_temp = 0; myL_J = 0; Bbar.resize(nel, nmo); psiM_inv.resize(nel, nel); psiM_all.resize(nel, nmo); dpsiM_all.resize(nel, nmo); d2psiM_all.resize(nel, nmo); Bbar = 0; psiM_inv = 0; psiM_all = 0; dpsiM_all = 0; d2psiM_all = 0; Phi->evaluate_notranspose(P, FirstIndex, LastIndex, psiM_all, dpsiM_all, d2psiM_all); for (int i = 0; i < nel; i++) for (int j = 0; j < nel; j++) psiM_inv(i, j) = psiM_all(i, j); Invert(psiM_inv.data(), nel, nel); //current value of Gradient and Laplacian // gradient components for (int a = 0; a < nel; a++) for (int i = 0; i < nel; i++) for (int k = 0; k < 3; k++) myG_temp[a][k] += psiM_inv(i, a) * dpsiM_all(a, i)[k]; // laplacian components for (int a = 0; a < nel; a++) { for (int i = 0; i < nel; i++) myL_temp[a] += psiM_inv(i, a) * d2psiM_all(a, i); } // calculation of myG_J which will be used to represent \frac{\nabla\psi_{J}}{\psi_{J}} // calculation of myL_J will be used to represent \frac{\nabla^2\psi_{J}}{\psi_{J}} // IMPORTANT NOTE: The value of P.L holds \nabla^2 ln[\psi] but we need \frac{\nabla^2 \psi}{\psi} and this is what myL_J will hold for (int a = 0, iat = FirstIndex; a < nel; a++, iat++) { myG_J[a] = (P.G[iat] - myG_temp[a]); myL_J[a] = (P.L[iat] + dot(P.G[iat], P.G[iat]) - myL_temp[a]); } //possibly replace wit BLAS calls for (int i = 0; i < nel; i++) for (int j = 0; j < nmo; j++) Bbar(i, j) = d2psiM_all(i, j) + 2 * dot(myG_J[i], dpsiM_all(i, j)) + myL_J[i] * psiM_all(i, j); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PART2 const ValueType* const A(psiM_all.data()); const ValueType* const Ainv(psiM_inv.data()); const ValueType* const B(Bbar.data()); SPOSet::ValueMatrix_t T; SPOSet::ValueMatrix_t Y1; SPOSet::ValueMatrix_t Y2; SPOSet::ValueMatrix_t Y3; SPOSet::ValueMatrix_t Y4; T.resize(nel, nmo); Y1.resize(nel, nel); Y2.resize(nel, nmo); Y3.resize(nel, nmo); Y4.resize(nel, nmo); BLAS::gemm('N', 'N', nmo, nel, nel, ValueType(1.0), A, nmo, Ainv, nel, ValueType(0.0), T.data(), nmo); BLAS::gemm('N', 'N', nel, nel, nel, ValueType(1.0), B, nmo, Ainv, nel, ValueType(0.0), Y1.data(), nel); BLAS::gemm('N', 'N', nmo, nel, nel, ValueType(1.0), T.data(), nmo, Y1.data(), nel, ValueType(0.0), Y2.data(), nmo); BLAS::gemm('N', 'N', nmo, nel, nel, ValueType(1.0), B, nmo, Ainv, nel, ValueType(0.0), Y3.data(), nmo); //possibly replace with BLAS call Y4 = Y3 - Y2; for (int i = 0; i < m_act_rot_inds.size(); i++) { int kk = myVars.where(i); const int p = m_act_rot_inds.at(i).first; const int q = m_act_rot_inds.at(i).second; dlogpsi.at(kk) = T(p, q); dhpsioverpsi.at(kk) = ValueType(-0.5) * Y4(p, q); } } void RotatedSPOs::evaluateDerivatives(ParticleSet& P, const opt_variables_type& optvars, std::vector<ValueType>& dlogpsi, std::vector<ValueType>& dhpsioverpsi, const ValueType& psiCurrent, const std::vector<ValueType>& Coeff, const std::vector<size_t>& C2node_up, const std::vector<size_t>& C2node_dn, const ValueVector_t& detValues_up, const ValueVector_t& detValues_dn, const GradMatrix_t& grads_up, const GradMatrix_t& grads_dn, const ValueMatrix_t& lapls_up, const ValueMatrix_t& lapls_dn, const ValueMatrix_t& M_up, const ValueMatrix_t& M_dn, const ValueMatrix_t& Minv_up, const ValueMatrix_t& Minv_dn, const GradMatrix_t& B_grad, const ValueMatrix_t& B_lapl, const std::vector<int>& detData_up, const size_t N1, const size_t N2, const size_t NP1, const size_t NP2, const std::vector<std::vector<int>>& lookup_tbl) { bool recalculate(false); for (int k = 0; k < myVars.size(); ++k) { int kk = myVars.where(k); if (kk < 0) continue; if (optvars.recompute(kk)) recalculate = true; } if (recalculate) { ParticleSet::ParticleGradient_t myG_temp, myG_J; ParticleSet::ParticleLaplacian_t myL_temp, myL_J; const int NP = P.getTotalNum(); myG_temp.resize(NP); myG_temp = 0.0; myL_temp.resize(NP); myL_temp = 0.0; myG_J.resize(NP); myG_J = 0.0; myL_J.resize(NP); myL_J = 0.0; const size_t nmo = Phi->getOrbitalSetSize(); const size_t nb = Phi->getBasisSetSize(); const size_t nel = P.last(0) - P.first(0); const RealType* restrict C_p = Coeff.data(); for (int i = 0; i < Coeff.size(); i++) { const size_t upC = C2node_up[i]; const size_t dnC = C2node_dn[i]; const ValueType tmp1 = C_p[i] * detValues_dn[dnC]; const ValueType tmp2 = C_p[i] * detValues_up[upC]; for (size_t k = 0, j = N1; k < NP1; k++, j++) { myG_temp[j] += tmp1 * grads_up(upC, k); myL_temp[j] += tmp1 * lapls_up(upC, k); } for (size_t k = 0, j = N2; k < NP2; k++, j++) { myG_temp[j] += tmp2 * grads_dn(dnC, k); myL_temp[j] += tmp2 * lapls_dn(dnC, k); } } myG_temp *= (1 / psiCurrent); myL_temp *= (1 / psiCurrent); // calculation of myG_J which will be used to represent \frac{\nabla\psi_{J}}{\psi_{J}} // calculation of myL_J will be used to represent \frac{\nabla^2\psi_{J}}{\psi_{J}} // IMPORTANT NOTE: The value of P.L holds \nabla^2 ln[\psi] but we need \frac{\nabla^2 \psi}{\psi} and this is what myL_J will hold for (int iat = 0; iat < (myL_temp.size()); iat++) { myG_J[iat] = (P.G[iat] - myG_temp[iat]); myL_J[iat] = (P.L[iat] + dot(P.G[iat], P.G[iat]) - myL_temp[iat]); } table_method_eval(dlogpsi, dhpsioverpsi, myL_J, myG_J, nel, nmo, psiCurrent, Coeff, C2node_up, C2node_dn, detValues_up, detValues_dn, grads_up, grads_dn, lapls_up, lapls_dn, M_up, M_dn, Minv_up, Minv_dn, B_grad, B_lapl, detData_up, N1, N2, NP1, NP2, lookup_tbl); } } void RotatedSPOs::evaluateDerivativesWF(ParticleSet& P, const opt_variables_type& optvars, std::vector<ValueType>& dlogpsi, const QTFull::ValueType& psiCurrent, const std::vector<ValueType>& Coeff, const std::vector<size_t>& C2node_up, const std::vector<size_t>& C2node_dn, const ValueVector_t& detValues_up, const ValueVector_t& detValues_dn, const ValueMatrix_t& M_up, const ValueMatrix_t& M_dn, const ValueMatrix_t& Minv_up, const ValueMatrix_t& Minv_dn, const std::vector<int>& detData_up, const std::vector<std::vector<int>>& lookup_tbl) { bool recalculate(false); for (int k = 0; k < myVars.size(); ++k) { int kk = myVars.where(k); if (kk < 0) continue; if (optvars.recompute(kk)) recalculate = true; } if (recalculate) { const size_t nmo = Phi->getOrbitalSetSize(); const size_t nb = Phi->getBasisSetSize(); const size_t nel = P.last(0) - P.first(0); table_method_evalWF(dlogpsi, nel, nmo, psiCurrent, Coeff, C2node_up, C2node_dn, detValues_up, detValues_dn, M_up, M_dn, Minv_up, Minv_dn, detData_up, lookup_tbl); } } void RotatedSPOs::table_method_eval(std::vector<ValueType>& dlogpsi, std::vector<ValueType>& dhpsioverpsi, const ParticleSet::ParticleLaplacian_t& myL_J, const ParticleSet::ParticleGradient_t& myG_J, const size_t nel, const size_t nmo, const ValueType& psiCurrent, const std::vector<RealType>& Coeff, const std::vector<size_t>& C2node_up, const std::vector<size_t>& C2node_dn, const ValueVector_t& detValues_up, const ValueVector_t& detValues_dn, const GradMatrix_t& grads_up, const GradMatrix_t& grads_dn, const ValueMatrix_t& lapls_up, const ValueMatrix_t& lapls_dn, const ValueMatrix_t& M_up, const ValueMatrix_t& M_dn, const ValueMatrix_t& Minv_up, const ValueMatrix_t& Minv_dn, const GradMatrix_t& B_grad, const ValueMatrix_t& B_lapl, const std::vector<int>& detData_up, const size_t N1, const size_t N2, const size_t NP1, const size_t NP2, const std::vector<std::vector<int>>& lookup_tbl) /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GUIDE TO THE MATICES BEING BUILT ---------------------------------------------- The idea here is that there is a loop over all unique determinants. For each determiant the table method is employed to calculate the contributions to the parameter derivatives (dhpsioverpsi/dlogpsi) loop through unquie determinants loop through parameters evaluate contributaion to dlogpsi and dhpsioverpsi \noindent BLAS GUIDE for matrix multiplication of [ alpha * A.B + beta * C = C ] Matrix A is of dimensions a1,a2 and Matrix B is b1,b2 in which a2=b1 The BLAS command is as follows... BLAS::gemm('N','N', b2, a1, a2 ,alpha, B, b2, A, a2, beta, C, b2); Below is a human readable format for the matrix multiplications performed below... This notation is inspired by http://dx.doi.org/10.1063/1.4948778 \newline \hfill\break $ A_{i,j}=\phi_j(r_{i}) \\ T = A^{-1} \widetilde{A} \\ B_{i,j} =\nabla^2 \phi_{j}(r_i) + \frac{\nabla_{i}J}{J} \cdot \nabla \phi_{j}(r_{i}) + \frac{\nabla^2_i J}{J} \phi_{j}(r_{i}) \\ \hat{O_{I}} = \hat{O}D_{I} \\ D_{I}=det(A_{I}) \newline \psi_{MS} = \sum_{I=0} C_{I} D_{I\uparrow}D_{I\downarrow} \\ \Psi_{total} = \psi_{J}\psi_{MS} \\ \alpha_{I} = P^{T}_{I}TQ_{I} \\ M_{I} = P^{T}_{I} \widetilde{M} Q_{I} = P^{T}_{I} (A^{-1}\widetilde{B} - A^{-1} B A^{-1}\widetilde{A} )Q_{I} \\ $ \newline There are three constants I use in the expressions for dhpsioverpsi and dlogpsi \newline \hfill\break $ const0 = C_{0}*det(A_{0\downarrow})+\sum_{I=1} C_{I}*det(A_{I\downarrow})* det(\alpha_{I\uparrow}) \\ const1 = C_{0}*\hat{O} det(A_{0\downarrow})+\sum_{I=1} C_{I}*\hat{O}det(A_{I\downarrow})* det(\alpha_{I\uparrow}) \\ const2 = \sum_{I=1} C_{I}*det(A_{I\downarrow})* Tr[\alpha_{I}^{-1}M_{I}]*det(\alpha_{I}) \\ $ \newline Below is a translation of the shorthand I use to represent matrices independent of ``excitation matrix". \newline \hfill\break $ Y_{1} = A^{-1}B \\ Y_{2} = A^{-1}BA^{-1}\widetilde{A} \\ Y_{3} = A^{-1}\widetilde{B} \\ Y_{4} = \widetilde{M} = (A^{-1}\widetilde{B} - A^{-1} B A^{-1}\widetilde{A} )\\ $ \newline Below is a translation of the shorthand I use to represent matrices dependent on ``excitation" with respect to the reference Matrix and sums of matrices. Above this line I have represented these excitation matrices with a subscript ``I" but from this point on The subscript will be omitted and it is clear that whenever a matrix depends on $P^{T}_I$ and $Q_{I}$ that this is an excitation matrix. The reference matrix is always $A_{0}$ and is always the Hartree Fock Matrix. \newline \hfill\break $ Y_{5} = TQ \\ Y_{6} = (P^{T}TQ)^{-1} = \alpha_{I}^{-1}\\ Y_{7} = \alpha_{I}^{-1} P^{T} \\ Y_{11} = \widetilde{M}Q \\ Y_{23} = P^{T}\widetilde{M}Q \\ Y_{24} = \alpha_{I}^{-1}P^{T}\widetilde{M}Q \\ Y_{25} = \alpha_{I}^{-1}P^{T}\widetilde{M}Q\alpha_{I}^{-1} \\ Y_{26} = \alpha_{I}^{-1}P^{T}\widetilde{M}Q\alpha_{I}^{-1}P^{T}\\ $ \newline So far you will notice that I have not included up or down arrows to specify what spin the matrices are of. This is because we are calculating the derivative of all up or all down spin orbital rotation parameters at a time. If we are finding the up spin derivatives then any term that is down spin will be constant. The following assumes that we are taking up-spin MO rotation parameter derivatives. Of course the down spin expression can be retrieved by swapping the up and down arrows. I have dubbed any expression with lowercase p prefix as a "precursor" to an expression actually used... \newline \hfill\break $ \dot{C_{I}} = C_{I}*det(A_{I\downarrow})\\ \ddot{C_{I}} = C_{I}*\hat{O}det(A_{I\downarrow}) \\ pK1 = \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) Tr[\alpha_{I}^{-1}M_{I}] (Q\alpha_{I}^{-1}P^{T}) \\ pK2 = \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) (Q\alpha_{I}^{-1}P^{T}) \\ pK3 = \sum_{I=1} \ddot{C_{I}} det(\alpha_{I}) (Q\alpha_{I}^{-1}P^{T}) \\ pK4 = \sum_{I=1} \dot{C_{I}} det(A_{I}) (Q\alpha_{I}^{-1}P^{T}) \\ pK5 = \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) (Q\alpha_{I}^{-1} M_{I} \alpha_{I}^{-1}P^{T}) \\ $ \newline Now these p matrices will be used to make various expressions via BLAS commands. \newline \hfill\break $ K1T = const0^{-1}*pK1.T =const0^{-1} \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) Tr[\alpha_{I}^{-1}M_{I}] (Q\alpha_{I}^{-1}P^{T}T) \\ TK1T = T.K1T = const0^{-1} \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) Tr[\alpha_{I}^{-1}M_{I}] (TQ\alpha_{I}^{-1}P^{T}T)\\ \\ K2AiB = const0^{-1} \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) (Q\alpha_{I}^{-1}P^{T}A^{-1}\widetilde{B})\\ TK2AiB = T.K2AiB = const0^{-1} \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) (TQ\alpha_{I}^{-1}P^{T}A^{-1}\widetilde{B})\\ K2XA = const0^{-1} \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) (Q\alpha_{I}^{-1}P^{T}X\widetilde{A})\\ TK2XA = T.K2XA = const0^{-1} \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) (TQ\alpha_{I}^{-1}P^{T}X\widetilde{A})\\ \\ K2T = \frac{const1}{const0^{2}} \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) (Q\alpha_{I}^{-1}P^{T}T) \\ TK2T = T.K2T =\frac{const1}{const0^{2}} \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) (TQ\alpha_{I}^{-1}P^{T}T) \\ MK2T = \frac{const0}{const1} Y_{4}.K2T= const0^{-1} \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) (\widetilde{M}Q\alpha_{I}^{-1}P^{T}T)\\ \\ K3T = const0^{-1} \sum_{I=1} \ddot{C_{I}} det(\alpha_{I}) (Q\alpha_{I}^{-1}P^{T}T) \\ TK3T = T.K3T = const0^{-1} \sum_{I=1} \ddot{C_{I}} det(\alpha_{I}) (TQ\alpha_{I}^{-1}P^{T}T)\\ \\ K4T = \sum_{I=1} \dot{C_{I}} det(A_{I}) (Q\alpha_{I}^{-1}P^{T}T) \\ TK4T = T.K4T = \sum_{I=1} \dot{C_{I}} det(A_{I}) (TQ\alpha_{I}^{-1}P^{T}T) \\ \\ K5T = const0^{-1} \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) (Q\alpha_{I}^{-1} M_{I} \alpha_{I}^{-1}P^{T} T) \\ TK5T = T.K5T = \sum_{I=1} \dot{C_{I}} det(\alpha_{I}) (T Q\alpha_{I}^{-1} M_{I} \alpha_{I}^{-1}P^{T} T) \\ $ \newline Now with all these matrices and constants the expressions of dhpsioverpsi and dlogpsi can be created. In addition I will be using a special generalization of the kinetic operator which I will denote as O. Our Slater matrix with the special O operator applied to each element will be called B_bar $ ``Bbar"_{i,j} =\nabla^2 \phi_{j}(r_i) + \frac{\nabla_{i}J}{J} \cdot \nabla \phi_{j}(r_{i}) + \frac{\nabla^2_i J}{J} \phi_{j}(r_{i}) $ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ { ValueMatrix_t Table; ValueMatrix_t Bbar; ValueMatrix_t Y1, Y2, Y3, Y4, Y5, Y6, Y7, Y11, Y23, Y24, Y25, Y26; ValueMatrix_t pK1, K1T, TK1T, pK2, K2AiB, TK2AiB, K2XA, TK2XA, K2T, TK2T, MK2T, pK3, K3T, TK3T, pK5, K5T, TK5T; Table.resize(nel, nmo); Bbar.resize(nel, nmo); Y1.resize(nel, nel); Y2.resize(nel, nmo); Y3.resize(nel, nmo); Y4.resize(nel, nmo); pK1.resize(nmo, nel); K1T.resize(nmo, nmo); TK1T.resize(nel, nmo); pK2.resize(nmo, nel); K2AiB.resize(nmo, nmo); TK2AiB.resize(nel, nmo); K2XA.resize(nmo, nmo); TK2XA.resize(nel, nmo); K2T.resize(nmo, nmo); TK2T.resize(nel, nmo); MK2T.resize(nel, nmo); pK3.resize(nmo, nel); K3T.resize(nmo, nmo); TK3T.resize(nel, nmo); pK5.resize(nmo, nel); K5T.resize(nmo, nmo); TK5T.resize(nel, nmo); const int parameters_size(m_act_rot_inds.size()); const int parameter_start_index(0); const size_t num_unique_up_dets(detValues_up.size()); const size_t num_unique_dn_dets(detValues_dn.size()); const RealType* restrict cptr = Coeff.data(); const size_t nc = Coeff.size(); const size_t* restrict upC(C2node_up.data()); const size_t* restrict dnC(C2node_dn.data()); //B_grad holds the gardient operator //B_lapl holds the laplacian operator //B_bar will hold our special O operator const int offset1(N1); const int offset2(N2); const int NPother(NP2); RealType* T(Table.data()); //possibly replace wit BLAS calls for (int i = 0; i < nel; i++) for (int j = 0; j < nmo; j++) Bbar(i, j) = B_lapl(i, j) + 2 * dot(myG_J[i + offset1], B_grad(i, j)) + myL_J[i + offset1] * M_up(i, j); const RealType* restrict B(Bbar.data()); const RealType* restrict A(M_up.data()); const RealType* restrict Ainv(Minv_up.data()); //IMPORTANT NOTE: THE Dets[0]->psiMinv OBJECT DOES NOT HOLD THE INVERSE IF THE MULTIDIRACDETERMINANTBASE ONLY CONTAINES ONE ELECTRON. NEED A FIX FOR THIS CASE // The T matrix should be calculated and stored for use // T = A^{-1} \widetilde A //REMINDER: that the ValueMatrix_t "matrix" stores data in a row major order and that BLAS commands assume column major BLAS::gemm('N', 'N', nmo, nel, nel, RealType(1.0), A, nmo, Ainv, nel, RealType(0.0), T, nmo); BLAS::gemm('N', 'N', nel, nel, nel, RealType(1.0), B, nmo, Ainv, nel, RealType(0.0), Y1.data(), nel); BLAS::gemm('N', 'N', nmo, nel, nel, RealType(1.0), T, nmo, Y1.data(), nel, RealType(0.0), Y2.data(), nmo); BLAS::gemm('N', 'N', nmo, nel, nel, RealType(1.0), B, nmo, Ainv, nel, RealType(0.0), Y3.data(), nmo); //possibly replace with BLAS call Y4 = Y3 - Y2; //Need to create the constants: (Oi, const0, const1, const2)to take advantage of minimal BLAS commands; //Oi is the special operator applied to the slater matrix "A subscript i" from the total CI expansion //\hat{O_{i}} = \hat{O}D_{i} with D_{i}=det(A_{i}) and Multi-Slater component defined as \sum_{i=0} C_{i} D_{i\uparrow}D_{i\downarrow} std::vector<RealType> Oi(num_unique_dn_dets); for (int index = 0; index < num_unique_dn_dets; index++) for (int iat = 0; iat < NPother; iat++) Oi[index] += lapls_dn(index, iat) + 2 * dot(grads_dn(index, iat), myG_J[offset2 + iat]) + myL_J[offset2 + iat] * detValues_dn[index]; //const0 = C_{0}*det(A_{0\downarrow})+\sum_{i=1} C_{i}*det(A_{i\downarrow})* det(\alpha_{i\uparrow}) //const1 = C_{0}*\hat{O} det(A_{0\downarrow})+\sum_{i=1} C_{i}*\hat{O}det(A_{i\downarrow})* det(\alpha_{i\uparrow}) //const2 = \sum_{i=1} C_{i}*det(A_{i\downarrow})* Tr[\alpha_{i}^{-1}M_{i}]*det(\alpha_{i}) RealType const0(0.0), const1(0.0), const2(0.0); for (size_t i = 0; i < nc; ++i) { const RealType c = cptr[i]; const size_t up = upC[i]; const size_t down = dnC[i]; const0 += c * detValues_dn[down] * (detValues_up[up] / detValues_up[0]); const1 += c * Oi[down] * (detValues_up[up] / detValues_up[0]); } std::fill(pK1.begin(), pK1.end(), 0.0); std::fill(pK2.begin(), pK2.end(), 0.0); std::fill(pK3.begin(), pK3.end(), 0.0); std::fill(pK5.begin(), pK5.end(), 0.0); //Now we are going to loop through all unique determinants. //The few lines above are for the reference matrix contribution. //Although I start the loop below from index 0, the loop only performs actions when the index is >= 1 //the detData object contains all the information about the P^T and Q matrices (projection matrices) needed in the table method const int* restrict data_it = detData_up.data(); for (int index = 0, datum = 0; index < num_unique_up_dets; index++) { const int k = data_it[datum]; if (k == 0) { datum += 3 * k + 1; } else { //Number of rows and cols of P^T const int prows = k; const int pcols = nel; //Number of rows and cols of Q const int qrows = nmo; const int qcols = k; Y5.resize(nel, k); Y6.resize(k, k); //Any matrix multiplication of P^T or Q is simply a projection //Explicit matrix multiplication can be avoided; instead column or row copying can be done //BlAS::copy(size of col/row being copied, // Matrix pointer + place to begin copying, // storage spacing (number of elements btw next row/col element), // Pointer to resultant matrix + place to begin pasting, // storage spacing of resultant matrix) //For example the next 4 lines is the matrix multiplication of T*Q = Y5 std::fill(Y5.begin(), Y5.end(), 0.0); for (int i = 0; i < k; i++) { BLAS::copy(nel, T + data_it[datum + 1 + k + i], nmo, Y5.data() + i, k); } std::fill(Y6.begin(), Y6.end(), 0.0); for (int i = 0; i < k; i++) { BLAS::copy(k, Y5.data() + (data_it[datum + 1 + i]) * k, 1, (Y6.data() + i * k), 1); } Vector<ValueType> WS; Vector<IndexType> Piv; WS.resize(k); Piv.resize(k); std::complex<RealType> logdet = 0.0; InvertWithLog(Y6.data(), k, k, WS.data(), Piv.data(), logdet); Y11.resize(nel, k); Y23.resize(k, k); Y24.resize(k, k); Y25.resize(k, k); Y26.resize(k, nel); std::fill(Y11.begin(), Y11.end(), 0.0); for (int i = 0; i < k; i++) { BLAS::copy(nel, Y4.data() + (data_it[datum + 1 + k + i]), nmo, Y11.data() + i, k); } std::fill(Y23.begin(), Y23.end(), 0.0); for (int i = 0; i < k; i++) { BLAS::copy(k, Y11.data() + (data_it[datum + 1 + i]) * k, 1, (Y23.data() + i * k), 1); } BLAS::gemm('N', 'N', k, k, k, RealType(1.0), Y23.data(), k, Y6.data(), k, RealType(0.0), Y24.data(), k); BLAS::gemm('N', 'N', k, k, k, RealType(1.0), Y6.data(), k, Y24.data(), k, RealType(0.0), Y25.data(), k); Y26.resize(k, nel); std::fill(Y26.begin(), Y26.end(), 0.0); for (int i = 0; i < k; i++) { BLAS::copy(k, Y25.data() + i, k, Y26.data() + (data_it[datum + 1 + i]), nel); } Y7.resize(k, nel); std::fill(Y7.begin(), Y7.end(), 0.0); for (int i = 0; i < k; i++) { BLAS::copy(k, Y6.data() + i, k, Y7.data() + (data_it[datum + 1 + i]), nel); } // c_Tr_AlphaI_MI is a constant contributing to constant const2 // c_Tr_AlphaI_MI = Tr[\alpha_{I}^{-1}(P^{T}\widetilde{M} Q)] RealType c_Tr_AlphaI_MI = 0.0; for (int i = 0; i < k; i++) { c_Tr_AlphaI_MI += Y24(i, i); } for (int p = 0; p < lookup_tbl[index].size(); p++) { //el_p is the element position that contains information about the CI coefficient, and det up/dn values associated with the current unique determinant const int el_p(lookup_tbl[index][p]); const RealType c = cptr[el_p]; const size_t up = upC[el_p]; const size_t down = dnC[el_p]; const RealType alpha_1(c * detValues_dn[down] * detValues_up[up] / detValues_up[0] * c_Tr_AlphaI_MI); const RealType alpha_2(c * detValues_dn[down] * detValues_up[up] / detValues_up[0]); const RealType alpha_3(c * Oi[down] * detValues_up[up] / detValues_up[0]); const2 += alpha_1; for (int i = 0; i < k; i++) { BLAS::axpy(nel, alpha_1, Y7.data() + i * nel, 1, pK1.data() + (data_it[datum + 1 + k + i]) * nel, 1); BLAS::axpy(nel, alpha_2, Y7.data() + i * nel, 1, pK2.data() + (data_it[datum + 1 + k + i]) * nel, 1); BLAS::axpy(nel, alpha_3, Y7.data() + i * nel, 1, pK3.data() + (data_it[datum + 1 + k + i]) * nel, 1); BLAS::axpy(nel, alpha_2, Y26.data() + i * nel, 1, pK5.data() + (data_it[datum + 1 + k + i]) * nel, 1); } } datum += 3 * k + 1; } } BLAS::gemm('N', 'N', nmo, nmo, nel, 1.0 / const0, T, nmo, pK1.data(), nel, RealType(0.0), K1T.data(), nmo); BLAS::gemm('N', 'N', nmo, nel, nmo, RealType(1.0), K1T.data(), nmo, T, nmo, RealType(0.0), TK1T.data(), nmo); BLAS::gemm('N', 'N', nmo, nmo, nel, 1.0 / const0, Y3.data(), nmo, pK2.data(), nel, RealType(0.0), K2AiB.data(), nmo); BLAS::gemm('N', 'N', nmo, nel, nmo, RealType(1.0), K2AiB.data(), nmo, T, nmo, RealType(0.0), TK2AiB.data(), nmo); BLAS::gemm('N', 'N', nmo, nmo, nel, 1.0 / const0, Y2.data(), nmo, pK2.data(), nel, RealType(0.0), K2XA.data(), nmo); BLAS::gemm('N', 'N', nmo, nel, nmo, RealType(1.0), K2XA.data(), nmo, T, nmo, RealType(0.0), TK2XA.data(), nmo); BLAS::gemm('N', 'N', nmo, nmo, nel, const1 / (const0 * const0), T, nmo, pK2.data(), nel, RealType(0.0), K2T.data(), nmo); BLAS::gemm('N', 'N', nmo, nel, nmo, RealType(1.0), K2T.data(), nmo, T, nmo, RealType(0.0), TK2T.data(), nmo); BLAS::gemm('N', 'N', nmo, nel, nmo, const0 / const1, K2T.data(), nmo, Y4.data(), nmo, RealType(0.0), MK2T.data(), nmo); BLAS::gemm('N', 'N', nmo, nmo, nel, 1.0 / const0, T, nmo, pK3.data(), nel, RealType(0.0), K3T.data(), nmo); BLAS::gemm('N', 'N', nmo, nel, nmo, RealType(1.0), K3T.data(), nmo, T, nmo, RealType(0.0), TK3T.data(), nmo); BLAS::gemm('N', 'N', nmo, nmo, nel, 1.0 / const0, T, nmo, pK5.data(), nel, RealType(0.0), K5T.data(), nmo); BLAS::gemm('N', 'N', nmo, nel, nmo, RealType(1.0), K5T.data(), nmo, T, nmo, RealType(0.0), TK5T.data(), nmo); for (int mu = 0, k = parameter_start_index; k < (parameter_start_index + parameters_size); k++, mu++) { int kk = myVars.where(k); const int i(m_act_rot_inds[mu].first), j(m_act_rot_inds[mu].second); if (i <= nel - 1 && j > nel - 1) { dhpsioverpsi[kk] += ValueType(-0.5 * Y4(i, j) - 0.5 * (-K5T(i, j) + K5T(j, i) + TK5T(i, j) + K2AiB(i, j) - K2AiB(j, i) - TK2AiB(i, j) - K2XA(i, j) + K2XA(j, i) + TK2XA(i, j) - MK2T(i, j) + K1T(i, j) - K1T(j, i) - TK1T(i, j) - const2 / const1 * K2T(i, j) + const2 / const1 * K2T(j, i) + const2 / const1 * TK2T(i, j) + K3T(i, j) - K3T(j, i) - TK3T(i, j) - K2T(i, j) + K2T(j, i) + TK2T(i, j))); } else if (i <= nel - 1 && j <= nel - 1) { dhpsioverpsi[kk] += ValueType( -0.5 * (Y4(i, j) - Y4(j, i)) - 0.5 * (-K5T(i, j) + K5T(j, i) + TK5T(i, j) - TK5T(j, i) + K2AiB(i, j) - K2AiB(j, i) - TK2AiB(i, j) + TK2AiB(j, i) - K2XA(i, j) + K2XA(j, i) + TK2XA(i, j) - TK2XA(j, i) - MK2T(i, j) + MK2T(j, i) + K1T(i, j) - K1T(j, i) - TK1T(i, j) + TK1T(j, i) - const2 / const1 * K2T(i, j) + const2 / const1 * K2T(j, i) + const2 / const1 * TK2T(i, j) - const2 / const1 * TK2T(j, i) + K3T(i, j) - K3T(j, i) - TK3T(i, j) + TK3T(j, i) - K2T(i, j) + K2T(j, i) + TK2T(i, j) - TK2T(j, i))); } else { dhpsioverpsi[kk] += ValueType(-0.5 * (-K5T(i, j) + K5T(j, i) + K2AiB(i, j) - K2AiB(j, i) - K2XA(i, j) + K2XA(j, i) + K1T(i, j) - K1T(j, i) - const2 / const1 * K2T(i, j) + const2 / const1 * K2T(j, i) + K3T(i, j) - K3T(j, i) - K2T(i, j) + K2T(j, i))); } } } void RotatedSPOs::table_method_evalWF(std::vector<ValueType>& dlogpsi, const size_t nel, const size_t nmo, const ValueType& psiCurrent, const std::vector<RealType>& Coeff, const std::vector<size_t>& C2node_up, const std::vector<size_t>& C2node_dn, const ValueVector_t& detValues_up, const ValueVector_t& detValues_dn, const ValueMatrix_t& M_up, const ValueMatrix_t& M_dn, const ValueMatrix_t& Minv_up, const ValueMatrix_t& Minv_dn, const std::vector<int>& detData_up, const std::vector<std::vector<int>>& lookup_tbl) { ValueMatrix_t Table; ValueMatrix_t Y5, Y6, Y7; ValueMatrix_t pK4, K4T, TK4T; Table.resize(nel, nmo); Bbar.resize(nel, nmo); pK4.resize(nmo, nel); K4T.resize(nmo, nmo); TK4T.resize(nel, nmo); const int parameters_size(m_act_rot_inds.size()); const int parameter_start_index(0); const size_t num_unique_up_dets(detValues_up.size()); const size_t num_unique_dn_dets(detValues_dn.size()); const RealType* restrict cptr = Coeff.data(); const size_t nc = Coeff.size(); const size_t* restrict upC(C2node_up.data()); const size_t* restrict dnC(C2node_dn.data()); RealType* T(Table.data()); const RealType* restrict A(M_up.data()); const RealType* restrict Ainv(Minv_up.data()); //IMPORTANT NOTE: THE Dets[0]->psiMinv OBJECT DOES NOT HOLD THE INVERSE IF THE MULTIDIRACDETERMINANTBASE ONLY CONTAINES ONE ELECTRON. NEED A FIX FOR THIS CASE // The T matrix should be calculated and stored for use // T = A^{-1} \widetilde A //REMINDER: that the ValueMatrix_t "matrix" stores data in a row major order and that BLAS commands assume column major BLAS::gemm('N', 'N', nmo, nel, nel, RealType(1.0), A, nmo, Ainv, nel, RealType(0.0), T, nmo); //const0 = C_{0}*det(A_{0\downarrow})+\sum_{i=1} C_{i}*det(A_{i\downarrow})* det(\alpha_{i\uparrow}) RealType const0(0.0), const1(0.0), const2(0.0); for (size_t i = 0; i < nc; ++i) { const RealType c = cptr[i]; const size_t up = upC[i]; const size_t down = dnC[i]; const0 += c * detValues_dn[down] * (detValues_up[up] / detValues_up[0]); } std::fill(pK4.begin(), pK4.end(), 0.0); //Now we are going to loop through all unique determinants. //The few lines above are for the reference matrix contribution. //Although I start the loop below from index 0, the loop only performs actions when the index is >= 1 //the detData object contains all the information about the P^T and Q matrices (projection matrices) needed in the table method const int* restrict data_it = detData_up.data(); for (int index = 0, datum = 0; index < num_unique_up_dets; index++) { const int k = data_it[datum]; if (k == 0) { datum += 3 * k + 1; } else { //Number of rows and cols of P^T const int prows = k; const int pcols = nel; //Number of rows and cols of Q const int qrows = nmo; const int qcols = k; Y5.resize(nel, k); Y6.resize(k, k); //Any matrix multiplication of P^T or Q is simply a projection //Explicit matrix multiplication can be avoided; instead column or row copying can be done //BlAS::copy(size of col/row being copied, // Matrix pointer + place to begin copying, // storage spacing (number of elements btw next row/col element), // Pointer to resultant matrix + place to begin pasting, // storage spacing of resultant matrix) //For example the next 4 lines is the matrix multiplication of T*Q = Y5 std::fill(Y5.begin(), Y5.end(), 0.0); for (int i = 0; i < k; i++) { BLAS::copy(nel, T + data_it[datum + 1 + k + i], nmo, Y5.data() + i, k); } std::fill(Y6.begin(), Y6.end(), 0.0); for (int i = 0; i < k; i++) { BLAS::copy(k, Y5.data() + (data_it[datum + 1 + i]) * k, 1, (Y6.data() + i * k), 1); } Vector<ValueType> WS; Vector<IndexType> Piv; WS.resize(k); Piv.resize(k); std::complex<RealType> logdet = 0.0; InvertWithLog(Y6.data(), k, k, WS.data(), Piv.data(), logdet); Y7.resize(k, nel); std::fill(Y7.begin(), Y7.end(), 0.0); for (int i = 0; i < k; i++) { BLAS::copy(k, Y6.data() + i, k, Y7.data() + (data_it[datum + 1 + i]), nel); } for (int p = 0; p < lookup_tbl[index].size(); p++) { //el_p is the element position that contains information about the CI coefficient, and det up/dn values associated with the current unique determinant const int el_p(lookup_tbl[index][p]); const RealType c = cptr[el_p]; const size_t up = upC[el_p]; const size_t down = dnC[el_p]; const RealType alpha_4(c * detValues_dn[down] * detValues_up[up] * (1 / psiCurrent)); for (int i = 0; i < k; i++) { BLAS::axpy(nel, alpha_4, Y7.data() + i * nel, 1, pK4.data() + (data_it[datum + 1 + k + i]) * nel, 1); } } datum += 3 * k + 1; } } BLAS::gemm('N', 'N', nmo, nmo, nel, RealType(1.0), T, nmo, pK4.data(), nel, RealType(0.0), K4T.data(), nmo); BLAS::gemm('N', 'N', nmo, nel, nmo, RealType(1.0), K4T.data(), nmo, T, nmo, RealType(0.0), TK4T.data(), nmo); for (int mu = 0, k = parameter_start_index; k < (parameter_start_index + parameters_size); k++, mu++) { int kk = myVars.where(k); const int i(m_act_rot_inds[mu].first), j(m_act_rot_inds[mu].second); if (i <= nel - 1 && j > nel - 1) { dlogpsi[kk] += ValueType(detValues_up[0] * (Table(i, j)) * const0 * (1 / psiCurrent) + (K4T(i, j) - K4T(j, i) - TK4T(i, j))); } else if (i <= nel - 1 && j <= nel - 1) { dlogpsi[kk] += ValueType(detValues_up[0] * (Table(i, j) - Table(j, i)) * const0 * (1 / psiCurrent) + (K4T(i, j) - TK4T(i, j) - K4T(j, i) + TK4T(j, i))); } else { dlogpsi[kk] += ValueType((K4T(i, j) - K4T(j, i))); } } } SPOSet* RotatedSPOs::makeClone() const { RotatedSPOs* myclone = new RotatedSPOs(Phi->makeClone()); myclone->IsCloned = true; myclone->params = this->params; myclone->params_supplied = this->params_supplied; myclone->m_act_rot_inds = this->m_act_rot_inds; myclone->myVars = this->myVars; return myclone; } } // namespace qmcplusplus
41.675447
591
0.548249
djstaros
4e4319d714a0174de20855c2ffeaa1777ce58cd7
1,761
cc
C++
multibody/test/multibody_utils_test.cc
DavidDePauw1/dairlib
3c75c8f587927b12a58f2e88dda61cc0e7dc82a3
[ "BSD-3-Clause" ]
32
2019-04-15T03:10:26.000Z
2022-03-28T17:27:03.000Z
multibody/test/multibody_utils_test.cc
DavidDePauw1/dairlib
3c75c8f587927b12a58f2e88dda61cc0e7dc82a3
[ "BSD-3-Clause" ]
157
2019-02-21T03:13:57.000Z
2022-03-09T19:13:59.000Z
multibody/test/multibody_utils_test.cc
DavidDePauw1/dairlib
3c75c8f587927b12a58f2e88dda61cc0e7dc82a3
[ "BSD-3-Clause" ]
22
2019-03-02T22:31:42.000Z
2022-03-10T21:28:50.000Z
#include <gtest/gtest.h> #include <memory> #include <utility> #include "drake/geometry/scene_graph.h" #include "drake/multibody/parsing/parser.h" #include "multibody/multibody_utils.h" #include "common/find_resource.h" namespace dairlib { namespace multibody { namespace { using drake::multibody::MultibodyPlant; using drake::multibody::Parser; using Eigen::VectorXd; class MultibodyUtilsTest : public ::testing::Test { protected: void SetUp() override { // Building a floating-base plant drake::geometry::SceneGraph<double> scene_graph; std::string full_name = FindResourceOrThrow( "examples/Cassie/urdf/cassie_v2.urdf"); Parser parser(&plant_, &scene_graph); parser.AddModelFromFile(full_name); plant_.Finalize(); } MultibodyPlant<double> plant_{0.0}; }; // Test that maps can be constructed without errrors caught by the functions // themselves TEST_F(MultibodyUtilsTest, StateAndActuatorMappingTest) { auto positions_map = makeNameToPositionsMap(plant_); auto velocities_map = makeNameToVelocitiesMap(plant_); auto actuators_map = makeNameToActuatorsMap(plant_); } TEST_F(MultibodyUtilsTest, ContextTest) { VectorXd x = VectorXd::Zero(plant_.num_positions() + plant_.num_velocities()); x(5) = 1; x(10) = -1.5; VectorXd u = VectorXd::Zero(plant_.num_actuators()); u(0) = 2; u(3) = -3.1; auto context = createContext<double>(plant_, x, u); VectorXd x_context = plant_.GetPositionsAndVelocities(*context); VectorXd u_context = getInput(plant_, *context); EXPECT_EQ(x, x_context); EXPECT_EQ(u, u_context); } } // namespace } // namespace multibody } // namespace dairlib int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
25.157143
80
0.729131
DavidDePauw1
4e448891d7d94daa75f5f8e8c717194279ea91e4
5,463
cpp
C++
renderer.cpp
nvpro-samples/gl_cadscene_rendertechniques
70becfc08318c54c2de45f1791e6c7f821144029
[ "Apache-2.0" ]
134
2015-01-09T13:00:56.000Z
2022-02-06T06:23:25.000Z
renderer.cpp
nvpro-samples/gl_cadscene_rendertechniques
70becfc08318c54c2de45f1791e6c7f821144029
[ "Apache-2.0" ]
4
2015-08-23T17:44:59.000Z
2019-11-14T14:08:27.000Z
renderer.cpp
nvpro-samples/gl_cadscene_rendertechniques
70becfc08318c54c2de45f1791e6c7f821144029
[ "Apache-2.0" ]
38
2015-02-13T22:27:09.000Z
2021-10-16T00:36:26.000Z
/* * Copyright (c) 2014-2021, NVIDIA CORPORATION. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-FileCopyrightText: Copyright (c) 2014-2021 NVIDIA CORPORATION * SPDX-License-Identifier: Apache-2.0 */ /* Contact ckubisch@nvidia.com (Christoph Kubisch) for feedback */ #include <assert.h> #include <algorithm> #include "renderer.hpp" #include <nvmath/nvmath_glsltypes.h> #include "common.h" #pragma pack(1) namespace csfviewer { ////////////////////////////////////////////////////////////////////////// bool Renderer::s_bindless_ubo = false; CullingSystem Renderer::s_cullsys; ScanSystem Renderer::s_scansys; const char* toString( enum ShadeType st ) { switch(st){ case SHADE_SOLID: return "solid"; case SHADE_SOLIDWIRE: return "solid w edges"; case SHADE_SOLIDWIRE_SPLIT: return "solid w edges (split)"; } return NULL; } static void FillCache( std::vector<Renderer::DrawItem>& drawItems, const CadScene::Object& obj, const CadScene::Geometry& geo, bool solid, int objectIndex ) { int begin = 0; const CadScene::DrawRangeCache &cache = solid ? obj.cacheSolid : obj.cacheWire; for (size_t s = 0; s < cache.state.size(); s++) { const CadScene::DrawStateInfo &state = cache.state[s]; for (int d = 0; d < cache.stateCount[s]; d++){ // evict Renderer::DrawItem di; di.geometryIndex = obj.geometryIndex; di.matrixIndex = state.matrixIndex; di.materialIndex = state.materialIndex; di.objectIndex = objectIndex; di.solid = solid; di.range.offset = cache.offsets[begin + d]; di.range.count = cache.counts [begin + d]; drawItems.push_back(di); } begin += cache.stateCount[s]; } } static void FillJoin( std::vector<Renderer::DrawItem>& drawItems, const CadScene::Object& obj, const CadScene::Geometry& geo, bool solid, int objectIndex ) { CadScene::DrawRange range; int lastMaterial = -1; int lastMatrix = -1; for (size_t p = 0; p < obj.parts.size(); p++){ const CadScene::ObjectPart& part = obj.parts[p]; const CadScene::GeometryPart& mesh = geo.parts[p]; if (!part.active) continue; if (part.materialIndex != lastMaterial || part.matrixIndex != lastMatrix){ if (range.count){ // evict Renderer::DrawItem di; di.geometryIndex = obj.geometryIndex; di.matrixIndex = lastMatrix; di.materialIndex = lastMaterial; di.objectIndex = objectIndex; di.solid = solid; di.range = range; drawItems.push_back(di); } range = CadScene::DrawRange(); lastMaterial = part.materialIndex; lastMatrix = part.matrixIndex; } if (!range.count){ range.offset = solid ? mesh.indexSolid.offset : mesh.indexWire.offset; } range.count += solid ? mesh.indexSolid.count : mesh.indexWire.count; } // evict Renderer::DrawItem di; di.geometryIndex = obj.geometryIndex; di.matrixIndex = lastMatrix; di.materialIndex = lastMaterial; di.objectIndex = objectIndex; di.solid = solid; di.range = range; drawItems.push_back(di); } static void FillIndividual( std::vector<Renderer::DrawItem>& drawItems, const CadScene::Object& obj, const CadScene::Geometry& geo, bool solid, int objectIndex ) { for (size_t p = 0; p < obj.parts.size(); p++){ const CadScene::ObjectPart& part = obj.parts[p]; const CadScene::GeometryPart& mesh = geo.parts[p]; if (!part.active) continue; Renderer::DrawItem di; di.geometryIndex = obj.geometryIndex; di.matrixIndex = part.matrixIndex; di.materialIndex = part.materialIndex; di.objectIndex = objectIndex; di.solid = solid; di.range = solid ? mesh.indexSolid : mesh.indexWire; drawItems.push_back(di); } } void Renderer::fillDrawItems( std::vector<DrawItem>& drawItems, size_t from, size_t to, bool solid, bool wire ) { const CadScene* NV_RESTRICT scene = m_scene; for (size_t i = from; i < scene->m_objects.size() && i < to; i++){ const CadScene::Object& obj = scene->m_objects[i]; const CadScene::Geometry& geo = scene->m_geometry[obj.geometryIndex]; if (m_strategy == STRATEGY_GROUPS){ if (solid) FillCache(drawItems, obj, geo, true, int(i)); if (wire) FillCache(drawItems, obj, geo, false, int(i)); } else if (m_strategy == STRATEGY_JOIN) { if (solid) FillJoin(drawItems, obj, geo, true, int(i)); if (wire) FillJoin(drawItems, obj, geo, false, int(i)); } else if (m_strategy == STRATEGY_INDIVIDUAL){ if (solid) FillIndividual(drawItems, obj, geo, true, int(i)); if (wire) FillIndividual(drawItems, obj, geo, false, int(i)); } } } }
29.52973
164
0.630789
nvpro-samples
4e458759d26deebe795d4939bb6305e76105278c
728
cpp
C++
aoc2017/aoc170201.cpp
jiayuehua/adventOfCode
fd47ddefd286fe94db204a9850110f8d1d74d15b
[ "Unlicense" ]
null
null
null
aoc2017/aoc170201.cpp
jiayuehua/adventOfCode
fd47ddefd286fe94db204a9850110f8d1d74d15b
[ "Unlicense" ]
null
null
null
aoc2017/aoc170201.cpp
jiayuehua/adventOfCode
fd47ddefd286fe94db204a9850110f8d1d74d15b
[ "Unlicense" ]
null
null
null
#include <boost/circular_buffer.hpp> #include <iostream> #include <fstream> #include <sstream> #include <algorithm> #include <range/v3/algorithm.hpp> #include <range/v3/numeric.hpp> #include <range/v3/view.hpp> namespace views = ranges::views; int main(int argc, char **argv) { if (argc > 1) { std::ifstream ifs(argv[1]); std::string line; int n = 0; while (std::getline(ifs, line)) { std::istringstream iss(line); std::istream_iterator<int> b(iss); std::istream_iterator<int> e; std::vector<int> v; std::copy(b, e, std::back_inserter(v)); auto [pmin, pmax] = std::minmax_element(v.begin(), v.end()); n += (*pmax - *pmin); } std::cout << n << std::endl; } }
26
66
0.614011
jiayuehua
4e46dc1c41aee16314813d8300b5ba6fc7137fe2
25,402
cpp
C++
src/chain_action/self_pass_generator.cpp
sanmit/HFO-benchmark
0104ff7527485c8a7c159e6bf16c410eded72c0a
[ "MIT" ]
1
2018-11-22T16:04:55.000Z
2018-11-22T16:04:55.000Z
allejos2d/src/chain_action/self_pass_generator.cpp
PmecSimulation/Allejos2D
d0b3cb48e88f44b509e7dfe0329bb035bab748ce
[ "Apache-2.0" ]
null
null
null
allejos2d/src/chain_action/self_pass_generator.cpp
PmecSimulation/Allejos2D
d0b3cb48e88f44b509e7dfe0329bb035bab748ce
[ "Apache-2.0" ]
null
null
null
// -*-c++-*- /*! \file self_pass_generator.cpp \brief self pass generator Source File */ /* *Copyright: Copyright (C) Hidehisa AKIYAMA This code is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this code; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. *EndCopyright: */ ///////////////////////////////////////////////////////////////////// #ifdef HAVE_CONFIG_H #include <config.h> #endif #include "self_pass_generator.h" #include "dribble.h" #include "field_analyzer.h" #include <rcsc/action/kick_table.h> #include <rcsc/player/world_model.h> #include <rcsc/common/server_param.h> #include <rcsc/common/logger.h> #include <rcsc/timer.h> #include <limits> #include <cmath> #define DEBUG_PROFILE // #define DEBUG_PRINT // #define DEBUG_PRINT_SELF_CACHE // #define DEBUG_PRINT_OPPONENT // #define DEBUG_PRINT_OPPONENT_LEVEL2 // #define DEBUG_PRINT_SUCCESS_COURSE // #define DEBUG_PRINT_FAILED_COURSE using namespace rcsc; namespace { inline void debug_paint_failed( const int count, const Vector2D & receive_point ) { dlog.addRect( Logger::DRIBBLE, receive_point.x - 0.1, receive_point.y - 0.1, 0.2, 0.2, "#ff0000" ); char num[8]; snprintf( num, 8, "%d", count ); dlog.addMessage( Logger::DRIBBLE, receive_point, num ); } } /*-------------------------------------------------------------------*/ /*! */ SelfPassGenerator::SelfPassGenerator() { M_courses.reserve( 128 ); clear(); } /*-------------------------------------------------------------------*/ /*! */ SelfPassGenerator & SelfPassGenerator::instance() { static SelfPassGenerator s_instance; return s_instance; } /*-------------------------------------------------------------------*/ /*! */ void SelfPassGenerator::clear() { M_total_count = 0; M_courses.clear(); } /*-------------------------------------------------------------------*/ /*! */ void SelfPassGenerator::generate( const WorldModel & wm ) { if ( M_update_time == wm.time() ) { return; } M_update_time = wm.time(); clear(); if ( wm.gameMode().type() != GameMode::PlayOn && ! wm.gameMode().isPenaltyKickMode() ) { return; } if ( ! wm.self().isKickable() || wm.self().isFrozen() ) { return; } #ifdef DEBUG_PROFILE Timer timer; #endif createCourses( wm ); std::sort( M_courses.begin(), M_courses.end(), CooperativeAction::DistCompare( ServerParam::i().theirTeamGoalPos() ) ); #ifdef DEBUG_PROFILE dlog.addText( Logger::DRIBBLE, __FILE__": (generate) PROFILE size=%d/%d elapsed %.3f [ms]", (int)M_courses.size(), M_total_count, timer.elapsedReal() ); #endif } /*-------------------------------------------------------------------*/ /*! */ void SelfPassGenerator::createCourses( const WorldModel & wm ) { static const int ANGLE_DIVS = 60; static const double ANGLE_STEP = 360.0 / ANGLE_DIVS; static std::vector< Vector2D > self_cache( 24 ); const ServerParam & SP = ServerParam::i(); const Vector2D ball_pos = wm.ball().pos(); const AngleDeg body_angle = wm.self().body(); const int min_dash = 5; const int max_dash = ( ball_pos.x < -20.0 ? 6 : ball_pos.x < 0.0 ? 7 : ball_pos.x < 10.0 ? 13 : ball_pos.x < 20.0 ? 15 : 20 ); const PlayerType & ptype = wm.self().playerType(); const double max_effective_turn = ptype.effectiveTurn( SP.maxMoment(), wm.self().vel().r() * ptype.playerDecay() ); const Vector2D our_goal = ServerParam::i().ourTeamGoalPos(); const double goal_dist_thr2 = std::pow( 18.0, 2 ); // Magic Number for ( int a = 0; a < ANGLE_DIVS; ++a ) { const double add_angle = ANGLE_STEP * a; int n_turn = 0; if ( a != 0 ) { if ( AngleDeg( add_angle ).abs() > max_effective_turn ) { // cannot turn by 1 step #ifdef DEBUG_PRINT_FAILED_COURSE dlog.addText( Logger::DRIBBLE, "?: xxx SelfPass rel_angle=%.1f > maxTurn=%.1f cannot turn by 1 step.", add_angle, max_effective_turn ); #endif continue; } n_turn = 1; } const AngleDeg dash_angle = body_angle + add_angle; if ( ball_pos.x < SP.theirPenaltyAreaLineX() + 5.0 && dash_angle.abs() > 85.0 ) // Magic Number { #ifdef DEBUG_PRINT_FAILED_COURSE dlog.addText( Logger::DRIBBLE, "?: xxx SelfPass angle=%.1f over angle.", dash_angle.degree() ); #endif continue; } createSelfCache( wm, dash_angle, n_turn, max_dash, self_cache ); int n_dash = self_cache.size() - n_turn; if ( n_dash < min_dash ) { #ifdef DEBUG_PRINT_FAILED_COURSE dlog.addText( Logger::DRIBBLE, "?: xxx SelfPass angle=%.1f turn=%d dash=%d too short dash step.", dash_angle.degree(), n_turn, n_dash ); #endif continue; } #if (defined DEBUG_PRINT_SUCCESS_COURSE) || (defined DEBUG_PRINT_SUCCESS_COURSE) dlog.addText( Logger::DRIBBLE, "===== SelfPass angle=%.1f turn=%d dash=%d =====", dash_angle.degree(), n_turn, n_dash ); #endif int count = 0; int dash_dec = 2; for ( ; n_dash >= min_dash; n_dash -= dash_dec ) { ++M_total_count; if ( n_dash <= 10 ) { dash_dec = 1; } const Vector2D receive_pos = self_cache[n_turn + n_dash - 1]; if ( receive_pos.dist2( our_goal ) < goal_dist_thr2 ) { #ifdef DEBUG_PRINT_FAILED_COURSE dlog.addText( Logger::DRIBBLE, "%d: xxx SelfPass step=%d(t:%d,d:%d) pos=(%.1f %.1f) near our goal", M_total_count, 1 + n_turn, n_turn, n_dash, receive_pos.x, receive_pos.y ); #endif continue; } if ( ! canKick( wm, n_turn, n_dash, receive_pos ) ) { continue; } if ( ! checkOpponent( wm, n_turn, n_dash, ball_pos, receive_pos ) ) { continue; } // double first_speed = calc_first_term_geom_series( ball_pos.dist( receive_pos ), // ServerParam::i().ballDecay(), // 1 + n_turn + n_dash ); double first_speed = SP.firstBallSpeed( ball_pos.dist( receive_pos ), 1 + n_turn + n_dash ); CooperativeAction::Ptr ptr( new Dribble( wm.self().unum(), receive_pos, first_speed, 1, // 1 kick n_turn, n_dash, "SelfPass" ) ); ptr->setIndex( M_total_count ); M_courses.push_back( ptr ); #ifdef DEBUG_PRINT_SUCCESS_COURSE dlog.addText( Logger::DRIBBLE, "%d: ok SelfPass step=%d(t:%d,d:%d) pos=(%.1f %.1f) speed=%.3f", M_total_count, 1 + n_turn + n_dash, n_turn, n_dash, receive_pos.x, receive_pos.y, first_speed ); char num[8]; snprintf( num, 8, "%d", M_total_count ); dlog.addMessage( Logger::DRIBBLE, receive_pos, num ); dlog.addRect( Logger::DRIBBLE, receive_pos.x - 0.1, receive_pos.y - 0.1, 0.2, 0.2, "#00ff00" ); #endif ++count; if ( count >= 10 ) { break; } } } } /*-------------------------------------------------------------------*/ /*! */ void SelfPassGenerator::createSelfCache( const WorldModel & wm, const AngleDeg & dash_angle, const int n_turn, const int n_dash, std::vector< Vector2D > & self_cache ) { self_cache.clear(); const PlayerType & ptype = wm.self().playerType(); const double dash_power = ServerParam::i().maxDashPower(); const double stamina_thr = ( wm.self().staminaModel().capacityIsEmpty() ? -ptype.extraStamina() // minus value to set available stamina : ServerParam::i().recoverDecThrValue() + 350.0 ); StaminaModel stamina_model = wm.self().staminaModel(); Vector2D my_pos = wm.self().pos(); Vector2D my_vel = wm.self().vel(); // // 1 kick // my_pos += my_vel; my_vel *= ptype.playerDecay(); stamina_model.simulateWait( ptype ); // // turns // for ( int i = 0; i < n_turn; ++i ) { my_pos += my_vel; my_vel *= ptype.playerDecay(); stamina_model.simulateWait( ptype ); self_cache.push_back( my_pos ); } // // simulate dashes // for ( int i = 0; i < n_dash; ++i ) { if ( stamina_model.stamina() < stamina_thr ) { #ifdef DEBUG_PRINT_SELF_CACHE dlog.addText( Logger::DRIBBLE, "?: SelfPass (createSelfCache) turn=%d dash=%d. stamina=%.1f < threshold", n_turn, n_dash, stamina_model.stamina() ); #endif break; } double available_stamina = std::max( 0.0, stamina_model.stamina() - stamina_thr ); double actual_dash_power = std::min( dash_power, available_stamina ); double accel_mag = actual_dash_power * ptype.dashPowerRate() * stamina_model.effort(); Vector2D dash_accel = Vector2D::polar2vector( accel_mag, dash_angle ); // TODO: check playerSpeedMax & update actual_dash_power if necessary // if ( ptype.normalizeAccel( my_vel, &dash_accel ) ) actual_dash_power = ... my_vel += dash_accel; my_pos += my_vel; // #ifdef DEBUG_PRINT_SELF_CACHE // dlog.addText( Logger::DRIBBLE, // "___ dash=%d accel=(%.2f %.2f)r=%.2f th=%.1f pos=(%.2f %.2f) vel=(%.2f %.2f)", // i + 1, // dash_accel.x, dash_accel.y, dash_accel.r(), dash_accel.th().degree(), // my_pos.x, my_pos.y, // my_vel.x, my_vel.y ); // #endif if ( my_pos.x > ServerParam::i().pitchHalfLength() - 2.5 ) { #ifdef DEBUG_PRINT_SELF_CACHE dlog.addText( Logger::DRIBBLE, "?: SelfPass (createSelfCache) turn=%d dash=%d. my_x=%.2f. over goal line", n_turn, n_dash, my_pos.x ); #endif break; } if ( my_pos.absY() > ServerParam::i().pitchHalfWidth() - 3.0 && ( ( my_pos.y > 0.0 && dash_angle.degree() > 0.0 ) || ( my_pos.y < 0.0 && dash_angle.degree() < 0.0 ) ) ) { #ifdef DEBUG_PRINT_SELF_CACHE dlog.addText( Logger::DRIBBLE, "?: SelfPass (createSelfCache) turn=%d dash=%d." " my_pos=(%.2f %.2f). dash_angle=%.1f", n_turn, n_dash, my_pos.x, my_pos.y, dash_angle.degree() ); dlog.addText( Logger::DRIBBLE, "__ dash_accel=(%.2f %.2f)r=%.2f vel=(%.2f %.2f)r=%.2f th=%.1f", dash_accel.x, dash_accel.y, accel_mag, my_vel.x, my_vel.y, my_vel.r(), my_vel.th().degree() ); #endif break; } my_vel *= ptype.playerDecay(); stamina_model.simulateDash( ptype, actual_dash_power ); self_cache.push_back( my_pos ); } } /*-------------------------------------------------------------------*/ /*! */ bool SelfPassGenerator::canKick( const WorldModel & wm, const int n_turn, const int n_dash, const Vector2D & receive_pos ) { const ServerParam & SP = ServerParam::i(); const Vector2D ball_pos = wm.ball().pos(); const Vector2D ball_vel = wm.ball().vel(); const AngleDeg target_angle = ( receive_pos - ball_pos ).th(); // // check kick possibility // double first_speed = calc_first_term_geom_series( ball_pos.dist( receive_pos ), SP.ballDecay(), 1 + n_turn + n_dash ); Vector2D max_vel = KickTable::calc_max_velocity( target_angle, wm.self().kickRate(), ball_vel ); if ( max_vel.r2() < std::pow( first_speed, 2 ) ) { #ifdef DEBUG_PRINT_FAILED_COURSE dlog.addText( Logger::DRIBBLE, "%d: xxx SelfPass step=%d(t:%d,d=%d) cannot kick by 1 step." " first_speed=%.2f > max_speed=%.2f", M_total_count, 1 + n_turn + n_dash, n_turn, n_dash, first_speed, max_vel.r() ); debug_paint_failed( M_total_count, receive_pos ); #endif return false; } // // check collision // const Vector2D my_next = wm.self().pos() + wm.self().vel(); const Vector2D ball_next = ball_pos + ( receive_pos - ball_pos ).setLengthVector( first_speed ); if ( my_next.dist2( ball_next ) < std::pow( wm.self().playerType().playerSize() + SP.ballSize() + 0.1, 2 ) ) { #ifdef DEBUG_PRINT_FAILED_COURSE dlog.addText( Logger::DRIBBLE, "%d: xxx SelfPass step=%d(t:%d,d=%d) maybe collision. next_dist=%.3f first_speed=%.2f", M_total_count, 1 + n_turn + n_dash, n_turn, n_dash, my_next.dist( ball_next ), first_speed ); debug_paint_failed( M_total_count, receive_pos ); #endif return false; } // // check opponent kickable area // const PlayerPtrCont::const_iterator o_end = wm.opponentsFromSelf().end(); for ( PlayerPtrCont::const_iterator o = wm.opponentsFromSelf().begin(); o != o_end; ++o ) { const PlayerType * ptype = (*o)->playerTypePtr(); Vector2D o_next = (*o)->pos() + (*o)->vel(); const double control_area = ( ( (*o)->goalie() && ball_next.x > SP.theirPenaltyAreaLineX() && ball_next.absY() < SP.penaltyAreaHalfWidth() ) ? SP.catchableArea() : ptype->kickableArea() ); if ( ball_next.dist2( o_next ) < std::pow( control_area + 0.1, 2 ) ) { #ifdef DEBUG_PRINT_FAILED_COURSE dlog.addText( Logger::DRIBBLE, "%d: xxx SelfPass (canKick) opponent may be kickable(1) dist=%.3f < control=%.3f + 0.1", M_total_count, ball_next.dist( o_next ), control_area ); debug_paint_failed( M_total_count, receive_pos ); #endif return false; } if ( (*o)->bodyCount() <= 1 ) { o_next += Vector2D::from_polar( SP.maxDashPower() * ptype->dashPowerRate() * ptype->effortMax(), (*o)->body() ); } else { o_next += (*o)->vel().setLengthVector( SP.maxDashPower() * ptype->dashPowerRate() * ptype->effortMax() ); } if ( ball_next.dist2( o_next ) < std::pow( control_area, 2 ) ) { #ifdef DEBUG_PRINT_FAILED_COURSE dlog.addText( Logger::DRIBBLE, "%d xxx SelfPass (canKick) opponent may be kickable(2) dist=%.3f < control=%.3f", M_total_count, ball_next.dist( o_next ), control_area ); debug_paint_failed( M_total_count, receive_pos ); #endif return false; } } return true; } /*-------------------------------------------------------------------*/ /*! */ bool SelfPassGenerator::checkOpponent( const WorldModel & wm, const int n_turn, const int n_dash, const Vector2D & ball_pos, const Vector2D & receive_pos ) { const ServerParam & SP = ServerParam::i(); const int self_step = 1 + n_turn + n_dash; const AngleDeg target_angle = ( receive_pos - ball_pos ).th(); const bool in_penalty_area = ( receive_pos.x > SP.theirPenaltyAreaLineX() && receive_pos.absY() < SP.penaltyAreaHalfWidth() ); #ifdef DEBUG_PRINT_OPPONENT dlog.addText( Logger::DRIBBLE, "%d: (checkOpponent) selfStep=%d(t:%d,d:%d) recvPos(%.2f %.2f)", M_total_count, self_step, n_turn, n_dash, receive_pos.x, receive_pos.y ); #endif int min_step = 1000; const PlayerPtrCont::const_iterator o_end = wm.opponentsFromSelf().end(); for ( PlayerPtrCont::const_iterator o = wm.opponentsFromSelf().begin(); o != o_end; ++o ) { const Vector2D & opos = ( (*o)->seenPosCount() <= (*o)->posCount() ? (*o)->seenPos() : (*o)->pos() ); const Vector2D ball_to_opp_rel = ( opos - ball_pos ).rotatedVector( -target_angle ); if ( ball_to_opp_rel.x < -4.0 ) { #ifdef DEBUG_PRINT_OPPONENT_LEVEL2 dlog.addText( Logger::DRIBBLE, "__ opponent[%d](%.2f %.2f) relx=%.2f", (*o)->unum(), (*o)->pos().x, (*o)->pos().y, ball_to_opp_rel.x ); #endif continue; } const Vector2D & ovel = ( (*o)->seenVelCount() <= (*o)->velCount() ? (*o)->seenVel() : (*o)->vel() ); const PlayerType * ptype = (*o)->playerTypePtr(); const bool goalie = ( (*o)->goalie() && in_penalty_area ); const double control_area ( goalie ? SP.catchableArea() : ptype->kickableArea() ); Vector2D opp_pos = ptype->inertiaPoint( opos, ovel, self_step ); double target_dist = opp_pos.dist( receive_pos ); if ( target_dist > ptype->realSpeedMax() * ( self_step + (*o)->posCount() ) + control_area ) { #ifdef DEBUG_PRINT_OPPONENT_LEVEL2 dlog.addText( Logger::DRIBBLE, "__ opponent[%d](%.2f %.2f) too far. ignore. dist=%.1f", (*o)->unum(), (*o)->pos().x, (*o)->pos().y, target_dist ); #endif continue; } if ( target_dist - control_area < 0.001 ) { #ifdef DEBUG_PRINT_FAILED_COURSE dlog.addText( Logger::DRIBBLE, "%d: xxx SelfPass (checkOpponent) step=%d(t:%d,d=%d) pos=(%.1f %.1f)" " opponent %d(%.1f %.1f) is already at receive point", M_total_count, self_step, n_turn, n_dash, receive_pos.x, receive_pos.y, (*o)->unum(), (*o)->pos().x, (*o)->pos().y ); debug_paint_failed( M_total_count, receive_pos ); #endif return false; } double dash_dist = target_dist; dash_dist -= control_area; dash_dist -= 0.2; dash_dist -= (*o)->distFromSelf() * 0.01; int opp_n_dash = ptype->cyclesToReachDistance( dash_dist ); int opp_n_turn = ( (*o)->bodyCount() > 1 ? 0 : FieldAnalyzer::predict_player_turn_cycle( ptype, (*o)->body(), ovel.r(), target_dist, ( receive_pos - opp_pos ).th(), control_area, false ) ); int opp_n_step = ( opp_n_turn == 0 ? opp_n_turn + opp_n_dash : opp_n_turn + opp_n_dash + 1 ); int bonus_step = 0; if ( receive_pos.x < 27.0 ) { bonus_step += 1; } if ( (*o)->isTackling() ) { bonus_step = -5; } if ( ball_to_opp_rel.x > 0.8 ) { bonus_step += 1; bonus_step += bound( 0, (*o)->posCount() - 1, 8 ); #ifdef DEBUG_PRINT_OPPONENT_LEVEL2 dlog.addText( Logger::DRIBBLE, "__ opponent[%d](%.2f %.2f) forward bonus = %d", (*o)->unum(), (*o)->pos().x, (*o)->pos().y, bonus_step ); #endif } else { int penalty_step = ( ( receive_pos.x > wm.offsideLineX() || receive_pos.x > 35.0 ) ? 1 : 0 ); bonus_step = bound( 0, (*o)->posCount() - penalty_step, 3 ); #ifdef DEBUG_PRINT_OPPONENT_LEVEL2 dlog.addText( Logger::DRIBBLE, "__ opponent[%d](%.2f %.2f) backward bonus = %d", (*o)->unum(), (*o)->pos().x, (*o)->pos().y, bonus_step ); #endif } // if ( goalie ) // { // opp_n_step -= 1; // } #ifdef DEBUG_PRINT_OPPONENT dlog.addText( Logger::DRIBBLE, "__ opponent[%d](%.2f %.2f) oppStep=%d(t:%d,d:%d) selfStep=%d rel.x=%.2f", (*o)->unum(), (*o)->pos().x, (*o)->pos().y, opp_n_step, opp_n_turn, opp_n_dash, self_step, ball_to_opp_rel.x ); #endif if ( opp_n_step - bonus_step <= self_step ) { #ifdef DEBUG_PRINT_FAILED_COURSE dlog.addText( Logger::DRIBBLE, "%d: xxx SelfPass step=%d(t:%d,d:%d) pos=(%.1f %.1f)" " opponent %d(%.1f %.1f) can reach." " oppStep=%d(turn=%d,bonus=%d)", M_total_count, 1 + n_turn + n_dash, n_turn, n_dash, receive_pos.x, receive_pos.y, (*o)->unum(), (*o)->pos().x, (*o)->pos().y, opp_n_step, opp_n_turn, bonus_step ); debug_paint_failed( M_total_count, receive_pos ); #endif return false; } if ( min_step > opp_n_step ) { min_step = opp_n_step; } } #ifdef DEBUG_PRINT_OPPONENT dlog.addText( Logger::DRIBBLE, "%d: (checkOpponent) selfStep=%d(t:%d,d:%d) oppStep=%d", M_total_count, self_step, n_turn, n_dash, min_step ); #endif return true; }
32.692407
114
0.459846
sanmit
4e4c666994ce0cc1b2c2f139e3cd877a6d192ace
1,866
cpp
C++
src/api/api-example.cpp
knzm/kytea
e29eaf9933cc31f4461a8e726cff5141253a9727
[ "Apache-2.0" ]
1
2018-10-25T07:49:10.000Z
2018-10-25T07:49:10.000Z
src/api/api-example.cpp
knzm/kytea
e29eaf9933cc31f4461a8e726cff5141253a9727
[ "Apache-2.0" ]
null
null
null
src/api/api-example.cpp
knzm/kytea
e29eaf9933cc31f4461a8e726cff5141253a9727
[ "Apache-2.0" ]
null
null
null
#include <iostream> // a file including the main program #include "kytea/kytea.h" // a file including sentence, word, and pronunciation objects #include "kytea/kytea-struct.h" using namespace std; using namespace kytea; int main(int argc, char** argv) { // Create an instance of the Kytea program Kytea kytea; // Load a KyTea model from a model file // this can be a binary or text model in any character encoding, // it will be detected automatically kytea.readModel("../../data/model.bin"); // Get the string utility class. This allows you to convert from // the appropriate string encoding to Kytea's internal format StringUtil* util = kytea.getStringUtil(); // Get the configuration class, this allows you to read or set the // configuration for the analysis KyteaConfig* config = kytea.getConfig(); // Map a plain text string to a KyteaString, and create a sentence object KyteaSentence sentence(util->mapString("これはテストです。")); // Find the word boundaries kytea.calculateWS(sentence); // Find the pronunciations for each tag level for(int i = 0; i < config->getNumTags(); i++) kytea.calculateTags(sentence,i); // For each word in the sentence const KyteaSentence::Words & words = sentence.words; for(int i = 0; i < (int)words.size(); i++) { // Print the word cout << util->showString(words[i].surf); // For each tag level for(int j = 0; j < (int)words[i].tags.size(); j++) { cout << "\t"; // Print each of its tags for(int k = 0; k < (int)words[i].tags[j].size(); k++) { cout << " " << util->showString(words[i].tags[j][k].first) << "/" << words[i].tags[j][k].second; } } cout << endl; } cout << endl; }
32.736842
78
0.606109
knzm
4e4c9f05cf4e78576f2da1512a2776bd1efa93be
352
cpp
C++
test/util.cpp
andoma/saga
7231f63ff933ebfc517940ffa18f9a448f533f78
[ "BSD-2-Clause" ]
10
2019-12-22T22:33:28.000Z
2021-06-07T06:44:29.000Z
test/util.cpp
andoma/saga
7231f63ff933ebfc517940ffa18f9a448f533f78
[ "BSD-2-Clause" ]
null
null
null
test/util.cpp
andoma/saga
7231f63ff933ebfc517940ffa18f9a448f533f78
[ "BSD-2-Clause" ]
1
2020-06-20T09:14:27.000Z
2020-06-20T09:14:27.000Z
#include <stdio.h> #include "saga.h" using namespace saga; extern int util_showtensors(int argc, char **argv) { if(argc < 1) { fprintf(stderr, "usage: <path>\n"); return 1; } Network net(false); net.loadTensors(argv[0]); for(const auto &it : net.named_tensors_) { it.second->printStats(it.first.c_str()); } return 0; }
14.08
44
0.630682
andoma
4e4f9a759c10b34ce65f173c532c80201480a521
2,608
cc
C++
osi/src/allocator.cc
digi-embedded/android_platform_system_bt
635ddc5671274697ecfc9d4d44881f23d73a4cd0
[ "Apache-2.0" ]
null
null
null
osi/src/allocator.cc
digi-embedded/android_platform_system_bt
635ddc5671274697ecfc9d4d44881f23d73a4cd0
[ "Apache-2.0" ]
null
null
null
osi/src/allocator.cc
digi-embedded/android_platform_system_bt
635ddc5671274697ecfc9d4d44881f23d73a4cd0
[ "Apache-2.0" ]
2
2019-05-30T08:37:28.000Z
2019-10-01T16:39:33.000Z
/****************************************************************************** * * Copyright (C) 2014 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ******************************************************************************/ #include <base/logging.h> #include <stdlib.h> #include <string.h> #include "osi/include/allocation_tracker.h" #include "osi/include/allocator.h" static const allocator_id_t alloc_allocator_id = 42; char* osi_strdup(const char* str) { size_t size = strlen(str) + 1; // + 1 for the null terminator size_t real_size = allocation_tracker_resize_for_canary(size); void* ptr = malloc(real_size); CHECK(ptr); char* new_string = static_cast<char*>( allocation_tracker_notify_alloc(alloc_allocator_id, ptr, size)); if (!new_string) return NULL; memcpy(new_string, str, size); return new_string; } char* osi_strndup(const char* str, size_t len) { size_t size = strlen(str); if (len < size) size = len; size_t real_size = allocation_tracker_resize_for_canary(size + 1); void* ptr = malloc(real_size); CHECK(ptr); char* new_string = static_cast<char*>( allocation_tracker_notify_alloc(alloc_allocator_id, ptr, size + 1)); if (!new_string) return NULL; memcpy(new_string, str, size); new_string[size] = '\0'; return new_string; } void* osi_malloc(size_t size) { size_t real_size = allocation_tracker_resize_for_canary(size); void* ptr = malloc(real_size); CHECK(ptr); return allocation_tracker_notify_alloc(alloc_allocator_id, ptr, size); } void* osi_calloc(size_t size) { size_t real_size = allocation_tracker_resize_for_canary(size); void* ptr = calloc(1, real_size); CHECK(ptr); return allocation_tracker_notify_alloc(alloc_allocator_id, ptr, size); } void osi_free(void* ptr) { free(allocation_tracker_notify_free(alloc_allocator_id, ptr)); } void osi_free_and_reset(void** p_ptr) { CHECK(p_ptr != NULL); osi_free(*p_ptr); *p_ptr = NULL; } const allocator_t allocator_calloc = {osi_calloc, osi_free}; const allocator_t allocator_malloc = {osi_malloc, osi_free};
30.682353
80
0.688267
digi-embedded
4e50ac7c19f0325873f510813997b65236d60845
2,357
cpp
C++
external/iotivity/iotivity_1.2-rel/resource/src/OCDirectPairing.cpp
SenthilKumarGS/TizenRT
691639aa9667de5d966f040f0291a402727ab6ae
[ "Apache-2.0" ]
511
2017-03-29T09:14:09.000Z
2022-03-30T23:10:29.000Z
external/iotivity/iotivity_1.2-rel/resource/src/OCDirectPairing.cpp
SenthilKumarGS/TizenRT
691639aa9667de5d966f040f0291a402727ab6ae
[ "Apache-2.0" ]
4,673
2017-03-29T10:43:43.000Z
2022-03-31T08:33:44.000Z
external/iotivity/iotivity_1.2-rel/resource/src/OCDirectPairing.cpp
SenthilKumarGS/TizenRT
691639aa9667de5d966f040f0291a402727ab6ae
[ "Apache-2.0" ]
642
2017-03-30T20:45:33.000Z
2022-03-24T17:07:33.000Z
//****************************************************************** // // Copyright 2016 Samsung Electronics All Rights Reserved. // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #include "OCDirectPairing.h" #include <iomanip> namespace OC { static const char COAP[] = "coap://"; static const char COAPS[] = "coaps://"; static const int UUID_LENGTH = (128/8); //UUID length OCDirectPairing::OCDirectPairing(OCDPDev_t *ptr):m_devPtr(ptr) { } std::string OCDirectPairing::getHost() { bool ipv6 = false; std::ostringstream host(""); if (m_devPtr->connType & CT_IP_USE_V6) { ipv6 = true; } host << COAPS << (ipv6?"[":"") << m_devPtr->endpoint.addr; host << (ipv6?"]:":":") << m_devPtr->securePort; return host.str(); } std::string OCDirectPairing::getDeviceID() { std::ostringstream deviceId(""); for (int i = 0; i < UUID_LENGTH; i++) { if (i == 4 || i == 6 || i == 8 || i == 10) { deviceId << '-'; } deviceId << std::hex << std::setfill('0') << std::setw(2) << static_cast<unsigned>(m_devPtr->deviceID.id[i]); } return deviceId.str(); } std::vector<OCPrm_t> OCDirectPairing::getPairingMethods() { std::vector<OCPrm_t> prms; for (size_t i = 0; i < m_devPtr->prmLen; i++) { prms.push_back(m_devPtr->prm[i]); } return prms; } OCConnectivityType OCDirectPairing::getConnType() { return m_devPtr->connType; } OCDPDev_t* OCDirectPairing::getDev() { return m_devPtr; } }
27.406977
121
0.531608
SenthilKumarGS
4e511c4600bd4c7898179125bc3dbab28b1bea99
7,048
cpp
C++
third_party/omr/compiler/arm/codegen/StackCheckFailureSnippet.cpp
xiacijie/omr-wala-linkage
a1aff7aef9ed131a45555451abde4615a04412c1
[ "Apache-2.0" ]
null
null
null
third_party/omr/compiler/arm/codegen/StackCheckFailureSnippet.cpp
xiacijie/omr-wala-linkage
a1aff7aef9ed131a45555451abde4615a04412c1
[ "Apache-2.0" ]
null
null
null
third_party/omr/compiler/arm/codegen/StackCheckFailureSnippet.cpp
xiacijie/omr-wala-linkage
a1aff7aef9ed131a45555451abde4615a04412c1
[ "Apache-2.0" ]
null
null
null
/******************************************************************************* * Copyright (c) 2000, 2019 IBM Corp. and others * * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this * distribution and is available at http://eclipse.org/legal/epl-2.0 * or the Apache License, Version 2.0 which accompanies this distribution * and is available at https://www.apache.org/licenses/LICENSE-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the * Eclipse Public License, v. 2.0 are satisfied: GNU General Public License, * version 2 with the GNU Classpath Exception [1] and GNU General Public * License, version 2 with the OpenJDK Assembly Exception [2]. * * [1] https://www.gnu.org/software/classpath/license.html * [2] http://openjdk.java.net/legal/assembly-exception.html * * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception *******************************************************************************/ #include "il/Symbol.hpp" #include "il/symbol/LabelSymbol.hpp" #include "il/symbol/MethodSymbol.hpp" #include "il/symbol/ResolvedMethodSymbol.hpp" #include "il/symbol/RegisterMappedSymbol.hpp" #include "il/symbol/StaticSymbol.hpp" #include "codegen/CodeGenerator.hpp" #include "codegen/Linkage.hpp" #include "codegen/Linkage_inlines.hpp" #include "codegen/StackCheckFailureSnippet.hpp" #include "codegen/SnippetGCMap.hpp" #include "codegen/GCStackAtlas.hpp" /* @@ */ uint8_t *storeArgumentItem(TR_ARMOpCodes op, uint8_t *buffer, TR::RealRegister *reg, int32_t offset, TR::CodeGenerator *cg) { TR::RealRegister *stackPtr = cg->machine()->getRealRegister(cg->getLinkage()->getProperties().getStackPointerRegister()); TR_ARMOpCode opCode(op); opCode.copyBinaryToBuffer(buffer); reg->setRegisterFieldRD(toARMCursor(buffer)); stackPtr->setRegisterFieldRN(toARMCursor(buffer)); *toARMCursor(buffer) |= offset & 0x00000fff; // assume offset is +ve *toARMCursor(buffer) |= 1 << 24; // set P bit to be offset addressing *toARMCursor(buffer) |= 1 << 23; // set U bit for +ve *toARMCursor(buffer) |= ARMConditionCodeAL << 28; // set condition return(buffer+4); } uint8_t *loadArgumentItem(TR_ARMOpCodes op, uint8_t *buffer, TR::RealRegister *reg, int32_t offset, TR::CodeGenerator *cg) { TR_ASSERT(0, "fix loadArgumentItem"); TR::RealRegister *stackPtr = cg->machine()->getRealRegister(cg->getLinkage()->getProperties().getStackPointerRegister()); TR_ARMOpCode opCode(op); opCode.copyBinaryToBuffer(buffer); reg->setRegisterFieldRT(toARMCursor(buffer)); stackPtr->setRegisterFieldRD(toARMCursor(buffer)); *toARMCursor(buffer) |= offset & 0x0000ffff; return(buffer+4); } uint8_t *TR::ARMStackCheckFailureSnippet::emitSnippetBody() { uint8_t *buffer = cg()->getBinaryBufferCursor(); #ifdef J9_PROJECT_SPECIFIC TR::ResolvedMethodSymbol *bodySymbol = cg()->comp()->getJittedMethodSymbol(); TR::Machine *machine = cg()->machine(); TR::SymbolReference *sofRef = cg()->comp()->getSymRefTab()->findOrCreateStackOverflowSymbolRef(bodySymbol); uint8_t *bufferStart = buffer; uint8_t *returnLocation; bool saveLR = (cg()->getSnippetList().size() <= 1 && !bodySymbol->isEHAware() && !machine->getLinkRegisterKilled()) ? true : false; getSnippetLabel()->setCodeLocation(buffer); // Pass cg()->getFrameSizeInBytes() to jitStackOverflow in a scratch // register (R11). // // If (frameSize - offset) cannot be represented in a rotated 8-bit number, // then the prologue must have already loaded it into R11; otherwise, // the snippet needs to load the number into R11. // const TR::ARMLinkageProperties &linkage = cg()->getLinkage()->getProperties(); uint32_t frameSize = cg()->getFrameSizeInBytes(); int32_t offset = linkage.getOffsetToFirstLocal(); uint32_t base, rotate; if (constantIsImmed8r(frameSize, &base, &rotate)) { // mov R11, frameSize *(int32_t *)buffer = 0xe3a0b << 12 | (rotate ? 16 - (rotate >> 1) : 0) << 8 | base & 0xFF; buffer+=4; } else if (!constantIsImmed8r(frameSize-offset, &base, &rotate) && constantIsImmed8r(-offset, &base, &rotate)) { // sub R11, R11, -offset *(int32_t *)buffer = 0xe24bb << 12 | ((rotate ? 16 - (rotate >> 1) : 0) << 8) | base & 0xFF; buffer+=4; } else { // R11 <- cg()->getFrameSizeInBytes() by mov, add, add // There is no need in another add, since a stack frame will never be that big. *(int32_t *)buffer = 0xe3a0b << 12 | frameSize & 0xFF; buffer+=4; *(int32_t *)buffer = 0xe28bb << 12 | 12 << 8 | (frameSize >> 8 & 0xFF); buffer+=4; *(int32_t *)buffer = 0xe28bb << 12 | 8 << 8 | (frameSize >> 16 & 0xFF); buffer+=4; } // add R7, R7, R11 *(int32_t *)buffer = 0xe087700b; buffer+=4; if (saveLR) { // str [R7, 0], R14 *(int32_t *)buffer = 0xe587e000; buffer += 4; } *(int32_t *)buffer = encodeHelperBranchAndLink(sofRef, buffer, getNode(), cg()); buffer += 4; returnLocation = buffer; if (saveLR) { // ldr R14, [R7, 0] *(int32_t *)buffer = 0xe597e000; buffer += 4; } // sub R7, R7, R11 ; assume that jitStackOverflow does not clobber R11 *(int32_t *)buffer = 0xe047700b; buffer+=4; // b restartLabel ; assuming it is less than 26 bits away. *(int32_t *)buffer = 0xEA000000 | encodeBranchDistance((uintptr_t) buffer, (uintptr_t) getReStartLabel()->getCodeLocation()); TR::GCStackAtlas *atlas = cg()->getStackAtlas(); if (atlas) { // only the arg references are live at this point TR_GCStackMap *map = atlas->getParameterMap(); // set the GC map gcMap().setStackMap(map); } gcMap().registerStackMap(returnLocation, cg()); #endif return buffer + 4; } uint32_t TR::ARMStackCheckFailureSnippet::getLength(int32_t estimatedSnippetStart) { TR::ResolvedMethodSymbol *bodySymbol=cg()->comp()->getJittedMethodSymbol(); int32_t length = 20; // mov/sub, add, bl, sub, b uint32_t base, rotate; uint32_t frameSize = cg()->getFrameSizeInBytes(); // const TR::ARMLinkageProperties &linkage = cg()->getLinkage()->getProperties(); // uint32_t offset = linkage.getOffsetToFirstLocal(); if (!constantIsImmed8r(frameSize, &base, &rotate)) /* && (constantIsImmed8r(frameSize-offset, &base, &rotate) || !constantIsImmed8r(-offset, &base, &rotate)))*/ { length += 8; // add, add } if (cg()->getSnippetList().size() <=1 && !bodySymbol->isEHAware() && !cg()->machine()->getLinkRegisterKilled()) { length += 8; // str, ldr } return length; }
38.513661
135
0.645857
xiacijie
4e54adde281a096d1950fd62bbc8c1b4f49accf0
6,893
cpp
C++
Day 22 Part 2/main.cpp
Miroslav-Cetojevic/aoc-2015
2807fcd3fc684843ae4222b25af6fd086fac77f5
[ "Unlicense" ]
1
2019-11-19T20:19:18.000Z
2019-11-19T20:19:18.000Z
Day 22 Part 2/main.cpp
Miroslav-Cetojevic/aoc-2015
2807fcd3fc684843ae4222b25af6fd086fac77f5
[ "Unlicense" ]
null
null
null
Day 22 Part 2/main.cpp
Miroslav-Cetojevic/aoc-2015
2807fcd3fc684843ae4222b25af6fd086fac77f5
[ "Unlicense" ]
null
null
null
#include <algorithm> #include <iostream> #include <vector> // ======== // Entities // ======== struct Hero { std::int64_t health; std::uint64_t mana; std::uint64_t armor; }; struct Boss { std::int64_t health; std::uint64_t damage; }; // ================ // Spells & Effects // ================ // need to forward declare these structs // so I can use them for the function pointer struct GameState; struct Page; using DoMagic = void (*) (GameState&, Page&); struct Effect { DoMagic apply; std::int64_t value; std::uint64_t turns_max; std::uint64_t turns_left; }; struct Spell { DoMagic cast; std::uint64_t cost; std::uint64_t value; }; struct Page { Effect effect; Spell spell; std::uint64_t id; }; using Spellbook = std::vector<Page>; struct GameState { Hero hero; Boss boss; Spellbook spellbook; std::uint64_t current_page; std::uint64_t mana_spent; }; auto subtract_mana(GameState& state, const Page& page) { state.hero.mana -= page.spell.cost; } auto subtract_boss_health(GameState& state, const Page& page) { state.boss.health -= page.spell.value; } auto calc_mana_spent(GameState& state, const Page& page) { state.mana_spent += page.spell.cost; } auto init_effect(GameState& state, Page& page) { subtract_mana(state, page); page.effect.turns_left = page.effect.turns_max; } auto apply_immediate_effects(GameState& state, const Page& page) { subtract_mana(state, page); subtract_boss_health(state, page); calc_mana_spent(state, page); } auto cast_missile(GameState& state, Page& page) { apply_immediate_effects(state, page); } auto cast_drain(GameState& state, Page& page) { apply_immediate_effects(state, page); state.hero.health += page.spell.value; } auto activate_effect(GameState& state, Page& page) { init_effect(state, page); calc_mana_spent(state, page); } auto cast_poison(GameState& state, Page& page) { activate_effect(state, page); } auto cast_recharge(GameState& state, Page& page) { activate_effect(state, page); } auto cast_shield(GameState& state, Page& page) { activate_effect(state, page); state.hero.armor = page.spell.value; } auto apply_missile(GameState&, Page&) {} auto apply_drain(GameState&, Page&) {} template<typename F> auto apply_effect(GameState& state, Page& page, F effect) { if(page.effect.turns_left > 0) { --(page.effect.turns_left); effect(state, page); } } auto apply_poison(GameState& state, Page& page) { apply_effect(state, page, [] (auto& state, auto& page) { state.boss.health -= page.effect.value; }); } auto apply_recharge(GameState& state, Page& page) { apply_effect(state, page, [] (auto& state, auto& page) { state.hero.mana += page.effect.value; }); } auto apply_shield(GameState& state, Page& page) { apply_effect(state, page, [] (auto& state, auto& page) { if(page.effect.turns_left == 0) { state.hero.armor = 0; } }); } auto boss_attack(GameState& state) { const auto boss_dmg = state.boss.damage; const auto hero_ac = state.hero.armor; const auto boss_real_dmg = (hero_ac < boss_dmg) ? (boss_dmg - hero_ac) : 1; state.hero.health -= boss_real_dmg; } // ======== // The Game // ======== int main() { const auto spellbook = Spellbook{ {{apply_missile, 0, 0, 0}, {cast_missile, 53, 4}, 0}, {{apply_drain, 0, 0, 0}, {cast_drain, 73, 2}, 1}, {{apply_shield, 0, 6, 0}, {cast_shield, 113, 7}, 2}, {{apply_poison, 3, 6, 0}, {cast_poison, 173, 0}, 3}, {{apply_recharge, 101, 5, 0}, {cast_recharge, 229, 0}, 4} }; auto hero = Hero{50, 500, 0}; auto boss = Boss{55, 8}; auto states = std::vector<GameState>{{hero, boss, spellbook, 0, 0}}; auto least_mana = std::numeric_limits<decltype(hero.mana)>::max(); const auto save_state = [&states] (auto& state) { // each new state means re-reading the spellbook from the beginning state.current_page = 0; states.push_back(state); }; const auto delete_state = [&states] () { states.pop_back(); }; const auto apply_effects = [] (auto& state) { for(auto& page : state.spellbook) { page.effect.apply(state, page); } }; const auto has_won = [] (const auto& state) { return (state.boss.health <= 0); }; const auto has_lost = [] (const auto& state) { return (state.hero.health <= 0); }; const auto end_of_spellbook = [] (const auto& state) { return (state.current_page == state.spellbook.size()); }; const auto get_least_mana = [least_mana, &delete_state] (const auto& state) { // a victory has been attained, the last state is not needed anymore delete_state(); // the state argument will be a reference to the copy of the state // that we just deleted, so it's safe to refer to it return std::min(least_mana, state.mana_spent); }; // each iteration (and thus each state) represents two turns played do { auto state = GameState(states.back()); // =========== // hero's turn // =========== --(state.hero.health); if(has_lost(state)) { delete_state(); continue; } apply_effects(state); if(has_won(state)) { least_mana = get_least_mana(state); continue; } // there's no spell to be cast, so we discard the current state if(end_of_spellbook(state)) { delete_state(); continue; } const auto begin = state.spellbook.begin() + state.current_page; const auto end = state.spellbook.end(); const auto check = [&state, least_mana] (auto& page) { const auto mana_spent = state.mana_spent; const auto spell_cost = page.spell.cost; const auto turns_left = page.effect.turns_left; const auto hero_mana = state.hero.mana; const auto reduces_mana_cost = (least_mana > 0) && ((mana_spent + spell_cost) >= least_mana); const auto is_spell_castable = (turns_left == 0) && (hero_mana >= spell_cost); return !reduces_mana_cost && is_spell_castable; }; const auto eligible_spell = std::find_if(begin, end, check); const auto has_castable_spell = (eligible_spell != state.spellbook.end()); if(has_castable_spell) { // the hero attacks eligible_spell->spell.cast(state, *eligible_spell); // if we return to this state later on, the hero may only cast the next spell, // because casting any of the previous ones will simply result in an already visited scenario ++(states.back().current_page); } // no spells were cast either because // 1. there was not enough mana for any of them, or // 2. there's already a victory scenario with equal or less total mana spent if(!has_castable_spell) { delete_state(); continue; } if(has_won(state)) { least_mana = get_least_mana(state); continue; } // ========== // boss' turn // ========== apply_effects(state); if(has_won(state)) { least_mana = get_least_mana(state); continue; } boss_attack(state); if(has_lost(state)) { delete_state(); continue; } save_state(state); } while(!states.empty()); std::cout << least_mana << std::endl; return 0; }
23.130872
96
0.673582
Miroslav-Cetojevic
4e5682a1650bc6673e1e26c04f80e9b921f3ca6a
15,398
cpp
C++
NOLF/Shared/SharedMission.cpp
rastrup/no-one-lives-forever
dfbe22fb4cc01bf7e5f54a79174fa8f108dd2f54
[ "Unlicense" ]
65
2015-02-28T03:35:14.000Z
2021-09-23T05:43:33.000Z
NOLF/Shared/SharedMission.cpp
rastrup/no-one-lives-forever
dfbe22fb4cc01bf7e5f54a79174fa8f108dd2f54
[ "Unlicense" ]
null
null
null
NOLF/Shared/SharedMission.cpp
rastrup/no-one-lives-forever
dfbe22fb4cc01bf7e5f54a79174fa8f108dd2f54
[ "Unlicense" ]
27
2015-02-28T07:42:01.000Z
2022-02-11T01:35:20.000Z
// ----------------------------------------------------------------------- // // // MODULE : SharedMission.cpp // // PURPOSE : SharedMission implementation - shared mission summary stuff // // CREATED : 9/16/99 // // (c) 1999 Monolith Productions, Inc. All Rights Reserved // // ----------------------------------------------------------------------- // #include "stdafx.h" #include "SharedMission.h" #define PLAYERRANK_TAG "RankData" #define PLAYERRANK_HEALTH "Health" #define PLAYERRANK_ARMOR "Armor" #define PLAYERRANK_AMMO "Ammo" #define PLAYERRANK_DAM "Damage" #define PLAYERRANK_PERTURB "Perturb" #define PLAYERRANK_STEALTH "Stealth" #define PLAYERRANK_REP "Reputation" #define MISSIONSUMMARY_TOTALLEVELINTEL "TotalLevelIntel" #define MISSIONSUMMARY_MAXNUMLEVELINTEL "MaxNumLevelIntel" static char s_aAttName[100]; // ----------------------------------------------------------------------- // // // ROUTINE: PLAYERRANK::PLAYERRANK // // PURPOSE: Constructor // // ----------------------------------------------------------------------- // PLAYERRANK::PLAYERRANK() { Reset(); } // ----------------------------------------------------------------------- // // // ROUTINE: PLAYERRANK::Reset // // PURPOSE: Reset all the data // // ----------------------------------------------------------------------- // void PLAYERRANK::Reset() { fHealthMultiplier = 1.0f; fArmorMultiplier = 1.0f; fAmmoMultiplier = 1.0f; fDamageMultiplier = 1.0f; fPerturbMultiplier = 1.0f; fStealthMultiplier = 1.0f; nReputation = 0; } // ----------------------------------------------------------------------- // // // ROUTINE: PLAYERRANK::Write // // PURPOSE: Write the data to be sent to the client // // ----------------------------------------------------------------------- // void PLAYERRANK::Write(ILTCSBase *pInterface, HMESSAGEWRITE hWrite) { if (!hWrite) return; pInterface->WriteToMessageFloat(hWrite, fHealthMultiplier); pInterface->WriteToMessageFloat(hWrite, fArmorMultiplier); pInterface->WriteToMessageFloat(hWrite, fAmmoMultiplier); pInterface->WriteToMessageFloat(hWrite, fDamageMultiplier); pInterface->WriteToMessageFloat(hWrite, fPerturbMultiplier); pInterface->WriteToMessageFloat(hWrite, fStealthMultiplier); pInterface->WriteToMessageByte(hWrite, nReputation); } // ----------------------------------------------------------------------- // // // ROUTINE: PLAYERRANK::ReadClientData // // PURPOSE: Read the data sent to the client // // ----------------------------------------------------------------------- // void PLAYERRANK::Read(ILTCSBase *pInterface, HMESSAGEREAD hRead) { if (!hRead) return; fHealthMultiplier = pInterface->ReadFromMessageFloat(hRead); fArmorMultiplier = pInterface->ReadFromMessageFloat(hRead); fAmmoMultiplier = pInterface->ReadFromMessageFloat(hRead); fDamageMultiplier = pInterface->ReadFromMessageFloat(hRead); fPerturbMultiplier = pInterface->ReadFromMessageFloat(hRead); fStealthMultiplier = pInterface->ReadFromMessageFloat(hRead); nReputation = pInterface->ReadFromMessageByte(hRead); } // ----------------------------------------------------------------------- // // // ROUTINE: PLAYERRANK::WriteRankData // // PURPOSE: Write the data to the butefile // // ----------------------------------------------------------------------- // void PLAYERRANK::WriteRankData(CButeMgr & buteMgr) { // Write the global data for each level... buteMgr.SetFloat(PLAYERRANK_TAG, PLAYERRANK_HEALTH, fHealthMultiplier); buteMgr.SetFloat(PLAYERRANK_TAG, PLAYERRANK_ARMOR, fArmorMultiplier); buteMgr.SetFloat(PLAYERRANK_TAG, PLAYERRANK_AMMO, fAmmoMultiplier); buteMgr.SetFloat(PLAYERRANK_TAG, PLAYERRANK_DAM, fDamageMultiplier); buteMgr.SetFloat(PLAYERRANK_TAG, PLAYERRANK_PERTURB, fPerturbMultiplier); buteMgr.SetFloat(PLAYERRANK_TAG, PLAYERRANK_STEALTH, fStealthMultiplier); buteMgr.SetInt( PLAYERRANK_TAG, PLAYERRANK_REP, nReputation); } // ----------------------------------------------------------------------- // // // ROUTINE: PLAYERRANK::ClearRankData // // PURPOSE: Reset the data in the butefile // // ----------------------------------------------------------------------- // void PLAYERRANK::ClearRankData(CButeMgr & buteMgr) { Reset(); WriteRankData(buteMgr); } // ----------------------------------------------------------------------- // // // ROUTINE: PLAYERRANK::ReadRankData // // PURPOSE: Read the data from the butefile // // ----------------------------------------------------------------------- // void PLAYERRANK::ReadRankData(CButeMgr & buteMgr) { // Write the global data for each level... fHealthMultiplier = buteMgr.GetFloat(PLAYERRANK_TAG, PLAYERRANK_HEALTH, 1.0f); fArmorMultiplier = buteMgr.GetFloat(PLAYERRANK_TAG, PLAYERRANK_ARMOR, 1.0f); fAmmoMultiplier = buteMgr.GetFloat(PLAYERRANK_TAG, PLAYERRANK_AMMO, 1.0f); fDamageMultiplier = buteMgr.GetFloat(PLAYERRANK_TAG, PLAYERRANK_DAM, 1.0f); fPerturbMultiplier = buteMgr.GetFloat(PLAYERRANK_TAG, PLAYERRANK_PERTURB, 1.0f); fStealthMultiplier = buteMgr.GetFloat(PLAYERRANK_TAG, PLAYERRANK_STEALTH, 1.0f); nReputation = buteMgr.GetByte(PLAYERRANK_TAG, PLAYERRANK_REP, 0); } // ----------------------------------------------------------------------- // // // ROUTINE: LEVELSUMMARY::LEVELSUMMARY // // PURPOSE: Constructor // // ----------------------------------------------------------------------- // LEVELSUMMARY::LEVELSUMMARY() { // Global data... nTotalIntel = -1; nMaxNumIntel = 0; // Instant data... nCurNumIntel = 0; } // ----------------------------------------------------------------------- // // // ROUTINE: MISSIONSUMMARY::MISSIONSUMMARY // // PURPOSE: Constructor // // ----------------------------------------------------------------------- // MISSIONSUMMARY::MISSIONSUMMARY() { nId = -1; nNumLevels = 0; fBestRank = 0.0f; fOldBestRank = 0.0f; fCurRank = 0.0f; fTotalMissionTime = 0.0f; dwNumShotsFired = 0; dwNumHits = 0; dwNumTimesDetected = 0; dwNumDisturbances = 0; dwNumBodies = 0; dwNumEnemyKills = 0; dwNumFriendKills = 0; dwNumNeutralKills = 0; dwNumTimesHit = 0; m_nMissionTotalIntel = 0; m_nMissionMaxIntel = 0; m_nMissionCurNumIntel = 0; for (int i = 0; i < HL_NUM_LOCS; i++) dwHitLocations[i] = 0; } // ----------------------------------------------------------------------- // // // ROUTINE: MISSIONSUMMARY::Init // // PURPOSE: Build the mission summary struct // // ----------------------------------------------------------------------- // LTBOOL MISSIONSUMMARY::Init(CButeMgr & buteMgr, char* aTagName, MISSION* pMission) { if (!aTagName || !pMission) return LTFALSE; // Read in the data for each level... nNumLevels = pMission->nNumLevels; for (int i=0; i < nNumLevels; i++) { sprintf(s_aAttName, "%s%d", MISSIONSUMMARY_TOTALLEVELINTEL, i); if (buteMgr.Exist(aTagName, s_aAttName)) { Levels[i].nTotalIntel = buteMgr.GetInt(aTagName, s_aAttName); } else { buteMgr.SetInt(aTagName, s_aAttName, Levels[i].nTotalIntel); } sprintf(s_aAttName, "%s%d", MISSIONSUMMARY_MAXNUMLEVELINTEL, i); if (buteMgr.Exist(aTagName, s_aAttName)) { Levels[i].nMaxNumIntel = buteMgr.GetInt(aTagName, s_aAttName); } else { buteMgr.SetInt(aTagName, s_aAttName, Levels[i].nMaxNumIntel); } } return LTTRUE; } // ----------------------------------------------------------------------- // // // ROUTINE: MISSIONSUMMARY::WriteClientData // // PURPOSE: Write the data to be sent to the client // // ----------------------------------------------------------------------- // void MISSIONSUMMARY::WriteClientData(ILTCSBase *pInterface, HMESSAGEWRITE hWrite) { if (!hWrite) return; int nTotalIntel=0, nMaxIntel=0, nCurIntel=0; int i; for (i=0; i < nNumLevels; i++) { nTotalIntel += (Levels[i].nTotalIntel > 0 ? Levels[i].nTotalIntel : 0); nMaxIntel += (Levels[i].nMaxNumIntel > 0 ? Levels[i].nMaxNumIntel : 0); nCurIntel += (Levels[i].nCurNumIntel > 0 ? Levels[i].nCurNumIntel : 0); } LTFLOAT fTime = fTotalMissionTime > 0 ? fTotalMissionTime : pInterface->GetTime(); pInterface->WriteToMessageByte(hWrite, nTotalIntel); pInterface->WriteToMessageByte(hWrite, nMaxIntel); pInterface->WriteToMessageByte(hWrite, nCurIntel); pInterface->WriteToMessageFloat(hWrite, fBestRank); pInterface->WriteToMessageFloat(hWrite, fOldBestRank); pInterface->WriteToMessageFloat(hWrite, fCurRank); pInterface->WriteToMessageFloat(hWrite, fTime); pInterface->WriteToMessageDWord(hWrite, dwNumShotsFired); pInterface->WriteToMessageDWord(hWrite, dwNumHits); pInterface->WriteToMessageDWord(hWrite, dwNumTimesDetected); pInterface->WriteToMessageDWord(hWrite, dwNumDisturbances); pInterface->WriteToMessageDWord(hWrite, dwNumBodies); pInterface->WriteToMessageDWord(hWrite, dwNumEnemyKills); pInterface->WriteToMessageDWord(hWrite, dwNumFriendKills); pInterface->WriteToMessageDWord(hWrite, dwNumNeutralKills); pInterface->WriteToMessageDWord(hWrite, dwNumTimesHit); for (i = 0; i < HL_NUM_LOCS; i++) pInterface->WriteToMessageDWord(hWrite,dwHitLocations[i]); } // ----------------------------------------------------------------------- // // // ROUTINE: MISSIONSUMMARY::ReadClientData // // PURPOSE: Read the data sent to the client // // ----------------------------------------------------------------------- // void MISSIONSUMMARY::ReadClientData(ILTCSBase *pInterface, HMESSAGEREAD hRead) { if (!hRead) return; uint8 nTotalIntel, nMaxIntel, nCurIntel; nTotalIntel = pInterface->ReadFromMessageByte(hRead); nMaxIntel = pInterface->ReadFromMessageByte(hRead); nCurIntel = pInterface->ReadFromMessageByte(hRead); fBestRank = pInterface->ReadFromMessageFloat(hRead); fOldBestRank = pInterface->ReadFromMessageFloat(hRead); fCurRank = pInterface->ReadFromMessageFloat(hRead); fTotalMissionTime = pInterface->ReadFromMessageFloat(hRead); dwNumShotsFired = pInterface->ReadFromMessageDWord(hRead); dwNumHits = pInterface->ReadFromMessageDWord(hRead); dwNumTimesDetected = pInterface->ReadFromMessageDWord(hRead); dwNumDisturbances = pInterface->ReadFromMessageDWord(hRead); dwNumBodies = pInterface->ReadFromMessageDWord(hRead); dwNumEnemyKills = pInterface->ReadFromMessageDWord(hRead); dwNumFriendKills = pInterface->ReadFromMessageDWord(hRead); dwNumNeutralKills = pInterface->ReadFromMessageDWord(hRead); dwNumTimesHit = pInterface->ReadFromMessageDWord(hRead); for (int i = 0; i < HL_NUM_LOCS; i++) dwHitLocations[i] = pInterface->ReadFromMessageDWord(hRead); // Just store the intel totals in level 0... m_nMissionTotalIntel = nTotalIntel; m_nMissionMaxIntel = nMaxIntel; m_nMissionCurNumIntel = nCurIntel; } // ----------------------------------------------------------------------- // // // ROUTINE: MISSIONSUMMARY::WriteGlobalData // // PURPOSE: Write the global data to the bute mgr // // ----------------------------------------------------------------------- // void MISSIONSUMMARY::WriteGlobalData(CButeMgr & buteMgr, char* aTagName) { if (!aTagName || !aTagName[0]) return; // Write the global data for each level... for (int i=0; i < nNumLevels; i++) { sprintf(s_aAttName, "%s%d", MISSIONSUMMARY_TOTALLEVELINTEL, i); buteMgr.SetInt(aTagName, s_aAttName, Levels[i].nTotalIntel); sprintf(s_aAttName, "%s%d", MISSIONSUMMARY_MAXNUMLEVELINTEL, i); buteMgr.SetInt(aTagName, s_aAttName, Levels[i].nMaxNumIntel); } } // ----------------------------------------------------------------------- // // // ROUTINE: MISSIONSUMMARY::ClearGlobalData // // PURPOSE: Clear the global data in the bute mgr // // ----------------------------------------------------------------------- // void MISSIONSUMMARY::ClearGlobalData(CButeMgr & buteMgr, char* aTagName) { if (!aTagName || !aTagName[0]) return; // Write the global data for each level... for (int i=0; i < nNumLevels; i++) { Levels[i].nMaxNumIntel = 0; sprintf(s_aAttName, "%s%d", MISSIONSUMMARY_MAXNUMLEVELINTEL, i); buteMgr.SetInt(aTagName, s_aAttName, Levels[i].nMaxNumIntel); } } // ----------------------------------------------------------------------- // // // ROUTINE: MISSIONSUMMARY::WriteIntantData // // PURPOSE: Write the instant data // // ----------------------------------------------------------------------- // void MISSIONSUMMARY::WriteInstantData(ILTCSBase *pInterface, HMESSAGEWRITE hWrite) { if (!hWrite) return; // Write the instant summary data... pInterface->WriteToMessageFloat(hWrite, fTotalMissionTime); pInterface->WriteToMessageDWord(hWrite, dwNumShotsFired); pInterface->WriteToMessageDWord(hWrite, dwNumHits); pInterface->WriteToMessageDWord(hWrite, dwNumTimesDetected); pInterface->WriteToMessageDWord(hWrite, dwNumDisturbances); pInterface->WriteToMessageDWord(hWrite, dwNumBodies); pInterface->WriteToMessageDWord(hWrite, dwNumEnemyKills); pInterface->WriteToMessageDWord(hWrite, dwNumFriendKills); pInterface->WriteToMessageDWord(hWrite, dwNumNeutralKills); pInterface->WriteToMessageDWord(hWrite, dwNumTimesHit); int i; for (i = 0; i < HL_NUM_LOCS; i++) pInterface->WriteToMessageDWord(hWrite,dwHitLocations[i]); pInterface->WriteToMessageByte(hWrite, nNumLevels); for (i=0; i < nNumLevels; i++) { pInterface->WriteToMessageByte(hWrite, Levels[i].nCurNumIntel); } } // ----------------------------------------------------------------------- // // // ROUTINE: MISSIONSUMMARY::ReadIntantData // // PURPOSE: Read the instant data // // ----------------------------------------------------------------------- // void MISSIONSUMMARY::ReadInstantData(ILTCSBase *pInterface, HMESSAGEREAD hRead) { if (!hRead) return; // Read the instant summary data... fTotalMissionTime = pInterface->ReadFromMessageFloat(hRead); dwNumShotsFired = pInterface->ReadFromMessageDWord(hRead); dwNumHits = pInterface->ReadFromMessageDWord(hRead); dwNumTimesDetected = pInterface->ReadFromMessageDWord(hRead); dwNumDisturbances = pInterface->ReadFromMessageDWord(hRead); dwNumBodies = pInterface->ReadFromMessageDWord(hRead); dwNumEnemyKills = pInterface->ReadFromMessageDWord(hRead); dwNumFriendKills = pInterface->ReadFromMessageDWord(hRead); dwNumNeutralKills = pInterface->ReadFromMessageDWord(hRead); dwNumTimesHit = pInterface->ReadFromMessageDWord(hRead); int i; for (i = 0; i < HL_NUM_LOCS; i++) dwHitLocations[i] = pInterface->ReadFromMessageDWord(hRead); nNumLevels = pInterface->ReadFromMessageByte(hRead); for (i=0; i < nNumLevels; i++) { Levels[i].nCurNumIntel = pInterface->ReadFromMessageByte(hRead); } }
33.257019
87
0.584167
rastrup
4e5cb6c13d0ce471472e6712fb9bc163b8cb8cfb
20,676
cpp
C++
libraries/ine-vm/tests/spec/call_indirect_tests.cpp
inery-blockchain/inery
2823539f76a0debae22b6783781b1374c63a59d8
[ "MIT" ]
null
null
null
libraries/ine-vm/tests/spec/call_indirect_tests.cpp
inery-blockchain/inery
2823539f76a0debae22b6783781b1374c63a59d8
[ "MIT" ]
null
null
null
libraries/ine-vm/tests/spec/call_indirect_tests.cpp
inery-blockchain/inery
2823539f76a0debae22b6783781b1374c63a59d8
[ "MIT" ]
null
null
null
#include <algorithm> #include <vector> #include <iostream> #include <iterator> #include <cmath> #include <cstdlib> #include <catch2/catch.hpp> #include <utils.hpp> #include <wasm_config.hpp> #include <inery/vm/backend.hpp> using namespace inery; using namespace inery::vm; extern wasm_allocator wa; BACKEND_TEST_CASE( "Testing wasm <call_indirect_0_wasm>", "[call_indirect_0_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.0.wasm"); backend_t bkend( code ); bkend.set_wasm_allocator( &wa ); bkend.initialize(nullptr); CHECK(bkend.call_with_return(nullptr, "env", "type-i32")->to_ui32() == UINT32_C(306)); CHECK(bkend.call_with_return(nullptr, "env", "type-i64")->to_ui64() == UINT32_C(356)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "type-f32")->to_f32()) == UINT32_C(1165172736)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "type-f64")->to_f64()) == UINT64_C(4660882566700597248)); CHECK(bkend.call_with_return(nullptr, "env", "type-index")->to_ui64() == UINT32_C(100)); CHECK(bkend.call_with_return(nullptr, "env", "type-first-i32")->to_ui32() == UINT32_C(32)); CHECK(bkend.call_with_return(nullptr, "env", "type-first-i64")->to_ui64() == UINT32_C(64)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "type-first-f32")->to_f32()) == UINT32_C(1068037571)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "type-first-f64")->to_f64()) == UINT64_C(4610064722561534525)); CHECK(bkend.call_with_return(nullptr, "env", "type-second-i32")->to_ui32() == UINT32_C(32)); CHECK(bkend.call_with_return(nullptr, "env", "type-second-i64")->to_ui64() == UINT32_C(64)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "type-second-f32")->to_f32()) == UINT32_C(1107296256)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "type-second-f64")->to_f64()) == UINT64_C(4634211053438658150)); CHECK(bkend.call_with_return(nullptr, "env", "dispatch", UINT32_C(5), UINT64_C(2))->to_ui64() == UINT32_C(2)); CHECK(bkend.call_with_return(nullptr, "env", "dispatch", UINT32_C(5), UINT64_C(5))->to_ui64() == UINT32_C(5)); CHECK(bkend.call_with_return(nullptr, "env", "dispatch", UINT32_C(12), UINT64_C(5))->to_ui64() == UINT32_C(120)); CHECK(bkend.call_with_return(nullptr, "env", "dispatch", UINT32_C(13), UINT64_C(5))->to_ui64() == UINT32_C(8)); CHECK(bkend.call_with_return(nullptr, "env", "dispatch", UINT32_C(20), UINT64_C(2))->to_ui64() == UINT32_C(2)); CHECK_THROWS_AS(bkend(nullptr, "env", "dispatch", UINT32_C(0), UINT64_C(2)), std::exception); CHECK_THROWS_AS(bkend(nullptr, "env", "dispatch", UINT32_C(15), UINT64_C(2)), std::exception); CHECK_THROWS_AS(bkend(nullptr, "env", "dispatch", UINT32_C(29), UINT64_C(2)), std::exception); CHECK_THROWS_AS(bkend(nullptr, "env", "dispatch", UINT32_C(4294967295), UINT64_C(2)), std::exception); CHECK_THROWS_AS(bkend(nullptr, "env", "dispatch", UINT32_C(1213432423), UINT64_C(2)), std::exception); CHECK(bkend.call_with_return(nullptr, "env", "dispatch-structural-i64", UINT32_C(5))->to_ui64() == UINT32_C(9)); CHECK(bkend.call_with_return(nullptr, "env", "dispatch-structural-i64", UINT32_C(12))->to_ui64() == UINT32_C(362880)); CHECK(bkend.call_with_return(nullptr, "env", "dispatch-structural-i64", UINT32_C(13))->to_ui64() == UINT32_C(55)); CHECK(bkend.call_with_return(nullptr, "env", "dispatch-structural-i64", UINT32_C(20))->to_ui64() == UINT32_C(9)); CHECK_THROWS_AS(bkend(nullptr, "env", "dispatch-structural-i64", UINT32_C(11)), std::exception); CHECK_THROWS_AS(bkend(nullptr, "env", "dispatch-structural-i64", UINT32_C(22)), std::exception); CHECK(bkend.call_with_return(nullptr, "env", "dispatch-structural-i32", UINT32_C(4))->to_ui32() == UINT32_C(9)); CHECK(bkend.call_with_return(nullptr, "env", "dispatch-structural-i32", UINT32_C(23))->to_ui32() == UINT32_C(362880)); CHECK(bkend.call_with_return(nullptr, "env", "dispatch-structural-i32", UINT32_C(26))->to_ui32() == UINT32_C(55)); CHECK(bkend.call_with_return(nullptr, "env", "dispatch-structural-i32", UINT32_C(19))->to_ui32() == UINT32_C(9)); CHECK_THROWS_AS(bkend(nullptr, "env", "dispatch-structural-i32", UINT32_C(9)), std::exception); CHECK_THROWS_AS(bkend(nullptr, "env", "dispatch-structural-i32", UINT32_C(21)), std::exception); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "dispatch-structural-f32", UINT32_C(6))->to_f32()) == UINT32_C(1091567616)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "dispatch-structural-f32", UINT32_C(24))->to_f32()) == UINT32_C(1219571712)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "dispatch-structural-f32", UINT32_C(27))->to_f32()) == UINT32_C(1113325568)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "dispatch-structural-f32", UINT32_C(21))->to_f32()) == UINT32_C(1091567616)); CHECK_THROWS_AS(bkend(nullptr, "env", "dispatch-structural-f32", UINT32_C(8)), std::exception); CHECK_THROWS_AS(bkend(nullptr, "env", "dispatch-structural-f32", UINT32_C(19)), std::exception); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "dispatch-structural-f64", UINT32_C(7))->to_f64()) == UINT64_C(4621256167635550208)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "dispatch-structural-f64", UINT32_C(25))->to_f64()) == UINT64_C(4689977843394805760)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "dispatch-structural-f64", UINT32_C(28))->to_f64()) == UINT64_C(4632937379169042432)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "dispatch-structural-f64", UINT32_C(22))->to_f64()) == UINT64_C(4621256167635550208)); CHECK_THROWS_AS(bkend(nullptr, "env", "dispatch-structural-f64", UINT32_C(10)), std::exception); CHECK_THROWS_AS(bkend(nullptr, "env", "dispatch-structural-f64", UINT32_C(18)), std::exception); CHECK(bkend.call_with_return(nullptr, "env", "fac-i64", UINT64_C(0))->to_ui64() == UINT32_C(1)); CHECK(bkend.call_with_return(nullptr, "env", "fac-i64", UINT64_C(1))->to_ui64() == UINT32_C(1)); CHECK(bkend.call_with_return(nullptr, "env", "fac-i64", UINT64_C(5))->to_ui64() == UINT32_C(120)); CHECK(bkend.call_with_return(nullptr, "env", "fac-i64", UINT64_C(25))->to_ui64() == UINT32_C(7034535277573963776)); CHECK(bkend.call_with_return(nullptr, "env", "fac-i32", UINT32_C(0))->to_ui32() == UINT32_C(1)); CHECK(bkend.call_with_return(nullptr, "env", "fac-i32", UINT32_C(1))->to_ui32() == UINT32_C(1)); CHECK(bkend.call_with_return(nullptr, "env", "fac-i32", UINT32_C(5))->to_ui32() == UINT32_C(120)); CHECK(bkend.call_with_return(nullptr, "env", "fac-i32", UINT32_C(10))->to_ui32() == UINT32_C(3628800)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "fac-f32", bit_cast<float>(UINT32_C(0)))->to_f32()) == UINT32_C(1065353216)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "fac-f32", bit_cast<float>(UINT32_C(1065353216)))->to_f32()) == UINT32_C(1065353216)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "fac-f32", bit_cast<float>(UINT32_C(1084227584)))->to_f32()) == UINT32_C(1123024896)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "fac-f32", bit_cast<float>(UINT32_C(1092616192)))->to_f32()) == UINT32_C(1247640576)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "fac-f64", bit_cast<double>(UINT64_C(0)))->to_f64()) == UINT64_C(4607182418800017408)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "fac-f64", bit_cast<double>(UINT64_C(4607182418800017408)))->to_f64()) == UINT64_C(4607182418800017408)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "fac-f64", bit_cast<double>(UINT64_C(4617315517961601024)))->to_f64()) == UINT64_C(4638144666238189568)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "fac-f64", bit_cast<double>(UINT64_C(4621819117588971520)))->to_f64()) == UINT64_C(4705047200009289728)); CHECK(bkend.call_with_return(nullptr, "env", "fib-i64", UINT64_C(0))->to_ui64() == UINT32_C(1)); CHECK(bkend.call_with_return(nullptr, "env", "fib-i64", UINT64_C(1))->to_ui64() == UINT32_C(1)); CHECK(bkend.call_with_return(nullptr, "env", "fib-i64", UINT64_C(2))->to_ui64() == UINT32_C(2)); CHECK(bkend.call_with_return(nullptr, "env", "fib-i64", UINT64_C(5))->to_ui64() == UINT32_C(8)); CHECK(bkend.call_with_return(nullptr, "env", "fib-i64", UINT64_C(20))->to_ui64() == UINT32_C(10946)); CHECK(bkend.call_with_return(nullptr, "env", "fib-i32", UINT32_C(0))->to_ui32() == UINT32_C(1)); CHECK(bkend.call_with_return(nullptr, "env", "fib-i32", UINT32_C(1))->to_ui32() == UINT32_C(1)); CHECK(bkend.call_with_return(nullptr, "env", "fib-i32", UINT32_C(2))->to_ui32() == UINT32_C(2)); CHECK(bkend.call_with_return(nullptr, "env", "fib-i32", UINT32_C(5))->to_ui32() == UINT32_C(8)); CHECK(bkend.call_with_return(nullptr, "env", "fib-i32", UINT32_C(20))->to_ui32() == UINT32_C(10946)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "fib-f32", bit_cast<float>(UINT32_C(0)))->to_f32()) == UINT32_C(1065353216)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "fib-f32", bit_cast<float>(UINT32_C(1065353216)))->to_f32()) == UINT32_C(1065353216)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "fib-f32", bit_cast<float>(UINT32_C(1073741824)))->to_f32()) == UINT32_C(1073741824)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "fib-f32", bit_cast<float>(UINT32_C(1084227584)))->to_f32()) == UINT32_C(1090519040)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "fib-f32", bit_cast<float>(UINT32_C(1101004800)))->to_f32()) == UINT32_C(1177225216)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "fib-f64", bit_cast<double>(UINT64_C(0)))->to_f64()) == UINT64_C(4607182418800017408)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "fib-f64", bit_cast<double>(UINT64_C(4607182418800017408)))->to_f64()) == UINT64_C(4607182418800017408)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "fib-f64", bit_cast<double>(UINT64_C(4611686018427387904)))->to_f64()) == UINT64_C(4611686018427387904)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "fib-f64", bit_cast<double>(UINT64_C(4617315517961601024)))->to_f64()) == UINT64_C(4620693217682128896)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "fib-f64", bit_cast<double>(UINT64_C(4626322717216342016)))->to_f64()) == UINT64_C(4667243241467281408)); CHECK(bkend.call_with_return(nullptr, "env", "even", UINT32_C(0))->to_ui32() == UINT32_C(44)); CHECK(bkend.call_with_return(nullptr, "env", "even", UINT32_C(1))->to_ui32() == UINT32_C(99)); CHECK(bkend.call_with_return(nullptr, "env", "even", UINT32_C(100))->to_ui32() == UINT32_C(44)); CHECK(bkend.call_with_return(nullptr, "env", "even", UINT32_C(77))->to_ui32() == UINT32_C(99)); CHECK(bkend.call_with_return(nullptr, "env", "odd", UINT32_C(0))->to_ui32() == UINT32_C(99)); CHECK(bkend.call_with_return(nullptr, "env", "odd", UINT32_C(1))->to_ui32() == UINT32_C(44)); CHECK(bkend.call_with_return(nullptr, "env", "odd", UINT32_C(200))->to_ui32() == UINT32_C(99)); CHECK(bkend.call_with_return(nullptr, "env", "odd", UINT32_C(77))->to_ui32() == UINT32_C(44)); CHECK(bkend.call_with_return(nullptr, "env", "as-select-first")->to_ui32() == UINT32_C(306)); CHECK(bkend.call_with_return(nullptr, "env", "as-select-mid")->to_ui32() == UINT32_C(2)); CHECK(bkend.call_with_return(nullptr, "env", "as-select-last")->to_ui32() == UINT32_C(2)); CHECK(bkend.call_with_return(nullptr, "env", "as-if-condition")->to_ui32() == UINT32_C(1)); CHECK(bkend.call_with_return(nullptr, "env", "as-br_if-first")->to_ui64() == UINT32_C(356)); CHECK(bkend.call_with_return(nullptr, "env", "as-br_if-last")->to_ui32() == UINT32_C(2)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "as-br_table-first")->to_f32()) == UINT32_C(1165172736)); CHECK(bkend.call_with_return(nullptr, "env", "as-br_table-last")->to_ui32() == UINT32_C(2)); CHECK(!bkend.call_with_return(nullptr, "env", "as-store-first")); CHECK(!bkend.call_with_return(nullptr, "env", "as-store-last")); CHECK(bkend.call_with_return(nullptr, "env", "as-memory.grow-value")->to_ui32() == UINT32_C(1)); CHECK(bkend.call_with_return(nullptr, "env", "as-return-value")->to_ui32() == UINT32_C(1)); CHECK(!bkend.call_with_return(nullptr, "env", "as-drop-operand")); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "as-br-value")->to_f32()) == UINT32_C(1065353216)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "as-local.set-value")->to_f64()) == UINT64_C(4607182418800017408)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "as-local.tee-value")->to_f64()) == UINT64_C(4607182418800017408)); CHECK(bit_cast<uint64_t>(bkend.call_with_return(nullptr, "env", "as-global.set-value")->to_f64()) == UINT64_C(4607182418800017408)); CHECK(bkend.call_with_return(nullptr, "env", "as-load-operand")->to_ui32() == UINT32_C(1)); CHECK(bit_cast<uint32_t>(bkend.call_with_return(nullptr, "env", "as-unary-operand")->to_f32()) == UINT32_C(0)); CHECK(bkend.call_with_return(nullptr, "env", "as-binary-left")->to_ui32() == UINT32_C(11)); CHECK(bkend.call_with_return(nullptr, "env", "as-binary-right")->to_ui32() == UINT32_C(9)); CHECK(bkend.call_with_return(nullptr, "env", "as-test-operand")->to_ui32() == UINT32_C(0)); CHECK(bkend.call_with_return(nullptr, "env", "as-compare-left")->to_ui32() == UINT32_C(1)); CHECK(bkend.call_with_return(nullptr, "env", "as-compare-right")->to_ui32() == UINT32_C(1)); CHECK(bkend.call_with_return(nullptr, "env", "as-convert-operand")->to_ui64() == UINT32_C(1)); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_12_wasm>", "[call_indirect_12_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.12.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_13_wasm>", "[call_indirect_13_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.13.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_14_wasm>", "[call_indirect_14_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.14.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_15_wasm>", "[call_indirect_15_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.15.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_16_wasm>", "[call_indirect_16_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.16.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_17_wasm>", "[call_indirect_17_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.17.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_18_wasm>", "[call_indirect_18_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.18.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_19_wasm>", "[call_indirect_19_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.19.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_20_wasm>", "[call_indirect_20_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.20.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_21_wasm>", "[call_indirect_21_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.21.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_22_wasm>", "[call_indirect_22_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.22.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_23_wasm>", "[call_indirect_23_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.23.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_24_wasm>", "[call_indirect_24_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.24.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_25_wasm>", "[call_indirect_25_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.25.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_26_wasm>", "[call_indirect_26_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.26.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_27_wasm>", "[call_indirect_27_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.27.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_28_wasm>", "[call_indirect_28_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.28.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_29_wasm>", "[call_indirect_29_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.29.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_30_wasm>", "[call_indirect_30_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.30.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_31_wasm>", "[call_indirect_31_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.31.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_32_wasm>", "[call_indirect_32_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.32.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); } BACKEND_TEST_CASE( "Testing wasm <call_indirect_33_wasm>", "[call_indirect_33_wasm_tests]" ) { using backend_t = backend<std::nullptr_t, TestType>; auto code = backend_t::read_wasm( std::string(wasm_directory) + "call_indirect.33.wasm"); CHECK_THROWS_AS(backend_t(code), std::exception); }
75.736264
172
0.725285
inery-blockchain
4e5ce4235b7297fb7247875394ab7857c7d331eb
13,717
cpp
C++
src/drivers/goindol.cpp
gameblabla/mame_nspire
83dfe1606aba906bd28608f2cb8f0754492ac3da
[ "Unlicense" ]
33
2015-08-10T11:13:47.000Z
2021-08-30T10:00:46.000Z
src/drivers/goindol.cpp
gameblabla/mame_nspire
83dfe1606aba906bd28608f2cb8f0754492ac3da
[ "Unlicense" ]
13
2015-08-25T03:53:08.000Z
2022-03-30T18:02:35.000Z
src/drivers/goindol.cpp
gameblabla/mame_nspire
83dfe1606aba906bd28608f2cb8f0754492ac3da
[ "Unlicense" ]
40
2015-08-25T05:09:21.000Z
2022-02-08T05:02:30.000Z
#include "../vidhrdw/goindol.cpp" /*************************************************************************** GOINDOL Driver provided by Jarek Parchanski (jpdev@friko6.onet.pl) ***************************************************************************/ #include "driver.h" int goindol_vh_start(void); void goindol_vh_stop(void); WRITE_HANDLER( goindol_fg_videoram_w ); WRITE_HANDLER( goindol_bg_videoram_w ); void goindol_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh); void goindol_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom); extern unsigned char *goindol_fg_scrollx; extern unsigned char *goindol_fg_scrolly; extern unsigned char *goindol_fg_videoram; extern unsigned char *goindol_bg_videoram; extern unsigned char *goindol_spriteram1; extern unsigned char *goindol_spriteram2; extern size_t goindol_spriteram_size; extern size_t goindol_fg_videoram_size; extern size_t goindol_bg_videoram_size; extern int goindol_char_bank; WRITE_HANDLER( goindol_bankswitch_w ) { int bankaddress; unsigned char *RAM = memory_region(REGION_CPU1); bankaddress = 0x10000 + ((data & 3) * 0x4000); cpu_setbank(1,&RAM[bankaddress]); goindol_char_bank = data & 0x10; } static struct MemoryReadAddress readmem[] = { { 0x0000, 0x7fff, MRA_ROM }, { 0x8000, 0xbfff, MRA_BANK1 }, { 0xc000, 0xc7ff, MRA_RAM }, { 0xc800, 0xc800, MRA_NOP }, { 0xd000, 0xefff, MRA_RAM }, { 0xf000, 0xf000, input_port_3_r }, { 0xf800, 0xf800, input_port_4_r }, { 0xc834, 0xc834, input_port_1_r }, { 0xc820, 0xc820, input_port_2_r }, { 0xc830, 0xc830, input_port_0_r }, { 0xe000, 0xefff, MRA_RAM }, { -1 } /* end of table */ }; static struct MemoryWriteAddress writemem[] = { { 0x0000, 0xbfff, MWA_ROM }, { 0xc000, 0xc7ff, MWA_RAM }, { 0xc810, 0xc810, goindol_bankswitch_w }, { 0xc820, 0xd820, MWA_RAM, &goindol_fg_scrollx }, { 0xc830, 0xd830, MWA_RAM, &goindol_fg_scrolly }, { 0xc800, 0xc800, soundlatch_w }, { 0xd000, 0xd03f, MWA_RAM, &goindol_spriteram1, &goindol_spriteram_size }, { 0xd040, 0xd7ff, MWA_RAM }, { 0xd800, 0xdfff, goindol_bg_videoram_w, &goindol_bg_videoram, &goindol_bg_videoram_size }, { 0xe000, 0xe03f, MWA_RAM, &goindol_spriteram2 }, { 0xe040, 0xe7ff, MWA_RAM }, { 0xe800, 0xefff, goindol_fg_videoram_w, &goindol_fg_videoram, &goindol_fg_videoram_size }, { -1 } /* end of table */ }; static struct MemoryReadAddress sound_readmem[] = { { 0x0000, 0x7fff, MRA_ROM }, { 0xc000, 0xc7ff, MRA_RAM }, { 0xd800, 0xd800, soundlatch_r }, { -1 } /* end of table */ }; static struct MemoryWriteAddress sound_writemem[] = { { 0x0000, 0x7fff, MWA_ROM }, { 0xc000, 0xc7ff, MWA_RAM }, { 0xa000, 0xa000, YM2203_control_port_0_w }, { 0xa001, 0xa001, YM2203_write_port_0_w }, { -1 } /* end of table */ }; INPUT_PORTS_START( goindol ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT_IMPULSE( 0x80, IP_ACTIVE_LOW, IPT_COIN1, 1 ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT_IMPULSE( 0x80, IP_ACTIVE_LOW, IPT_COIN2, 1 ) PORT_START /* IN2 - spinner */ PORT_ANALOG( 0xff, 0x00, IPT_DIAL , 40, 10, 0, 0) PORT_START /* DSW0 */ PORT_DIPNAME( 0x03, 0x02, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x03, "2" ) PORT_DIPSETTING( 0x02, "3" ) PORT_DIPSETTING( 0x01, "4" ) PORT_DIPSETTING( 0x00, "5" ) PORT_DIPNAME( 0x1c, 0x0c, DEF_STR( Difficulty ) ) PORT_DIPSETTING( 0x1c, "Easiest" ) PORT_DIPSETTING( 0x18, "Very Very Easy" ) PORT_DIPSETTING( 0x14, "Very Easy" ) PORT_DIPSETTING( 0x10, "Easy" ) PORT_DIPSETTING( 0x0c, "Normal" ) PORT_DIPSETTING( 0x08, "Difficult" ) PORT_DIPSETTING( 0x04, "Hard" ) PORT_DIPSETTING( 0x00, "Very Hard" ) PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On )) PORT_BITX( 0x40, 0x40, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", IP_KEY_NONE, IP_JOY_NONE ) PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) PORT_SERVICE( 0x80, IP_ACTIVE_LOW ) PORT_START /* DSW1 */ PORT_DIPNAME( 0x07, 0x07, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x04, "30k and every 50k" ) PORT_DIPSETTING( 0x05, "50k and every 100k" ) PORT_DIPSETTING( 0x06, "50k and every 200k" ) PORT_DIPSETTING( 0x07, "100k and every 200k" ) PORT_DIPSETTING( 0x01, "10000 only" ) PORT_DIPSETTING( 0x02, "30000 only" ) PORT_DIPSETTING( 0x03, "50000 only" ) PORT_DIPSETTING( 0x00, "None" ) PORT_DIPNAME( 0x38, 0x00, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x28, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x20, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x10, DEF_STR( 1C_3C ) ) PORT_DIPSETTING( 0x18, DEF_STR( 1C_4C ) ) PORT_DIPSETTING( 0x30, DEF_STR( 1C_5C ) ) PORT_DIPSETTING( 0x38, DEF_STR( 1C_6C ) ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x40, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) INPUT_PORTS_END INPUT_PORTS_START( homo ) PORT_START /* IN0 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT_IMPULSE( 0x80, IP_ACTIVE_LOW, IPT_COIN1, 1 ) PORT_START /* IN1 */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL ) PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL ) PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT_IMPULSE( 0x80, IP_ACTIVE_LOW, IPT_COIN2, 1 ) PORT_START /* IN2 - spinner */ PORT_ANALOG( 0xff, 0x00, IPT_DIAL , 40, 10, 0, 0) PORT_START /* DSW0 */ PORT_DIPNAME( 0x03, 0x02, DEF_STR( Lives ) ) PORT_DIPSETTING( 0x03, "2" ) PORT_DIPSETTING( 0x02, "3" ) PORT_DIPSETTING( 0x01, "4" ) PORT_DIPSETTING( 0x00, "5" ) PORT_DIPNAME( 0x1c, 0x0c, DEF_STR( Difficulty ) ) PORT_DIPSETTING( 0x1c, "Easiest" ) PORT_DIPSETTING( 0x18, "Very Very Easy" ) PORT_DIPSETTING( 0x14, "Very Easy" ) PORT_DIPSETTING( 0x10, "Easy" ) PORT_DIPSETTING( 0x0c, "Normal" ) PORT_DIPSETTING( 0x08, "Difficult" ) PORT_DIPSETTING( 0x04, "Hard" ) PORT_DIPSETTING( 0x00, "Very Hard" ) PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On )) PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On )) PORT_SERVICE( 0x80, IP_ACTIVE_LOW ) PORT_START /* DSW1 */ PORT_DIPNAME( 0x07, 0x07, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x04, "30k and every 50k" ) PORT_DIPSETTING( 0x05, "50k and every 100k" ) PORT_DIPSETTING( 0x06, "50k and every 200k" ) PORT_DIPSETTING( 0x07, "100k and every 200k" ) PORT_DIPSETTING( 0x01, "10000 only" ) PORT_DIPSETTING( 0x02, "30000 only" ) PORT_DIPSETTING( 0x03, "50000 only" ) PORT_DIPSETTING( 0x00, "None" ) PORT_DIPNAME( 0x38, 0x00, DEF_STR( Coinage ) ) PORT_DIPSETTING( 0x28, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x20, DEF_STR( 2C_1C ) ) PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) PORT_DIPSETTING( 0x08, DEF_STR( 1C_2C ) ) PORT_DIPSETTING( 0x10, DEF_STR( 1C_3C ) ) PORT_DIPSETTING( 0x18, DEF_STR( 1C_4C ) ) PORT_DIPSETTING( 0x30, DEF_STR( 1C_5C ) ) PORT_DIPSETTING( 0x38, DEF_STR( 1C_6C ) ) PORT_DIPNAME( 0x40, 0x40, DEF_STR( Cabinet ) ) PORT_DIPSETTING( 0x40, DEF_STR( Upright ) ) PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) INPUT_PORTS_END static struct GfxLayout charlayout = { 8,8, /* 8*8 characters */ 4096, /* 1024 characters */ 3, /* 2 bits per pixel */ { 0, 0x8000*8, 0x10000*8 }, { 0, 1, 2, 3, 4, 5, 6, 7 }, { 0, 8, 16, 24, 32, 40, 48, 56 }, 8*8 /* every char takes 8 consecutive bytes */ }; static struct GfxDecodeInfo gfxdecodeinfo[] = { { REGION_GFX1, 0, &charlayout, 0, 32 }, { REGION_GFX2, 0, &charlayout, 0, 32 }, { -1 } /* end of array */ }; static struct YM2203interface ym2203_interface = { 1, /* 1 chip */ 2000000, /* 2 MHz (?) */ { YM2203_VOL(25,25) }, { 0 }, { 0 }, { 0 }, { 0 } }; static struct MachineDriver machine_driver_goindol = { /* basic machine hardware */ { { CPU_Z80, 6000000, /* 6 Mhz (?) */ readmem,writemem,0,0, interrupt,1 }, { CPU_Z80 | CPU_AUDIO_CPU, 4000000, /* 4 Mhz (?) */ sound_readmem,sound_writemem,0,0, interrupt,4 } }, 60, DEFAULT_60HZ_VBLANK_DURATION, /* frames per second, vblank duration */ 1, 0, /* video hardware */ 32*8, 32*8, { 0*8, 32*8-1, 2*8, 30*8-1 }, gfxdecodeinfo, 256,32*8+32*8, goindol_vh_convert_color_prom, VIDEO_TYPE_RASTER, 0, goindol_vh_start, goindol_vh_stop, goindol_vh_screenrefresh, /* sound hardware */ 0,0,0,0, { { SOUND_YM2203, &ym2203_interface } } }; /*************************************************************************** Game driver(s) ***************************************************************************/ ROM_START( goindol ) ROM_REGION( 0x20000, REGION_CPU1 ) /* 2*64k for code */ ROM_LOAD( "r1", 0x00000, 0x8000, 0x3111c61b ) /* Code 0000-7fff */ ROM_LOAD( "r2", 0x10000, 0x8000, 0x1ff6e3a2 ) /* Paged data */ ROM_LOAD( "r3", 0x18000, 0x8000, 0xe9eec24a ) /* Paged data */ ROM_REGION( 0x10000, REGION_CPU2 ) /* 64k for the audio CPU */ ROM_LOAD( "r10", 0x00000, 0x8000, 0x72e1add1 ) ROM_REGION( 0x18000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "r4", 0x00000, 0x8000, 0x1ab84225 ) /* Characters */ ROM_LOAD( "r5", 0x08000, 0x8000, 0x4997d469 ) ROM_LOAD( "r6", 0x10000, 0x8000, 0x752904b0 ) ROM_REGION( 0x18000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "r7", 0x00000, 0x8000, 0x362f2a27 ) ROM_LOAD( "r8", 0x08000, 0x8000, 0x9fc7946e ) ROM_LOAD( "r9", 0x10000, 0x8000, 0xe6212fe4 ) ROM_REGION( 0x0300, REGION_PROMS ) ROM_LOAD( "am27s21.pr1", 0x0000, 0x0100, 0x361f0868 ) /* palette red bits */ ROM_LOAD( "am27s21.pr2", 0x0100, 0x0100, 0xe355da4d ) /* palette green bits */ ROM_LOAD( "am27s21.pr3", 0x0200, 0x0100, 0x8534cfb5 ) /* palette blue bits */ ROM_END ROM_START( homo ) ROM_REGION( 0x20000, REGION_CPU1 ) /* 2*64k for code */ ROM_LOAD( "homo.01", 0x00000, 0x8000, 0x28c539ad ) /* Code 0000-7fff */ ROM_LOAD( "r2", 0x10000, 0x8000, 0x1ff6e3a2 ) /* Paged data */ ROM_LOAD( "r3", 0x18000, 0x8000, 0xe9eec24a ) /* Paged data */ ROM_REGION( 0x10000, REGION_CPU2 ) /* 64k for the audio CPU */ ROM_LOAD( "r10", 0x00000, 0x8000, 0x72e1add1 ) ROM_REGION( 0x18000, REGION_GFX1 | REGIONFLAG_DISPOSE ) ROM_LOAD( "r4", 0x00000, 0x8000, 0x1ab84225 ) /* Characters */ ROM_LOAD( "r5", 0x08000, 0x8000, 0x4997d469 ) ROM_LOAD( "r6", 0x10000, 0x8000, 0x752904b0 ) ROM_REGION( 0x18000, REGION_GFX2 | REGIONFLAG_DISPOSE ) ROM_LOAD( "r7", 0x00000, 0x8000, 0x362f2a27 ) ROM_LOAD( "r8", 0x08000, 0x8000, 0x9fc7946e ) ROM_LOAD( "r9", 0x10000, 0x8000, 0xe6212fe4 ) ROM_REGION( 0x0300, REGION_PROMS ) ROM_LOAD( "am27s21.pr1", 0x0000, 0x0100, 0x361f0868 ) /* palette red bits */ ROM_LOAD( "am27s21.pr2", 0x0100, 0x0100, 0xe355da4d ) /* palette green bits */ ROM_LOAD( "am27s21.pr3", 0x0200, 0x0100, 0x8534cfb5 ) /* palette blue bits */ ROM_END void init_goindol(void) { unsigned char *rom = memory_region(REGION_CPU1); /* I hope that's all patches to avoid protection */ rom[0x04a7] = 0xc9; rom[0x0641] = 0xc9; rom[0x0831] = 0xc9; rom[0x0b30] = 0x00; rom[0x0c13] = 0xc9; rom[0x134e] = 0xc9; rom[0x172e] = 0xc9; rom[0x1785] = 0xc9; rom[0x17cc] = 0xc9; rom[0x1aa5] = 0x7b; rom[0x1aa6] = 0x17; rom[0x1bee] = 0xc9; rom[0x218c] = 0x00; rom[0x218d] = 0x00; rom[0x218e] = 0x00; rom[0x333d] = 0xc9; rom[0x3365] = 0x00; } void init_homo(void) { unsigned char *rom = memory_region(REGION_CPU1); rom[0x218c] = 0x00; rom[0x218d] = 0x00; rom[0x218e] = 0x00; } GAME( 1987, goindol, 0, goindol, goindol, goindol, ROT90, "Sun a Electronics", "Goindol" ) GAME( 1987, homo, goindol, goindol, homo, homo, ROT90, "bootleg", "Homo" )
32.504739
119
0.680469
gameblabla
4e63569fff87e19a34116a1204caea2bb1375857
172
hpp
C++
src/controllers/hotkeys/HotkeyHelpers.hpp
agenttud/chatterino7
b40763c5f847c017106115f92b864b40b3a20501
[ "MIT" ]
200
2017-01-24T11:23:03.000Z
2019-05-15T19:31:18.000Z
src/controllers/hotkeys/HotkeyHelpers.hpp
agenttud/chatterino7
b40763c5f847c017106115f92b864b40b3a20501
[ "MIT" ]
878
2017-02-06T13:25:24.000Z
2019-05-18T16:15:21.000Z
src/controllers/hotkeys/HotkeyHelpers.hpp
agenttud/chatterino7
b40763c5f847c017106115f92b864b40b3a20501
[ "MIT" ]
138
2017-02-07T18:01:49.000Z
2019-05-18T19:00:03.000Z
#pragma once #include <QString> #include <vector> namespace chatterino { std::vector<QString> parseHotkeyArguments(QString argumentString); } // namespace chatterino
14.333333
66
0.767442
agenttud
4e64bec80fecd96ec04e666243cca6b20428d074
3,058
cpp
C++
catboost/cuda/methods/greedy_subsets_searcher/model_builder.cpp
neer201/catboost_SE
091d44aed29ebb40a4bf76ef67ee22cf9779263e
[ "Apache-2.0" ]
1
2019-11-24T08:32:37.000Z
2019-11-24T08:32:37.000Z
catboost/cuda/methods/greedy_subsets_searcher/model_builder.cpp
neer201/catboost_SE
091d44aed29ebb40a4bf76ef67ee22cf9779263e
[ "Apache-2.0" ]
null
null
null
catboost/cuda/methods/greedy_subsets_searcher/model_builder.cpp
neer201/catboost_SE
091d44aed29ebb40a4bf76ef67ee22cf9779263e
[ "Apache-2.0" ]
null
null
null
#include "model_builder.h" #include <catboost/libs/helpers/exception.h> #include <util/stream/labeled.h> #include <util/generic/array_ref.h> using NCatboostCuda::TLeafPath; static void ValidateParameters( const TConstArrayRef<TLeafPath> leaves, const TConstArrayRef<double> leafWeights, const TConstArrayRef<TVector<float>> leafValues) { CB_ENSURE(!leaves.empty(), "Error: empty tree"); const auto depth = leaves.front().Splits.size(); const auto expectedLeavesCount = size_t(1) << depth; CB_ENSURE(leaves.size() == expectedLeavesCount, LabeledOutput(leaves.size(), expectedLeavesCount)); CB_ENSURE(leaves.size() == leafValues.size(), LabeledOutput(leaves.size(), leafValues.size())); CB_ENSURE(leaves.size() == leafWeights.size(), LabeledOutput(leaves.size(), leafWeights.size())); for (size_t i = 1; i < leaves.size(); ++i) { CB_ENSURE(leaves[i].Splits == leaves.front().Splits, LabeledOutput(i)); } for (size_t i = 1; i < leafValues.size(); ++i) { CB_ENSURE(leafValues[i].size() == leafValues.front().size(), LabeledOutput(i)); } } namespace NCatboostCuda { template <> TObliviousTreeModel BuildTreeLikeModel<TObliviousTreeModel>(const TVector<TLeafPath>& leaves, const TVector<double>& leafWeights, const TVector<TVector<float>>& leafValues) { ValidateParameters(leaves, leafWeights, leafValues); const auto depth = leaves.front().Splits.size(); const auto leavesCount = size_t(1) << depth; const auto outputDimention = leafValues.front().size(); TVector<ui32> binIds(leavesCount); ui32 checkSum = 0; for (size_t i = 0; i < leavesCount; ++i) { ui32 bin = 0; for (size_t level = 0; level < depth; ++level) { const auto direction = leaves[i].Directions[level]; bin |= ((direction == ESplitValue::Zero) ? 0 : 1) << level; } Y_VERIFY(bin < leavesCount); binIds[i] = bin; checkSum += bin; } const auto expectedCheckSum = leavesCount * (leavesCount - 1) / 2; CB_ENSURE(checkSum == expectedCheckSum, LabeledOutput(checkSum, expectedCheckSum, leavesCount)); TVector<double> resultWeights(leavesCount); TVector<float> resultValues(outputDimention * leavesCount); for (size_t i = 0; i < leavesCount; ++i) { ui32 bin = binIds[i]; resultWeights[bin] = leafWeights[i]; for (size_t dim = 0; dim < outputDimention; ++dim) { resultValues[bin * outputDimention + dim] = leafValues[i][dim]; } } TObliviousTreeStructure structure; structure.Splits = leaves[0].Splits; return TObliviousTreeModel( std::move(structure), std::move(resultValues), std::move(resultWeights), outputDimention); } }
35.976471
108
0.600719
neer201