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
sequencelengths
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
sequencelengths
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
sequencelengths
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
33858aa8773c010d80a42ebadd564f73db9b6324
1,549
hpp
C++
include/wtengine/mnu/apply.hpp
wtfsystems/wtengine
0fb56d6eb2ac6359509e7a52876c8656da6b3ce0
[ "MIT" ]
7
2020-06-16T18:47:35.000Z
2021-08-25T13:41:13.000Z
include/wtengine/mnu/apply.hpp
wtfsystems/wtengine
0fb56d6eb2ac6359509e7a52876c8656da6b3ce0
[ "MIT" ]
15
2020-07-23T14:03:39.000Z
2022-01-28T02:32:07.000Z
include/wtengine/mnu/apply.hpp
wtfsystems/wtengine
0fb56d6eb2ac6359509e7a52876c8656da6b3ce0
[ "MIT" ]
null
null
null
/*! * WTEngine | File: apply.hpp * * \author Matthew Evans * \version 0.7 * \copyright See LICENSE.md for copyright information. * \date 2019-2021 */ #ifndef WTE_MNU_ITEM_APPLY_HPP #define WTE_MNU_ITEM_APPLY_HPP #include <string> #include <vector> #include "wtengine/mnu/item.hpp" #include "wtengine/mgr/menus.hpp" #include "wtengine/mgr/messages.hpp" namespace wte::mnu { /*! * \class apply * \brief An apply option for the menus. */ class apply final : public item { public: /*! * \brief Menu Item Apply constructor. */ apply(); ~apply() = default; //!< Default destructor. private: /* * Set the apply item to cancel. */ void on_left(void) override; /* * Set the apply item to apply. */ void on_right(void) override; /* * On select trigger. */ void on_select(void) override; /* * Return display text for the menu item when rendering. */ const std::vector<std::string> get_text(void) const override; /* * Reset the apply item to the canceled state. */ void reset_to_default(void) override; /* * Set the apply item's default state to canceled. */ void set_default(void) override; /* * Reset the apply item to the canceled state. */ void apply_setting(void) override; bool do_apply; }; } // end namespace wte::mnu #endif
19.858974
69
0.564881
wtfsystems
33870031d521da5415d0ce25043318749bbee966
8,413
cxx
C++
genericio/python/lib/gio.cxx
lanl/VizAly
c4ee01737e1ed9977dfb2cc882cfdc3925832a9f
[ "Unlicense", "BSD-3-Clause" ]
4
2019-02-15T20:11:18.000Z
2020-03-19T06:56:02.000Z
genericio/python/lib/gio.cxx
lanl/VizAly
c4ee01737e1ed9977dfb2cc882cfdc3925832a9f
[ "Unlicense", "BSD-3-Clause" ]
null
null
null
genericio/python/lib/gio.cxx
lanl/VizAly
c4ee01737e1ed9977dfb2cc882cfdc3925832a9f
[ "Unlicense", "BSD-3-Clause" ]
1
2020-03-19T06:56:04.000Z
2020-03-19T06:56:04.000Z
/* * Copyright (C) 2015, UChicago Argonne, LLC * All Rights Reserved * * Generic IO (ANL-15-066) * Hal Finkel, Argonne National Laboratory * * OPEN SOURCE LICENSE * * Under the terms of Contract No. DE-AC02-06CH11357 with UChicago Argonne, * LLC, the U.S. Government retains certain rights in this software. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the names of UChicago Argonne, LLC or the Department of Energy * nor the names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * ***************************************************************************** * * DISCLAIMER * THE SOFTWARE IS SUPPLIED “AS IS” WITHOUT WARRANTY OF ANY KIND. NEITHER THE * UNTED STATES GOVERNMENT, NOR THE UNITED STATES DEPARTMENT OF ENERGY, NOR * UCHICAGO ARGONNE, LLC, NOR ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY, * EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE * ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, DATA, APPARATUS, * PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE * PRIVATELY OWNED RIGHTS. * * ***************************************************************************** */ #include "gio.h" #include <iostream> void read_gio_float(char* file_name, char* var_name, float* data, int field_count) { read_gio<float>(file_name, var_name, data, field_count); } void read_gio_double(char* file_name, char* var_name, double* data, int field_count) { read_gio<double>(file_name, var_name, data, field_count); } void read_gio_int32(char* file_name, char* var_name, int* data, int field_count) { read_gio<int>(file_name, var_name, data, field_count); } void read_gio_int64(char* file_name, char* var_name, int64_t* data, int field_count) { read_gio<int64_t>(file_name, var_name, data, field_count); } void read_gio_oct_float(char* file_name, int leaf_id, char* var_name, float* data) { read_gio_rankLeaf<float>(file_name, leaf_id, var_name, data); } void read_gio_oct_double(char* file_name, int leaf_id, char* var_name, double* data) { read_gio_rankLeaf<double>(file_name, leaf_id, var_name, data); } void read_gio_oct_int32(char* file_name, int leaf_id, char* var_name, int* data) { read_gio_rankLeaf<int>(file_name, leaf_id, var_name, data); } void read_gio_oct_int64(char* file_name, int leaf_id, char* var_name, int64_t* data) { read_gio_rankLeaf<int64_t>(file_name, leaf_id, var_name, data); } int64_t get_elem_num(char* file_name) { gio::GenericIO reader(file_name); reader.openAndReadHeader(gio::GenericIO::MismatchAllowed); int num_ranks = reader.readNRanks(); uint64_t size = 0; for(int i =0;i<num_ranks;++i) size +=reader.readNumElems(i); reader.close(); return size; } int64_t get_elem_num_in_leaf(char* file_name, int leaf_id) { gio::GenericIO reader(file_name); reader.openAndReadHeader(gio::GenericIO::MismatchAllowed); GIOOctree tempOctree = reader.getOctree(); reader.close(); return tempOctree.getCount(leaf_id); } void inspect_gio(char* file_name) { int64_t size = get_elem_num(file_name); gio::GenericIO reader(file_name); std::vector<gio::GenericIO::VariableInfo> VI; reader.openAndReadHeader(gio::GenericIO::MismatchAllowed); reader.getVariableInfo(VI); std::cout << "Number of Elements: " << size << std::endl; int num = VI.size(); std::cout << "[data type] Variable name" << std::endl; std::cout << "---------------------------------------------" << std::endl; for (int i = 0; i < num; ++i) { gio::GenericIO::VariableInfo vinfo = VI[i]; if (vinfo.IsFloat) std::cout << "[f"; else std::cout << "[i"; int NumElements = vinfo.Size / vinfo.ElementSize; std::cout << " " << vinfo.ElementSize * 8; if (NumElements > 1) std::cout << "x" << NumElements; std::cout << "] "; std::cout << vinfo.Name << std::endl; } std::cout << "\n(i=integer,f=floating point, number bits size)" << std::endl; if (reader.isOctree()) { std::cout << "---------------------------------------------" << std::endl; std::cout << "Octree info:" << std::endl; reader.printOctree(); } } var_type get_variable_type(char* file_name, char* var_name) { gio::GenericIO reader(file_name); std::vector<gio::GenericIO::VariableInfo> VI; reader.openAndReadHeader(gio::GenericIO::MismatchAllowed); reader.getVariableInfo(VI); int num = VI.size(); for (int i = 0; i < num; ++i) { gio::GenericIO::VariableInfo vinfo = VI[i]; if (vinfo.Name == var_name) { if (vinfo.IsFloat && vinfo.ElementSize == 4) return float_type; else if (vinfo.IsFloat && vinfo.ElementSize == 8) return double_type; else if (!vinfo.IsFloat && vinfo.ElementSize == 4) return int32_type; else if (!vinfo.IsFloat && vinfo.ElementSize == 8) return int64_type; else return type_not_found; } } return var_not_found; } int get_variable_field_count(char* file_name, char* var_name) { gio::GenericIO reader(file_name); std::vector<gio::GenericIO::VariableInfo> VI; reader.openAndReadHeader(gio::GenericIO::MismatchAllowed); reader.getVariableInfo(VI); int num = VI.size(); for (int i = 0; i < num; ++i) { gio::GenericIO::VariableInfo vinfo = VI[i]; if (vinfo.Name == var_name) { return vinfo.Size / vinfo.ElementSize; } } return 0; } int64_t get_num_variables(char* file_name) { gio::GenericIO reader(file_name); reader.openAndReadHeader(gio::GenericIO::MismatchAllowed); std::vector<gio::GenericIO::VariableInfo> VI; reader.getVariableInfo(VI); return VI.size(); } char* get_octree(char* file_name) { gio::GenericIO reader(file_name); reader.openAndReadHeader(gio::GenericIO::MismatchAllowed); std::string octreeStr; if (reader.isOctree()) octreeStr = (reader.getOctree()).getOctreeStr(); char *temp_name = new char[octreeStr.size() + 1]; strcpy(temp_name, octreeStr.c_str()); return temp_name; } char* get_variable(char* file_name, int var) { gio::GenericIO reader(file_name); reader.openAndReadHeader(gio::GenericIO::MismatchAllowed); std::vector<gio::GenericIO::VariableInfo> VI; reader.getVariableInfo(VI); std::string scaler_name = VI[var].Name; char *temp_name = new char[scaler_name.size() + 1]; strcpy(temp_name, scaler_name.c_str()); return temp_name; } int get_num_octree_leaves(char* file_name, int extents[]) { gio::GenericIO reader(file_name); reader.openAndReadHeader(gio::GenericIO::MismatchAllowed); std::vector<int> intersectedLeaves; GIOOctree tempOctree = reader.getOctree(); for (int i=0; i<tempOctree.rows.size(); i++) if ( tempOctree.rows[i].intersect(extents) ) intersectedLeaves.push_back(i); return intersectedLeaves.size(); } int* get_octree_leaves(char* file_name, int extents[]) { gio::GenericIO reader(file_name); reader.openAndReadHeader(gio::GenericIO::MismatchAllowed); std::vector<int> intersectedLeaves; GIOOctree tempOctree = reader.getOctree(); for (int i=0; i<tempOctree.rows.size(); i++) if ( tempOctree.rows[i].intersect(extents) ) intersectedLeaves.push_back(i); int *x = new int[intersectedLeaves.size()]; std::copy(intersectedLeaves.begin(), intersectedLeaves.end(), x); return x; }
31.275093
84
0.636753
lanl
3387d237c719d492424256f0b05d786d35e7c624
6,132
cpp
C++
tbb/tbb41_20120718oss/src/test/test_task_arena.cpp
glycerine/shore-mt
39f1802ba9588bc9d32d34386ed0193477f7e8d1
[ "Spencer-94", "Spencer-86", "Xnet", "Linux-OpenIB", "Spencer-99", "X11", "CECILL-B" ]
3
2016-07-15T08:22:56.000Z
2019-10-10T02:26:08.000Z
tbb/tbb41_20120718oss/src/test/test_task_arena.cpp
glycerine/shore-mt
39f1802ba9588bc9d32d34386ed0193477f7e8d1
[ "Spencer-94", "Spencer-86", "Xnet", "Linux-OpenIB", "Spencer-99", "X11", "CECILL-B" ]
null
null
null
tbb/tbb41_20120718oss/src/test/test_task_arena.cpp
glycerine/shore-mt
39f1802ba9588bc9d32d34386ed0193477f7e8d1
[ "Spencer-94", "Spencer-86", "Xnet", "Linux-OpenIB", "Spencer-99", "X11", "CECILL-B" ]
2
2020-12-23T06:49:23.000Z
2021-03-05T07:00:28.000Z
/* Copyright 2005-2012 Intel Corporation. All Rights Reserved. This file is part of Threading Building Blocks. Threading Building Blocks is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. Threading Building Blocks 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 Threading Building Blocks; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA As a special exception, you may use this file as part of a free software library without restriction. Specifically, if other files instantiate templates or use macros or inline functions from this file, or you compile this file and link it with other files to produce an executable, this file does not by itself cause the resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU General Public License. */ #if __TBB_CPF_BUILD // undefine __TBB_CPF_BUILD to simulate user's setup #undef __TBB_CPF_BUILD #define TBB_PREVIEW_TASK_ARENA 1 #include "tbb/task_arena.h" #include "tbb/task_scheduler_observer.h" #include "tbb/task_scheduler_init.h" #include <cstdlib> #include "harness_assert.h" #include <cstdio> #include "harness.h" #include "harness_barrier.h" #include "harness_concurrency_tracker.h" #include "tbb/parallel_for.h" #include "tbb/blocked_range.h" #include "tbb/enumerable_thread_specific.h" #if _MSC_VER // plays around __TBB_NO_IMPLICIT_LINKAGE. __TBB_LIB_NAME should be defined (in makefiles) #pragma comment(lib, __TBB_STRING(__TBB_LIB_NAME)) #endif typedef tbb::blocked_range<int> Range; class ConcurrencyTrackingBody { public: void operator() ( const Range& ) const { Harness::ConcurrencyTracker ct; for ( volatile int i = 0; i < 1000000; ++i ) ; } }; Harness::SpinBarrier our_barrier; static tbb::enumerable_thread_specific<int> local_id, old_id; void ResetTLS() { local_id.clear(); old_id.clear(); } class ArenaObserver : public tbb::task_scheduler_observer { int myId; tbb::atomic<int> myTrappedSlot; /*override*/ void on_scheduler_entry( bool is_worker ) { REMARK("a %s #%p is entering arena %d from %d\n", is_worker?"worker":"master", &local_id.local(), myId, local_id.local()); ASSERT(!old_id.local(), "double-call to on_scheduler_entry"); old_id.local() = local_id.local(); ASSERT(old_id.local() != myId, "double-entry to the same arena"); local_id.local() = myId; if(is_worker) ASSERT(tbb::task_arena::current_slot()>0, NULL); else ASSERT(tbb::task_arena::current_slot()==0, NULL); } /*override*/ void on_scheduler_exit( bool is_worker ) { REMARK("a %s #%p is leaving arena %d to %d\n", is_worker?"worker":"master", &local_id.local(), myId, old_id.local()); //ASSERT(old_id.local(), "call to on_scheduler_exit without prior entry"); ASSERT(local_id.local() == myId, "nesting of arenas is broken"); local_id.local() = old_id.local(); old_id.local() = 0; } /*override*/ bool on_scheduler_leaving() { return tbb::task_arena::current_slot() >= myTrappedSlot; } public: ArenaObserver(tbb::task_arena &a, int id, int trap = 0) : tbb::task_scheduler_observer(a) { observe(true); ASSERT(id, NULL); myId = id; myTrappedSlot = trap; } ~ArenaObserver () { ASSERT(!old_id.local(), "inconsistent observer state"); } }; struct AsynchronousWork : NoAssign { Harness::SpinBarrier &my_barrier; bool my_is_blocking; AsynchronousWork(Harness::SpinBarrier &a_barrier, bool blocking = true) : my_barrier(a_barrier), my_is_blocking(blocking) {} void operator()() const { ASSERT(local_id.local() != 0, "not in explicit arena"); tbb::parallel_for(Range(0,35), ConcurrencyTrackingBody()); if(my_is_blocking) my_barrier.timed_wait(10); // must be asynchronous to master thread else my_barrier.signal_nowait(); } }; void TestConcurrentArenas(int p) { //Harness::ConcurrencyTracker::Reset(); tbb::task_arena a1(1); ArenaObserver o1(a1, p*2+1); tbb::task_arena a2(2); ArenaObserver o2(a2, p*2+2); Harness::SpinBarrier barrier(2); AsynchronousWork work(barrier); a1.enqueue(work); // put async work barrier.timed_wait(10); a2.enqueue(work); // another work a2.execute(work); // my_barrier.timed_wait(10) inside a1.wait_until_empty(); a2.wait_until_empty(); } class MultipleMastersBody : NoAssign { tbb::task_arena &my_a; Harness::SpinBarrier &my_b; public: MultipleMastersBody(tbb::task_arena &a, Harness::SpinBarrier &b) : my_a(a), my_b(b) {} void operator()(int) const { my_a.execute(AsynchronousWork(my_b, /*blocking=*/false)); my_a.wait_until_empty(); } }; void TestMultipleMasters(int p) { REMARK("multiple masters\n"); tbb::task_arena a(1); ArenaObserver o(a, 1); Harness::SpinBarrier barrier(p+1); NativeParallelFor( p, MultipleMastersBody(a, barrier) ); a.wait_until_empty(); barrier.timed_wait(10); } int TestMain () { // TODO: a workaround for temporary p-1 issue in market tbb::task_scheduler_init init_market_p_plus_one(MaxThread+1); for( int p=MinThread; p<=MaxThread; ++p ) { REMARK("testing with %d threads\n", p ); NativeParallelFor( p, &TestConcurrentArenas ); ResetTLS(); TestMultipleMasters( p ); ResetTLS(); } return Harness::Done; } #else // __TBB_CPF_BUILD #include "harness.h" int TestMain () { return Harness::Skipped; } #endif
33.878453
130
0.687378
glycerine
3387f7cceec9f7b22b107e00570175c4f67730f5
921
cpp
C++
dev/TreeView/TreeViewDragItemsCompletedEventArgs.cpp
riverar/microsoft-ui-xaml
ef3a0fcd85d200c98514e765eea94323b943cf1e
[ "MIT" ]
3,788
2019-05-07T02:41:36.000Z
2022-03-30T12:34:15.000Z
dev/TreeView/TreeViewDragItemsCompletedEventArgs.cpp
riverar/microsoft-ui-xaml
ef3a0fcd85d200c98514e765eea94323b943cf1e
[ "MIT" ]
6,170
2019-05-06T21:32:43.000Z
2022-03-31T23:46:55.000Z
dev/TreeView/TreeViewDragItemsCompletedEventArgs.cpp
riverar/microsoft-ui-xaml
ef3a0fcd85d200c98514e765eea94323b943cf1e
[ "MIT" ]
532
2019-05-07T12:15:58.000Z
2022-03-31T11:36:26.000Z
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. #include "pch.h" #include "common.h" #include "Vector.h" #include "TreeViewDragItemsCompletedEventArgs.h" TreeViewDragItemsCompletedEventArgs::TreeViewDragItemsCompletedEventArgs(const winrt::DragItemsCompletedEventArgs& args, const winrt::IInspectable& newParentItem) { m_dragItemsCompletedEventArgs = args; m_newParentItem = newParentItem; } DataPackageOperation TreeViewDragItemsCompletedEventArgs::DropResult() const { return m_dragItemsCompletedEventArgs.DropResult(); } winrt::IVectorView<winrt::IInspectable> TreeViewDragItemsCompletedEventArgs::Items() { return m_dragItemsCompletedEventArgs.Items(); } winrt::IInspectable TreeViewDragItemsCompletedEventArgs::NewParentItem() { return m_newParentItem; }
30.7
163
0.785016
riverar
338935672ccf113b972a0343825e98e27b4f3d91
13,245
cc
C++
cpp/tests/test_five_round_distinguisher_present_sbox_small.cc
medsec/expectation-cryptanalysis-on-round-reduced-aes
52a4d5b4dd7555a1b4badafd95c5aeed92a70872
[ "Unlicense" ]
2
2019-06-04T00:52:17.000Z
2022-01-19T08:06:44.000Z
cpp/tests/test_five_round_distinguisher_present_sbox_small.cc
medsec/expectation-cryptanalysis-on-round-reduced-aes
52a4d5b4dd7555a1b4badafd95c5aeed92a70872
[ "Unlicense" ]
null
null
null
cpp/tests/test_five_round_distinguisher_present_sbox_small.cc
medsec/expectation-cryptanalysis-on-round-reduced-aes
52a4d5b4dd7555a1b4badafd95c5aeed92a70872
[ "Unlicense" ]
2
2019-06-03T08:12:29.000Z
2019-06-03T12:53:26.000Z
/** * __author__ = anonymized * __date__ = 2019-05 * __copyright__ = Creative Commons CC0 */ #include <array> #include <vector> #include <stdint.h> #include <stdlib.h> #include "ciphers/random_function.h" #include "ciphers/small_aes_present_sbox.h" #include "ciphers/small_state.h" #include "ciphers/speck64.h" #include "utils/argparse.h" #include "utils/utils.h" #include "utils/xorshift1024.h" using ciphers::small_aes_ctx_t; using ciphers::small_aes_state_t; using ciphers::small_aes_key_t; using ciphers::SmallState; using ciphers::speck64_context_t; using ciphers::speck64_96_key_t; using ciphers::speck64_state_t; using utils::assert_equal; using utils::compute_mean; using utils::compute_variance; using utils::xor_arrays; using utils::ArgumentParser; // --------------------------------------------------------- static const size_t NUM_CONSIDERED_ROUNDS = 5; static const size_t NUM_TEXTS_IN_DELTA_SET = 16; // --------------------------------------------------------- typedef struct { small_aes_key_t key; small_aes_ctx_t cipher_ctx; size_t num_keys; size_t num_sets_per_key; std::vector<size_t> num_matches; bool use_prp = false; bool use_all_delta_sets_from_diagonal = false; } ExperimentContext; typedef struct { std::vector<size_t> num_collisions_per_set; size_t num_collisions; } ExperimentResult; typedef size_t (*experiment_function_t)(ExperimentContext *); typedef std::vector<SmallState> SmallStatesVector; // --------------------------------------------------------- static void generate_base_plaintext(small_aes_state_t plaintext) { utils::get_random_bytes(plaintext, SMALL_AES_NUM_STATE_BYTES); } // --------------------------------------------------------- static void get_text_from_delta_set(small_aes_state_t base_text, const size_t i) { base_text[0] = (uint8_t) ((i << 4) & 0xF0); } // --------------------------------------------------------- static void generate_base_plaintext_in_diagonal(small_aes_state_t plaintext, const size_t set_index_in_diagonal, const size_t byte_index_in_diagonal) { if (byte_index_in_diagonal == 0) { plaintext[2] = (uint8_t) (((set_index_in_diagonal >> 8) & 0x0F) | (plaintext[2] & 0xF0)); plaintext[5] = (uint8_t) ((set_index_in_diagonal & 0xF0) | (plaintext[5] & 0x0F)); plaintext[7] = (uint8_t) ((set_index_in_diagonal & 0x0F) | (plaintext[7] & 0xF0)); } else if (byte_index_in_diagonal == 1) { plaintext[0] = (uint8_t) (((set_index_in_diagonal >> 4) & 0xF0) | (plaintext[0] & 0x0F)); plaintext[5] = (uint8_t) ((set_index_in_diagonal & 0xF0) | (plaintext[5] & 0x0F)); plaintext[7] = (uint8_t) ((set_index_in_diagonal & 0x0F) | (plaintext[7] & 0xF0)); } else if (byte_index_in_diagonal == 2) { plaintext[0] = (uint8_t) (((set_index_in_diagonal >> 4) & 0xF0) | (plaintext[0] & 0x0F)); plaintext[2] = (uint8_t) (((set_index_in_diagonal >> 4) & 0x0F) | (plaintext[2] & 0xF0)); plaintext[7] = (uint8_t) ((set_index_in_diagonal & 0x0F) | (plaintext[7] & 0xF0)); } else if (byte_index_in_diagonal == 3) { plaintext[0] = (uint8_t) (((set_index_in_diagonal >> 4) & 0xF0) | (plaintext[0] & 0x0F)); plaintext[2] = (uint8_t) (((set_index_in_diagonal >> 4) & 0x0F) | (plaintext[2] & 0xF0)); plaintext[5] = (uint8_t) ((set_index_in_diagonal & 0xF0) | (plaintext[5] & 0x0F)); } } // --------------------------------------------------------- static void get_text_from_diagonal_delta_set(small_aes_state_t plaintext, const size_t byte_index_in_diagonal, const size_t index_in_delta_set) { if (byte_index_in_diagonal == 0) { plaintext[0] = (uint8_t) ((plaintext[0] & 0x0F) | ((index_in_delta_set << 4) & 0xF0)); } else if (byte_index_in_diagonal == 1) { plaintext[2] = (uint8_t) ((plaintext[2] & 0xF0) | (index_in_delta_set & 0x0F)); } else if (byte_index_in_diagonal == 2) { plaintext[5] = (uint8_t) ((plaintext[5] & 0x0F) | ((index_in_delta_set << 4) & 0xF0)); } else if (byte_index_in_diagonal == 3) { plaintext[7] = (uint8_t) ((plaintext[7] & 0xF0) | (index_in_delta_set & 0x0F)); } } // --------------------------------------------------------- static void encrypt(const small_aes_ctx_t *aes_context, small_aes_state_t plaintext, SmallState &ciphertext) { small_aes_present_sbox_encrypt_rounds_only_sbox_in_final( aes_context, plaintext, ciphertext.state, NUM_CONSIDERED_ROUNDS ); } // --------------------------------------------------------- bool has_zero_column(const small_aes_state_t state) { return ((state[0] == 0) && (state[1] == 0)) || ((state[2] == 0) && (state[3] == 0)) || ((state[4] == 0) && (state[5] == 0)) || ((state[6] == 0) && (state[7] == 0)); } // --------------------------------------------------------- static size_t find_num_collisions(SmallStatesVector &ciphertexts) { const size_t num_texts = ciphertexts.size(); size_t num_collisions = 0; small_aes_state_t temp; for (size_t i = 0; i != num_texts; ++i) { const SmallState left = ciphertexts[i]; for (size_t j = i + 1; j != num_texts; ++j) { const SmallState right = ciphertexts[j]; xor_arrays(temp, left.state, right.state, SMALL_AES_NUM_STATE_BYTES); if (has_zero_column(temp)) { num_collisions++; } } } return num_collisions; } // --------------------------------------------------------- static size_t perform_experiment(ExperimentContext *context) { small_aes_ctx_t cipher_ctx = context->cipher_ctx; small_aes_key_t key; utils::get_random_bytes(key, SMALL_AES_NUM_KEY_BYTES); small_aes_key_setup(&cipher_ctx, key); utils::print_hex("# Key", key, SMALL_AES_NUM_KEY_BYTES); size_t num_collisions = 0; for (size_t i = 0; i < context->num_sets_per_key; ++i) { SmallStatesVector ciphertexts; small_aes_state_t plaintext; generate_base_plaintext(plaintext); for (size_t j = 0; j < NUM_TEXTS_IN_DELTA_SET; ++j) { SmallState ciphertext; get_text_from_delta_set(plaintext, j); encrypt(&cipher_ctx, plaintext, ciphertext); ciphertexts.push_back(ciphertext); } num_collisions += find_num_collisions(ciphertexts); if (i > 0) { if ((i & 0xFFFFF) == 0) { printf("# Tested %8zu sets. Collisions: %8zu\n", i, num_collisions); } } } return num_collisions; } // --------------------------------------------------------- static size_t perform_experiment_from_diagonal(ExperimentContext *context) { small_aes_ctx_t cipher_ctx = context->cipher_ctx; small_aes_key_t key; utils::get_random_bytes(key, SMALL_AES_NUM_KEY_BYTES); small_aes_key_setup(&cipher_ctx, key); utils::print_hex("# Key", key, SMALL_AES_NUM_KEY_BYTES); size_t num_collisions = 0; const size_t num_sets_in_diagonal = 1L << 12; const size_t num_bytes_in_diagonal = 4; small_aes_state_t plaintext; generate_base_plaintext(plaintext); for (size_t i = 0; i < num_sets_in_diagonal; ++i) { for (size_t m = 0; m < num_bytes_in_diagonal; ++m) { generate_base_plaintext_in_diagonal(plaintext, i, m); SmallStatesVector ciphertexts; for (size_t j = 0; j < NUM_TEXTS_IN_DELTA_SET; ++j) { SmallState ciphertext; get_text_from_diagonal_delta_set(plaintext, m, j); encrypt(&cipher_ctx, plaintext, ciphertext); ciphertexts.push_back(ciphertext); } num_collisions += find_num_collisions(ciphertexts); } if (i > 0) { if ((i & 0xFFFFF) == 0) { printf("# Tested %8zu sets. Collisions: %8zu\n", i, num_collisions); } } } return num_collisions; } // --------------------------------------------------------- static size_t perform_experiment_with_prp(ExperimentContext *context) { speck64_context_t cipher_ctx; speck64_96_key_t key; utils::get_random_bytes(key, SPECK_64_96_NUM_KEY_BYTES); utils::print_hex("# Key", key, SPECK_64_96_NUM_KEY_BYTES); speck64_96_key_schedule(&cipher_ctx, key); size_t num_collisions = 0; for (size_t i = 0; i < context->num_sets_per_key; ++i) { SmallStatesVector ciphertexts; speck64_state_t plaintext; generate_base_plaintext(plaintext); for (size_t j = 0; j < NUM_TEXTS_IN_DELTA_SET; ++j) { SmallState ciphertext; get_text_from_delta_set(plaintext, j); speck64_encrypt(&cipher_ctx, plaintext, ciphertext.state); ciphertexts.push_back(ciphertext); } num_collisions += find_num_collisions(ciphertexts); if (i > 0) { if ((i & 0xFFFFF) == 0) { printf("# Tested %8zu sets. Collisions: %8zu\n", i, num_collisions); } } } return num_collisions; } // --------------------------------------------------------- static void perform_experiments(ExperimentContext *context) { experiment_function_t experiment_function = nullptr; if (context->use_prp) { experiment_function = &perform_experiment_with_prp; } else if (!context->use_prp && !context->use_all_delta_sets_from_diagonal) { experiment_function = &perform_experiment; } else if (!context->use_prp && context->use_all_delta_sets_from_diagonal) { experiment_function = &perform_experiment_from_diagonal; } ExperimentResult all_results; all_results.num_collisions = 0; printf("#%8zu Experiments\n", context->num_keys); printf("#%8zu Sets/key\n", context->num_sets_per_key); printf("# Key Collisions Mean Variance \n"); for (size_t i = 0; i < context->num_keys; ++i) { const size_t num_collisions = experiment_function(context); const double mean = (double) num_collisions / (double) context->num_sets_per_key; all_results.num_collisions += num_collisions; all_results.num_collisions_per_set.push_back(num_collisions); printf("%4zu %8zu %8.4f\n", i + 1, num_collisions, mean); } const double mean = compute_mean(all_results.num_collisions_per_set); const double variance = compute_variance( all_results.num_collisions_per_set); printf("# Total Keys Collisions Mean Variance \n"); printf("# %4zu %8zu %8.4f %8.8f\n", context->num_keys, all_results.num_collisions, mean, variance); } // --------------------------------------------------------- // Argument parsing // --------------------------------------------------------- static void parse_args(ExperimentContext *context, int argc, const char **argv) { ArgumentParser parser; parser.appName("Test for the Small-AES five-round distinguisher." "If -d 1 -r 0 is set, uses all 4 * 2^12 * binom(16, 2) " "delta-sets from diagonals, but only for the Small-AES, " "not for the PRP."); parser.addArgument("-k", "--num_keys", 1, false); parser.addArgument("-s", "--num_sets_per_key", 1, false); parser.addArgument("-r", "--use_random_function", 1, false); parser.addArgument("-d", "--use_diagonals", 1, false); try { parser.parse((size_t) argc, argv); context->num_sets_per_key = static_cast<const size_t>(1L << parser.retrieveAsLong("s")); context->num_keys = parser.retrieveAsLong("k"); context->use_prp = (bool) parser.retrieveAsInt("r"); context->use_all_delta_sets_from_diagonal = (bool) parser.retrieveAsInt( "d"); } catch (...) { fprintf(stderr, "%s\n", parser.usage().c_str()); exit(EXIT_FAILURE); } printf("#Keys %8zu\n", context->num_keys); printf("#Sets/Key (log) %8zu\n", context->num_sets_per_key); printf("#Uses PRP %8d\n", context->use_prp); printf("#Uses Diagonal %8d\n", context->use_all_delta_sets_from_diagonal); } // --------------------------------------------------------- int main(int argc, const char **argv) { ExperimentContext context; parse_args(&context, argc, argv); perform_experiments(&context); return EXIT_SUCCESS; }
34.672775
80
0.564137
medsec
3389df337ccdcea5c21e2c71a970049bec6a7382
6,003
cxx
C++
StRoot/StEEmcUtil/EEfeeRaw/EEfeeDataBlock.cxx
xiaohaijin/RHIC-STAR
a305cb0a6ac15c8165bd8f0d074d7075d5e58752
[ "MIT" ]
2
2018-12-24T19:37:00.000Z
2022-02-28T06:57:20.000Z
StRoot/StEEmcUtil/EEfeeRaw/EEfeeDataBlock.cxx
xiaohaijin/RHIC-STAR
a305cb0a6ac15c8165bd8f0d074d7075d5e58752
[ "MIT" ]
null
null
null
StRoot/StEEmcUtil/EEfeeRaw/EEfeeDataBlock.cxx
xiaohaijin/RHIC-STAR
a305cb0a6ac15c8165bd8f0d074d7075d5e58752
[ "MIT" ]
null
null
null
#include <cassert> #include <string.h> #include "EEdims.h" #include "EEfeeDataBlock.h" ClassImp(EEfeeDataBlock) const int EEfeeDataBlock::DefaultMaxHead=4; const int EEfeeDataBlock::DefaultMaxData=192; //-------------------------------------------------- //-------------------------------------------------- //-------------------------------------------------- EEfeeDataBlock :: EEfeeDataBlock() { MaxHead = DefaultMaxHead; MaxData = 0 ; head = new UShort_t[MaxHead]; data = NULL; sanity=0xff; } EEfeeDataBlock::EEfeeDataBlock(const EEfeeDataBlock *b) { MaxData = b->getDataLen(); MaxHead = b->getHeadLen(); head=0; if(MaxHead>0) head = new UShort_t[MaxHead]; data=0; if(MaxData>0) data = new UShort_t[MaxData]; set(b); } //-------------------------------------------------- //-------------------------------------------------- //-------------------------------------------------- EEfeeDataBlock :: ~EEfeeDataBlock() { if(head) delete [] head; if(data) delete [] data; } //-------------------------------------------------- //-------------------------------------------------- //-------------------------------------------------- void EEfeeDataBlock :: print(int flag){ printf("feeDataBlock Head: 0x%04hx 0x%04hx 0x%04hx 0x%04hx ",head[0],head[1],head[2],head[3]); printf("\n --> token=0x%2x crateID=0x%x trigComm=0x%x lenCount=0x%x errFlag=0x%x\n NpositiveData=%d sanity=0x%02x\n", getToken(),getCrateID(),getTrigComm(),getLenCount(),getErrFlag(),getNData(0),sanity); if(flag<=0) return; int nd=getDataLen(); printf("Data[%3d]:",nd); for(int i=0;i<nd;i++) { if( i%8 == 0 ) printf("\n"); printf("0x%04hx ",data[i]); } printf("\n"); } //-------------------------------------------------- //-------------------------------------------------- //-------------------------------------------------- void EEfeeDataBlock :: set(const EEfeeDataBlock *b) { setHead(b->getHead()); setDataArray(b->getData(),b->getDataLen()); } //-------------------------------------------------- //-------------------------------------------------- //-------------------------------------------------- void EEfeeDataBlock ::setHead(const UShort_t *h) { if(h) memcpy(head,h,sizeof(head[0])*MaxHead); else // empty header==>clear memset(head,0,sizeof(head[0])*MaxHead); } //-------------------------------------------------- //-------------------------------------------------- //-------------------------------------------------- int EEfeeDataBlock ::getNData(int thres) const { int n=0; int i; const int nd=getValidDataLen(); for(i=0;i<nd;i++) if(data[i]>thres) n++; return n; } //-------------------------------------------------- //-------------------------------------------------- //-------------------------------------------------- void EEfeeDataBlock ::setDataArray(const UShort_t *dIn, int size) { const UShort_t x=0,*d=&x; if(dIn) { d=dIn; } else { size =1; } if(size!=MaxData) { // tmp, was '>' if(data) delete [] data; MaxData = size; data = new UShort_t[MaxData]; } else { memset(data,0x0,sizeof(data[0])*MaxData); } memcpy(data,d,size*sizeof(data[0])); } //-------------------------------------------------- //-------------------------------------------------- //-------------------------------------------------- void EEfeeDataBlock ::setData(int chan, UShort_t d){ assert(chan>=0); if(chan>=MaxData) { Int_t newsize = MaxData + DefaultMaxData; UShort_t *newdata = new UShort_t[newsize]; if(data) { memcpy(newdata,data,MaxData); delete [] data; } data = newdata; MaxData = newsize; } data[chan]=d; } //-------------------------------------------------- //-------------------------------------------------- //-------------------------------------------------- void EEfeeDataBlock :: clear(){ if(head) memset(head,0,sizeof(head[0])*MaxHead); if(data) memset(data,0,sizeof(data[0])*MaxData); sanity=0xff; // reset to full corruption } //-------------------------------------------------- //-------------------------------------------------- //-------------------------------------------------- UChar_t EEfeeDataBlock ::isHeadValid(int token, int crId, int len, int trigComm, int errFlag){ // encode failure all test as subsequent bits unsigned char ret=0; ret|=(getCrateID()!=crId)<<0; ret|=(getToken()!=token)<<1; ret|=(getLenCount()!=len)<<2; ret|=(getTrigComm()!=trigComm)<<3; ret|=(getErrFlag()!=errFlag)<<4; sanity=ret; #if 0 printf("\nask/0x: %x %x %x %x %x\n", token,crId,len,trigComm,errFlag); print(0); printf("getCrateID()/0x = %x %x\n",getCrateID(),crId); printf("getToken()/0x = %x %x\n",getToken(),token); printf("getLenCount()/0x = %x %x\n",getLenCount(),len); printf("getTrigComm()/0x = %x %x\n",getTrigComm(),trigComm); printf("getErrFlag()/0x = %x %x\n",getErrFlag(),errFlag); #endif return ret; // zero==good header } /* * $Log: EEfeeDataBlock.cxx,v $ * Revision 1.16 2007/07/12 19:30:13 fisyak * Add includes for ROOT 5.16 * * Revision 1.15 2004/06/21 19:50:21 balewski * mre detailed monitoring of data corruption * * Revision 1.14 2004/06/01 16:05:18 balewski * forgoten update of data block headers check * * Revision 1.13 2004/04/16 17:26:46 balewski * more header checking, some mess introduced * * Revision 1.12 2004/04/02 06:38:52 balewski * *** empty log message *** * * Revision 1.11 2004/03/25 16:54:58 balewski * cleanup of arguments * * Revision 1.10 2004/03/20 20:25:55 balewski * *** empty log message *** * * Revision 1.9 2004/01/27 07:09:37 balewski * slower but simpler * * Revision 1.8 2003/12/03 18:55:41 zolnie * fixed yet another bug * * Revision 1.7 2003/12/02 17:22:07 balewski * fix after version mixup * * Revision 1.5 2003/11/24 05:40:55 balewski * new stuff for miniDaq * * Revision 1.4 2003/11/20 16:01:46 balewski * towars run 4 * */
26.328947
126
0.47243
xiaohaijin
338b6b44beba7b2b1c91901f024088df8166a69d
486
cpp
C++
Uncategorized/bts18p1.cpp
crackersamdjam/DMOJ-Solutions
97992566595e2c7bf41b5da9217d8ef61bdd1d71
[ "MIT" ]
null
null
null
Uncategorized/bts18p1.cpp
crackersamdjam/DMOJ-Solutions
97992566595e2c7bf41b5da9217d8ef61bdd1d71
[ "MIT" ]
null
null
null
Uncategorized/bts18p1.cpp
crackersamdjam/DMOJ-Solutions
97992566595e2c7bf41b5da9217d8ef61bdd1d71
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> #define MM 1002 using namespace std; string a, b; int c; int main(){ getline(cin,a); getline(cin,b); cin >> c; for(int i = 0; i < a.length(); i++){ if(a[i] != b[i]){ if(a[i] == ' ' || b[i] == ' '){ c = -1; break; } c--; if(c < 0) break; } } printf( c < 0? "No plagiarism":"Plagiarized"); return 0; }
21.130435
51
0.358025
crackersamdjam
338d473bb21c5a5342db27c4e180bfd44e2c98ad
178
cpp
C++
OO1Lab2V1/Carolija.cpp
shkemilo/Lab1HomeworkOO1
3f32a980c44c9df009c128791e28e90d23c86358
[ "MIT" ]
null
null
null
OO1Lab2V1/Carolija.cpp
shkemilo/Lab1HomeworkOO1
3f32a980c44c9df009c128791e28e90d23c86358
[ "MIT" ]
null
null
null
OO1Lab2V1/Carolija.cpp
shkemilo/Lab1HomeworkOO1
3f32a980c44c9df009c128791e28e90d23c86358
[ "MIT" ]
null
null
null
#include <string> #include "Carolija.h" Carolija::Carolija(std::string ime, int cost) : Karta(ime, cost) { } std::string Carolija::GetCategory() const { return "CAROLIJA"; }
13.692308
64
0.691011
shkemilo
3391d4ec4e8475f0efde936f6982ebe7ad0db7af
4,624
cc
C++
EventGenerator/src/PrimaryProtonGunR_module.cc
pavel1murat/Offline
729840761324a4d9c49c037114dd3a3ec38e3358
[ "Apache-2.0" ]
null
null
null
EventGenerator/src/PrimaryProtonGunR_module.cc
pavel1murat/Offline
729840761324a4d9c49c037114dd3a3ec38e3358
[ "Apache-2.0" ]
null
null
null
EventGenerator/src/PrimaryProtonGunR_module.cc
pavel1murat/Offline
729840761324a4d9c49c037114dd3a3ec38e3358
[ "Apache-2.0" ]
null
null
null
/* This is a Replicated Module. A plug-in for running PrimaryProtonGun-based event generator for running in MT art. It produces a GenParticleCollection of primary protons using the PrimaryProtonGun. These Collections are used in Mu2eG4_module.cc. Original author Lisa Goodenough */ // Mu2e includes. #include "ConfigTools/inc/SimpleConfig.hh" #include "MCDataProducts/inc/GenId.hh" #include "MCDataProducts/inc/GenParticleCollection.hh" // Particular generators that this code knows about. #include "EventGenerator/inc/PrimaryProtonGun.hh" #include "SeedService/inc/SeedService.hh" // Includes from art and its toolchain. #include "art/Framework/Core/ReplicatedProducer.h" #include "art/Framework/Principal/Event.h" #include "art/Framework/Core/ModuleMacros.h" #include "art/Framework/Services/Registry/ServiceHandle.h" #include "art/Framework/Principal/Handle.h" #include "fhiclcpp/ParameterSet.h" #include "messagefacility/MessageLogger/MessageLogger.h" // C++ includes. #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; namespace mu2e { class PrimaryProtonGunR : public art::ReplicatedProducer { public: explicit PrimaryProtonGunR(fhicl::ParameterSet const& pS, art::ProcessingFrame const& pF); // Accept compiler written d'tor. Modules are never moved or copied. virtual void produce (art::Event& e, art::ProcessingFrame const& pF) override; virtual void beginRun(art::Run const& r, art::ProcessingFrame const& pF) override; private: // Name of the run-time configuration file. string _configfile; bool _allowReplacement; bool _messageOnReplacement; bool _messageOnDefault; int _configStatsVerbosity; // Print final config file after all replacements. bool _printConfig; CLHEP::HepJamesRandom _engine; std::unique_ptr<PrimaryProtonGun> _primaryProtonGunGenerator; // Number of times BeginRun is called on this module int ncalls = 0; }; PrimaryProtonGunR::PrimaryProtonGunR(fhicl::ParameterSet const& pSet, art::ProcessingFrame const& procFrame): art::ReplicatedProducer{pSet,procFrame}, _configfile( pSet.get<std::string> ("inputfile")), _allowReplacement( pSet.get<bool> ("allowReplacement", true)), _messageOnReplacement( pSet.get<bool> ("messageOnReplacement", false)), _messageOnDefault( pSet.get<bool> ("messageOnDefault", false)), _configStatsVerbosity( pSet.get<int> ("configStatsVerbosity", 0)), _printConfig( pSet.get<bool> ("printConfig", false)), _engine{art::ServiceHandle<SeedService>{}->getSeed()} { produces<GenParticleCollection>(); } void PrimaryProtonGunR::beginRun(art::Run const& run, art::ProcessingFrame const& procFrame){ // The configuration of the PPG Generator does not change within a job. if ( ++ncalls > 1){ mf::LogInfo("PrimaryProtonGunR") << "For Schedule: " << procFrame.scheduleID() << ", PrimaryProtonGunR Generator does not change state at beginRun. Hope that's OK."; return; } // We don't want to print this out more than once, // regardless of the number of instances/schedules running. std::string schedID = std::to_string(procFrame.scheduleID().id()); if ( schedID == "0"){ cout << "Event generator configuration file: " << _configfile << "\n" << endl; } // Load the configuration, make modifications if required, and print if desired. SimpleConfig config(_configfile, _allowReplacement, _messageOnReplacement, _messageOnDefault ); if ( _printConfig ){ config.print(cout,"PrimaryProtonGunR: "); } config.printAllSummaries( cout, _configStatsVerbosity, "PrimaryProtonGunR: "); // Instantiate generator for this run. _primaryProtonGunGenerator = std::make_unique <PrimaryProtonGun>( _engine, run, config); }//beginRun void PrimaryProtonGunR::produce(art::Event& evt, art::ProcessingFrame const& procFrame) { // Make the collections to hold the output. unique_ptr<GenParticleCollection> genParticles(new GenParticleCollection); // Run the generator and put the generated particles into the event. _primaryProtonGunGenerator->generate(*genParticles); evt.put(std::move(genParticles)); }//produce() } DEFINE_ART_MODULE(mu2e::PrimaryProtonGunR);
34.766917
113
0.683824
pavel1murat
3392c25bc82629445d57429d1aaac874c7306995
635
hpp
C++
pythran/pythonic/numpy/ones_like.hpp
rfiischer/pythran
a580245b1b45e5eb0df01c518e442041b89afa21
[ "BSD-3-Clause" ]
null
null
null
pythran/pythonic/numpy/ones_like.hpp
rfiischer/pythran
a580245b1b45e5eb0df01c518e442041b89afa21
[ "BSD-3-Clause" ]
null
null
null
pythran/pythonic/numpy/ones_like.hpp
rfiischer/pythran
a580245b1b45e5eb0df01c518e442041b89afa21
[ "BSD-3-Clause" ]
null
null
null
#ifndef PYTHONIC_NUMPY_ONESLIKE_HPP #define PYTHONIC_NUMPY_ONESLIKE_HPP #include "pythonic/include/numpy/ones_like.hpp" #include "pythonic/utils/functor.hpp" #include "pythonic/numpy/ones.hpp" PYTHONIC_NS_BEGIN namespace numpy { template <class E, class dtype> auto ones_like(E const &expr, dtype d) -> decltype(ones(expr.shape(), d)) { return ones(expr.shape(), d); } template <class E> auto ones_like(E const &expr, types::none_type) -> decltype(ones(expr.shape(), types::dtype_t<typename E::dtype>())) { return ones(expr.shape(), types::dtype_t<typename E::dtype>()); } } PYTHONIC_NS_END #endif
21.166667
75
0.710236
rfiischer
33932ff95bdbcc48833f4df2f6624d26ae3dcf50
23,687
cc
C++
third_party/libvpx/source/libvpx/test/vp9_quantize_test.cc
zipated/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
2,151
2020-04-18T07:31:17.000Z
2022-03-31T08:39:18.000Z
third_party/libvpx/source/libvpx/test/vp9_quantize_test.cc
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
third_party/libvpx/source/libvpx/test/vp9_quantize_test.cc
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
338
2020-04-18T08:03:10.000Z
2022-03-29T12:33:22.000Z
/* * Copyright (c) 2014 The WebM 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 <math.h> #include <stdlib.h> #include <string.h> #include "third_party/googletest/src/include/gtest/gtest.h" #include "./vp9_rtcd.h" #include "./vpx_config.h" #include "./vpx_dsp_rtcd.h" #include "test/acm_random.h" #include "test/buffer.h" #include "test/clear_system_state.h" #include "test/register_state_check.h" #include "test/util.h" #include "vp9/common/vp9_entropy.h" #include "vp9/common/vp9_scan.h" #include "vpx/vpx_codec.h" #include "vpx/vpx_integer.h" #include "vpx_ports/vpx_timer.h" using libvpx_test::ACMRandom; using libvpx_test::Buffer; namespace { const int number_of_iterations = 100; typedef void (*QuantizeFunc)(const tran_low_t *coeff, intptr_t count, int skip_block, const int16_t *zbin, const int16_t *round, const int16_t *quant, const int16_t *quant_shift, tran_low_t *qcoeff, tran_low_t *dqcoeff, const int16_t *dequant, uint16_t *eob, const int16_t *scan, const int16_t *iscan); typedef ::testing::tuple<QuantizeFunc, QuantizeFunc, vpx_bit_depth_t, int /*max_size*/, bool /*is_fp*/> QuantizeParam; // Wrapper for FP version which does not use zbin or quant_shift. typedef void (*QuantizeFPFunc)(const tran_low_t *coeff, intptr_t count, int skip_block, const int16_t *round, const int16_t *quant, tran_low_t *qcoeff, tran_low_t *dqcoeff, const int16_t *dequant, uint16_t *eob, const int16_t *scan, const int16_t *iscan); template <QuantizeFPFunc fn> void QuantFPWrapper(const tran_low_t *coeff, intptr_t count, int skip_block, const int16_t *zbin, const int16_t *round, const int16_t *quant, const int16_t *quant_shift, tran_low_t *qcoeff, tran_low_t *dqcoeff, const int16_t *dequant, uint16_t *eob, const int16_t *scan, const int16_t *iscan) { (void)zbin; (void)quant_shift; fn(coeff, count, skip_block, round, quant, qcoeff, dqcoeff, dequant, eob, scan, iscan); } class VP9QuantizeBase { public: VP9QuantizeBase(vpx_bit_depth_t bit_depth, int max_size, bool is_fp) : bit_depth_(bit_depth), max_size_(max_size), is_fp_(is_fp) { max_value_ = (1 << bit_depth_) - 1; zbin_ptr_ = reinterpret_cast<int16_t *>(vpx_memalign(16, 8 * sizeof(*zbin_ptr_))); round_fp_ptr_ = reinterpret_cast<int16_t *>( vpx_memalign(16, 8 * sizeof(*round_fp_ptr_))); quant_fp_ptr_ = reinterpret_cast<int16_t *>( vpx_memalign(16, 8 * sizeof(*quant_fp_ptr_))); round_ptr_ = reinterpret_cast<int16_t *>(vpx_memalign(16, 8 * sizeof(*round_ptr_))); quant_ptr_ = reinterpret_cast<int16_t *>(vpx_memalign(16, 8 * sizeof(*quant_ptr_))); quant_shift_ptr_ = reinterpret_cast<int16_t *>( vpx_memalign(16, 8 * sizeof(*quant_shift_ptr_))); dequant_ptr_ = reinterpret_cast<int16_t *>( vpx_memalign(16, 8 * sizeof(*dequant_ptr_))); } ~VP9QuantizeBase() { vpx_free(zbin_ptr_); vpx_free(round_fp_ptr_); vpx_free(quant_fp_ptr_); vpx_free(round_ptr_); vpx_free(quant_ptr_); vpx_free(quant_shift_ptr_); vpx_free(dequant_ptr_); zbin_ptr_ = NULL; round_fp_ptr_ = NULL; quant_fp_ptr_ = NULL; round_ptr_ = NULL; quant_ptr_ = NULL; quant_shift_ptr_ = NULL; dequant_ptr_ = NULL; libvpx_test::ClearSystemState(); } protected: int16_t *zbin_ptr_; int16_t *round_fp_ptr_; int16_t *quant_fp_ptr_; int16_t *round_ptr_; int16_t *quant_ptr_; int16_t *quant_shift_ptr_; int16_t *dequant_ptr_; const vpx_bit_depth_t bit_depth_; int max_value_; const int max_size_; const bool is_fp_; }; class VP9QuantizeTest : public VP9QuantizeBase, public ::testing::TestWithParam<QuantizeParam> { public: VP9QuantizeTest() : VP9QuantizeBase(GET_PARAM(2), GET_PARAM(3), GET_PARAM(4)), quantize_op_(GET_PARAM(0)), ref_quantize_op_(GET_PARAM(1)) {} protected: const QuantizeFunc quantize_op_; const QuantizeFunc ref_quantize_op_; }; // This quantizer compares the AC coefficients to the quantization step size to // determine if further multiplication operations are needed. // Based on vp9_quantize_fp_sse2(). inline void quant_fp_nz(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *round_ptr, const int16_t *quant_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan, int is_32x32) { int i, eob = -1; const int thr = dequant_ptr[1] >> (1 + is_32x32); (void)iscan; (void)skip_block; assert(!skip_block); // Quantization pass: All coefficients with index >= zero_flag are // skippable. Note: zero_flag can be zero. for (i = 0; i < n_coeffs; i += 16) { int y; int nzflag_cnt = 0; int abs_coeff[16]; int coeff_sign[16]; // count nzflag for each row (16 tran_low_t) for (y = 0; y < 16; ++y) { const int rc = i + y; const int coeff = coeff_ptr[rc]; coeff_sign[y] = (coeff >> 31); abs_coeff[y] = (coeff ^ coeff_sign[y]) - coeff_sign[y]; // The first 16 are skipped in the sse2 code. Do the same here to match. if (i >= 16 && (abs_coeff[y] <= thr)) { nzflag_cnt++; } } for (y = 0; y < 16; ++y) { const int rc = i + y; // If all of the AC coeffs in a row has magnitude less than the // quantization step_size/2, quantize to zero. if (nzflag_cnt < 16) { int tmp; int _round; if (is_32x32) { _round = ROUND_POWER_OF_TWO(round_ptr[rc != 0], 1); } else { _round = round_ptr[rc != 0]; } tmp = clamp(abs_coeff[y] + _round, INT16_MIN, INT16_MAX); tmp = (tmp * quant_ptr[rc != 0]) >> (16 - is_32x32); qcoeff_ptr[rc] = (tmp ^ coeff_sign[y]) - coeff_sign[y]; dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0]; if (is_32x32) { dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0] / 2; } else { dqcoeff_ptr[rc] = qcoeff_ptr[rc] * dequant_ptr[rc != 0]; } } else { qcoeff_ptr[rc] = 0; dqcoeff_ptr[rc] = 0; } } } // Scan for eob. for (i = 0; i < n_coeffs; i++) { // Use the scan order to find the correct eob. const int rc = scan[i]; if (qcoeff_ptr[rc]) { eob = i; } } *eob_ptr = eob + 1; } void quantize_fp_nz_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *round_ptr, const int16_t *quant_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan) { quant_fp_nz(coeff_ptr, n_coeffs, skip_block, round_ptr, quant_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan, 0); } void quantize_fp_32x32_nz_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs, int skip_block, const int16_t *round_ptr, const int16_t *quant_ptr, tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan) { quant_fp_nz(coeff_ptr, n_coeffs, skip_block, round_ptr, quant_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan, 1); } void GenerateHelperArrays(ACMRandom *rnd, int16_t *zbin, int16_t *round, int16_t *quant, int16_t *quant_shift, int16_t *dequant, int16_t *round_fp, int16_t *quant_fp) { // Max when q == 0. Otherwise, it is 48 for Y and 42 for U/V. const int max_qrounding_factor_fp = 64; for (int j = 0; j < 2; j++) { // The range is 4 to 1828 in the VP9 tables. const int qlookup = rnd->RandRange(1825) + 4; round_fp[j] = (max_qrounding_factor_fp * qlookup) >> 7; quant_fp[j] = (1 << 16) / qlookup; // Values determined by deconstructing vp9_init_quantizer(). // zbin may be up to 1143 for 8 and 10 bit Y values, or 1200 for 12 bit Y // values or U/V values of any bit depth. This is because y_delta is not // factored into the vp9_ac_quant() call. zbin[j] = rnd->RandRange(1200); // round may be up to 685 for Y values or 914 for U/V. round[j] = rnd->RandRange(914); // quant ranges from 1 to -32703 quant[j] = static_cast<int>(rnd->RandRange(32704)) - 32703; // quant_shift goes up to 1 << 16. quant_shift[j] = rnd->RandRange(16384); // dequant maxes out at 1828 for all cases. dequant[j] = rnd->RandRange(1828); } for (int j = 2; j < 8; j++) { zbin[j] = zbin[1]; round_fp[j] = round_fp[1]; quant_fp[j] = quant_fp[1]; round[j] = round[1]; quant[j] = quant[1]; quant_shift[j] = quant_shift[1]; dequant[j] = dequant[1]; } } TEST_P(VP9QuantizeTest, OperationCheck) { ACMRandom rnd(ACMRandom::DeterministicSeed()); Buffer<tran_low_t> coeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 16); ASSERT_TRUE(coeff.Init()); Buffer<tran_low_t> qcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32); ASSERT_TRUE(qcoeff.Init()); Buffer<tran_low_t> dqcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32); ASSERT_TRUE(dqcoeff.Init()); Buffer<tran_low_t> ref_qcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32); ASSERT_TRUE(ref_qcoeff.Init()); Buffer<tran_low_t> ref_dqcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32); ASSERT_TRUE(ref_dqcoeff.Init()); uint16_t eob, ref_eob; for (int i = 0; i < number_of_iterations; ++i) { // Test skip block for the first three iterations to catch all the different // sizes. const int skip_block = 0; TX_SIZE sz; if (max_size_ == 16) { sz = static_cast<TX_SIZE>(i % 3); // TX_4X4, TX_8X8 TX_16X16 } else { sz = TX_32X32; } const TX_TYPE tx_type = static_cast<TX_TYPE>((i >> 2) % 3); const scan_order *scan_order = &vp9_scan_orders[sz][tx_type]; const int count = (4 << sz) * (4 << sz); coeff.Set(&rnd, -max_value_, max_value_); GenerateHelperArrays(&rnd, zbin_ptr_, round_ptr_, quant_ptr_, quant_shift_ptr_, dequant_ptr_, round_fp_ptr_, quant_fp_ptr_); int16_t *r_ptr = (is_fp_) ? round_fp_ptr_ : round_ptr_; int16_t *q_ptr = (is_fp_) ? quant_fp_ptr_ : quant_ptr_; ref_quantize_op_(coeff.TopLeftPixel(), count, skip_block, zbin_ptr_, r_ptr, q_ptr, quant_shift_ptr_, ref_qcoeff.TopLeftPixel(), ref_dqcoeff.TopLeftPixel(), dequant_ptr_, &ref_eob, scan_order->scan, scan_order->iscan); ASM_REGISTER_STATE_CHECK(quantize_op_( coeff.TopLeftPixel(), count, skip_block, zbin_ptr_, r_ptr, q_ptr, quant_shift_ptr_, qcoeff.TopLeftPixel(), dqcoeff.TopLeftPixel(), dequant_ptr_, &eob, scan_order->scan, scan_order->iscan)); EXPECT_TRUE(qcoeff.CheckValues(ref_qcoeff)); EXPECT_TRUE(dqcoeff.CheckValues(ref_dqcoeff)); EXPECT_EQ(eob, ref_eob); if (HasFailure()) { printf("Failure on iteration %d.\n", i); qcoeff.PrintDifference(ref_qcoeff); dqcoeff.PrintDifference(ref_dqcoeff); return; } } } TEST_P(VP9QuantizeTest, EOBCheck) { ACMRandom rnd(ACMRandom::DeterministicSeed()); Buffer<tran_low_t> coeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 16); ASSERT_TRUE(coeff.Init()); Buffer<tran_low_t> qcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32); ASSERT_TRUE(qcoeff.Init()); Buffer<tran_low_t> dqcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32); ASSERT_TRUE(dqcoeff.Init()); Buffer<tran_low_t> ref_qcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32); ASSERT_TRUE(ref_qcoeff.Init()); Buffer<tran_low_t> ref_dqcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32); ASSERT_TRUE(ref_dqcoeff.Init()); uint16_t eob, ref_eob; for (int i = 0; i < number_of_iterations; ++i) { const int skip_block = 0; TX_SIZE sz; if (max_size_ == 16) { sz = static_cast<TX_SIZE>(i % 3); // TX_4X4, TX_8X8 TX_16X16 } else { sz = TX_32X32; } const TX_TYPE tx_type = static_cast<TX_TYPE>((i >> 2) % 3); const scan_order *scan_order = &vp9_scan_orders[sz][tx_type]; int count = (4 << sz) * (4 << sz); // Two random entries coeff.Set(0); coeff.TopLeftPixel()[rnd(count)] = static_cast<int>(rnd.RandRange(max_value_ * 2)) - max_value_; coeff.TopLeftPixel()[rnd(count)] = static_cast<int>(rnd.RandRange(max_value_ * 2)) - max_value_; GenerateHelperArrays(&rnd, zbin_ptr_, round_ptr_, quant_ptr_, quant_shift_ptr_, dequant_ptr_, round_fp_ptr_, quant_fp_ptr_); int16_t *r_ptr = (is_fp_) ? round_fp_ptr_ : round_ptr_; int16_t *q_ptr = (is_fp_) ? quant_fp_ptr_ : quant_ptr_; ref_quantize_op_(coeff.TopLeftPixel(), count, skip_block, zbin_ptr_, r_ptr, q_ptr, quant_shift_ptr_, ref_qcoeff.TopLeftPixel(), ref_dqcoeff.TopLeftPixel(), dequant_ptr_, &ref_eob, scan_order->scan, scan_order->iscan); ASM_REGISTER_STATE_CHECK(quantize_op_( coeff.TopLeftPixel(), count, skip_block, zbin_ptr_, r_ptr, q_ptr, quant_shift_ptr_, qcoeff.TopLeftPixel(), dqcoeff.TopLeftPixel(), dequant_ptr_, &eob, scan_order->scan, scan_order->iscan)); EXPECT_TRUE(qcoeff.CheckValues(ref_qcoeff)); EXPECT_TRUE(dqcoeff.CheckValues(ref_dqcoeff)); EXPECT_EQ(eob, ref_eob); if (HasFailure()) { printf("Failure on iteration %d.\n", i); qcoeff.PrintDifference(ref_qcoeff); dqcoeff.PrintDifference(ref_dqcoeff); return; } } } TEST_P(VP9QuantizeTest, DISABLED_Speed) { ACMRandom rnd(ACMRandom::DeterministicSeed()); Buffer<tran_low_t> coeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 16); ASSERT_TRUE(coeff.Init()); Buffer<tran_low_t> qcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32); ASSERT_TRUE(qcoeff.Init()); Buffer<tran_low_t> dqcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32); ASSERT_TRUE(dqcoeff.Init()); uint16_t eob; TX_SIZE starting_sz, ending_sz; if (max_size_ == 16) { starting_sz = TX_4X4; ending_sz = TX_16X16; } else { starting_sz = TX_32X32; ending_sz = TX_32X32; } for (TX_SIZE sz = starting_sz; sz <= ending_sz; ++sz) { // zbin > coeff, zbin < coeff. for (int i = 0; i < 2; ++i) { const int skip_block = 0; // TX_TYPE defines the scan order. That is not relevant to the speed test. // Pick the first one. const TX_TYPE tx_type = DCT_DCT; const scan_order *scan_order = &vp9_scan_orders[sz][tx_type]; const int count = (4 << sz) * (4 << sz); GenerateHelperArrays(&rnd, zbin_ptr_, round_ptr_, quant_ptr_, quant_shift_ptr_, dequant_ptr_, round_fp_ptr_, quant_fp_ptr_); int16_t *r_ptr = (is_fp_) ? round_fp_ptr_ : round_ptr_; int16_t *q_ptr = (is_fp_) ? quant_fp_ptr_ : quant_ptr_; if (i == 0) { // When |coeff values| are less than zbin the results are 0. int threshold = 100; if (max_size_ == 32) { // For 32x32, the threshold is halved. Double it to keep the values // from clearing it. threshold = 200; } for (int j = 0; j < 8; ++j) zbin_ptr_[j] = threshold; coeff.Set(&rnd, -99, 99); } else if (i == 1) { for (int j = 0; j < 8; ++j) zbin_ptr_[j] = 50; coeff.Set(&rnd, -500, 500); } vpx_usec_timer timer; vpx_usec_timer_start(&timer); for (int j = 0; j < 100000000 / count; ++j) { quantize_op_(coeff.TopLeftPixel(), count, skip_block, zbin_ptr_, r_ptr, q_ptr, quant_shift_ptr_, qcoeff.TopLeftPixel(), dqcoeff.TopLeftPixel(), dequant_ptr_, &eob, scan_order->scan, scan_order->iscan); } vpx_usec_timer_mark(&timer); const int elapsed_time = static_cast<int>(vpx_usec_timer_elapsed(&timer)); if (i == 0) printf("Bypass calculations.\n"); if (i == 1) printf("Full calculations.\n"); printf("Quantize %dx%d time: %5d ms\n", 4 << sz, 4 << sz, elapsed_time / 1000); } printf("\n"); } } using ::testing::make_tuple; #if HAVE_SSE2 #if CONFIG_VP9_HIGHBITDEPTH // TODO(johannkoenig): Fix vpx_quantize_b_sse2 in highbitdepth builds. // make_tuple(&vpx_quantize_b_sse2, &vpx_highbd_quantize_b_c, VPX_BITS_8), INSTANTIATE_TEST_CASE_P( SSE2, VP9QuantizeTest, ::testing::Values( make_tuple(&vpx_highbd_quantize_b_sse2, &vpx_highbd_quantize_b_c, VPX_BITS_8, 16, false), make_tuple(&vpx_highbd_quantize_b_sse2, &vpx_highbd_quantize_b_c, VPX_BITS_10, 16, false), make_tuple(&vpx_highbd_quantize_b_sse2, &vpx_highbd_quantize_b_c, VPX_BITS_12, 16, false), make_tuple(&vpx_highbd_quantize_b_32x32_sse2, &vpx_highbd_quantize_b_32x32_c, VPX_BITS_8, 32, false), make_tuple(&vpx_highbd_quantize_b_32x32_sse2, &vpx_highbd_quantize_b_32x32_c, VPX_BITS_10, 32, false), make_tuple(&vpx_highbd_quantize_b_32x32_sse2, &vpx_highbd_quantize_b_32x32_c, VPX_BITS_12, 32, false))); #else INSTANTIATE_TEST_CASE_P( SSE2, VP9QuantizeTest, ::testing::Values(make_tuple(&vpx_quantize_b_sse2, &vpx_quantize_b_c, VPX_BITS_8, 16, false), make_tuple(&QuantFPWrapper<vp9_quantize_fp_sse2>, &QuantFPWrapper<quantize_fp_nz_c>, VPX_BITS_8, 16, true))); #endif // CONFIG_VP9_HIGHBITDEPTH #endif // HAVE_SSE2 #if HAVE_SSSE3 && !CONFIG_VP9_HIGHBITDEPTH #if ARCH_X86_64 INSTANTIATE_TEST_CASE_P( SSSE3, VP9QuantizeTest, ::testing::Values(make_tuple(&vpx_quantize_b_ssse3, &vpx_quantize_b_c, VPX_BITS_8, 16, false), make_tuple(&QuantFPWrapper<vp9_quantize_fp_ssse3>, &QuantFPWrapper<quantize_fp_nz_c>, VPX_BITS_8, 16, true), make_tuple(&QuantFPWrapper<vp9_quantize_fp_32x32_ssse3>, &QuantFPWrapper<quantize_fp_32x32_nz_c>, VPX_BITS_8, 32, true))); #else INSTANTIATE_TEST_CASE_P(SSSE3, VP9QuantizeTest, ::testing::Values(make_tuple(&vpx_quantize_b_ssse3, &vpx_quantize_b_c, VPX_BITS_8, 16, false))); #endif #if ARCH_X86_64 // TODO(johannkoenig): SSSE3 optimizations do not yet pass this test. INSTANTIATE_TEST_CASE_P(DISABLED_SSSE3, VP9QuantizeTest, ::testing::Values(make_tuple( &vpx_quantize_b_32x32_ssse3, &vpx_quantize_b_32x32_c, VPX_BITS_8, 32, false))); #endif // ARCH_X86_64 #endif // HAVE_SSSE3 && !CONFIG_VP9_HIGHBITDEPTH // TODO(johannkoenig): AVX optimizations do not yet pass the 32x32 test or // highbitdepth configurations. #if HAVE_AVX && !CONFIG_VP9_HIGHBITDEPTH INSTANTIATE_TEST_CASE_P( AVX, VP9QuantizeTest, ::testing::Values(make_tuple(&vpx_quantize_b_avx, &vpx_quantize_b_c, VPX_BITS_8, 16, false), // Even though SSSE3 and AVX do not match the reference // code, we can keep them in sync with each other. make_tuple(&vpx_quantize_b_32x32_avx, &vpx_quantize_b_32x32_ssse3, VPX_BITS_8, 32, false))); #endif // HAVE_AVX && !CONFIG_VP9_HIGHBITDEPTH #if ARCH_X86_64 && HAVE_AVX2 INSTANTIATE_TEST_CASE_P( AVX2, VP9QuantizeTest, ::testing::Values(make_tuple(&QuantFPWrapper<vp9_quantize_fp_avx2>, &QuantFPWrapper<quantize_fp_nz_c>, VPX_BITS_8, 16, true))); #endif // HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH // TODO(webm:1448): dqcoeff is not handled correctly in HBD builds. #if HAVE_NEON && !CONFIG_VP9_HIGHBITDEPTH INSTANTIATE_TEST_CASE_P( NEON, VP9QuantizeTest, ::testing::Values(make_tuple(&vpx_quantize_b_neon, &vpx_quantize_b_c, VPX_BITS_8, 16, false), make_tuple(&vpx_quantize_b_32x32_neon, &vpx_quantize_b_32x32_c, VPX_BITS_8, 32, false), make_tuple(&QuantFPWrapper<vp9_quantize_fp_neon>, &QuantFPWrapper<vp9_quantize_fp_c>, VPX_BITS_8, 16, true), make_tuple(&QuantFPWrapper<vp9_quantize_fp_32x32_neon>, &QuantFPWrapper<vp9_quantize_fp_32x32_c>, VPX_BITS_8, 32, true))); #endif // HAVE_NEON && !CONFIG_VP9_HIGHBITDEPTH #if HAVE_VSX && !CONFIG_VP9_HIGHBITDEPTH INSTANTIATE_TEST_CASE_P(VSX, VP9QuantizeTest, ::testing::Values(make_tuple(&vpx_quantize_b_vsx, &vpx_quantize_b_c, VPX_BITS_8, 16, false), make_tuple(&vpx_quantize_b_32x32_vsx, &vpx_quantize_b_32x32_c, VPX_BITS_8, 32, false))); #endif // HAVE_VSX && !CONFIG_VP9_HIGHBITDEPTH // Only useful to compare "Speed" test results. INSTANTIATE_TEST_CASE_P( DISABLED_C, VP9QuantizeTest, ::testing::Values( make_tuple(&vpx_quantize_b_c, &vpx_quantize_b_c, VPX_BITS_8, 16, false), make_tuple(&vpx_quantize_b_32x32_c, &vpx_quantize_b_32x32_c, VPX_BITS_8, 32, false), make_tuple(&QuantFPWrapper<vp9_quantize_fp_c>, &QuantFPWrapper<vp9_quantize_fp_c>, VPX_BITS_8, 16, true), make_tuple(&QuantFPWrapper<quantize_fp_nz_c>, &QuantFPWrapper<quantize_fp_nz_c>, VPX_BITS_8, 16, true), make_tuple(&QuantFPWrapper<quantize_fp_32x32_nz_c>, &QuantFPWrapper<quantize_fp_32x32_nz_c>, VPX_BITS_8, 32, true), make_tuple(&QuantFPWrapper<vp9_quantize_fp_32x32_c>, &QuantFPWrapper<vp9_quantize_fp_32x32_c>, VPX_BITS_8, 32, true))); } // namespace
40.284014
80
0.615781
zipated
3393c2e5e346e56e56e54c1a428f3a9e3110f643
3,341
cpp
C++
bindings/java/LSFJava/jni/XControllerServiceManagerCallback.cpp
alljoyn/lighting-apps
f423a252d64cbd41d575dcfe554a1cb5b49fa307
[ "Apache-2.0" ]
null
null
null
bindings/java/LSFJava/jni/XControllerServiceManagerCallback.cpp
alljoyn/lighting-apps
f423a252d64cbd41d575dcfe554a1cb5b49fa307
[ "Apache-2.0" ]
null
null
null
bindings/java/LSFJava/jni/XControllerServiceManagerCallback.cpp
alljoyn/lighting-apps
f423a252d64cbd41d575dcfe554a1cb5b49fa307
[ "Apache-2.0" ]
null
null
null
/****************************************************************************** * Copyright (c) Open Connectivity Foundation (OCF), AllJoyn Open Source * Project (AJOSP) Contributors and others. * * SPDX-License-Identifier: Apache-2.0 * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Apache License, Version 2.0 * which accompanies this distribution, and is available at * http://www.apache.org/licenses/LICENSE-2.0 * * Copyright (c) Open Connectivity Foundation and Contributors to AllSeen * Alliance. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * ******************************************************************************/ #include <qcc/Debug.h> #include "XJavaDelegator.h" #include "XControllerServiceManagerCallback.h" #define QCC_MODULE "AJN-LSF-JNI" namespace lsf { XControllerServiceManagerCallback::XControllerServiceManagerCallback(jobject jobj) { // Get the JNIEnv for the current native thread JScopedEnv env; /* * Be careful when using a weak global reference. They can only be * passed to NewLocalRef, NewGlobalRef and DeleteWeakGlobalRef. */ QCC_DbgPrintf(("Taking weak global reference to Java object %p", jobj)); jdelegate = env->NewWeakGlobalRef(jobj); if (env->ExceptionCheck() || !jdelegate) { QCC_LogError(ER_FAIL, ("NewWeakGlobalRef() failed")); return; } } XControllerServiceManagerCallback::~XControllerServiceManagerCallback() { // Get the JNIEnv for the current native thread JScopedEnv env; env->DeleteWeakGlobalRef(jdelegate); if (env->ExceptionCheck()) { QCC_LogError(ER_FAIL, ("DeleteWeakGlobalRef() failed")); return; } } void XControllerServiceManagerCallback::GetControllerServiceVersionReplyCB(const uint32_t& version) { XJavaDelegator::Call_Void_UInt32(jdelegate, __func__, version); } void XControllerServiceManagerCallback::LightingResetControllerServiceReplyCB(const LSFResponseCode& responseCode) { XJavaDelegator::Call_Void_ResponseCode(jdelegate, __func__, responseCode); } void XControllerServiceManagerCallback::ControllerServiceLightingResetCB(void) { XJavaDelegator::Call_Void(jdelegate, __func__); } void XControllerServiceManagerCallback::ControllerServiceNameChangedCB(const LSFString& controllerServiceDeviceID, const LSFString& controllerServiceName) { XJavaDelegator::Call_Void_String_String(jdelegate, __func__, controllerServiceDeviceID, controllerServiceName); } } /* namespace lsf */
37.539326
154
0.709368
alljoyn
33945075e34bacee54c2f5c3effe95f5674874e5
3,225
cpp
C++
src/MushGame/MushGameMessageControlInfo.cpp
quimnuss/adanaxis
a04eb945fe808aeb9be5da305a37ff47e04dd006
[ "MIT" ]
null
null
null
src/MushGame/MushGameMessageControlInfo.cpp
quimnuss/adanaxis
a04eb945fe808aeb9be5da305a37ff47e04dd006
[ "MIT" ]
null
null
null
src/MushGame/MushGameMessageControlInfo.cpp
quimnuss/adanaxis
a04eb945fe808aeb9be5da305a37ff47e04dd006
[ "MIT" ]
null
null
null
//%Header { /***************************************************************************** * * File: src/MushGame/MushGameMessageControlInfo.cpp * * Author: Andy Southgate 2002-2005 * * This file contains original work by Andy Southgate. The author and his * employer (Mushware Limited) irrevocably waive all of their copyright rights * vested in this particular version of this file to the furthest extent * permitted. The author and Mushware Limited also irrevocably waive any and * all of their intellectual property rights arising from said file and its * creation that would otherwise restrict the rights of any party to use and/or * distribute the use of, the techniques and methods used herein. A written * waiver can be obtained via http://www.mushware.com/. * * This software carries NO WARRANTY of any kind. * ****************************************************************************/ //%Header } w1/s8yA5XXvqhMRSZQYCrg /* * $Id: MushGameMessageControlInfo.cpp,v 1.1 2005/07/06 19:08:27 southa Exp $ * $Log: MushGameMessageControlInfo.cpp,v $ * Revision 1.1 2005/07/06 19:08:27 southa * Adanaxis control work * */ #include "MushGameMessageControlInfo.h" //%outOfLineFunctions { const char *MushGameMessageControlInfo::AutoName(void) const { return "MushGameMessageControlInfo"; } MushcoreVirtualObject *MushGameMessageControlInfo::AutoClone(void) const { return new MushGameMessageControlInfo(*this); } MushcoreVirtualObject *MushGameMessageControlInfo::AutoCreate(void) const { return new MushGameMessageControlInfo; } MushcoreVirtualObject *MushGameMessageControlInfo::AutoVirtualFactory(void) { return new MushGameMessageControlInfo; } namespace { void AutoInstall(void) { MushcoreFactory::Sgl().FactoryAdd("MushGameMessageControlInfo", MushGameMessageControlInfo::AutoVirtualFactory); } MushcoreInstaller AutoInstaller(AutoInstall); } // end anonymous namespace void MushGameMessageControlInfo::AutoPrint(std::ostream& ioOut) const { ioOut << "["; MushGameMessage::AutoPrint(ioOut); ioOut << "timestamp=" << m_timestamp << ", "; ioOut << "axisEvents=" << m_axisEvents << ", "; ioOut << "keyEvents=" << m_keyEvents; ioOut << "]"; } bool MushGameMessageControlInfo::AutoXMLDataProcess(MushcoreXMLIStream& ioIn, const std::string& inTagStr) { if (inTagStr == "obj") { AutoInputPrologue(ioIn); ioIn >> *this; AutoInputEpilogue(ioIn); } else if (inTagStr == "timestamp") { ioIn >> m_timestamp; } else if (inTagStr == "axisEvents") { ioIn >> m_axisEvents; } else if (inTagStr == "keyEvents") { ioIn >> m_keyEvents; } else if (MushGameMessage::AutoXMLDataProcess(ioIn, inTagStr)) { // Tag consumed by base class } else { return false; } return true; } void MushGameMessageControlInfo::AutoXMLPrint(MushcoreXMLOStream& ioOut) const { MushGameMessage::AutoXMLPrint(ioOut); ioOut.TagSet("timestamp"); ioOut << m_timestamp; ioOut.TagSet("axisEvents"); ioOut << m_axisEvents; ioOut.TagSet("keyEvents"); ioOut << m_keyEvents; } //%outOfLineFunctions } 2pzNQJVGzbzqSBE8BGC1KA
28.794643
116
0.674419
quimnuss
33949f698540e0c307de44ebe94117d7d98436bd
95,213
cpp
C++
HotSpot1.7-JVM-Linux-x86/src/share/vm/adlc/output_h.cpp
codefollower/Open-Source-Research
b9f2aed9d0f060b80be45f713c3d48fe91f247b2
[ "Apache-2.0" ]
184
2015-01-04T03:38:20.000Z
2022-03-30T05:47:21.000Z
HotSpot1.7/src/share/vm/adlc/output_h.cpp
doczyw/Open-Source-Research
b9f2aed9d0f060b80be45f713c3d48fe91f247b2
[ "Apache-2.0" ]
1
2016-01-17T09:18:17.000Z
2016-01-17T09:18:17.000Z
HotSpot1.7/src/share/vm/adlc/output_h.cpp
doczyw/Open-Source-Research
b9f2aed9d0f060b80be45f713c3d48fe91f247b2
[ "Apache-2.0" ]
101
2015-01-16T23:46:31.000Z
2022-03-30T05:47:06.000Z
/* * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ // output_h.cpp - Class HPP file output routines for architecture definition #include "adlc.hpp" // The comment delimiter used in format statements after assembler instructions. #define commentSeperator "!" // Generate the #define that describes the number of registers. static void defineRegCount(FILE *fp, RegisterForm *registers) { if (registers) { int regCount = AdlcVMDeps::Physical + registers->_rdefs.count(); fprintf(fp,"\n"); fprintf(fp,"// the number of reserved registers + machine registers.\n"); fprintf(fp,"#define REG_COUNT %d\n", regCount); } } // Output enumeration of machine register numbers // (1) // // Enumerate machine registers starting after reserved regs. // // in the order of occurrence in the register block. // enum MachRegisterNumbers { // EAX_num = 0, // ... // _last_Mach_Reg // } void ArchDesc::buildMachRegisterNumbers(FILE *fp_hpp) { if (_register) { RegDef *reg_def = NULL; // Output a #define for the number of machine registers defineRegCount(fp_hpp, _register); // Count all the Save_On_Entry and Always_Save registers int saved_on_entry = 0; int c_saved_on_entry = 0; _register->reset_RegDefs(); while( (reg_def = _register->iter_RegDefs()) != NULL ) { if( strcmp(reg_def->_callconv,"SOE") == 0 || strcmp(reg_def->_callconv,"AS") == 0 ) ++saved_on_entry; if( strcmp(reg_def->_c_conv,"SOE") == 0 || strcmp(reg_def->_c_conv,"AS") == 0 ) ++c_saved_on_entry; } fprintf(fp_hpp, "\n"); fprintf(fp_hpp, "// the number of save_on_entry + always_saved registers.\n"); fprintf(fp_hpp, "#define MAX_SAVED_ON_ENTRY_REG_COUNT %d\n", max(saved_on_entry,c_saved_on_entry)); fprintf(fp_hpp, "#define SAVED_ON_ENTRY_REG_COUNT %d\n", saved_on_entry); fprintf(fp_hpp, "#define C_SAVED_ON_ENTRY_REG_COUNT %d\n", c_saved_on_entry); // (1) // Build definition for enumeration of register numbers fprintf(fp_hpp, "\n"); fprintf(fp_hpp, "// Enumerate machine register numbers starting after reserved regs.\n"); fprintf(fp_hpp, "// in the order of occurrence in the register block.\n"); fprintf(fp_hpp, "enum MachRegisterNumbers {\n"); // Output the register number for each register in the allocation classes _register->reset_RegDefs(); int i = 0; while( (reg_def = _register->iter_RegDefs()) != NULL ) { fprintf(fp_hpp," %s_num,", reg_def->_regname); for (int j = 0; j < 20-(int)strlen(reg_def->_regname); j++) fprintf(fp_hpp, " "); fprintf(fp_hpp," // enum %3d, regnum %3d, reg encode %3s\n", i++, reg_def->register_num(), reg_def->register_encode()); } // Finish defining enumeration fprintf(fp_hpp, " _last_Mach_Reg // %d\n", i); fprintf(fp_hpp, "};\n"); } fprintf(fp_hpp, "\n// Size of register-mask in ints\n"); fprintf(fp_hpp, "#define RM_SIZE %d\n",RegisterForm::RegMask_Size()); fprintf(fp_hpp, "// Unroll factor for loops over the data in a RegMask\n"); fprintf(fp_hpp, "#define FORALL_BODY "); int len = RegisterForm::RegMask_Size(); for( int i = 0; i < len; i++ ) fprintf(fp_hpp, "BODY(%d) ",i); fprintf(fp_hpp, "\n\n"); fprintf(fp_hpp,"class RegMask;\n"); // All RegMasks are declared "extern const ..." in ad_<arch>.hpp // fprintf(fp_hpp,"extern RegMask STACK_OR_STACK_SLOTS_mask;\n\n"); } // Output enumeration of machine register encodings // (2) // // Enumerate machine registers starting after reserved regs. // // in the order of occurrence in the alloc_class(es). // enum MachRegisterEncodes { // EAX_enc = 0x00, // ... // } void ArchDesc::buildMachRegisterEncodes(FILE *fp_hpp) { if (_register) { RegDef *reg_def = NULL; RegDef *reg_def_next = NULL; // (2) // Build definition for enumeration of encode values fprintf(fp_hpp, "\n"); fprintf(fp_hpp, "// Enumerate machine registers starting after reserved regs.\n"); fprintf(fp_hpp, "// in the order of occurrence in the alloc_class(es).\n"); fprintf(fp_hpp, "enum MachRegisterEncodes {\n"); // Find max enum string length. size_t maxlen = 0; _register->reset_RegDefs(); reg_def = _register->iter_RegDefs(); while (reg_def != NULL) { size_t len = strlen(reg_def->_regname); if (len > maxlen) maxlen = len; reg_def = _register->iter_RegDefs(); } // Output the register encoding for each register in the allocation classes _register->reset_RegDefs(); reg_def_next = _register->iter_RegDefs(); while( (reg_def = reg_def_next) != NULL ) { reg_def_next = _register->iter_RegDefs(); fprintf(fp_hpp," %s_enc", reg_def->_regname); for (size_t i = strlen(reg_def->_regname); i < maxlen; i++) fprintf(fp_hpp, " "); fprintf(fp_hpp," = %3s%s\n", reg_def->register_encode(), reg_def_next == NULL? "" : "," ); } // Finish defining enumeration fprintf(fp_hpp, "};\n"); } // Done with register form } // Declare an array containing the machine register names, strings. static void declareRegNames(FILE *fp, RegisterForm *registers) { if (registers) { // fprintf(fp,"\n"); // fprintf(fp,"// An array of character pointers to machine register names.\n"); // fprintf(fp,"extern const char *regName[];\n"); } } // Declare an array containing the machine register sizes in 32-bit words. void ArchDesc::declareRegSizes(FILE *fp) { // regSize[] is not used } // Declare an array containing the machine register encoding values static void declareRegEncodes(FILE *fp, RegisterForm *registers) { if (registers) { // // // // fprintf(fp,"\n"); // fprintf(fp,"// An array containing the machine register encode values\n"); // fprintf(fp,"extern const char regEncode[];\n"); } } // --------------------------------------------------------------------------- //------------------------------Utilities to build Instruction Classes-------- // --------------------------------------------------------------------------- static void out_RegMask(FILE *fp) { fprintf(fp," virtual const RegMask &out_RegMask() const;\n"); } // --------------------------------------------------------------------------- //--------Utilities to build MachOper and MachNode derived Classes------------ // --------------------------------------------------------------------------- //------------------------------Utilities to build Operand Classes------------ static void in_RegMask(FILE *fp) { fprintf(fp," virtual const RegMask *in_RegMask(int index) const;\n"); } static void declareConstStorage(FILE *fp, FormDict &globals, OperandForm *oper) { int i = 0; Component *comp; if (oper->num_consts(globals) == 0) return; // Iterate over the component list looking for constants oper->_components.reset(); if ((comp = oper->_components.iter()) == NULL) { assert(oper->num_consts(globals) == 1, "Bad component list detected.\n"); const char *type = oper->ideal_type(globals); if (!strcmp(type, "ConI")) { if (i > 0) fprintf(fp,", "); fprintf(fp," int32 _c%d;\n", i); } else if (!strcmp(type, "ConP")) { if (i > 0) fprintf(fp,", "); fprintf(fp," const TypePtr *_c%d;\n", i); } else if (!strcmp(type, "ConN")) { if (i > 0) fprintf(fp,", "); fprintf(fp," const TypeNarrowOop *_c%d;\n", i); } else if (!strcmp(type, "ConL")) { if (i > 0) fprintf(fp,", "); fprintf(fp," jlong _c%d;\n", i); } else if (!strcmp(type, "ConF")) { if (i > 0) fprintf(fp,", "); fprintf(fp," jfloat _c%d;\n", i); } else if (!strcmp(type, "ConD")) { if (i > 0) fprintf(fp,", "); fprintf(fp," jdouble _c%d;\n", i); } else if (!strcmp(type, "Bool")) { fprintf(fp,"private:\n"); fprintf(fp," BoolTest::mask _c%d;\n", i); fprintf(fp,"public:\n"); } else { assert(0, "Non-constant operand lacks component list."); } } // end if NULL else { oper->_components.reset(); while ((comp = oper->_components.iter()) != NULL) { if (!strcmp(comp->base_type(globals), "ConI")) { fprintf(fp," jint _c%d;\n", i); i++; } else if (!strcmp(comp->base_type(globals), "ConP")) { fprintf(fp," const TypePtr *_c%d;\n", i); i++; } else if (!strcmp(comp->base_type(globals), "ConN")) { fprintf(fp," const TypePtr *_c%d;\n", i); i++; } else if (!strcmp(comp->base_type(globals), "ConL")) { fprintf(fp," jlong _c%d;\n", i); i++; } else if (!strcmp(comp->base_type(globals), "ConF")) { fprintf(fp," jfloat _c%d;\n", i); i++; } else if (!strcmp(comp->base_type(globals), "ConD")) { fprintf(fp," jdouble _c%d;\n", i); i++; } } } } // Declare constructor. // Parameters start with condition code, then all other constants // // (0) public: // (1) MachXOper(int32 ccode, int32 c0, int32 c1, ..., int32 cn) // (2) : _ccode(ccode), _c0(c0), _c1(c1), ..., _cn(cn) { } // static void defineConstructor(FILE *fp, const char *name, uint num_consts, ComponentList &lst, bool is_ideal_bool, Form::DataType constant_type, FormDict &globals) { fprintf(fp,"public:\n"); // generate line (1) fprintf(fp," %sOper(", name); if( num_consts == 0 ) { fprintf(fp,") {}\n"); return; } // generate parameters for constants uint i = 0; Component *comp; lst.reset(); if ((comp = lst.iter()) == NULL) { assert(num_consts == 1, "Bad component list detected.\n"); switch( constant_type ) { case Form::idealI : { fprintf(fp,is_ideal_bool ? "BoolTest::mask c%d" : "int32 c%d", i); break; } case Form::idealN : { fprintf(fp,"const TypeNarrowOop *c%d", i); break; } case Form::idealP : { fprintf(fp,"const TypePtr *c%d", i); break; } case Form::idealL : { fprintf(fp,"jlong c%d", i); break; } case Form::idealF : { fprintf(fp,"jfloat c%d", i); break; } case Form::idealD : { fprintf(fp,"jdouble c%d", i); break; } default: assert(!is_ideal_bool, "Non-constant operand lacks component list."); break; } } // end if NULL else { lst.reset(); while((comp = lst.iter()) != NULL) { if (!strcmp(comp->base_type(globals), "ConI")) { if (i > 0) fprintf(fp,", "); fprintf(fp,"int32 c%d", i); i++; } else if (!strcmp(comp->base_type(globals), "ConP")) { if (i > 0) fprintf(fp,", "); fprintf(fp,"const TypePtr *c%d", i); i++; } else if (!strcmp(comp->base_type(globals), "ConN")) { if (i > 0) fprintf(fp,", "); fprintf(fp,"const TypePtr *c%d", i); i++; } else if (!strcmp(comp->base_type(globals), "ConL")) { if (i > 0) fprintf(fp,", "); fprintf(fp,"jlong c%d", i); i++; } else if (!strcmp(comp->base_type(globals), "ConF")) { if (i > 0) fprintf(fp,", "); fprintf(fp,"jfloat c%d", i); i++; } else if (!strcmp(comp->base_type(globals), "ConD")) { if (i > 0) fprintf(fp,", "); fprintf(fp,"jdouble c%d", i); i++; } else if (!strcmp(comp->base_type(globals), "Bool")) { if (i > 0) fprintf(fp,", "); fprintf(fp,"BoolTest::mask c%d", i); i++; } } } // finish line (1) and start line (2) fprintf(fp,") : "); // generate initializers for constants i = 0; fprintf(fp,"_c%d(c%d)", i, i); for( i = 1; i < num_consts; ++i) { fprintf(fp,", _c%d(c%d)", i, i); } // The body for the constructor is empty fprintf(fp," {}\n"); } // --------------------------------------------------------------------------- // Utilities to generate format rules for machine operands and instructions // --------------------------------------------------------------------------- // Generate the format rule for condition codes static void defineCCodeDump(OperandForm* oper, FILE *fp, int i) { assert(oper != NULL, "what"); CondInterface* cond = oper->_interface->is_CondInterface(); fprintf(fp, " if( _c%d == BoolTest::eq ) st->print(\"%s\");\n",i,cond->_equal_format); fprintf(fp, " else if( _c%d == BoolTest::ne ) st->print(\"%s\");\n",i,cond->_not_equal_format); fprintf(fp, " else if( _c%d == BoolTest::le ) st->print(\"%s\");\n",i,cond->_less_equal_format); fprintf(fp, " else if( _c%d == BoolTest::ge ) st->print(\"%s\");\n",i,cond->_greater_equal_format); fprintf(fp, " else if( _c%d == BoolTest::lt ) st->print(\"%s\");\n",i,cond->_less_format); fprintf(fp, " else if( _c%d == BoolTest::gt ) st->print(\"%s\");\n",i,cond->_greater_format); } // Output code that dumps constant values, increment "i" if type is constant static uint dump_spec_constant(FILE *fp, const char *ideal_type, uint i, OperandForm* oper) { if (!strcmp(ideal_type, "ConI")) { fprintf(fp," st->print(\"#%%d\", _c%d);\n", i); fprintf(fp," st->print(\"/0x%%08x\", _c%d);\n", i); ++i; } else if (!strcmp(ideal_type, "ConP")) { fprintf(fp," _c%d->dump_on(st);\n", i); ++i; } else if (!strcmp(ideal_type, "ConN")) { fprintf(fp," _c%d->dump_on(st);\n", i); ++i; } else if (!strcmp(ideal_type, "ConL")) { fprintf(fp," st->print(\"#\" INT64_FORMAT, _c%d);\n", i); fprintf(fp," st->print(\"/\" PTR64_FORMAT, _c%d);\n", i); ++i; } else if (!strcmp(ideal_type, "ConF")) { fprintf(fp," st->print(\"#%%f\", _c%d);\n", i); fprintf(fp," jint _c%di = JavaValue(_c%d).get_jint();\n", i, i); fprintf(fp," st->print(\"/0x%%x/\", _c%di);\n", i); ++i; } else if (!strcmp(ideal_type, "ConD")) { fprintf(fp," st->print(\"#%%f\", _c%d);\n", i); fprintf(fp," jlong _c%dl = JavaValue(_c%d).get_jlong();\n", i, i); fprintf(fp," st->print(\"/\" PTR64_FORMAT, _c%dl);\n", i); ++i; } else if (!strcmp(ideal_type, "Bool")) { defineCCodeDump(oper, fp,i); ++i; } return i; } // Generate the format rule for an operand void gen_oper_format(FILE *fp, FormDict &globals, OperandForm &oper, bool for_c_file = false) { if (!for_c_file) { // invoked after output #ifndef PRODUCT to ad_<arch>.hpp // compile the bodies separately, to cut down on recompilations fprintf(fp," virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const;\n"); fprintf(fp," virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const;\n"); return; } // Local pointer indicates remaining part of format rule int idx = 0; // position of operand in match rule // Generate internal format function, used when stored locally fprintf(fp, "\n#ifndef PRODUCT\n"); fprintf(fp,"void %sOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const {\n", oper._ident); // Generate the user-defined portion of the format if (oper._format) { if ( oper._format->_strings.count() != 0 ) { // No initialization code for int_format // Build the format from the entries in strings and rep_vars const char *string = NULL; oper._format->_rep_vars.reset(); oper._format->_strings.reset(); while ( (string = oper._format->_strings.iter()) != NULL ) { // Check if this is a standard string or a replacement variable if ( string != NameList::_signal ) { // Normal string // Pass through to st->print fprintf(fp," st->print(\"%s\");\n", string); } else { // Replacement variable const char *rep_var = oper._format->_rep_vars.iter(); // Check that it is a local name, and an operand const Form* form = oper._localNames[rep_var]; if (form == NULL) { globalAD->syntax_err(oper._linenum, "\'%s\' not found in format for %s\n", rep_var, oper._ident); assert(form, "replacement variable was not found in local names"); } OperandForm *op = form->is_operand(); // Get index if register or constant if ( op->_matrule && op->_matrule->is_base_register(globals) ) { idx = oper.register_position( globals, rep_var); } else if (op->_matrule && op->_matrule->is_base_constant(globals)) { idx = oper.constant_position( globals, rep_var); } else { idx = 0; } // output invocation of "$..."s format function if ( op != NULL ) op->int_format(fp, globals, idx); if ( idx == -1 ) { fprintf(stderr, "Using a name, %s, that isn't in match rule\n", rep_var); assert( strcmp(op->_ident,"label")==0, "Unimplemented"); } } // Done with a replacement variable } // Done with all format strings } else { // Default formats for base operands (RegI, RegP, ConI, ConP, ...) oper.int_format(fp, globals, 0); } } else { // oper._format == NULL // Provide a few special case formats where the AD writer cannot. if ( strcmp(oper._ident,"Universe")==0 ) { fprintf(fp, " st->print(\"$$univ\");\n"); } // labelOper::int_format is defined in ad_<...>.cpp } // ALWAYS! Provide a special case output for condition codes. if( oper.is_ideal_bool() ) { defineCCodeDump(&oper, fp,0); } fprintf(fp,"}\n"); // Generate external format function, when data is stored externally fprintf(fp,"void %sOper::ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const {\n", oper._ident); // Generate the user-defined portion of the format if (oper._format) { if ( oper._format->_strings.count() != 0 ) { // Check for a replacement string "$..." if ( oper._format->_rep_vars.count() != 0 ) { // Initialization code for ext_format } // Build the format from the entries in strings and rep_vars const char *string = NULL; oper._format->_rep_vars.reset(); oper._format->_strings.reset(); while ( (string = oper._format->_strings.iter()) != NULL ) { // Check if this is a standard string or a replacement variable if ( string != NameList::_signal ) { // Normal string // Pass through to st->print fprintf(fp," st->print(\"%s\");\n", string); } else { // Replacement variable const char *rep_var = oper._format->_rep_vars.iter(); // Check that it is a local name, and an operand const Form* form = oper._localNames[rep_var]; if (form == NULL) { globalAD->syntax_err(oper._linenum, "\'%s\' not found in format for %s\n", rep_var, oper._ident); assert(form, "replacement variable was not found in local names"); } OperandForm *op = form->is_operand(); // Get index if register or constant if ( op->_matrule && op->_matrule->is_base_register(globals) ) { idx = oper.register_position( globals, rep_var); } else if (op->_matrule && op->_matrule->is_base_constant(globals)) { idx = oper.constant_position( globals, rep_var); } else { idx = 0; } // output invocation of "$..."s format function if ( op != NULL ) op->ext_format(fp, globals, idx); // Lookup the index position of the replacement variable idx = oper._components.operand_position_format(rep_var, &oper); if ( idx == -1 ) { fprintf(stderr, "Using a name, %s, that isn't in match rule\n", rep_var); assert( strcmp(op->_ident,"label")==0, "Unimplemented"); } } // Done with a replacement variable } // Done with all format strings } else { // Default formats for base operands (RegI, RegP, ConI, ConP, ...) oper.ext_format(fp, globals, 0); } } else { // oper._format == NULL // Provide a few special case formats where the AD writer cannot. if ( strcmp(oper._ident,"Universe")==0 ) { fprintf(fp, " st->print(\"$$univ\");\n"); } // labelOper::ext_format is defined in ad_<...>.cpp } // ALWAYS! Provide a special case output for condition codes. if( oper.is_ideal_bool() ) { defineCCodeDump(&oper, fp,0); } fprintf(fp, "}\n"); fprintf(fp, "#endif\n"); } // Generate the format rule for an instruction void gen_inst_format(FILE *fp, FormDict &globals, InstructForm &inst, bool for_c_file = false) { if (!for_c_file) { // compile the bodies separately, to cut down on recompilations // #ifndef PRODUCT region generated by caller fprintf(fp," virtual void format(PhaseRegAlloc *ra, outputStream *st) const;\n"); return; } // Define the format function fprintf(fp, "#ifndef PRODUCT\n"); fprintf(fp, "void %sNode::format(PhaseRegAlloc *ra, outputStream *st) const {\n", inst._ident); // Generate the user-defined portion of the format if( inst._format ) { // If there are replacement variables, // Generate index values needed for determining the operand position if( inst._format->_rep_vars.count() ) inst.index_temps(fp, globals); // Build the format from the entries in strings and rep_vars const char *string = NULL; inst._format->_rep_vars.reset(); inst._format->_strings.reset(); while( (string = inst._format->_strings.iter()) != NULL ) { fprintf(fp," "); // Check if this is a standard string or a replacement variable if( string == NameList::_signal ) { // Replacement variable const char* rep_var = inst._format->_rep_vars.iter(); inst.rep_var_format( fp, rep_var); } else if( string == NameList::_signal3 ) { // Replacement variable in raw text const char* rep_var = inst._format->_rep_vars.iter(); const Form *form = inst._localNames[rep_var]; if (form == NULL) { fprintf(stderr, "unknown replacement variable in format statement: '%s'\n", rep_var); assert(false, "ShouldNotReachHere()"); } OpClassForm *opc = form->is_opclass(); assert( opc, "replacement variable was not found in local names"); // Lookup the index position of the replacement variable int idx = inst.operand_position_format(rep_var); if ( idx == -1 ) { assert( strcmp(opc->_ident,"label")==0, "Unimplemented"); assert( false, "ShouldNotReachHere()"); } if (inst.is_noninput_operand(idx)) { assert( false, "ShouldNotReachHere()"); } else { // Output the format call for this operand fprintf(fp,"opnd_array(%d)",idx); } rep_var = inst._format->_rep_vars.iter(); inst._format->_strings.iter(); if ( strcmp(rep_var,"$constant") == 0 && opc->is_operand()) { Form::DataType constant_type = form->is_operand()->is_base_constant(globals); if ( constant_type == Form::idealD ) { fprintf(fp,"->constantD()"); } else if ( constant_type == Form::idealF ) { fprintf(fp,"->constantF()"); } else if ( constant_type == Form::idealL ) { fprintf(fp,"->constantL()"); } else { fprintf(fp,"->constant()"); } } else if ( strcmp(rep_var,"$cmpcode") == 0) { fprintf(fp,"->ccode()"); } else { assert( false, "ShouldNotReachHere()"); } } else if( string == NameList::_signal2 ) // Raw program text fputs(inst._format->_strings.iter(), fp); else fprintf(fp,"st->print(\"%s\");\n", string); } // Done with all format strings } // Done generating the user-defined portion of the format // Add call debug info automatically Form::CallType call_type = inst.is_ideal_call(); if( call_type != Form::invalid_type ) { switch( call_type ) { case Form::JAVA_DYNAMIC: fprintf(fp," _method->print_short_name(st);\n"); break; case Form::JAVA_STATIC: fprintf(fp," if( _method ) _method->print_short_name(st);\n"); fprintf(fp," else st->print(\" wrapper for: %%s\", _name);\n"); fprintf(fp," if( !_method ) dump_trap_args(st);\n"); break; case Form::JAVA_COMPILED: case Form::JAVA_INTERP: break; case Form::JAVA_RUNTIME: case Form::JAVA_LEAF: case Form::JAVA_NATIVE: fprintf(fp," st->print(\" %%s\", _name);"); break; default: assert(0,"ShouldNotReachHere"); } fprintf(fp, " st->print_cr(\"\");\n" ); fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" ); fprintf(fp, " st->print(\" # \");\n" ); fprintf(fp, " if( _jvms && _oop_map ) _oop_map->print_on(st);\n"); } else if(inst.is_ideal_safepoint()) { fprintf(fp, " st->print(\"\");\n" ); fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" ); fprintf(fp, " st->print(\" # \");\n" ); fprintf(fp, " if( _jvms && _oop_map ) _oop_map->print_on(st);\n"); } else if( inst.is_ideal_if() ) { fprintf(fp, " st->print(\" P=%%f C=%%f\",_prob,_fcnt);\n" ); } else if( inst.is_ideal_mem() ) { // Print out the field name if available to improve readability fprintf(fp, " if (ra->C->alias_type(adr_type())->field() != NULL) {\n"); fprintf(fp, " ciField* f = ra->C->alias_type(adr_type())->field();\n"); fprintf(fp, " st->print(\" %s Field: \");\n", commentSeperator); fprintf(fp, " if (f->is_volatile())\n"); fprintf(fp, " st->print(\"volatile \");\n"); fprintf(fp, " f->holder()->name()->print_symbol_on(st);\n"); fprintf(fp, " st->print(\".\");\n"); fprintf(fp, " f->name()->print_symbol_on(st);\n"); fprintf(fp, " if (f->is_constant())\n"); fprintf(fp, " st->print(\" (constant)\");\n"); fprintf(fp, " } else {\n"); // Make sure 'Volatile' gets printed out fprintf(fp, " if (ra->C->alias_type(adr_type())->is_volatile())\n"); fprintf(fp, " st->print(\" volatile!\");\n"); fprintf(fp, " }\n"); } // Complete the definition of the format function fprintf(fp, "}\n#endif\n"); } void ArchDesc::declare_pipe_classes(FILE *fp_hpp) { if (!_pipeline) return; fprintf(fp_hpp, "\n"); fprintf(fp_hpp, "// Pipeline_Use_Cycle_Mask Class\n"); fprintf(fp_hpp, "class Pipeline_Use_Cycle_Mask {\n"); if (_pipeline->_maxcycleused <= #ifdef SPARC 64 #else 32 #endif ) { fprintf(fp_hpp, "protected:\n"); fprintf(fp_hpp, " %s _mask;\n\n", _pipeline->_maxcycleused <= 32 ? "uint" : "uint64_t" ); fprintf(fp_hpp, "public:\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask() : _mask(0) {}\n\n"); if (_pipeline->_maxcycleused <= 32) fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint mask) : _mask(mask) {}\n\n"); else { fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint mask1, uint mask2) : _mask((((uint64_t)mask1) << 32) | mask2) {}\n\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint64_t mask) : _mask(mask) {}\n\n"); } fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator=(const Pipeline_Use_Cycle_Mask &in) {\n"); fprintf(fp_hpp, " _mask = in._mask;\n"); fprintf(fp_hpp, " return *this;\n"); fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " bool overlaps(const Pipeline_Use_Cycle_Mask &in2) const {\n"); fprintf(fp_hpp, " return ((_mask & in2._mask) != 0);\n"); fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator<<=(int n) {\n"); fprintf(fp_hpp, " _mask <<= n;\n"); fprintf(fp_hpp, " return *this;\n"); fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " void Or(const Pipeline_Use_Cycle_Mask &in2) {\n"); fprintf(fp_hpp, " _mask |= in2._mask;\n"); fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator&(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n"); fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator|(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n\n"); } else { fprintf(fp_hpp, "protected:\n"); uint masklen = (_pipeline->_maxcycleused + 31) >> 5; uint l; fprintf(fp_hpp, " uint "); for (l = 1; l <= masklen; l++) fprintf(fp_hpp, "_mask%d%s", l, l < masklen ? ", " : ";\n\n"); fprintf(fp_hpp, "public:\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask() : "); for (l = 1; l <= masklen; l++) fprintf(fp_hpp, "_mask%d(0)%s", l, l < masklen ? ", " : " {}\n\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask("); for (l = 1; l <= masklen; l++) fprintf(fp_hpp, "uint mask%d%s", l, l < masklen ? ", " : ") : "); for (l = 1; l <= masklen; l++) fprintf(fp_hpp, "_mask%d(mask%d)%s", l, l, l < masklen ? ", " : " {}\n\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator=(const Pipeline_Use_Cycle_Mask &in) {\n"); for (l = 1; l <= masklen; l++) fprintf(fp_hpp, " _mask%d = in._mask%d;\n", l, l); fprintf(fp_hpp, " return *this;\n"); fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask intersect(const Pipeline_Use_Cycle_Mask &in2) {\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask out;\n"); for (l = 1; l <= masklen; l++) fprintf(fp_hpp, " out._mask%d = _mask%d & in2._mask%d;\n", l, l, l); fprintf(fp_hpp, " return out;\n"); fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " bool overlaps(const Pipeline_Use_Cycle_Mask &in2) const {\n"); fprintf(fp_hpp, " return ("); for (l = 1; l <= masklen; l++) fprintf(fp_hpp, "((_mask%d & in2._mask%d) != 0)%s", l, l, l < masklen ? " || " : ""); fprintf(fp_hpp, ") ? true : false;\n"); fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator<<=(int n) {\n"); fprintf(fp_hpp, " if (n >= 32)\n"); fprintf(fp_hpp, " do {\n "); for (l = masklen; l > 1; l--) fprintf(fp_hpp, " _mask%d = _mask%d;", l, l-1); fprintf(fp_hpp, " _mask%d = 0;\n", 1); fprintf(fp_hpp, " } while ((n -= 32) >= 32);\n\n"); fprintf(fp_hpp, " if (n > 0) {\n"); fprintf(fp_hpp, " uint m = 32 - n;\n"); fprintf(fp_hpp, " uint mask = (1 << n) - 1;\n"); fprintf(fp_hpp, " uint temp%d = mask & (_mask%d >> m); _mask%d <<= n;\n", 2, 1, 1); for (l = 2; l < masklen; l++) { fprintf(fp_hpp, " uint temp%d = mask & (_mask%d >> m); _mask%d <<= n; _mask%d |= temp%d;\n", l+1, l, l, l, l); } fprintf(fp_hpp, " _mask%d <<= n; _mask%d |= temp%d;\n", masklen, masklen, masklen); fprintf(fp_hpp, " }\n"); fprintf(fp_hpp, " return *this;\n"); fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " void Or(const Pipeline_Use_Cycle_Mask &);\n\n"); fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator&(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n"); fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator|(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n\n"); } fprintf(fp_hpp, " friend class Pipeline_Use;\n\n"); fprintf(fp_hpp, " friend class Pipeline_Use_Element;\n\n"); fprintf(fp_hpp, "};\n\n"); uint rescount = 0; const char *resource; for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) { int mask = _pipeline->_resdict[resource]->is_resource()->mask(); if ((mask & (mask-1)) == 0) rescount++; } fprintf(fp_hpp, "// Pipeline_Use_Element Class\n"); fprintf(fp_hpp, "class Pipeline_Use_Element {\n"); fprintf(fp_hpp, "protected:\n"); fprintf(fp_hpp, " // Mask of used functional units\n"); fprintf(fp_hpp, " uint _used;\n\n"); fprintf(fp_hpp, " // Lower and upper bound of functional unit number range\n"); fprintf(fp_hpp, " uint _lb, _ub;\n\n"); fprintf(fp_hpp, " // Indicates multiple functionals units available\n"); fprintf(fp_hpp, " bool _multiple;\n\n"); fprintf(fp_hpp, " // Mask of specific used cycles\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask _mask;\n\n"); fprintf(fp_hpp, "public:\n"); fprintf(fp_hpp, " Pipeline_Use_Element() {}\n\n"); fprintf(fp_hpp, " Pipeline_Use_Element(uint used, uint lb, uint ub, bool multiple, Pipeline_Use_Cycle_Mask mask)\n"); fprintf(fp_hpp, " : _used(used), _lb(lb), _ub(ub), _multiple(multiple), _mask(mask) {}\n\n"); fprintf(fp_hpp, " uint used() const { return _used; }\n\n"); fprintf(fp_hpp, " uint lowerBound() const { return _lb; }\n\n"); fprintf(fp_hpp, " uint upperBound() const { return _ub; }\n\n"); fprintf(fp_hpp, " bool multiple() const { return _multiple; }\n\n"); fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask mask() const { return _mask; }\n\n"); fprintf(fp_hpp, " bool overlaps(const Pipeline_Use_Element &in2) const {\n"); fprintf(fp_hpp, " return ((_used & in2._used) != 0 && _mask.overlaps(in2._mask));\n"); fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " void step(uint cycles) {\n"); fprintf(fp_hpp, " _used = 0;\n"); fprintf(fp_hpp, " _mask <<= cycles;\n"); fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " friend class Pipeline_Use;\n"); fprintf(fp_hpp, "};\n\n"); fprintf(fp_hpp, "// Pipeline_Use Class\n"); fprintf(fp_hpp, "class Pipeline_Use {\n"); fprintf(fp_hpp, "protected:\n"); fprintf(fp_hpp, " // These resources can be used\n"); fprintf(fp_hpp, " uint _resources_used;\n\n"); fprintf(fp_hpp, " // These resources are used; excludes multiple choice functional units\n"); fprintf(fp_hpp, " uint _resources_used_exclusively;\n\n"); fprintf(fp_hpp, " // Number of elements\n"); fprintf(fp_hpp, " uint _count;\n\n"); fprintf(fp_hpp, " // This is the array of Pipeline_Use_Elements\n"); fprintf(fp_hpp, " Pipeline_Use_Element * _elements;\n\n"); fprintf(fp_hpp, "public:\n"); fprintf(fp_hpp, " Pipeline_Use(uint resources_used, uint resources_used_exclusively, uint count, Pipeline_Use_Element *elements)\n"); fprintf(fp_hpp, " : _resources_used(resources_used)\n"); fprintf(fp_hpp, " , _resources_used_exclusively(resources_used_exclusively)\n"); fprintf(fp_hpp, " , _count(count)\n"); fprintf(fp_hpp, " , _elements(elements)\n"); fprintf(fp_hpp, " {}\n\n"); fprintf(fp_hpp, " uint resourcesUsed() const { return _resources_used; }\n\n"); fprintf(fp_hpp, " uint resourcesUsedExclusively() const { return _resources_used_exclusively; }\n\n"); fprintf(fp_hpp, " uint count() const { return _count; }\n\n"); fprintf(fp_hpp, " Pipeline_Use_Element * element(uint i) const { return &_elements[i]; }\n\n"); fprintf(fp_hpp, " uint full_latency(uint delay, const Pipeline_Use &pred) const;\n\n"); fprintf(fp_hpp, " void add_usage(const Pipeline_Use &pred);\n\n"); fprintf(fp_hpp, " void reset() {\n"); fprintf(fp_hpp, " _resources_used = _resources_used_exclusively = 0;\n"); fprintf(fp_hpp, " };\n\n"); fprintf(fp_hpp, " void step(uint cycles) {\n"); fprintf(fp_hpp, " reset();\n"); fprintf(fp_hpp, " for (uint i = 0; i < %d; i++)\n", rescount); fprintf(fp_hpp, " (&_elements[i])->step(cycles);\n"); fprintf(fp_hpp, " };\n\n"); fprintf(fp_hpp, " static const Pipeline_Use elaborated_use;\n"); fprintf(fp_hpp, " static const Pipeline_Use_Element elaborated_elements[%d];\n\n", rescount); fprintf(fp_hpp, " friend class Pipeline;\n"); fprintf(fp_hpp, "};\n\n"); fprintf(fp_hpp, "// Pipeline Class\n"); fprintf(fp_hpp, "class Pipeline {\n"); fprintf(fp_hpp, "public:\n"); fprintf(fp_hpp, " static bool enabled() { return %s; }\n\n", _pipeline ? "true" : "false" ); assert( _pipeline->_maxInstrsPerBundle && ( _pipeline->_instrUnitSize || _pipeline->_bundleUnitSize) && _pipeline->_instrFetchUnitSize && _pipeline->_instrFetchUnits, "unspecified pipeline architecture units"); uint unitSize = _pipeline->_instrUnitSize ? _pipeline->_instrUnitSize : _pipeline->_bundleUnitSize; fprintf(fp_hpp, " enum {\n"); fprintf(fp_hpp, " _variable_size_instructions = %d,\n", _pipeline->_variableSizeInstrs ? 1 : 0); fprintf(fp_hpp, " _fixed_size_instructions = %d,\n", _pipeline->_variableSizeInstrs ? 0 : 1); fprintf(fp_hpp, " _branch_has_delay_slot = %d,\n", _pipeline->_branchHasDelaySlot ? 1 : 0); fprintf(fp_hpp, " _max_instrs_per_bundle = %d,\n", _pipeline->_maxInstrsPerBundle); fprintf(fp_hpp, " _max_bundles_per_cycle = %d,\n", _pipeline->_maxBundlesPerCycle); fprintf(fp_hpp, " _max_instrs_per_cycle = %d\n", _pipeline->_maxBundlesPerCycle * _pipeline->_maxInstrsPerBundle); fprintf(fp_hpp, " };\n\n"); fprintf(fp_hpp, " static bool instr_has_unit_size() { return %s; }\n\n", _pipeline->_instrUnitSize != 0 ? "true" : "false" ); if( _pipeline->_bundleUnitSize != 0 ) if( _pipeline->_instrUnitSize != 0 ) fprintf(fp_hpp, "// Individual Instructions may be bundled together by the hardware\n\n"); else fprintf(fp_hpp, "// Instructions exist only in bundles\n\n"); else fprintf(fp_hpp, "// Bundling is not supported\n\n"); if( _pipeline->_instrUnitSize != 0 ) fprintf(fp_hpp, " // Size of an instruction\n"); else fprintf(fp_hpp, " // Size of an individual instruction does not exist - unsupported\n"); fprintf(fp_hpp, " static uint instr_unit_size() {"); if( _pipeline->_instrUnitSize == 0 ) fprintf(fp_hpp, " assert( false, \"Instructions are only in bundles\" );"); fprintf(fp_hpp, " return %d; };\n\n", _pipeline->_instrUnitSize); if( _pipeline->_bundleUnitSize != 0 ) fprintf(fp_hpp, " // Size of a bundle\n"); else fprintf(fp_hpp, " // Bundles do not exist - unsupported\n"); fprintf(fp_hpp, " static uint bundle_unit_size() {"); if( _pipeline->_bundleUnitSize == 0 ) fprintf(fp_hpp, " assert( false, \"Bundles are not supported\" );"); fprintf(fp_hpp, " return %d; };\n\n", _pipeline->_bundleUnitSize); fprintf(fp_hpp, " static bool requires_bundling() { return %s; }\n\n", _pipeline->_bundleUnitSize != 0 && _pipeline->_instrUnitSize == 0 ? "true" : "false" ); fprintf(fp_hpp, "private:\n"); fprintf(fp_hpp, " Pipeline(); // Not a legal constructor\n"); fprintf(fp_hpp, "\n"); fprintf(fp_hpp, " const unsigned char _read_stage_count;\n"); fprintf(fp_hpp, " const unsigned char _write_stage;\n"); fprintf(fp_hpp, " const unsigned char _fixed_latency;\n"); fprintf(fp_hpp, " const unsigned char _instruction_count;\n"); fprintf(fp_hpp, " const bool _has_fixed_latency;\n"); fprintf(fp_hpp, " const bool _has_branch_delay;\n"); fprintf(fp_hpp, " const bool _has_multiple_bundles;\n"); fprintf(fp_hpp, " const bool _force_serialization;\n"); fprintf(fp_hpp, " const bool _may_have_no_code;\n"); fprintf(fp_hpp, " const enum machPipelineStages * const _read_stages;\n"); fprintf(fp_hpp, " const enum machPipelineStages * const _resource_stage;\n"); fprintf(fp_hpp, " const uint * const _resource_cycles;\n"); fprintf(fp_hpp, " const Pipeline_Use _resource_use;\n"); fprintf(fp_hpp, "\n"); fprintf(fp_hpp, "public:\n"); fprintf(fp_hpp, " Pipeline(uint write_stage,\n"); fprintf(fp_hpp, " uint count,\n"); fprintf(fp_hpp, " bool has_fixed_latency,\n"); fprintf(fp_hpp, " uint fixed_latency,\n"); fprintf(fp_hpp, " uint instruction_count,\n"); fprintf(fp_hpp, " bool has_branch_delay,\n"); fprintf(fp_hpp, " bool has_multiple_bundles,\n"); fprintf(fp_hpp, " bool force_serialization,\n"); fprintf(fp_hpp, " bool may_have_no_code,\n"); fprintf(fp_hpp, " enum machPipelineStages * const dst,\n"); fprintf(fp_hpp, " enum machPipelineStages * const stage,\n"); fprintf(fp_hpp, " uint * const cycles,\n"); fprintf(fp_hpp, " Pipeline_Use resource_use)\n"); fprintf(fp_hpp, " : _write_stage(write_stage)\n"); fprintf(fp_hpp, " , _read_stage_count(count)\n"); fprintf(fp_hpp, " , _has_fixed_latency(has_fixed_latency)\n"); fprintf(fp_hpp, " , _fixed_latency(fixed_latency)\n"); fprintf(fp_hpp, " , _read_stages(dst)\n"); fprintf(fp_hpp, " , _resource_stage(stage)\n"); fprintf(fp_hpp, " , _resource_cycles(cycles)\n"); fprintf(fp_hpp, " , _resource_use(resource_use)\n"); fprintf(fp_hpp, " , _instruction_count(instruction_count)\n"); fprintf(fp_hpp, " , _has_branch_delay(has_branch_delay)\n"); fprintf(fp_hpp, " , _has_multiple_bundles(has_multiple_bundles)\n"); fprintf(fp_hpp, " , _force_serialization(force_serialization)\n"); fprintf(fp_hpp, " , _may_have_no_code(may_have_no_code)\n"); fprintf(fp_hpp, " {};\n"); fprintf(fp_hpp, "\n"); fprintf(fp_hpp, " uint writeStage() const {\n"); fprintf(fp_hpp, " return (_write_stage);\n"); fprintf(fp_hpp, " }\n"); fprintf(fp_hpp, "\n"); fprintf(fp_hpp, " enum machPipelineStages readStage(int ndx) const {\n"); fprintf(fp_hpp, " return (ndx < _read_stage_count ? _read_stages[ndx] : stage_undefined);"); fprintf(fp_hpp, " }\n\n"); fprintf(fp_hpp, " uint resourcesUsed() const {\n"); fprintf(fp_hpp, " return _resource_use.resourcesUsed();\n }\n\n"); fprintf(fp_hpp, " uint resourcesUsedExclusively() const {\n"); fprintf(fp_hpp, " return _resource_use.resourcesUsedExclusively();\n }\n\n"); fprintf(fp_hpp, " bool hasFixedLatency() const {\n"); fprintf(fp_hpp, " return (_has_fixed_latency);\n }\n\n"); fprintf(fp_hpp, " uint fixedLatency() const {\n"); fprintf(fp_hpp, " return (_fixed_latency);\n }\n\n"); fprintf(fp_hpp, " uint functional_unit_latency(uint start, const Pipeline *pred) const;\n\n"); fprintf(fp_hpp, " uint operand_latency(uint opnd, const Pipeline *pred) const;\n\n"); fprintf(fp_hpp, " const Pipeline_Use& resourceUse() const {\n"); fprintf(fp_hpp, " return (_resource_use); }\n\n"); fprintf(fp_hpp, " const Pipeline_Use_Element * resourceUseElement(uint i) const {\n"); fprintf(fp_hpp, " return (&_resource_use._elements[i]); }\n\n"); fprintf(fp_hpp, " uint resourceUseCount() const {\n"); fprintf(fp_hpp, " return (_resource_use._count); }\n\n"); fprintf(fp_hpp, " uint instructionCount() const {\n"); fprintf(fp_hpp, " return (_instruction_count); }\n\n"); fprintf(fp_hpp, " bool hasBranchDelay() const {\n"); fprintf(fp_hpp, " return (_has_branch_delay); }\n\n"); fprintf(fp_hpp, " bool hasMultipleBundles() const {\n"); fprintf(fp_hpp, " return (_has_multiple_bundles); }\n\n"); fprintf(fp_hpp, " bool forceSerialization() const {\n"); fprintf(fp_hpp, " return (_force_serialization); }\n\n"); fprintf(fp_hpp, " bool mayHaveNoCode() const {\n"); fprintf(fp_hpp, " return (_may_have_no_code); }\n\n"); fprintf(fp_hpp, "//const Pipeline_Use_Cycle_Mask& resourceUseMask(int resource) const {\n"); fprintf(fp_hpp, "// return (_resource_use_masks[resource]); }\n\n"); fprintf(fp_hpp, "\n#ifndef PRODUCT\n"); fprintf(fp_hpp, " static const char * stageName(uint i);\n"); fprintf(fp_hpp, "#endif\n"); fprintf(fp_hpp, "};\n\n"); fprintf(fp_hpp, "// Bundle class\n"); fprintf(fp_hpp, "class Bundle {\n"); uint mshift = 0; for (uint msize = _pipeline->_maxInstrsPerBundle * _pipeline->_maxBundlesPerCycle; msize != 0; msize >>= 1) mshift++; uint rshift = rescount; fprintf(fp_hpp, "protected:\n"); fprintf(fp_hpp, " enum {\n"); fprintf(fp_hpp, " _unused_delay = 0x%x,\n", 0); fprintf(fp_hpp, " _use_nop_delay = 0x%x,\n", 1); fprintf(fp_hpp, " _use_unconditional_delay = 0x%x,\n", 2); fprintf(fp_hpp, " _use_conditional_delay = 0x%x,\n", 3); fprintf(fp_hpp, " _used_in_conditional_delay = 0x%x,\n", 4); fprintf(fp_hpp, " _used_in_unconditional_delay = 0x%x,\n", 5); fprintf(fp_hpp, " _used_in_all_conditional_delays = 0x%x,\n", 6); fprintf(fp_hpp, "\n"); fprintf(fp_hpp, " _use_delay = 0x%x,\n", 3); fprintf(fp_hpp, " _used_in_delay = 0x%x\n", 4); fprintf(fp_hpp, " };\n\n"); fprintf(fp_hpp, " uint _flags : 3,\n"); fprintf(fp_hpp, " _starts_bundle : 1,\n"); fprintf(fp_hpp, " _instr_count : %d,\n", mshift); fprintf(fp_hpp, " _resources_used : %d;\n", rshift); fprintf(fp_hpp, "public:\n"); fprintf(fp_hpp, " Bundle() : _flags(_unused_delay), _starts_bundle(0), _instr_count(0), _resources_used(0) {}\n\n"); fprintf(fp_hpp, " void set_instr_count(uint i) { _instr_count = i; }\n"); fprintf(fp_hpp, " void set_resources_used(uint i) { _resources_used = i; }\n"); fprintf(fp_hpp, " void clear_usage() { _flags = _unused_delay; }\n"); fprintf(fp_hpp, " void set_starts_bundle() { _starts_bundle = true; }\n"); fprintf(fp_hpp, " uint flags() const { return (_flags); }\n"); fprintf(fp_hpp, " uint instr_count() const { return (_instr_count); }\n"); fprintf(fp_hpp, " uint resources_used() const { return (_resources_used); }\n"); fprintf(fp_hpp, " bool starts_bundle() const { return (_starts_bundle != 0); }\n"); fprintf(fp_hpp, " void set_use_nop_delay() { _flags = _use_nop_delay; }\n"); fprintf(fp_hpp, " void set_use_unconditional_delay() { _flags = _use_unconditional_delay; }\n"); fprintf(fp_hpp, " void set_use_conditional_delay() { _flags = _use_conditional_delay; }\n"); fprintf(fp_hpp, " void set_used_in_unconditional_delay() { _flags = _used_in_unconditional_delay; }\n"); fprintf(fp_hpp, " void set_used_in_conditional_delay() { _flags = _used_in_conditional_delay; }\n"); fprintf(fp_hpp, " void set_used_in_all_conditional_delays() { _flags = _used_in_all_conditional_delays; }\n"); fprintf(fp_hpp, " bool use_nop_delay() { return (_flags == _use_nop_delay); }\n"); fprintf(fp_hpp, " bool use_unconditional_delay() { return (_flags == _use_unconditional_delay); }\n"); fprintf(fp_hpp, " bool use_conditional_delay() { return (_flags == _use_conditional_delay); }\n"); fprintf(fp_hpp, " bool used_in_unconditional_delay() { return (_flags == _used_in_unconditional_delay); }\n"); fprintf(fp_hpp, " bool used_in_conditional_delay() { return (_flags == _used_in_conditional_delay); }\n"); fprintf(fp_hpp, " bool used_in_all_conditional_delays() { return (_flags == _used_in_all_conditional_delays); }\n"); fprintf(fp_hpp, " bool use_delay() { return ((_flags & _use_delay) != 0); }\n"); fprintf(fp_hpp, " bool used_in_delay() { return ((_flags & _used_in_delay) != 0); }\n\n"); fprintf(fp_hpp, " enum {\n"); fprintf(fp_hpp, " _nop_count = %d\n", _pipeline->_nopcnt); fprintf(fp_hpp, " };\n\n"); fprintf(fp_hpp, " static void initialize_nops(MachNode *nop_list[%d], Compile* C);\n\n", _pipeline->_nopcnt); fprintf(fp_hpp, "#ifndef PRODUCT\n"); fprintf(fp_hpp, " void dump(outputStream *st = tty) const;\n"); fprintf(fp_hpp, "#endif\n"); fprintf(fp_hpp, "};\n\n"); // const char *classname; // for (_pipeline->_classlist.reset(); (classname = _pipeline->_classlist.iter()) != NULL; ) { // PipeClassForm *pipeclass = _pipeline->_classdict[classname]->is_pipeclass(); // fprintf(fp_hpp, "// Pipeline Class Instance for \"%s\"\n", classname); // } } //------------------------------declareClasses--------------------------------- // Construct the class hierarchy of MachNode classes from the instruction & // operand lists void ArchDesc::declareClasses(FILE *fp) { // Declare an array containing the machine register names, strings. declareRegNames(fp, _register); // Declare an array containing the machine register encoding values declareRegEncodes(fp, _register); // Generate declarations for the total number of operands fprintf(fp,"\n"); fprintf(fp,"// Total number of operands defined in architecture definition\n"); int num_operands = 0; OperandForm *op; for (_operands.reset(); (op = (OperandForm*)_operands.iter()) != NULL; ) { // Ensure this is a machine-world instruction if (op->ideal_only()) continue; ++num_operands; } int first_operand_class = num_operands; OpClassForm *opc; for (_opclass.reset(); (opc = (OpClassForm*)_opclass.iter()) != NULL; ) { // Ensure this is a machine-world instruction if (opc->ideal_only()) continue; ++num_operands; } fprintf(fp,"#define FIRST_OPERAND_CLASS %d\n", first_operand_class); fprintf(fp,"#define NUM_OPERANDS %d\n", num_operands); fprintf(fp,"\n"); // Generate declarations for the total number of instructions fprintf(fp,"// Total number of instructions defined in architecture definition\n"); fprintf(fp,"#define NUM_INSTRUCTIONS %d\n",instructFormCount()); // Generate Machine Classes for each operand defined in AD file fprintf(fp,"\n"); fprintf(fp,"//----------------------------Declare classes derived from MachOper----------\n"); // Iterate through all operands _operands.reset(); OperandForm *oper; for( ; (oper = (OperandForm*)_operands.iter()) != NULL;) { // Ensure this is a machine-world instruction if (oper->ideal_only() ) continue; // The declaration of labelOper is in machine-independent file: machnode if ( strcmp(oper->_ident,"label") == 0 ) continue; // The declaration of methodOper is in machine-independent file: machnode if ( strcmp(oper->_ident,"method") == 0 ) continue; // Build class definition for this operand fprintf(fp,"\n"); fprintf(fp,"class %sOper : public MachOper { \n",oper->_ident); fprintf(fp,"private:\n"); // Operand definitions that depend upon number of input edges { uint num_edges = oper->num_edges(_globalNames); if( num_edges != 1 ) { // Use MachOper::num_edges() {return 1;} fprintf(fp," virtual uint num_edges() const { return %d; }\n", num_edges ); } if( num_edges > 0 ) { in_RegMask(fp); } } // Support storing constants inside the MachOper declareConstStorage(fp,_globalNames,oper); // Support storage of the condition codes if( oper->is_ideal_bool() ) { fprintf(fp," virtual int ccode() const { \n"); fprintf(fp," switch (_c0) {\n"); fprintf(fp," case BoolTest::eq : return equal();\n"); fprintf(fp," case BoolTest::gt : return greater();\n"); fprintf(fp," case BoolTest::lt : return less();\n"); fprintf(fp," case BoolTest::ne : return not_equal();\n"); fprintf(fp," case BoolTest::le : return less_equal();\n"); fprintf(fp," case BoolTest::ge : return greater_equal();\n"); fprintf(fp," default : ShouldNotReachHere(); return 0;\n"); fprintf(fp," }\n"); fprintf(fp," };\n"); } // Support storage of the condition codes if( oper->is_ideal_bool() ) { fprintf(fp," virtual void negate() { \n"); fprintf(fp," _c0 = (BoolTest::mask)((int)_c0^0x4); \n"); fprintf(fp," };\n"); } // Declare constructor. // Parameters start with condition code, then all other constants // // (1) MachXOper(int32 ccode, int32 c0, int32 c1, ..., int32 cn) // (2) : _ccode(ccode), _c0(c0), _c1(c1), ..., _cn(cn) { } // Form::DataType constant_type = oper->simple_type(_globalNames); defineConstructor(fp, oper->_ident, oper->num_consts(_globalNames), oper->_components, oper->is_ideal_bool(), constant_type, _globalNames); // Clone function fprintf(fp," virtual MachOper *clone(Compile* C) const;\n"); // Support setting a spill offset into a constant operand. // We only support setting an 'int' offset, while in the // LP64 build spill offsets are added with an AddP which // requires a long constant. Thus we don't support spilling // in frames larger than 4Gig. if( oper->has_conI(_globalNames) || oper->has_conL(_globalNames) ) fprintf(fp, " virtual void set_con( jint c0 ) { _c0 = c0; }\n"); // virtual functions for encoding and format // fprintf(fp," virtual void encode() const {\n %s }\n", // (oper->_encrule)?(oper->_encrule->_encrule):""); // Check the interface type, and generate the correct query functions // encoding queries based upon MEMORY_INTER, REG_INTER, CONST_INTER. fprintf(fp," virtual uint opcode() const { return %s; }\n", machOperEnum(oper->_ident)); // virtual function to look up ideal return type of machine instruction // // (1) virtual const Type *type() const { return .....; } // if ((oper->_matrule) && (oper->_matrule->_lChild == NULL) && (oper->_matrule->_rChild == NULL)) { unsigned int position = 0; const char *opret, *opname, *optype; oper->_matrule->base_operand(position,_globalNames,opret,opname,optype); fprintf(fp," virtual const Type *type() const {"); const char *type = getIdealType(optype); if( type != NULL ) { Form::DataType data_type = oper->is_base_constant(_globalNames); // Check if we are an ideal pointer type if( data_type == Form::idealP || data_type == Form::idealN ) { // Return the ideal type we already have: <TypePtr *> fprintf(fp," return _c0;"); } else { // Return the appropriate bottom type fprintf(fp," return %s;", getIdealType(optype)); } } else { fprintf(fp," ShouldNotCallThis(); return Type::BOTTOM;"); } fprintf(fp," }\n"); } else { // Check for user-defined stack slots, based upon sRegX Form::DataType data_type = oper->is_user_name_for_sReg(); if( data_type != Form::none ){ const char *type = NULL; switch( data_type ) { case Form::idealI: type = "TypeInt::INT"; break; case Form::idealP: type = "TypePtr::BOTTOM";break; case Form::idealF: type = "Type::FLOAT"; break; case Form::idealD: type = "Type::DOUBLE"; break; case Form::idealL: type = "TypeLong::LONG"; break; case Form::none: // fall through default: assert( false, "No support for this type of stackSlot"); } fprintf(fp," virtual const Type *type() const { return %s; } // stackSlotX\n", type); } } // // virtual functions for defining the encoding interface. // // Access the linearized ideal register mask, // map to physical register encoding if ( oper->_matrule && oper->_matrule->is_base_register(_globalNames) ) { // Just use the default virtual 'reg' call } else if ( oper->ideal_to_sReg_type(oper->_ident) != Form::none ) { // Special handling for operand 'sReg', a Stack Slot Register. // Map linearized ideal register mask to stack slot number fprintf(fp," virtual int reg(PhaseRegAlloc *ra_, const Node *node) const {\n"); fprintf(fp," return (int)OptoReg::reg2stack(ra_->get_reg_first(node));/* sReg */\n"); fprintf(fp," }\n"); fprintf(fp," virtual int reg(PhaseRegAlloc *ra_, const Node *node, int idx) const {\n"); fprintf(fp," return (int)OptoReg::reg2stack(ra_->get_reg_first(node->in(idx)));/* sReg */\n"); fprintf(fp," }\n"); } // Output the operand specific access functions used by an enc_class // These are only defined when we want to override the default virtual func if (oper->_interface != NULL) { fprintf(fp,"\n"); // Check if it is a Memory Interface if ( oper->_interface->is_MemInterface() != NULL ) { MemInterface *mem_interface = oper->_interface->is_MemInterface(); const char *base = mem_interface->_base; if( base != NULL ) { define_oper_interface(fp, *oper, _globalNames, "base", base); } char *index = mem_interface->_index; if( index != NULL ) { define_oper_interface(fp, *oper, _globalNames, "index", index); } const char *scale = mem_interface->_scale; if( scale != NULL ) { define_oper_interface(fp, *oper, _globalNames, "scale", scale); } const char *disp = mem_interface->_disp; if( disp != NULL ) { define_oper_interface(fp, *oper, _globalNames, "disp", disp); oper->disp_is_oop(fp, _globalNames); } if( oper->stack_slots_only(_globalNames) ) { // should not call this: fprintf(fp," virtual int constant_disp() const { return Type::OffsetBot; }"); } else if ( disp != NULL ) { define_oper_interface(fp, *oper, _globalNames, "constant_disp", disp); } } // end Memory Interface // Check if it is a Conditional Interface else if (oper->_interface->is_CondInterface() != NULL) { CondInterface *cInterface = oper->_interface->is_CondInterface(); const char *equal = cInterface->_equal; if( equal != NULL ) { define_oper_interface(fp, *oper, _globalNames, "equal", equal); } const char *not_equal = cInterface->_not_equal; if( not_equal != NULL ) { define_oper_interface(fp, *oper, _globalNames, "not_equal", not_equal); } const char *less = cInterface->_less; if( less != NULL ) { define_oper_interface(fp, *oper, _globalNames, "less", less); } const char *greater_equal = cInterface->_greater_equal; if( greater_equal != NULL ) { define_oper_interface(fp, *oper, _globalNames, "greater_equal", greater_equal); } const char *less_equal = cInterface->_less_equal; if( less_equal != NULL ) { define_oper_interface(fp, *oper, _globalNames, "less_equal", less_equal); } const char *greater = cInterface->_greater; if( greater != NULL ) { define_oper_interface(fp, *oper, _globalNames, "greater", greater); } } // end Conditional Interface // Check if it is a Constant Interface else if (oper->_interface->is_ConstInterface() != NULL ) { assert( oper->num_consts(_globalNames) == 1, "Must have one constant when using CONST_INTER encoding"); if (!strcmp(oper->ideal_type(_globalNames), "ConI")) { // Access the locally stored constant fprintf(fp," virtual intptr_t constant() const {"); fprintf(fp, " return (intptr_t)_c0;"); fprintf(fp," }\n"); } else if (!strcmp(oper->ideal_type(_globalNames), "ConP")) { // Access the locally stored constant fprintf(fp," virtual intptr_t constant() const {"); fprintf(fp, " return _c0->get_con();"); fprintf(fp, " }\n"); // Generate query to determine if this pointer is an oop fprintf(fp," virtual bool constant_is_oop() const {"); fprintf(fp, " return _c0->isa_oop_ptr();"); fprintf(fp, " }\n"); } else if (!strcmp(oper->ideal_type(_globalNames), "ConN")) { // Access the locally stored constant fprintf(fp," virtual intptr_t constant() const {"); fprintf(fp, " return _c0->get_ptrtype()->get_con();"); fprintf(fp, " }\n"); // Generate query to determine if this pointer is an oop fprintf(fp," virtual bool constant_is_oop() const {"); fprintf(fp, " return _c0->get_ptrtype()->isa_oop_ptr();"); fprintf(fp, " }\n"); } else if (!strcmp(oper->ideal_type(_globalNames), "ConL")) { fprintf(fp," virtual intptr_t constant() const {"); // We don't support addressing modes with > 4Gig offsets. // Truncate to int. fprintf(fp, " return (intptr_t)_c0;"); fprintf(fp, " }\n"); fprintf(fp," virtual jlong constantL() const {"); fprintf(fp, " return _c0;"); fprintf(fp, " }\n"); } else if (!strcmp(oper->ideal_type(_globalNames), "ConF")) { fprintf(fp," virtual intptr_t constant() const {"); fprintf(fp, " ShouldNotReachHere(); return 0; "); fprintf(fp, " }\n"); fprintf(fp," virtual jfloat constantF() const {"); fprintf(fp, " return (jfloat)_c0;"); fprintf(fp, " }\n"); } else if (!strcmp(oper->ideal_type(_globalNames), "ConD")) { fprintf(fp," virtual intptr_t constant() const {"); fprintf(fp, " ShouldNotReachHere(); return 0; "); fprintf(fp, " }\n"); fprintf(fp," virtual jdouble constantD() const {"); fprintf(fp, " return _c0;"); fprintf(fp, " }\n"); } } else if (oper->_interface->is_RegInterface() != NULL) { // make sure that a fixed format string isn't used for an // operand which might be assiged to multiple registers. // Otherwise the opto assembly output could be misleading. if (oper->_format->_strings.count() != 0 && !oper->is_bound_register()) { syntax_err(oper->_linenum, "Only bound registers can have fixed formats: %s\n", oper->_ident); } } else { assert( false, "ShouldNotReachHere();"); } } fprintf(fp,"\n"); // // Currently all XXXOper::hash() methods are identical (990820) // declare_hash(fp); // // Currently all XXXOper::Cmp() methods are identical (990820) // declare_cmp(fp); // Do not place dump_spec() and Name() into PRODUCT code // int_format and ext_format are not needed in PRODUCT code either fprintf(fp, "#ifndef PRODUCT\n"); // Declare int_format() and ext_format() gen_oper_format(fp, _globalNames, *oper); // Machine independent print functionality for debugging // IF we have constants, create a dump_spec function for the derived class // // (1) virtual void dump_spec() const { // (2) st->print("#%d", _c#); // Constant != ConP // OR _c#->dump_on(st); // Type ConP // ... // (3) } uint num_consts = oper->num_consts(_globalNames); if( num_consts > 0 ) { // line (1) fprintf(fp, " virtual void dump_spec(outputStream *st) const {\n"); // generate format string for st->print // Iterate over the component list & spit out the right thing uint i = 0; const char *type = oper->ideal_type(_globalNames); Component *comp; oper->_components.reset(); if ((comp = oper->_components.iter()) == NULL) { assert(num_consts == 1, "Bad component list detected.\n"); i = dump_spec_constant( fp, type, i, oper ); // Check that type actually matched assert( i != 0, "Non-constant operand lacks component list."); } // end if NULL else { // line (2) // dump all components oper->_components.reset(); while((comp = oper->_components.iter()) != NULL) { type = comp->base_type(_globalNames); i = dump_spec_constant( fp, type, i, NULL ); } } // finish line (3) fprintf(fp," }\n"); } fprintf(fp," virtual const char *Name() const { return \"%s\";}\n", oper->_ident); fprintf(fp,"#endif\n"); // Close definition of this XxxMachOper fprintf(fp,"};\n"); } // Generate Machine Classes for each instruction defined in AD file fprintf(fp,"\n"); fprintf(fp,"//----------------------------Declare classes for Pipelines-----------------\n"); declare_pipe_classes(fp); // Generate Machine Classes for each instruction defined in AD file fprintf(fp,"\n"); fprintf(fp,"//----------------------------Declare classes derived from MachNode----------\n"); _instructions.reset(); InstructForm *instr; for( ; (instr = (InstructForm*)_instructions.iter()) != NULL; ) { // Ensure this is a machine-world instruction if ( instr->ideal_only() ) continue; // Build class definition for this instruction fprintf(fp,"\n"); fprintf(fp,"class %sNode : public %s { \n", instr->_ident, instr->mach_base_class(_globalNames) ); fprintf(fp,"private:\n"); fprintf(fp," MachOper *_opnd_array[%d];\n", instr->num_opnds() ); if ( instr->is_ideal_jump() ) { fprintf(fp, " GrowableArray<Label*> _index2label;\n"); } fprintf(fp,"public:\n"); fprintf(fp," MachOper *opnd_array(uint operand_index) const {\n"); fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n"); fprintf(fp," return _opnd_array[operand_index];\n"); fprintf(fp," }\n"); fprintf(fp," void set_opnd_array(uint operand_index, MachOper *operand) {\n"); fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n"); fprintf(fp," _opnd_array[operand_index] = operand;\n"); fprintf(fp," }\n"); fprintf(fp,"private:\n"); if ( instr->is_ideal_jump() ) { fprintf(fp," virtual void add_case_label(int index_num, Label* blockLabel) {\n"); fprintf(fp," _index2label.at_put_grow(index_num, blockLabel);\n"); fprintf(fp," }\n"); } if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) { fprintf(fp," const RegMask *_cisc_RegMask;\n"); } out_RegMask(fp); // output register mask fprintf(fp," virtual uint rule() const { return %s_rule; }\n", instr->_ident); // If this instruction contains a labelOper // Declare Node::methods that set operand Label's contents int label_position = instr->label_position(); if( label_position != -1 ) { // Set/Save the label, stored in labelOper::_branch_label fprintf(fp," virtual void label_set( Label* label, uint block_num );\n"); fprintf(fp," virtual void save_label( Label** label, uint* block_num );\n"); } // If this instruction contains a methodOper // Declare Node::methods that set operand method's contents int method_position = instr->method_position(); if( method_position != -1 ) { // Set the address method, stored in methodOper::_method fprintf(fp," virtual void method_set( intptr_t method );\n"); } // virtual functions for attributes // // Each instruction attribute results in a virtual call of same name. // The ins_cost is not handled here. Attribute *attr = instr->_attribs; bool avoid_back_to_back = false; while (attr != NULL) { if (strcmp(attr->_ident,"ins_cost") && strcmp(attr->_ident,"ins_short_branch")) { fprintf(fp," int %s() const { return %s; }\n", attr->_ident, attr->_val); } // Check value for ins_avoid_back_to_back, and if it is true (1), set the flag if (!strcmp(attr->_ident,"ins_avoid_back_to_back") && attr->int_val(*this) != 0) avoid_back_to_back = true; attr = (Attribute *)attr->_next; } // virtual functions for encode and format // Virtual function for evaluating the constant. if (instr->is_mach_constant()) { fprintf(fp," virtual void eval_constant(Compile* C);\n"); } // Output the opcode function and the encode function here using the // encoding class information in the _insencode slot. if ( instr->_insencode ) { fprintf(fp," virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n"); } // virtual function for getting the size of an instruction if ( instr->_size ) { fprintf(fp," virtual uint size(PhaseRegAlloc *ra_) const;\n"); } // Return the top-level ideal opcode. // Use MachNode::ideal_Opcode() for nodes based on MachNode class // if the ideal_Opcode == Op_Node. if ( strcmp("Node", instr->ideal_Opcode(_globalNames)) != 0 || strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) { fprintf(fp," virtual int ideal_Opcode() const { return Op_%s; }\n", instr->ideal_Opcode(_globalNames) ); } // Allow machine-independent optimization, invert the sense of the IF test if( instr->is_ideal_if() ) { fprintf(fp," virtual void negate() { \n"); // Identify which operand contains the negate(able) ideal condition code int idx = 0; instr->_components.reset(); for( Component *comp; (comp = instr->_components.iter()) != NULL; ) { // Check that component is an operand Form *form = (Form*)_globalNames[comp->_type]; OperandForm *opForm = form ? form->is_operand() : NULL; if( opForm == NULL ) continue; // Lookup the position of the operand in the instruction. if( opForm->is_ideal_bool() ) { idx = instr->operand_position(comp->_name, comp->_usedef); assert( idx != NameList::Not_in_list, "Did not find component in list that contained it."); break; } } fprintf(fp," opnd_array(%d)->negate();\n", idx); fprintf(fp," _prob = 1.0f - _prob;\n"); fprintf(fp," };\n"); } // Identify which input register matches the input register. uint matching_input = instr->two_address(_globalNames); // Generate the method if it returns != 0 otherwise use MachNode::two_adr() if( matching_input != 0 ) { fprintf(fp," virtual uint two_adr() const "); fprintf(fp,"{ return oper_input_base()"); for( uint i = 2; i <= matching_input; i++ ) fprintf(fp," + opnd_array(%d)->num_edges()",i-1); fprintf(fp,"; }\n"); } // Declare cisc_version, if applicable // MachNode *cisc_version( int offset /* ,... */ ); instr->declare_cisc_version(*this, fp); // If there is an explicit peephole rule, build it if ( instr->peepholes() != NULL ) { fprintf(fp," virtual MachNode *peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile *C);\n"); } // Output the declaration for number of relocation entries if ( instr->reloc(_globalNames) != 0 ) { fprintf(fp," virtual int reloc() const;\n"); } if (instr->alignment() != 1) { fprintf(fp," virtual int alignment_required() const { return %d; }\n", instr->alignment()); fprintf(fp," virtual int compute_padding(int current_offset) const;\n"); } // Starting point for inputs matcher wants. // Use MachNode::oper_input_base() for nodes based on MachNode class // if the base == 1. if ( instr->oper_input_base(_globalNames) != 1 || strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) { fprintf(fp," virtual uint oper_input_base() const { return %d; }\n", instr->oper_input_base(_globalNames)); } // Make the constructor and following methods 'public:' fprintf(fp,"public:\n"); // Constructor if ( instr->is_ideal_jump() ) { fprintf(fp," %sNode() : _index2label(MinJumpTableSize*2) { ", instr->_ident); } else { fprintf(fp," %sNode() { ", instr->_ident); if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) { fprintf(fp,"_cisc_RegMask = NULL; "); } } fprintf(fp," _num_opnds = %d; _opnds = _opnd_array; ", instr->num_opnds()); bool node_flags_set = false; // flag: if this instruction matches an ideal 'Copy*' node if ( instr->is_ideal_copy() != 0 ) { fprintf(fp,"init_flags(Flag_is_Copy"); node_flags_set = true; } // Is an instruction is a constant? If so, get its type Form::DataType data_type; const char *opType = NULL; const char *result = NULL; data_type = instr->is_chain_of_constant(_globalNames, opType, result); // Check if this instruction is a constant if ( data_type != Form::none ) { if ( node_flags_set ) { fprintf(fp," | Flag_is_Con"); } else { fprintf(fp,"init_flags(Flag_is_Con"); node_flags_set = true; } } // flag: if this instruction is cisc alternate if ( can_cisc_spill() && instr->is_cisc_alternate() ) { if ( node_flags_set ) { fprintf(fp," | Flag_is_cisc_alternate"); } else { fprintf(fp,"init_flags(Flag_is_cisc_alternate"); node_flags_set = true; } } // flag: if this instruction has short branch form if ( instr->has_short_branch_form() ) { if ( node_flags_set ) { fprintf(fp," | Flag_may_be_short_branch"); } else { fprintf(fp,"init_flags(Flag_may_be_short_branch"); node_flags_set = true; } } // flag: if this instruction should not be generated back to back. if ( avoid_back_to_back ) { if ( node_flags_set ) { fprintf(fp," | Flag_avoid_back_to_back"); } else { fprintf(fp,"init_flags(Flag_avoid_back_to_back"); node_flags_set = true; } } // Check if machine instructions that USE memory, but do not DEF memory, // depend upon a node that defines memory in machine-independent graph. if ( instr->needs_anti_dependence_check(_globalNames) ) { if ( node_flags_set ) { fprintf(fp," | Flag_needs_anti_dependence_check"); } else { fprintf(fp,"init_flags(Flag_needs_anti_dependence_check"); node_flags_set = true; } } // flag: if this instruction is implemented with a call if ( instr->_has_call ) { if ( node_flags_set ) { fprintf(fp," | Flag_has_call"); } else { fprintf(fp,"init_flags(Flag_has_call"); node_flags_set = true; } } if ( node_flags_set ) { fprintf(fp,"); "); } fprintf(fp,"}\n"); // size_of, used by base class's clone to obtain the correct size. fprintf(fp," virtual uint size_of() const {"); fprintf(fp, " return sizeof(%sNode);", instr->_ident); fprintf(fp, " }\n"); // Virtual methods which are only generated to override base class if( instr->expands() || instr->needs_projections() || instr->has_temps() || instr->is_mach_constant() || instr->_matrule != NULL && instr->num_opnds() != instr->num_unique_opnds() ) { fprintf(fp," virtual MachNode *Expand(State *state, Node_List &proj_list, Node* mem);\n"); } if (instr->is_pinned(_globalNames)) { fprintf(fp," virtual bool pinned() const { return "); if (instr->is_parm(_globalNames)) { fprintf(fp,"_in[0]->pinned();"); } else { fprintf(fp,"true;"); } fprintf(fp," }\n"); } if (instr->is_projection(_globalNames)) { fprintf(fp," virtual const Node *is_block_proj() const { return this; }\n"); } if ( instr->num_post_match_opnds() != 0 || instr->is_chain_of_constant(_globalNames) ) { fprintf(fp," friend MachNode *State::MachNodeGenerator(int opcode, Compile* C);\n"); } if ( instr->rematerialize(_globalNames, get_registers()) ) { fprintf(fp," // Rematerialize %s\n", instr->_ident); } // Declare short branch methods, if applicable instr->declare_short_branch_methods(fp); // See if there is an "ins_pipe" declaration for this instruction if (instr->_ins_pipe) { fprintf(fp," static const Pipeline *pipeline_class();\n"); fprintf(fp," virtual const Pipeline *pipeline() const;\n"); } // Generate virtual function for MachNodeX::bottom_type when necessary // // Note on accuracy: Pointer-types of machine nodes need to be accurate, // or else alias analysis on the matched graph may produce bad code. // Moreover, the aliasing decisions made on machine-node graph must be // no less accurate than those made on the ideal graph, or else the graph // may fail to schedule. (Reason: Memory ops which are reordered in // the ideal graph might look interdependent in the machine graph, // thereby removing degrees of scheduling freedom that the optimizer // assumed would be available.) // // %%% We should handle many of these cases with an explicit ADL clause: // instruct foo() %{ ... bottom_type(TypeRawPtr::BOTTOM); ... %} if( data_type != Form::none ) { // A constant's bottom_type returns a Type containing its constant value // !!!!! // Convert all ints, floats, ... to machine-independent TypeXs // as is done for pointers // // Construct appropriate constant type containing the constant value. fprintf(fp," virtual const class Type *bottom_type() const {\n"); switch( data_type ) { case Form::idealI: fprintf(fp," return TypeInt::make(opnd_array(1)->constant());\n"); break; case Form::idealP: case Form::idealN: fprintf(fp," return opnd_array(1)->type();\n"); break; case Form::idealD: fprintf(fp," return TypeD::make(opnd_array(1)->constantD());\n"); break; case Form::idealF: fprintf(fp," return TypeF::make(opnd_array(1)->constantF());\n"); break; case Form::idealL: fprintf(fp," return TypeLong::make(opnd_array(1)->constantL());\n"); break; default: assert( false, "Unimplemented()" ); break; } fprintf(fp," };\n"); } /* else if ( instr->_matrule && instr->_matrule->_rChild && ( strcmp("ConvF2I",instr->_matrule->_rChild->_opType)==0 || strcmp("ConvD2I",instr->_matrule->_rChild->_opType)==0 ) ) { // !!!!! !!!!! // Provide explicit bottom type for conversions to int // On Intel the result operand is a stackSlot, untyped. fprintf(fp," virtual const class Type *bottom_type() const {"); fprintf(fp, " return TypeInt::INT;"); fprintf(fp, " };\n"); }*/ else if( instr->is_ideal_copy() && !strcmp(instr->_matrule->_lChild->_opType,"stackSlotP") ) { // !!!!! // Special hack for ideal Copy of pointer. Bottom type is oop or not depending on input. fprintf(fp," const Type *bottom_type() const { return in(1)->bottom_type(); } // Copy?\n"); } else if( instr->is_ideal_loadPC() ) { // LoadPCNode provides the return address of a call to native code. // Define its bottom type to be TypeRawPtr::BOTTOM instead of TypePtr::BOTTOM // since it is a pointer to an internal VM location and must have a zero offset. // Allocation detects derived pointers, in part, by their non-zero offsets. fprintf(fp," const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } // LoadPC?\n"); } else if( instr->is_ideal_box() ) { // BoxNode provides the address of a stack slot. // Define its bottom type to be TypeRawPtr::BOTTOM instead of TypePtr::BOTTOM // This prevent s insert_anti_dependencies from complaining. It will // complain if it sees that the pointer base is TypePtr::BOTTOM since // it doesn't understand what that might alias. fprintf(fp," const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } // Box?\n"); } else if( instr->_matrule && instr->_matrule->_rChild && !strcmp(instr->_matrule->_rChild->_opType,"CMoveP") ) { int offset = 1; // Special special hack to see if the Cmp? has been incorporated in the conditional move MatchNode *rl = instr->_matrule->_rChild->_lChild; if( rl && !strcmp(rl->_opType, "Binary") ) { MatchNode *rlr = rl->_rChild; if (rlr && strncmp(rlr->_opType, "Cmp", 3) == 0) offset = 2; } // Special hack for ideal CMoveP; ideal type depends on inputs fprintf(fp," const Type *bottom_type() const { const Type *t = in(oper_input_base()+%d)->bottom_type(); return (req() <= oper_input_base()+%d) ? t : t->meet(in(oper_input_base()+%d)->bottom_type()); } // CMoveP\n", offset, offset+1, offset+1); } else if( instr->_matrule && instr->_matrule->_rChild && !strcmp(instr->_matrule->_rChild->_opType,"CMoveN") ) { int offset = 1; // Special special hack to see if the Cmp? has been incorporated in the conditional move MatchNode *rl = instr->_matrule->_rChild->_lChild; if( rl && !strcmp(rl->_opType, "Binary") ) { MatchNode *rlr = rl->_rChild; if (rlr && strncmp(rlr->_opType, "Cmp", 3) == 0) offset = 2; } // Special hack for ideal CMoveN; ideal type depends on inputs fprintf(fp," const Type *bottom_type() const { const Type *t = in(oper_input_base()+%d)->bottom_type(); return (req() <= oper_input_base()+%d) ? t : t->meet(in(oper_input_base()+%d)->bottom_type()); } // CMoveN\n", offset, offset+1, offset+1); } else if (instr->is_tls_instruction()) { // Special hack for tlsLoadP fprintf(fp," const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } // tlsLoadP\n"); } else if ( instr->is_ideal_if() ) { fprintf(fp," const Type *bottom_type() const { return TypeTuple::IFBOTH; } // matched IfNode\n"); } else if ( instr->is_ideal_membar() ) { fprintf(fp," const Type *bottom_type() const { return TypeTuple::MEMBAR; } // matched MemBar\n"); } // Check where 'ideal_type' must be customized /* if ( instr->_matrule && instr->_matrule->_rChild && ( strcmp("ConvF2I",instr->_matrule->_rChild->_opType)==0 || strcmp("ConvD2I",instr->_matrule->_rChild->_opType)==0 ) ) { fprintf(fp," virtual uint ideal_reg() const { return Compile::current()->matcher()->base2reg[Type::Int]; }\n"); }*/ // Analyze machine instructions that either USE or DEF memory. int memory_operand = instr->memory_operand(_globalNames); // Some guys kill all of memory if ( instr->is_wide_memory_kill(_globalNames) ) { memory_operand = InstructForm::MANY_MEMORY_OPERANDS; } if ( memory_operand != InstructForm::NO_MEMORY_OPERAND ) { if( memory_operand == InstructForm::MANY_MEMORY_OPERANDS ) { fprintf(fp," virtual const TypePtr *adr_type() const;\n"); } fprintf(fp," virtual const MachOper *memory_operand() const;\n"); } fprintf(fp, "#ifndef PRODUCT\n"); // virtual function for generating the user's assembler output gen_inst_format(fp, _globalNames,*instr); // Machine independent print functionality for debugging fprintf(fp," virtual const char *Name() const { return \"%s\";}\n", instr->_ident); fprintf(fp, "#endif\n"); // Close definition of this XxxMachNode fprintf(fp,"};\n"); }; } void ArchDesc::defineStateClass(FILE *fp) { static const char *state__valid = "_valid[((uint)index) >> 5] & (0x1 << (((uint)index) & 0x0001F))"; static const char *state__set_valid= "_valid[((uint)index) >> 5] |= (0x1 << (((uint)index) & 0x0001F))"; fprintf(fp,"\n"); fprintf(fp,"// MACROS to inline and constant fold State::valid(index)...\n"); fprintf(fp,"// when given a constant 'index' in dfa_<arch>.cpp\n"); fprintf(fp,"// uint word = index >> 5; // Shift out bit position\n"); fprintf(fp,"// uint bitpos = index & 0x0001F; // Mask off word bits\n"); fprintf(fp,"#define STATE__VALID(index) "); fprintf(fp," (%s)\n", state__valid); fprintf(fp,"\n"); fprintf(fp,"#define STATE__NOT_YET_VALID(index) "); fprintf(fp," ( (%s) == 0 )\n", state__valid); fprintf(fp,"\n"); fprintf(fp,"#define STATE__VALID_CHILD(state,index) "); fprintf(fp," ( state && (state->%s) )\n", state__valid); fprintf(fp,"\n"); fprintf(fp,"#define STATE__SET_VALID(index) "); fprintf(fp," (%s)\n", state__set_valid); fprintf(fp,"\n"); fprintf(fp, "//---------------------------State-------------------------------------------\n"); fprintf(fp,"// State contains an integral cost vector, indexed by machine operand opcodes,\n"); fprintf(fp,"// a rule vector consisting of machine operand/instruction opcodes, and also\n"); fprintf(fp,"// indexed by machine operand opcodes, pointers to the children in the label\n"); fprintf(fp,"// tree generated by the Label routines in ideal nodes (currently limited to\n"); fprintf(fp,"// two for convenience, but this could change).\n"); fprintf(fp,"class State : public ResourceObj {\n"); fprintf(fp,"public:\n"); fprintf(fp," int _id; // State identifier\n"); fprintf(fp," Node *_leaf; // Ideal (non-machine-node) leaf of match tree\n"); fprintf(fp," State *_kids[2]; // Children of state node in label tree\n"); fprintf(fp," unsigned int _cost[_LAST_MACH_OPER]; // Cost vector, indexed by operand opcodes\n"); fprintf(fp," unsigned int _rule[_LAST_MACH_OPER]; // Rule vector, indexed by operand opcodes\n"); fprintf(fp," unsigned int _valid[(_LAST_MACH_OPER/32)+1]; // Bit Map of valid Cost/Rule entries\n"); fprintf(fp,"\n"); fprintf(fp," State(void); // Constructor\n"); fprintf(fp," DEBUG_ONLY( ~State(void); ) // Destructor\n"); fprintf(fp,"\n"); fprintf(fp," // Methods created by ADLC and invoked by Reduce\n"); fprintf(fp," MachOper *MachOperGenerator( int opcode, Compile* C );\n"); fprintf(fp," MachNode *MachNodeGenerator( int opcode, Compile* C );\n"); fprintf(fp,"\n"); fprintf(fp," // Assign a state to a node, definition of method produced by ADLC\n"); fprintf(fp," bool DFA( int opcode, const Node *ideal );\n"); fprintf(fp,"\n"); fprintf(fp," // Access function for _valid bit vector\n"); fprintf(fp," bool valid(uint index) {\n"); fprintf(fp," return( STATE__VALID(index) != 0 );\n"); fprintf(fp," }\n"); fprintf(fp,"\n"); fprintf(fp," // Set function for _valid bit vector\n"); fprintf(fp," void set_valid(uint index) {\n"); fprintf(fp," STATE__SET_VALID(index);\n"); fprintf(fp," }\n"); fprintf(fp,"\n"); fprintf(fp,"#ifndef PRODUCT\n"); fprintf(fp," void dump(); // Debugging prints\n"); fprintf(fp," void dump(int depth);\n"); fprintf(fp,"#endif\n"); if (_dfa_small) { // Generate the routine name we'll need for (int i = 1; i < _last_opcode; i++) { if (_mlistab[i] == NULL) continue; fprintf(fp, " void _sub_Op_%s(const Node *n);\n", NodeClassNames[i]); } } fprintf(fp,"};\n"); fprintf(fp,"\n"); fprintf(fp,"\n"); } //---------------------------buildMachOperEnum--------------------------------- // Build enumeration for densely packed operands. // This enumeration is used to index into the arrays in the State objects // that indicate cost and a successfull rule match. // Information needed to generate the ReduceOp mapping for the DFA class OutputMachOperands : public OutputMap { public: OutputMachOperands(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD) : OutputMap(hpp, cpp, globals, AD, "MachOperands") {}; void declaration() { } void definition() { fprintf(_cpp, "enum MachOperands {\n"); } void closing() { fprintf(_cpp, " _LAST_MACH_OPER\n"); OutputMap::closing(); } void map(OpClassForm &opc) { const char* opc_ident_to_upper = _AD.machOperEnum(opc._ident); fprintf(_cpp, " %s", opc_ident_to_upper); delete[] opc_ident_to_upper; } void map(OperandForm &oper) { const char* oper_ident_to_upper = _AD.machOperEnum(oper._ident); fprintf(_cpp, " %s", oper_ident_to_upper); delete[] oper_ident_to_upper; } void map(char *name) { const char* name_to_upper = _AD.machOperEnum(name); fprintf(_cpp, " %s", name_to_upper); delete[] name_to_upper; } bool do_instructions() { return false; } void map(InstructForm &inst){ assert( false, "ShouldNotCallThis()"); } }; void ArchDesc::buildMachOperEnum(FILE *fp_hpp) { // Construct the table for MachOpcodes OutputMachOperands output_mach_operands(fp_hpp, fp_hpp, _globalNames, *this); build_map(output_mach_operands); } //---------------------------buildMachEnum---------------------------------- // Build enumeration for all MachOpers and all MachNodes // Information needed to generate the ReduceOp mapping for the DFA class OutputMachOpcodes : public OutputMap { int begin_inst_chain_rule; int end_inst_chain_rule; int begin_rematerialize; int end_rematerialize; int end_instructions; public: OutputMachOpcodes(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD) : OutputMap(hpp, cpp, globals, AD, "MachOpcodes"), begin_inst_chain_rule(-1), end_inst_chain_rule(-1), end_instructions(-1) {}; void declaration() { } void definition() { fprintf(_cpp, "enum MachOpcodes {\n"); } void closing() { if( begin_inst_chain_rule != -1 ) fprintf(_cpp, " _BEGIN_INST_CHAIN_RULE = %d,\n", begin_inst_chain_rule); if( end_inst_chain_rule != -1 ) fprintf(_cpp, " _END_INST_CHAIN_RULE = %d,\n", end_inst_chain_rule); if( begin_rematerialize != -1 ) fprintf(_cpp, " _BEGIN_REMATERIALIZE = %d,\n", begin_rematerialize); if( end_rematerialize != -1 ) fprintf(_cpp, " _END_REMATERIALIZE = %d,\n", end_rematerialize); // always execute since do_instructions() is true, and avoids trailing comma fprintf(_cpp, " _last_Mach_Node = %d \n", end_instructions); OutputMap::closing(); } void map(OpClassForm &opc) { fprintf(_cpp, " %s_rule", opc._ident ); } void map(OperandForm &oper) { fprintf(_cpp, " %s_rule", oper._ident ); } void map(char *name) { if (name) fprintf(_cpp, " %s_rule", name); else fprintf(_cpp, " 0"); } void map(InstructForm &inst) {fprintf(_cpp, " %s_rule", inst._ident ); } void record_position(OutputMap::position place, int idx ) { switch(place) { case OutputMap::BEGIN_INST_CHAIN_RULES : begin_inst_chain_rule = idx; break; case OutputMap::END_INST_CHAIN_RULES : end_inst_chain_rule = idx; break; case OutputMap::BEGIN_REMATERIALIZE : begin_rematerialize = idx; break; case OutputMap::END_REMATERIALIZE : end_rematerialize = idx; break; case OutputMap::END_INSTRUCTIONS : end_instructions = idx; break; default: break; } } }; void ArchDesc::buildMachOpcodesEnum(FILE *fp_hpp) { // Construct the table for MachOpcodes OutputMachOpcodes output_mach_opcodes(fp_hpp, fp_hpp, _globalNames, *this); build_map(output_mach_opcodes); } // Generate an enumeration of the pipeline states, and both // the functional units (resources) and the masks for // specifying resources void ArchDesc::build_pipeline_enums(FILE *fp_hpp) { int stagelen = (int)strlen("undefined"); int stagenum = 0; if (_pipeline) { // Find max enum string length const char *stage; for ( _pipeline->_stages.reset(); (stage = _pipeline->_stages.iter()) != NULL; ) { int len = (int)strlen(stage); if (stagelen < len) stagelen = len; } } // Generate a list of stages fprintf(fp_hpp, "\n"); fprintf(fp_hpp, "// Pipeline Stages\n"); fprintf(fp_hpp, "enum machPipelineStages {\n"); fprintf(fp_hpp, " stage_%-*s = 0,\n", stagelen, "undefined"); if( _pipeline ) { const char *stage; for ( _pipeline->_stages.reset(); (stage = _pipeline->_stages.iter()) != NULL; ) fprintf(fp_hpp, " stage_%-*s = %d,\n", stagelen, stage, ++stagenum); } fprintf(fp_hpp, " stage_%-*s = %d\n", stagelen, "count", stagenum); fprintf(fp_hpp, "};\n"); fprintf(fp_hpp, "\n"); fprintf(fp_hpp, "// Pipeline Resources\n"); fprintf(fp_hpp, "enum machPipelineResources {\n"); int rescount = 0; if( _pipeline ) { const char *resource; int reslen = 0; // Generate a list of resources, and masks for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) { int len = (int)strlen(resource); if (reslen < len) reslen = len; } for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) { const ResourceForm *resform = _pipeline->_resdict[resource]->is_resource(); int mask = resform->mask(); if ((mask & (mask-1)) == 0) fprintf(fp_hpp, " resource_%-*s = %d,\n", reslen, resource, rescount++); } fprintf(fp_hpp, "\n"); for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) { const ResourceForm *resform = _pipeline->_resdict[resource]->is_resource(); fprintf(fp_hpp, " res_mask_%-*s = 0x%08x,\n", reslen, resource, resform->mask()); } fprintf(fp_hpp, "\n"); } fprintf(fp_hpp, " resource_count = %d\n", rescount); fprintf(fp_hpp, "};\n"); }
43.258973
232
0.602449
codefollower
3396f42fe13c591266185b7fc6000f416a4fbfb5
5,273
cc
C++
chrome/browser/android/preferences/prefs_unittest.cc
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/android/preferences/prefs_unittest.cc
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/android/preferences/prefs_unittest.cc
sarang-apps/darshan_browser
173649bb8a7c656dc60784d19e7bb73e07c20daa
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/android/preferences/prefs.h" #include "base/stl_util.h" #include "chrome/browser/android/preferences/pref_service_bridge.h" #include "chrome/common/pref_names.h" #include "testing/gtest/include/gtest/gtest.h" namespace { class PrefsTest : public ::testing::Test { protected: const char* GetPrefName(Pref pref) { pref_count_++; return PrefServiceBridge::GetPrefNameExposedToJava(pref); } int pref_count_; }; TEST_F(PrefsTest, TestIndex) { pref_count_ = 0; // If one of these checks fails, most likely the Pref enum and // |kPrefExposedToJava| are out of sync. EXPECT_EQ(Pref::PREF_NUM_PREFS, base::size(kPrefsExposedToJava)); EXPECT_EQ(prefs::kAllowDeletingBrowserHistory, GetPrefName(ALLOW_DELETING_BROWSER_HISTORY)); EXPECT_EQ(prefs::kIncognitoModeAvailability, GetPrefName(INCOGNITO_MODE_AVAILABILITY)); EXPECT_EQ(feed::prefs::kEnableSnippets, GetPrefName(NTP_ARTICLES_SECTION_ENABLED)); EXPECT_EQ(feed::prefs::kArticlesListVisible, GetPrefName(NTP_ARTICLES_LIST_VISIBLE)); EXPECT_EQ(prefs::kPromptForDownloadAndroid, GetPrefName(PROMPT_FOR_DOWNLOAD_ANDROID)); EXPECT_EQ(dom_distiller::prefs::kReaderForAccessibility, GetPrefName(READER_FOR_ACCESSIBILITY_ENABLED)); EXPECT_EQ(prefs::kShowMissingSdCardErrorAndroid, GetPrefName(SHOW_MISSING_SD_CARD_ERROR_ANDROID)); EXPECT_EQ(payments::kCanMakePaymentEnabled, GetPrefName(CAN_MAKE_PAYMENT_ENABLED)); EXPECT_EQ(prefs::kContextualSearchEnabled, GetPrefName(CONTEXTUAL_SEARCH_ENABLED)); EXPECT_EQ(autofill::prefs::kAutofillProfileEnabled, GetPrefName(AUTOFILL_PROFILE_ENABLED)); EXPECT_EQ(autofill::prefs::kAutofillCreditCardEnabled, GetPrefName(AUTOFILL_CREDIT_CARD_ENABLED)); EXPECT_EQ(prefs::kUsageStatsEnabled, GetPrefName(USAGE_STATS_ENABLED)); EXPECT_EQ(offline_pages::prefetch_prefs::kUserSettingEnabled, GetPrefName(OFFLINE_PREFETCH_USER_SETTING_ENABLED)); EXPECT_EQ(prefs::kSafeBrowsingExtendedReportingOptInAllowed, GetPrefName(SAFE_BROWSING_EXTENDED_REPORTING_OPT_IN_ALLOWED)); EXPECT_EQ(prefs::kSafeBrowsingEnabled, GetPrefName(SAFE_BROWSING_ENABLED)); EXPECT_EQ(password_manager::prefs::kPasswordManagerOnboardingState, GetPrefName(PASSWORD_MANAGER_ONBOARDING_STATE)); EXPECT_EQ(prefs::kSearchSuggestEnabled, GetPrefName(SEARCH_SUGGEST_ENABLED)); EXPECT_EQ(password_manager::prefs::kCredentialsEnableService, GetPrefName(REMEMBER_PASSWORDS_ENABLED)); EXPECT_EQ(password_manager::prefs::kCredentialsEnableAutosignin, GetPrefName(PASSWORD_MANAGER_AUTO_SIGNIN_ENABLED)); EXPECT_EQ(password_manager::prefs::kPasswordLeakDetectionEnabled, GetPrefName(PASSWORD_MANAGER_LEAK_DETECTION_ENABLED)); EXPECT_EQ(prefs::kSupervisedUserSafeSites, GetPrefName(SUPERVISED_USER_SAFE_SITES)); EXPECT_EQ(prefs::kDefaultSupervisedUserFilteringBehavior, GetPrefName(DEFAULT_SUPERVISED_USER_FILTERING_BEHAVIOR)); EXPECT_EQ(prefs::kSupervisedUserId, GetPrefName(SUPERVISED_USER_ID)); EXPECT_EQ(prefs::kSupervisedUserCustodianEmail, GetPrefName(SUPERVISED_USER_CUSTODIAN_EMAIL)); EXPECT_EQ(prefs::kSupervisedUserSecondCustodianName, GetPrefName(SUPERVISED_USER_SECOND_CUSTODIAN_NAME)); EXPECT_EQ(prefs::kSupervisedUserSecondCustodianEmail, GetPrefName(SUPERVISED_USER_SECOND_CUSTODIAN_EMAIL)); EXPECT_EQ(prefs::kClickedUpdateMenuItem, GetPrefName(CLICKED_UPDATE_MENU_ITEM)); EXPECT_EQ(prefs::kLatestVersionWhenClickedUpdateMenuItem, GetPrefName(LATEST_VERSION_WHEN_CLICKED_UPDATE_MENU_ITEM)); EXPECT_EQ(prefs::kBlockThirdPartyCookies, GetPrefName(BLOCK_THIRD_PARTY_COOKIES)); EXPECT_EQ(prefs::kCookieControlsMode, GetPrefName(COOKIE_CONTROLS_MODE)); EXPECT_EQ(prefs::kEnableDoNotTrack, GetPrefName(ENABLE_DO_NOT_TRACK)); EXPECT_EQ(prefs::kPrintingEnabled, GetPrefName(PRINTING_ENABLED)); EXPECT_EQ(prefs::kOfferTranslateEnabled, GetPrefName(OFFER_TRANSLATE_ENABLED)); EXPECT_EQ(prefs::kNotificationsVibrateEnabled, GetPrefName(NOTIFICATIONS_VIBRATE_ENABLED)); EXPECT_EQ(embedder_support::kAlternateErrorPagesEnabled, GetPrefName(ALTERNATE_ERROR_PAGES_ENABLED)); EXPECT_EQ(prefs::kGoogleServicesLastUsername, GetPrefName(SYNC_LAST_ACCOUNT_NAME)); EXPECT_EQ(prefs::kWebKitPasswordEchoEnabled, GetPrefName(WEBKIT_PASSWORD_ECHO_ENABLED)); EXPECT_EQ(prefs::kWebKitForceDarkModeEnabled, GetPrefName(WEBKIT_FORCE_DARK_MODE_ENABLED)); EXPECT_EQ(prefs::kHomePage, GetPrefName(HOME_PAGE)); EXPECT_EQ(autofill::prefs::kAutofillCreditCardFidoAuthEnabled, GetPrefName(AUTOFILL_CREDIT_CARD_FIDO_AUTH_ENABLED)); EXPECT_EQ(prefs::kEnableQuietNotificationPermissionUi, GetPrefName(ENABLE_QUIET_NOTIFICATION_PERMISSION_UI)); // If this check fails, a pref is missing a test case above. EXPECT_EQ(Pref::PREF_NUM_PREFS, pref_count_); } } // namespace
47.504505
79
0.779632
sarang-apps
3397195f0f5fc2b4b3f9b200ccb92e83f1cb48f7
6,744
hpp
C++
se_core/include/se/geometry/octree_collision.hpp
hexagon-geo-surv/supereight-public
29a978956d2b169a3f34eed9bc374e325551c10b
[ "MIT" ]
null
null
null
se_core/include/se/geometry/octree_collision.hpp
hexagon-geo-surv/supereight-public
29a978956d2b169a3f34eed9bc374e325551c10b
[ "MIT" ]
null
null
null
se_core/include/se/geometry/octree_collision.hpp
hexagon-geo-surv/supereight-public
29a978956d2b169a3f34eed9bc374e325551c10b
[ "MIT" ]
null
null
null
/* Copyright 2016 Emanuele Vespa, Imperial College London Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef OCTREE_COLLISION_HPP #define OCTREE_COLLISION_HPP #include "../node.hpp" #include "../octree.hpp" #include "aabb_collision.hpp" namespace se { template<typename T> using VoxelBlockType = typename T::VoxelBlockType; namespace geometry { enum class collision_status { occupied, unseen, empty }; /*! \brief Implements a simple state machine to update the collision status. * The importance order is given as follows in ascending order: * Empty, Unseen, Occupied. * \param previous_status * \param new_status */ inline collision_status update_status(const collision_status previous_status, const collision_status new_status) { switch(previous_status) { case collision_status::unseen: if(new_status != collision_status::occupied) return previous_status; else return new_status; break; case collision_status::occupied: return previous_status; break; default: return new_status; break; } } /*! \brief Perform a collision test for each voxel value in the input voxel * block. The test function test takes as input a voxel value and returns a * collision_status. This is used to distinguish between seen-empty voxels and * occupied voxels. * \param block voxel block of type FieldType * \param test function that takes a voxel and returns a collision_status value */ template <typename FieldType, template <typename FieldT> class VoxelBlockT, typename TestVoxelF> collision_status collides_with(const VoxelBlockT<FieldType>* block, const Eigen::Vector3i bbox_coord, const Eigen::Vector3i size, TestVoxelF test) { collision_status status = collision_status::empty; const Eigen::Vector3i block_coord = block->coordinates(); int x, y, z, block_size; block_size = (int) VoxelBlockT<FieldType>::size_li; int x_last = block_coord.x() + block_size; int y_last = block_coord.y() + block_size; int z_last = block_coord.z() + block_size; for(z = block_coord.z(); z < z_last; ++z){ for (y = block_coord.y(); y < y_last; ++y){ for (x = block_coord.x(); x < x_last; ++x){ typename VoxelBlockT<FieldType>::VoxelData data; const Eigen::Vector3i voxel_coord{x, y, z}; if(!geometry::aabb_aabb_collision(bbox_coord, size, voxel_coord, Eigen::Vector3i::Constant(1))) continue; data = block->data(Eigen::Vector3i(x, y, z)); status = update_status(status, test(data)); } } } return status; } /*! \brief Perform a collision test between the input octree map and the * input axis aligned bounding box bbox_coord of extension size. The test function * test takes as input a voxel data and returns a collision_status. This is * used to distinguish between seen-empty voxels and occupied voxels. * \param octree octree map * \param bbox_coord test bounding box lower bottom corner * \param size extension in number of voxels of the bounding box * \param test function that takes a voxel and returns a collision_status data */ template <typename FieldType, typename TestVoxelF> collision_status collides_with(const Octree<FieldType>& octree, const Eigen::Vector3i bbox_coord, const Eigen::Vector3i bbox_size, TestVoxelF test) { typedef struct stack_entry { se::Node<FieldType>* node_ptr; Eigen::Vector3i coordinates; int size; typename se::Node<FieldType>::VoxelData parent_data; } stack_entry; stack_entry stack[Octree<FieldType>::max_voxel_depth * 8 + 1]; size_t stack_idx = 0; se::Node<FieldType>* node = octree.root(); if(!node) return collision_status::unseen; stack_entry current; current.node_ptr = node; current.size = octree.size(); current.coordinates = {0, 0, 0}; current.parent_data = FieldType::initData(); stack[stack_idx++] = current; collision_status status = collision_status::empty; while(stack_idx != 0){ node = current.node_ptr; if(node->isBlock()){ status = collides_with(static_cast<VoxelBlockType<FieldType>*>(node), bbox_coord, bbox_size, test); } if(node->children_mask() == 0) { current = stack[--stack_idx]; continue; } for(int child_idx = 0; child_idx < 8; ++child_idx){ se::Node<FieldType>* child = node->child(child_idx); stack_entry child_descr; child_descr.node_ptr = nullptr; child_descr.size = current.size / 2; child_descr.coordinates = Eigen::Vector3i(current.coordinates.x() + child_descr.size*((child_idx & 1) > 0), current.coordinates.y() + child_descr.size*((child_idx & 2) > 0), current.coordinates.z() + child_descr.size*((child_idx & 4) > 0)); const bool overlaps = geometry::aabb_aabb_collision(bbox_coord, bbox_size, child_descr.coordinates, Eigen::Vector3i::Constant(child_descr.size)); if(overlaps && child != nullptr) { child_descr.node_ptr = child; child_descr.parent_data = node->childData(0); stack[stack_idx++] = child_descr; } else if(overlaps && child == nullptr) { status = update_status(status, test(node->childData(0))); } } current = stack[--stack_idx]; } return status; } } } #endif
37.675978
96
0.714561
hexagon-geo-surv
3397507940455c76012aaa8f7131477356eca3a0
11,711
hh
C++
third_party/masstree-beta/masstree_remove.hh
nilyibo/eRPC
c9ec2c81672c45cca04a8bb2e0d7887c3e8cff32
[ "Apache-2.0" ]
1
2022-03-08T00:36:10.000Z
2022-03-08T00:36:10.000Z
third_party/masstree-beta/masstree_remove.hh
nilyibo/eRPC
c9ec2c81672c45cca04a8bb2e0d7887c3e8cff32
[ "Apache-2.0" ]
null
null
null
third_party/masstree-beta/masstree_remove.hh
nilyibo/eRPC
c9ec2c81672c45cca04a8bb2e0d7887c3e8cff32
[ "Apache-2.0" ]
null
null
null
/* Masstree * Eddie Kohler, Yandong Mao, Robert Morris * Copyright (c) 2012-2016 President and Fellows of Harvard College * Copyright (c) 2012-2016 Massachusetts Institute of Technology * * 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, subject to the conditions * listed in the Masstree LICENSE file. These conditions include: you must * preserve this copyright notice, and you cannot mention the copyright * holders in advertising related to the Software without their permission. * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This * notice is a summary of the Masstree LICENSE file; the license in that file * is legally binding. */ #ifndef MASSTREE_REMOVE_HH #define MASSTREE_REMOVE_HH #include "masstree_get.hh" #include "btree_leaflink.hh" #include "circular_int.hh" namespace Masstree { template <typename P> bool tcursor<P>::gc_layer(threadinfo& ti) { find_locked(ti); masstree_precondition(!n_->deleted() && !n_->deleted_layer()); // find_locked might return early if another gc_layer attempt has // succeeded at removing multiple tree layers. So check that the whole // key has been consumed if (ka_.has_suffix()) return false; // find the slot for the child tree // ka_ is a multiple of ikey_size bytes long. We are looking for the entry // for the next tree layer, which has keylenx_ corresponding to ikey_size+1. // So if has_value(), then we found an entry for the same ikey, but with // length ikey_size; we need to adjust ki_. kx_.i += has_value(); if (kx_.i >= n_->size()) return false; permuter_type perm(n_->permutation_); kx_.p = perm[kx_.i]; if (n_->ikey0_[kx_.p] != ka_.ikey() || !n_->is_layer(kx_.p)) return false; // remove redundant internode layers node_type *layer; while (1) { layer = n_->lv_[kx_.p].layer(); if (!layer->is_root()) { n_->lv_[kx_.p] = layer->maybe_parent(); continue; } if (layer->isleaf()) break; internode_type *in = static_cast<internode_type *>(layer); if (in->size() > 0) return false; in->lock(*layer, ti.lock_fence(tc_internode_lock)); if (!in->is_root() || in->size() > 0) goto unlock_layer; node_type *child = in->child_[0]; child->make_layer_root(); n_->lv_[kx_.p] = child; in->mark_split(); in->set_parent(child); // ensure concurrent reader finds true root // NB: now in->parent() might weirdly be a LEAF! in->unlock(); in->deallocate_rcu(ti); } { leaf_type* lf = static_cast<leaf_type*>(layer); if (lf->size() > 0) return false; lf->lock(*lf, ti.lock_fence(tc_leaf_lock)); if (!lf->is_root() || lf->size() > 0) goto unlock_layer; // child is an empty leaf: kill it masstree_invariant(!lf->prev_ && !lf->next_.ptr); masstree_invariant(!lf->deleted()); masstree_invariant(!lf->deleted_layer()); if (P::need_phantom_epoch && circular_int<typename P::phantom_epoch_type>::less(n_->phantom_epoch_[0], lf->phantom_epoch_[0])) n_->phantom_epoch_[0] = lf->phantom_epoch_[0]; lf->mark_deleted_layer(); // NB DO NOT mark as deleted (see above) lf->unlock(); lf->deallocate_rcu(ti); return true; } unlock_layer: layer->unlock(); return false; } template <typename P> struct gc_layer_rcu_callback : public P::threadinfo_type::mrcu_callback { typedef typename P::threadinfo_type threadinfo; node_base<P>* root_; int len_; char s_[0]; gc_layer_rcu_callback(node_base<P>* root, Str prefix) : root_(root), len_(prefix.length()) { memcpy(s_, prefix.data(), len_); } void operator()(threadinfo& ti); size_t size() const { return len_ + sizeof(*this); } static void make(node_base<P>* root, Str prefix, threadinfo& ti); }; template <typename P> void gc_layer_rcu_callback<P>::operator()(threadinfo& ti) { while (!root_->is_root()) root_ = root_->maybe_parent(); if (!root_->deleted()) { // if not destroying tree... tcursor<P> lp(root_, s_, len_); bool do_remove = lp.gc_layer(ti); if (!do_remove || !lp.finish_remove(ti)) lp.n_->unlock(); ti.deallocate(this, size(), memtag_masstree_gc); } } template <typename P> void gc_layer_rcu_callback<P>::make(node_base<P>* root, Str prefix, threadinfo& ti) { size_t sz = prefix.len + sizeof(gc_layer_rcu_callback<P>); void *data = ti.allocate(sz, memtag_masstree_gc); gc_layer_rcu_callback<P> *cb = new(data) gc_layer_rcu_callback<P>(root, prefix); ti.rcu_register(cb); } template <typename P> bool tcursor<P>::finish_remove(threadinfo& ti) { if (n_->modstate_ == leaf<P>::modstate_insert) { n_->mark_insert(); n_->modstate_ = leaf<P>::modstate_remove; } permuter_type perm(n_->permutation_); perm.remove(kx_.i); n_->permutation_ = perm.value(); if (perm.size()) return false; else return remove_leaf(n_, root_, ka_.prefix_string(), ti); } template <typename P> bool tcursor<P>::remove_leaf(leaf_type* leaf, node_type* root, Str prefix, threadinfo& ti) { if (!leaf->prev_) { if (!leaf->next_.ptr && !prefix.empty()) gc_layer_rcu_callback<P>::make(root, prefix, ti); return false; } // mark leaf deleted, RCU-free leaf->mark_deleted(); leaf->deallocate_rcu(ti); // Ensure node that becomes responsible for our keys has its phantom epoch // kept up to date while (P::need_phantom_epoch) { leaf_type *prev = leaf->prev_; typename P::phantom_epoch_type prev_ts = prev->phantom_epoch(); while (circular_int<typename P::phantom_epoch_type>::less(prev_ts, leaf->phantom_epoch()) && !bool_cmpxchg(&prev->phantom_epoch_[0], prev_ts, leaf->phantom_epoch())) prev_ts = prev->phantom_epoch(); fence(); if (prev == leaf->prev_) break; } // Unlink leaf from doubly-linked leaf list btree_leaflink<leaf_type>::unlink(leaf); // Remove leaf from tree. This is simple unless the leaf is the first // child of its parent, in which case we need to traverse up until we find // its key. node_type *n = leaf; ikey_type ikey = leaf->ikey_bound(); while (1) { internode_type *p = n->locked_parent(ti); masstree_invariant(p); n->unlock(); int kp = internode_type::bound_type::upper(ikey, *p); masstree_invariant(kp == 0 || p->compare_key(ikey, kp - 1) == 0); if (kp > 0) { p->mark_insert(); p->shift_down(kp - 1, kp, p->nkeys_ - kp); --p->nkeys_; if (kp > 1 || p->child_[0]) return collapse(p, ikey, root, prefix, ti); } if (p->size() == 0) { p->mark_deleted(); p->deallocate_rcu(ti); } else return reshape(p, ikey, root, prefix, ti); n = p; } } template <typename P> bool tcursor<P>::reshape(internode_type* n, ikey_type ikey, node_type* root, Str prefix, threadinfo& ti) { masstree_precondition(n && n->locked()); n->child_[0] = 0; ikey_type patchkey = n->ikey0_[0]; while (1) { internode_type *p = n->locked_parent(ti); masstree_invariant(p); n->unlock(); int kp = internode_type::bound_type::upper(ikey, *p); masstree_invariant(kp == 0 || p->compare_key(ikey, kp - 1) == 0); if (kp > 0) { p->mark_insert(); p->ikey0_[kp - 1] = patchkey; if (kp > 1 || p->child_[0]) return collapse(p, ikey, root, prefix, ti); } n = p; } } template <typename P> bool tcursor<P>::collapse(internode_type* n, ikey_type ikey, node_type* root, Str prefix, threadinfo& ti) { masstree_precondition(n && n->locked()); while (n->size() == 0) { internode_type *p = n->locked_parent(ti); if (!n->parent_exists(p)) { if (!prefix.empty()) gc_layer_rcu_callback<P>::make(root, prefix, ti); break; } int kp = key_upper_bound(ikey, *p); masstree_invariant(p->child_[kp] == n); p->child_[kp] = n->child_[0]; n->child_[0]->set_parent(p); n->mark_deleted(); n->unlock(); n->deallocate_rcu(ti); n = p; } n->unlock(); return true; } template <typename P> struct destroy_rcu_callback : public P::threadinfo_type::mrcu_callback { typedef typename P::threadinfo_type threadinfo; typedef typename node_base<P>::leaf_type leaf_type; typedef typename node_base<P>::internode_type internode_type; node_base<P>* root_; int count_; destroy_rcu_callback(node_base<P>* root) : root_(root), count_(0) { } void operator()(threadinfo& ti); static void make(node_base<P>* root, Str prefix, threadinfo& ti); private: static inline node_base<P>** link_ptr(node_base<P>* n); static inline void enqueue(node_base<P>* n, node_base<P>**& tailp); }; template <typename P> inline node_base<P>** destroy_rcu_callback<P>::link_ptr(node_base<P>* n) { if (n->isleaf()) return &static_cast<leaf_type*>(n)->parent_; else return &static_cast<internode_type*>(n)->parent_; } template <typename P> inline void destroy_rcu_callback<P>::enqueue(node_base<P>* n, node_base<P>**& tailp) { *tailp = n; tailp = link_ptr(n); } template <typename P> void destroy_rcu_callback<P>::operator()(threadinfo& ti) { if (++count_ == 1) { while (!root_->is_root()) root_ = root_->maybe_parent(); root_->lock(); root_->mark_deleted_tree(); // i.e., deleted but not splitting root_->unlock(); ti.rcu_register(this); return; } node_base<P>* workq; node_base<P>** tailp = &workq; enqueue(root_, tailp); while (node_base<P>* n = workq) { node_base<P>** linkp = link_ptr(n); if (linkp != tailp) workq = *linkp; else { workq = 0; tailp = &workq; } if (n->isleaf()) { leaf_type* l = static_cast<leaf_type*>(n); typename leaf_type::permuter_type perm = l->permutation(); for (int i = 0; i != l->size(); ++i) { int p = perm[i]; if (l->is_layer(p)) enqueue(l->lv_[p].layer(), tailp); } l->deallocate(ti); } else { internode_type* in = static_cast<internode_type*>(n); for (int i = 0; i != in->size() + 1; ++i) if (in->child_[i]) enqueue(in->child_[i], tailp); in->deallocate(ti); } } ti.deallocate(this, sizeof(this), memtag_masstree_gc); } template <typename P> void basic_table<P>::destroy(threadinfo& ti) { if (root_) { void* data = ti.allocate(sizeof(destroy_rcu_callback<P>), memtag_masstree_gc); destroy_rcu_callback<P>* cb = new(data) destroy_rcu_callback<P>(root_); ti.rcu_register(cb); root_ = 0; } } } // namespace Masstree #endif
31.566038
112
0.590129
nilyibo
3397d33cd6d6363a04c6089ed501d6436280c7cb
384
hpp
C++
Test/Common.hpp
chrisoldwood/Core
9c9dd95d8912c0108dc14e2409e6368bcdd7687e
[ "MIT" ]
6
2017-04-27T14:24:50.000Z
2020-09-11T13:13:05.000Z
Test/Common.hpp
chrisoldwood/XML
78913e7b9fbc1fbfec3779652d034ebd150668bc
[ "MIT" ]
1
2019-08-08T23:02:46.000Z
2020-04-29T21:42:31.000Z
Test/Common.hpp
chrisoldwood/XML
78913e7b9fbc1fbfec3779652d034ebd150668bc
[ "MIT" ]
1
2019-07-31T08:32:22.000Z
2019-07-31T08:32:22.000Z
//////////////////////////////////////////////////////////////////////////////// //! \file Common.hpp //! \brief File to include the most commonly used headers. //! \author Chris Oldwood // Check for previous inclusion #ifndef APP_COMMON_HPP #define APP_COMMON_HPP #if _MSC_VER > 1000 #pragma once #endif #include <Core/Common.hpp> #include <iostream> #endif // APP_COMMON_HPP
21.333333
80
0.580729
chrisoldwood
3398acb2bdb811ba7dd7a028188a3433e558a85a
1,387
cpp
C++
learncpp/classes/exercise1.cpp
Ethic41/learning_c-
17a444d5a41d4f559330cf54bfb4bf6d0f7bd8b3
[ "MIT" ]
2
2019-11-06T20:14:18.000Z
2020-12-26T20:30:28.000Z
learncpp/classes/exercise1.cpp
Ethic41/learning_c-
17a444d5a41d4f559330cf54bfb4bf6d0f7bd8b3
[ "MIT" ]
null
null
null
learncpp/classes/exercise1.cpp
Ethic41/learning_c-
17a444d5a41d4f559330cf54bfb4bf6d0f7bd8b3
[ "MIT" ]
null
null
null
/** * -=-<[ Bismillahirrahmanirrahim ]>-=- * Date : 2021-01-11 06:31:32 * Author : Dahir Muhammad Dahir (dahirmuhammad3@gmail.com) * About : Compile with g++ */ #include <iostream> #include <string> #include <sstream> using namespace std; class Student { private: int age; string first_name; string last_name; int standard; public: int get_age(){ return age; } void set_age(int new_age) { age = new_age; } string get_first_name() { return first_name; } void set_first_name(string new_first_name) { first_name = new_first_name; } string get_last_name() { return last_name; } void set_last_name(string new_last_name) { last_name = new_last_name; } int get_standard() { return standard; } void set_standard(int new_standard) { standard = new_standard; } string to_string(){ stringstream my_string_stream; string stringed; my_string_stream << age << ',' << first_name << ',' << last_name << ',' << standard; my_string_stream >> stringed; return stringed; } }; int main(){ //pass return 0; }
19.814286
96
0.516222
Ethic41
33994ee700fdc9232832e312423cbf656c2b79b4
35,534
cpp
C++
src/sedml/SedFunctionalRange.cpp
AMDmi3/libSEDML
a59c87df9298c8d72b199531f96b531bf4b4d9bb
[ "BSD-2-Clause" ]
7
2016-01-12T03:53:45.000Z
2019-10-17T21:23:37.000Z
src/sedml/SedFunctionalRange.cpp
AMDmi3/libSEDML
a59c87df9298c8d72b199531f96b531bf4b4d9bb
[ "BSD-2-Clause" ]
138
2015-05-29T19:18:34.000Z
2022-03-07T08:32:44.000Z
src/sedml/SedFunctionalRange.cpp
AMDmi3/libSEDML
a59c87df9298c8d72b199531f96b531bf4b4d9bb
[ "BSD-2-Clause" ]
12
2015-02-24T23:37:26.000Z
2021-11-02T17:11:27.000Z
/** * @file SedFunctionalRange.cpp * @brief Implementation of the SedFunctionalRange class. * @author DEVISER * * <!-------------------------------------------------------------------------- * This file is part of libSEDML. Please visit http://sed-ml.org for more * information about SED-ML. The latest version of libSEDML can be found on * github: https://github.com/fbergmann/libSEDML/ * * Copyright (c) 2013-2019, Frank T. Bergmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this * list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the * Free Software Foundation. A copy of the license agreement is provided in the * file named "LICENSE.txt" included with this software distribution and also * available online as http://sbml.org/software/libsbml/license.html * ------------------------------------------------------------------------ --> */ #include <sedml/SedFunctionalRange.h> #include <sedml/SedVariable.h> #include <sbml/xml/XMLInputStream.h> #include <sbml/math/MathML.h> using namespace std; LIBSEDML_CPP_NAMESPACE_BEGIN #ifdef __cplusplus /* * Creates a new SedFunctionalRange using the given SED-ML Level and @ p version * values. */ SedFunctionalRange::SedFunctionalRange(unsigned int level, unsigned int version) : SedRange(level, version) , mRange ("") , mMath (NULL) , mVariables (level, version) , mParameters (level, version) { setSedNamespacesAndOwn(new SedNamespaces(level, version)); connectToChild(); } /* * Creates a new SedFunctionalRange using the given SedNamespaces object @p * sedmlns. */ SedFunctionalRange::SedFunctionalRange(SedNamespaces *sedmlns) : SedRange(sedmlns) , mRange ("") , mMath (NULL) , mVariables (sedmlns) , mParameters (sedmlns) { setElementNamespace(sedmlns->getURI()); connectToChild(); } /* * Copy constructor for SedFunctionalRange. */ SedFunctionalRange::SedFunctionalRange(const SedFunctionalRange& orig) : SedRange( orig ) , mRange ( orig.mRange ) , mMath ( NULL ) , mVariables ( orig.mVariables ) , mParameters ( orig.mParameters ) { if (orig.mMath != NULL) { mMath = orig.mMath->deepCopy(); } connectToChild(); } /* * Assignment operator for SedFunctionalRange. */ SedFunctionalRange& SedFunctionalRange::operator=(const SedFunctionalRange& rhs) { if (&rhs != this) { SedRange::operator=(rhs); mRange = rhs.mRange; mVariables = rhs.mVariables; mParameters = rhs.mParameters; delete mMath; if (rhs.mMath != NULL) { mMath = rhs.mMath->deepCopy(); } else { mMath = NULL; } connectToChild(); } return *this; } /* * Creates and returns a deep copy of this SedFunctionalRange object. */ SedFunctionalRange* SedFunctionalRange::clone() const { return new SedFunctionalRange(*this); } /* * Destructor for SedFunctionalRange. */ SedFunctionalRange::~SedFunctionalRange() { delete mMath; mMath = NULL; } /* * Returns the value of the "range" attribute of this SedFunctionalRange. */ const std::string& SedFunctionalRange::getRange() const { return mRange; } /* * Predicate returning @c true if this SedFunctionalRange's "range" attribute * is set. */ bool SedFunctionalRange::isSetRange() const { return (mRange.empty() == false); } /* * Sets the value of the "range" attribute of this SedFunctionalRange. */ int SedFunctionalRange::setRange(const std::string& range) { if (!(SyntaxChecker::isValidInternalSId(range))) { return LIBSEDML_INVALID_ATTRIBUTE_VALUE; } else { mRange = range; return LIBSEDML_OPERATION_SUCCESS; } } /* * Unsets the value of the "range" attribute of this SedFunctionalRange. */ int SedFunctionalRange::unsetRange() { mRange.erase(); if (mRange.empty() == true) { return LIBSEDML_OPERATION_SUCCESS; } else { return LIBSEDML_OPERATION_FAILED; } } /* * Returns the value of the "math" element of this SedFunctionalRange. */ const LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode* SedFunctionalRange::getMath() const { return mMath; } /* * Returns the value of the "math" element of this SedFunctionalRange. */ LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode* SedFunctionalRange::getMath() { return mMath; } /* * Predicate returning @c true if this SedFunctionalRange's "math" element is * set. */ bool SedFunctionalRange::isSetMath() const { return (mMath != NULL); } /* * Sets the value of the "math" element of this SedFunctionalRange. */ int SedFunctionalRange::setMath(const LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode* math) { if (mMath == math) { return LIBSEDML_OPERATION_SUCCESS; } else if (math == NULL) { delete mMath; mMath = NULL; return LIBSEDML_OPERATION_SUCCESS; } else if (!(math->isWellFormedASTNode())) { return LIBSEDML_INVALID_OBJECT; } else { delete mMath; mMath = (math != NULL) ? math->deepCopy() : NULL; return LIBSEDML_OPERATION_SUCCESS; } } /* * Unsets the value of the "math" element of this SedFunctionalRange. */ int SedFunctionalRange::unsetMath() { delete mMath; mMath = NULL; return LIBSEDML_OPERATION_SUCCESS; } /* * Returns the SedListOfVariables from this SedFunctionalRange. */ const SedListOfVariables* SedFunctionalRange::getListOfVariables() const { return &mVariables; } /* * Returns the SedListOfVariables from this SedFunctionalRange. */ SedListOfVariables* SedFunctionalRange::getListOfVariables() { return &mVariables; } /* * Get a SedVariable from the SedFunctionalRange. */ SedVariable* SedFunctionalRange::getVariable(unsigned int n) { return mVariables.get(n); } /* * Get a SedVariable from the SedFunctionalRange. */ const SedVariable* SedFunctionalRange::getVariable(unsigned int n) const { return mVariables.get(n); } /* * Get a SedVariable from the SedFunctionalRange based on its identifier. */ SedVariable* SedFunctionalRange::getVariable(const std::string& sid) { return mVariables.get(sid); } /* * Get a SedVariable from the SedFunctionalRange based on its identifier. */ const SedVariable* SedFunctionalRange::getVariable(const std::string& sid) const { return mVariables.get(sid); } /* * Get a SedVariable from the SedFunctionalRange based on the TaskReference to * which it refers. */ const SedVariable* SedFunctionalRange::getVariableByTaskReference(const std::string& sid) const { return mVariables.getByTaskReference(sid); } /* * Get a SedVariable from the SedFunctionalRange based on the TaskReference to * which it refers. */ SedVariable* SedFunctionalRange::getVariableByTaskReference(const std::string& sid) { return mVariables.getByTaskReference(sid); } /* * Get a SedVariable from the SedFunctionalRange based on the ModelReference to * which it refers. */ const SedVariable* SedFunctionalRange::getVariableByModelReference(const std::string& sid) const { return mVariables.getByModelReference(sid); } /* * Get a SedVariable from the SedFunctionalRange based on the ModelReference to * which it refers. */ SedVariable* SedFunctionalRange::getVariableByModelReference(const std::string& sid) { return mVariables.getByModelReference(sid); } /* * Adds a copy of the given SedVariable to this SedFunctionalRange. */ int SedFunctionalRange::addVariable(const SedVariable* sv) { if (sv == NULL) { return LIBSEDML_OPERATION_FAILED; } else if (sv->hasRequiredAttributes() == false) { return LIBSEDML_INVALID_OBJECT; } else if (getLevel() != sv->getLevel()) { return LIBSEDML_LEVEL_MISMATCH; } else if (getVersion() != sv->getVersion()) { return LIBSEDML_VERSION_MISMATCH; } else if (matchesRequiredSedNamespacesForAddition(static_cast<const SedBase*>(sv)) == false) { return LIBSEDML_NAMESPACES_MISMATCH; } else if (sv->isSetId() && (mVariables.get(sv->getId())) != NULL) { return LIBSEDML_DUPLICATE_OBJECT_ID; } else { return mVariables.append(sv); } } /* * Get the number of SedVariable objects in this SedFunctionalRange. */ unsigned int SedFunctionalRange::getNumVariables() const { return mVariables.size(); } /* * Creates a new SedVariable object, adds it to this SedFunctionalRange object * and returns the SedVariable object created. */ SedVariable* SedFunctionalRange::createVariable() { SedVariable* sv = NULL; try { sv = new SedVariable(getSedNamespaces()); } catch (...) { } if (sv != NULL) { mVariables.appendAndOwn(sv); } return sv; } /* * Removes the nth SedVariable from this SedFunctionalRange and returns a * pointer to it. */ SedVariable* SedFunctionalRange::removeVariable(unsigned int n) { return mVariables.remove(n); } /* * Removes the SedVariable from this SedFunctionalRange based on its identifier * and returns a pointer to it. */ SedVariable* SedFunctionalRange::removeVariable(const std::string& sid) { return mVariables.remove(sid); } /* * Returns the SedListOfParameters from this SedFunctionalRange. */ const SedListOfParameters* SedFunctionalRange::getListOfParameters() const { return &mParameters; } /* * Returns the SedListOfParameters from this SedFunctionalRange. */ SedListOfParameters* SedFunctionalRange::getListOfParameters() { return &mParameters; } /* * Get a SedParameter from the SedFunctionalRange. */ SedParameter* SedFunctionalRange::getParameter(unsigned int n) { return mParameters.get(n); } /* * Get a SedParameter from the SedFunctionalRange. */ const SedParameter* SedFunctionalRange::getParameter(unsigned int n) const { return mParameters.get(n); } /* * Get a SedParameter from the SedFunctionalRange based on its identifier. */ SedParameter* SedFunctionalRange::getParameter(const std::string& sid) { return mParameters.get(sid); } /* * Get a SedParameter from the SedFunctionalRange based on its identifier. */ const SedParameter* SedFunctionalRange::getParameter(const std::string& sid) const { return mParameters.get(sid); } /* * Adds a copy of the given SedParameter to this SedFunctionalRange. */ int SedFunctionalRange::addParameter(const SedParameter* sp) { if (sp == NULL) { return LIBSEDML_OPERATION_FAILED; } else if (sp->hasRequiredAttributes() == false) { return LIBSEDML_INVALID_OBJECT; } else if (getLevel() != sp->getLevel()) { return LIBSEDML_LEVEL_MISMATCH; } else if (getVersion() != sp->getVersion()) { return LIBSEDML_VERSION_MISMATCH; } else if (matchesRequiredSedNamespacesForAddition(static_cast<const SedBase*>(sp)) == false) { return LIBSEDML_NAMESPACES_MISMATCH; } else if (sp->isSetId() && (mParameters.get(sp->getId())) != NULL) { return LIBSEDML_DUPLICATE_OBJECT_ID; } else { return mParameters.append(sp); } } /* * Get the number of SedParameter objects in this SedFunctionalRange. */ unsigned int SedFunctionalRange::getNumParameters() const { return mParameters.size(); } /* * Creates a new SedParameter object, adds it to this SedFunctionalRange object * and returns the SedParameter object created. */ SedParameter* SedFunctionalRange::createParameter() { SedParameter* sp = NULL; try { sp = new SedParameter(getSedNamespaces()); } catch (...) { } if (sp != NULL) { mParameters.appendAndOwn(sp); } return sp; } /* * Removes the nth SedParameter from this SedFunctionalRange and returns a * pointer to it. */ SedParameter* SedFunctionalRange::removeParameter(unsigned int n) { return mParameters.remove(n); } /* * Removes the SedParameter from this SedFunctionalRange based on its * identifier and returns a pointer to it. */ SedParameter* SedFunctionalRange::removeParameter(const std::string& sid) { return mParameters.remove(sid); } /* * @copydoc doc_renamesidref_common */ void SedFunctionalRange::renameSIdRefs(const std::string& oldid, const std::string& newid) { if (isSetRange() && mRange == oldid) { setRange(newid); } if (isSetMath()) { mMath->renameSIdRefs(oldid, newid); } } /* * Returns the XML element name of this SedFunctionalRange object. */ const std::string& SedFunctionalRange::getElementName() const { static const string name = "functionalRange"; return name; } /* * Returns the libSEDML type code for this SedFunctionalRange object. */ int SedFunctionalRange::getTypeCode() const { return SEDML_RANGE_FUNCTIONALRANGE; } /* * Predicate returning @c true if all the required attributes for this * SedFunctionalRange object have been set. */ bool SedFunctionalRange::hasRequiredAttributes() const { bool allPresent = SedRange::hasRequiredAttributes(); if (isSetRange() == false) { allPresent = false; } return allPresent; } /* * Predicate returning @c true if all the required elements for this * SedFunctionalRange object have been set. */ bool SedFunctionalRange::hasRequiredElements() const { bool allPresent = SedRange::hasRequiredElements(); return allPresent; } /** @cond doxygenLibSEDMLInternal */ /* * Write any contained elements */ void SedFunctionalRange::writeElements(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream) const { SedRange::writeElements(stream); if (isSetMath() == true) { writeMathML(getMath(), stream, NULL); } if (getNumVariables() > 0) { mVariables.write(stream); } if (getNumParameters() > 0) { mParameters.write(stream); } } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Accepts the given SedVisitor */ bool SedFunctionalRange::accept(SedVisitor& v) const { return false; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Sets the parent SedDocument */ void SedFunctionalRange::setSedDocument(SedDocument* d) { SedRange::setSedDocument(d); mVariables.setSedDocument(d); mParameters.setSedDocument(d); } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Connects to child elements */ void SedFunctionalRange::connectToChild() { SedRange::connectToChild(); mVariables.connectToParent(this); mParameters.connectToParent(this); } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Gets the value of the "attributeName" attribute of this SedFunctionalRange. */ int SedFunctionalRange::getAttribute(const std::string& attributeName, bool& value) const { int return_value = SedRange::getAttribute(attributeName, value); return return_value; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Gets the value of the "attributeName" attribute of this SedFunctionalRange. */ int SedFunctionalRange::getAttribute(const std::string& attributeName, int& value) const { int return_value = SedRange::getAttribute(attributeName, value); return return_value; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Gets the value of the "attributeName" attribute of this SedFunctionalRange. */ int SedFunctionalRange::getAttribute(const std::string& attributeName, double& value) const { int return_value = SedRange::getAttribute(attributeName, value); return return_value; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Gets the value of the "attributeName" attribute of this SedFunctionalRange. */ int SedFunctionalRange::getAttribute(const std::string& attributeName, unsigned int& value) const { int return_value = SedRange::getAttribute(attributeName, value); return return_value; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Gets the value of the "attributeName" attribute of this SedFunctionalRange. */ int SedFunctionalRange::getAttribute(const std::string& attributeName, std::string& value) const { int return_value = SedRange::getAttribute(attributeName, value); if (return_value == LIBSEDML_OPERATION_SUCCESS) { return return_value; } if (attributeName == "range") { value = getRange(); return_value = LIBSEDML_OPERATION_SUCCESS; } return return_value; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Predicate returning @c true if this SedFunctionalRange's attribute * "attributeName" is set. */ bool SedFunctionalRange::isSetAttribute(const std::string& attributeName) const { bool value = SedRange::isSetAttribute(attributeName); if (attributeName == "range") { value = isSetRange(); } return value; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Sets the value of the "attributeName" attribute of this SedFunctionalRange. */ int SedFunctionalRange::setAttribute(const std::string& attributeName, bool value) { int return_value = SedRange::setAttribute(attributeName, value); return return_value; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Sets the value of the "attributeName" attribute of this SedFunctionalRange. */ int SedFunctionalRange::setAttribute(const std::string& attributeName, int value) { int return_value = SedRange::setAttribute(attributeName, value); return return_value; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Sets the value of the "attributeName" attribute of this SedFunctionalRange. */ int SedFunctionalRange::setAttribute(const std::string& attributeName, double value) { int return_value = SedRange::setAttribute(attributeName, value); return return_value; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Sets the value of the "attributeName" attribute of this SedFunctionalRange. */ int SedFunctionalRange::setAttribute(const std::string& attributeName, unsigned int value) { int return_value = SedRange::setAttribute(attributeName, value); return return_value; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Sets the value of the "attributeName" attribute of this SedFunctionalRange. */ int SedFunctionalRange::setAttribute(const std::string& attributeName, const std::string& value) { int return_value = SedRange::setAttribute(attributeName, value); if (attributeName == "range") { return_value = setRange(value); } return return_value; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Unsets the value of the "attributeName" attribute of this * SedFunctionalRange. */ int SedFunctionalRange::unsetAttribute(const std::string& attributeName) { int value = SedRange::unsetAttribute(attributeName); if (attributeName == "range") { value = unsetRange(); } return value; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Creates and returns an new "elementName" object in this SedFunctionalRange. */ SedBase* SedFunctionalRange::createChildObject(const std::string& elementName) { SedRange* obj = NULL; if (elementName == "variable") { return createVariable(); } if (elementName == "parameter") { return createParameter(); } return obj; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Adds a new "elementName" object to this SedFunctionalRange. */ int SedFunctionalRange::addChildObject(const std::string& elementName, const SedBase* element) { if (elementName == "variable" && element->getTypeCode() == SEDML_VARIABLE) { return addVariable((const SedVariable*)(element)); } else if (elementName == "parameter" && element->getTypeCode() == SEDML_PARAMETER) { return addParameter((const SedParameter*)(element)); } return LIBSBML_OPERATION_FAILED; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Removes and returns the new "elementName" object with the given id in this * SedFunctionalRange. */ SedBase* SedFunctionalRange::removeChildObject(const std::string& elementName, const std::string& id) { if (elementName == "variable") { return removeVariable(id); } else if (elementName == "parameter") { return removeParameter(id); } return NULL; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Returns the number of "elementName" in this SedFunctionalRange. */ unsigned int SedFunctionalRange::getNumObjects(const std::string& elementName) { unsigned int n = 0; if (elementName == "variable") { return getNumVariables(); } else if (elementName == "parameter") { return getNumParameters(); } return n; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Returns the nth object of "objectName" in this SedFunctionalRange. */ SedBase* SedFunctionalRange::getObject(const std::string& elementName, unsigned int index) { SedBase* obj = NULL; if (elementName == "variable") { return getVariable(index); } else if (elementName == "parameter") { return getParameter(index); } return obj; } /** @endcond */ /* * Returns the first child element that has the given @p id in the model-wide * SId namespace, or @c NULL if no such object is found. */ SedBase* SedFunctionalRange::getElementBySId(const std::string& id) { if (id.empty()) { return NULL; } SedBase* obj = NULL; obj = mVariables.getElementBySId(id); if (obj != NULL) { return obj; } obj = mParameters.getElementBySId(id); if (obj != NULL) { return obj; } return obj; } /* * Returns a List of all child SedBase objects, including those nested to an * arbitrary depth. */ List* SedFunctionalRange::getAllElements(SedElementFilter* filter) { List* ret = new List(); List* sublist = NULL; SED_ADD_FILTERED_LIST(ret, sublist, mVariables, filter); SED_ADD_FILTERED_LIST(ret, sublist, mParameters, filter); return ret; } /** @cond doxygenLibSEDMLInternal */ /* * Creates a new object from the next XMLToken on the XMLInputStream */ SedBase* SedFunctionalRange::createObject(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream& stream) { SedBase* obj = SedRange::createObject(stream); const std::string& name = stream.peek().getName(); if (name == "listOfVariables") { if (getErrorLog() && mVariables.size() != 0) { getErrorLog()->logError(SedmlFunctionalRangeAllowedElements, getLevel(), getVersion(), "", getLine(), getColumn()); } obj = &mVariables; } else if (name == "listOfParameters") { if (getErrorLog() && mParameters.size() != 0) { getErrorLog()->logError(SedmlFunctionalRangeAllowedElements, getLevel(), getVersion(), "", getLine(), getColumn()); } obj = &mParameters; } connectToChild(); return obj; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Adds the expected attributes for this element */ void SedFunctionalRange::addExpectedAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes& attributes) { SedRange::addExpectedAttributes(attributes); attributes.add("range"); } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Reads the expected attributes into the member data variables */ void SedFunctionalRange::readAttributes( const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLAttributes& attributes, const LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes& expectedAttributes) { unsigned int level = getLevel(); unsigned int version = getVersion(); unsigned int numErrs; bool assigned = false; SedErrorLog* log = getErrorLog(); SedRange::readAttributes(attributes, expectedAttributes); if (log) { numErrs = log->getNumErrors(); for (int n = numErrs-1; n >= 0; n--) { if (log->getError(n)->getErrorId() == SedUnknownCoreAttribute) { const std::string details = log->getError(n)->getMessage(); log->remove(SedUnknownCoreAttribute); log->logError(SedmlFunctionalRangeAllowedAttributes, level, version, details, getLine(), getColumn()); } } } // // range SIdRef (use = "required" ) // assigned = attributes.readInto("range", mRange); if (assigned == true) { if (mRange.empty() == true) { logEmptyString(mRange, level, version, "<SedFunctionalRange>"); } else if (SyntaxChecker::isValidSBMLSId(mRange) == false) { std::string msg = "The range attribute on the <" + getElementName() + ">"; if (isSetId()) { msg += " with id '" + getId() + "'"; } msg += " is '" + mRange + "', which does not conform to the syntax."; logError(SedmlFunctionalRangeRangeMustBeRange, level, version, msg, getLine(), getColumn()); } } else { if (log) { std::string message = "Sedml attribute 'range' is missing from the " "<SedFunctionalRange> element."; log->logError(SedmlFunctionalRangeAllowedAttributes, level, version, message, getLine(), getColumn()); } } } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Reads other XML such as math/notes etc. */ bool SedFunctionalRange::readOtherXML(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream& stream) { bool read = false; const string& name = stream.peek().getName(); if (name == "math") { const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLToken elem = stream.peek(); const std::string prefix = checkMathMLNamespace(elem); delete mMath; mMath = readMathML(stream, prefix); read = true; } if (SedRange::readOtherXML(stream)) { read = true; } return read; } /** @endcond */ /** @cond doxygenLibSEDMLInternal */ /* * Writes the attributes to the stream */ void SedFunctionalRange::writeAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream) const { SedRange::writeAttributes(stream); if (isSetRange() == true) { stream.writeAttribute("range", getPrefix(), mRange); } } /** @endcond */ #endif /* __cplusplus */ /* * Creates a new SedFunctionalRange_t using the given SED-ML Level and @ p * version values. */ LIBSEDML_EXTERN SedFunctionalRange_t * SedFunctionalRange_create(unsigned int level, unsigned int version) { return new SedFunctionalRange(level, version); } /* * Creates and returns a deep copy of this SedFunctionalRange_t object. */ LIBSEDML_EXTERN SedFunctionalRange_t* SedFunctionalRange_clone(const SedFunctionalRange_t* sfr) { if (sfr != NULL) { return static_cast<SedFunctionalRange_t*>(sfr->clone()); } else { return NULL; } } /* * Frees this SedFunctionalRange_t object. */ LIBSEDML_EXTERN void SedFunctionalRange_free(SedFunctionalRange_t* sfr) { if (sfr != NULL) { delete sfr; } } /* * Returns the value of the "range" attribute of this SedFunctionalRange_t. */ LIBSEDML_EXTERN char * SedFunctionalRange_getRange(const SedFunctionalRange_t * sfr) { if (sfr == NULL) { return NULL; } return sfr->getRange().empty() ? NULL : safe_strdup(sfr->getRange().c_str()); } /* * Predicate returning @c 1 (true) if this SedFunctionalRange_t's "range" * attribute is set. */ LIBSEDML_EXTERN int SedFunctionalRange_isSetRange(const SedFunctionalRange_t * sfr) { return (sfr != NULL) ? static_cast<int>(sfr->isSetRange()) : 0; } /* * Sets the value of the "range" attribute of this SedFunctionalRange_t. */ LIBSEDML_EXTERN int SedFunctionalRange_setRange(SedFunctionalRange_t * sfr, const char * range) { return (sfr != NULL) ? sfr->setRange(range) : LIBSEDML_INVALID_OBJECT; } /* * Unsets the value of the "range" attribute of this SedFunctionalRange_t. */ LIBSEDML_EXTERN int SedFunctionalRange_unsetRange(SedFunctionalRange_t * sfr) { return (sfr != NULL) ? sfr->unsetRange() : LIBSEDML_INVALID_OBJECT; } /* * Returns the value of the "math" element of this SedFunctionalRange_t. */ LIBSEDML_EXTERN const LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode_t* SedFunctionalRange_getMath(const SedFunctionalRange_t * sfr) { if (sfr == NULL) { return NULL; } return (LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode_t*)(sfr->getMath()); } /* * Predicate returning @c 1 (true) if this SedFunctionalRange_t's "math" * element is set. */ LIBSEDML_EXTERN int SedFunctionalRange_isSetMath(const SedFunctionalRange_t * sfr) { return (sfr != NULL) ? static_cast<int>(sfr->isSetMath()) : 0; } /* * Sets the value of the "math" element of this SedFunctionalRange_t. */ LIBSEDML_EXTERN int SedFunctionalRange_setMath(SedFunctionalRange_t * sfr, const LIBSBML_CPP_NAMESPACE_QUALIFIER ASTNode_t* math) { return (sfr != NULL) ? sfr->setMath(math) : LIBSEDML_INVALID_OBJECT; } /* * Unsets the value of the "math" element of this SedFunctionalRange_t. */ LIBSEDML_EXTERN int SedFunctionalRange_unsetMath(SedFunctionalRange_t * sfr) { return (sfr != NULL) ? sfr->unsetMath() : LIBSEDML_INVALID_OBJECT; } /* * Returns a ListOf_t * containing SedVariable_t objects from this * SedFunctionalRange_t. */ LIBSEDML_EXTERN SedListOf_t* SedFunctionalRange_getListOfVariables(SedFunctionalRange_t* sfr) { return (sfr != NULL) ? sfr->getListOfVariables() : NULL; } /* * Get a SedVariable_t from the SedFunctionalRange_t. */ LIBSEDML_EXTERN SedVariable_t* SedFunctionalRange_getVariable(SedFunctionalRange_t* sfr, unsigned int n) { return (sfr != NULL) ? sfr->getVariable(n) : NULL; } /* * Get a SedVariable_t from the SedFunctionalRange_t based on its identifier. */ LIBSEDML_EXTERN SedVariable_t* SedFunctionalRange_getVariableById(SedFunctionalRange_t* sfr, const char *sid) { return (sfr != NULL && sid != NULL) ? sfr->getVariable(sid) : NULL; } /* * Get a SedVariable_t from the SedFunctionalRange_t based on the TaskReference * to which it refers. */ LIBSEDML_EXTERN SedVariable_t* SedFunctionalRange_getVariableByTaskReference(SedFunctionalRange_t* sfr, const char *sid) { return (sfr != NULL && sid != NULL) ? sfr->getVariableByTaskReference(sid) : NULL; } /* * Get a SedVariable_t from the SedFunctionalRange_t based on the * ModelReference to which it refers. */ LIBSEDML_EXTERN SedVariable_t* SedFunctionalRange_getVariableByModelReference(SedFunctionalRange_t* sfr, const char *sid) { return (sfr != NULL && sid != NULL) ? sfr->getVariableByModelReference(sid) : NULL; } /* * Adds a copy of the given SedVariable_t to this SedFunctionalRange_t. */ LIBSEDML_EXTERN int SedFunctionalRange_addVariable(SedFunctionalRange_t* sfr, const SedVariable_t* sv) { return (sfr != NULL) ? sfr->addVariable(sv) : LIBSEDML_INVALID_OBJECT; } /* * Get the number of SedVariable_t objects in this SedFunctionalRange_t. */ LIBSEDML_EXTERN unsigned int SedFunctionalRange_getNumVariables(SedFunctionalRange_t* sfr) { return (sfr != NULL) ? sfr->getNumVariables() : SEDML_INT_MAX; } /* * Creates a new SedVariable_t object, adds it to this SedFunctionalRange_t * object and returns the SedVariable_t object created. */ LIBSEDML_EXTERN SedVariable_t* SedFunctionalRange_createVariable(SedFunctionalRange_t* sfr) { return (sfr != NULL) ? sfr->createVariable() : NULL; } /* * Removes the nth SedVariable_t from this SedFunctionalRange_t and returns a * pointer to it. */ LIBSEDML_EXTERN SedVariable_t* SedFunctionalRange_removeVariable(SedFunctionalRange_t* sfr, unsigned int n) { return (sfr != NULL) ? sfr->removeVariable(n) : NULL; } /* * Removes the SedVariable_t from this SedFunctionalRange_t based on its * identifier and returns a pointer to it. */ LIBSEDML_EXTERN SedVariable_t* SedFunctionalRange_removeVariableById(SedFunctionalRange_t* sfr, const char* sid) { return (sfr != NULL && sid != NULL) ? sfr->removeVariable(sid) : NULL; } /* * Returns a ListOf_t * containing SedParameter_t objects from this * SedFunctionalRange_t. */ LIBSEDML_EXTERN SedListOf_t* SedFunctionalRange_getListOfParameters(SedFunctionalRange_t* sfr) { return (sfr != NULL) ? sfr->getListOfParameters() : NULL; } /* * Get a SedParameter_t from the SedFunctionalRange_t. */ LIBSEDML_EXTERN SedParameter_t* SedFunctionalRange_getParameter(SedFunctionalRange_t* sfr, unsigned int n) { return (sfr != NULL) ? sfr->getParameter(n) : NULL; } /* * Get a SedParameter_t from the SedFunctionalRange_t based on its identifier. */ LIBSEDML_EXTERN SedParameter_t* SedFunctionalRange_getParameterById(SedFunctionalRange_t* sfr, const char *sid) { return (sfr != NULL && sid != NULL) ? sfr->getParameter(sid) : NULL; } /* * Adds a copy of the given SedParameter_t to this SedFunctionalRange_t. */ LIBSEDML_EXTERN int SedFunctionalRange_addParameter(SedFunctionalRange_t* sfr, const SedParameter_t* sp) { return (sfr != NULL) ? sfr->addParameter(sp) : LIBSEDML_INVALID_OBJECT; } /* * Get the number of SedParameter_t objects in this SedFunctionalRange_t. */ LIBSEDML_EXTERN unsigned int SedFunctionalRange_getNumParameters(SedFunctionalRange_t* sfr) { return (sfr != NULL) ? sfr->getNumParameters() : SEDML_INT_MAX; } /* * Creates a new SedParameter_t object, adds it to this SedFunctionalRange_t * object and returns the SedParameter_t object created. */ LIBSEDML_EXTERN SedParameter_t* SedFunctionalRange_createParameter(SedFunctionalRange_t* sfr) { return (sfr != NULL) ? sfr->createParameter() : NULL; } /* * Removes the nth SedParameter_t from this SedFunctionalRange_t and returns a * pointer to it. */ LIBSEDML_EXTERN SedParameter_t* SedFunctionalRange_removeParameter(SedFunctionalRange_t* sfr, unsigned int n) { return (sfr != NULL) ? sfr->removeParameter(n) : NULL; } /* * Removes the SedParameter_t from this SedFunctionalRange_t based on its * identifier and returns a pointer to it. */ LIBSEDML_EXTERN SedParameter_t* SedFunctionalRange_removeParameterById(SedFunctionalRange_t* sfr, const char* sid) { return (sfr != NULL && sid != NULL) ? sfr->removeParameter(sid) : NULL; } /* * Predicate returning @c 1 (true) if all the required attributes for this * SedFunctionalRange_t object have been set. */ LIBSEDML_EXTERN int SedFunctionalRange_hasRequiredAttributes(const SedFunctionalRange_t * sfr) { return (sfr != NULL) ? static_cast<int>(sfr->hasRequiredAttributes()) : 0; } /* * Predicate returning @c 1 (true) if all the required elements for this * SedFunctionalRange_t object have been set. */ LIBSEDML_EXTERN int SedFunctionalRange_hasRequiredElements(const SedFunctionalRange_t * sfr) { return (sfr != NULL) ? static_cast<int>(sfr->hasRequiredElements()) : 0; } LIBSEDML_CPP_NAMESPACE_END
19.675526
80
0.69328
AMDmi3
3399b4eeb9d5e099b57c74d423684c4d0aec8b53
18,883
hpp
C++
reef-env/rocclr/device/comgrctx.hpp
SJTU-IPADS/reef-artifacts
8750974f2d6655525a2cc317bf2471914fe68dab
[ "Apache-2.0" ]
7
2022-03-23T07:04:20.000Z
2022-03-30T02:44:42.000Z
reef-env/rocclr/device/comgrctx.hpp
SJTU-IPADS/reef-artifacts
8750974f2d6655525a2cc317bf2471914fe68dab
[ "Apache-2.0" ]
null
null
null
reef-env/rocclr/device/comgrctx.hpp
SJTU-IPADS/reef-artifacts
8750974f2d6655525a2cc317bf2471914fe68dab
[ "Apache-2.0" ]
null
null
null
/* Copyright (c) 2008-present Advanced Micro Devices, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #pragma once #include <mutex> #if defined(USE_COMGR_LIBRARY) #include "top.hpp" #include "amd_comgr.h" namespace amd { typedef void (*t_amd_comgr_get_version)(size_t *major, size_t *minor); typedef amd_comgr_status_t (*t_amd_comgr_status_string)(amd_comgr_status_t status, const char ** status_string); typedef amd_comgr_status_t (*t_amd_comgr_get_isa_count)(size_t *count); typedef amd_comgr_status_t (*t_amd_comgr_get_isa_name)(size_t index, const char **isa_name); typedef amd_comgr_status_t (*t_amd_comgr_get_isa_metadata)(const char *isa_name, amd_comgr_metadata_node_t *metadata); typedef amd_comgr_status_t (*t_amd_comgr_create_data)(amd_comgr_data_kind_t kind, amd_comgr_data_t *data); typedef amd_comgr_status_t (*t_amd_comgr_release_data)(amd_comgr_data_t data); typedef amd_comgr_status_t (*t_amd_comgr_get_data_kind)(amd_comgr_data_t data, amd_comgr_data_kind_t *kind); typedef amd_comgr_status_t (*t_amd_comgr_set_data)(amd_comgr_data_t data, size_t size, const char* bytes); typedef amd_comgr_status_t (*t_amd_comgr_set_data_name)(amd_comgr_data_t data, const char* name); typedef amd_comgr_status_t (*t_amd_comgr_get_data)(amd_comgr_data_t data, size_t *size, char *bytes); typedef amd_comgr_status_t (*t_amd_comgr_get_data_name)(amd_comgr_data_t data, size_t *size, char *name); typedef amd_comgr_status_t (*t_amd_comgr_get_data_isa_name)(amd_comgr_data_t data, size_t *size, char *isa_name); typedef amd_comgr_status_t (*t_amd_comgr_get_data_metadata)(amd_comgr_data_t data, amd_comgr_metadata_node_t *metadata); typedef amd_comgr_status_t (*t_amd_comgr_destroy_metadata)(amd_comgr_metadata_node_t metadata); typedef amd_comgr_status_t (*t_amd_comgr_create_data_set)(amd_comgr_data_set_t *data_set); typedef amd_comgr_status_t (*t_amd_comgr_destroy_data_set)(amd_comgr_data_set_t data_set); typedef amd_comgr_status_t (*t_amd_comgr_data_set_add)(amd_comgr_data_set_t data_set, amd_comgr_data_t data); typedef amd_comgr_status_t (*t_amd_comgr_data_set_remove)(amd_comgr_data_set_t data_set, amd_comgr_data_kind_t data_kind); typedef amd_comgr_status_t (*t_amd_comgr_action_data_count)(amd_comgr_data_set_t data_set, amd_comgr_data_kind_t data_kind, size_t *count); typedef amd_comgr_status_t (*t_amd_comgr_action_data_get_data)(amd_comgr_data_set_t data_set, amd_comgr_data_kind_t data_kind, size_t index, amd_comgr_data_t *data); typedef amd_comgr_status_t (*t_amd_comgr_create_action_info)(amd_comgr_action_info_t *action_info); typedef amd_comgr_status_t (*t_amd_comgr_destroy_action_info)(amd_comgr_action_info_t action_info); typedef amd_comgr_status_t (*t_amd_comgr_action_info_set_isa_name)(amd_comgr_action_info_t action_info, const char *isa_name); typedef amd_comgr_status_t (*t_amd_comgr_action_info_get_isa_name)(amd_comgr_action_info_t action_info, size_t *size, char *isa_name); typedef amd_comgr_status_t (*t_amd_comgr_action_info_set_language)(amd_comgr_action_info_t action_info, amd_comgr_language_t language); typedef amd_comgr_status_t (*t_amd_comgr_action_info_get_language)(amd_comgr_action_info_t action_info, amd_comgr_language_t *language); typedef amd_comgr_status_t (*t_amd_comgr_action_info_set_option_list)(amd_comgr_action_info_t action_info, const char *options[], size_t count); typedef amd_comgr_status_t (*t_amd_comgr_action_info_get_option_list_count)(amd_comgr_action_info_t action_info, size_t *count); typedef amd_comgr_status_t (*t_amd_comgr_action_info_get_option_list_item)(amd_comgr_action_info_t action_info, size_t index, size_t *size, char *option); typedef amd_comgr_status_t (*t_amd_comgr_action_info_set_working_directory_path)(amd_comgr_action_info_t action_info, const char *path); typedef amd_comgr_status_t (*t_amd_comgr_action_info_get_working_directory_path)(amd_comgr_action_info_t action_info, size_t *size, char *path); typedef amd_comgr_status_t (*t_amd_comgr_action_info_set_logging)(amd_comgr_action_info_t action_info, bool logging); typedef amd_comgr_status_t (*t_amd_comgr_action_info_get_logging)(amd_comgr_action_info_t action_info, bool *logging); typedef amd_comgr_status_t (*t_amd_comgr_do_action)(amd_comgr_action_kind_t kind, amd_comgr_action_info_t info, amd_comgr_data_set_t input, amd_comgr_data_set_t result); typedef amd_comgr_status_t (*t_amd_comgr_get_metadata_kind)(amd_comgr_metadata_node_t metadata, amd_comgr_metadata_kind_t *kind); typedef amd_comgr_status_t (*t_amd_comgr_get_metadata_string)(amd_comgr_metadata_node_t metadata, size_t *size, char *string); typedef amd_comgr_status_t (*t_amd_comgr_get_metadata_map_size)(amd_comgr_metadata_node_t metadata, size_t *size); typedef amd_comgr_status_t (*t_amd_comgr_iterate_map_metadata)(amd_comgr_metadata_node_t metadata, amd_comgr_status_t(*callback)(amd_comgr_metadata_node_t key, amd_comgr_metadata_node_t value, void *user_data), void *user_data); typedef amd_comgr_status_t (*t_amd_comgr_metadata_lookup)(amd_comgr_metadata_node_t metadata, const char *key, amd_comgr_metadata_node_t *value); typedef amd_comgr_status_t (*t_amd_comgr_get_metadata_list_size)(amd_comgr_metadata_node_t metadata, size_t *size); typedef amd_comgr_status_t (*t_amd_comgr_index_list_metadata)(amd_comgr_metadata_node_t metadata, size_t index, amd_comgr_metadata_node_t *value); typedef amd_comgr_status_t (*t_amd_comgr_iterate_symbols)(amd_comgr_data_t data, amd_comgr_status_t(*callback)(amd_comgr_symbol_t symbol, void *user_data), void *user_data); typedef amd_comgr_status_t (*t_amd_comgr_symbol_lookup)(amd_comgr_data_t data, const char *name, amd_comgr_symbol_t *symbol); typedef amd_comgr_status_t (*t_amd_comgr_symbol_get_info)(amd_comgr_symbol_t symbol, amd_comgr_symbol_info_t attribute, void *value); struct ComgrEntryPoints { void* handle; t_amd_comgr_get_version amd_comgr_get_version; t_amd_comgr_status_string amd_comgr_status_string; t_amd_comgr_get_isa_count amd_comgr_get_isa_count; t_amd_comgr_get_isa_name amd_comgr_get_isa_name; t_amd_comgr_get_isa_metadata amd_comgr_get_isa_metadata; t_amd_comgr_create_data amd_comgr_create_data; t_amd_comgr_release_data amd_comgr_release_data; t_amd_comgr_get_data_kind amd_comgr_get_data_kind; t_amd_comgr_set_data amd_comgr_set_data; t_amd_comgr_set_data_name amd_comgr_set_data_name; t_amd_comgr_get_data amd_comgr_get_data; t_amd_comgr_get_data_name amd_comgr_get_data_name; t_amd_comgr_get_data_isa_name amd_comgr_get_data_isa_name; t_amd_comgr_get_data_metadata amd_comgr_get_data_metadata; t_amd_comgr_destroy_metadata amd_comgr_destroy_metadata; t_amd_comgr_create_data_set amd_comgr_create_data_set; t_amd_comgr_destroy_data_set amd_comgr_destroy_data_set; t_amd_comgr_data_set_add amd_comgr_data_set_add; t_amd_comgr_data_set_remove amd_comgr_data_set_remove; t_amd_comgr_action_data_count amd_comgr_action_data_count; t_amd_comgr_action_data_get_data amd_comgr_action_data_get_data; t_amd_comgr_create_action_info amd_comgr_create_action_info; t_amd_comgr_destroy_action_info amd_comgr_destroy_action_info; t_amd_comgr_action_info_set_isa_name amd_comgr_action_info_set_isa_name; t_amd_comgr_action_info_get_isa_name amd_comgr_action_info_get_isa_name; t_amd_comgr_action_info_set_language amd_comgr_action_info_set_language; t_amd_comgr_action_info_get_language amd_comgr_action_info_get_language; t_amd_comgr_action_info_set_option_list amd_comgr_action_info_set_option_list; t_amd_comgr_action_info_get_option_list_count amd_comgr_action_info_get_option_list_count; t_amd_comgr_action_info_get_option_list_item amd_comgr_action_info_get_option_list_item; t_amd_comgr_action_info_set_working_directory_path amd_comgr_action_info_set_working_directory_path; t_amd_comgr_action_info_get_working_directory_path amd_comgr_action_info_get_working_directory_path; t_amd_comgr_action_info_set_logging amd_comgr_action_info_set_logging; t_amd_comgr_action_info_get_logging amd_comgr_action_info_get_logging; t_amd_comgr_do_action amd_comgr_do_action; t_amd_comgr_get_metadata_kind amd_comgr_get_metadata_kind; t_amd_comgr_get_metadata_string amd_comgr_get_metadata_string; t_amd_comgr_get_metadata_map_size amd_comgr_get_metadata_map_size; t_amd_comgr_iterate_map_metadata amd_comgr_iterate_map_metadata; t_amd_comgr_metadata_lookup amd_comgr_metadata_lookup; t_amd_comgr_get_metadata_list_size amd_comgr_get_metadata_list_size; t_amd_comgr_index_list_metadata amd_comgr_index_list_metadata; t_amd_comgr_iterate_symbols amd_comgr_iterate_symbols; t_amd_comgr_symbol_lookup amd_comgr_symbol_lookup; t_amd_comgr_symbol_get_info amd_comgr_symbol_get_info; }; #ifdef COMGR_DYN_DLL #define COMGR_DYN(NAME) cep_.NAME #define GET_COMGR_SYMBOL(NAME) cep_.NAME = \ reinterpret_cast<t_##NAME>(Os::getSymbol(cep_.handle, #NAME)); \ if (nullptr == cep_.NAME) { return false; } #else #define COMGR_DYN(NAME) NAME #define GET_COMGR_SYMBOL(NAME) #endif class Comgr : public amd::AllStatic { public: static std::once_flag initialized; static bool LoadLib(); static bool IsReady() { return is_ready_; } static void get_version(size_t *major, size_t *minor) { COMGR_DYN(amd_comgr_get_version)(major, minor); } static amd_comgr_status_t status_string(amd_comgr_status_t status, const char ** status_string) { return COMGR_DYN(amd_comgr_status_string)(status, status_string); } static amd_comgr_status_t get_isa_count(size_t *count) { return COMGR_DYN(amd_comgr_get_isa_count)(count); } static amd_comgr_status_t get_isa_name(size_t index, const char **isa_name) { return COMGR_DYN(amd_comgr_get_isa_name)(index, isa_name); } static amd_comgr_status_t get_isa_metadata(const char *isa_name, amd_comgr_metadata_node_t *metadata) { return COMGR_DYN(amd_comgr_get_isa_metadata)(isa_name, metadata); } static amd_comgr_status_t create_data(amd_comgr_data_kind_t kind, amd_comgr_data_t *data) { return COMGR_DYN(amd_comgr_create_data)(kind, data); } static amd_comgr_status_t release_data(amd_comgr_data_t data) { return COMGR_DYN(amd_comgr_release_data)(data); } static amd_comgr_status_t get_data_kind(amd_comgr_data_t data, amd_comgr_data_kind_t *kind) { return COMGR_DYN(amd_comgr_get_data_kind)(data, kind); } static amd_comgr_status_t set_data(amd_comgr_data_t data, size_t size, const char* bytes) { return COMGR_DYN(amd_comgr_set_data)(data, size, bytes); } static amd_comgr_status_t set_data_name(amd_comgr_data_t data, const char* name) { return COMGR_DYN(amd_comgr_set_data_name)(data, name); } static amd_comgr_status_t get_data(amd_comgr_data_t data, size_t *size, char *bytes) { return COMGR_DYN(amd_comgr_get_data)(data, size, bytes); } static amd_comgr_status_t get_data_name(amd_comgr_data_t data, size_t *size, char *name) { return COMGR_DYN(amd_comgr_get_data_name)(data, size, name); } static amd_comgr_status_t get_data_isa_name(amd_comgr_data_t data, size_t *size, char *isa_name) { return COMGR_DYN(amd_comgr_get_data_isa_name)(data, size, isa_name); } static amd_comgr_status_t get_data_metadata(amd_comgr_data_t data, amd_comgr_metadata_node_t *metadata) { return COMGR_DYN(amd_comgr_get_data_metadata)(data, metadata); } static amd_comgr_status_t destroy_metadata(amd_comgr_metadata_node_t metadata) { return COMGR_DYN(amd_comgr_destroy_metadata)(metadata); } static amd_comgr_status_t create_data_set(amd_comgr_data_set_t *data_set) { return COMGR_DYN(amd_comgr_create_data_set)(data_set); } static amd_comgr_status_t destroy_data_set(amd_comgr_data_set_t data_set) { return COMGR_DYN(amd_comgr_destroy_data_set)(data_set); } static amd_comgr_status_t data_set_add(amd_comgr_data_set_t data_set, amd_comgr_data_t data) { return COMGR_DYN(amd_comgr_data_set_add)(data_set, data); } static amd_comgr_status_t data_set_remove(amd_comgr_data_set_t data_set, amd_comgr_data_kind_t data_kind) { return COMGR_DYN(amd_comgr_data_set_remove)(data_set, data_kind); } static amd_comgr_status_t action_data_count(amd_comgr_data_set_t data_set, amd_comgr_data_kind_t data_kind, size_t *count) { return COMGR_DYN(amd_comgr_action_data_count)(data_set, data_kind, count); } static amd_comgr_status_t action_data_get_data(amd_comgr_data_set_t data_set, amd_comgr_data_kind_t data_kind, size_t index, amd_comgr_data_t *data) { return COMGR_DYN(amd_comgr_action_data_get_data)(data_set, data_kind, index, data); } static amd_comgr_status_t create_action_info(amd_comgr_action_info_t *action_info) { return COMGR_DYN(amd_comgr_create_action_info)(action_info); } static amd_comgr_status_t destroy_action_info(amd_comgr_action_info_t action_info) { return COMGR_DYN(amd_comgr_destroy_action_info)(action_info); } static amd_comgr_status_t action_info_set_isa_name(amd_comgr_action_info_t action_info, const char *isa_name) { return COMGR_DYN(amd_comgr_action_info_set_isa_name)(action_info, isa_name); } static amd_comgr_status_t action_info_get_isa_name(amd_comgr_action_info_t action_info, size_t *size, char *isa_name) { return COMGR_DYN(amd_comgr_action_info_get_isa_name)(action_info, size, isa_name); } static amd_comgr_status_t action_info_set_language(amd_comgr_action_info_t action_info, amd_comgr_language_t language) { return COMGR_DYN(amd_comgr_action_info_set_language)(action_info, language); } static amd_comgr_status_t action_info_get_language(amd_comgr_action_info_t action_info, amd_comgr_language_t *language) { return COMGR_DYN(amd_comgr_action_info_get_language)(action_info, language); } static amd_comgr_status_t action_info_set_option_list(amd_comgr_action_info_t action_info, const char *options[], size_t count) { return COMGR_DYN(amd_comgr_action_info_set_option_list)(action_info, options, count); } static amd_comgr_status_t action_info_get_option_list_count(amd_comgr_action_info_t action_info, size_t *count) { return COMGR_DYN(amd_comgr_action_info_get_option_list_count)(action_info, count); } static amd_comgr_status_t action_info_get_option_list_item(amd_comgr_action_info_t action_info, size_t index, size_t *size, char *option) { return COMGR_DYN(amd_comgr_action_info_get_option_list_item)(action_info, index, size, option); } static amd_comgr_status_t action_info_set_working_directory_path(amd_comgr_action_info_t action_info, const char *path) { return COMGR_DYN(amd_comgr_action_info_set_working_directory_path)(action_info, path); } static amd_comgr_status_t action_info_get_working_directory_path(amd_comgr_action_info_t action_info, size_t *size, char *path) { return COMGR_DYN(amd_comgr_action_info_get_working_directory_path)(action_info, size, path); } static amd_comgr_status_t action_info_set_logging(amd_comgr_action_info_t action_info, bool logging) { return COMGR_DYN(amd_comgr_action_info_set_logging)(action_info, logging); } static amd_comgr_status_t action_info_get_logging(amd_comgr_action_info_t action_info, bool *logging) { return COMGR_DYN(amd_comgr_action_info_get_logging)(action_info, logging); } static amd_comgr_status_t do_action(amd_comgr_action_kind_t kind, amd_comgr_action_info_t info, amd_comgr_data_set_t input, amd_comgr_data_set_t result) { return COMGR_DYN(amd_comgr_do_action)(kind, info, input, result); } static amd_comgr_status_t get_metadata_kind(amd_comgr_metadata_node_t metadata, amd_comgr_metadata_kind_t *kind) { return COMGR_DYN(amd_comgr_get_metadata_kind)(metadata, kind); } static amd_comgr_status_t get_metadata_string(amd_comgr_metadata_node_t metadata, size_t *size, char *string) { return COMGR_DYN(amd_comgr_get_metadata_string)(metadata, size, string); } static amd_comgr_status_t get_metadata_map_size(amd_comgr_metadata_node_t metadata, size_t *size) { return COMGR_DYN(amd_comgr_get_metadata_map_size)(metadata, size); } static amd_comgr_status_t iterate_map_metadata(amd_comgr_metadata_node_t metadata, amd_comgr_status_t(*callback)(amd_comgr_metadata_node_t key, amd_comgr_metadata_node_t value, void *user_data), void *user_data) { return COMGR_DYN(amd_comgr_iterate_map_metadata)(metadata, callback, user_data); } static amd_comgr_status_t metadata_lookup(amd_comgr_metadata_node_t metadata, const char *key, amd_comgr_metadata_node_t *value) { return COMGR_DYN(amd_comgr_metadata_lookup)(metadata, key, value); } static amd_comgr_status_t get_metadata_list_size(amd_comgr_metadata_node_t metadata, size_t *size) { return COMGR_DYN(amd_comgr_get_metadata_list_size)(metadata, size); } static amd_comgr_status_t index_list_metadata(amd_comgr_metadata_node_t metadata, size_t index, amd_comgr_metadata_node_t *value) { return COMGR_DYN(amd_comgr_index_list_metadata)(metadata, index, value); } static amd_comgr_status_t iterate_symbols(amd_comgr_data_t data, amd_comgr_status_t(*callback)(amd_comgr_symbol_t symbol, void *user_data), void *user_data) { return COMGR_DYN(amd_comgr_iterate_symbols)(data, callback, user_data); } static amd_comgr_status_t symbol_lookup(amd_comgr_data_t data, const char *name, amd_comgr_symbol_t *symbol) { return COMGR_DYN(amd_comgr_symbol_lookup)(data, name, symbol); } static amd_comgr_status_t symbol_get_info(amd_comgr_symbol_t symbol, amd_comgr_symbol_info_t attribute, void *value) { return COMGR_DYN(amd_comgr_symbol_get_info)(symbol, attribute, value); } private: static ComgrEntryPoints cep_; static bool is_ready_; }; } #endif
66.25614
228
0.829794
SJTU-IPADS
339ca18e3a3898ed03dc2eac6a3b97a6f2dd0139
47,119
cxx
C++
inetcore/mshtml/src/edit/edutil.cxx
npocmaka/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
17
2020-11-13T13:42:52.000Z
2021-09-16T09:13:13.000Z
inetcore/mshtml/src/edit/edutil.cxx
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
2
2020-10-19T08:02:06.000Z
2020-10-19T08:23:18.000Z
inetcore/mshtml/src/edit/edutil.cxx
sancho1952007/Windows-Server-2003
5c6fe3db626b63a384230a1aa6b92ac416b0765f
[ "Unlicense" ]
14
2020-11-14T09:43:20.000Z
2021-08-28T08:59:57.000Z
//+--------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation, 1998. // // File: EDUTIL.CXX // // Contents: Utility functions for CMsHtmled // // History: 15-Jan-98 raminh Created // // Notes: This file contains some utility functions from Trident, // such as LoadLibrary, which have been modified to eliminate // dependencies. In addition, it provides the implementation // for editing commands such as InsertObject etc. //------------------------------------------------------------------------ #include "headers.hxx" #pragma MARK_DATA(__FILE__) #pragma MARK_CODE(__FILE__) #pragma MARK_CONST(__FILE__) #ifndef X_SLOAD_HXX_ #define X_SLOAD_HXX_ #include "sload.hxx" #endif #ifndef X_EDEVENT_HXX_ #define X_EDEVENT_HXX_ #include "edevent.hxx" #endif #ifndef X_EDUTIL_HXX_ #define X_EDUTIL_HXX_ #include "edutil.hxx" #endif #ifndef X_EDCMD_HXX_ #define X_EDCMD_HXX_ #include "edcmd.hxx" #endif #ifndef X_BLOCKCMD_HXX_ #define X_BLOCKCMD_HXX_ #include "blockcmd.hxx" #endif #ifndef X_SELMAN_HXX_ #define X_SELMAN_HXX_ #include "selman.hxx" #endif #ifndef X_EDUNDO_HXX_ #define X_EDUNDO_HXX_ #include "edundo.hxx" #endif #ifndef X_INPUTTXT_H_ #define X_INPUTTXT_H_ #include "inputtxt.h" #endif #ifndef X_TEXTAREA_H_ #define X_TEXTAREA_H_ #include "textarea.h" #endif #ifndef X_SELSERV_HXX_ #define X_SELSERV_HXX_ #include "selserv.hxx" #endif using namespace EdUtil; using namespace MshtmledUtil; DYNLIB g_dynlibSHDOCVW = { NULL, NULL, "SHDOCVW.DLL" }; // This line is required for linking with wrappers.lib LCID g_lcidUserDefault = 0; // Required for linking with formsary.obj #if DBG == 1 && !defined(WIN16) // // Global vars for use by the DYNCAST macro // char g_achDynCastMsg[200]; char *g_pszDynMsg = "Invalid Static Cast -- Attempt to cast object " "of type %s to type %s."; char *g_pszDynMsg2 = "Dynamic Cast Attempted --- " "Attempt to cast between two base classes of %s. " "The cast was to class %s from some other base class " "pointer. This cast will not succeed in a retail build."; #endif static DYNLIB * s_pdynlibHead; // List used by LoadProcedure and DeiIntDynamic libraries // // Forward references // int edWsprintf(LPTSTR pstrOut, LPCTSTR pstrFormat, LPCTSTR pstrParam); HRESULT GetLastWin32Error(); void DeinitDynamicLibraries(); HRESULT DoInsertObjectUI (HWND hwnd, DWORD * pdwResult, LPTSTR * pstrResult); HRESULT CreateHtmlFromIDM (UINT cmd, LPTSTR pstrParam, LPTSTR pstrHtml); //+------------------------------------------------------------------------ // // Function: ReleaseInterface // // Synopsis: Releases an interface pointer if it is non-NULL // // Arguments: [pUnk] // //------------------------------------------------------------------------- void ReleaseInterface(IUnknown * pUnk) { if (pUnk) pUnk->Release(); } //+------------------------------------------------------------------------ // // Function: edNlstrlenW // // Synopsis: This function takes a string and count the characters (WCHAR) // contained in that string until either NULL termination is // encountered or cchLimit is reached. // // Returns: Number of characters in pstrIn // //------------------------------------------------------------------------- LONG edNlstrlenW(LPWSTR pstrIn, LONG cchLimit ) { Assert(pstrIn); Assert(cchLimit >= 0); LONG cchCount = 0; while (*pstrIn && cchLimit) { cchCount ++; cchLimit --; ++pstrIn; } return cchCount; } //+------------------------------------------------------------------------ // // Function: edWsprintf // // Synopsis: This function is a replacement for a simple version of sprintf. // Since using Format() links in a lot of extra code and since // wsprintf does not work under Win95, this simple alternative // is being used. // // Returns: Number of characters written to pstrOut // //------------------------------------------------------------------------- int edWsprintf(LPTSTR pstrOut, LPCTSTR pstrFormat, LPCTSTR pstrParam) { TCHAR * pstrPercentS; ULONG cLength; if (!pstrFormat) goto Cleanup; pstrPercentS = _tcsstr( pstrFormat, _T( "%s" ) ); if (!pstrPercentS) { _tcscpy( pstrOut, pstrFormat ); } else { if (!pstrParam) goto Cleanup; cLength = PTR_DIFF( pstrPercentS, pstrFormat ); _tcsncpy( pstrOut, pstrFormat, cLength ); pstrOut[ cLength ] = _T( '\0' ); ++pstrPercentS; ++pstrPercentS; // Increment pstrPercentS passed "%s" _tcscat( pstrOut, pstrParam ); _tcscat( pstrOut, pstrPercentS ); } return _tcslen(pstrOut); Cleanup: return 0; } //+------------------------------------------------------------------------ // // Function: GetLastWin32Error from misc.cxx // // Synopsis: Returns the last Win32 error, converted to an HRESULT. // // Returns: HRESULT // //------------------------------------------------------------------------- HRESULT GetLastWin32Error( ) { #ifdef WIN16 return E_FAIL; #else // Win 95 can return 0, even when there's an error. DWORD dw = GetLastError(); return dw ? HRESULT_FROM_WIN32(dw) : E_FAIL; #endif } //+--------------------------------------------------------------------------- // // Function: LoadProcedure // // Synopsis: Load library and get address of procedure. // // Declare DYNLIB and DYNPROC globals describing the procedure. // Note that several DYNPROC structures can point to a single // DYNLIB structure. // // DYNLIB g_dynlibOLEDLG = { NULL, "OLEDLG.DLL" }; // DYNPROC g_dynprocOleUIInsertObjectA = // { NULL, &g_dynlibOLEDLG, "OleUIInsertObjectA" }; // DYNPROC g_dynprocOleUIPasteSpecialA = // { NULL, &g_dynlibOLEDLG, "OleUIPasteSpecialA" }; // // Call LoadProcedure to load the library and get the procedure // address. LoadProcedure returns immediatly if the procedure // has already been loaded. // // hr = LoadProcedure(&g_dynprocOLEUIInsertObjectA); // if (hr) // goto Error; // // uiResult = (*(UINT (__stdcall *)(LPOLEUIINSERTOBJECTA)) // g_dynprocOLEUIInsertObjectA.pfn)(&ouiio); // // Release the library at shutdown. // // void DllProcessDetach() // { // DeinitDynamicLibraries(); // } // // Arguments: pdynproc Descrition of library and procedure to load. // // Returns: HRESULT // //---------------------------------------------------------------------------- HRESULT LoadProcedure(DYNPROC *pdynproc) { HINSTANCE hinst; DYNLIB * pdynlib = pdynproc->pdynlib; DWORD dwError; if (pdynproc->pfn && pdynlib->hinst) return S_OK; if (!pdynlib->hinst) { // Try to load the library using the normal mechanism. hinst = LoadLibraryA(pdynlib->achName); #ifdef WINCE if (!hinst) { goto Error; } #endif // WINCE #ifdef WIN16 if ( (UINT) hinst < 32 ) { // jumping to error won't work, // since GetLastError is currently always 0. //goto Error; // instead, return a bogus (but non-zero) error code. // (What should we return? I got 0x7e on one test.) // --mblain27feb97 RRETURN(hinst ? (DWORD) hinst : (DWORD) ~0); } #endif // WIN16 #if !defined(WIN16) && !defined(WINCE) // If that failed because the module was not be found, // then try to find the module in the directory we were // loaded from. dwError = GetLastError(); if (!hinst) { goto Error; } #endif // !defined(WIN16) && !defined(WINCE) // Link into list for DeinitDynamicLibraries { if (pdynlib->hinst) FreeLibrary(hinst); else { pdynlib->hinst = hinst; pdynlib->pdynlibNext = s_pdynlibHead; s_pdynlibHead = pdynlib; } } } pdynproc->pfn = GetProcAddress(pdynlib->hinst, pdynproc->achName); if (!pdynproc->pfn) { goto Error; } return S_OK; Error: RRETURN(GetLastWin32Error()); } //+--------------------------------------------------------------------------- // // Function: DeinitDynamicLibraries // // Synopsis: Undoes the work of LoadProcedure. // //---------------------------------------------------------------------------- void DeinitDynamicLibraries() { DYNLIB * pdynlib; for (pdynlib = s_pdynlibHead; pdynlib; pdynlib = pdynlib->pdynlibNext) { if (pdynlib->hinst) { FreeLibrary(pdynlib->hinst); pdynlib->hinst = NULL; } } s_pdynlibHead = NULL; } // // EnumElements() and EnumVARIANT() are methods of CImplAry class that are // implemented in cenum.cxx. MshtmlEd does not currently use these methods // hence the stubs below are provided to avoid linking code unnecessarily. // If these methods are ever used, MshtmlEd shall link with cenum.cxx. // //+--------------------------------------------------------------------------- // // Member: CImplAry::EnumElements // //---------------------------------------------------------------------------- HRESULT CImplAry::EnumElements( size_t cb, REFIID iid, void ** ppv, BOOL fAddRef, BOOL fCopy, BOOL fDelete) { return E_NOTIMPL; } //+--------------------------------------------------------------------------- // // Member: CImplAry::EnumVARIANT // //---------------------------------------------------------------------------- HRESULT CImplAry::EnumVARIANT( size_t cb, VARTYPE vt, IEnumVARIANT ** ppenum, BOOL fCopy, BOOL fDelete) { return E_NOTIMPL; } //+------------------------------------------------------------------------ // // Function: ReplaceInterfaceFn // // Synopsis: Replaces an interface pointer with a new interface, // following proper ref counting rules: // // = *ppUnk is set to pUnk // = if *ppUnk was not NULL initially, it is Release'd // = if pUnk is not NULL, it is AddRef'd // // Effectively, this allows pointer assignment for ref-counted // pointers. // // Arguments: [ppUnk] // [pUnk] // //------------------------------------------------------------------------- void ReplaceInterfaceFn(IUnknown ** ppUnk, IUnknown * pUnk) { IUnknown * pUnkOld = *ppUnk; *ppUnk = pUnk; // Note that we do AddRef before Release; this avoids // accidentally destroying an object if this function // is passed two aliases to it if (pUnk) pUnk->AddRef(); if (pUnkOld) pUnkOld->Release(); } //+------------------------------------------------------------------------ // // Function: ClearInterfaceFn // // Synopsis: Sets an interface pointer to NULL, after first calling // Release if the pointer was not NULL initially // // Arguments: [ppUnk] *ppUnk is cleared // //------------------------------------------------------------------------- void ClearInterfaceFn(IUnknown ** ppUnk) { IUnknown * pUnk; pUnk = *ppUnk; *ppUnk = NULL; if (pUnk) pUnk->Release(); } Direction Reverse( Direction iDir ) { if( iDir == LEFT ) return RIGHT; else if (iDir == RIGHT) return LEFT; else return iDir; } //+=================================================================================== // Method: MoveWord // // Synopsis: Moves the pointer to the previous or next word. This method takes into // account block and site ends. // // Parameters: // eDir [in] Direction to move // pfNotAtBOL [out] What line is pointer on after move? (optional) // pfAtLogcialBOL [out] Is pointer at lbol after move? (otional) //+=================================================================================== HRESULT CHTMLEditor::MoveWord( IDisplayPointer *pDispPointer, Direction eDir) { HRESULT hr = S_OK; if( eDir == LEFT ) hr = THR( MoveUnit( pDispPointer, eDir, MOVEUNIT_PREVWORDBEGIN )); else hr = THR( MoveUnit( pDispPointer,eDir, MOVEUNIT_NEXTWORDBEGIN )); RRETURN( hr ); } //+=================================================================================== // Method: MoveCharacter // // Synopsis: Moves the pointer to the previous or next character. This method takes // into account block and site ends. // // Parameters: // eDir [in] Direction to move // pfNotAtBOL [out] What line is pointer on after move? (optional) // pfAtLogcialBOL [out] Is pointer at lbol after move? (otional) //+=================================================================================== HRESULT CHTMLEditor::MoveCharacter( IDisplayPointer *pDispPointer, Direction eDir) { HRESULT hr = S_OK; BOOL fNearText = FALSE; CEditPointer tLooker(this); DWORD dwBreak = BREAK_CONDITION_OMIT_PHRASE-BREAK_CONDITION_Anchor; DWORD dwFound = BREAK_CONDITION_None; IFC( pDispPointer->PositionMarkupPointer(tLooker) ); IFC( tLooker.Scan( eDir, dwBreak, &dwFound )); fNearText = CheckFlag( dwFound, BREAK_CONDITION_Text ); if( eDir == LEFT ) { if( fNearText ) { hr = THR( MoveUnit( pDispPointer, eDir, MOVEUNIT_PREVCLUSTERBEGIN )); } else { hr = THR( MoveUnit( pDispPointer, eDir, MOVEUNIT_PREVCLUSTEREND )); } } else { if( fNearText ) { hr = THR( MoveUnit( pDispPointer, eDir, MOVEUNIT_NEXTCLUSTEREND )); } else { hr = THR( MoveUnit( pDispPointer, eDir, MOVEUNIT_NEXTCLUSTERBEGIN )); } } Cleanup: RRETURN( hr ); } //+=================================================================================== // Method: MoveUnit // // Synopsis: Moves the pointer to the previous or next character. This method takes // into account block and site ends. // // Parameters: // eDir [in] Direction to move // pfNotAtBOL [out] What line is pointer on after move? (optional) // pfAtLogcialBOL [out] Is pointer at lbol after move? (otional) // // // //+=================================================================================== HRESULT CHTMLEditor::MoveUnit( IDisplayPointer *pDispPointer, Direction eDir, MOVEUNIT_ACTION eUnit ) { HRESULT hr = S_OK; BOOL fBeyondThisLine; BOOL fAtEdgeOfLine; BOOL fThereIsAnotherLine = FALSE; BOOL fBeyondNextLine = FALSE; BOOL fLineBreakDueToTextWrapping = FALSE; BOOL fHackedLineBreak = FALSE; DWORD dwBreak = BREAK_CONDITION_Site | BREAK_CONDITION_NoScopeSite | BREAK_CONDITION_Control; DWORD dwFound = BREAK_CONDITION_None; SP_IHTMLElement spSite; CEditPointer epDestination(this); CEditPointer epBoundary(this); CEditPointer epNextLine(this); CEditPointer epWalker(this); SP_IDisplayPointer spDispPointer; IFC( pDispPointer->PositionMarkupPointer(epDestination) ); IFC( pDispPointer->PositionMarkupPointer(epNextLine) ); IFC( pDispPointer->PositionMarkupPointer(epWalker) ); IFC( pDispPointer->PositionMarkupPointer(epBoundary) ); IFC( GetDisplayServices()->CreateDisplayPointer(&spDispPointer) ); IFC( spDispPointer->SetDisplayGravity(DISPLAY_GRAVITY_PreviousLine) ); IFC( epDestination->MoveUnit( eUnit )); if( eDir == LEFT ) { DWORD dwIgnore = BREAK_CONDITION_Phrase | BREAK_CONDITION_Anchor | BREAK_CONDITION_NoLayoutSpan; IFC( spDispPointer->MoveToPointer(pDispPointer) ); IFC( spDispPointer->MoveUnit(DISPLAY_MOVEUNIT_CurrentLineStart, -1) ); IFC( spDispPointer->PositionMarkupPointer(epBoundary) ); fLineBreakDueToTextWrapping = TRUE; hr = THR( spDispPointer->MoveUnit(DISPLAY_MOVEUNIT_PreviousLine, -1) ); if (SUCCEEDED(hr)) { hr = THR( spDispPointer->MoveUnit(DISPLAY_MOVEUNIT_CurrentLineEnd, -1) ); if (SUCCEEDED(hr)) { fThereIsAnotherLine = TRUE; IFC( spDispPointer->PositionMarkupPointer(epNextLine) ); IFC( AdjustOut(epNextLine, RIGHT) ); { // // HACKHACK: To fix bug #98353, we need to make sure epNextLine // does not go beyond this line. AdjustOut is very buggy but // we don't want to make a big modification as of now. So we do // a little hacking here. [zhenbinx] // SP_IDisplayPointer spDispAdjusted; IFC( GetDisplayServices()->CreateDisplayPointer(&spDispAdjusted) ); if (S_FALSE == spDispAdjusted->MoveToMarkupPointer(epNextLine, spDispPointer)) { CEditPointer epScan(this); DWORD dwScanFound; epScan->MoveToPointer(epNextLine); epScan.Scan(LEFT, BREAK_CONDITION_OMIT_PHRASE, &dwScanFound); epScan.Scan(RIGHT, BREAK_CONDITION_OMIT_PHRASE, &dwScanFound); epNextLine->MoveToPointer(epScan); } } IFC( epDestination->IsLeftOf( epNextLine, &fBeyondNextLine )); } } // // HACKHACK: When glyph is turned on, we use the non-adjusted line start instead // of adjusted line start for epBoundary. So we need to handle it specially. // if (!_fIgnoreGlyphs) { DWORD dwLBSearch = BREAK_CONDITION_Content; DWORD dwLBFound; CEditPointer epLBScan(this); IFC( epLBScan->MoveToPointer(epBoundary) ); IFC( epLBScan.Scan(LEFT, dwLBSearch, &dwLBFound) ); if ( (CheckFlag(dwLBFound, BREAK_CONDITION_EnterBlock) && CheckFlag(dwLBFound, BREAK_CONDITION_EnterSite)) ) { // // HACKHACK: // since we use non-adjusted line start. We need // to hack this to FALSE. // fLineBreakDueToTextWrapping = FALSE; fHackedLineBreak = TRUE; } } if (!fHackedLineBreak) { // If the current line start and previous line end are the same point // in the markup, we are breaking the line due to wrapping IFC( epNextLine->IsEqualTo( epBoundary, &fLineBreakDueToTextWrapping )); } IFC( epDestination->IsLeftOf( epBoundary, &fBeyondThisLine )); IFC( epWalker.IsLeftOfOrEqualTo( epBoundary, dwIgnore, &fAtEdgeOfLine )); if (!_fIgnoreGlyphs) { // // IEV6-6553-2000/08/08/-zhenbinx // some positions are not valid even if glyph is turned on. // This is because the caret is considered to be "valid // for input". To maintain this assumption, Some glyphs // should be ingored since inserting text into such position // would have resulted in incorrect HTML. // We should have a better glyph story in the future. // SP_IHTMLElement spIElem; ELEMENT_TAG_ID eTag; IFC( CurrentScopeOrMaster(epWalker, &spIElem) ); IFC( GetMarkupServices()->GetElementTagId(spIElem, & eTag) ); if (EdUtil::IsListItem(eTag)) // add more invalid positions here... { // // In theory, this could have skipped over too much // however LI is not surround by any element in normal cases // DWORD dwAdjustedIgnore = dwIgnore|BREAK_CONDITION_Glyph|BREAK_CONDITION_Block; IFC( epWalker.IsLeftOfOrEqualTo(epBoundary, dwAdjustedIgnore, &fAtEdgeOfLine) ); } } } else { DWORD dwIgnore = BREAK_CONDITION_Phrase | BREAK_CONDITION_Anchor | BREAK_CONDITION_NoScope | BREAK_CONDITION_NoLayoutSpan; IFC( spDispPointer->MoveToPointer(pDispPointer) ); IFC( spDispPointer->MoveUnit(DISPLAY_MOVEUNIT_CurrentLineEnd, -1) ); IFC( spDispPointer->PositionMarkupPointer(epBoundary) ); fLineBreakDueToTextWrapping = TRUE; IFC( spDispPointer->MoveToPointer(pDispPointer) ); hr = THR( spDispPointer->MoveUnit(DISPLAY_MOVEUNIT_NextLine, -1) ); if (SUCCEEDED(hr)) { hr = THR( spDispPointer->MoveUnit(DISPLAY_MOVEUNIT_CurrentLineStart, -1) ); if (SUCCEEDED(hr)) { fThereIsAnotherLine = TRUE; IFC( spDispPointer->PositionMarkupPointer(epNextLine) ); IFC( AdjustOut(epNextLine, LEFT) ); { // // HACKHACK: To fix bug #108383, we need to make sure epNextLine // does not go beyond this line. AdjustOut is very buggy but // we don't want to make a big modification as of now. So we do // a little hacking here. [zhenbinx] // SP_IDisplayPointer spDispAdjusted; IFC( GetDisplayServices()->CreateDisplayPointer(&spDispAdjusted) ); if (S_FALSE == spDispAdjusted->MoveToMarkupPointer(epNextLine, spDispPointer)) { CEditPointer epScan(this); DWORD dwScanFound; epScan->MoveToPointer(epNextLine); epScan.Scan(RIGHT, BREAK_CONDITION_OMIT_PHRASE, &dwScanFound); epScan.Scan(LEFT, BREAK_CONDITION_OMIT_PHRASE, &dwScanFound); epNextLine->MoveToPointer(epScan); } } IFC( epDestination->IsRightOf( epNextLine, &fBeyondNextLine )); } } // // HACKHACK: When glyph is turned on, we use the non-adjusted line end instead // of adjusted line end for epBoundary. So we need to handle it specially. // if (!_fIgnoreGlyphs) { DWORD dwLBSearch = BREAK_CONDITION_Content; DWORD dwLBFound; CEditPointer epLBScan(this); IFC( epLBScan->MoveToPointer(epBoundary) ); IFC( epLBScan.Scan(RIGHT, dwLBSearch, &dwLBFound) ); if ( (CheckFlag(dwLBFound, BREAK_CONDITION_EnterBlock) && CheckFlag(dwLBFound, BREAK_CONDITION_EnterSite)) ) { // // HACKHACK: // We have a block and a glyph right before it // since we use non-adjusted line end. We need // to hack this to FALSE. // fLineBreakDueToTextWrapping = FALSE; fHackedLineBreak = TRUE; } } if (!fHackedLineBreak) { // If the current line END and next line START are the same point // in the markup, we are breaking the line due to wrapping IFC( epNextLine->IsEqualTo( epBoundary, &fLineBreakDueToTextWrapping )); } IFC( epDestination->IsRightOf( epBoundary, &fBeyondThisLine )); IFC( epWalker.IsRightOfOrEqualTo( epBoundary, dwIgnore, &fAtEdgeOfLine )); } // // If I'm not at the edge of the line, my destination is the edge of the line. // if( ! fAtEdgeOfLine && fBeyondThisLine ) { IFC( epDestination->MoveToPointer( epBoundary )); } // // If I am at the edge of the line and there is another line, and my destination // is beyond that line - my destination is that line. // if( fAtEdgeOfLine && fBeyondThisLine && fBeyondNextLine && ! fLineBreakDueToTextWrapping ) { // we are at the edge of the line and our destination is beyond the next line boundary // so move our destination to that line boundary. IFC( epDestination->MoveToPointer( epNextLine )); } // // Scan towards my destination. If I hit a site boundary, move to the other // side of it and be done. Otherwise, move to the next line. // IFC( epWalker.SetBoundaryForDirection( eDir, epDestination )); hr = THR( epWalker.Scan( eDir, dwBreak, &dwFound, &spSite )); if( CheckFlag( dwFound, BREAK_CONDITION_NoScopeSite ) || CheckFlag( dwFound, BREAK_CONDITION_EnterControl )) { IFC( epWalker->MoveAdjacentToElement( spSite , eDir == LEFT ? ELEM_ADJ_BeforeBegin : ELEM_ADJ_AfterEnd )); goto CalcBOL; } else if( CheckFlag( dwFound, BREAK_CONDITION_ExitControl )) { // do not move at all goto Cleanup; } else if( CheckFlag( dwFound, BREAK_CONDITION_Site )) { ELEMENT_TAG_ID tagId; IFC( GetMarkupServices()->GetElementTagId(spSite, &tagId) ); if (tagId == TAGID_BODY) goto Cleanup; // don't exit the body IFC( EnterTables(epWalker, eDir) ); // move wherever scan put us... if( eDir == LEFT ) { IFC( pDispPointer->SetDisplayGravity(DISPLAY_GRAVITY_PreviousLine) ); } else { IFC( pDispPointer->SetDisplayGravity(DISPLAY_GRAVITY_NextLine) ); } goto Done; } else if( CheckFlag( dwFound, BREAK_CONDITION_Boundary )) { // No site transitions between here and our destination. if( fBeyondThisLine && fAtEdgeOfLine && ! fLineBreakDueToTextWrapping ) { // If our destination pointer is on another line than our start pointer... IFC( spDispPointer->MoveToPointer(pDispPointer) ); if( eDir == LEFT ) { hr = THR( spDispPointer->MoveUnit(DISPLAY_MOVEUNIT_PreviousLine, -1) ); if (SUCCEEDED(hr)) { hr = THR( spDispPointer->MoveUnit(DISPLAY_MOVEUNIT_CurrentLineEnd, -1) ); if (SUCCEEDED(hr)) { IFC( spDispPointer->PositionMarkupPointer(epWalker) ); IFC( AdjustOut(epWalker, RIGHT) ); { // // HACKHACK: To fix bug #98353, we need to make sure epNextLine // does not go beyond this line. AdjustOut is very buggy but // we don't want to make a big modification as of now. So we do // a little hacking here. [zhenbinx] // SP_IDisplayPointer spDispAdjusted; IFC( GetDisplayServices()->CreateDisplayPointer(&spDispAdjusted) ); if (S_FALSE == spDispAdjusted->MoveToMarkupPointer(epWalker, spDispPointer) ) { CEditPointer epScan(this); DWORD dwScanFound; epScan->MoveToPointer(epWalker); epScan.Scan(LEFT, BREAK_CONDITION_OMIT_PHRASE, &dwScanFound); epScan.Scan(RIGHT, BREAK_CONDITION_OMIT_PHRASE, &dwScanFound); epWalker->MoveToPointer(epScan); } } IFC( EnterTables(epWalker, LEFT) ); IFC( pDispPointer->MoveToMarkupPointer(epWalker, NULL) ); { // // HACKHACK: // // We might just moved into an empty line!!! // Consider the case of "\r\rA" where we are moving // from between '\r' and 'A' to between two '\r's, // // In this case CurrentLineEnd will be before the 2nd // 'r' !!! (this is our current design)!!!!!!!!!! // // We are moving into an ambigious position at an // empty line. Do not set display gravity to PreviousLine // in this case! Note in this case fLineBreakDueToTextWrapping // is set to FALSE // // [zhenbinx] // CEditPointer epScan(this); DWORD dwSearch = BREAK_CONDITION_OMIT_PHRASE; DWORD dwScanFound = BREAK_CONDITION_None; WCHAR wch; IFC( pDispPointer->PositionMarkupPointer(epScan) ); IFC( epScan.Scan(RIGHT, dwSearch, &dwScanFound, NULL, NULL, &wch) ); if (CheckFlag(dwScanFound, BREAK_CONDITION_NoScopeBlock) && wch == L'\r') { IFC( pDispPointer->SetDisplayGravity(DISPLAY_GRAVITY_NextLine) ); } else { IFC( pDispPointer->SetDisplayGravity(DISPLAY_GRAVITY_PreviousLine) ); } } } } } else { hr = THR( spDispPointer->MoveUnit(DISPLAY_MOVEUNIT_NextLine, -1) ); if (SUCCEEDED(hr)) { hr = THR( spDispPointer->MoveUnit(DISPLAY_MOVEUNIT_CurrentLineStart, -1) ); if (SUCCEEDED(hr)) { IFC( spDispPointer->PositionMarkupPointer(epWalker) ); IFC( AdjustOut(epWalker, LEFT) ); { // // HACKHACK: To fix bug #108383, we need to make sure epNextLine // does not go beyond this line. AdjustOut is very buggy but // we don't want to make a big modification as of now. So we do // a little hacking here. [zhenbinx] // SP_IDisplayPointer spDispAdjusted; IFC( GetDisplayServices()->CreateDisplayPointer(&spDispAdjusted) ); if (S_FALSE == spDispAdjusted->MoveToMarkupPointer(epWalker, spDispPointer) ) { CEditPointer epScan(this); DWORD dwScanFound; epScan->MoveToPointer(epWalker); epScan.Scan(RIGHT, BREAK_CONDITION_OMIT_PHRASE, &dwScanFound); epScan.Scan(LEFT, BREAK_CONDITION_OMIT_PHRASE, &dwScanFound); epWalker->MoveToPointer(epScan); } } IFC( EnterTables(epWalker, RIGHT) ); IFC( pDispPointer->MoveToMarkupPointer(epWalker, NULL) ); IFC( pDispPointer->SetDisplayGravity(DISPLAY_GRAVITY_NextLine) ); } } } goto Cleanup; } else { // We started and ended on same line with no little stops along the way - move to destination... IFC( epWalker->MoveToPointer( epDestination )); } } else { // we hit some sort of error, go to cleanup hr = E_FAIL; goto Cleanup; } CalcBOL: // // Fix up fNotAtBOL - if the cp we are at is between lines, we should // always be at the beginning of the line. One exception - if we are to the // left of a layout, we should render on the previous line. If we are to the // right of a layout, we should render on the next line. // { CEditPointer tPointer( this ); BOOL fAtNextLineFuzzy = FALSE; DWORD dwScanBreak = BREAK_CONDITION_OMIT_PHRASE - BREAK_CONDITION_Anchor; DWORD dwScanFound = BREAK_CONDITION_None; IFC( tPointer.MoveToPointer( epWalker )); IFC( tPointer.Scan( RIGHT, dwScanBreak, &dwScanFound )); if( fThereIsAnotherLine ) IFC( tPointer.IsEqualTo( epNextLine, BREAK_CONDITION_Phrase | BREAK_CONDITION_Anchor, & fAtNextLineFuzzy )); if( ! CheckFlag( dwScanFound, BREAK_CONDITION_Site ) && ! fAtNextLineFuzzy ) { // No site to the right of me and I'm not right next to the next line, // render at the bol. IFC( pDispPointer->SetDisplayGravity(DISPLAY_GRAVITY_NextLine) ); } else { // there was a site to my right - render at the end of the line IFC( pDispPointer->SetDisplayGravity(DISPLAY_GRAVITY_PreviousLine) ); } } Done: IFC( pDispPointer->MoveToMarkupPointer(epWalker, NULL) ); Cleanup: RRETURN( hr ); } // // General markup services helpers // //+---------------------------------------------------------------------------- // Method: CSegmentListIter::CSegmentListIter // Synopsis: ctor //----------------------------------------------------------------------------- CSegmentListIter::CSegmentListIter() { _pLeft = _pRight = NULL; _pSegmentList = NULL; _pIter = NULL; } //+---------------------------------------------------------------------------- // Method: CSegmentListIter::CSegmentListIter // Synopsis: dtor //----------------------------------------------------------------------------- CSegmentListIter::~CSegmentListIter() { ReleaseInterface(_pLeft); ReleaseInterface(_pRight); ReleaseInterface(_pSegmentList); ReleaseInterface(_pIter); } //+---------------------------------------------------------------------------- // Method: CSegmentListIter::Init // Synopsis: init method //----------------------------------------------------------------------------- HRESULT CSegmentListIter::Init(CEditorDoc *pEditorDoc, ISegmentList *pSegmentList) { HRESULT hr; // // Set up pointers // ReleaseInterface(_pLeft); ReleaseInterface(_pRight); ReleaseInterface(_pSegmentList); ReleaseInterface(_pIter); IFC( pSegmentList->CreateIterator(&_pIter) ); hr = THR(CreateMarkupPointer2(pEditorDoc, &_pLeft)); if (FAILED(hr)) goto Cleanup; hr = THR(CreateMarkupPointer2(pEditorDoc, &_pRight)); if (FAILED(hr)) goto Cleanup; // Cache segment list _pSegmentList = pSegmentList; _pSegmentList->AddRef(); Cleanup: RRETURN1(hr, S_FALSE); } //+---------------------------------------------------------------------------- // Method: CSegmentListIter::Next // Synopsis: Move pointers to next segment. // Returns S_FALSE if last segment //----------------------------------------------------------------------------- HRESULT CSegmentListIter::Next(IMarkupPointer **ppLeft, IMarkupPointer **ppRight) { SP_ISegment spSegment; HRESULT hr; // // Advance to next segment // if( _pIter->IsDone() == S_FALSE ) { IFC( _pIter->Current(&spSegment) ); IFC( spSegment->GetPointers( _pLeft, _pRight ) ); *ppLeft = _pLeft; *ppRight = _pRight; IFC( _pIter->Advance() ); } else { hr = S_FALSE; } Cleanup: RRETURN1(hr, S_FALSE); } //+---------------------------------------------------------------------------- // Method: CBreakContainer::Add // Synopsis: Add an element to the break container //----------------------------------------------------------------------------- VOID CBreakContainer::Set(ELEMENT_TAG_ID tagId, Mask mask) { if (mask & BreakOnStart) bitFieldStart.Set(tagId); else bitFieldStart.Clear(tagId); if (mask & BreakOnEnd) bitFieldEnd.Set(tagId); else bitFieldEnd.Clear(tagId); } //+---------------------------------------------------------------------------- // Method: CBreakContainer::Test // Synopsis: Tests an element in the break container //----------------------------------------------------------------------------- VOID CBreakContainer::Clear(ELEMENT_TAG_ID tagId, Mask mask) { if (mask & BreakOnStart) bitFieldStart.Clear(tagId); if (mask & BreakOnEnd) bitFieldEnd.Clear(tagId); } //+---------------------------------------------------------------------------- // Method: CBreakContainer::Clear // Synopsis: Clears an element in the break container //----------------------------------------------------------------------------- BOOL CBreakContainer::Test(ELEMENT_TAG_ID tagId, Mask mask) { BOOL bResult = FALSE; switch (mask) { case BreakOnStart: bResult = bitFieldStart.Test(tagId); break; case BreakOnEnd: bResult = bitFieldEnd.Test(tagId); break; case BreakOnBoth: bResult = bitFieldStart.Test(tagId) && bitFieldEnd.Test(tagId) ; break; } return bResult; } #if DBG==1 void AssertPositioned(IMarkupPointer *pPointer) { HRESULT hr; BOOL fIsPositioned; hr = pPointer->IsPositioned(&fIsPositioned); Assert(hr == S_OK); Assert(fIsPositioned); } #endif HRESULT MshtmledUtil::GetEditResourceLibrary( HINSTANCE *hResourceLibrary) { if (!g_hEditLibInstance) { g_hEditLibInstance = MLLoadLibrary(_T("mshtmler.dll"), g_hInstance, ML_CROSSCODEPAGE); } *hResourceLibrary = g_hEditLibInstance; if (!g_hEditLibInstance) return E_FAIL; // TODO: can we convert GetLastError() to an HRESULT? return S_OK; } //+---------------------------------------------------------------------------+ // // // Currently only deal with writing-mode: tb-rl // // styleWritingMode // styleWritingModeLrtb // styleWritingModeTbrl // styleWritingModeNotSet // // //+---------------------------------------------------------------------------+ HRESULT MshtmledUtil::IsElementInVerticalLayout(IHTMLElement *pElement, BOOL *fRet ) { HRESULT hr = S_OK; SP_IHTMLElement2 spElem2; SP_IHTMLCurrentStyle spStyle; SP_IHTMLCurrentStyle2 spStyle2; BSTR bstrWritingMode=NULL; Assert( pElement ); Assert( fRet ); IFC( pElement->QueryInterface(IID_IHTMLElement2, reinterpret_cast<LPVOID *>(&spElem2)) ); IFC( spElem2->get_currentStyle(&spStyle) ); if (!spStyle) goto Cleanup; IFC( spStyle->QueryInterface(IID_IHTMLCurrentStyle2, reinterpret_cast<LPVOID *>(&spStyle2)) ); IFC( spStyle2->get_writingMode(&bstrWritingMode) ); // // TODO: Should not hard-code strings however cannot find a way around! // *fRet = bstrWritingMode && !_tcscmp(bstrWritingMode, _T("tb-rl")); Cleanup: ::SysFreeString(bstrWritingMode); RRETURN(hr); } // // Synoposis: This function moves the markuppointer according to editing rules. // It manipulates the markup pointer according to the visual box tree // // HRESULT MshtmledUtil::MoveMarkupPointerToBlockLimit( CHTMLEditor *pEditor, Direction direction, // LEFT -- START of BLOCK RIGHT -- END of BLOCK IMarkupPointer *pMarkupPointer, ELEMENT_ADJACENCY elemAdj ) { Assert( pEditor ); Assert( pMarkupPointer ); HRESULT hr = S_OK; CBlockPointer bpStBlock(pEditor); CBlockPointer bpEndBlock(pEditor); CBlockPointer bpWkBlock(pEditor); BOOL fEmpty; IFC( bpStBlock.MoveTo(pMarkupPointer, direction) ); IFC( bpStBlock.IsEmpty(&fEmpty) ); if (!fEmpty) { IFC( bpStBlock.MoveToFirstNodeInBlock() ); } if (LEFT == direction) { IFC( bpStBlock.MovePointerTo(pMarkupPointer, elemAdj) ); goto Cleanup; } // // Fall through -- RIGHT == direction // IFC( bpWkBlock.MoveTo(&bpStBlock) ); if (!fEmpty) { IFC( bpWkBlock.MoveToLastNodeInBlock() ); } IFC( bpEndBlock.MoveTo(&bpWkBlock) ); if (ELEM_ADJ_AfterEnd == elemAdj) { if (S_FALSE == bpEndBlock.MoveToSibling(RIGHT)) { if (bpEndBlock.IsLeafNode()) { IFC( bpEndBlock.MoveToParent() ); } } IFC( bpEndBlock.MovePointerTo(pMarkupPointer, ELEM_ADJ_AfterEnd) ); } else { Assert( ELEM_ADJ_BeforeEnd == elemAdj ); IFC( bpEndBlock.MovePointerTo(pMarkupPointer, ELEM_ADJ_BeforeEnd) ); } Cleanup: RRETURN(hr); } // // CEdUndoHelper helper // CEdUndoHelper::CEdUndoHelper(CHTMLEditor *pEd) { _pEd= pEd; _fOpen = FALSE; } CEdUndoHelper::~CEdUndoHelper() { if (_fOpen) IGNORE_HR(_pEd->GetUndoManagerHelper()->EndUndoUnit()); } HRESULT CEdUndoHelper::Begin(UINT uiStringId, CBatchParentUndoUnit *pBatchPUU) { HRESULT hr; Assert(!_fOpen); hr = THR(_pEd->GetUndoManagerHelper()->BeginUndoUnit(uiStringId, pBatchPUU)); _fOpen = SUCCEEDED(hr); RRETURN(hr); } // // CStringCache // CStringCache::CStringCache(UINT uiStart, UINT uiEnd) { _uiStart = uiStart; _uiEnd = uiEnd; _pCache = new CacheEntry[_uiEnd - _uiStart + 1]; if (_pCache) { for (UINT i = 0; i < (_uiEnd - _uiStart + 1); i++) { _pCache[i].pchString = NULL; } } } CStringCache::~CStringCache() { for (UINT i = 0; i < (_uiEnd - _uiStart + 1); i++) { delete [] _pCache[i].pchString; } delete [] _pCache; } TCHAR * CStringCache::GetString(UINT uiStringId) { HRESULT hr; CacheEntry *pEntry; HINSTANCE hinstEditResDLL; INT iResult; const int iBufferSize = 1024; Assert(_pCache); if (!_pCache || uiStringId < _uiStart || uiStringId > _uiEnd) return NULL; // error pEntry = &_pCache[uiStringId - _uiStart]; if (pEntry->pchString == NULL) { TCHAR pchBuffer[iBufferSize]; IFC( MshtmledUtil::GetEditResourceLibrary(&hinstEditResDLL) ); pchBuffer[iBufferSize-1] = 0; // so we are always 0 terminated iResult = LoadString( hinstEditResDLL, uiStringId, pchBuffer, ARRAY_SIZE(pchBuffer)-1 ); if (!iResult) goto Cleanup; pEntry->pchString = new TCHAR[_tcslen(pchBuffer)+1]; if (pEntry->pchString) StrCpy(pEntry->pchString, pchBuffer); } return pEntry->pchString; Cleanup: return NULL; } #if DBG==1 // // Debugging aid - this little hack lets us look at the CElement from inside the debugger. // #include <initguid.h> DEFINE_GUID(CLSID_CElement, 0x3050f233, 0x98b5, 0x11cf, 0xbb, 0x82, 0x00, 0xaa, 0x00, 0xbd, 0xce, 0x0b); DEBUG_HELPER CElement *_(IHTMLElement *pIElement) { CElement *pElement = NULL; pIElement->QueryInterface(CLSID_CElement, (LPVOID *)&pElement); return pElement; } // // Helpers to dump the tree // DEBUG_HELPER VOID dt(IUnknown* pUnknown) { IOleCommandTarget *pCmdTarget = NULL; IMarkupPointer *pMarkupPointer = NULL; if (SUCCEEDED(pUnknown->QueryInterface(IID_IOleCommandTarget, (LPVOID *)&pCmdTarget))) { IGNORE_HR(pCmdTarget->Exec( &CGID_MSHTML, IDM_DEBUG_DUMPTREE, 0, NULL, NULL)); ReleaseInterface(pCmdTarget); } else if (SUCCEEDED(pUnknown->QueryInterface(IID_IMarkupPointer, (LPVOID *)&pMarkupPointer))) { IMarkupContainer *pContainer = NULL; if (SUCCEEDED(pMarkupPointer->GetContainer(&pContainer))) { dt(pContainer); ReleaseInterface(pContainer); } ReleaseInterface(pMarkupPointer); } } DEBUG_HELPER VOID dt(SP_IMarkupPointer &spPointer) { dt(spPointer.p); } #endif
32.185109
131
0.511407
npocmaka
339cfee207ba0db4e066b4a04a55a4a710578796
8,710
cpp
C++
RemoteControl/LinuxDevice.cpp
dwrobel/WPEFrameworkPlugins
0cf410aebe5b9d7a516eb0995e32383cc944f838
[ "Apache-2.0" ]
null
null
null
RemoteControl/LinuxDevice.cpp
dwrobel/WPEFrameworkPlugins
0cf410aebe5b9d7a516eb0995e32383cc944f838
[ "Apache-2.0" ]
null
null
null
RemoteControl/LinuxDevice.cpp
dwrobel/WPEFrameworkPlugins
0cf410aebe5b9d7a516eb0995e32383cc944f838
[ "Apache-2.0" ]
null
null
null
#include "RemoteAdministrator.h" #include <interfaces/IKeyHandler.h> #include <libudev.h> #include <linux/uinput.h> namespace WPEFramework { namespace Plugin { static char Locator[] = _T("/dev/input"); class LinuxDevice : public Exchange::IKeyProducer, Core::Thread { private: LinuxDevice(const LinuxDevice&) = delete; LinuxDevice& operator=(const LinuxDevice&) = delete; public: LinuxDevice() : Core::Thread(Core::Thread::DefaultStackSize(), _T("LinuxInputSystem")) , _devices() , _monitor(nullptr) , _update(-1) , _callback(nullptr) { _pipe[0] = -1; _pipe[1] = -1; if (::pipe(_pipe) < 0) { // Pipe not successfully opened. Close, if needed; if (_pipe[0] != -1) { close(_pipe[0]); } if (_pipe[1] != -1) { close(_pipe[1]); } _pipe[0] = -1; _pipe[1] = -1; } else { struct udev* udev = udev_new(); // Set up a monitor to monitor event devices _monitor = udev_monitor_new_from_netlink(udev, "udev"); udev_monitor_filter_add_match_subsystem_devtype(_monitor, "input", nullptr); udev_monitor_enable_receiving(_monitor); // Get the file descriptor (fd) for the monitor _update = udev_monitor_get_fd(_monitor); udev_unref(udev); Remotes::RemoteAdministrator::Instance().Announce(*this); } } virtual ~LinuxDevice() { Block(); Clear(); if (_pipe[0] != -1) { Remotes::RemoteAdministrator::Instance().Revoke(*this); close(_pipe[0]); close(_pipe[1]); } if (_update != -1) { ::close(_update); } if (_monitor != nullptr) { udev_monitor_unref(_monitor); } } public: virtual const TCHAR* Name() const { return (_T("DevInput")); } virtual void Configure(const string&) { Pair(); } virtual bool Pair() { // Make sure we are not processing anything. Block(); Refresh(); // We are done, start observing again. Run(); return (true); } virtual bool Unpair(string bindingId) { // Make sure we are not processing anything. Block(); Refresh(); // We are done, start observing again. Run(); return (true); } virtual uint32_t Callback(Exchange::IKeyHandler* callback) { ASSERT((callback == nullptr) ^ (_callback == nullptr)); if (callback == nullptr) { // We are unlinked. Deinitialize the stuff. _callback = nullptr; } else { TRACE_L1("%s: callback=%p _callback=%p", __FUNCTION__, callback, _callback); _callback = callback; } return (Core::ERROR_NONE); } virtual uint32_t Error() const { return (Core::ERROR_NONE); } virtual string MetaData() const { return (Name()); } BEGIN_INTERFACE_MAP(LinuxDevice) INTERFACE_ENTRY(Exchange::IKeyProducer) END_INTERFACE_MAP private: void Refresh() { // Remove all current open devices. Clear(); // find devices in /dev/input/ Core::Directory dir(Locator); while (dir.Next() == true) { Core::File entry(dir.Current(), false); if ((entry.IsDirectory() == false) && (entry.FileName().substr(0, 5) == _T("event"))) { TRACE(Trace::Information, (_T("Opening input device: %s"), entry.Name().c_str())); if (entry.Open(true) == true) { _devices.push_back(entry.DuplicateHandle()); } } } } void Clear() { for (std::vector<int>::const_iterator it = _devices.begin(), end = _devices.end(); it != end; ++it) { close(*it); } _devices.clear(); } void Block() { Core::Thread::Block(); write(_pipe[1], " ", 1); Wait(Core::Thread::INITIALIZED | Core::Thread::BLOCKED | Core::Thread::STOPPED, Core::infinite); } virtual uint32_t Worker() { while (IsRunning() == true) { fd_set readset; FD_ZERO(&readset); FD_SET(_pipe[0], &readset); FD_SET(_update, &readset); int result = std::max(_pipe[0], _update); // set up all the input devices for (std::vector<int>::const_iterator index = _devices.begin(), end = _devices.end(); index != end; ++index) { FD_SET(*index, &readset); result = std::max(result, *index); } result = select(result + 1, &readset, 0, 0, nullptr); if (result > 0) { if (FD_ISSET(_pipe[0], &readset)) { char buff; (void)read(_pipe[0], &buff, 1); } if (FD_ISSET(_update, &readset)) { // Make the call to receive the device. select() ensured that this will not block. udev_device* dev = udev_monitor_receive_device(_monitor); if (dev) { const char* nodeId = udev_device_get_devnode(dev); bool reload = ((nodeId != nullptr) && (strncmp(Locator, nodeId, sizeof(Locator) - 1) == 0)); udev_device_unref(dev); TRACE_L1("Changes from udev perspective. Reload (%s)", reload ? _T("true") : _T("false")); if (reload == true) { Refresh(); } } } // find the devices to read from std::vector<int>::iterator index = _devices.begin(); while (index != _devices.end()) { if (FD_ISSET(*index, &readset)) { if (HandleInput(*index) == false) { // fd closed? close(*index); index = _devices.erase(index); } else { ++index; } } else { ++index; } } } } return (Core::infinite); } bool HandleInput(const int fd) { input_event entry[16]; int index = 0; int result = ::read(fd, entry, sizeof(entry)); if (result > 0) { while (result >= static_cast<int>(sizeof(input_event))) { ASSERT(index < static_cast<int>((sizeof(entry) / sizeof(input_event)))); // If it is a KEY and it is *NOT* a repeat, send it.. // Repeat gets constructed by the framework anyway. if ((entry[index].type == EV_KEY) && (entry[index].value != 2)) { const uint16_t code = entry[index].code; const bool pressed = entry[index].value != 0; TRACE(Trace::Information, (_T("Sending pressed: %s, code: 0x%04X"), (pressed ? _T("true") : _T("false")), code)); _callback->KeyEvent(pressed, code, Name()); } index++; result -= sizeof(input_event); } } return (result >= 0); } private: std::vector<int> _devices; int _pipe[2]; udev_monitor* _monitor; int _update; Exchange::IKeyHandler* _callback; static LinuxDevice* _singleton; }; /* static */ LinuxDevice* LinuxDevice::_singleton = Core::Service<LinuxDevice>::Create<LinuxDevice>(); } }
32.259259
137
0.443169
dwrobel
339dce0367f9e7ea9b31beb134823f9b12d7d9d2
1,900
cpp
C++
src/+cv/colorChange.cpp
1123852253/mexopencv
17db690133299f561924a45e9092673a4df66c5b
[ "BSD-3-Clause" ]
571
2015-01-04T06:23:19.000Z
2022-03-31T07:37:19.000Z
src/+cv/colorChange.cpp
1123852253/mexopencv
17db690133299f561924a45e9092673a4df66c5b
[ "BSD-3-Clause" ]
362
2015-01-06T14:20:46.000Z
2022-01-20T08:10:46.000Z
src/+cv/colorChange.cpp
1123852253/mexopencv
17db690133299f561924a45e9092673a4df66c5b
[ "BSD-3-Clause" ]
300
2015-01-20T03:21:27.000Z
2022-03-31T07:36:37.000Z
/** * @file colorChange.cpp * @brief mex interface for cv::colorChange * @ingroup photo * @author Amro * @date 2015 */ #include "mexopencv.hpp" #include "opencv2/photo.hpp" using namespace std; using namespace cv; /** * Main entry called from Matlab * @param nlhs number of left-hand-side arguments * @param plhs pointers to mxArrays in the left-hand-side * @param nrhs number of right-hand-side arguments * @param prhs pointers to mxArrays in the right-hand-side */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { // Check the number of arguments nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1); // Argument vector vector<MxArray> rhs(prhs, prhs+nrhs); // Option processing float red_mul = 1.0f; float green_mul = 1.0f; float blue_mul = 1.0f; bool flip = false; for (int i=2; i<nrhs; i+=2) { string key(rhs[i].toString()); if (key == "R") red_mul = rhs[i+1].toFloat(); else if (key == "G") green_mul = rhs[i+1].toFloat(); else if (key == "B") blue_mul = rhs[i+1].toFloat(); else if (key == "FlipChannels") flip = rhs[i+1].toBool(); else mexErrMsgIdAndTxt("mexopencv:error", "Unrecognized option %s", key.c_str()); } // Process Mat src(rhs[0].toMat(CV_8U)), mask(rhs[1].toMat(CV_8U)), dst; // MATLAB's default is RGB while OpenCV's is BGR if (flip) { if (src.channels() == 3) cvtColor(src, src, cv::COLOR_RGB2BGR); if (mask.channels() == 3) cvtColor(mask, mask, cv::COLOR_RGB2BGR); } colorChange(src, mask, dst, red_mul, green_mul, blue_mul); // OpenCV's default is BGR while MATLAB's is RGB if (flip && dst.channels() == 3) cvtColor(dst, dst, cv::COLOR_BGR2RGB); plhs[0] = MxArray(dst); }
29.230769
76
0.584737
1123852253
339e0d3a8aba3297551cefdabb6e799b63201e1a
438,399
cc
C++
deps/v8/src/hydrogen.cc
Myrannas/runtime
d81f9ec641bb84e6713ae2ad8de29e1e54c65f4d
[ "ECL-2.0", "Apache-2.0" ]
1
2018-03-06T20:08:50.000Z
2018-03-06T20:08:50.000Z
deps/v8/src/hydrogen.cc
Myrannas/runtime
d81f9ec641bb84e6713ae2ad8de29e1e54c65f4d
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
deps/v8/src/hydrogen.cc
Myrannas/runtime
d81f9ec641bb84e6713ae2ad8de29e1e54c65f4d
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
// Copyright 2013 the V8 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. #include "src/hydrogen.h" #include <algorithm> #include "src/v8.h" #include "src/allocation-site-scopes.h" #include "src/codegen.h" #include "src/full-codegen.h" #include "src/hashmap.h" #include "src/hydrogen-bce.h" #include "src/hydrogen-bch.h" #include "src/hydrogen-canonicalize.h" #include "src/hydrogen-check-elimination.h" #include "src/hydrogen-dce.h" #include "src/hydrogen-dehoist.h" #include "src/hydrogen-environment-liveness.h" #include "src/hydrogen-escape-analysis.h" #include "src/hydrogen-gvn.h" #include "src/hydrogen-infer-representation.h" #include "src/hydrogen-infer-types.h" #include "src/hydrogen-load-elimination.h" #include "src/hydrogen-mark-deoptimize.h" #include "src/hydrogen-mark-unreachable.h" #include "src/hydrogen-osr.h" #include "src/hydrogen-range-analysis.h" #include "src/hydrogen-redundant-phi.h" #include "src/hydrogen-removable-simulates.h" #include "src/hydrogen-representation-changes.h" #include "src/hydrogen-sce.h" #include "src/hydrogen-store-elimination.h" #include "src/hydrogen-uint32-analysis.h" #include "src/lithium-allocator.h" #include "src/parser.h" #include "src/runtime.h" #include "src/scopeinfo.h" #include "src/scopes.h" #include "src/stub-cache.h" #include "src/typing.h" #if V8_TARGET_ARCH_IA32 #include "src/ia32/lithium-codegen-ia32.h" // NOLINT #elif V8_TARGET_ARCH_X64 #include "src/x64/lithium-codegen-x64.h" // NOLINT #elif V8_TARGET_ARCH_ARM64 #include "src/arm64/lithium-codegen-arm64.h" // NOLINT #elif V8_TARGET_ARCH_ARM #include "src/arm/lithium-codegen-arm.h" // NOLINT #elif V8_TARGET_ARCH_MIPS #include "src/mips/lithium-codegen-mips.h" // NOLINT #elif V8_TARGET_ARCH_X87 #include "src/x87/lithium-codegen-x87.h" // NOLINT #else #error Unsupported target architecture. #endif namespace v8 { namespace internal { HBasicBlock::HBasicBlock(HGraph* graph) : block_id_(graph->GetNextBlockID()), graph_(graph), phis_(4, graph->zone()), first_(NULL), last_(NULL), end_(NULL), loop_information_(NULL), predecessors_(2, graph->zone()), dominator_(NULL), dominated_blocks_(4, graph->zone()), last_environment_(NULL), argument_count_(-1), first_instruction_index_(-1), last_instruction_index_(-1), deleted_phis_(4, graph->zone()), parent_loop_header_(NULL), inlined_entry_block_(NULL), is_inline_return_target_(false), is_reachable_(true), dominates_loop_successors_(false), is_osr_entry_(false), is_ordered_(false) { } Isolate* HBasicBlock::isolate() const { return graph_->isolate(); } void HBasicBlock::MarkUnreachable() { is_reachable_ = false; } void HBasicBlock::AttachLoopInformation() { ASSERT(!IsLoopHeader()); loop_information_ = new(zone()) HLoopInformation(this, zone()); } void HBasicBlock::DetachLoopInformation() { ASSERT(IsLoopHeader()); loop_information_ = NULL; } void HBasicBlock::AddPhi(HPhi* phi) { ASSERT(!IsStartBlock()); phis_.Add(phi, zone()); phi->SetBlock(this); } void HBasicBlock::RemovePhi(HPhi* phi) { ASSERT(phi->block() == this); ASSERT(phis_.Contains(phi)); phi->Kill(); phis_.RemoveElement(phi); phi->SetBlock(NULL); } void HBasicBlock::AddInstruction(HInstruction* instr, HSourcePosition position) { ASSERT(!IsStartBlock() || !IsFinished()); ASSERT(!instr->IsLinked()); ASSERT(!IsFinished()); if (!position.IsUnknown()) { instr->set_position(position); } if (first_ == NULL) { ASSERT(last_environment() != NULL); ASSERT(!last_environment()->ast_id().IsNone()); HBlockEntry* entry = new(zone()) HBlockEntry(); entry->InitializeAsFirst(this); if (!position.IsUnknown()) { entry->set_position(position); } else { ASSERT(!FLAG_hydrogen_track_positions || !graph()->info()->IsOptimizing()); } first_ = last_ = entry; } instr->InsertAfter(last_); } HPhi* HBasicBlock::AddNewPhi(int merged_index) { if (graph()->IsInsideNoSideEffectsScope()) { merged_index = HPhi::kInvalidMergedIndex; } HPhi* phi = new(zone()) HPhi(merged_index, zone()); AddPhi(phi); return phi; } HSimulate* HBasicBlock::CreateSimulate(BailoutId ast_id, RemovableSimulate removable) { ASSERT(HasEnvironment()); HEnvironment* environment = last_environment(); ASSERT(ast_id.IsNone() || ast_id == BailoutId::StubEntry() || environment->closure()->shared()->VerifyBailoutId(ast_id)); int push_count = environment->push_count(); int pop_count = environment->pop_count(); HSimulate* instr = new(zone()) HSimulate(ast_id, pop_count, zone(), removable); #ifdef DEBUG instr->set_closure(environment->closure()); #endif // Order of pushed values: newest (top of stack) first. This allows // HSimulate::MergeWith() to easily append additional pushed values // that are older (from further down the stack). for (int i = 0; i < push_count; ++i) { instr->AddPushedValue(environment->ExpressionStackAt(i)); } for (GrowableBitVector::Iterator it(environment->assigned_variables(), zone()); !it.Done(); it.Advance()) { int index = it.Current(); instr->AddAssignedValue(index, environment->Lookup(index)); } environment->ClearHistory(); return instr; } void HBasicBlock::Finish(HControlInstruction* end, HSourcePosition position) { ASSERT(!IsFinished()); AddInstruction(end, position); end_ = end; for (HSuccessorIterator it(end); !it.Done(); it.Advance()) { it.Current()->RegisterPredecessor(this); } } void HBasicBlock::Goto(HBasicBlock* block, HSourcePosition position, FunctionState* state, bool add_simulate) { bool drop_extra = state != NULL && state->inlining_kind() == NORMAL_RETURN; if (block->IsInlineReturnTarget()) { HEnvironment* env = last_environment(); int argument_count = env->arguments_environment()->parameter_count(); AddInstruction(new(zone()) HLeaveInlined(state->entry(), argument_count), position); UpdateEnvironment(last_environment()->DiscardInlined(drop_extra)); } if (add_simulate) AddNewSimulate(BailoutId::None(), position); HGoto* instr = new(zone()) HGoto(block); Finish(instr, position); } void HBasicBlock::AddLeaveInlined(HValue* return_value, FunctionState* state, HSourcePosition position) { HBasicBlock* target = state->function_return(); bool drop_extra = state->inlining_kind() == NORMAL_RETURN; ASSERT(target->IsInlineReturnTarget()); ASSERT(return_value != NULL); HEnvironment* env = last_environment(); int argument_count = env->arguments_environment()->parameter_count(); AddInstruction(new(zone()) HLeaveInlined(state->entry(), argument_count), position); UpdateEnvironment(last_environment()->DiscardInlined(drop_extra)); last_environment()->Push(return_value); AddNewSimulate(BailoutId::None(), position); HGoto* instr = new(zone()) HGoto(target); Finish(instr, position); } void HBasicBlock::SetInitialEnvironment(HEnvironment* env) { ASSERT(!HasEnvironment()); ASSERT(first() == NULL); UpdateEnvironment(env); } void HBasicBlock::UpdateEnvironment(HEnvironment* env) { last_environment_ = env; graph()->update_maximum_environment_size(env->first_expression_index()); } void HBasicBlock::SetJoinId(BailoutId ast_id) { int length = predecessors_.length(); ASSERT(length > 0); for (int i = 0; i < length; i++) { HBasicBlock* predecessor = predecessors_[i]; ASSERT(predecessor->end()->IsGoto()); HSimulate* simulate = HSimulate::cast(predecessor->end()->previous()); ASSERT(i != 0 || (predecessor->last_environment()->closure().is_null() || predecessor->last_environment()->closure()->shared() ->VerifyBailoutId(ast_id))); simulate->set_ast_id(ast_id); predecessor->last_environment()->set_ast_id(ast_id); } } bool HBasicBlock::Dominates(HBasicBlock* other) const { HBasicBlock* current = other->dominator(); while (current != NULL) { if (current == this) return true; current = current->dominator(); } return false; } bool HBasicBlock::EqualToOrDominates(HBasicBlock* other) const { if (this == other) return true; return Dominates(other); } int HBasicBlock::LoopNestingDepth() const { const HBasicBlock* current = this; int result = (current->IsLoopHeader()) ? 1 : 0; while (current->parent_loop_header() != NULL) { current = current->parent_loop_header(); result++; } return result; } void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) { ASSERT(IsLoopHeader()); SetJoinId(stmt->EntryId()); if (predecessors()->length() == 1) { // This is a degenerated loop. DetachLoopInformation(); return; } // Only the first entry into the loop is from outside the loop. All other // entries must be back edges. for (int i = 1; i < predecessors()->length(); ++i) { loop_information()->RegisterBackEdge(predecessors()->at(i)); } } void HBasicBlock::MarkSuccEdgeUnreachable(int succ) { ASSERT(IsFinished()); HBasicBlock* succ_block = end()->SuccessorAt(succ); ASSERT(succ_block->predecessors()->length() == 1); succ_block->MarkUnreachable(); } void HBasicBlock::RegisterPredecessor(HBasicBlock* pred) { if (HasPredecessor()) { // Only loop header blocks can have a predecessor added after // instructions have been added to the block (they have phis for all // values in the environment, these phis may be eliminated later). ASSERT(IsLoopHeader() || first_ == NULL); HEnvironment* incoming_env = pred->last_environment(); if (IsLoopHeader()) { ASSERT(phis()->length() == incoming_env->length()); for (int i = 0; i < phis_.length(); ++i) { phis_[i]->AddInput(incoming_env->values()->at(i)); } } else { last_environment()->AddIncomingEdge(this, pred->last_environment()); } } else if (!HasEnvironment() && !IsFinished()) { ASSERT(!IsLoopHeader()); SetInitialEnvironment(pred->last_environment()->Copy()); } predecessors_.Add(pred, zone()); } void HBasicBlock::AddDominatedBlock(HBasicBlock* block) { ASSERT(!dominated_blocks_.Contains(block)); // Keep the list of dominated blocks sorted such that if there is two // succeeding block in this list, the predecessor is before the successor. int index = 0; while (index < dominated_blocks_.length() && dominated_blocks_[index]->block_id() < block->block_id()) { ++index; } dominated_blocks_.InsertAt(index, block, zone()); } void HBasicBlock::AssignCommonDominator(HBasicBlock* other) { if (dominator_ == NULL) { dominator_ = other; other->AddDominatedBlock(this); } else if (other->dominator() != NULL) { HBasicBlock* first = dominator_; HBasicBlock* second = other; while (first != second) { if (first->block_id() > second->block_id()) { first = first->dominator(); } else { second = second->dominator(); } ASSERT(first != NULL && second != NULL); } if (dominator_ != first) { ASSERT(dominator_->dominated_blocks_.Contains(this)); dominator_->dominated_blocks_.RemoveElement(this); dominator_ = first; first->AddDominatedBlock(this); } } } void HBasicBlock::AssignLoopSuccessorDominators() { // Mark blocks that dominate all subsequent reachable blocks inside their // loop. Exploit the fact that blocks are sorted in reverse post order. When // the loop is visited in increasing block id order, if the number of // non-loop-exiting successor edges at the dominator_candidate block doesn't // exceed the number of previously encountered predecessor edges, there is no // path from the loop header to any block with higher id that doesn't go // through the dominator_candidate block. In this case, the // dominator_candidate block is guaranteed to dominate all blocks reachable // from it with higher ids. HBasicBlock* last = loop_information()->GetLastBackEdge(); int outstanding_successors = 1; // one edge from the pre-header // Header always dominates everything. MarkAsLoopSuccessorDominator(); for (int j = block_id(); j <= last->block_id(); ++j) { HBasicBlock* dominator_candidate = graph_->blocks()->at(j); for (HPredecessorIterator it(dominator_candidate); !it.Done(); it.Advance()) { HBasicBlock* predecessor = it.Current(); // Don't count back edges. if (predecessor->block_id() < dominator_candidate->block_id()) { outstanding_successors--; } } // If more successors than predecessors have been seen in the loop up to // now, it's not possible to guarantee that the current block dominates // all of the blocks with higher IDs. In this case, assume conservatively // that those paths through loop that don't go through the current block // contain all of the loop's dependencies. Also be careful to record // dominator information about the current loop that's being processed, // and not nested loops, which will be processed when // AssignLoopSuccessorDominators gets called on their header. ASSERT(outstanding_successors >= 0); HBasicBlock* parent_loop_header = dominator_candidate->parent_loop_header(); if (outstanding_successors == 0 && (parent_loop_header == this && !dominator_candidate->IsLoopHeader())) { dominator_candidate->MarkAsLoopSuccessorDominator(); } HControlInstruction* end = dominator_candidate->end(); for (HSuccessorIterator it(end); !it.Done(); it.Advance()) { HBasicBlock* successor = it.Current(); // Only count successors that remain inside the loop and don't loop back // to a loop header. if (successor->block_id() > dominator_candidate->block_id() && successor->block_id() <= last->block_id()) { // Backwards edges must land on loop headers. ASSERT(successor->block_id() > dominator_candidate->block_id() || successor->IsLoopHeader()); outstanding_successors++; } } } } int HBasicBlock::PredecessorIndexOf(HBasicBlock* predecessor) const { for (int i = 0; i < predecessors_.length(); ++i) { if (predecessors_[i] == predecessor) return i; } UNREACHABLE(); return -1; } #ifdef DEBUG void HBasicBlock::Verify() { // Check that every block is finished. ASSERT(IsFinished()); ASSERT(block_id() >= 0); // Check that the incoming edges are in edge split form. if (predecessors_.length() > 1) { for (int i = 0; i < predecessors_.length(); ++i) { ASSERT(predecessors_[i]->end()->SecondSuccessor() == NULL); } } } #endif void HLoopInformation::RegisterBackEdge(HBasicBlock* block) { this->back_edges_.Add(block, block->zone()); AddBlock(block); } HBasicBlock* HLoopInformation::GetLastBackEdge() const { int max_id = -1; HBasicBlock* result = NULL; for (int i = 0; i < back_edges_.length(); ++i) { HBasicBlock* cur = back_edges_[i]; if (cur->block_id() > max_id) { max_id = cur->block_id(); result = cur; } } return result; } void HLoopInformation::AddBlock(HBasicBlock* block) { if (block == loop_header()) return; if (block->parent_loop_header() == loop_header()) return; if (block->parent_loop_header() != NULL) { AddBlock(block->parent_loop_header()); } else { block->set_parent_loop_header(loop_header()); blocks_.Add(block, block->zone()); for (int i = 0; i < block->predecessors()->length(); ++i) { AddBlock(block->predecessors()->at(i)); } } } #ifdef DEBUG // Checks reachability of the blocks in this graph and stores a bit in // the BitVector "reachable()" for every block that can be reached // from the start block of the graph. If "dont_visit" is non-null, the given // block is treated as if it would not be part of the graph. "visited_count()" // returns the number of reachable blocks. class ReachabilityAnalyzer BASE_EMBEDDED { public: ReachabilityAnalyzer(HBasicBlock* entry_block, int block_count, HBasicBlock* dont_visit) : visited_count_(0), stack_(16, entry_block->zone()), reachable_(block_count, entry_block->zone()), dont_visit_(dont_visit) { PushBlock(entry_block); Analyze(); } int visited_count() const { return visited_count_; } const BitVector* reachable() const { return &reachable_; } private: void PushBlock(HBasicBlock* block) { if (block != NULL && block != dont_visit_ && !reachable_.Contains(block->block_id())) { reachable_.Add(block->block_id()); stack_.Add(block, block->zone()); visited_count_++; } } void Analyze() { while (!stack_.is_empty()) { HControlInstruction* end = stack_.RemoveLast()->end(); for (HSuccessorIterator it(end); !it.Done(); it.Advance()) { PushBlock(it.Current()); } } } int visited_count_; ZoneList<HBasicBlock*> stack_; BitVector reachable_; HBasicBlock* dont_visit_; }; void HGraph::Verify(bool do_full_verify) const { Heap::RelocationLock relocation_lock(isolate()->heap()); AllowHandleDereference allow_deref; AllowDeferredHandleDereference allow_deferred_deref; for (int i = 0; i < blocks_.length(); i++) { HBasicBlock* block = blocks_.at(i); block->Verify(); // Check that every block contains at least one node and that only the last // node is a control instruction. HInstruction* current = block->first(); ASSERT(current != NULL && current->IsBlockEntry()); while (current != NULL) { ASSERT((current->next() == NULL) == current->IsControlInstruction()); ASSERT(current->block() == block); current->Verify(); current = current->next(); } // Check that successors are correctly set. HBasicBlock* first = block->end()->FirstSuccessor(); HBasicBlock* second = block->end()->SecondSuccessor(); ASSERT(second == NULL || first != NULL); // Check that the predecessor array is correct. if (first != NULL) { ASSERT(first->predecessors()->Contains(block)); if (second != NULL) { ASSERT(second->predecessors()->Contains(block)); } } // Check that phis have correct arguments. for (int j = 0; j < block->phis()->length(); j++) { HPhi* phi = block->phis()->at(j); phi->Verify(); } // Check that all join blocks have predecessors that end with an // unconditional goto and agree on their environment node id. if (block->predecessors()->length() >= 2) { BailoutId id = block->predecessors()->first()->last_environment()->ast_id(); for (int k = 0; k < block->predecessors()->length(); k++) { HBasicBlock* predecessor = block->predecessors()->at(k); ASSERT(predecessor->end()->IsGoto() || predecessor->end()->IsDeoptimize()); ASSERT(predecessor->last_environment()->ast_id() == id); } } } // Check special property of first block to have no predecessors. ASSERT(blocks_.at(0)->predecessors()->is_empty()); if (do_full_verify) { // Check that the graph is fully connected. ReachabilityAnalyzer analyzer(entry_block_, blocks_.length(), NULL); ASSERT(analyzer.visited_count() == blocks_.length()); // Check that entry block dominator is NULL. ASSERT(entry_block_->dominator() == NULL); // Check dominators. for (int i = 0; i < blocks_.length(); ++i) { HBasicBlock* block = blocks_.at(i); if (block->dominator() == NULL) { // Only start block may have no dominator assigned to. ASSERT(i == 0); } else { // Assert that block is unreachable if dominator must not be visited. ReachabilityAnalyzer dominator_analyzer(entry_block_, blocks_.length(), block->dominator()); ASSERT(!dominator_analyzer.reachable()->Contains(block->block_id())); } } } } #endif HConstant* HGraph::GetConstant(SetOncePointer<HConstant>* pointer, int32_t value) { if (!pointer->is_set()) { // Can't pass GetInvalidContext() to HConstant::New, because that will // recursively call GetConstant HConstant* constant = HConstant::New(zone(), NULL, value); constant->InsertAfter(entry_block()->first()); pointer->set(constant); return constant; } return ReinsertConstantIfNecessary(pointer->get()); } HConstant* HGraph::ReinsertConstantIfNecessary(HConstant* constant) { if (!constant->IsLinked()) { // The constant was removed from the graph. Reinsert. constant->ClearFlag(HValue::kIsDead); constant->InsertAfter(entry_block()->first()); } return constant; } HConstant* HGraph::GetConstant0() { return GetConstant(&constant_0_, 0); } HConstant* HGraph::GetConstant1() { return GetConstant(&constant_1_, 1); } HConstant* HGraph::GetConstantMinus1() { return GetConstant(&constant_minus1_, -1); } #define DEFINE_GET_CONSTANT(Name, name, type, htype, boolean_value) \ HConstant* HGraph::GetConstant##Name() { \ if (!constant_##name##_.is_set()) { \ HConstant* constant = new(zone()) HConstant( \ Unique<Object>::CreateImmovable(isolate()->factory()->name##_value()), \ Unique<Map>::CreateImmovable(isolate()->factory()->type##_map()), \ false, \ Representation::Tagged(), \ htype, \ true, \ boolean_value, \ false, \ ODDBALL_TYPE); \ constant->InsertAfter(entry_block()->first()); \ constant_##name##_.set(constant); \ } \ return ReinsertConstantIfNecessary(constant_##name##_.get()); \ } DEFINE_GET_CONSTANT(Undefined, undefined, undefined, HType::Undefined(), false) DEFINE_GET_CONSTANT(True, true, boolean, HType::Boolean(), true) DEFINE_GET_CONSTANT(False, false, boolean, HType::Boolean(), false) DEFINE_GET_CONSTANT(Hole, the_hole, the_hole, HType::None(), false) DEFINE_GET_CONSTANT(Null, null, null, HType::Null(), false) #undef DEFINE_GET_CONSTANT #define DEFINE_IS_CONSTANT(Name, name) \ bool HGraph::IsConstant##Name(HConstant* constant) { \ return constant_##name##_.is_set() && constant == constant_##name##_.get(); \ } DEFINE_IS_CONSTANT(Undefined, undefined) DEFINE_IS_CONSTANT(0, 0) DEFINE_IS_CONSTANT(1, 1) DEFINE_IS_CONSTANT(Minus1, minus1) DEFINE_IS_CONSTANT(True, true) DEFINE_IS_CONSTANT(False, false) DEFINE_IS_CONSTANT(Hole, the_hole) DEFINE_IS_CONSTANT(Null, null) #undef DEFINE_IS_CONSTANT HConstant* HGraph::GetInvalidContext() { return GetConstant(&constant_invalid_context_, 0xFFFFC0C7); } bool HGraph::IsStandardConstant(HConstant* constant) { if (IsConstantUndefined(constant)) return true; if (IsConstant0(constant)) return true; if (IsConstant1(constant)) return true; if (IsConstantMinus1(constant)) return true; if (IsConstantTrue(constant)) return true; if (IsConstantFalse(constant)) return true; if (IsConstantHole(constant)) return true; if (IsConstantNull(constant)) return true; return false; } HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder) : builder_(builder), finished_(false), did_then_(false), did_else_(false), did_else_if_(false), did_and_(false), did_or_(false), captured_(false), needs_compare_(true), pending_merge_block_(false), split_edge_merge_block_(NULL), merge_at_join_blocks_(NULL), normal_merge_at_join_block_count_(0), deopt_merge_at_join_block_count_(0) { HEnvironment* env = builder->environment(); first_true_block_ = builder->CreateBasicBlock(env->Copy()); first_false_block_ = builder->CreateBasicBlock(env->Copy()); } HGraphBuilder::IfBuilder::IfBuilder( HGraphBuilder* builder, HIfContinuation* continuation) : builder_(builder), finished_(false), did_then_(false), did_else_(false), did_else_if_(false), did_and_(false), did_or_(false), captured_(false), needs_compare_(false), pending_merge_block_(false), first_true_block_(NULL), first_false_block_(NULL), split_edge_merge_block_(NULL), merge_at_join_blocks_(NULL), normal_merge_at_join_block_count_(0), deopt_merge_at_join_block_count_(0) { continuation->Continue(&first_true_block_, &first_false_block_); } HControlInstruction* HGraphBuilder::IfBuilder::AddCompare( HControlInstruction* compare) { ASSERT(did_then_ == did_else_); if (did_else_) { // Handle if-then-elseif did_else_if_ = true; did_else_ = false; did_then_ = false; did_and_ = false; did_or_ = false; pending_merge_block_ = false; split_edge_merge_block_ = NULL; HEnvironment* env = builder_->environment(); first_true_block_ = builder_->CreateBasicBlock(env->Copy()); first_false_block_ = builder_->CreateBasicBlock(env->Copy()); } if (split_edge_merge_block_ != NULL) { HEnvironment* env = first_false_block_->last_environment(); HBasicBlock* split_edge = builder_->CreateBasicBlock(env->Copy()); if (did_or_) { compare->SetSuccessorAt(0, split_edge); compare->SetSuccessorAt(1, first_false_block_); } else { compare->SetSuccessorAt(0, first_true_block_); compare->SetSuccessorAt(1, split_edge); } builder_->GotoNoSimulate(split_edge, split_edge_merge_block_); } else { compare->SetSuccessorAt(0, first_true_block_); compare->SetSuccessorAt(1, first_false_block_); } builder_->FinishCurrentBlock(compare); needs_compare_ = false; return compare; } void HGraphBuilder::IfBuilder::Or() { ASSERT(!needs_compare_); ASSERT(!did_and_); did_or_ = true; HEnvironment* env = first_false_block_->last_environment(); if (split_edge_merge_block_ == NULL) { split_edge_merge_block_ = builder_->CreateBasicBlock(env->Copy()); builder_->GotoNoSimulate(first_true_block_, split_edge_merge_block_); first_true_block_ = split_edge_merge_block_; } builder_->set_current_block(first_false_block_); first_false_block_ = builder_->CreateBasicBlock(env->Copy()); } void HGraphBuilder::IfBuilder::And() { ASSERT(!needs_compare_); ASSERT(!did_or_); did_and_ = true; HEnvironment* env = first_false_block_->last_environment(); if (split_edge_merge_block_ == NULL) { split_edge_merge_block_ = builder_->CreateBasicBlock(env->Copy()); builder_->GotoNoSimulate(first_false_block_, split_edge_merge_block_); first_false_block_ = split_edge_merge_block_; } builder_->set_current_block(first_true_block_); first_true_block_ = builder_->CreateBasicBlock(env->Copy()); } void HGraphBuilder::IfBuilder::CaptureContinuation( HIfContinuation* continuation) { ASSERT(!did_else_if_); ASSERT(!finished_); ASSERT(!captured_); HBasicBlock* true_block = NULL; HBasicBlock* false_block = NULL; Finish(&true_block, &false_block); ASSERT(true_block != NULL); ASSERT(false_block != NULL); continuation->Capture(true_block, false_block); captured_ = true; builder_->set_current_block(NULL); End(); } void HGraphBuilder::IfBuilder::JoinContinuation(HIfContinuation* continuation) { ASSERT(!did_else_if_); ASSERT(!finished_); ASSERT(!captured_); HBasicBlock* true_block = NULL; HBasicBlock* false_block = NULL; Finish(&true_block, &false_block); merge_at_join_blocks_ = NULL; if (true_block != NULL && !true_block->IsFinished()) { ASSERT(continuation->IsTrueReachable()); builder_->GotoNoSimulate(true_block, continuation->true_branch()); } if (false_block != NULL && !false_block->IsFinished()) { ASSERT(continuation->IsFalseReachable()); builder_->GotoNoSimulate(false_block, continuation->false_branch()); } captured_ = true; End(); } void HGraphBuilder::IfBuilder::Then() { ASSERT(!captured_); ASSERT(!finished_); did_then_ = true; if (needs_compare_) { // Handle if's without any expressions, they jump directly to the "else" // branch. However, we must pretend that the "then" branch is reachable, // so that the graph builder visits it and sees any live range extending // constructs within it. HConstant* constant_false = builder_->graph()->GetConstantFalse(); ToBooleanStub::Types boolean_type = ToBooleanStub::Types(); boolean_type.Add(ToBooleanStub::BOOLEAN); HBranch* branch = builder()->New<HBranch>( constant_false, boolean_type, first_true_block_, first_false_block_); builder_->FinishCurrentBlock(branch); } builder_->set_current_block(first_true_block_); pending_merge_block_ = true; } void HGraphBuilder::IfBuilder::Else() { ASSERT(did_then_); ASSERT(!captured_); ASSERT(!finished_); AddMergeAtJoinBlock(false); builder_->set_current_block(first_false_block_); pending_merge_block_ = true; did_else_ = true; } void HGraphBuilder::IfBuilder::Deopt(const char* reason) { ASSERT(did_then_); builder_->Add<HDeoptimize>(reason, Deoptimizer::EAGER); AddMergeAtJoinBlock(true); } void HGraphBuilder::IfBuilder::Return(HValue* value) { HValue* parameter_count = builder_->graph()->GetConstantMinus1(); builder_->FinishExitCurrentBlock( builder_->New<HReturn>(value, parameter_count)); AddMergeAtJoinBlock(false); } void HGraphBuilder::IfBuilder::AddMergeAtJoinBlock(bool deopt) { if (!pending_merge_block_) return; HBasicBlock* block = builder_->current_block(); ASSERT(block == NULL || !block->IsFinished()); MergeAtJoinBlock* record = new(builder_->zone()) MergeAtJoinBlock(block, deopt, merge_at_join_blocks_); merge_at_join_blocks_ = record; if (block != NULL) { ASSERT(block->end() == NULL); if (deopt) { normal_merge_at_join_block_count_++; } else { deopt_merge_at_join_block_count_++; } } builder_->set_current_block(NULL); pending_merge_block_ = false; } void HGraphBuilder::IfBuilder::Finish() { ASSERT(!finished_); if (!did_then_) { Then(); } AddMergeAtJoinBlock(false); if (!did_else_) { Else(); AddMergeAtJoinBlock(false); } finished_ = true; } void HGraphBuilder::IfBuilder::Finish(HBasicBlock** then_continuation, HBasicBlock** else_continuation) { Finish(); MergeAtJoinBlock* else_record = merge_at_join_blocks_; if (else_continuation != NULL) { *else_continuation = else_record->block_; } MergeAtJoinBlock* then_record = else_record->next_; if (then_continuation != NULL) { *then_continuation = then_record->block_; } ASSERT(then_record->next_ == NULL); } void HGraphBuilder::IfBuilder::End() { if (captured_) return; Finish(); int total_merged_blocks = normal_merge_at_join_block_count_ + deopt_merge_at_join_block_count_; ASSERT(total_merged_blocks >= 1); HBasicBlock* merge_block = total_merged_blocks == 1 ? NULL : builder_->graph()->CreateBasicBlock(); // Merge non-deopt blocks first to ensure environment has right size for // padding. MergeAtJoinBlock* current = merge_at_join_blocks_; while (current != NULL) { if (!current->deopt_ && current->block_ != NULL) { // If there is only one block that makes it through to the end of the // if, then just set it as the current block and continue rather then // creating an unnecessary merge block. if (total_merged_blocks == 1) { builder_->set_current_block(current->block_); return; } builder_->GotoNoSimulate(current->block_, merge_block); } current = current->next_; } // Merge deopt blocks, padding when necessary. current = merge_at_join_blocks_; while (current != NULL) { if (current->deopt_ && current->block_ != NULL) { current->block_->FinishExit( HAbnormalExit::New(builder_->zone(), NULL), HSourcePosition::Unknown()); } current = current->next_; } builder_->set_current_block(merge_block); } HGraphBuilder::LoopBuilder::LoopBuilder(HGraphBuilder* builder, HValue* context, LoopBuilder::Direction direction) : builder_(builder), context_(context), direction_(direction), finished_(false) { header_block_ = builder->CreateLoopHeaderBlock(); body_block_ = NULL; exit_block_ = NULL; exit_trampoline_block_ = NULL; increment_amount_ = builder_->graph()->GetConstant1(); } HGraphBuilder::LoopBuilder::LoopBuilder(HGraphBuilder* builder, HValue* context, LoopBuilder::Direction direction, HValue* increment_amount) : builder_(builder), context_(context), direction_(direction), finished_(false) { header_block_ = builder->CreateLoopHeaderBlock(); body_block_ = NULL; exit_block_ = NULL; exit_trampoline_block_ = NULL; increment_amount_ = increment_amount; } HValue* HGraphBuilder::LoopBuilder::BeginBody( HValue* initial, HValue* terminating, Token::Value token) { HEnvironment* env = builder_->environment(); phi_ = header_block_->AddNewPhi(env->values()->length()); phi_->AddInput(initial); env->Push(initial); builder_->GotoNoSimulate(header_block_); HEnvironment* body_env = env->Copy(); HEnvironment* exit_env = env->Copy(); // Remove the phi from the expression stack body_env->Pop(); exit_env->Pop(); body_block_ = builder_->CreateBasicBlock(body_env); exit_block_ = builder_->CreateBasicBlock(exit_env); builder_->set_current_block(header_block_); env->Pop(); builder_->FinishCurrentBlock(builder_->New<HCompareNumericAndBranch>( phi_, terminating, token, body_block_, exit_block_)); builder_->set_current_block(body_block_); if (direction_ == kPreIncrement || direction_ == kPreDecrement) { HValue* one = builder_->graph()->GetConstant1(); if (direction_ == kPreIncrement) { increment_ = HAdd::New(zone(), context_, phi_, one); } else { increment_ = HSub::New(zone(), context_, phi_, one); } increment_->ClearFlag(HValue::kCanOverflow); builder_->AddInstruction(increment_); return increment_; } else { return phi_; } } void HGraphBuilder::LoopBuilder::Break() { if (exit_trampoline_block_ == NULL) { // Its the first time we saw a break. HEnvironment* env = exit_block_->last_environment()->Copy(); exit_trampoline_block_ = builder_->CreateBasicBlock(env); builder_->GotoNoSimulate(exit_block_, exit_trampoline_block_); } builder_->GotoNoSimulate(exit_trampoline_block_); builder_->set_current_block(NULL); } void HGraphBuilder::LoopBuilder::EndBody() { ASSERT(!finished_); if (direction_ == kPostIncrement || direction_ == kPostDecrement) { if (direction_ == kPostIncrement) { increment_ = HAdd::New(zone(), context_, phi_, increment_amount_); } else { increment_ = HSub::New(zone(), context_, phi_, increment_amount_); } increment_->ClearFlag(HValue::kCanOverflow); builder_->AddInstruction(increment_); } // Push the new increment value on the expression stack to merge into the phi. builder_->environment()->Push(increment_); HBasicBlock* last_block = builder_->current_block(); builder_->GotoNoSimulate(last_block, header_block_); header_block_->loop_information()->RegisterBackEdge(last_block); if (exit_trampoline_block_ != NULL) { builder_->set_current_block(exit_trampoline_block_); } else { builder_->set_current_block(exit_block_); } finished_ = true; } HGraph* HGraphBuilder::CreateGraph() { graph_ = new(zone()) HGraph(info_); if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_); CompilationPhase phase("H_Block building", info_); set_current_block(graph()->entry_block()); if (!BuildGraph()) return NULL; graph()->FinalizeUniqueness(); return graph_; } HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { ASSERT(current_block() != NULL); ASSERT(!FLAG_hydrogen_track_positions || !position_.IsUnknown() || !info_->IsOptimizing()); current_block()->AddInstruction(instr, source_position()); if (graph()->IsInsideNoSideEffectsScope()) { instr->SetFlag(HValue::kHasNoObservableSideEffects); } return instr; } void HGraphBuilder::FinishCurrentBlock(HControlInstruction* last) { ASSERT(!FLAG_hydrogen_track_positions || !info_->IsOptimizing() || !position_.IsUnknown()); current_block()->Finish(last, source_position()); if (last->IsReturn() || last->IsAbnormalExit()) { set_current_block(NULL); } } void HGraphBuilder::FinishExitCurrentBlock(HControlInstruction* instruction) { ASSERT(!FLAG_hydrogen_track_positions || !info_->IsOptimizing() || !position_.IsUnknown()); current_block()->FinishExit(instruction, source_position()); if (instruction->IsReturn() || instruction->IsAbnormalExit()) { set_current_block(NULL); } } void HGraphBuilder::AddIncrementCounter(StatsCounter* counter) { if (FLAG_native_code_counters && counter->Enabled()) { HValue* reference = Add<HConstant>(ExternalReference(counter)); HValue* old_value = Add<HLoadNamedField>( reference, static_cast<HValue*>(NULL), HObjectAccess::ForCounter()); HValue* new_value = AddUncasted<HAdd>(old_value, graph()->GetConstant1()); new_value->ClearFlag(HValue::kCanOverflow); // Ignore counter overflow Add<HStoreNamedField>(reference, HObjectAccess::ForCounter(), new_value, STORE_TO_INITIALIZED_ENTRY); } } void HGraphBuilder::AddSimulate(BailoutId id, RemovableSimulate removable) { ASSERT(current_block() != NULL); ASSERT(!graph()->IsInsideNoSideEffectsScope()); current_block()->AddNewSimulate(id, source_position(), removable); } HBasicBlock* HGraphBuilder::CreateBasicBlock(HEnvironment* env) { HBasicBlock* b = graph()->CreateBasicBlock(); b->SetInitialEnvironment(env); return b; } HBasicBlock* HGraphBuilder::CreateLoopHeaderBlock() { HBasicBlock* header = graph()->CreateBasicBlock(); HEnvironment* entry_env = environment()->CopyAsLoopHeader(header); header->SetInitialEnvironment(entry_env); header->AttachLoopInformation(); return header; } HValue* HGraphBuilder::BuildGetElementsKind(HValue* object) { HValue* map = Add<HLoadNamedField>(object, static_cast<HValue*>(NULL), HObjectAccess::ForMap()); HValue* bit_field2 = Add<HLoadNamedField>(map, static_cast<HValue*>(NULL), HObjectAccess::ForMapBitField2()); return BuildDecodeField<Map::ElementsKindBits>(bit_field2); } HValue* HGraphBuilder::BuildCheckHeapObject(HValue* obj) { if (obj->type().IsHeapObject()) return obj; return Add<HCheckHeapObject>(obj); } void HGraphBuilder::FinishExitWithHardDeoptimization(const char* reason) { Add<HDeoptimize>(reason, Deoptimizer::EAGER); FinishExitCurrentBlock(New<HAbnormalExit>()); } HValue* HGraphBuilder::BuildCheckString(HValue* string) { if (!string->type().IsString()) { ASSERT(!string->IsConstant() || !HConstant::cast(string)->HasStringValue()); BuildCheckHeapObject(string); return Add<HCheckInstanceType>(string, HCheckInstanceType::IS_STRING); } return string; } HValue* HGraphBuilder::BuildWrapReceiver(HValue* object, HValue* function) { if (object->type().IsJSObject()) return object; if (function->IsConstant() && HConstant::cast(function)->handle(isolate())->IsJSFunction()) { Handle<JSFunction> f = Handle<JSFunction>::cast( HConstant::cast(function)->handle(isolate())); SharedFunctionInfo* shared = f->shared(); if (shared->strict_mode() == STRICT || shared->native()) return object; } return Add<HWrapReceiver>(object, function); } HValue* HGraphBuilder::BuildCheckForCapacityGrow( HValue* object, HValue* elements, ElementsKind kind, HValue* length, HValue* key, bool is_js_array, PropertyAccessType access_type) { IfBuilder length_checker(this); Token::Value token = IsHoleyElementsKind(kind) ? Token::GTE : Token::EQ; length_checker.If<HCompareNumericAndBranch>(key, length, token); length_checker.Then(); HValue* current_capacity = AddLoadFixedArrayLength(elements); IfBuilder capacity_checker(this); capacity_checker.If<HCompareNumericAndBranch>(key, current_capacity, Token::GTE); capacity_checker.Then(); HValue* max_gap = Add<HConstant>(static_cast<int32_t>(JSObject::kMaxGap)); HValue* max_capacity = AddUncasted<HAdd>(current_capacity, max_gap); Add<HBoundsCheck>(key, max_capacity); HValue* new_capacity = BuildNewElementsCapacity(key); HValue* new_elements = BuildGrowElementsCapacity(object, elements, kind, kind, length, new_capacity); environment()->Push(new_elements); capacity_checker.Else(); environment()->Push(elements); capacity_checker.End(); if (is_js_array) { HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1()); new_length->ClearFlag(HValue::kCanOverflow); Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind), new_length); } if (access_type == STORE && kind == FAST_SMI_ELEMENTS) { HValue* checked_elements = environment()->Top(); // Write zero to ensure that the new element is initialized with some smi. Add<HStoreKeyed>(checked_elements, key, graph()->GetConstant0(), kind); } length_checker.Else(); Add<HBoundsCheck>(key, length); environment()->Push(elements); length_checker.End(); return environment()->Pop(); } HValue* HGraphBuilder::BuildCopyElementsOnWrite(HValue* object, HValue* elements, ElementsKind kind, HValue* length) { Factory* factory = isolate()->factory(); IfBuilder cow_checker(this); cow_checker.If<HCompareMap>(elements, factory->fixed_cow_array_map()); cow_checker.Then(); HValue* capacity = AddLoadFixedArrayLength(elements); HValue* new_elements = BuildGrowElementsCapacity(object, elements, kind, kind, length, capacity); environment()->Push(new_elements); cow_checker.Else(); environment()->Push(elements); cow_checker.End(); return environment()->Pop(); } void HGraphBuilder::BuildTransitionElementsKind(HValue* object, HValue* map, ElementsKind from_kind, ElementsKind to_kind, bool is_jsarray) { ASSERT(!IsFastHoleyElementsKind(from_kind) || IsFastHoleyElementsKind(to_kind)); if (AllocationSite::GetMode(from_kind, to_kind) == TRACK_ALLOCATION_SITE) { Add<HTrapAllocationMemento>(object); } if (!IsSimpleMapChangeTransition(from_kind, to_kind)) { HInstruction* elements = AddLoadElements(object); HInstruction* empty_fixed_array = Add<HConstant>( isolate()->factory()->empty_fixed_array()); IfBuilder if_builder(this); if_builder.IfNot<HCompareObjectEqAndBranch>(elements, empty_fixed_array); if_builder.Then(); HInstruction* elements_length = AddLoadFixedArrayLength(elements); HInstruction* array_length = is_jsarray ? Add<HLoadNamedField>(object, static_cast<HValue*>(NULL), HObjectAccess::ForArrayLength(from_kind)) : elements_length; BuildGrowElementsCapacity(object, elements, from_kind, to_kind, array_length, elements_length); if_builder.End(); } Add<HStoreNamedField>(object, HObjectAccess::ForMap(), map); } void HGraphBuilder::BuildJSObjectCheck(HValue* receiver, int bit_field_mask) { // Check that the object isn't a smi. Add<HCheckHeapObject>(receiver); // Get the map of the receiver. HValue* map = Add<HLoadNamedField>(receiver, static_cast<HValue*>(NULL), HObjectAccess::ForMap()); // Check the instance type and if an access check is needed, this can be // done with a single load, since both bytes are adjacent in the map. HObjectAccess access(HObjectAccess::ForMapInstanceTypeAndBitField()); HValue* instance_type_and_bit_field = Add<HLoadNamedField>(map, static_cast<HValue*>(NULL), access); HValue* mask = Add<HConstant>(0x00FF | (bit_field_mask << 8)); HValue* and_result = AddUncasted<HBitwise>(Token::BIT_AND, instance_type_and_bit_field, mask); HValue* sub_result = AddUncasted<HSub>(and_result, Add<HConstant>(JS_OBJECT_TYPE)); Add<HBoundsCheck>(sub_result, Add<HConstant>(0x100 - JS_OBJECT_TYPE)); } void HGraphBuilder::BuildKeyedIndexCheck(HValue* key, HIfContinuation* join_continuation) { // The sometimes unintuitively backward ordering of the ifs below is // convoluted, but necessary. All of the paths must guarantee that the // if-true of the continuation returns a smi element index and the if-false of // the continuation returns either a symbol or a unique string key. All other // object types cause a deopt to fall back to the runtime. IfBuilder key_smi_if(this); key_smi_if.If<HIsSmiAndBranch>(key); key_smi_if.Then(); { Push(key); // Nothing to do, just continue to true of continuation. } key_smi_if.Else(); { HValue* map = Add<HLoadNamedField>(key, static_cast<HValue*>(NULL), HObjectAccess::ForMap()); HValue* instance_type = Add<HLoadNamedField>(map, static_cast<HValue*>(NULL), HObjectAccess::ForMapInstanceType()); // Non-unique string, check for a string with a hash code that is actually // an index. STATIC_ASSERT(LAST_UNIQUE_NAME_TYPE == FIRST_NONSTRING_TYPE); IfBuilder not_string_or_name_if(this); not_string_or_name_if.If<HCompareNumericAndBranch>( instance_type, Add<HConstant>(LAST_UNIQUE_NAME_TYPE), Token::GT); not_string_or_name_if.Then(); { // Non-smi, non-Name, non-String: Try to convert to smi in case of // HeapNumber. // TODO(danno): This could call some variant of ToString Push(AddUncasted<HForceRepresentation>(key, Representation::Smi())); } not_string_or_name_if.Else(); { // String or Name: check explicitly for Name, they can short-circuit // directly to unique non-index key path. IfBuilder not_symbol_if(this); not_symbol_if.If<HCompareNumericAndBranch>( instance_type, Add<HConstant>(SYMBOL_TYPE), Token::NE); not_symbol_if.Then(); { // String: check whether the String is a String of an index. If it is, // extract the index value from the hash. HValue* hash = Add<HLoadNamedField>(key, static_cast<HValue*>(NULL), HObjectAccess::ForNameHashField()); HValue* not_index_mask = Add<HConstant>(static_cast<int>( String::kContainsCachedArrayIndexMask)); HValue* not_index_test = AddUncasted<HBitwise>( Token::BIT_AND, hash, not_index_mask); IfBuilder string_index_if(this); string_index_if.If<HCompareNumericAndBranch>(not_index_test, graph()->GetConstant0(), Token::EQ); string_index_if.Then(); { // String with index in hash: extract string and merge to index path. Push(BuildDecodeField<String::ArrayIndexValueBits>(hash)); } string_index_if.Else(); { // Key is a non-index String, check for uniqueness/internalization. If // it's not, deopt. HValue* not_internalized_bit = AddUncasted<HBitwise>( Token::BIT_AND, instance_type, Add<HConstant>(static_cast<int>(kIsNotInternalizedMask))); DeoptimizeIf<HCompareNumericAndBranch>( not_internalized_bit, graph()->GetConstant0(), Token::NE, "BuildKeyedIndexCheck: string isn't internalized"); // Key guaranteed to be a unqiue string Push(key); } string_index_if.JoinContinuation(join_continuation); } not_symbol_if.Else(); { Push(key); // Key is symbol } not_symbol_if.JoinContinuation(join_continuation); } not_string_or_name_if.JoinContinuation(join_continuation); } key_smi_if.JoinContinuation(join_continuation); } void HGraphBuilder::BuildNonGlobalObjectCheck(HValue* receiver) { // Get the the instance type of the receiver, and make sure that it is // not one of the global object types. HValue* map = Add<HLoadNamedField>(receiver, static_cast<HValue*>(NULL), HObjectAccess::ForMap()); HValue* instance_type = Add<HLoadNamedField>(map, static_cast<HValue*>(NULL), HObjectAccess::ForMapInstanceType()); STATIC_ASSERT(JS_BUILTINS_OBJECT_TYPE == JS_GLOBAL_OBJECT_TYPE + 1); HValue* min_global_type = Add<HConstant>(JS_GLOBAL_OBJECT_TYPE); HValue* max_global_type = Add<HConstant>(JS_BUILTINS_OBJECT_TYPE); IfBuilder if_global_object(this); if_global_object.If<HCompareNumericAndBranch>(instance_type, max_global_type, Token::LTE); if_global_object.And(); if_global_object.If<HCompareNumericAndBranch>(instance_type, min_global_type, Token::GTE); if_global_object.ThenDeopt("receiver was a global object"); if_global_object.End(); } void HGraphBuilder::BuildTestForDictionaryProperties( HValue* object, HIfContinuation* continuation) { HValue* properties = Add<HLoadNamedField>( object, static_cast<HValue*>(NULL), HObjectAccess::ForPropertiesPointer()); HValue* properties_map = Add<HLoadNamedField>(properties, static_cast<HValue*>(NULL), HObjectAccess::ForMap()); HValue* hash_map = Add<HLoadRoot>(Heap::kHashTableMapRootIndex); IfBuilder builder(this); builder.If<HCompareObjectEqAndBranch>(properties_map, hash_map); builder.CaptureContinuation(continuation); } HValue* HGraphBuilder::BuildKeyedLookupCacheHash(HValue* object, HValue* key) { // Load the map of the receiver, compute the keyed lookup cache hash // based on 32 bits of the map pointer and the string hash. HValue* object_map = Add<HLoadNamedField>(object, static_cast<HValue*>(NULL), HObjectAccess::ForMapAsInteger32()); HValue* shifted_map = AddUncasted<HShr>( object_map, Add<HConstant>(KeyedLookupCache::kMapHashShift)); HValue* string_hash = Add<HLoadNamedField>(key, static_cast<HValue*>(NULL), HObjectAccess::ForStringHashField()); HValue* shifted_hash = AddUncasted<HShr>( string_hash, Add<HConstant>(String::kHashShift)); HValue* xor_result = AddUncasted<HBitwise>(Token::BIT_XOR, shifted_map, shifted_hash); int mask = (KeyedLookupCache::kCapacityMask & KeyedLookupCache::kHashMask); return AddUncasted<HBitwise>(Token::BIT_AND, xor_result, Add<HConstant>(mask)); } HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoadHelper( HValue* elements, HValue* key, HValue* hash, HValue* mask, int current_probe) { if (current_probe == kNumberDictionaryProbes) { return NULL; } int32_t offset = SeededNumberDictionary::GetProbeOffset(current_probe); HValue* raw_index = (current_probe == 0) ? hash : AddUncasted<HAdd>(hash, Add<HConstant>(offset)); raw_index = AddUncasted<HBitwise>(Token::BIT_AND, raw_index, mask); int32_t entry_size = SeededNumberDictionary::kEntrySize; raw_index = AddUncasted<HMul>(raw_index, Add<HConstant>(entry_size)); raw_index->ClearFlag(HValue::kCanOverflow); int32_t base_offset = SeededNumberDictionary::kElementsStartIndex; HValue* key_index = AddUncasted<HAdd>(raw_index, Add<HConstant>(base_offset)); key_index->ClearFlag(HValue::kCanOverflow); HValue* candidate_key = Add<HLoadKeyed>(elements, key_index, static_cast<HValue*>(NULL), FAST_ELEMENTS); IfBuilder key_compare(this); key_compare.IfNot<HCompareObjectEqAndBranch>(key, candidate_key); key_compare.Then(); { // Key at the current probe doesn't match, try at the next probe. HValue* result = BuildUncheckedDictionaryElementLoadHelper( elements, key, hash, mask, current_probe + 1); if (result == NULL) { key_compare.Deopt("probes exhausted in keyed load dictionary lookup"); result = graph()->GetConstantUndefined(); } else { Push(result); } } key_compare.Else(); { // Key at current probe matches. Details must be zero, otherwise the // dictionary element requires special handling. HValue* details_index = AddUncasted<HAdd>( raw_index, Add<HConstant>(base_offset + 2)); details_index->ClearFlag(HValue::kCanOverflow); HValue* details = Add<HLoadKeyed>(elements, details_index, static_cast<HValue*>(NULL), FAST_ELEMENTS); IfBuilder details_compare(this); details_compare.If<HCompareNumericAndBranch>(details, graph()->GetConstant0(), Token::NE); details_compare.ThenDeopt("keyed load dictionary element not fast case"); details_compare.Else(); { // Key matches and details are zero --> fast case. Load and return the // value. HValue* result_index = AddUncasted<HAdd>( raw_index, Add<HConstant>(base_offset + 1)); result_index->ClearFlag(HValue::kCanOverflow); Push(Add<HLoadKeyed>(elements, result_index, static_cast<HValue*>(NULL), FAST_ELEMENTS)); } details_compare.End(); } key_compare.End(); return Pop(); } HValue* HGraphBuilder::BuildElementIndexHash(HValue* index) { int32_t seed_value = static_cast<uint32_t>(isolate()->heap()->HashSeed()); HValue* seed = Add<HConstant>(seed_value); HValue* hash = AddUncasted<HBitwise>(Token::BIT_XOR, index, seed); // hash = ~hash + (hash << 15); HValue* shifted_hash = AddUncasted<HShl>(hash, Add<HConstant>(15)); HValue* not_hash = AddUncasted<HBitwise>(Token::BIT_XOR, hash, graph()->GetConstantMinus1()); hash = AddUncasted<HAdd>(shifted_hash, not_hash); // hash = hash ^ (hash >> 12); shifted_hash = AddUncasted<HShr>(hash, Add<HConstant>(12)); hash = AddUncasted<HBitwise>(Token::BIT_XOR, hash, shifted_hash); // hash = hash + (hash << 2); shifted_hash = AddUncasted<HShl>(hash, Add<HConstant>(2)); hash = AddUncasted<HAdd>(hash, shifted_hash); // hash = hash ^ (hash >> 4); shifted_hash = AddUncasted<HShr>(hash, Add<HConstant>(4)); hash = AddUncasted<HBitwise>(Token::BIT_XOR, hash, shifted_hash); // hash = hash * 2057; hash = AddUncasted<HMul>(hash, Add<HConstant>(2057)); hash->ClearFlag(HValue::kCanOverflow); // hash = hash ^ (hash >> 16); shifted_hash = AddUncasted<HShr>(hash, Add<HConstant>(16)); return AddUncasted<HBitwise>(Token::BIT_XOR, hash, shifted_hash); } HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoad(HValue* receiver, HValue* elements, HValue* key, HValue* hash) { HValue* capacity = Add<HLoadKeyed>( elements, Add<HConstant>(NameDictionary::kCapacityIndex), static_cast<HValue*>(NULL), FAST_ELEMENTS); HValue* mask = AddUncasted<HSub>(capacity, graph()->GetConstant1()); mask->ChangeRepresentation(Representation::Integer32()); mask->ClearFlag(HValue::kCanOverflow); return BuildUncheckedDictionaryElementLoadHelper(elements, key, hash, mask, 0); } HValue* HGraphBuilder::BuildRegExpConstructResult(HValue* length, HValue* index, HValue* input) { NoObservableSideEffectsScope scope(this); HConstant* max_length = Add<HConstant>(JSObject::kInitialMaxFastElementArray); Add<HBoundsCheck>(length, max_length); // Generate size calculation code here in order to make it dominate // the JSRegExpResult allocation. ElementsKind elements_kind = FAST_ELEMENTS; HValue* size = BuildCalculateElementsSize(elements_kind, length); // Allocate the JSRegExpResult and the FixedArray in one step. HValue* result = Add<HAllocate>( Add<HConstant>(JSRegExpResult::kSize), HType::JSArray(), NOT_TENURED, JS_ARRAY_TYPE); // Initialize the JSRegExpResult header. HValue* global_object = Add<HLoadNamedField>( context(), static_cast<HValue*>(NULL), HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); HValue* native_context = Add<HLoadNamedField>( global_object, static_cast<HValue*>(NULL), HObjectAccess::ForGlobalObjectNativeContext()); Add<HStoreNamedField>( result, HObjectAccess::ForMap(), Add<HLoadNamedField>( native_context, static_cast<HValue*>(NULL), HObjectAccess::ForContextSlot(Context::REGEXP_RESULT_MAP_INDEX))); HConstant* empty_fixed_array = Add<HConstant>(isolate()->factory()->empty_fixed_array()); Add<HStoreNamedField>( result, HObjectAccess::ForJSArrayOffset(JSArray::kPropertiesOffset), empty_fixed_array); Add<HStoreNamedField>( result, HObjectAccess::ForJSArrayOffset(JSArray::kElementsOffset), empty_fixed_array); Add<HStoreNamedField>( result, HObjectAccess::ForJSArrayOffset(JSArray::kLengthOffset), length); // Initialize the additional fields. Add<HStoreNamedField>( result, HObjectAccess::ForJSArrayOffset(JSRegExpResult::kIndexOffset), index); Add<HStoreNamedField>( result, HObjectAccess::ForJSArrayOffset(JSRegExpResult::kInputOffset), input); // Allocate and initialize the elements header. HAllocate* elements = BuildAllocateElements(elements_kind, size); BuildInitializeElementsHeader(elements, elements_kind, length); HConstant* size_in_bytes_upper_bound = EstablishElementsAllocationSize( elements_kind, max_length->Integer32Value()); elements->set_size_upper_bound(size_in_bytes_upper_bound); Add<HStoreNamedField>( result, HObjectAccess::ForJSArrayOffset(JSArray::kElementsOffset), elements); // Initialize the elements contents with undefined. BuildFillElementsWithValue( elements, elements_kind, graph()->GetConstant0(), length, graph()->GetConstantUndefined()); return result; } HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) { NoObservableSideEffectsScope scope(this); // Convert constant numbers at compile time. if (object->IsConstant() && HConstant::cast(object)->HasNumberValue()) { Handle<Object> number = HConstant::cast(object)->handle(isolate()); Handle<String> result = isolate()->factory()->NumberToString(number); return Add<HConstant>(result); } // Create a joinable continuation. HIfContinuation found(graph()->CreateBasicBlock(), graph()->CreateBasicBlock()); // Load the number string cache. HValue* number_string_cache = Add<HLoadRoot>(Heap::kNumberStringCacheRootIndex); // Make the hash mask from the length of the number string cache. It // contains two elements (number and string) for each cache entry. HValue* mask = AddLoadFixedArrayLength(number_string_cache); mask->set_type(HType::Smi()); mask = AddUncasted<HSar>(mask, graph()->GetConstant1()); mask = AddUncasted<HSub>(mask, graph()->GetConstant1()); // Check whether object is a smi. IfBuilder if_objectissmi(this); if_objectissmi.If<HIsSmiAndBranch>(object); if_objectissmi.Then(); { // Compute hash for smi similar to smi_get_hash(). HValue* hash = AddUncasted<HBitwise>(Token::BIT_AND, object, mask); // Load the key. HValue* key_index = AddUncasted<HShl>(hash, graph()->GetConstant1()); HValue* key = Add<HLoadKeyed>(number_string_cache, key_index, static_cast<HValue*>(NULL), FAST_ELEMENTS, ALLOW_RETURN_HOLE); // Check if object == key. IfBuilder if_objectiskey(this); if_objectiskey.If<HCompareObjectEqAndBranch>(object, key); if_objectiskey.Then(); { // Make the key_index available. Push(key_index); } if_objectiskey.JoinContinuation(&found); } if_objectissmi.Else(); { if (type->Is(Type::SignedSmall())) { if_objectissmi.Deopt("Expected smi"); } else { // Check if the object is a heap number. IfBuilder if_objectisnumber(this); HValue* objectisnumber = if_objectisnumber.If<HCompareMap>( object, isolate()->factory()->heap_number_map()); if_objectisnumber.Then(); { // Compute hash for heap number similar to double_get_hash(). HValue* low = Add<HLoadNamedField>( object, objectisnumber, HObjectAccess::ForHeapNumberValueLowestBits()); HValue* high = Add<HLoadNamedField>( object, objectisnumber, HObjectAccess::ForHeapNumberValueHighestBits()); HValue* hash = AddUncasted<HBitwise>(Token::BIT_XOR, low, high); hash = AddUncasted<HBitwise>(Token::BIT_AND, hash, mask); // Load the key. HValue* key_index = AddUncasted<HShl>(hash, graph()->GetConstant1()); HValue* key = Add<HLoadKeyed>(number_string_cache, key_index, static_cast<HValue*>(NULL), FAST_ELEMENTS, ALLOW_RETURN_HOLE); // Check if the key is a heap number and compare it with the object. IfBuilder if_keyisnotsmi(this); HValue* keyisnotsmi = if_keyisnotsmi.IfNot<HIsSmiAndBranch>(key); if_keyisnotsmi.Then(); { IfBuilder if_keyisheapnumber(this); if_keyisheapnumber.If<HCompareMap>( key, isolate()->factory()->heap_number_map()); if_keyisheapnumber.Then(); { // Check if values of key and object match. IfBuilder if_keyeqobject(this); if_keyeqobject.If<HCompareNumericAndBranch>( Add<HLoadNamedField>(key, keyisnotsmi, HObjectAccess::ForHeapNumberValue()), Add<HLoadNamedField>(object, objectisnumber, HObjectAccess::ForHeapNumberValue()), Token::EQ); if_keyeqobject.Then(); { // Make the key_index available. Push(key_index); } if_keyeqobject.JoinContinuation(&found); } if_keyisheapnumber.JoinContinuation(&found); } if_keyisnotsmi.JoinContinuation(&found); } if_objectisnumber.Else(); { if (type->Is(Type::Number())) { if_objectisnumber.Deopt("Expected heap number"); } } if_objectisnumber.JoinContinuation(&found); } } if_objectissmi.JoinContinuation(&found); // Check for cache hit. IfBuilder if_found(this, &found); if_found.Then(); { // Count number to string operation in native code. AddIncrementCounter(isolate()->counters()->number_to_string_native()); // Load the value in case of cache hit. HValue* key_index = Pop(); HValue* value_index = AddUncasted<HAdd>(key_index, graph()->GetConstant1()); Push(Add<HLoadKeyed>(number_string_cache, value_index, static_cast<HValue*>(NULL), FAST_ELEMENTS, ALLOW_RETURN_HOLE)); } if_found.Else(); { // Cache miss, fallback to runtime. Add<HPushArguments>(object); Push(Add<HCallRuntime>( isolate()->factory()->empty_string(), Runtime::FunctionForId(Runtime::kHiddenNumberToStringSkipCache), 1)); } if_found.End(); return Pop(); } HAllocate* HGraphBuilder::BuildAllocate( HValue* object_size, HType type, InstanceType instance_type, HAllocationMode allocation_mode) { // Compute the effective allocation size. HValue* size = object_size; if (allocation_mode.CreateAllocationMementos()) { size = AddUncasted<HAdd>(size, Add<HConstant>(AllocationMemento::kSize)); size->ClearFlag(HValue::kCanOverflow); } // Perform the actual allocation. HAllocate* object = Add<HAllocate>( size, type, allocation_mode.GetPretenureMode(), instance_type, allocation_mode.feedback_site()); // Setup the allocation memento. if (allocation_mode.CreateAllocationMementos()) { BuildCreateAllocationMemento( object, object_size, allocation_mode.current_site()); } return object; } HValue* HGraphBuilder::BuildAddStringLengths(HValue* left_length, HValue* right_length) { // Compute the combined string length and check against max string length. HValue* length = AddUncasted<HAdd>(left_length, right_length); // Check that length <= kMaxLength <=> length < MaxLength + 1. HValue* max_length = Add<HConstant>(String::kMaxLength + 1); Add<HBoundsCheck>(length, max_length); return length; } HValue* HGraphBuilder::BuildCreateConsString( HValue* length, HValue* left, HValue* right, HAllocationMode allocation_mode) { // Determine the string instance types. HInstruction* left_instance_type = AddLoadStringInstanceType(left); HInstruction* right_instance_type = AddLoadStringInstanceType(right); // Allocate the cons string object. HAllocate does not care whether we // pass CONS_STRING_TYPE or CONS_ASCII_STRING_TYPE here, so we just use // CONS_STRING_TYPE here. Below we decide whether the cons string is // one-byte or two-byte and set the appropriate map. ASSERT(HAllocate::CompatibleInstanceTypes(CONS_STRING_TYPE, CONS_ASCII_STRING_TYPE)); HAllocate* result = BuildAllocate(Add<HConstant>(ConsString::kSize), HType::String(), CONS_STRING_TYPE, allocation_mode); // Compute intersection and difference of instance types. HValue* anded_instance_types = AddUncasted<HBitwise>( Token::BIT_AND, left_instance_type, right_instance_type); HValue* xored_instance_types = AddUncasted<HBitwise>( Token::BIT_XOR, left_instance_type, right_instance_type); // We create a one-byte cons string if // 1. both strings are one-byte, or // 2. at least one of the strings is two-byte, but happens to contain only // one-byte characters. // To do this, we check // 1. if both strings are one-byte, or if the one-byte data hint is set in // both strings, or // 2. if one of the strings has the one-byte data hint set and the other // string is one-byte. IfBuilder if_onebyte(this); STATIC_ASSERT(kOneByteStringTag != 0); STATIC_ASSERT(kOneByteDataHintMask != 0); if_onebyte.If<HCompareNumericAndBranch>( AddUncasted<HBitwise>( Token::BIT_AND, anded_instance_types, Add<HConstant>(static_cast<int32_t>( kStringEncodingMask | kOneByteDataHintMask))), graph()->GetConstant0(), Token::NE); if_onebyte.Or(); STATIC_ASSERT(kOneByteStringTag != 0 && kOneByteDataHintTag != 0 && kOneByteDataHintTag != kOneByteStringTag); if_onebyte.If<HCompareNumericAndBranch>( AddUncasted<HBitwise>( Token::BIT_AND, xored_instance_types, Add<HConstant>(static_cast<int32_t>( kOneByteStringTag | kOneByteDataHintTag))), Add<HConstant>(static_cast<int32_t>( kOneByteStringTag | kOneByteDataHintTag)), Token::EQ); if_onebyte.Then(); { // We can safely skip the write barrier for storing the map here. Add<HStoreNamedField>( result, HObjectAccess::ForMap(), Add<HConstant>(isolate()->factory()->cons_ascii_string_map())); } if_onebyte.Else(); { // We can safely skip the write barrier for storing the map here. Add<HStoreNamedField>( result, HObjectAccess::ForMap(), Add<HConstant>(isolate()->factory()->cons_string_map())); } if_onebyte.End(); // Initialize the cons string fields. Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), Add<HConstant>(String::kEmptyHashField)); Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length); Add<HStoreNamedField>(result, HObjectAccess::ForConsStringFirst(), left); Add<HStoreNamedField>(result, HObjectAccess::ForConsStringSecond(), right); // Count the native string addition. AddIncrementCounter(isolate()->counters()->string_add_native()); return result; } void HGraphBuilder::BuildCopySeqStringChars(HValue* src, HValue* src_offset, String::Encoding src_encoding, HValue* dst, HValue* dst_offset, String::Encoding dst_encoding, HValue* length) { ASSERT(dst_encoding != String::ONE_BYTE_ENCODING || src_encoding == String::ONE_BYTE_ENCODING); LoopBuilder loop(this, context(), LoopBuilder::kPostIncrement); HValue* index = loop.BeginBody(graph()->GetConstant0(), length, Token::LT); { HValue* src_index = AddUncasted<HAdd>(src_offset, index); HValue* value = AddUncasted<HSeqStringGetChar>(src_encoding, src, src_index); HValue* dst_index = AddUncasted<HAdd>(dst_offset, index); Add<HSeqStringSetChar>(dst_encoding, dst, dst_index, value); } loop.EndBody(); } HValue* HGraphBuilder::BuildObjectSizeAlignment( HValue* unaligned_size, int header_size) { ASSERT((header_size & kObjectAlignmentMask) == 0); HValue* size = AddUncasted<HAdd>( unaligned_size, Add<HConstant>(static_cast<int32_t>( header_size + kObjectAlignmentMask))); size->ClearFlag(HValue::kCanOverflow); return AddUncasted<HBitwise>( Token::BIT_AND, size, Add<HConstant>(static_cast<int32_t>( ~kObjectAlignmentMask))); } HValue* HGraphBuilder::BuildUncheckedStringAdd( HValue* left, HValue* right, HAllocationMode allocation_mode) { // Determine the string lengths. HValue* left_length = AddLoadStringLength(left); HValue* right_length = AddLoadStringLength(right); // Compute the combined string length. HValue* length = BuildAddStringLengths(left_length, right_length); // Do some manual constant folding here. if (left_length->IsConstant()) { HConstant* c_left_length = HConstant::cast(left_length); ASSERT_NE(0, c_left_length->Integer32Value()); if (c_left_length->Integer32Value() + 1 >= ConsString::kMinLength) { // The right string contains at least one character. return BuildCreateConsString(length, left, right, allocation_mode); } } else if (right_length->IsConstant()) { HConstant* c_right_length = HConstant::cast(right_length); ASSERT_NE(0, c_right_length->Integer32Value()); if (c_right_length->Integer32Value() + 1 >= ConsString::kMinLength) { // The left string contains at least one character. return BuildCreateConsString(length, left, right, allocation_mode); } } // Check if we should create a cons string. IfBuilder if_createcons(this); if_createcons.If<HCompareNumericAndBranch>( length, Add<HConstant>(ConsString::kMinLength), Token::GTE); if_createcons.Then(); { // Create a cons string. Push(BuildCreateConsString(length, left, right, allocation_mode)); } if_createcons.Else(); { // Determine the string instance types. HValue* left_instance_type = AddLoadStringInstanceType(left); HValue* right_instance_type = AddLoadStringInstanceType(right); // Compute union and difference of instance types. HValue* ored_instance_types = AddUncasted<HBitwise>( Token::BIT_OR, left_instance_type, right_instance_type); HValue* xored_instance_types = AddUncasted<HBitwise>( Token::BIT_XOR, left_instance_type, right_instance_type); // Check if both strings have the same encoding and both are // sequential. IfBuilder if_sameencodingandsequential(this); if_sameencodingandsequential.If<HCompareNumericAndBranch>( AddUncasted<HBitwise>( Token::BIT_AND, xored_instance_types, Add<HConstant>(static_cast<int32_t>(kStringEncodingMask))), graph()->GetConstant0(), Token::EQ); if_sameencodingandsequential.And(); STATIC_ASSERT(kSeqStringTag == 0); if_sameencodingandsequential.If<HCompareNumericAndBranch>( AddUncasted<HBitwise>( Token::BIT_AND, ored_instance_types, Add<HConstant>(static_cast<int32_t>(kStringRepresentationMask))), graph()->GetConstant0(), Token::EQ); if_sameencodingandsequential.Then(); { HConstant* string_map = Add<HConstant>(isolate()->factory()->string_map()); HConstant* ascii_string_map = Add<HConstant>(isolate()->factory()->ascii_string_map()); // Determine map and size depending on whether result is one-byte string. IfBuilder if_onebyte(this); STATIC_ASSERT(kOneByteStringTag != 0); if_onebyte.If<HCompareNumericAndBranch>( AddUncasted<HBitwise>( Token::BIT_AND, ored_instance_types, Add<HConstant>(static_cast<int32_t>(kStringEncodingMask))), graph()->GetConstant0(), Token::NE); if_onebyte.Then(); { // Allocate sequential one-byte string object. Push(length); Push(ascii_string_map); } if_onebyte.Else(); { // Allocate sequential two-byte string object. HValue* size = AddUncasted<HShl>(length, graph()->GetConstant1()); size->ClearFlag(HValue::kCanOverflow); size->SetFlag(HValue::kUint32); Push(size); Push(string_map); } if_onebyte.End(); HValue* map = Pop(); // Calculate the number of bytes needed for the characters in the // string while observing object alignment. STATIC_ASSERT((SeqString::kHeaderSize & kObjectAlignmentMask) == 0); HValue* size = BuildObjectSizeAlignment(Pop(), SeqString::kHeaderSize); // Allocate the string object. HAllocate does not care whether we pass // STRING_TYPE or ASCII_STRING_TYPE here, so we just use STRING_TYPE here. HAllocate* result = BuildAllocate( size, HType::String(), STRING_TYPE, allocation_mode); Add<HStoreNamedField>(result, HObjectAccess::ForMap(), map); // Initialize the string fields. Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), Add<HConstant>(String::kEmptyHashField)); Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length); // Copy characters to the result string. IfBuilder if_twobyte(this); if_twobyte.If<HCompareObjectEqAndBranch>(map, string_map); if_twobyte.Then(); { // Copy characters from the left string. BuildCopySeqStringChars( left, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, result, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, left_length); // Copy characters from the right string. BuildCopySeqStringChars( right, graph()->GetConstant0(), String::TWO_BYTE_ENCODING, result, left_length, String::TWO_BYTE_ENCODING, right_length); } if_twobyte.Else(); { // Copy characters from the left string. BuildCopySeqStringChars( left, graph()->GetConstant0(), String::ONE_BYTE_ENCODING, result, graph()->GetConstant0(), String::ONE_BYTE_ENCODING, left_length); // Copy characters from the right string. BuildCopySeqStringChars( right, graph()->GetConstant0(), String::ONE_BYTE_ENCODING, result, left_length, String::ONE_BYTE_ENCODING, right_length); } if_twobyte.End(); // Count the native string addition. AddIncrementCounter(isolate()->counters()->string_add_native()); // Return the sequential string. Push(result); } if_sameencodingandsequential.Else(); { // Fallback to the runtime to add the two strings. Add<HPushArguments>(left, right); Push(Add<HCallRuntime>( isolate()->factory()->empty_string(), Runtime::FunctionForId(Runtime::kHiddenStringAdd), 2)); } if_sameencodingandsequential.End(); } if_createcons.End(); return Pop(); } HValue* HGraphBuilder::BuildStringAdd( HValue* left, HValue* right, HAllocationMode allocation_mode) { NoObservableSideEffectsScope no_effects(this); // Determine string lengths. HValue* left_length = AddLoadStringLength(left); HValue* right_length = AddLoadStringLength(right); // Check if left string is empty. IfBuilder if_leftempty(this); if_leftempty.If<HCompareNumericAndBranch>( left_length, graph()->GetConstant0(), Token::EQ); if_leftempty.Then(); { // Count the native string addition. AddIncrementCounter(isolate()->counters()->string_add_native()); // Just return the right string. Push(right); } if_leftempty.Else(); { // Check if right string is empty. IfBuilder if_rightempty(this); if_rightempty.If<HCompareNumericAndBranch>( right_length, graph()->GetConstant0(), Token::EQ); if_rightempty.Then(); { // Count the native string addition. AddIncrementCounter(isolate()->counters()->string_add_native()); // Just return the left string. Push(left); } if_rightempty.Else(); { // Add the two non-empty strings. Push(BuildUncheckedStringAdd(left, right, allocation_mode)); } if_rightempty.End(); } if_leftempty.End(); return Pop(); } HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess( HValue* checked_object, HValue* key, HValue* val, bool is_js_array, ElementsKind elements_kind, PropertyAccessType access_type, LoadKeyedHoleMode load_mode, KeyedAccessStoreMode store_mode) { ASSERT((!IsExternalArrayElementsKind(elements_kind) && !IsFixedTypedArrayElementsKind(elements_kind)) || !is_js_array); // No GVNFlag is necessary for ElementsKind if there is an explicit dependency // on a HElementsTransition instruction. The flag can also be removed if the // map to check has FAST_HOLEY_ELEMENTS, since there can be no further // ElementsKind transitions. Finally, the dependency can be removed for stores // for FAST_ELEMENTS, since a transition to HOLEY elements won't change the // generated store code. if ((elements_kind == FAST_HOLEY_ELEMENTS) || (elements_kind == FAST_ELEMENTS && access_type == STORE)) { checked_object->ClearDependsOnFlag(kElementsKind); } bool fast_smi_only_elements = IsFastSmiElementsKind(elements_kind); bool fast_elements = IsFastObjectElementsKind(elements_kind); HValue* elements = AddLoadElements(checked_object); if (access_type == STORE && (fast_elements || fast_smi_only_elements) && store_mode != STORE_NO_TRANSITION_HANDLE_COW) { HCheckMaps* check_cow_map = Add<HCheckMaps>( elements, isolate()->factory()->fixed_array_map()); check_cow_map->ClearDependsOnFlag(kElementsKind); } HInstruction* length = NULL; if (is_js_array) { length = Add<HLoadNamedField>( checked_object->ActualValue(), checked_object, HObjectAccess::ForArrayLength(elements_kind)); } else { length = AddLoadFixedArrayLength(elements); } length->set_type(HType::Smi()); HValue* checked_key = NULL; if (IsExternalArrayElementsKind(elements_kind) || IsFixedTypedArrayElementsKind(elements_kind)) { HValue* backing_store; if (IsExternalArrayElementsKind(elements_kind)) { backing_store = Add<HLoadNamedField>( elements, static_cast<HValue*>(NULL), HObjectAccess::ForExternalArrayExternalPointer()); } else { backing_store = elements; } if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { NoObservableSideEffectsScope no_effects(this); IfBuilder length_checker(this); length_checker.If<HCompareNumericAndBranch>(key, length, Token::LT); length_checker.Then(); IfBuilder negative_checker(this); HValue* bounds_check = negative_checker.If<HCompareNumericAndBranch>( key, graph()->GetConstant0(), Token::GTE); negative_checker.Then(); HInstruction* result = AddElementAccess( backing_store, key, val, bounds_check, elements_kind, access_type); negative_checker.ElseDeopt("Negative key encountered"); negative_checker.End(); length_checker.End(); return result; } else { ASSERT(store_mode == STANDARD_STORE); checked_key = Add<HBoundsCheck>(key, length); return AddElementAccess( backing_store, checked_key, val, checked_object, elements_kind, access_type); } } ASSERT(fast_smi_only_elements || fast_elements || IsFastDoubleElementsKind(elements_kind)); // In case val is stored into a fast smi array, assure that the value is a smi // before manipulating the backing store. Otherwise the actual store may // deopt, leaving the backing store in an invalid state. if (access_type == STORE && IsFastSmiElementsKind(elements_kind) && !val->type().IsSmi()) { val = AddUncasted<HForceRepresentation>(val, Representation::Smi()); } if (IsGrowStoreMode(store_mode)) { NoObservableSideEffectsScope no_effects(this); elements = BuildCheckForCapacityGrow(checked_object, elements, elements_kind, length, key, is_js_array, access_type); checked_key = key; } else { checked_key = Add<HBoundsCheck>(key, length); if (access_type == STORE && (fast_elements || fast_smi_only_elements)) { if (store_mode == STORE_NO_TRANSITION_HANDLE_COW) { NoObservableSideEffectsScope no_effects(this); elements = BuildCopyElementsOnWrite(checked_object, elements, elements_kind, length); } else { HCheckMaps* check_cow_map = Add<HCheckMaps>( elements, isolate()->factory()->fixed_array_map()); check_cow_map->ClearDependsOnFlag(kElementsKind); } } } return AddElementAccess(elements, checked_key, val, checked_object, elements_kind, access_type, load_mode); } HValue* HGraphBuilder::BuildAllocateArrayFromLength( JSArrayBuilder* array_builder, HValue* length_argument) { if (length_argument->IsConstant() && HConstant::cast(length_argument)->HasSmiValue()) { int array_length = HConstant::cast(length_argument)->Integer32Value(); if (array_length == 0) { return array_builder->AllocateEmptyArray(); } else { return array_builder->AllocateArray(length_argument, array_length, length_argument); } } HValue* constant_zero = graph()->GetConstant0(); HConstant* max_alloc_length = Add<HConstant>(JSObject::kInitialMaxFastElementArray); HInstruction* checked_length = Add<HBoundsCheck>(length_argument, max_alloc_length); IfBuilder if_builder(this); if_builder.If<HCompareNumericAndBranch>(checked_length, constant_zero, Token::EQ); if_builder.Then(); const int initial_capacity = JSArray::kPreallocatedArrayElements; HConstant* initial_capacity_node = Add<HConstant>(initial_capacity); Push(initial_capacity_node); // capacity Push(constant_zero); // length if_builder.Else(); if (!(top_info()->IsStub()) && IsFastPackedElementsKind(array_builder->kind())) { // We'll come back later with better (holey) feedback. if_builder.Deopt("Holey array despite packed elements_kind feedback"); } else { Push(checked_length); // capacity Push(checked_length); // length } if_builder.End(); // Figure out total size HValue* length = Pop(); HValue* capacity = Pop(); return array_builder->AllocateArray(capacity, max_alloc_length, length); } HValue* HGraphBuilder::BuildCalculateElementsSize(ElementsKind kind, HValue* capacity) { int elements_size = IsFastDoubleElementsKind(kind) ? kDoubleSize : kPointerSize; HConstant* elements_size_value = Add<HConstant>(elements_size); HInstruction* mul = HMul::NewImul(zone(), context(), capacity->ActualValue(), elements_size_value); AddInstruction(mul); mul->ClearFlag(HValue::kCanOverflow); STATIC_ASSERT(FixedDoubleArray::kHeaderSize == FixedArray::kHeaderSize); HConstant* header_size = Add<HConstant>(FixedArray::kHeaderSize); HValue* total_size = AddUncasted<HAdd>(mul, header_size); total_size->ClearFlag(HValue::kCanOverflow); return total_size; } HAllocate* HGraphBuilder::AllocateJSArrayObject(AllocationSiteMode mode) { int base_size = JSArray::kSize; if (mode == TRACK_ALLOCATION_SITE) { base_size += AllocationMemento::kSize; } HConstant* size_in_bytes = Add<HConstant>(base_size); return Add<HAllocate>( size_in_bytes, HType::JSArray(), NOT_TENURED, JS_OBJECT_TYPE); } HConstant* HGraphBuilder::EstablishElementsAllocationSize( ElementsKind kind, int capacity) { int base_size = IsFastDoubleElementsKind(kind) ? FixedDoubleArray::SizeFor(capacity) : FixedArray::SizeFor(capacity); return Add<HConstant>(base_size); } HAllocate* HGraphBuilder::BuildAllocateElements(ElementsKind kind, HValue* size_in_bytes) { InstanceType instance_type = IsFastDoubleElementsKind(kind) ? FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE; return Add<HAllocate>(size_in_bytes, HType::HeapObject(), NOT_TENURED, instance_type); } void HGraphBuilder::BuildInitializeElementsHeader(HValue* elements, ElementsKind kind, HValue* capacity) { Factory* factory = isolate()->factory(); Handle<Map> map = IsFastDoubleElementsKind(kind) ? factory->fixed_double_array_map() : factory->fixed_array_map(); Add<HStoreNamedField>(elements, HObjectAccess::ForMap(), Add<HConstant>(map)); Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), capacity); } HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader( ElementsKind kind, HValue* capacity) { // The HForceRepresentation is to prevent possible deopt on int-smi // conversion after allocation but before the new object fields are set. capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi()); HValue* size_in_bytes = BuildCalculateElementsSize(kind, capacity); HValue* new_elements = BuildAllocateElements(kind, size_in_bytes); BuildInitializeElementsHeader(new_elements, kind, capacity); return new_elements; } void HGraphBuilder::BuildJSArrayHeader(HValue* array, HValue* array_map, HValue* elements, AllocationSiteMode mode, ElementsKind elements_kind, HValue* allocation_site_payload, HValue* length_field) { Add<HStoreNamedField>(array, HObjectAccess::ForMap(), array_map); HConstant* empty_fixed_array = Add<HConstant>(isolate()->factory()->empty_fixed_array()); Add<HStoreNamedField>( array, HObjectAccess::ForPropertiesPointer(), empty_fixed_array); Add<HStoreNamedField>( array, HObjectAccess::ForElementsPointer(), elements != NULL ? elements : empty_fixed_array); Add<HStoreNamedField>( array, HObjectAccess::ForArrayLength(elements_kind), length_field); if (mode == TRACK_ALLOCATION_SITE) { BuildCreateAllocationMemento( array, Add<HConstant>(JSArray::kSize), allocation_site_payload); } } HInstruction* HGraphBuilder::AddElementAccess( HValue* elements, HValue* checked_key, HValue* val, HValue* dependency, ElementsKind elements_kind, PropertyAccessType access_type, LoadKeyedHoleMode load_mode) { if (access_type == STORE) { ASSERT(val != NULL); if (elements_kind == EXTERNAL_UINT8_CLAMPED_ELEMENTS || elements_kind == UINT8_CLAMPED_ELEMENTS) { val = Add<HClampToUint8>(val); } return Add<HStoreKeyed>(elements, checked_key, val, elements_kind, elements_kind == FAST_SMI_ELEMENTS ? STORE_TO_INITIALIZED_ENTRY : INITIALIZING_STORE); } ASSERT(access_type == LOAD); ASSERT(val == NULL); HLoadKeyed* load = Add<HLoadKeyed>( elements, checked_key, dependency, elements_kind, load_mode); if (FLAG_opt_safe_uint32_operations && (elements_kind == EXTERNAL_UINT32_ELEMENTS || elements_kind == UINT32_ELEMENTS)) { graph()->RecordUint32Instruction(load); } return load; } HLoadNamedField* HGraphBuilder::AddLoadMap(HValue* object, HValue* dependency) { return Add<HLoadNamedField>(object, dependency, HObjectAccess::ForMap()); } HLoadNamedField* HGraphBuilder::AddLoadElements(HValue* object, HValue* dependency) { return Add<HLoadNamedField>( object, dependency, HObjectAccess::ForElementsPointer()); } HLoadNamedField* HGraphBuilder::AddLoadFixedArrayLength( HValue* array, HValue* dependency) { return Add<HLoadNamedField>( array, dependency, HObjectAccess::ForFixedArrayLength()); } HLoadNamedField* HGraphBuilder::AddLoadArrayLength(HValue* array, ElementsKind kind, HValue* dependency) { return Add<HLoadNamedField>( array, dependency, HObjectAccess::ForArrayLength(kind)); } HValue* HGraphBuilder::BuildNewElementsCapacity(HValue* old_capacity) { HValue* half_old_capacity = AddUncasted<HShr>(old_capacity, graph_->GetConstant1()); HValue* new_capacity = AddUncasted<HAdd>(half_old_capacity, old_capacity); new_capacity->ClearFlag(HValue::kCanOverflow); HValue* min_growth = Add<HConstant>(16); new_capacity = AddUncasted<HAdd>(new_capacity, min_growth); new_capacity->ClearFlag(HValue::kCanOverflow); return new_capacity; } HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object, HValue* elements, ElementsKind kind, ElementsKind new_kind, HValue* length, HValue* new_capacity) { Add<HBoundsCheck>(new_capacity, Add<HConstant>( (Page::kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) >> ElementsKindToShiftSize(kind))); HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader( new_kind, new_capacity); BuildCopyElements(elements, kind, new_elements, new_kind, length, new_capacity); Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), new_elements); return new_elements; } void HGraphBuilder::BuildFillElementsWithValue(HValue* elements, ElementsKind elements_kind, HValue* from, HValue* to, HValue* value) { if (to == NULL) { to = AddLoadFixedArrayLength(elements); } // Special loop unfolding case STATIC_ASSERT(JSArray::kPreallocatedArrayElements <= kElementLoopUnrollThreshold); int initial_capacity = -1; if (from->IsInteger32Constant() && to->IsInteger32Constant()) { int constant_from = from->GetInteger32Constant(); int constant_to = to->GetInteger32Constant(); if (constant_from == 0 && constant_to <= kElementLoopUnrollThreshold) { initial_capacity = constant_to; } } // Since we're about to store a hole value, the store instruction below must // assume an elements kind that supports heap object values. if (IsFastSmiOrObjectElementsKind(elements_kind)) { elements_kind = FAST_HOLEY_ELEMENTS; } if (initial_capacity >= 0) { for (int i = 0; i < initial_capacity; i++) { HInstruction* key = Add<HConstant>(i); Add<HStoreKeyed>(elements, key, value, elements_kind); } } else { // Carefully loop backwards so that the "from" remains live through the loop // rather than the to. This often corresponds to keeping length live rather // then capacity, which helps register allocation, since length is used more // other than capacity after filling with holes. LoopBuilder builder(this, context(), LoopBuilder::kPostDecrement); HValue* key = builder.BeginBody(to, from, Token::GT); HValue* adjusted_key = AddUncasted<HSub>(key, graph()->GetConstant1()); adjusted_key->ClearFlag(HValue::kCanOverflow); Add<HStoreKeyed>(elements, adjusted_key, value, elements_kind); builder.EndBody(); } } void HGraphBuilder::BuildFillElementsWithHole(HValue* elements, ElementsKind elements_kind, HValue* from, HValue* to) { // Fast elements kinds need to be initialized in case statements below cause a // garbage collection. Factory* factory = isolate()->factory(); double nan_double = FixedDoubleArray::hole_nan_as_double(); HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind) ? Add<HConstant>(factory->the_hole_value()) : Add<HConstant>(nan_double); BuildFillElementsWithValue(elements, elements_kind, from, to, hole); } void HGraphBuilder::BuildCopyElements(HValue* from_elements, ElementsKind from_elements_kind, HValue* to_elements, ElementsKind to_elements_kind, HValue* length, HValue* capacity) { int constant_capacity = -1; if (capacity != NULL && capacity->IsConstant() && HConstant::cast(capacity)->HasInteger32Value()) { int constant_candidate = HConstant::cast(capacity)->Integer32Value(); if (constant_candidate <= kElementLoopUnrollThreshold) { constant_capacity = constant_candidate; } } bool pre_fill_with_holes = IsFastDoubleElementsKind(from_elements_kind) && IsFastObjectElementsKind(to_elements_kind); if (pre_fill_with_holes) { // If the copy might trigger a GC, make sure that the FixedArray is // pre-initialized with holes to make sure that it's always in a // consistent state. BuildFillElementsWithHole(to_elements, to_elements_kind, graph()->GetConstant0(), NULL); } if (constant_capacity != -1) { // Unroll the loop for small elements kinds. for (int i = 0; i < constant_capacity; i++) { HValue* key_constant = Add<HConstant>(i); HInstruction* value = Add<HLoadKeyed>(from_elements, key_constant, static_cast<HValue*>(NULL), from_elements_kind); Add<HStoreKeyed>(to_elements, key_constant, value, to_elements_kind); } } else { if (!pre_fill_with_holes && (capacity == NULL || !length->Equals(capacity))) { BuildFillElementsWithHole(to_elements, to_elements_kind, length, NULL); } if (capacity == NULL) { capacity = AddLoadFixedArrayLength(to_elements); } LoopBuilder builder(this, context(), LoopBuilder::kPostDecrement); HValue* key = builder.BeginBody(length, graph()->GetConstant0(), Token::GT); key = AddUncasted<HSub>(key, graph()->GetConstant1()); key->ClearFlag(HValue::kCanOverflow); HValue* element = Add<HLoadKeyed>(from_elements, key, static_cast<HValue*>(NULL), from_elements_kind, ALLOW_RETURN_HOLE); ElementsKind kind = (IsHoleyElementsKind(from_elements_kind) && IsFastSmiElementsKind(to_elements_kind)) ? FAST_HOLEY_ELEMENTS : to_elements_kind; if (IsHoleyElementsKind(from_elements_kind) && from_elements_kind != to_elements_kind) { IfBuilder if_hole(this); if_hole.If<HCompareHoleAndBranch>(element); if_hole.Then(); HConstant* hole_constant = IsFastDoubleElementsKind(to_elements_kind) ? Add<HConstant>(FixedDoubleArray::hole_nan_as_double()) : graph()->GetConstantHole(); Add<HStoreKeyed>(to_elements, key, hole_constant, kind); if_hole.Else(); HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind); store->SetFlag(HValue::kAllowUndefinedAsNaN); if_hole.End(); } else { HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind); store->SetFlag(HValue::kAllowUndefinedAsNaN); } builder.EndBody(); } Counters* counters = isolate()->counters(); AddIncrementCounter(counters->inlined_copied_elements()); } HValue* HGraphBuilder::BuildCloneShallowArrayCow(HValue* boilerplate, HValue* allocation_site, AllocationSiteMode mode, ElementsKind kind) { HAllocate* array = AllocateJSArrayObject(mode); HValue* map = AddLoadMap(boilerplate); HValue* elements = AddLoadElements(boilerplate); HValue* length = AddLoadArrayLength(boilerplate, kind); BuildJSArrayHeader(array, map, elements, mode, FAST_ELEMENTS, allocation_site, length); return array; } HValue* HGraphBuilder::BuildCloneShallowArrayEmpty(HValue* boilerplate, HValue* allocation_site, AllocationSiteMode mode) { HAllocate* array = AllocateJSArrayObject(mode); HValue* map = AddLoadMap(boilerplate); BuildJSArrayHeader(array, map, NULL, // set elements to empty fixed array mode, FAST_ELEMENTS, allocation_site, graph()->GetConstant0()); return array; } HValue* HGraphBuilder::BuildCloneShallowArrayNonEmpty(HValue* boilerplate, HValue* allocation_site, AllocationSiteMode mode, ElementsKind kind) { HValue* boilerplate_elements = AddLoadElements(boilerplate); HValue* capacity = AddLoadFixedArrayLength(boilerplate_elements); // Generate size calculation code here in order to make it dominate // the JSArray allocation. HValue* elements_size = BuildCalculateElementsSize(kind, capacity); // Create empty JSArray object for now, store elimination should remove // redundant initialization of elements and length fields and at the same // time the object will be fully prepared for GC if it happens during // elements allocation. HValue* result = BuildCloneShallowArrayEmpty( boilerplate, allocation_site, mode); HAllocate* elements = BuildAllocateElements(kind, elements_size); // This function implicitly relies on the fact that the // FastCloneShallowArrayStub is called only for literals shorter than // JSObject::kInitialMaxFastElementArray. // Can't add HBoundsCheck here because otherwise the stub will eager a frame. HConstant* size_upper_bound = EstablishElementsAllocationSize( kind, JSObject::kInitialMaxFastElementArray); elements->set_size_upper_bound(size_upper_bound); Add<HStoreNamedField>(result, HObjectAccess::ForElementsPointer(), elements); // The allocation for the cloned array above causes register pressure on // machines with low register counts. Force a reload of the boilerplate // elements here to free up a register for the allocation to avoid unnecessary // spillage. boilerplate_elements = AddLoadElements(boilerplate); boilerplate_elements->SetFlag(HValue::kCantBeReplaced); // Copy the elements array header. for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i); Add<HStoreNamedField>(elements, access, Add<HLoadNamedField>(boilerplate_elements, static_cast<HValue*>(NULL), access)); } // And the result of the length HValue* length = AddLoadArrayLength(boilerplate, kind); Add<HStoreNamedField>(result, HObjectAccess::ForArrayLength(kind), length); BuildCopyElements(boilerplate_elements, kind, elements, kind, length, NULL); return result; } void HGraphBuilder::BuildCompareNil( HValue* value, Type* type, HIfContinuation* continuation) { IfBuilder if_nil(this); bool some_case_handled = false; bool some_case_missing = false; if (type->Maybe(Type::Null())) { if (some_case_handled) if_nil.Or(); if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantNull()); some_case_handled = true; } else { some_case_missing = true; } if (type->Maybe(Type::Undefined())) { if (some_case_handled) if_nil.Or(); if_nil.If<HCompareObjectEqAndBranch>(value, graph()->GetConstantUndefined()); some_case_handled = true; } else { some_case_missing = true; } if (type->Maybe(Type::Undetectable())) { if (some_case_handled) if_nil.Or(); if_nil.If<HIsUndetectableAndBranch>(value); some_case_handled = true; } else { some_case_missing = true; } if (some_case_missing) { if_nil.Then(); if_nil.Else(); if (type->NumClasses() == 1) { BuildCheckHeapObject(value); // For ICs, the map checked below is a sentinel map that gets replaced by // the monomorphic map when the code is used as a template to generate a // new IC. For optimized functions, there is no sentinel map, the map // emitted below is the actual monomorphic map. Add<HCheckMaps>(value, type->Classes().Current()); } else { if_nil.Deopt("Too many undetectable types"); } } if_nil.CaptureContinuation(continuation); } void HGraphBuilder::BuildCreateAllocationMemento( HValue* previous_object, HValue* previous_object_size, HValue* allocation_site) { ASSERT(allocation_site != NULL); HInnerAllocatedObject* allocation_memento = Add<HInnerAllocatedObject>( previous_object, previous_object_size, HType::HeapObject()); AddStoreMapConstant( allocation_memento, isolate()->factory()->allocation_memento_map()); Add<HStoreNamedField>( allocation_memento, HObjectAccess::ForAllocationMementoSite(), allocation_site); if (FLAG_allocation_site_pretenuring) { HValue* memento_create_count = Add<HLoadNamedField>( allocation_site, static_cast<HValue*>(NULL), HObjectAccess::ForAllocationSiteOffset( AllocationSite::kPretenureCreateCountOffset)); memento_create_count = AddUncasted<HAdd>( memento_create_count, graph()->GetConstant1()); // This smi value is reset to zero after every gc, overflow isn't a problem // since the counter is bounded by the new space size. memento_create_count->ClearFlag(HValue::kCanOverflow); Add<HStoreNamedField>( allocation_site, HObjectAccess::ForAllocationSiteOffset( AllocationSite::kPretenureCreateCountOffset), memento_create_count); } } HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) { // Get the global context, then the native context HInstruction* context = Add<HLoadNamedField>(closure, static_cast<HValue*>(NULL), HObjectAccess::ForFunctionContextPointer()); HInstruction* global_object = Add<HLoadNamedField>( context, static_cast<HValue*>(NULL), HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset( GlobalObject::kNativeContextOffset); return Add<HLoadNamedField>( global_object, static_cast<HValue*>(NULL), access); } HInstruction* HGraphBuilder::BuildGetNativeContext() { // Get the global context, then the native context HValue* global_object = Add<HLoadNamedField>( context(), static_cast<HValue*>(NULL), HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); return Add<HLoadNamedField>( global_object, static_cast<HValue*>(NULL), HObjectAccess::ForObservableJSObjectOffset( GlobalObject::kNativeContextOffset)); } HInstruction* HGraphBuilder::BuildGetArrayFunction() { HInstruction* native_context = BuildGetNativeContext(); HInstruction* index = Add<HConstant>(static_cast<int32_t>(Context::ARRAY_FUNCTION_INDEX)); return Add<HLoadKeyed>( native_context, index, static_cast<HValue*>(NULL), FAST_ELEMENTS); } HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, ElementsKind kind, HValue* allocation_site_payload, HValue* constructor_function, AllocationSiteOverrideMode override_mode) : builder_(builder), kind_(kind), allocation_site_payload_(allocation_site_payload), constructor_function_(constructor_function) { ASSERT(!allocation_site_payload->IsConstant() || HConstant::cast(allocation_site_payload)->handle( builder_->isolate())->IsAllocationSite()); mode_ = override_mode == DISABLE_ALLOCATION_SITES ? DONT_TRACK_ALLOCATION_SITE : AllocationSite::GetMode(kind); } HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, ElementsKind kind, HValue* constructor_function) : builder_(builder), kind_(kind), mode_(DONT_TRACK_ALLOCATION_SITE), allocation_site_payload_(NULL), constructor_function_(constructor_function) { } HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode() { if (!builder()->top_info()->IsStub()) { // A constant map is fine. Handle<Map> map(builder()->isolate()->get_initial_js_array_map(kind_), builder()->isolate()); return builder()->Add<HConstant>(map); } if (constructor_function_ != NULL && kind_ == GetInitialFastElementsKind()) { // No need for a context lookup if the kind_ matches the initial // map, because we can just load the map in that case. HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); return builder()->Add<HLoadNamedField>( constructor_function_, static_cast<HValue*>(NULL), access); } // TODO(mvstanton): we should always have a constructor function if we // are creating a stub. HInstruction* native_context = constructor_function_ != NULL ? builder()->BuildGetNativeContext(constructor_function_) : builder()->BuildGetNativeContext(); HInstruction* index = builder()->Add<HConstant>( static_cast<int32_t>(Context::JS_ARRAY_MAPS_INDEX)); HInstruction* map_array = builder()->Add<HLoadKeyed>( native_context, index, static_cast<HValue*>(NULL), FAST_ELEMENTS); HInstruction* kind_index = builder()->Add<HConstant>(kind_); return builder()->Add<HLoadKeyed>( map_array, kind_index, static_cast<HValue*>(NULL), FAST_ELEMENTS); } HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() { // Find the map near the constructor function HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); return builder()->Add<HLoadNamedField>( constructor_function_, static_cast<HValue*>(NULL), access); } HAllocate* HGraphBuilder::JSArrayBuilder::AllocateEmptyArray() { HConstant* capacity = builder()->Add<HConstant>(initial_capacity()); return AllocateArray(capacity, capacity, builder()->graph()->GetConstant0()); } HAllocate* HGraphBuilder::JSArrayBuilder::AllocateArray( HValue* capacity, HConstant* capacity_upper_bound, HValue* length_field, FillMode fill_mode) { return AllocateArray(capacity, capacity_upper_bound->GetInteger32Constant(), length_field, fill_mode); } HAllocate* HGraphBuilder::JSArrayBuilder::AllocateArray( HValue* capacity, int capacity_upper_bound, HValue* length_field, FillMode fill_mode) { HConstant* elememts_size_upper_bound = capacity->IsInteger32Constant() ? HConstant::cast(capacity) : builder()->EstablishElementsAllocationSize(kind_, capacity_upper_bound); HAllocate* array = AllocateArray(capacity, length_field, fill_mode); if (!elements_location_->has_size_upper_bound()) { elements_location_->set_size_upper_bound(elememts_size_upper_bound); } return array; } HAllocate* HGraphBuilder::JSArrayBuilder::AllocateArray( HValue* capacity, HValue* length_field, FillMode fill_mode) { // These HForceRepresentations are because we store these as fields in the // objects we construct, and an int32-to-smi HChange could deopt. Accept // the deopt possibility now, before allocation occurs. capacity = builder()->AddUncasted<HForceRepresentation>(capacity, Representation::Smi()); length_field = builder()->AddUncasted<HForceRepresentation>(length_field, Representation::Smi()); // Generate size calculation code here in order to make it dominate // the JSArray allocation. HValue* elements_size = builder()->BuildCalculateElementsSize(kind_, capacity); // Allocate (dealing with failure appropriately) HAllocate* array_object = builder()->AllocateJSArrayObject(mode_); // Fill in the fields: map, properties, length HValue* map; if (allocation_site_payload_ == NULL) { map = EmitInternalMapCode(); } else { map = EmitMapCode(); } builder()->BuildJSArrayHeader(array_object, map, NULL, // set elements to empty fixed array mode_, kind_, allocation_site_payload_, length_field); // Allocate and initialize the elements elements_location_ = builder()->BuildAllocateElements(kind_, elements_size); builder()->BuildInitializeElementsHeader(elements_location_, kind_, capacity); // Set the elements builder()->Add<HStoreNamedField>( array_object, HObjectAccess::ForElementsPointer(), elements_location_); if (fill_mode == FILL_WITH_HOLE) { builder()->BuildFillElementsWithHole(elements_location_, kind_, graph()->GetConstant0(), capacity); } return array_object; } HValue* HGraphBuilder::AddLoadJSBuiltin(Builtins::JavaScript builtin) { HValue* global_object = Add<HLoadNamedField>( context(), static_cast<HValue*>(NULL), HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset( GlobalObject::kBuiltinsOffset); HValue* builtins = Add<HLoadNamedField>( global_object, static_cast<HValue*>(NULL), access); HObjectAccess function_access = HObjectAccess::ForObservableJSObjectOffset( JSBuiltinsObject::OffsetOfFunctionWithId(builtin)); return Add<HLoadNamedField>( builtins, static_cast<HValue*>(NULL), function_access); } HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) : HGraphBuilder(info), function_state_(NULL), initial_function_state_(this, info, NORMAL_RETURN, 0), ast_context_(NULL), break_scope_(NULL), inlined_count_(0), globals_(10, info->zone()), inline_bailout_(false), osr_(new(info->zone()) HOsrBuilder(this)) { // This is not initialized in the initializer list because the // constructor for the initial state relies on function_state_ == NULL // to know it's the initial state. function_state_= &initial_function_state_; InitializeAstVisitor(info->zone()); if (FLAG_hydrogen_track_positions) { SetSourcePosition(info->shared_info()->start_position()); } } HBasicBlock* HOptimizedGraphBuilder::CreateJoin(HBasicBlock* first, HBasicBlock* second, BailoutId join_id) { if (first == NULL) { return second; } else if (second == NULL) { return first; } else { HBasicBlock* join_block = graph()->CreateBasicBlock(); Goto(first, join_block); Goto(second, join_block); join_block->SetJoinId(join_id); return join_block; } } HBasicBlock* HOptimizedGraphBuilder::JoinContinue(IterationStatement* statement, HBasicBlock* exit_block, HBasicBlock* continue_block) { if (continue_block != NULL) { if (exit_block != NULL) Goto(exit_block, continue_block); continue_block->SetJoinId(statement->ContinueId()); return continue_block; } return exit_block; } HBasicBlock* HOptimizedGraphBuilder::CreateLoop(IterationStatement* statement, HBasicBlock* loop_entry, HBasicBlock* body_exit, HBasicBlock* loop_successor, HBasicBlock* break_block) { if (body_exit != NULL) Goto(body_exit, loop_entry); loop_entry->PostProcessLoopHeader(statement); if (break_block != NULL) { if (loop_successor != NULL) Goto(loop_successor, break_block); break_block->SetJoinId(statement->ExitId()); return break_block; } return loop_successor; } // Build a new loop header block and set it as the current block. HBasicBlock* HOptimizedGraphBuilder::BuildLoopEntry() { HBasicBlock* loop_entry = CreateLoopHeaderBlock(); Goto(loop_entry); set_current_block(loop_entry); return loop_entry; } HBasicBlock* HOptimizedGraphBuilder::BuildLoopEntry( IterationStatement* statement) { HBasicBlock* loop_entry = osr()->HasOsrEntryAt(statement) ? osr()->BuildOsrLoopEntry(statement) : BuildLoopEntry(); return loop_entry; } void HBasicBlock::FinishExit(HControlInstruction* instruction, HSourcePosition position) { Finish(instruction, position); ClearEnvironment(); } HGraph::HGraph(CompilationInfo* info) : isolate_(info->isolate()), next_block_id_(0), entry_block_(NULL), blocks_(8, info->zone()), values_(16, info->zone()), phi_list_(NULL), uint32_instructions_(NULL), osr_(NULL), info_(info), zone_(info->zone()), is_recursive_(false), use_optimistic_licm_(false), depends_on_empty_array_proto_elements_(false), type_change_checksum_(0), maximum_environment_size_(0), no_side_effects_scope_count_(0), disallow_adding_new_values_(false), next_inline_id_(0), inlined_functions_(5, info->zone()) { if (info->IsStub()) { HydrogenCodeStub* stub = info->code_stub(); CodeStubInterfaceDescriptor* descriptor = stub->GetInterfaceDescriptor(); start_environment_ = new(zone_) HEnvironment(zone_, descriptor->environment_length()); } else { TraceInlinedFunction(info->shared_info(), HSourcePosition::Unknown()); start_environment_ = new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_); } start_environment_->set_ast_id(BailoutId::FunctionEntry()); entry_block_ = CreateBasicBlock(); entry_block_->SetInitialEnvironment(start_environment_); } HBasicBlock* HGraph::CreateBasicBlock() { HBasicBlock* result = new(zone()) HBasicBlock(this); blocks_.Add(result, zone()); return result; } void HGraph::FinalizeUniqueness() { DisallowHeapAllocation no_gc; ASSERT(!OptimizingCompilerThread::IsOptimizerThread(isolate())); for (int i = 0; i < blocks()->length(); ++i) { for (HInstructionIterator it(blocks()->at(i)); !it.Done(); it.Advance()) { it.Current()->FinalizeUniqueness(); } } } int HGraph::TraceInlinedFunction( Handle<SharedFunctionInfo> shared, HSourcePosition position) { if (!FLAG_hydrogen_track_positions) { return 0; } int id = 0; for (; id < inlined_functions_.length(); id++) { if (inlined_functions_[id].shared().is_identical_to(shared)) { break; } } if (id == inlined_functions_.length()) { inlined_functions_.Add(InlinedFunctionInfo(shared), zone()); if (!shared->script()->IsUndefined()) { Handle<Script> script(Script::cast(shared->script())); if (!script->source()->IsUndefined()) { CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); PrintF(tracing_scope.file(), "--- FUNCTION SOURCE (%s) id{%d,%d} ---\n", shared->DebugName()->ToCString().get(), info()->optimization_id(), id); { ConsStringIteratorOp op; StringCharacterStream stream(String::cast(script->source()), &op, shared->start_position()); // fun->end_position() points to the last character in the stream. We // need to compensate by adding one to calculate the length. int source_len = shared->end_position() - shared->start_position() + 1; for (int i = 0; i < source_len; i++) { if (stream.HasMore()) { PrintF(tracing_scope.file(), "%c", stream.GetNext()); } } } PrintF(tracing_scope.file(), "\n--- END ---\n"); } } } int inline_id = next_inline_id_++; if (inline_id != 0) { CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); PrintF(tracing_scope.file(), "INLINE (%s) id{%d,%d} AS %d AT ", shared->DebugName()->ToCString().get(), info()->optimization_id(), id, inline_id); position.PrintTo(tracing_scope.file()); PrintF(tracing_scope.file(), "\n"); } return inline_id; } int HGraph::SourcePositionToScriptPosition(HSourcePosition pos) { if (!FLAG_hydrogen_track_positions || pos.IsUnknown()) { return pos.raw(); } return inlined_functions_[pos.inlining_id()].start_position() + pos.position(); } // Block ordering was implemented with two mutually recursive methods, // HGraph::Postorder and HGraph::PostorderLoopBlocks. // The recursion could lead to stack overflow so the algorithm has been // implemented iteratively. // At a high level the algorithm looks like this: // // Postorder(block, loop_header) : { // if (block has already been visited or is of another loop) return; // mark block as visited; // if (block is a loop header) { // VisitLoopMembers(block, loop_header); // VisitSuccessorsOfLoopHeader(block); // } else { // VisitSuccessors(block) // } // put block in result list; // } // // VisitLoopMembers(block, outer_loop_header) { // foreach (block b in block loop members) { // VisitSuccessorsOfLoopMember(b, outer_loop_header); // if (b is loop header) VisitLoopMembers(b); // } // } // // VisitSuccessorsOfLoopMember(block, outer_loop_header) { // foreach (block b in block successors) Postorder(b, outer_loop_header) // } // // VisitSuccessorsOfLoopHeader(block) { // foreach (block b in block successors) Postorder(b, block) // } // // VisitSuccessors(block, loop_header) { // foreach (block b in block successors) Postorder(b, loop_header) // } // // The ordering is started calling Postorder(entry, NULL). // // Each instance of PostorderProcessor represents the "stack frame" of the // recursion, and particularly keeps the state of the loop (iteration) of the // "Visit..." function it represents. // To recycle memory we keep all the frames in a double linked list but // this means that we cannot use constructors to initialize the frames. // class PostorderProcessor : public ZoneObject { public: // Back link (towards the stack bottom). PostorderProcessor* parent() {return father_; } // Forward link (towards the stack top). PostorderProcessor* child() {return child_; } HBasicBlock* block() { return block_; } HLoopInformation* loop() { return loop_; } HBasicBlock* loop_header() { return loop_header_; } static PostorderProcessor* CreateEntryProcessor(Zone* zone, HBasicBlock* block) { PostorderProcessor* result = new(zone) PostorderProcessor(NULL); return result->SetupSuccessors(zone, block, NULL); } PostorderProcessor* PerformStep(Zone* zone, ZoneList<HBasicBlock*>* order) { PostorderProcessor* next = PerformNonBacktrackingStep(zone, order); if (next != NULL) { return next; } else { return Backtrack(zone, order); } } private: explicit PostorderProcessor(PostorderProcessor* father) : father_(father), child_(NULL), successor_iterator(NULL) { } // Each enum value states the cycle whose state is kept by this instance. enum LoopKind { NONE, SUCCESSORS, SUCCESSORS_OF_LOOP_HEADER, LOOP_MEMBERS, SUCCESSORS_OF_LOOP_MEMBER }; // Each "Setup..." method is like a constructor for a cycle state. PostorderProcessor* SetupSuccessors(Zone* zone, HBasicBlock* block, HBasicBlock* loop_header) { if (block == NULL || block->IsOrdered() || block->parent_loop_header() != loop_header) { kind_ = NONE; block_ = NULL; loop_ = NULL; loop_header_ = NULL; return this; } else { block_ = block; loop_ = NULL; block->MarkAsOrdered(); if (block->IsLoopHeader()) { kind_ = SUCCESSORS_OF_LOOP_HEADER; loop_header_ = block; InitializeSuccessors(); PostorderProcessor* result = Push(zone); return result->SetupLoopMembers(zone, block, block->loop_information(), loop_header); } else { ASSERT(block->IsFinished()); kind_ = SUCCESSORS; loop_header_ = loop_header; InitializeSuccessors(); return this; } } } PostorderProcessor* SetupLoopMembers(Zone* zone, HBasicBlock* block, HLoopInformation* loop, HBasicBlock* loop_header) { kind_ = LOOP_MEMBERS; block_ = block; loop_ = loop; loop_header_ = loop_header; InitializeLoopMembers(); return this; } PostorderProcessor* SetupSuccessorsOfLoopMember( HBasicBlock* block, HLoopInformation* loop, HBasicBlock* loop_header) { kind_ = SUCCESSORS_OF_LOOP_MEMBER; block_ = block; loop_ = loop; loop_header_ = loop_header; InitializeSuccessors(); return this; } // This method "allocates" a new stack frame. PostorderProcessor* Push(Zone* zone) { if (child_ == NULL) { child_ = new(zone) PostorderProcessor(this); } return child_; } void ClosePostorder(ZoneList<HBasicBlock*>* order, Zone* zone) { ASSERT(block_->end()->FirstSuccessor() == NULL || order->Contains(block_->end()->FirstSuccessor()) || block_->end()->FirstSuccessor()->IsLoopHeader()); ASSERT(block_->end()->SecondSuccessor() == NULL || order->Contains(block_->end()->SecondSuccessor()) || block_->end()->SecondSuccessor()->IsLoopHeader()); order->Add(block_, zone); } // This method is the basic block to walk up the stack. PostorderProcessor* Pop(Zone* zone, ZoneList<HBasicBlock*>* order) { switch (kind_) { case SUCCESSORS: case SUCCESSORS_OF_LOOP_HEADER: ClosePostorder(order, zone); return father_; case LOOP_MEMBERS: return father_; case SUCCESSORS_OF_LOOP_MEMBER: if (block()->IsLoopHeader() && block() != loop_->loop_header()) { // In this case we need to perform a LOOP_MEMBERS cycle so we // initialize it and return this instead of father. return SetupLoopMembers(zone, block(), block()->loop_information(), loop_header_); } else { return father_; } case NONE: return father_; } UNREACHABLE(); return NULL; } // Walks up the stack. PostorderProcessor* Backtrack(Zone* zone, ZoneList<HBasicBlock*>* order) { PostorderProcessor* parent = Pop(zone, order); while (parent != NULL) { PostorderProcessor* next = parent->PerformNonBacktrackingStep(zone, order); if (next != NULL) { return next; } else { parent = parent->Pop(zone, order); } } return NULL; } PostorderProcessor* PerformNonBacktrackingStep( Zone* zone, ZoneList<HBasicBlock*>* order) { HBasicBlock* next_block; switch (kind_) { case SUCCESSORS: next_block = AdvanceSuccessors(); if (next_block != NULL) { PostorderProcessor* result = Push(zone); return result->SetupSuccessors(zone, next_block, loop_header_); } break; case SUCCESSORS_OF_LOOP_HEADER: next_block = AdvanceSuccessors(); if (next_block != NULL) { PostorderProcessor* result = Push(zone); return result->SetupSuccessors(zone, next_block, block()); } break; case LOOP_MEMBERS: next_block = AdvanceLoopMembers(); if (next_block != NULL) { PostorderProcessor* result = Push(zone); return result->SetupSuccessorsOfLoopMember(next_block, loop_, loop_header_); } break; case SUCCESSORS_OF_LOOP_MEMBER: next_block = AdvanceSuccessors(); if (next_block != NULL) { PostorderProcessor* result = Push(zone); return result->SetupSuccessors(zone, next_block, loop_header_); } break; case NONE: return NULL; } return NULL; } // The following two methods implement a "foreach b in successors" cycle. void InitializeSuccessors() { loop_index = 0; loop_length = 0; successor_iterator = HSuccessorIterator(block_->end()); } HBasicBlock* AdvanceSuccessors() { if (!successor_iterator.Done()) { HBasicBlock* result = successor_iterator.Current(); successor_iterator.Advance(); return result; } return NULL; } // The following two methods implement a "foreach b in loop members" cycle. void InitializeLoopMembers() { loop_index = 0; loop_length = loop_->blocks()->length(); } HBasicBlock* AdvanceLoopMembers() { if (loop_index < loop_length) { HBasicBlock* result = loop_->blocks()->at(loop_index); loop_index++; return result; } else { return NULL; } } LoopKind kind_; PostorderProcessor* father_; PostorderProcessor* child_; HLoopInformation* loop_; HBasicBlock* block_; HBasicBlock* loop_header_; int loop_index; int loop_length; HSuccessorIterator successor_iterator; }; void HGraph::OrderBlocks() { CompilationPhase phase("H_Block ordering", info()); #ifdef DEBUG // Initially the blocks must not be ordered. for (int i = 0; i < blocks_.length(); ++i) { ASSERT(!blocks_[i]->IsOrdered()); } #endif PostorderProcessor* postorder = PostorderProcessor::CreateEntryProcessor(zone(), blocks_[0]); blocks_.Rewind(0); while (postorder) { postorder = postorder->PerformStep(zone(), &blocks_); } #ifdef DEBUG // Now all blocks must be marked as ordered. for (int i = 0; i < blocks_.length(); ++i) { ASSERT(blocks_[i]->IsOrdered()); } #endif // Reverse block list and assign block IDs. for (int i = 0, j = blocks_.length(); --j >= i; ++i) { HBasicBlock* bi = blocks_[i]; HBasicBlock* bj = blocks_[j]; bi->set_block_id(j); bj->set_block_id(i); blocks_[i] = bj; blocks_[j] = bi; } } void HGraph::AssignDominators() { HPhase phase("H_Assign dominators", this); for (int i = 0; i < blocks_.length(); ++i) { HBasicBlock* block = blocks_[i]; if (block->IsLoopHeader()) { // Only the first predecessor of a loop header is from outside the loop. // All others are back edges, and thus cannot dominate the loop header. block->AssignCommonDominator(block->predecessors()->first()); block->AssignLoopSuccessorDominators(); } else { for (int j = blocks_[i]->predecessors()->length() - 1; j >= 0; --j) { blocks_[i]->AssignCommonDominator(blocks_[i]->predecessors()->at(j)); } } } } bool HGraph::CheckArgumentsPhiUses() { int block_count = blocks_.length(); for (int i = 0; i < block_count; ++i) { for (int j = 0; j < blocks_[i]->phis()->length(); ++j) { HPhi* phi = blocks_[i]->phis()->at(j); // We don't support phi uses of arguments for now. if (phi->CheckFlag(HValue::kIsArguments)) return false; } } return true; } bool HGraph::CheckConstPhiUses() { int block_count = blocks_.length(); for (int i = 0; i < block_count; ++i) { for (int j = 0; j < blocks_[i]->phis()->length(); ++j) { HPhi* phi = blocks_[i]->phis()->at(j); // Check for the hole value (from an uninitialized const). for (int k = 0; k < phi->OperandCount(); k++) { if (phi->OperandAt(k) == GetConstantHole()) return false; } } } return true; } void HGraph::CollectPhis() { int block_count = blocks_.length(); phi_list_ = new(zone()) ZoneList<HPhi*>(block_count, zone()); for (int i = 0; i < block_count; ++i) { for (int j = 0; j < blocks_[i]->phis()->length(); ++j) { HPhi* phi = blocks_[i]->phis()->at(j); phi_list_->Add(phi, zone()); } } } // Implementation of utility class to encapsulate the translation state for // a (possibly inlined) function. FunctionState::FunctionState(HOptimizedGraphBuilder* owner, CompilationInfo* info, InliningKind inlining_kind, int inlining_id) : owner_(owner), compilation_info_(info), call_context_(NULL), inlining_kind_(inlining_kind), function_return_(NULL), test_context_(NULL), entry_(NULL), arguments_object_(NULL), arguments_elements_(NULL), inlining_id_(inlining_id), outer_source_position_(HSourcePosition::Unknown()), outer_(owner->function_state()) { if (outer_ != NULL) { // State for an inline function. if (owner->ast_context()->IsTest()) { HBasicBlock* if_true = owner->graph()->CreateBasicBlock(); HBasicBlock* if_false = owner->graph()->CreateBasicBlock(); if_true->MarkAsInlineReturnTarget(owner->current_block()); if_false->MarkAsInlineReturnTarget(owner->current_block()); TestContext* outer_test_context = TestContext::cast(owner->ast_context()); Expression* cond = outer_test_context->condition(); // The AstContext constructor pushed on the context stack. This newed // instance is the reason that AstContext can't be BASE_EMBEDDED. test_context_ = new TestContext(owner, cond, if_true, if_false); } else { function_return_ = owner->graph()->CreateBasicBlock(); function_return()->MarkAsInlineReturnTarget(owner->current_block()); } // Set this after possibly allocating a new TestContext above. call_context_ = owner->ast_context(); } // Push on the state stack. owner->set_function_state(this); if (FLAG_hydrogen_track_positions) { outer_source_position_ = owner->source_position(); owner->EnterInlinedSource( info->shared_info()->start_position(), inlining_id); owner->SetSourcePosition(info->shared_info()->start_position()); } } FunctionState::~FunctionState() { delete test_context_; owner_->set_function_state(outer_); if (FLAG_hydrogen_track_positions) { owner_->set_source_position(outer_source_position_); owner_->EnterInlinedSource( outer_->compilation_info()->shared_info()->start_position(), outer_->inlining_id()); } } // Implementation of utility classes to represent an expression's context in // the AST. AstContext::AstContext(HOptimizedGraphBuilder* owner, Expression::Context kind) : owner_(owner), kind_(kind), outer_(owner->ast_context()), for_typeof_(false) { owner->set_ast_context(this); // Push. #ifdef DEBUG ASSERT(owner->environment()->frame_type() == JS_FUNCTION); original_length_ = owner->environment()->length(); #endif } AstContext::~AstContext() { owner_->set_ast_context(outer_); // Pop. } EffectContext::~EffectContext() { ASSERT(owner()->HasStackOverflow() || owner()->current_block() == NULL || (owner()->environment()->length() == original_length_ && owner()->environment()->frame_type() == JS_FUNCTION)); } ValueContext::~ValueContext() { ASSERT(owner()->HasStackOverflow() || owner()->current_block() == NULL || (owner()->environment()->length() == original_length_ + 1 && owner()->environment()->frame_type() == JS_FUNCTION)); } void EffectContext::ReturnValue(HValue* value) { // The value is simply ignored. } void ValueContext::ReturnValue(HValue* value) { // The value is tracked in the bailout environment, and communicated // through the environment as the result of the expression. if (!arguments_allowed() && value->CheckFlag(HValue::kIsArguments)) { owner()->Bailout(kBadValueContextForArgumentsValue); } owner()->Push(value); } void TestContext::ReturnValue(HValue* value) { BuildBranch(value); } void EffectContext::ReturnInstruction(HInstruction* instr, BailoutId ast_id) { ASSERT(!instr->IsControlInstruction()); owner()->AddInstruction(instr); if (instr->HasObservableSideEffects()) { owner()->Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); } } void EffectContext::ReturnControl(HControlInstruction* instr, BailoutId ast_id) { ASSERT(!instr->HasObservableSideEffects()); HBasicBlock* empty_true = owner()->graph()->CreateBasicBlock(); HBasicBlock* empty_false = owner()->graph()->CreateBasicBlock(); instr->SetSuccessorAt(0, empty_true); instr->SetSuccessorAt(1, empty_false); owner()->FinishCurrentBlock(instr); HBasicBlock* join = owner()->CreateJoin(empty_true, empty_false, ast_id); owner()->set_current_block(join); } void EffectContext::ReturnContinuation(HIfContinuation* continuation, BailoutId ast_id) { HBasicBlock* true_branch = NULL; HBasicBlock* false_branch = NULL; continuation->Continue(&true_branch, &false_branch); if (!continuation->IsTrueReachable()) { owner()->set_current_block(false_branch); } else if (!continuation->IsFalseReachable()) { owner()->set_current_block(true_branch); } else { HBasicBlock* join = owner()->CreateJoin(true_branch, false_branch, ast_id); owner()->set_current_block(join); } } void ValueContext::ReturnInstruction(HInstruction* instr, BailoutId ast_id) { ASSERT(!instr->IsControlInstruction()); if (!arguments_allowed() && instr->CheckFlag(HValue::kIsArguments)) { return owner()->Bailout(kBadValueContextForArgumentsObjectValue); } owner()->AddInstruction(instr); owner()->Push(instr); if (instr->HasObservableSideEffects()) { owner()->Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); } } void ValueContext::ReturnControl(HControlInstruction* instr, BailoutId ast_id) { ASSERT(!instr->HasObservableSideEffects()); if (!arguments_allowed() && instr->CheckFlag(HValue::kIsArguments)) { return owner()->Bailout(kBadValueContextForArgumentsObjectValue); } HBasicBlock* materialize_false = owner()->graph()->CreateBasicBlock(); HBasicBlock* materialize_true = owner()->graph()->CreateBasicBlock(); instr->SetSuccessorAt(0, materialize_true); instr->SetSuccessorAt(1, materialize_false); owner()->FinishCurrentBlock(instr); owner()->set_current_block(materialize_true); owner()->Push(owner()->graph()->GetConstantTrue()); owner()->set_current_block(materialize_false); owner()->Push(owner()->graph()->GetConstantFalse()); HBasicBlock* join = owner()->CreateJoin(materialize_true, materialize_false, ast_id); owner()->set_current_block(join); } void ValueContext::ReturnContinuation(HIfContinuation* continuation, BailoutId ast_id) { HBasicBlock* materialize_true = NULL; HBasicBlock* materialize_false = NULL; continuation->Continue(&materialize_true, &materialize_false); if (continuation->IsTrueReachable()) { owner()->set_current_block(materialize_true); owner()->Push(owner()->graph()->GetConstantTrue()); owner()->set_current_block(materialize_true); } if (continuation->IsFalseReachable()) { owner()->set_current_block(materialize_false); owner()->Push(owner()->graph()->GetConstantFalse()); owner()->set_current_block(materialize_false); } if (continuation->TrueAndFalseReachable()) { HBasicBlock* join = owner()->CreateJoin(materialize_true, materialize_false, ast_id); owner()->set_current_block(join); } } void TestContext::ReturnInstruction(HInstruction* instr, BailoutId ast_id) { ASSERT(!instr->IsControlInstruction()); HOptimizedGraphBuilder* builder = owner(); builder->AddInstruction(instr); // We expect a simulate after every expression with side effects, though // this one isn't actually needed (and wouldn't work if it were targeted). if (instr->HasObservableSideEffects()) { builder->Push(instr); builder->Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); builder->Pop(); } BuildBranch(instr); } void TestContext::ReturnControl(HControlInstruction* instr, BailoutId ast_id) { ASSERT(!instr->HasObservableSideEffects()); HBasicBlock* empty_true = owner()->graph()->CreateBasicBlock(); HBasicBlock* empty_false = owner()->graph()->CreateBasicBlock(); instr->SetSuccessorAt(0, empty_true); instr->SetSuccessorAt(1, empty_false); owner()->FinishCurrentBlock(instr); owner()->Goto(empty_true, if_true(), owner()->function_state()); owner()->Goto(empty_false, if_false(), owner()->function_state()); owner()->set_current_block(NULL); } void TestContext::ReturnContinuation(HIfContinuation* continuation, BailoutId ast_id) { HBasicBlock* true_branch = NULL; HBasicBlock* false_branch = NULL; continuation->Continue(&true_branch, &false_branch); if (continuation->IsTrueReachable()) { owner()->Goto(true_branch, if_true(), owner()->function_state()); } if (continuation->IsFalseReachable()) { owner()->Goto(false_branch, if_false(), owner()->function_state()); } owner()->set_current_block(NULL); } void TestContext::BuildBranch(HValue* value) { // We expect the graph to be in edge-split form: there is no edge that // connects a branch node to a join node. We conservatively ensure that // property by always adding an empty block on the outgoing edges of this // branch. HOptimizedGraphBuilder* builder = owner(); if (value != NULL && value->CheckFlag(HValue::kIsArguments)) { builder->Bailout(kArgumentsObjectValueInATestContext); } ToBooleanStub::Types expected(condition()->to_boolean_types()); ReturnControl(owner()->New<HBranch>(value, expected), BailoutId::None()); } // HOptimizedGraphBuilder infrastructure for bailing out and checking bailouts. #define CHECK_BAILOUT(call) \ do { \ call; \ if (HasStackOverflow()) return; \ } while (false) #define CHECK_ALIVE(call) \ do { \ call; \ if (HasStackOverflow() || current_block() == NULL) return; \ } while (false) #define CHECK_ALIVE_OR_RETURN(call, value) \ do { \ call; \ if (HasStackOverflow() || current_block() == NULL) return value; \ } while (false) void HOptimizedGraphBuilder::Bailout(BailoutReason reason) { current_info()->set_bailout_reason(reason); SetStackOverflow(); } void HOptimizedGraphBuilder::VisitForEffect(Expression* expr) { EffectContext for_effect(this); Visit(expr); } void HOptimizedGraphBuilder::VisitForValue(Expression* expr, ArgumentsAllowedFlag flag) { ValueContext for_value(this, flag); Visit(expr); } void HOptimizedGraphBuilder::VisitForTypeOf(Expression* expr) { ValueContext for_value(this, ARGUMENTS_NOT_ALLOWED); for_value.set_for_typeof(true); Visit(expr); } void HOptimizedGraphBuilder::VisitForControl(Expression* expr, HBasicBlock* true_block, HBasicBlock* false_block) { TestContext for_test(this, expr, true_block, false_block); Visit(expr); } void HOptimizedGraphBuilder::VisitExpressions( ZoneList<Expression*>* exprs) { for (int i = 0; i < exprs->length(); ++i) { CHECK_ALIVE(VisitForValue(exprs->at(i))); } } bool HOptimizedGraphBuilder::BuildGraph() { if (current_info()->function()->is_generator()) { Bailout(kFunctionIsAGenerator); return false; } Scope* scope = current_info()->scope(); if (scope->HasIllegalRedeclaration()) { Bailout(kFunctionWithIllegalRedeclaration); return false; } if (scope->calls_eval()) { Bailout(kFunctionCallsEval); return false; } SetUpScope(scope); // Add an edge to the body entry. This is warty: the graph's start // environment will be used by the Lithium translation as the initial // environment on graph entry, but it has now been mutated by the // Hydrogen translation of the instructions in the start block. This // environment uses values which have not been defined yet. These // Hydrogen instructions will then be replayed by the Lithium // translation, so they cannot have an environment effect. The edge to // the body's entry block (along with some special logic for the start // block in HInstruction::InsertAfter) seals the start block from // getting unwanted instructions inserted. // // TODO(kmillikin): Fix this. Stop mutating the initial environment. // Make the Hydrogen instructions in the initial block into Hydrogen // values (but not instructions), present in the initial environment and // not replayed by the Lithium translation. HEnvironment* initial_env = environment()->CopyWithoutHistory(); HBasicBlock* body_entry = CreateBasicBlock(initial_env); Goto(body_entry); body_entry->SetJoinId(BailoutId::FunctionEntry()); set_current_block(body_entry); // Handle implicit declaration of the function name in named function // expressions before other declarations. if (scope->is_function_scope() && scope->function() != NULL) { VisitVariableDeclaration(scope->function()); } VisitDeclarations(scope->declarations()); Add<HSimulate>(BailoutId::Declarations()); Add<HStackCheck>(HStackCheck::kFunctionEntry); VisitStatements(current_info()->function()->body()); if (HasStackOverflow()) return false; if (current_block() != NULL) { Add<HReturn>(graph()->GetConstantUndefined()); set_current_block(NULL); } // If the checksum of the number of type info changes is the same as the // last time this function was compiled, then this recompile is likely not // due to missing/inadequate type feedback, but rather too aggressive // optimization. Disable optimistic LICM in that case. Handle<Code> unoptimized_code(current_info()->shared_info()->code()); ASSERT(unoptimized_code->kind() == Code::FUNCTION); Handle<TypeFeedbackInfo> type_info( TypeFeedbackInfo::cast(unoptimized_code->type_feedback_info())); int checksum = type_info->own_type_change_checksum(); int composite_checksum = graph()->update_type_change_checksum(checksum); graph()->set_use_optimistic_licm( !type_info->matches_inlined_type_change_checksum(composite_checksum)); type_info->set_inlined_type_change_checksum(composite_checksum); // Perform any necessary OSR-specific cleanups or changes to the graph. osr()->FinishGraph(); return true; } bool HGraph::Optimize(BailoutReason* bailout_reason) { OrderBlocks(); AssignDominators(); // We need to create a HConstant "zero" now so that GVN will fold every // zero-valued constant in the graph together. // The constant is needed to make idef-based bounds check work: the pass // evaluates relations with "zero" and that zero cannot be created after GVN. GetConstant0(); #ifdef DEBUG // Do a full verify after building the graph and computing dominators. Verify(true); #endif if (FLAG_analyze_environment_liveness && maximum_environment_size() != 0) { Run<HEnvironmentLivenessAnalysisPhase>(); } if (!CheckConstPhiUses()) { *bailout_reason = kUnsupportedPhiUseOfConstVariable; return false; } Run<HRedundantPhiEliminationPhase>(); if (!CheckArgumentsPhiUses()) { *bailout_reason = kUnsupportedPhiUseOfArguments; return false; } // Find and mark unreachable code to simplify optimizations, especially gvn, // where unreachable code could unnecessarily defeat LICM. Run<HMarkUnreachableBlocksPhase>(); if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>(); if (FLAG_use_escape_analysis) Run<HEscapeAnalysisPhase>(); if (FLAG_load_elimination) Run<HLoadEliminationPhase>(); CollectPhis(); if (has_osr()) osr()->FinishOsrValues(); Run<HInferRepresentationPhase>(); // Remove HSimulate instructions that have turned out not to be needed // after all by folding them into the following HSimulate. // This must happen after inferring representations. Run<HMergeRemovableSimulatesPhase>(); Run<HMarkDeoptimizeOnUndefinedPhase>(); Run<HRepresentationChangesPhase>(); Run<HInferTypesPhase>(); // Must be performed before canonicalization to ensure that Canonicalize // will not remove semantically meaningful ToInt32 operations e.g. BIT_OR with // zero. if (FLAG_opt_safe_uint32_operations) Run<HUint32AnalysisPhase>(); if (FLAG_use_canonicalizing) Run<HCanonicalizePhase>(); if (FLAG_use_gvn) Run<HGlobalValueNumberingPhase>(); if (FLAG_check_elimination) Run<HCheckEliminationPhase>(); if (FLAG_store_elimination) Run<HStoreEliminationPhase>(); Run<HRangeAnalysisPhase>(); Run<HComputeChangeUndefinedToNaN>(); // Eliminate redundant stack checks on backwards branches. Run<HStackCheckEliminationPhase>(); if (FLAG_array_bounds_checks_elimination) Run<HBoundsCheckEliminationPhase>(); if (FLAG_array_bounds_checks_hoisting) Run<HBoundsCheckHoistingPhase>(); if (FLAG_array_index_dehoisting) Run<HDehoistIndexComputationsPhase>(); if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>(); RestoreActualValues(); // Find unreachable code a second time, GVN and other optimizations may have // made blocks unreachable that were previously reachable. Run<HMarkUnreachableBlocksPhase>(); return true; } void HGraph::RestoreActualValues() { HPhase phase("H_Restore actual values", this); for (int block_index = 0; block_index < blocks()->length(); block_index++) { HBasicBlock* block = blocks()->at(block_index); #ifdef DEBUG for (int i = 0; i < block->phis()->length(); i++) { HPhi* phi = block->phis()->at(i); ASSERT(phi->ActualValue() == phi); } #endif for (HInstructionIterator it(block); !it.Done(); it.Advance()) { HInstruction* instruction = it.Current(); if (instruction->ActualValue() == instruction) continue; if (instruction->CheckFlag(HValue::kIsDead)) { // The instruction was marked as deleted but left in the graph // as a control flow dependency point for subsequent // instructions. instruction->DeleteAndReplaceWith(instruction->ActualValue()); } else { ASSERT(instruction->IsInformativeDefinition()); if (instruction->IsPurelyInformativeDefinition()) { instruction->DeleteAndReplaceWith(instruction->RedefinedOperand()); } else { instruction->ReplaceAllUsesWith(instruction->ActualValue()); } } } } } void HOptimizedGraphBuilder::PushArgumentsFromEnvironment(int count) { ZoneList<HValue*> arguments(count, zone()); for (int i = 0; i < count; ++i) { arguments.Add(Pop(), zone()); } HPushArguments* push_args = New<HPushArguments>(); while (!arguments.is_empty()) { push_args->AddInput(arguments.RemoveLast()); } AddInstruction(push_args); } template <class Instruction> HInstruction* HOptimizedGraphBuilder::PreProcessCall(Instruction* call) { PushArgumentsFromEnvironment(call->argument_count()); return call; } void HOptimizedGraphBuilder::SetUpScope(Scope* scope) { // First special is HContext. HInstruction* context = Add<HContext>(); environment()->BindContext(context); // Create an arguments object containing the initial parameters. Set the // initial values of parameters including "this" having parameter index 0. ASSERT_EQ(scope->num_parameters() + 1, environment()->parameter_count()); HArgumentsObject* arguments_object = New<HArgumentsObject>(environment()->parameter_count()); for (int i = 0; i < environment()->parameter_count(); ++i) { HInstruction* parameter = Add<HParameter>(i); arguments_object->AddArgument(parameter, zone()); environment()->Bind(i, parameter); } AddInstruction(arguments_object); graph()->SetArgumentsObject(arguments_object); HConstant* undefined_constant = graph()->GetConstantUndefined(); // Initialize specials and locals to undefined. for (int i = environment()->parameter_count() + 1; i < environment()->length(); ++i) { environment()->Bind(i, undefined_constant); } // Handle the arguments and arguments shadow variables specially (they do // not have declarations). if (scope->arguments() != NULL) { if (!scope->arguments()->IsStackAllocated()) { return Bailout(kContextAllocatedArguments); } environment()->Bind(scope->arguments(), graph()->GetArgumentsObject()); } } void HOptimizedGraphBuilder::VisitStatements(ZoneList<Statement*>* statements) { for (int i = 0; i < statements->length(); i++) { Statement* stmt = statements->at(i); CHECK_ALIVE(Visit(stmt)); if (stmt->IsJump()) break; } } void HOptimizedGraphBuilder::VisitBlock(Block* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); Scope* outer_scope = scope(); Scope* scope = stmt->scope(); BreakAndContinueInfo break_info(stmt, outer_scope); { BreakAndContinueScope push(&break_info, this); if (scope != NULL) { // Load the function object. Scope* declaration_scope = scope->DeclarationScope(); HInstruction* function; HValue* outer_context = environment()->context(); if (declaration_scope->is_global_scope() || declaration_scope->is_eval_scope()) { function = new(zone()) HLoadContextSlot( outer_context, Context::CLOSURE_INDEX, HLoadContextSlot::kNoCheck); } else { function = New<HThisFunction>(); } AddInstruction(function); // Allocate a block context and store it to the stack frame. HInstruction* inner_context = Add<HAllocateBlockContext>( outer_context, function, scope->GetScopeInfo()); HInstruction* instr = Add<HStoreFrameContext>(inner_context); if (instr->HasObservableSideEffects()) { AddSimulate(stmt->EntryId(), REMOVABLE_SIMULATE); } set_scope(scope); environment()->BindContext(inner_context); VisitDeclarations(scope->declarations()); AddSimulate(stmt->DeclsId(), REMOVABLE_SIMULATE); } CHECK_BAILOUT(VisitStatements(stmt->statements())); } set_scope(outer_scope); if (scope != NULL && current_block() != NULL) { HValue* inner_context = environment()->context(); HValue* outer_context = Add<HLoadNamedField>( inner_context, static_cast<HValue*>(NULL), HObjectAccess::ForContextSlot(Context::PREVIOUS_INDEX)); HInstruction* instr = Add<HStoreFrameContext>(outer_context); if (instr->HasObservableSideEffects()) { AddSimulate(stmt->ExitId(), REMOVABLE_SIMULATE); } environment()->BindContext(outer_context); } HBasicBlock* break_block = break_info.break_block(); if (break_block != NULL) { if (current_block() != NULL) Goto(break_block); break_block->SetJoinId(stmt->ExitId()); set_current_block(break_block); } } void HOptimizedGraphBuilder::VisitExpressionStatement( ExpressionStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); VisitForEffect(stmt->expression()); } void HOptimizedGraphBuilder::VisitEmptyStatement(EmptyStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); } void HOptimizedGraphBuilder::VisitIfStatement(IfStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); if (stmt->condition()->ToBooleanIsTrue()) { Add<HSimulate>(stmt->ThenId()); Visit(stmt->then_statement()); } else if (stmt->condition()->ToBooleanIsFalse()) { Add<HSimulate>(stmt->ElseId()); Visit(stmt->else_statement()); } else { HBasicBlock* cond_true = graph()->CreateBasicBlock(); HBasicBlock* cond_false = graph()->CreateBasicBlock(); CHECK_BAILOUT(VisitForControl(stmt->condition(), cond_true, cond_false)); if (cond_true->HasPredecessor()) { cond_true->SetJoinId(stmt->ThenId()); set_current_block(cond_true); CHECK_BAILOUT(Visit(stmt->then_statement())); cond_true = current_block(); } else { cond_true = NULL; } if (cond_false->HasPredecessor()) { cond_false->SetJoinId(stmt->ElseId()); set_current_block(cond_false); CHECK_BAILOUT(Visit(stmt->else_statement())); cond_false = current_block(); } else { cond_false = NULL; } HBasicBlock* join = CreateJoin(cond_true, cond_false, stmt->IfId()); set_current_block(join); } } HBasicBlock* HOptimizedGraphBuilder::BreakAndContinueScope::Get( BreakableStatement* stmt, BreakType type, Scope** scope, int* drop_extra) { *drop_extra = 0; BreakAndContinueScope* current = this; while (current != NULL && current->info()->target() != stmt) { *drop_extra += current->info()->drop_extra(); current = current->next(); } ASSERT(current != NULL); // Always found (unless stack is malformed). *scope = current->info()->scope(); if (type == BREAK) { *drop_extra += current->info()->drop_extra(); } HBasicBlock* block = NULL; switch (type) { case BREAK: block = current->info()->break_block(); if (block == NULL) { block = current->owner()->graph()->CreateBasicBlock(); current->info()->set_break_block(block); } break; case CONTINUE: block = current->info()->continue_block(); if (block == NULL) { block = current->owner()->graph()->CreateBasicBlock(); current->info()->set_continue_block(block); } break; } return block; } void HOptimizedGraphBuilder::VisitContinueStatement( ContinueStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); Scope* outer_scope = NULL; Scope* inner_scope = scope(); int drop_extra = 0; HBasicBlock* continue_block = break_scope()->Get( stmt->target(), BreakAndContinueScope::CONTINUE, &outer_scope, &drop_extra); HValue* context = environment()->context(); Drop(drop_extra); int context_pop_count = inner_scope->ContextChainLength(outer_scope); if (context_pop_count > 0) { while (context_pop_count-- > 0) { HInstruction* context_instruction = Add<HLoadNamedField>( context, static_cast<HValue*>(NULL), HObjectAccess::ForContextSlot(Context::PREVIOUS_INDEX)); context = context_instruction; } HInstruction* instr = Add<HStoreFrameContext>(context); if (instr->HasObservableSideEffects()) { AddSimulate(stmt->target()->EntryId(), REMOVABLE_SIMULATE); } environment()->BindContext(context); } Goto(continue_block); set_current_block(NULL); } void HOptimizedGraphBuilder::VisitBreakStatement(BreakStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); Scope* outer_scope = NULL; Scope* inner_scope = scope(); int drop_extra = 0; HBasicBlock* break_block = break_scope()->Get( stmt->target(), BreakAndContinueScope::BREAK, &outer_scope, &drop_extra); HValue* context = environment()->context(); Drop(drop_extra); int context_pop_count = inner_scope->ContextChainLength(outer_scope); if (context_pop_count > 0) { while (context_pop_count-- > 0) { HInstruction* context_instruction = Add<HLoadNamedField>( context, static_cast<HValue*>(NULL), HObjectAccess::ForContextSlot(Context::PREVIOUS_INDEX)); context = context_instruction; } HInstruction* instr = Add<HStoreFrameContext>(context); if (instr->HasObservableSideEffects()) { AddSimulate(stmt->target()->ExitId(), REMOVABLE_SIMULATE); } environment()->BindContext(context); } Goto(break_block); set_current_block(NULL); } void HOptimizedGraphBuilder::VisitReturnStatement(ReturnStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); FunctionState* state = function_state(); AstContext* context = call_context(); if (context == NULL) { // Not an inlined return, so an actual one. CHECK_ALIVE(VisitForValue(stmt->expression())); HValue* result = environment()->Pop(); Add<HReturn>(result); } else if (state->inlining_kind() == CONSTRUCT_CALL_RETURN) { // Return from an inlined construct call. In a test context the return value // will always evaluate to true, in a value context the return value needs // to be a JSObject. if (context->IsTest()) { TestContext* test = TestContext::cast(context); CHECK_ALIVE(VisitForEffect(stmt->expression())); Goto(test->if_true(), state); } else if (context->IsEffect()) { CHECK_ALIVE(VisitForEffect(stmt->expression())); Goto(function_return(), state); } else { ASSERT(context->IsValue()); CHECK_ALIVE(VisitForValue(stmt->expression())); HValue* return_value = Pop(); HValue* receiver = environment()->arguments_environment()->Lookup(0); HHasInstanceTypeAndBranch* typecheck = New<HHasInstanceTypeAndBranch>(return_value, FIRST_SPEC_OBJECT_TYPE, LAST_SPEC_OBJECT_TYPE); HBasicBlock* if_spec_object = graph()->CreateBasicBlock(); HBasicBlock* not_spec_object = graph()->CreateBasicBlock(); typecheck->SetSuccessorAt(0, if_spec_object); typecheck->SetSuccessorAt(1, not_spec_object); FinishCurrentBlock(typecheck); AddLeaveInlined(if_spec_object, return_value, state); AddLeaveInlined(not_spec_object, receiver, state); } } else if (state->inlining_kind() == SETTER_CALL_RETURN) { // Return from an inlined setter call. The returned value is never used, the // value of an assignment is always the value of the RHS of the assignment. CHECK_ALIVE(VisitForEffect(stmt->expression())); if (context->IsTest()) { HValue* rhs = environment()->arguments_environment()->Lookup(1); context->ReturnValue(rhs); } else if (context->IsEffect()) { Goto(function_return(), state); } else { ASSERT(context->IsValue()); HValue* rhs = environment()->arguments_environment()->Lookup(1); AddLeaveInlined(rhs, state); } } else { // Return from a normal inlined function. Visit the subexpression in the // expression context of the call. if (context->IsTest()) { TestContext* test = TestContext::cast(context); VisitForControl(stmt->expression(), test->if_true(), test->if_false()); } else if (context->IsEffect()) { // Visit in value context and ignore the result. This is needed to keep // environment in sync with full-codegen since some visitors (e.g. // VisitCountOperation) use the operand stack differently depending on // context. CHECK_ALIVE(VisitForValue(stmt->expression())); Pop(); Goto(function_return(), state); } else { ASSERT(context->IsValue()); CHECK_ALIVE(VisitForValue(stmt->expression())); AddLeaveInlined(Pop(), state); } } set_current_block(NULL); } void HOptimizedGraphBuilder::VisitWithStatement(WithStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); return Bailout(kWithStatement); } void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); // We only optimize switch statements with a bounded number of clauses. const int kCaseClauseLimit = 128; ZoneList<CaseClause*>* clauses = stmt->cases(); int clause_count = clauses->length(); ZoneList<HBasicBlock*> body_blocks(clause_count, zone()); if (clause_count > kCaseClauseLimit) { return Bailout(kSwitchStatementTooManyClauses); } CHECK_ALIVE(VisitForValue(stmt->tag())); Add<HSimulate>(stmt->EntryId()); HValue* tag_value = Top(); Type* tag_type = stmt->tag()->bounds().lower; // 1. Build all the tests, with dangling true branches BailoutId default_id = BailoutId::None(); for (int i = 0; i < clause_count; ++i) { CaseClause* clause = clauses->at(i); if (clause->is_default()) { body_blocks.Add(NULL, zone()); if (default_id.IsNone()) default_id = clause->EntryId(); continue; } // Generate a compare and branch. CHECK_ALIVE(VisitForValue(clause->label())); HValue* label_value = Pop(); Type* label_type = clause->label()->bounds().lower; Type* combined_type = clause->compare_type(); HControlInstruction* compare = BuildCompareInstruction( Token::EQ_STRICT, tag_value, label_value, tag_type, label_type, combined_type, ScriptPositionToSourcePosition(stmt->tag()->position()), ScriptPositionToSourcePosition(clause->label()->position()), PUSH_BEFORE_SIMULATE, clause->id()); HBasicBlock* next_test_block = graph()->CreateBasicBlock(); HBasicBlock* body_block = graph()->CreateBasicBlock(); body_blocks.Add(body_block, zone()); compare->SetSuccessorAt(0, body_block); compare->SetSuccessorAt(1, next_test_block); FinishCurrentBlock(compare); set_current_block(body_block); Drop(1); // tag_value set_current_block(next_test_block); } // Save the current block to use for the default or to join with the // exit. HBasicBlock* last_block = current_block(); Drop(1); // tag_value // 2. Loop over the clauses and the linked list of tests in lockstep, // translating the clause bodies. HBasicBlock* fall_through_block = NULL; BreakAndContinueInfo break_info(stmt, scope()); { BreakAndContinueScope push(&break_info, this); for (int i = 0; i < clause_count; ++i) { CaseClause* clause = clauses->at(i); // Identify the block where normal (non-fall-through) control flow // goes to. HBasicBlock* normal_block = NULL; if (clause->is_default()) { if (last_block == NULL) continue; normal_block = last_block; last_block = NULL; // Cleared to indicate we've handled it. } else { normal_block = body_blocks[i]; } if (fall_through_block == NULL) { set_current_block(normal_block); } else { HBasicBlock* join = CreateJoin(fall_through_block, normal_block, clause->EntryId()); set_current_block(join); } CHECK_BAILOUT(VisitStatements(clause->statements())); fall_through_block = current_block(); } } // Create an up-to-3-way join. Use the break block if it exists since // it's already a join block. HBasicBlock* break_block = break_info.break_block(); if (break_block == NULL) { set_current_block(CreateJoin(fall_through_block, last_block, stmt->ExitId())); } else { if (fall_through_block != NULL) Goto(fall_through_block, break_block); if (last_block != NULL) Goto(last_block, break_block); break_block->SetJoinId(stmt->ExitId()); set_current_block(break_block); } } void HOptimizedGraphBuilder::VisitLoopBody(IterationStatement* stmt, HBasicBlock* loop_entry) { Add<HSimulate>(stmt->StackCheckId()); HStackCheck* stack_check = HStackCheck::cast(Add<HStackCheck>(HStackCheck::kBackwardsBranch)); ASSERT(loop_entry->IsLoopHeader()); loop_entry->loop_information()->set_stack_check(stack_check); CHECK_BAILOUT(Visit(stmt->body())); } void HOptimizedGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); ASSERT(current_block() != NULL); HBasicBlock* loop_entry = BuildLoopEntry(stmt); BreakAndContinueInfo break_info(stmt, scope()); { BreakAndContinueScope push(&break_info, this); CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry)); } HBasicBlock* body_exit = JoinContinue(stmt, current_block(), break_info.continue_block()); HBasicBlock* loop_successor = NULL; if (body_exit != NULL && !stmt->cond()->ToBooleanIsTrue()) { set_current_block(body_exit); loop_successor = graph()->CreateBasicBlock(); if (stmt->cond()->ToBooleanIsFalse()) { loop_entry->loop_information()->stack_check()->Eliminate(); Goto(loop_successor); body_exit = NULL; } else { // The block for a true condition, the actual predecessor block of the // back edge. body_exit = graph()->CreateBasicBlock(); CHECK_BAILOUT(VisitForControl(stmt->cond(), body_exit, loop_successor)); } if (body_exit != NULL && body_exit->HasPredecessor()) { body_exit->SetJoinId(stmt->BackEdgeId()); } else { body_exit = NULL; } if (loop_successor->HasPredecessor()) { loop_successor->SetJoinId(stmt->ExitId()); } else { loop_successor = NULL; } } HBasicBlock* loop_exit = CreateLoop(stmt, loop_entry, body_exit, loop_successor, break_info.break_block()); set_current_block(loop_exit); } void HOptimizedGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); ASSERT(current_block() != NULL); HBasicBlock* loop_entry = BuildLoopEntry(stmt); // If the condition is constant true, do not generate a branch. HBasicBlock* loop_successor = NULL; if (!stmt->cond()->ToBooleanIsTrue()) { HBasicBlock* body_entry = graph()->CreateBasicBlock(); loop_successor = graph()->CreateBasicBlock(); CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor)); if (body_entry->HasPredecessor()) { body_entry->SetJoinId(stmt->BodyId()); set_current_block(body_entry); } if (loop_successor->HasPredecessor()) { loop_successor->SetJoinId(stmt->ExitId()); } else { loop_successor = NULL; } } BreakAndContinueInfo break_info(stmt, scope()); if (current_block() != NULL) { BreakAndContinueScope push(&break_info, this); CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry)); } HBasicBlock* body_exit = JoinContinue(stmt, current_block(), break_info.continue_block()); HBasicBlock* loop_exit = CreateLoop(stmt, loop_entry, body_exit, loop_successor, break_info.break_block()); set_current_block(loop_exit); } void HOptimizedGraphBuilder::VisitForStatement(ForStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); if (stmt->init() != NULL) { CHECK_ALIVE(Visit(stmt->init())); } ASSERT(current_block() != NULL); HBasicBlock* loop_entry = BuildLoopEntry(stmt); HBasicBlock* loop_successor = NULL; if (stmt->cond() != NULL) { HBasicBlock* body_entry = graph()->CreateBasicBlock(); loop_successor = graph()->CreateBasicBlock(); CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor)); if (body_entry->HasPredecessor()) { body_entry->SetJoinId(stmt->BodyId()); set_current_block(body_entry); } if (loop_successor->HasPredecessor()) { loop_successor->SetJoinId(stmt->ExitId()); } else { loop_successor = NULL; } } BreakAndContinueInfo break_info(stmt, scope()); if (current_block() != NULL) { BreakAndContinueScope push(&break_info, this); CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry)); } HBasicBlock* body_exit = JoinContinue(stmt, current_block(), break_info.continue_block()); if (stmt->next() != NULL && body_exit != NULL) { set_current_block(body_exit); CHECK_BAILOUT(Visit(stmt->next())); body_exit = current_block(); } HBasicBlock* loop_exit = CreateLoop(stmt, loop_entry, body_exit, loop_successor, break_info.break_block()); set_current_block(loop_exit); } void HOptimizedGraphBuilder::VisitForInStatement(ForInStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); if (!FLAG_optimize_for_in) { return Bailout(kForInStatementOptimizationIsDisabled); } if (stmt->for_in_type() != ForInStatement::FAST_FOR_IN) { return Bailout(kForInStatementIsNotFastCase); } if (!stmt->each()->IsVariableProxy() || !stmt->each()->AsVariableProxy()->var()->IsStackLocal()) { return Bailout(kForInStatementWithNonLocalEachVariable); } Variable* each_var = stmt->each()->AsVariableProxy()->var(); CHECK_ALIVE(VisitForValue(stmt->enumerable())); HValue* enumerable = Top(); // Leave enumerable at the top. HInstruction* map = Add<HForInPrepareMap>(enumerable); Add<HSimulate>(stmt->PrepareId()); HInstruction* array = Add<HForInCacheArray>( enumerable, map, DescriptorArray::kEnumCacheBridgeCacheIndex); HInstruction* enum_length = Add<HMapEnumLength>(map); HInstruction* start_index = Add<HConstant>(0); Push(map); Push(array); Push(enum_length); Push(start_index); HInstruction* index_cache = Add<HForInCacheArray>( enumerable, map, DescriptorArray::kEnumCacheBridgeIndicesCacheIndex); HForInCacheArray::cast(array)->set_index_cache( HForInCacheArray::cast(index_cache)); HBasicBlock* loop_entry = BuildLoopEntry(stmt); HValue* index = environment()->ExpressionStackAt(0); HValue* limit = environment()->ExpressionStackAt(1); // Check that we still have more keys. HCompareNumericAndBranch* compare_index = New<HCompareNumericAndBranch>(index, limit, Token::LT); compare_index->set_observed_input_representation( Representation::Smi(), Representation::Smi()); HBasicBlock* loop_body = graph()->CreateBasicBlock(); HBasicBlock* loop_successor = graph()->CreateBasicBlock(); compare_index->SetSuccessorAt(0, loop_body); compare_index->SetSuccessorAt(1, loop_successor); FinishCurrentBlock(compare_index); set_current_block(loop_successor); Drop(5); set_current_block(loop_body); HValue* key = Add<HLoadKeyed>( environment()->ExpressionStackAt(2), // Enum cache. environment()->ExpressionStackAt(0), // Iteration index. environment()->ExpressionStackAt(0), FAST_ELEMENTS); // Check if the expected map still matches that of the enumerable. // If not just deoptimize. Add<HCheckMapValue>(environment()->ExpressionStackAt(4), environment()->ExpressionStackAt(3)); Bind(each_var, key); BreakAndContinueInfo break_info(stmt, scope(), 5); { BreakAndContinueScope push(&break_info, this); CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry)); } HBasicBlock* body_exit = JoinContinue(stmt, current_block(), break_info.continue_block()); if (body_exit != NULL) { set_current_block(body_exit); HValue* current_index = Pop(); Push(AddUncasted<HAdd>(current_index, graph()->GetConstant1())); body_exit = current_block(); } HBasicBlock* loop_exit = CreateLoop(stmt, loop_entry, body_exit, loop_successor, break_info.break_block()); set_current_block(loop_exit); } void HOptimizedGraphBuilder::VisitForOfStatement(ForOfStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); return Bailout(kForOfStatement); } void HOptimizedGraphBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); return Bailout(kTryCatchStatement); } void HOptimizedGraphBuilder::VisitTryFinallyStatement( TryFinallyStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); return Bailout(kTryFinallyStatement); } void HOptimizedGraphBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); return Bailout(kDebuggerStatement); } void HOptimizedGraphBuilder::VisitCaseClause(CaseClause* clause) { UNREACHABLE(); } void HOptimizedGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); Handle<SharedFunctionInfo> shared_info = expr->shared_info(); if (shared_info.is_null()) { shared_info = Compiler::BuildFunctionInfo(expr, current_info()->script()); } // We also have a stack overflow if the recursive compilation did. if (HasStackOverflow()) return; HFunctionLiteral* instr = New<HFunctionLiteral>(shared_info, expr->pretenure()); return ast_context()->ReturnInstruction(instr, expr->id()); } void HOptimizedGraphBuilder::VisitNativeFunctionLiteral( NativeFunctionLiteral* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); return Bailout(kNativeFunctionLiteral); } void HOptimizedGraphBuilder::VisitConditional(Conditional* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); HBasicBlock* cond_true = graph()->CreateBasicBlock(); HBasicBlock* cond_false = graph()->CreateBasicBlock(); CHECK_BAILOUT(VisitForControl(expr->condition(), cond_true, cond_false)); // Visit the true and false subexpressions in the same AST context as the // whole expression. if (cond_true->HasPredecessor()) { cond_true->SetJoinId(expr->ThenId()); set_current_block(cond_true); CHECK_BAILOUT(Visit(expr->then_expression())); cond_true = current_block(); } else { cond_true = NULL; } if (cond_false->HasPredecessor()) { cond_false->SetJoinId(expr->ElseId()); set_current_block(cond_false); CHECK_BAILOUT(Visit(expr->else_expression())); cond_false = current_block(); } else { cond_false = NULL; } if (!ast_context()->IsTest()) { HBasicBlock* join = CreateJoin(cond_true, cond_false, expr->id()); set_current_block(join); if (join != NULL && !ast_context()->IsEffect()) { return ast_context()->ReturnValue(Pop()); } } } HOptimizedGraphBuilder::GlobalPropertyAccess HOptimizedGraphBuilder::LookupGlobalProperty( Variable* var, LookupResult* lookup, PropertyAccessType access_type) { if (var->is_this() || !current_info()->has_global_object()) { return kUseGeneric; } Handle<GlobalObject> global(current_info()->global_object()); global->Lookup(var->name(), lookup); if (!lookup->IsNormal() || (access_type == STORE && lookup->IsReadOnly()) || lookup->holder() != *global) { return kUseGeneric; } return kUseCell; } HValue* HOptimizedGraphBuilder::BuildContextChainWalk(Variable* var) { ASSERT(var->IsContextSlot()); HValue* context = environment()->context(); int length = scope()->ContextChainLength(var->scope()); while (length-- > 0) { context = Add<HLoadNamedField>( context, static_cast<HValue*>(NULL), HObjectAccess::ForContextSlot(Context::PREVIOUS_INDEX)); } return context; } void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) { if (expr->is_this()) { current_info()->set_this_has_uses(true); } ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); Variable* variable = expr->var(); switch (variable->location()) { case Variable::UNALLOCATED: { if (IsLexicalVariableMode(variable->mode())) { // TODO(rossberg): should this be an ASSERT? return Bailout(kReferenceToGlobalLexicalVariable); } // Handle known global constants like 'undefined' specially to avoid a // load from a global cell for them. Handle<Object> constant_value = isolate()->factory()->GlobalConstantFor(variable->name()); if (!constant_value.is_null()) { HConstant* instr = New<HConstant>(constant_value); return ast_context()->ReturnInstruction(instr, expr->id()); } LookupResult lookup(isolate()); GlobalPropertyAccess type = LookupGlobalProperty(variable, &lookup, LOAD); if (type == kUseCell && current_info()->global_object()->IsAccessCheckNeeded()) { type = kUseGeneric; } if (type == kUseCell) { Handle<GlobalObject> global(current_info()->global_object()); Handle<PropertyCell> cell(global->GetPropertyCell(&lookup)); if (cell->type()->IsConstant()) { PropertyCell::AddDependentCompilationInfo(cell, top_info()); Handle<Object> constant_object = cell->type()->AsConstant()->Value(); if (constant_object->IsConsString()) { constant_object = String::Flatten(Handle<String>::cast(constant_object)); } HConstant* constant = New<HConstant>(constant_object); return ast_context()->ReturnInstruction(constant, expr->id()); } else { HLoadGlobalCell* instr = New<HLoadGlobalCell>(cell, lookup.GetPropertyDetails()); return ast_context()->ReturnInstruction(instr, expr->id()); } } else { HValue* global_object = Add<HLoadNamedField>( context(), static_cast<HValue*>(NULL), HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); HLoadGlobalGeneric* instr = New<HLoadGlobalGeneric>(global_object, variable->name(), ast_context()->is_for_typeof()); return ast_context()->ReturnInstruction(instr, expr->id()); } } case Variable::PARAMETER: case Variable::LOCAL: { HValue* value = LookupAndMakeLive(variable); if (value == graph()->GetConstantHole()) { ASSERT(IsDeclaredVariableMode(variable->mode()) && variable->mode() != VAR); return Bailout(kReferenceToUninitializedVariable); } return ast_context()->ReturnValue(value); } case Variable::CONTEXT: { HValue* context = BuildContextChainWalk(variable); HLoadContextSlot::Mode mode; switch (variable->mode()) { case LET: case CONST: mode = HLoadContextSlot::kCheckDeoptimize; break; case CONST_LEGACY: mode = HLoadContextSlot::kCheckReturnUndefined; break; default: mode = HLoadContextSlot::kNoCheck; break; } HLoadContextSlot* instr = new(zone()) HLoadContextSlot(context, variable->index(), mode); return ast_context()->ReturnInstruction(instr, expr->id()); } case Variable::LOOKUP: return Bailout(kReferenceToAVariableWhichRequiresDynamicLookup); } } void HOptimizedGraphBuilder::VisitLiteral(Literal* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); HConstant* instr = New<HConstant>(expr->value()); return ast_context()->ReturnInstruction(instr, expr->id()); } void HOptimizedGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); Handle<JSFunction> closure = function_state()->compilation_info()->closure(); Handle<FixedArray> literals(closure->literals()); HRegExpLiteral* instr = New<HRegExpLiteral>(literals, expr->pattern(), expr->flags(), expr->literal_index()); return ast_context()->ReturnInstruction(instr, expr->id()); } static bool CanInlinePropertyAccess(Type* type) { if (type->Is(Type::NumberOrString())) return true; if (!type->IsClass()) return false; Handle<Map> map = type->AsClass()->Map(); return map->IsJSObjectMap() && !map->is_dictionary_map() && !map->has_named_interceptor(); } // Determines whether the given array or object literal boilerplate satisfies // all limits to be considered for fast deep-copying and computes the total // size of all objects that are part of the graph. static bool IsFastLiteral(Handle<JSObject> boilerplate, int max_depth, int* max_properties) { if (boilerplate->map()->is_deprecated() && !JSObject::TryMigrateInstance(boilerplate)) { return false; } ASSERT(max_depth >= 0 && *max_properties >= 0); if (max_depth == 0) return false; Isolate* isolate = boilerplate->GetIsolate(); Handle<FixedArrayBase> elements(boilerplate->elements()); if (elements->length() > 0 && elements->map() != isolate->heap()->fixed_cow_array_map()) { if (boilerplate->HasFastObjectElements()) { Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); int length = elements->length(); for (int i = 0; i < length; i++) { if ((*max_properties)-- == 0) return false; Handle<Object> value(fast_elements->get(i), isolate); if (value->IsJSObject()) { Handle<JSObject> value_object = Handle<JSObject>::cast(value); if (!IsFastLiteral(value_object, max_depth - 1, max_properties)) { return false; } } } } else if (!boilerplate->HasFastDoubleElements()) { return false; } } Handle<FixedArray> properties(boilerplate->properties()); if (properties->length() > 0) { return false; } else { Handle<DescriptorArray> descriptors( boilerplate->map()->instance_descriptors()); int limit = boilerplate->map()->NumberOfOwnDescriptors(); for (int i = 0; i < limit; i++) { PropertyDetails details = descriptors->GetDetails(i); if (details.type() != FIELD) continue; int index = descriptors->GetFieldIndex(i); if ((*max_properties)-- == 0) return false; Handle<Object> value(boilerplate->InObjectPropertyAt(index), isolate); if (value->IsJSObject()) { Handle<JSObject> value_object = Handle<JSObject>::cast(value); if (!IsFastLiteral(value_object, max_depth - 1, max_properties)) { return false; } } } } return true; } void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); expr->BuildConstantProperties(isolate()); Handle<JSFunction> closure = function_state()->compilation_info()->closure(); HInstruction* literal; // Check whether to use fast or slow deep-copying for boilerplate. int max_properties = kMaxFastLiteralProperties; Handle<Object> literals_cell(closure->literals()->get(expr->literal_index()), isolate()); Handle<AllocationSite> site; Handle<JSObject> boilerplate; if (!literals_cell->IsUndefined()) { // Retrieve the boilerplate site = Handle<AllocationSite>::cast(literals_cell); boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), isolate()); } if (!boilerplate.is_null() && IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { AllocationSiteUsageContext usage_context(isolate(), site, false); usage_context.EnterNewScope(); literal = BuildFastLiteral(boilerplate, &usage_context); usage_context.ExitScope(site, boilerplate); } else { NoObservableSideEffectsScope no_effects(this); Handle<FixedArray> closure_literals(closure->literals(), isolate()); Handle<FixedArray> constant_properties = expr->constant_properties(); int literal_index = expr->literal_index(); int flags = expr->fast_elements() ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags; flags |= expr->has_function() ? ObjectLiteral::kHasFunction : ObjectLiteral::kNoFlags; Add<HPushArguments>(Add<HConstant>(closure_literals), Add<HConstant>(literal_index), Add<HConstant>(constant_properties), Add<HConstant>(flags)); // TODO(mvstanton): Add a flag to turn off creation of any // AllocationMementos for this call: we are in crankshaft and should have // learned enough about transition behavior to stop emitting mementos. Runtime::FunctionId function_id = Runtime::kHiddenCreateObjectLiteral; literal = Add<HCallRuntime>(isolate()->factory()->empty_string(), Runtime::FunctionForId(function_id), 4); } // The object is expected in the bailout environment during computation // of the property values and is the value of the entire expression. Push(literal); expr->CalculateEmitStore(zone()); for (int i = 0; i < expr->properties()->length(); i++) { ObjectLiteral::Property* property = expr->properties()->at(i); if (property->IsCompileTimeValue()) continue; Literal* key = property->key(); Expression* value = property->value(); switch (property->kind()) { case ObjectLiteral::Property::MATERIALIZED_LITERAL: ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); // Fall through. case ObjectLiteral::Property::COMPUTED: if (key->value()->IsInternalizedString()) { if (property->emit_store()) { CHECK_ALIVE(VisitForValue(value)); HValue* value = Pop(); Handle<Map> map = property->GetReceiverType(); Handle<String> name = property->key()->AsPropertyName(); HInstruction* store; if (map.is_null()) { // If we don't know the monomorphic type, do a generic store. CHECK_ALIVE(store = BuildNamedGeneric( STORE, literal, name, value)); } else { PropertyAccessInfo info(this, STORE, ToType(map), name); if (info.CanAccessMonomorphic()) { HValue* checked_literal = Add<HCheckMaps>(literal, map); ASSERT(!info.lookup()->IsPropertyCallbacks()); store = BuildMonomorphicAccess( &info, literal, checked_literal, value, BailoutId::None(), BailoutId::None()); } else { CHECK_ALIVE(store = BuildNamedGeneric( STORE, literal, name, value)); } } AddInstruction(store); if (store->HasObservableSideEffects()) { Add<HSimulate>(key->id(), REMOVABLE_SIMULATE); } } else { CHECK_ALIVE(VisitForEffect(value)); } break; } // Fall through. case ObjectLiteral::Property::PROTOTYPE: case ObjectLiteral::Property::SETTER: case ObjectLiteral::Property::GETTER: return Bailout(kObjectLiteralWithComplexProperty); default: UNREACHABLE(); } } if (expr->has_function()) { // Return the result of the transformation to fast properties // instead of the original since this operation changes the map // of the object. This makes sure that the original object won't // be used by other optimized code before it is transformed // (e.g. because of code motion). HToFastProperties* result = Add<HToFastProperties>(Pop()); return ast_context()->ReturnValue(result); } else { return ast_context()->ReturnValue(Pop()); } } void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); expr->BuildConstantElements(isolate()); ZoneList<Expression*>* subexprs = expr->values(); int length = subexprs->length(); HInstruction* literal; Handle<AllocationSite> site; Handle<FixedArray> literals(environment()->closure()->literals(), isolate()); bool uninitialized = false; Handle<Object> literals_cell(literals->get(expr->literal_index()), isolate()); Handle<JSObject> boilerplate_object; if (literals_cell->IsUndefined()) { uninitialized = true; Handle<Object> raw_boilerplate; ASSIGN_RETURN_ON_EXCEPTION_VALUE( isolate(), raw_boilerplate, Runtime::CreateArrayLiteralBoilerplate( isolate(), literals, expr->constant_elements()), Bailout(kArrayBoilerplateCreationFailed)); boilerplate_object = Handle<JSObject>::cast(raw_boilerplate); AllocationSiteCreationContext creation_context(isolate()); site = creation_context.EnterNewScope(); if (JSObject::DeepWalk(boilerplate_object, &creation_context).is_null()) { return Bailout(kArrayBoilerplateCreationFailed); } creation_context.ExitScope(site, boilerplate_object); literals->set(expr->literal_index(), *site); if (boilerplate_object->elements()->map() == isolate()->heap()->fixed_cow_array_map()) { isolate()->counters()->cow_arrays_created_runtime()->Increment(); } } else { ASSERT(literals_cell->IsAllocationSite()); site = Handle<AllocationSite>::cast(literals_cell); boilerplate_object = Handle<JSObject>( JSObject::cast(site->transition_info()), isolate()); } ASSERT(!boilerplate_object.is_null()); ASSERT(site->SitePointsToLiteral()); ElementsKind boilerplate_elements_kind = boilerplate_object->GetElementsKind(); // Check whether to use fast or slow deep-copying for boilerplate. int max_properties = kMaxFastLiteralProperties; if (IsFastLiteral(boilerplate_object, kMaxFastLiteralDepth, &max_properties)) { AllocationSiteUsageContext usage_context(isolate(), site, false); usage_context.EnterNewScope(); literal = BuildFastLiteral(boilerplate_object, &usage_context); usage_context.ExitScope(site, boilerplate_object); } else { NoObservableSideEffectsScope no_effects(this); // Boilerplate already exists and constant elements are never accessed, // pass an empty fixed array to the runtime function instead. Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); int literal_index = expr->literal_index(); int flags = expr->depth() == 1 ? ArrayLiteral::kShallowElements : ArrayLiteral::kNoFlags; flags |= ArrayLiteral::kDisableMementos; Add<HPushArguments>(Add<HConstant>(literals), Add<HConstant>(literal_index), Add<HConstant>(constants), Add<HConstant>(flags)); // TODO(mvstanton): Consider a flag to turn off creation of any // AllocationMementos for this call: we are in crankshaft and should have // learned enough about transition behavior to stop emitting mementos. Runtime::FunctionId function_id = Runtime::kHiddenCreateArrayLiteral; literal = Add<HCallRuntime>(isolate()->factory()->empty_string(), Runtime::FunctionForId(function_id), 4); // De-opt if elements kind changed from boilerplate_elements_kind. Handle<Map> map = Handle<Map>(boilerplate_object->map(), isolate()); literal = Add<HCheckMaps>(literal, map); } // The array is expected in the bailout environment during computation // of the property values and is the value of the entire expression. Push(literal); // The literal index is on the stack, too. Push(Add<HConstant>(expr->literal_index())); HInstruction* elements = NULL; for (int i = 0; i < length; i++) { Expression* subexpr = subexprs->at(i); // If the subexpression is a literal or a simple materialized literal it // is already set in the cloned array. if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; CHECK_ALIVE(VisitForValue(subexpr)); HValue* value = Pop(); if (!Smi::IsValid(i)) return Bailout(kNonSmiKeyInArrayLiteral); elements = AddLoadElements(literal); HValue* key = Add<HConstant>(i); switch (boilerplate_elements_kind) { case FAST_SMI_ELEMENTS: case FAST_HOLEY_SMI_ELEMENTS: case FAST_ELEMENTS: case FAST_HOLEY_ELEMENTS: case FAST_DOUBLE_ELEMENTS: case FAST_HOLEY_DOUBLE_ELEMENTS: { HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value, boilerplate_elements_kind); instr->SetUninitialized(uninitialized); break; } default: UNREACHABLE(); break; } Add<HSimulate>(expr->GetIdForElement(i)); } Drop(1); // array literal index return ast_context()->ReturnValue(Pop()); } HCheckMaps* HOptimizedGraphBuilder::AddCheckMap(HValue* object, Handle<Map> map) { BuildCheckHeapObject(object); return Add<HCheckMaps>(object, map); } HInstruction* HOptimizedGraphBuilder::BuildLoadNamedField( PropertyAccessInfo* info, HValue* checked_object) { // See if this is a load for an immutable property if (checked_object->ActualValue()->IsConstant() && info->lookup()->IsCacheable() && info->lookup()->IsReadOnly() && info->lookup()->IsDontDelete()) { Handle<Object> object( HConstant::cast(checked_object->ActualValue())->handle(isolate())); if (object->IsJSObject()) { LookupResult lookup(isolate()); Handle<JSObject>::cast(object)->Lookup(info->name(), &lookup); Handle<Object> value(lookup.GetLazyValue(), isolate()); if (!value->IsTheHole()) { return New<HConstant>(value); } } } HObjectAccess access = info->access(); if (access.representation().IsDouble()) { // Load the heap number. checked_object = Add<HLoadNamedField>( checked_object, static_cast<HValue*>(NULL), access.WithRepresentation(Representation::Tagged())); // Load the double value from it. access = HObjectAccess::ForHeapNumberValue(); } SmallMapList* map_list = info->field_maps(); if (map_list->length() == 0) { return New<HLoadNamedField>(checked_object, checked_object, access); } UniqueSet<Map>* maps = new(zone()) UniqueSet<Map>(map_list->length(), zone()); for (int i = 0; i < map_list->length(); ++i) { maps->Add(Unique<Map>::CreateImmovable(map_list->at(i)), zone()); } return New<HLoadNamedField>( checked_object, checked_object, access, maps, info->field_type()); } HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField( PropertyAccessInfo* info, HValue* checked_object, HValue* value) { bool transition_to_field = info->lookup()->IsTransition(); // TODO(verwaest): Move this logic into PropertyAccessInfo. HObjectAccess field_access = info->access(); HStoreNamedField *instr; if (field_access.representation().IsDouble()) { HObjectAccess heap_number_access = field_access.WithRepresentation(Representation::Tagged()); if (transition_to_field) { // The store requires a mutable HeapNumber to be allocated. NoObservableSideEffectsScope no_side_effects(this); HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize); // TODO(hpayer): Allocation site pretenuring support. HInstruction* heap_number = Add<HAllocate>(heap_number_size, HType::HeapObject(), NOT_TENURED, HEAP_NUMBER_TYPE); AddStoreMapConstant(heap_number, isolate()->factory()->heap_number_map()); Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(), value); instr = New<HStoreNamedField>(checked_object->ActualValue(), heap_number_access, heap_number); } else { // Already holds a HeapNumber; load the box and write its value field. HInstruction* heap_number = Add<HLoadNamedField>( checked_object, static_cast<HValue*>(NULL), heap_number_access); instr = New<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(), value, STORE_TO_INITIALIZED_ENTRY); } } else { if (field_access.representation().IsHeapObject()) { BuildCheckHeapObject(value); } if (!info->field_maps()->is_empty()) { ASSERT(field_access.representation().IsHeapObject()); value = Add<HCheckMaps>(value, info->field_maps()); } // This is a normal store. instr = New<HStoreNamedField>( checked_object->ActualValue(), field_access, value, transition_to_field ? INITIALIZING_STORE : STORE_TO_INITIALIZED_ENTRY); } if (transition_to_field) { Handle<Map> transition(info->transition()); ASSERT(!transition->is_deprecated()); instr->SetTransition(Add<HConstant>(transition)); } return instr; } bool HOptimizedGraphBuilder::PropertyAccessInfo::IsCompatible( PropertyAccessInfo* info) { if (!CanInlinePropertyAccess(type_)) return false; // Currently only handle Type::Number as a polymorphic case. // TODO(verwaest): Support monomorphic handling of numbers with a HCheckNumber // instruction. if (type_->Is(Type::Number())) return false; // Values are only compatible for monomorphic load if they all behave the same // regarding value wrappers. if (type_->Is(Type::NumberOrString())) { if (!info->type_->Is(Type::NumberOrString())) return false; } else { if (info->type_->Is(Type::NumberOrString())) return false; } if (!LookupDescriptor()) return false; if (!lookup_.IsFound()) { return (!info->lookup_.IsFound() || info->has_holder()) && map()->prototype() == info->map()->prototype(); } // Mismatch if the other access info found the property in the prototype // chain. if (info->has_holder()) return false; if (lookup_.IsPropertyCallbacks()) { return accessor_.is_identical_to(info->accessor_) && api_holder_.is_identical_to(info->api_holder_); } if (lookup_.IsConstant()) { return constant_.is_identical_to(info->constant_); } ASSERT(lookup_.IsField()); if (!info->lookup_.IsField()) return false; Representation r = access_.representation(); if (IsLoad()) { if (!info->access_.representation().IsCompatibleForLoad(r)) return false; } else { if (!info->access_.representation().IsCompatibleForStore(r)) return false; } if (info->access_.offset() != access_.offset()) return false; if (info->access_.IsInobject() != access_.IsInobject()) return false; if (IsLoad()) { if (field_maps_.is_empty()) { info->field_maps_.Clear(); } else if (!info->field_maps_.is_empty()) { for (int i = 0; i < field_maps_.length(); ++i) { info->field_maps_.AddMapIfMissing(field_maps_.at(i), info->zone()); } info->field_maps_.Sort(); } } else { // We can only merge stores that agree on their field maps. The comparison // below is safe, since we keep the field maps sorted. if (field_maps_.length() != info->field_maps_.length()) return false; for (int i = 0; i < field_maps_.length(); ++i) { if (!field_maps_.at(i).is_identical_to(info->field_maps_.at(i))) { return false; } } } info->GeneralizeRepresentation(r); info->field_type_ = info->field_type_.Combine(field_type_); return true; } bool HOptimizedGraphBuilder::PropertyAccessInfo::LookupDescriptor() { if (!type_->IsClass()) return true; map()->LookupDescriptor(NULL, *name_, &lookup_); return LoadResult(map()); } bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle<Map> map) { if (!IsLoad() && lookup_.IsProperty() && (lookup_.IsReadOnly() || !lookup_.IsCacheable())) { return false; } if (lookup_.IsField()) { // Construct the object field access. access_ = HObjectAccess::ForField(map, &lookup_, name_); // Load field map for heap objects. LoadFieldMaps(map); } else if (lookup_.IsPropertyCallbacks()) { Handle<Object> callback(lookup_.GetValueFromMap(*map), isolate()); if (!callback->IsAccessorPair()) return false; Object* raw_accessor = IsLoad() ? Handle<AccessorPair>::cast(callback)->getter() : Handle<AccessorPair>::cast(callback)->setter(); if (!raw_accessor->IsJSFunction()) return false; Handle<JSFunction> accessor = handle(JSFunction::cast(raw_accessor)); if (accessor->shared()->IsApiFunction()) { CallOptimization call_optimization(accessor); if (call_optimization.is_simple_api_call()) { CallOptimization::HolderLookup holder_lookup; Handle<Map> receiver_map = this->map(); api_holder_ = call_optimization.LookupHolderOfExpectedType( receiver_map, &holder_lookup); } } accessor_ = accessor; } else if (lookup_.IsConstant()) { constant_ = handle(lookup_.GetConstantFromMap(*map), isolate()); } return true; } void HOptimizedGraphBuilder::PropertyAccessInfo::LoadFieldMaps( Handle<Map> map) { // Clear any previously collected field maps/type. field_maps_.Clear(); field_type_ = HType::Tagged(); // Figure out the field type from the accessor map. Handle<HeapType> field_type(lookup_.GetFieldTypeFromMap(*map), isolate()); // Collect the (stable) maps from the field type. int num_field_maps = field_type->NumClasses(); if (num_field_maps == 0) return; ASSERT(access_.representation().IsHeapObject()); field_maps_.Reserve(num_field_maps, zone()); HeapType::Iterator<Map> it = field_type->Classes(); while (!it.Done()) { Handle<Map> field_map = it.Current(); if (!field_map->is_stable()) { field_maps_.Clear(); return; } field_maps_.Add(field_map, zone()); it.Advance(); } field_maps_.Sort(); ASSERT_EQ(num_field_maps, field_maps_.length()); // Determine field HType from field HeapType. field_type_ = HType::FromType<HeapType>(field_type); ASSERT(field_type_.IsHeapObject()); // Add dependency on the map that introduced the field. Map::AddDependentCompilationInfo( handle(lookup_.GetFieldOwnerFromMap(*map), isolate()), DependentCode::kFieldTypeGroup, top_info()); } bool HOptimizedGraphBuilder::PropertyAccessInfo::LookupInPrototypes() { Handle<Map> map = this->map(); while (map->prototype()->IsJSObject()) { holder_ = handle(JSObject::cast(map->prototype())); if (holder_->map()->is_deprecated()) { JSObject::TryMigrateInstance(holder_); } map = Handle<Map>(holder_->map()); if (!CanInlinePropertyAccess(ToType(map))) { lookup_.NotFound(); return false; } map->LookupDescriptor(*holder_, *name_, &lookup_); if (lookup_.IsFound()) return LoadResult(map); } lookup_.NotFound(); return true; } bool HOptimizedGraphBuilder::PropertyAccessInfo::CanAccessMonomorphic() { if (!CanInlinePropertyAccess(type_)) return false; if (IsJSObjectFieldAccessor()) return IsLoad(); if (!LookupDescriptor()) return false; if (lookup_.IsFound()) { if (IsLoad()) return true; return !lookup_.IsReadOnly() && lookup_.IsCacheable(); } if (!LookupInPrototypes()) return false; if (IsLoad()) return true; if (lookup_.IsPropertyCallbacks()) return true; Handle<Map> map = this->map(); map->LookupTransition(NULL, *name_, &lookup_); if (lookup_.IsTransitionToField() && map->unused_property_fields() > 0) { // Construct the object field access. access_ = HObjectAccess::ForField(map, &lookup_, name_); // Load field map for heap objects. LoadFieldMaps(transition()); return true; } return false; } bool HOptimizedGraphBuilder::PropertyAccessInfo::CanAccessAsMonomorphic( SmallMapList* types) { ASSERT(type_->Is(ToType(types->first()))); if (!CanAccessMonomorphic()) return false; STATIC_ASSERT(kMaxLoadPolymorphism == kMaxStorePolymorphism); if (types->length() > kMaxLoadPolymorphism) return false; HObjectAccess access = HObjectAccess::ForMap(); // bogus default if (GetJSObjectFieldAccess(&access)) { for (int i = 1; i < types->length(); ++i) { PropertyAccessInfo test_info( builder_, access_type_, ToType(types->at(i)), name_); HObjectAccess test_access = HObjectAccess::ForMap(); // bogus default if (!test_info.GetJSObjectFieldAccess(&test_access)) return false; if (!access.Equals(test_access)) return false; } return true; } // Currently only handle Type::Number as a polymorphic case. // TODO(verwaest): Support monomorphic handling of numbers with a HCheckNumber // instruction. if (type_->Is(Type::Number())) return false; // Multiple maps cannot transition to the same target map. ASSERT(!IsLoad() || !lookup_.IsTransition()); if (lookup_.IsTransition() && types->length() > 1) return false; for (int i = 1; i < types->length(); ++i) { PropertyAccessInfo test_info( builder_, access_type_, ToType(types->at(i)), name_); if (!test_info.IsCompatible(this)) return false; } return true; } static bool NeedsWrappingFor(Type* type, Handle<JSFunction> target) { return type->Is(Type::NumberOrString()) && target->shared()->strict_mode() == SLOPPY && !target->shared()->native(); } HInstruction* HOptimizedGraphBuilder::BuildMonomorphicAccess( PropertyAccessInfo* info, HValue* object, HValue* checked_object, HValue* value, BailoutId ast_id, BailoutId return_id, bool can_inline_accessor) { HObjectAccess access = HObjectAccess::ForMap(); // bogus default if (info->GetJSObjectFieldAccess(&access)) { ASSERT(info->IsLoad()); return New<HLoadNamedField>(object, checked_object, access); } HValue* checked_holder = checked_object; if (info->has_holder()) { Handle<JSObject> prototype(JSObject::cast(info->map()->prototype())); checked_holder = BuildCheckPrototypeMaps(prototype, info->holder()); } if (!info->lookup()->IsFound()) { ASSERT(info->IsLoad()); return graph()->GetConstantUndefined(); } if (info->lookup()->IsField()) { if (info->IsLoad()) { return BuildLoadNamedField(info, checked_holder); } else { return BuildStoreNamedField(info, checked_object, value); } } if (info->lookup()->IsTransition()) { ASSERT(!info->IsLoad()); return BuildStoreNamedField(info, checked_object, value); } if (info->lookup()->IsPropertyCallbacks()) { Push(checked_object); int argument_count = 1; if (!info->IsLoad()) { argument_count = 2; Push(value); } if (NeedsWrappingFor(info->type(), info->accessor())) { HValue* function = Add<HConstant>(info->accessor()); PushArgumentsFromEnvironment(argument_count); return New<HCallFunction>(function, argument_count, WRAP_AND_CALL); } else if (FLAG_inline_accessors && can_inline_accessor) { bool success = info->IsLoad() ? TryInlineGetter(info->accessor(), info->map(), ast_id, return_id) : TryInlineSetter( info->accessor(), info->map(), ast_id, return_id, value); if (success || HasStackOverflow()) return NULL; } PushArgumentsFromEnvironment(argument_count); return BuildCallConstantFunction(info->accessor(), argument_count); } ASSERT(info->lookup()->IsConstant()); if (info->IsLoad()) { return New<HConstant>(info->constant()); } else { return New<HCheckValue>(value, Handle<JSFunction>::cast(info->constant())); } } void HOptimizedGraphBuilder::HandlePolymorphicNamedFieldAccess( PropertyAccessType access_type, BailoutId ast_id, BailoutId return_id, HValue* object, HValue* value, SmallMapList* types, Handle<String> name) { // Something did not match; must use a polymorphic load. int count = 0; HBasicBlock* join = NULL; HBasicBlock* number_block = NULL; bool handled_string = false; bool handle_smi = false; STATIC_ASSERT(kMaxLoadPolymorphism == kMaxStorePolymorphism); for (int i = 0; i < types->length() && count < kMaxLoadPolymorphism; ++i) { PropertyAccessInfo info(this, access_type, ToType(types->at(i)), name); if (info.type()->Is(Type::String())) { if (handled_string) continue; handled_string = true; } if (info.CanAccessMonomorphic()) { count++; if (info.type()->Is(Type::Number())) { handle_smi = true; break; } } } count = 0; HControlInstruction* smi_check = NULL; handled_string = false; for (int i = 0; i < types->length() && count < kMaxLoadPolymorphism; ++i) { PropertyAccessInfo info(this, access_type, ToType(types->at(i)), name); if (info.type()->Is(Type::String())) { if (handled_string) continue; handled_string = true; } if (!info.CanAccessMonomorphic()) continue; if (count == 0) { join = graph()->CreateBasicBlock(); if (handle_smi) { HBasicBlock* empty_smi_block = graph()->CreateBasicBlock(); HBasicBlock* not_smi_block = graph()->CreateBasicBlock(); number_block = graph()->CreateBasicBlock(); smi_check = New<HIsSmiAndBranch>( object, empty_smi_block, not_smi_block); FinishCurrentBlock(smi_check); GotoNoSimulate(empty_smi_block, number_block); set_current_block(not_smi_block); } else { BuildCheckHeapObject(object); } } ++count; HBasicBlock* if_true = graph()->CreateBasicBlock(); HBasicBlock* if_false = graph()->CreateBasicBlock(); HUnaryControlInstruction* compare; HValue* dependency; if (info.type()->Is(Type::Number())) { Handle<Map> heap_number_map = isolate()->factory()->heap_number_map(); compare = New<HCompareMap>(object, heap_number_map, if_true, if_false); dependency = smi_check; } else if (info.type()->Is(Type::String())) { compare = New<HIsStringAndBranch>(object, if_true, if_false); dependency = compare; } else { compare = New<HCompareMap>(object, info.map(), if_true, if_false); dependency = compare; } FinishCurrentBlock(compare); if (info.type()->Is(Type::Number())) { GotoNoSimulate(if_true, number_block); if_true = number_block; } set_current_block(if_true); HInstruction* access = BuildMonomorphicAccess( &info, object, dependency, value, ast_id, return_id, FLAG_polymorphic_inlining); HValue* result = NULL; switch (access_type) { case LOAD: result = access; break; case STORE: result = value; break; } if (access == NULL) { if (HasStackOverflow()) return; } else { if (!access->IsLinked()) AddInstruction(access); if (!ast_context()->IsEffect()) Push(result); } if (current_block() != NULL) Goto(join); set_current_block(if_false); } // Finish up. Unconditionally deoptimize if we've handled all the maps we // know about and do not want to handle ones we've never seen. Otherwise // use a generic IC. if (count == types->length() && FLAG_deoptimize_uncommon_cases) { FinishExitWithHardDeoptimization("Uknown map in polymorphic access"); } else { HInstruction* instr = BuildNamedGeneric(access_type, object, name, value); AddInstruction(instr); if (!ast_context()->IsEffect()) Push(access_type == LOAD ? instr : value); if (join != NULL) { Goto(join); } else { Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); if (!ast_context()->IsEffect()) ast_context()->ReturnValue(Pop()); return; } } ASSERT(join != NULL); if (join->HasPredecessor()) { join->SetJoinId(ast_id); set_current_block(join); if (!ast_context()->IsEffect()) ast_context()->ReturnValue(Pop()); } else { set_current_block(NULL); } } static bool ComputeReceiverTypes(Expression* expr, HValue* receiver, SmallMapList** t, Zone* zone) { SmallMapList* types = expr->GetReceiverTypes(); *t = types; bool monomorphic = expr->IsMonomorphic(); if (types != NULL && receiver->HasMonomorphicJSObjectType()) { Map* root_map = receiver->GetMonomorphicJSObjectMap()->FindRootMap(); types->FilterForPossibleTransitions(root_map); monomorphic = types->length() == 1; } return monomorphic && CanInlinePropertyAccess( IC::MapToType<Type>(types->first(), zone)); } static bool AreStringTypes(SmallMapList* types) { for (int i = 0; i < types->length(); i++) { if (types->at(i)->instance_type() >= FIRST_NONSTRING_TYPE) return false; } return true; } void HOptimizedGraphBuilder::BuildStore(Expression* expr, Property* prop, BailoutId ast_id, BailoutId return_id, bool is_uninitialized) { if (!prop->key()->IsPropertyName()) { // Keyed store. HValue* value = environment()->ExpressionStackAt(0); HValue* key = environment()->ExpressionStackAt(1); HValue* object = environment()->ExpressionStackAt(2); bool has_side_effects = false; HandleKeyedElementAccess(object, key, value, expr, STORE, &has_side_effects); Drop(3); Push(value); Add<HSimulate>(return_id, REMOVABLE_SIMULATE); return ast_context()->ReturnValue(Pop()); } // Named store. HValue* value = Pop(); HValue* object = Pop(); Literal* key = prop->key()->AsLiteral(); Handle<String> name = Handle<String>::cast(key->value()); ASSERT(!name.is_null()); HInstruction* instr = BuildNamedAccess(STORE, ast_id, return_id, expr, object, name, value, is_uninitialized); if (instr == NULL) return; if (!ast_context()->IsEffect()) Push(value); AddInstruction(instr); if (instr->HasObservableSideEffects()) { Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); } if (!ast_context()->IsEffect()) Drop(1); return ast_context()->ReturnValue(value); } void HOptimizedGraphBuilder::HandlePropertyAssignment(Assignment* expr) { Property* prop = expr->target()->AsProperty(); ASSERT(prop != NULL); CHECK_ALIVE(VisitForValue(prop->obj())); if (!prop->key()->IsPropertyName()) { CHECK_ALIVE(VisitForValue(prop->key())); } CHECK_ALIVE(VisitForValue(expr->value())); BuildStore(expr, prop, expr->id(), expr->AssignmentId(), expr->IsUninitialized()); } // Because not every expression has a position and there is not common // superclass of Assignment and CountOperation, we cannot just pass the // owning expression instead of position and ast_id separately. void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( Variable* var, HValue* value, BailoutId ast_id) { LookupResult lookup(isolate()); GlobalPropertyAccess type = LookupGlobalProperty(var, &lookup, STORE); if (type == kUseCell) { Handle<GlobalObject> global(current_info()->global_object()); Handle<PropertyCell> cell(global->GetPropertyCell(&lookup)); if (cell->type()->IsConstant()) { Handle<Object> constant = cell->type()->AsConstant()->Value(); if (value->IsConstant()) { HConstant* c_value = HConstant::cast(value); if (!constant.is_identical_to(c_value->handle(isolate()))) { Add<HDeoptimize>("Constant global variable assignment", Deoptimizer::EAGER); } } else { HValue* c_constant = Add<HConstant>(constant); IfBuilder builder(this); if (constant->IsNumber()) { builder.If<HCompareNumericAndBranch>(value, c_constant, Token::EQ); } else { builder.If<HCompareObjectEqAndBranch>(value, c_constant); } builder.Then(); builder.Else(); Add<HDeoptimize>("Constant global variable assignment", Deoptimizer::EAGER); builder.End(); } } HInstruction* instr = Add<HStoreGlobalCell>(value, cell, lookup.GetPropertyDetails()); if (instr->HasObservableSideEffects()) { Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); } } else { HValue* global_object = Add<HLoadNamedField>( context(), static_cast<HValue*>(NULL), HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); HStoreNamedGeneric* instr = Add<HStoreNamedGeneric>(global_object, var->name(), value, function_strict_mode()); USE(instr); ASSERT(instr->HasObservableSideEffects()); Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); } } void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { Expression* target = expr->target(); VariableProxy* proxy = target->AsVariableProxy(); Property* prop = target->AsProperty(); ASSERT(proxy == NULL || prop == NULL); // We have a second position recorded in the FullCodeGenerator to have // type feedback for the binary operation. BinaryOperation* operation = expr->binary_operation(); if (proxy != NULL) { Variable* var = proxy->var(); if (var->mode() == LET) { return Bailout(kUnsupportedLetCompoundAssignment); } CHECK_ALIVE(VisitForValue(operation)); switch (var->location()) { case Variable::UNALLOCATED: HandleGlobalVariableAssignment(var, Top(), expr->AssignmentId()); break; case Variable::PARAMETER: case Variable::LOCAL: if (var->mode() == CONST_LEGACY) { return Bailout(kUnsupportedConstCompoundAssignment); } BindIfLive(var, Top()); break; case Variable::CONTEXT: { // Bail out if we try to mutate a parameter value in a function // using the arguments object. We do not (yet) correctly handle the // arguments property of the function. if (current_info()->scope()->arguments() != NULL) { // Parameters will be allocated to context slots. We have no // direct way to detect that the variable is a parameter so we do // a linear search of the parameter variables. int count = current_info()->scope()->num_parameters(); for (int i = 0; i < count; ++i) { if (var == current_info()->scope()->parameter(i)) { Bailout(kAssignmentToParameterFunctionUsesArgumentsObject); } } } HStoreContextSlot::Mode mode; switch (var->mode()) { case LET: mode = HStoreContextSlot::kCheckDeoptimize; break; case CONST: // This case is checked statically so no need to // perform checks here UNREACHABLE(); case CONST_LEGACY: return ast_context()->ReturnValue(Pop()); default: mode = HStoreContextSlot::kNoCheck; } HValue* context = BuildContextChainWalk(var); HStoreContextSlot* instr = Add<HStoreContextSlot>( context, var->index(), mode, Top()); if (instr->HasObservableSideEffects()) { Add<HSimulate>(expr->AssignmentId(), REMOVABLE_SIMULATE); } break; } case Variable::LOOKUP: return Bailout(kCompoundAssignmentToLookupSlot); } return ast_context()->ReturnValue(Pop()); } else if (prop != NULL) { CHECK_ALIVE(VisitForValue(prop->obj())); HValue* object = Top(); HValue* key = NULL; if ((!prop->IsFunctionPrototype() && !prop->key()->IsPropertyName()) || prop->IsStringAccess()) { CHECK_ALIVE(VisitForValue(prop->key())); key = Top(); } CHECK_ALIVE(PushLoad(prop, object, key)); CHECK_ALIVE(VisitForValue(expr->value())); HValue* right = Pop(); HValue* left = Pop(); Push(BuildBinaryOperation(operation, left, right, PUSH_BEFORE_SIMULATE)); BuildStore(expr, prop, expr->id(), expr->AssignmentId(), expr->IsUninitialized()); } else { return Bailout(kInvalidLhsInCompoundAssignment); } } void HOptimizedGraphBuilder::VisitAssignment(Assignment* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); VariableProxy* proxy = expr->target()->AsVariableProxy(); Property* prop = expr->target()->AsProperty(); ASSERT(proxy == NULL || prop == NULL); if (expr->is_compound()) { HandleCompoundAssignment(expr); return; } if (prop != NULL) { HandlePropertyAssignment(expr); } else if (proxy != NULL) { Variable* var = proxy->var(); if (var->mode() == CONST) { if (expr->op() != Token::INIT_CONST) { return Bailout(kNonInitializerAssignmentToConst); } } else if (var->mode() == CONST_LEGACY) { if (expr->op() != Token::INIT_CONST_LEGACY) { CHECK_ALIVE(VisitForValue(expr->value())); return ast_context()->ReturnValue(Pop()); } if (var->IsStackAllocated()) { // We insert a use of the old value to detect unsupported uses of const // variables (e.g. initialization inside a loop). HValue* old_value = environment()->Lookup(var); Add<HUseConst>(old_value); } } if (proxy->IsArguments()) return Bailout(kAssignmentToArguments); // Handle the assignment. switch (var->location()) { case Variable::UNALLOCATED: CHECK_ALIVE(VisitForValue(expr->value())); HandleGlobalVariableAssignment(var, Top(), expr->AssignmentId()); return ast_context()->ReturnValue(Pop()); case Variable::PARAMETER: case Variable::LOCAL: { // Perform an initialization check for let declared variables // or parameters. if (var->mode() == LET && expr->op() == Token::ASSIGN) { HValue* env_value = environment()->Lookup(var); if (env_value == graph()->GetConstantHole()) { return Bailout(kAssignmentToLetVariableBeforeInitialization); } } // We do not allow the arguments object to occur in a context where it // may escape, but assignments to stack-allocated locals are // permitted. CHECK_ALIVE(VisitForValue(expr->value(), ARGUMENTS_ALLOWED)); HValue* value = Pop(); BindIfLive(var, value); return ast_context()->ReturnValue(value); } case Variable::CONTEXT: { // Bail out if we try to mutate a parameter value in a function using // the arguments object. We do not (yet) correctly handle the // arguments property of the function. if (current_info()->scope()->arguments() != NULL) { // Parameters will rewrite to context slots. We have no direct way // to detect that the variable is a parameter. int count = current_info()->scope()->num_parameters(); for (int i = 0; i < count; ++i) { if (var == current_info()->scope()->parameter(i)) { return Bailout(kAssignmentToParameterInArgumentsObject); } } } CHECK_ALIVE(VisitForValue(expr->value())); HStoreContextSlot::Mode mode; if (expr->op() == Token::ASSIGN) { switch (var->mode()) { case LET: mode = HStoreContextSlot::kCheckDeoptimize; break; case CONST: // This case is checked statically so no need to // perform checks here UNREACHABLE(); case CONST_LEGACY: return ast_context()->ReturnValue(Pop()); default: mode = HStoreContextSlot::kNoCheck; } } else if (expr->op() == Token::INIT_VAR || expr->op() == Token::INIT_LET || expr->op() == Token::INIT_CONST) { mode = HStoreContextSlot::kNoCheck; } else { ASSERT(expr->op() == Token::INIT_CONST_LEGACY); mode = HStoreContextSlot::kCheckIgnoreAssignment; } HValue* context = BuildContextChainWalk(var); HStoreContextSlot* instr = Add<HStoreContextSlot>( context, var->index(), mode, Top()); if (instr->HasObservableSideEffects()) { Add<HSimulate>(expr->AssignmentId(), REMOVABLE_SIMULATE); } return ast_context()->ReturnValue(Pop()); } case Variable::LOOKUP: return Bailout(kAssignmentToLOOKUPVariable); } } else { return Bailout(kInvalidLeftHandSideInAssignment); } } void HOptimizedGraphBuilder::VisitYield(Yield* expr) { // Generators are not optimized, so we should never get here. UNREACHABLE(); } void HOptimizedGraphBuilder::VisitThrow(Throw* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); // We don't optimize functions with invalid left-hand sides in // assignments, count operations, or for-in. Consequently throw can // currently only occur in an effect context. ASSERT(ast_context()->IsEffect()); CHECK_ALIVE(VisitForValue(expr->exception())); HValue* value = environment()->Pop(); if (!FLAG_hydrogen_track_positions) SetSourcePosition(expr->position()); Add<HPushArguments>(value); Add<HCallRuntime>(isolate()->factory()->empty_string(), Runtime::FunctionForId(Runtime::kHiddenThrow), 1); Add<HSimulate>(expr->id()); // If the throw definitely exits the function, we can finish with a dummy // control flow at this point. This is not the case if the throw is inside // an inlined function which may be replaced. if (call_context() == NULL) { FinishExitCurrentBlock(New<HAbnormalExit>()); } } HInstruction* HGraphBuilder::AddLoadStringInstanceType(HValue* string) { if (string->IsConstant()) { HConstant* c_string = HConstant::cast(string); if (c_string->HasStringValue()) { return Add<HConstant>(c_string->StringValue()->map()->instance_type()); } } return Add<HLoadNamedField>( Add<HLoadNamedField>(string, static_cast<HValue*>(NULL), HObjectAccess::ForMap()), static_cast<HValue*>(NULL), HObjectAccess::ForMapInstanceType()); } HInstruction* HGraphBuilder::AddLoadStringLength(HValue* string) { if (string->IsConstant()) { HConstant* c_string = HConstant::cast(string); if (c_string->HasStringValue()) { return Add<HConstant>(c_string->StringValue()->length()); } } return Add<HLoadNamedField>(string, static_cast<HValue*>(NULL), HObjectAccess::ForStringLength()); } HInstruction* HOptimizedGraphBuilder::BuildNamedGeneric( PropertyAccessType access_type, HValue* object, Handle<String> name, HValue* value, bool is_uninitialized) { if (is_uninitialized) { Add<HDeoptimize>("Insufficient type feedback for generic named access", Deoptimizer::SOFT); } if (access_type == LOAD) { return New<HLoadNamedGeneric>(object, name); } else { return New<HStoreNamedGeneric>(object, name, value, function_strict_mode()); } } HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( PropertyAccessType access_type, HValue* object, HValue* key, HValue* value) { if (access_type == LOAD) { return New<HLoadKeyedGeneric>(object, key); } else { return New<HStoreKeyedGeneric>(object, key, value, function_strict_mode()); } } LoadKeyedHoleMode HOptimizedGraphBuilder::BuildKeyedHoleMode(Handle<Map> map) { // Loads from a "stock" fast holey double arrays can elide the hole check. LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE; if (*map == isolate()->get_initial_js_array_map(FAST_HOLEY_DOUBLE_ELEMENTS) && isolate()->IsFastArrayConstructorPrototypeChainIntact()) { Handle<JSObject> prototype(JSObject::cast(map->prototype()), isolate()); Handle<JSObject> object_prototype = isolate()->initial_object_prototype(); BuildCheckPrototypeMaps(prototype, object_prototype); load_mode = ALLOW_RETURN_HOLE; graph()->MarkDependsOnEmptyArrayProtoElements(); } return load_mode; } HInstruction* HOptimizedGraphBuilder::BuildMonomorphicElementAccess( HValue* object, HValue* key, HValue* val, HValue* dependency, Handle<Map> map, PropertyAccessType access_type, KeyedAccessStoreMode store_mode) { HCheckMaps* checked_object = Add<HCheckMaps>(object, map, dependency); if (dependency) { checked_object->ClearDependsOnFlag(kElementsKind); } if (access_type == STORE && map->prototype()->IsJSObject()) { // monomorphic stores need a prototype chain check because shape // changes could allow callbacks on elements in the chain that // aren't compatible with monomorphic keyed stores. Handle<JSObject> prototype(JSObject::cast(map->prototype())); JSObject* holder = JSObject::cast(map->prototype()); while (!holder->GetPrototype()->IsNull()) { holder = JSObject::cast(holder->GetPrototype()); } BuildCheckPrototypeMaps(prototype, Handle<JSObject>(JSObject::cast(holder))); } LoadKeyedHoleMode load_mode = BuildKeyedHoleMode(map); return BuildUncheckedMonomorphicElementAccess( checked_object, key, val, map->instance_type() == JS_ARRAY_TYPE, map->elements_kind(), access_type, load_mode, store_mode); } HInstruction* HOptimizedGraphBuilder::TryBuildConsolidatedElementLoad( HValue* object, HValue* key, HValue* val, SmallMapList* maps) { // For polymorphic loads of similar elements kinds (i.e. all tagged or all // double), always use the "worst case" code without a transition. This is // much faster than transitioning the elements to the worst case, trading a // HTransitionElements for a HCheckMaps, and avoiding mutation of the array. bool has_double_maps = false; bool has_smi_or_object_maps = false; bool has_js_array_access = false; bool has_non_js_array_access = false; bool has_seen_holey_elements = false; Handle<Map> most_general_consolidated_map; for (int i = 0; i < maps->length(); ++i) { Handle<Map> map = maps->at(i); if (!map->IsJSObjectMap()) return NULL; // Don't allow mixing of JSArrays with JSObjects. if (map->instance_type() == JS_ARRAY_TYPE) { if (has_non_js_array_access) return NULL; has_js_array_access = true; } else if (has_js_array_access) { return NULL; } else { has_non_js_array_access = true; } // Don't allow mixed, incompatible elements kinds. if (map->has_fast_double_elements()) { if (has_smi_or_object_maps) return NULL; has_double_maps = true; } else if (map->has_fast_smi_or_object_elements()) { if (has_double_maps) return NULL; has_smi_or_object_maps = true; } else { return NULL; } // Remember if we've ever seen holey elements. if (IsHoleyElementsKind(map->elements_kind())) { has_seen_holey_elements = true; } // Remember the most general elements kind, the code for its load will // properly handle all of the more specific cases. if ((i == 0) || IsMoreGeneralElementsKindTransition( most_general_consolidated_map->elements_kind(), map->elements_kind())) { most_general_consolidated_map = map; } } if (!has_double_maps && !has_smi_or_object_maps) return NULL; HCheckMaps* checked_object = Add<HCheckMaps>(object, maps); // FAST_ELEMENTS is considered more general than FAST_HOLEY_SMI_ELEMENTS. // If we've seen both, the consolidated load must use FAST_HOLEY_ELEMENTS. ElementsKind consolidated_elements_kind = has_seen_holey_elements ? GetHoleyElementsKind(most_general_consolidated_map->elements_kind()) : most_general_consolidated_map->elements_kind(); HInstruction* instr = BuildUncheckedMonomorphicElementAccess( checked_object, key, val, most_general_consolidated_map->instance_type() == JS_ARRAY_TYPE, consolidated_elements_kind, LOAD, NEVER_RETURN_HOLE, STANDARD_STORE); return instr; } HValue* HOptimizedGraphBuilder::HandlePolymorphicElementAccess( HValue* object, HValue* key, HValue* val, SmallMapList* maps, PropertyAccessType access_type, KeyedAccessStoreMode store_mode, bool* has_side_effects) { *has_side_effects = false; BuildCheckHeapObject(object); if (access_type == LOAD) { HInstruction* consolidated_load = TryBuildConsolidatedElementLoad(object, key, val, maps); if (consolidated_load != NULL) { *has_side_effects |= consolidated_load->HasObservableSideEffects(); return consolidated_load; } } // Elements_kind transition support. MapHandleList transition_target(maps->length()); // Collect possible transition targets. MapHandleList possible_transitioned_maps(maps->length()); for (int i = 0; i < maps->length(); ++i) { Handle<Map> map = maps->at(i); ElementsKind elements_kind = map->elements_kind(); if (IsFastElementsKind(elements_kind) && elements_kind != GetInitialFastElementsKind()) { possible_transitioned_maps.Add(map); } if (elements_kind == SLOPPY_ARGUMENTS_ELEMENTS) { HInstruction* result = BuildKeyedGeneric(access_type, object, key, val); *has_side_effects = result->HasObservableSideEffects(); return AddInstruction(result); } } // Get transition target for each map (NULL == no transition). for (int i = 0; i < maps->length(); ++i) { Handle<Map> map = maps->at(i); Handle<Map> transitioned_map = map->FindTransitionedMap(&possible_transitioned_maps); transition_target.Add(transitioned_map); } MapHandleList untransitionable_maps(maps->length()); HTransitionElementsKind* transition = NULL; for (int i = 0; i < maps->length(); ++i) { Handle<Map> map = maps->at(i); ASSERT(map->IsMap()); if (!transition_target.at(i).is_null()) { ASSERT(Map::IsValidElementsTransition( map->elements_kind(), transition_target.at(i)->elements_kind())); transition = Add<HTransitionElementsKind>(object, map, transition_target.at(i)); } else { untransitionable_maps.Add(map); } } // If only one map is left after transitioning, handle this case // monomorphically. ASSERT(untransitionable_maps.length() >= 1); if (untransitionable_maps.length() == 1) { Handle<Map> untransitionable_map = untransitionable_maps[0]; HInstruction* instr = NULL; if (untransitionable_map->has_slow_elements_kind() || !untransitionable_map->IsJSObjectMap()) { instr = AddInstruction(BuildKeyedGeneric(access_type, object, key, val)); } else { instr = BuildMonomorphicElementAccess( object, key, val, transition, untransitionable_map, access_type, store_mode); } *has_side_effects |= instr->HasObservableSideEffects(); return access_type == STORE ? NULL : instr; } HBasicBlock* join = graph()->CreateBasicBlock(); for (int i = 0; i < untransitionable_maps.length(); ++i) { Handle<Map> map = untransitionable_maps[i]; if (!map->IsJSObjectMap()) continue; ElementsKind elements_kind = map->elements_kind(); HBasicBlock* this_map = graph()->CreateBasicBlock(); HBasicBlock* other_map = graph()->CreateBasicBlock(); HCompareMap* mapcompare = New<HCompareMap>(object, map, this_map, other_map); FinishCurrentBlock(mapcompare); set_current_block(this_map); HInstruction* access = NULL; if (IsDictionaryElementsKind(elements_kind)) { access = AddInstruction(BuildKeyedGeneric(access_type, object, key, val)); } else { ASSERT(IsFastElementsKind(elements_kind) || IsExternalArrayElementsKind(elements_kind) || IsFixedTypedArrayElementsKind(elements_kind)); LoadKeyedHoleMode load_mode = BuildKeyedHoleMode(map); // Happily, mapcompare is a checked object. access = BuildUncheckedMonomorphicElementAccess( mapcompare, key, val, map->instance_type() == JS_ARRAY_TYPE, elements_kind, access_type, load_mode, store_mode); } *has_side_effects |= access->HasObservableSideEffects(); // The caller will use has_side_effects and add a correct Simulate. access->SetFlag(HValue::kHasNoObservableSideEffects); if (access_type == LOAD) { Push(access); } NoObservableSideEffectsScope scope(this); GotoNoSimulate(join); set_current_block(other_map); } // Ensure that we visited at least one map above that goes to join. This is // necessary because FinishExitWithHardDeoptimization does an AbnormalExit // rather than joining the join block. If this becomes an issue, insert a // generic access in the case length() == 0. ASSERT(join->predecessors()->length() > 0); // Deopt if none of the cases matched. NoObservableSideEffectsScope scope(this); FinishExitWithHardDeoptimization("Unknown map in polymorphic element access"); set_current_block(join); return access_type == STORE ? NULL : Pop(); } HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( HValue* obj, HValue* key, HValue* val, Expression* expr, PropertyAccessType access_type, bool* has_side_effects) { ASSERT(!expr->IsPropertyName()); HInstruction* instr = NULL; SmallMapList* types; bool monomorphic = ComputeReceiverTypes(expr, obj, &types, zone()); bool force_generic = false; if (access_type == STORE && (monomorphic || (types != NULL && !types->is_empty()))) { // Stores can't be mono/polymorphic if their prototype chain has dictionary // elements. However a receiver map that has dictionary elements itself // should be left to normal mono/poly behavior (the other maps may benefit // from highly optimized stores). for (int i = 0; i < types->length(); i++) { Handle<Map> current_map = types->at(i); if (current_map->DictionaryElementsInPrototypeChainOnly()) { force_generic = true; monomorphic = false; break; } } } if (monomorphic) { Handle<Map> map = types->first(); if (map->has_slow_elements_kind() || !map->IsJSObjectMap()) { instr = AddInstruction(BuildKeyedGeneric(access_type, obj, key, val)); } else { BuildCheckHeapObject(obj); instr = BuildMonomorphicElementAccess( obj, key, val, NULL, map, access_type, expr->GetStoreMode()); } } else if (!force_generic && (types != NULL && !types->is_empty())) { return HandlePolymorphicElementAccess( obj, key, val, types, access_type, expr->GetStoreMode(), has_side_effects); } else { if (access_type == STORE) { if (expr->IsAssignment() && expr->AsAssignment()->HasNoTypeInformation()) { Add<HDeoptimize>("Insufficient type feedback for keyed store", Deoptimizer::SOFT); } } else { if (expr->AsProperty()->HasNoTypeInformation()) { Add<HDeoptimize>("Insufficient type feedback for keyed load", Deoptimizer::SOFT); } } instr = AddInstruction(BuildKeyedGeneric(access_type, obj, key, val)); } *has_side_effects = instr->HasObservableSideEffects(); return instr; } void HOptimizedGraphBuilder::EnsureArgumentsArePushedForAccess() { // Outermost function already has arguments on the stack. if (function_state()->outer() == NULL) return; if (function_state()->arguments_pushed()) return; // Push arguments when entering inlined function. HEnterInlined* entry = function_state()->entry(); entry->set_arguments_pushed(); HArgumentsObject* arguments = entry->arguments_object(); const ZoneList<HValue*>* arguments_values = arguments->arguments_values(); HInstruction* insert_after = entry; for (int i = 0; i < arguments_values->length(); i++) { HValue* argument = arguments_values->at(i); HInstruction* push_argument = New<HPushArguments>(argument); push_argument->InsertAfter(insert_after); insert_after = push_argument; } HArgumentsElements* arguments_elements = New<HArgumentsElements>(true); arguments_elements->ClearFlag(HValue::kUseGVN); arguments_elements->InsertAfter(insert_after); function_state()->set_arguments_elements(arguments_elements); } bool HOptimizedGraphBuilder::TryArgumentsAccess(Property* expr) { VariableProxy* proxy = expr->obj()->AsVariableProxy(); if (proxy == NULL) return false; if (!proxy->var()->IsStackAllocated()) return false; if (!environment()->Lookup(proxy->var())->CheckFlag(HValue::kIsArguments)) { return false; } HInstruction* result = NULL; if (expr->key()->IsPropertyName()) { Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); if (!name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("length"))) return false; if (function_state()->outer() == NULL) { HInstruction* elements = Add<HArgumentsElements>(false); result = New<HArgumentsLength>(elements); } else { // Number of arguments without receiver. int argument_count = environment()-> arguments_environment()->parameter_count() - 1; result = New<HConstant>(argument_count); } } else { Push(graph()->GetArgumentsObject()); CHECK_ALIVE_OR_RETURN(VisitForValue(expr->key()), true); HValue* key = Pop(); Drop(1); // Arguments object. if (function_state()->outer() == NULL) { HInstruction* elements = Add<HArgumentsElements>(false); HInstruction* length = Add<HArgumentsLength>(elements); HInstruction* checked_key = Add<HBoundsCheck>(key, length); result = New<HAccessArgumentsAt>(elements, length, checked_key); } else { EnsureArgumentsArePushedForAccess(); // Number of arguments without receiver. HInstruction* elements = function_state()->arguments_elements(); int argument_count = environment()-> arguments_environment()->parameter_count() - 1; HInstruction* length = Add<HConstant>(argument_count); HInstruction* checked_key = Add<HBoundsCheck>(key, length); result = New<HAccessArgumentsAt>(elements, length, checked_key); } } ast_context()->ReturnInstruction(result, expr->id()); return true; } HInstruction* HOptimizedGraphBuilder::BuildNamedAccess( PropertyAccessType access, BailoutId ast_id, BailoutId return_id, Expression* expr, HValue* object, Handle<String> name, HValue* value, bool is_uninitialized) { SmallMapList* types; ComputeReceiverTypes(expr, object, &types, zone()); ASSERT(types != NULL); if (types->length() > 0) { PropertyAccessInfo info(this, access, ToType(types->first()), name); if (!info.CanAccessAsMonomorphic(types)) { HandlePolymorphicNamedFieldAccess( access, ast_id, return_id, object, value, types, name); return NULL; } HValue* checked_object; // Type::Number() is only supported by polymorphic load/call handling. ASSERT(!info.type()->Is(Type::Number())); BuildCheckHeapObject(object); if (AreStringTypes(types)) { checked_object = Add<HCheckInstanceType>(object, HCheckInstanceType::IS_STRING); } else { checked_object = Add<HCheckMaps>(object, types); } return BuildMonomorphicAccess( &info, object, checked_object, value, ast_id, return_id); } return BuildNamedGeneric(access, object, name, value, is_uninitialized); } void HOptimizedGraphBuilder::PushLoad(Property* expr, HValue* object, HValue* key) { ValueContext for_value(this, ARGUMENTS_NOT_ALLOWED); Push(object); if (key != NULL) Push(key); BuildLoad(expr, expr->LoadId()); } void HOptimizedGraphBuilder::BuildLoad(Property* expr, BailoutId ast_id) { HInstruction* instr = NULL; if (expr->IsStringAccess()) { HValue* index = Pop(); HValue* string = Pop(); HInstruction* char_code = BuildStringCharCodeAt(string, index); AddInstruction(char_code); instr = NewUncasted<HStringCharFromCode>(char_code); } else if (expr->IsFunctionPrototype()) { HValue* function = Pop(); BuildCheckHeapObject(function); instr = New<HLoadFunctionPrototype>(function); } else if (expr->key()->IsPropertyName()) { Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); HValue* object = Pop(); instr = BuildNamedAccess(LOAD, ast_id, expr->LoadId(), expr, object, name, NULL, expr->IsUninitialized()); if (instr == NULL) return; if (instr->IsLinked()) return ast_context()->ReturnValue(instr); } else { HValue* key = Pop(); HValue* obj = Pop(); bool has_side_effects = false; HValue* load = HandleKeyedElementAccess( obj, key, NULL, expr, LOAD, &has_side_effects); if (has_side_effects) { if (ast_context()->IsEffect()) { Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); } else { Push(load); Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); Drop(1); } } return ast_context()->ReturnValue(load); } return ast_context()->ReturnInstruction(instr, ast_id); } void HOptimizedGraphBuilder::VisitProperty(Property* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); if (TryArgumentsAccess(expr)) return; CHECK_ALIVE(VisitForValue(expr->obj())); if ((!expr->IsFunctionPrototype() && !expr->key()->IsPropertyName()) || expr->IsStringAccess()) { CHECK_ALIVE(VisitForValue(expr->key())); } BuildLoad(expr, expr->id()); } HInstruction* HGraphBuilder::BuildConstantMapCheck(Handle<JSObject> constant) { HCheckMaps* check = Add<HCheckMaps>( Add<HConstant>(constant), handle(constant->map())); check->ClearDependsOnFlag(kElementsKind); return check; } HInstruction* HGraphBuilder::BuildCheckPrototypeMaps(Handle<JSObject> prototype, Handle<JSObject> holder) { while (holder.is_null() || !prototype.is_identical_to(holder)) { BuildConstantMapCheck(prototype); Object* next_prototype = prototype->GetPrototype(); if (next_prototype->IsNull()) return NULL; CHECK(next_prototype->IsJSObject()); prototype = handle(JSObject::cast(next_prototype)); } return BuildConstantMapCheck(prototype); } void HOptimizedGraphBuilder::AddCheckPrototypeMaps(Handle<JSObject> holder, Handle<Map> receiver_map) { if (!holder.is_null()) { Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype())); BuildCheckPrototypeMaps(prototype, holder); } } HInstruction* HOptimizedGraphBuilder::NewPlainFunctionCall( HValue* fun, int argument_count, bool pass_argument_count) { return New<HCallJSFunction>( fun, argument_count, pass_argument_count); } HInstruction* HOptimizedGraphBuilder::NewArgumentAdaptorCall( HValue* fun, HValue* context, int argument_count, HValue* expected_param_count) { CallInterfaceDescriptor* descriptor = isolate()->call_descriptor(Isolate::ArgumentAdaptorCall); HValue* arity = Add<HConstant>(argument_count - 1); HValue* op_vals[] = { fun, context, arity, expected_param_count }; Handle<Code> adaptor = isolate()->builtins()->ArgumentsAdaptorTrampoline(); HConstant* adaptor_value = Add<HConstant>(adaptor); return New<HCallWithDescriptor>( adaptor_value, argument_count, descriptor, Vector<HValue*>(op_vals, descriptor->environment_length())); } HInstruction* HOptimizedGraphBuilder::BuildCallConstantFunction( Handle<JSFunction> jsfun, int argument_count) { HValue* target = Add<HConstant>(jsfun); // For constant functions, we try to avoid calling the // argument adaptor and instead call the function directly int formal_parameter_count = jsfun->shared()->formal_parameter_count(); bool dont_adapt_arguments = (formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel); int arity = argument_count - 1; bool can_invoke_directly = dont_adapt_arguments || formal_parameter_count == arity; if (can_invoke_directly) { if (jsfun.is_identical_to(current_info()->closure())) { graph()->MarkRecursive(); } return NewPlainFunctionCall(target, argument_count, dont_adapt_arguments); } else { HValue* param_count_value = Add<HConstant>(formal_parameter_count); HValue* context = Add<HLoadNamedField>( target, static_cast<HValue*>(NULL), HObjectAccess::ForFunctionContextPointer()); return NewArgumentAdaptorCall(target, context, argument_count, param_count_value); } UNREACHABLE(); return NULL; } class FunctionSorter { public: FunctionSorter(int index = 0, int ticks = 0, int size = 0) : index_(index), ticks_(ticks), size_(size) { } int index() const { return index_; } int ticks() const { return ticks_; } int size() const { return size_; } private: int index_; int ticks_; int size_; }; inline bool operator<(const FunctionSorter& lhs, const FunctionSorter& rhs) { int diff = lhs.ticks() - rhs.ticks(); if (diff != 0) return diff > 0; return lhs.size() < rhs.size(); } void HOptimizedGraphBuilder::HandlePolymorphicCallNamed( Call* expr, HValue* receiver, SmallMapList* types, Handle<String> name) { int argument_count = expr->arguments()->length() + 1; // Includes receiver. FunctionSorter order[kMaxCallPolymorphism]; bool handle_smi = false; bool handled_string = false; int ordered_functions = 0; for (int i = 0; i < types->length() && ordered_functions < kMaxCallPolymorphism; ++i) { PropertyAccessInfo info(this, LOAD, ToType(types->at(i)), name); if (info.CanAccessMonomorphic() && info.lookup()->IsConstant() && info.constant()->IsJSFunction()) { if (info.type()->Is(Type::String())) { if (handled_string) continue; handled_string = true; } Handle<JSFunction> target = Handle<JSFunction>::cast(info.constant()); if (info.type()->Is(Type::Number())) { handle_smi = true; } expr->set_target(target); order[ordered_functions++] = FunctionSorter( i, target->shared()->profiler_ticks(), InliningAstSize(target)); } } std::sort(order, order + ordered_functions); HBasicBlock* number_block = NULL; HBasicBlock* join = NULL; handled_string = false; int count = 0; for (int fn = 0; fn < ordered_functions; ++fn) { int i = order[fn].index(); PropertyAccessInfo info(this, LOAD, ToType(types->at(i)), name); if (info.type()->Is(Type::String())) { if (handled_string) continue; handled_string = true; } // Reloads the target. info.CanAccessMonomorphic(); Handle<JSFunction> target = Handle<JSFunction>::cast(info.constant()); expr->set_target(target); if (count == 0) { // Only needed once. join = graph()->CreateBasicBlock(); if (handle_smi) { HBasicBlock* empty_smi_block = graph()->CreateBasicBlock(); HBasicBlock* not_smi_block = graph()->CreateBasicBlock(); number_block = graph()->CreateBasicBlock(); FinishCurrentBlock(New<HIsSmiAndBranch>( receiver, empty_smi_block, not_smi_block)); GotoNoSimulate(empty_smi_block, number_block); set_current_block(not_smi_block); } else { BuildCheckHeapObject(receiver); } } ++count; HBasicBlock* if_true = graph()->CreateBasicBlock(); HBasicBlock* if_false = graph()->CreateBasicBlock(); HUnaryControlInstruction* compare; Handle<Map> map = info.map(); if (info.type()->Is(Type::Number())) { Handle<Map> heap_number_map = isolate()->factory()->heap_number_map(); compare = New<HCompareMap>(receiver, heap_number_map, if_true, if_false); } else if (info.type()->Is(Type::String())) { compare = New<HIsStringAndBranch>(receiver, if_true, if_false); } else { compare = New<HCompareMap>(receiver, map, if_true, if_false); } FinishCurrentBlock(compare); if (info.type()->Is(Type::Number())) { GotoNoSimulate(if_true, number_block); if_true = number_block; } set_current_block(if_true); AddCheckPrototypeMaps(info.holder(), map); HValue* function = Add<HConstant>(expr->target()); environment()->SetExpressionStackAt(0, function); Push(receiver); CHECK_ALIVE(VisitExpressions(expr->arguments())); bool needs_wrapping = NeedsWrappingFor(info.type(), target); bool try_inline = FLAG_polymorphic_inlining && !needs_wrapping; if (FLAG_trace_inlining && try_inline) { Handle<JSFunction> caller = current_info()->closure(); SmartArrayPointer<char> caller_name = caller->shared()->DebugName()->ToCString(); PrintF("Trying to inline the polymorphic call to %s from %s\n", name->ToCString().get(), caller_name.get()); } if (try_inline && TryInlineCall(expr)) { // Trying to inline will signal that we should bailout from the // entire compilation by setting stack overflow on the visitor. if (HasStackOverflow()) return; } else { // Since HWrapReceiver currently cannot actually wrap numbers and strings, // use the regular CallFunctionStub for method calls to wrap the receiver. // TODO(verwaest): Support creation of value wrappers directly in // HWrapReceiver. HInstruction* call = needs_wrapping ? NewUncasted<HCallFunction>( function, argument_count, WRAP_AND_CALL) : BuildCallConstantFunction(target, argument_count); PushArgumentsFromEnvironment(argument_count); AddInstruction(call); Drop(1); // Drop the function. if (!ast_context()->IsEffect()) Push(call); } if (current_block() != NULL) Goto(join); set_current_block(if_false); } // Finish up. Unconditionally deoptimize if we've handled all the maps we // know about and do not want to handle ones we've never seen. Otherwise // use a generic IC. if (ordered_functions == types->length() && FLAG_deoptimize_uncommon_cases) { FinishExitWithHardDeoptimization("Unknown map in polymorphic call"); } else { Property* prop = expr->expression()->AsProperty(); HInstruction* function = BuildNamedGeneric( LOAD, receiver, name, NULL, prop->IsUninitialized()); AddInstruction(function); Push(function); AddSimulate(prop->LoadId(), REMOVABLE_SIMULATE); environment()->SetExpressionStackAt(1, function); environment()->SetExpressionStackAt(0, receiver); CHECK_ALIVE(VisitExpressions(expr->arguments())); CallFunctionFlags flags = receiver->type().IsJSObject() ? NO_CALL_FUNCTION_FLAGS : CALL_AS_METHOD; HInstruction* call = New<HCallFunction>( function, argument_count, flags); PushArgumentsFromEnvironment(argument_count); Drop(1); // Function. if (join != NULL) { AddInstruction(call); if (!ast_context()->IsEffect()) Push(call); Goto(join); } else { return ast_context()->ReturnInstruction(call, expr->id()); } } // We assume that control flow is always live after an expression. So // even without predecessors to the join block, we set it as the exit // block and continue by adding instructions there. ASSERT(join != NULL); if (join->HasPredecessor()) { set_current_block(join); join->SetJoinId(expr->id()); if (!ast_context()->IsEffect()) return ast_context()->ReturnValue(Pop()); } else { set_current_block(NULL); } } void HOptimizedGraphBuilder::TraceInline(Handle<JSFunction> target, Handle<JSFunction> caller, const char* reason) { if (FLAG_trace_inlining) { SmartArrayPointer<char> target_name = target->shared()->DebugName()->ToCString(); SmartArrayPointer<char> caller_name = caller->shared()->DebugName()->ToCString(); if (reason == NULL) { PrintF("Inlined %s called from %s.\n", target_name.get(), caller_name.get()); } else { PrintF("Did not inline %s called from %s (%s).\n", target_name.get(), caller_name.get(), reason); } } } static const int kNotInlinable = 1000000000; int HOptimizedGraphBuilder::InliningAstSize(Handle<JSFunction> target) { if (!FLAG_use_inlining) return kNotInlinable; // Precondition: call is monomorphic and we have found a target with the // appropriate arity. Handle<JSFunction> caller = current_info()->closure(); Handle<SharedFunctionInfo> target_shared(target->shared()); // Always inline builtins marked for inlining. if (target->IsBuiltin()) { return target_shared->inline_builtin() ? 0 : kNotInlinable; } if (target_shared->IsApiFunction()) { TraceInline(target, caller, "target is api function"); return kNotInlinable; } // Do a quick check on source code length to avoid parsing large // inlining candidates. if (target_shared->SourceSize() > Min(FLAG_max_inlined_source_size, kUnlimitedMaxInlinedSourceSize)) { TraceInline(target, caller, "target text too big"); return kNotInlinable; } // Target must be inlineable. if (!target_shared->IsInlineable()) { TraceInline(target, caller, "target not inlineable"); return kNotInlinable; } if (target_shared->dont_inline() || target_shared->dont_optimize()) { TraceInline(target, caller, "target contains unsupported syntax [early]"); return kNotInlinable; } int nodes_added = target_shared->ast_node_count(); return nodes_added; } bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, int arguments_count, HValue* implicit_return_value, BailoutId ast_id, BailoutId return_id, InliningKind inlining_kind, HSourcePosition position) { int nodes_added = InliningAstSize(target); if (nodes_added == kNotInlinable) return false; Handle<JSFunction> caller = current_info()->closure(); if (nodes_added > Min(FLAG_max_inlined_nodes, kUnlimitedMaxInlinedNodes)) { TraceInline(target, caller, "target AST is too large [early]"); return false; } // Don't inline deeper than the maximum number of inlining levels. HEnvironment* env = environment(); int current_level = 1; while (env->outer() != NULL) { if (current_level == FLAG_max_inlining_levels) { TraceInline(target, caller, "inline depth limit reached"); return false; } if (env->outer()->frame_type() == JS_FUNCTION) { current_level++; } env = env->outer(); } // Don't inline recursive functions. for (FunctionState* state = function_state(); state != NULL; state = state->outer()) { if (*state->compilation_info()->closure() == *target) { TraceInline(target, caller, "target is recursive"); return false; } } // We don't want to add more than a certain number of nodes from inlining. if (inlined_count_ > Min(FLAG_max_inlined_nodes_cumulative, kUnlimitedMaxInlinedNodesCumulative)) { TraceInline(target, caller, "cumulative AST node limit reached"); return false; } // Parse and allocate variables. CompilationInfo target_info(target, zone()); // Use the same AstValueFactory for creating strings in the sub-compilation // step, but don't transfer ownership to target_info. target_info.SetAstValueFactory(top_info()->ast_value_factory(), false); Handle<SharedFunctionInfo> target_shared(target->shared()); if (!Parser::Parse(&target_info) || !Scope::Analyze(&target_info)) { if (target_info.isolate()->has_pending_exception()) { // Parse or scope error, never optimize this function. SetStackOverflow(); target_shared->DisableOptimization(kParseScopeError); } TraceInline(target, caller, "parse failure"); return false; } if (target_info.scope()->num_heap_slots() > 0) { TraceInline(target, caller, "target has context-allocated variables"); return false; } FunctionLiteral* function = target_info.function(); // The following conditions must be checked again after re-parsing, because // earlier the information might not have been complete due to lazy parsing. nodes_added = function->ast_node_count(); if (nodes_added > Min(FLAG_max_inlined_nodes, kUnlimitedMaxInlinedNodes)) { TraceInline(target, caller, "target AST is too large [late]"); return false; } AstProperties::Flags* flags(function->flags()); if (flags->Contains(kDontInline) || function->dont_optimize()) { TraceInline(target, caller, "target contains unsupported syntax [late]"); return false; } // If the function uses the arguments object check that inlining of functions // with arguments object is enabled and the arguments-variable is // stack allocated. if (function->scope()->arguments() != NULL) { if (!FLAG_inline_arguments) { TraceInline(target, caller, "target uses arguments object"); return false; } if (!function->scope()->arguments()->IsStackAllocated()) { TraceInline(target, caller, "target uses non-stackallocated arguments object"); return false; } } // All declarations must be inlineable. ZoneList<Declaration*>* decls = target_info.scope()->declarations(); int decl_count = decls->length(); for (int i = 0; i < decl_count; ++i) { if (!decls->at(i)->IsInlineable()) { TraceInline(target, caller, "target has non-trivial declaration"); return false; } } // Generate the deoptimization data for the unoptimized version of // the target function if we don't already have it. if (!target_shared->has_deoptimization_support()) { // Note that we compile here using the same AST that we will use for // generating the optimized inline code. target_info.EnableDeoptimizationSupport(); if (!FullCodeGenerator::MakeCode(&target_info)) { TraceInline(target, caller, "could not generate deoptimization info"); return false; } if (target_shared->scope_info() == ScopeInfo::Empty(isolate())) { // The scope info might not have been set if a lazily compiled // function is inlined before being called for the first time. Handle<ScopeInfo> target_scope_info = ScopeInfo::Create(target_info.scope(), zone()); target_shared->set_scope_info(*target_scope_info); } target_shared->EnableDeoptimizationSupport(*target_info.code()); target_shared->set_feedback_vector(*target_info.feedback_vector()); Compiler::RecordFunctionCompilation(Logger::FUNCTION_TAG, &target_info, target_shared); } // ---------------------------------------------------------------- // After this point, we've made a decision to inline this function (so // TryInline should always return true). // Type-check the inlined function. ASSERT(target_shared->has_deoptimization_support()); AstTyper::Run(&target_info); int function_id = graph()->TraceInlinedFunction(target_shared, position); // Save the pending call context. Set up new one for the inlined function. // The function state is new-allocated because we need to delete it // in two different places. FunctionState* target_state = new FunctionState( this, &target_info, inlining_kind, function_id); HConstant* undefined = graph()->GetConstantUndefined(); HEnvironment* inner_env = environment()->CopyForInlining(target, arguments_count, function, undefined, function_state()->inlining_kind()); HConstant* context = Add<HConstant>(Handle<Context>(target->context())); inner_env->BindContext(context); HArgumentsObject* arguments_object = NULL; // If the function uses arguments object create and bind one, also copy // current arguments values to use them for materialization. if (function->scope()->arguments() != NULL) { ASSERT(function->scope()->arguments()->IsStackAllocated()); HEnvironment* arguments_env = inner_env->arguments_environment(); int arguments_count = arguments_env->parameter_count(); arguments_object = Add<HArgumentsObject>(arguments_count); inner_env->Bind(function->scope()->arguments(), arguments_object); for (int i = 0; i < arguments_count; i++) { arguments_object->AddArgument(arguments_env->Lookup(i), zone()); } } // Capture the state before invoking the inlined function for deopt in the // inlined function. This simulate has no bailout-id since it's not directly // reachable for deopt, and is only used to capture the state. If the simulate // becomes reachable by merging, the ast id of the simulate merged into it is // adopted. Add<HSimulate>(BailoutId::None()); current_block()->UpdateEnvironment(inner_env); Scope* saved_scope = scope(); set_scope(target_info.scope()); HEnterInlined* enter_inlined = Add<HEnterInlined>(return_id, target, arguments_count, function, function_state()->inlining_kind(), function->scope()->arguments(), arguments_object); function_state()->set_entry(enter_inlined); VisitDeclarations(target_info.scope()->declarations()); VisitStatements(function->body()); set_scope(saved_scope); if (HasStackOverflow()) { // Bail out if the inline function did, as we cannot residualize a call // instead. TraceInline(target, caller, "inline graph construction failed"); target_shared->DisableOptimization(kInliningBailedOut); inline_bailout_ = true; delete target_state; return true; } // Update inlined nodes count. inlined_count_ += nodes_added; Handle<Code> unoptimized_code(target_shared->code()); ASSERT(unoptimized_code->kind() == Code::FUNCTION); Handle<TypeFeedbackInfo> type_info( TypeFeedbackInfo::cast(unoptimized_code->type_feedback_info())); graph()->update_type_change_checksum(type_info->own_type_change_checksum()); TraceInline(target, caller, NULL); if (current_block() != NULL) { FunctionState* state = function_state(); if (state->inlining_kind() == CONSTRUCT_CALL_RETURN) { // Falling off the end of an inlined construct call. In a test context the // return value will always evaluate to true, in a value context the // return value is the newly allocated receiver. if (call_context()->IsTest()) { Goto(inlined_test_context()->if_true(), state); } else if (call_context()->IsEffect()) { Goto(function_return(), state); } else { ASSERT(call_context()->IsValue()); AddLeaveInlined(implicit_return_value, state); } } else if (state->inlining_kind() == SETTER_CALL_RETURN) { // Falling off the end of an inlined setter call. The returned value is // never used, the value of an assignment is always the value of the RHS // of the assignment. if (call_context()->IsTest()) { inlined_test_context()->ReturnValue(implicit_return_value); } else if (call_context()->IsEffect()) { Goto(function_return(), state); } else { ASSERT(call_context()->IsValue()); AddLeaveInlined(implicit_return_value, state); } } else { // Falling off the end of a normal inlined function. This basically means // returning undefined. if (call_context()->IsTest()) { Goto(inlined_test_context()->if_false(), state); } else if (call_context()->IsEffect()) { Goto(function_return(), state); } else { ASSERT(call_context()->IsValue()); AddLeaveInlined(undefined, state); } } } // Fix up the function exits. if (inlined_test_context() != NULL) { HBasicBlock* if_true = inlined_test_context()->if_true(); HBasicBlock* if_false = inlined_test_context()->if_false(); HEnterInlined* entry = function_state()->entry(); // Pop the return test context from the expression context stack. ASSERT(ast_context() == inlined_test_context()); ClearInlinedTestContext(); delete target_state; // Forward to the real test context. if (if_true->HasPredecessor()) { entry->RegisterReturnTarget(if_true, zone()); if_true->SetJoinId(ast_id); HBasicBlock* true_target = TestContext::cast(ast_context())->if_true(); Goto(if_true, true_target, function_state()); } if (if_false->HasPredecessor()) { entry->RegisterReturnTarget(if_false, zone()); if_false->SetJoinId(ast_id); HBasicBlock* false_target = TestContext::cast(ast_context())->if_false(); Goto(if_false, false_target, function_state()); } set_current_block(NULL); return true; } else if (function_return()->HasPredecessor()) { function_state()->entry()->RegisterReturnTarget(function_return(), zone()); function_return()->SetJoinId(ast_id); set_current_block(function_return()); } else { set_current_block(NULL); } delete target_state; return true; } bool HOptimizedGraphBuilder::TryInlineCall(Call* expr) { return TryInline(expr->target(), expr->arguments()->length(), NULL, expr->id(), expr->ReturnId(), NORMAL_RETURN, ScriptPositionToSourcePosition(expr->position())); } bool HOptimizedGraphBuilder::TryInlineConstruct(CallNew* expr, HValue* implicit_return_value) { return TryInline(expr->target(), expr->arguments()->length(), implicit_return_value, expr->id(), expr->ReturnId(), CONSTRUCT_CALL_RETURN, ScriptPositionToSourcePosition(expr->position())); } bool HOptimizedGraphBuilder::TryInlineGetter(Handle<JSFunction> getter, Handle<Map> receiver_map, BailoutId ast_id, BailoutId return_id) { if (TryInlineApiGetter(getter, receiver_map, ast_id)) return true; return TryInline(getter, 0, NULL, ast_id, return_id, GETTER_CALL_RETURN, source_position()); } bool HOptimizedGraphBuilder::TryInlineSetter(Handle<JSFunction> setter, Handle<Map> receiver_map, BailoutId id, BailoutId assignment_id, HValue* implicit_return_value) { if (TryInlineApiSetter(setter, receiver_map, id)) return true; return TryInline(setter, 1, implicit_return_value, id, assignment_id, SETTER_CALL_RETURN, source_position()); } bool HOptimizedGraphBuilder::TryInlineApply(Handle<JSFunction> function, Call* expr, int arguments_count) { return TryInline(function, arguments_count, NULL, expr->id(), expr->ReturnId(), NORMAL_RETURN, ScriptPositionToSourcePosition(expr->position())); } bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr) { if (!expr->target()->shared()->HasBuiltinFunctionId()) return false; BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); switch (id) { case kMathExp: if (!FLAG_fast_math) break; // Fall through if FLAG_fast_math. case kMathRound: case kMathFloor: case kMathAbs: case kMathSqrt: case kMathLog: case kMathClz32: if (expr->arguments()->length() == 1) { HValue* argument = Pop(); Drop(2); // Receiver and function. HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id); ast_context()->ReturnInstruction(op, expr->id()); return true; } break; case kMathImul: if (expr->arguments()->length() == 2) { HValue* right = Pop(); HValue* left = Pop(); Drop(2); // Receiver and function. HInstruction* op = HMul::NewImul(zone(), context(), left, right); ast_context()->ReturnInstruction(op, expr->id()); return true; } break; default: // Not supported for inlining yet. break; } return false; } bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall( Call* expr, HValue* receiver, Handle<Map> receiver_map) { // Try to inline calls like Math.* as operations in the calling function. if (!expr->target()->shared()->HasBuiltinFunctionId()) return false; BuiltinFunctionId id = expr->target()->shared()->builtin_function_id(); int argument_count = expr->arguments()->length() + 1; // Plus receiver. switch (id) { case kStringCharCodeAt: case kStringCharAt: if (argument_count == 2) { HValue* index = Pop(); HValue* string = Pop(); Drop(1); // Function. HInstruction* char_code = BuildStringCharCodeAt(string, index); if (id == kStringCharCodeAt) { ast_context()->ReturnInstruction(char_code, expr->id()); return true; } AddInstruction(char_code); HInstruction* result = NewUncasted<HStringCharFromCode>(char_code); ast_context()->ReturnInstruction(result, expr->id()); return true; } break; case kStringFromCharCode: if (argument_count == 2) { HValue* argument = Pop(); Drop(2); // Receiver and function. HInstruction* result = NewUncasted<HStringCharFromCode>(argument); ast_context()->ReturnInstruction(result, expr->id()); return true; } break; case kMathExp: if (!FLAG_fast_math) break; // Fall through if FLAG_fast_math. case kMathRound: case kMathFloor: case kMathAbs: case kMathSqrt: case kMathLog: case kMathClz32: if (argument_count == 2) { HValue* argument = Pop(); Drop(2); // Receiver and function. HInstruction* op = NewUncasted<HUnaryMathOperation>(argument, id); ast_context()->ReturnInstruction(op, expr->id()); return true; } break; case kMathPow: if (argument_count == 3) { HValue* right = Pop(); HValue* left = Pop(); Drop(2); // Receiver and function. HInstruction* result = NULL; // Use sqrt() if exponent is 0.5 or -0.5. if (right->IsConstant() && HConstant::cast(right)->HasDoubleValue()) { double exponent = HConstant::cast(right)->DoubleValue(); if (exponent == 0.5) { result = NewUncasted<HUnaryMathOperation>(left, kMathPowHalf); } else if (exponent == -0.5) { HValue* one = graph()->GetConstant1(); HInstruction* sqrt = AddUncasted<HUnaryMathOperation>( left, kMathPowHalf); // MathPowHalf doesn't have side effects so there's no need for // an environment simulation here. ASSERT(!sqrt->HasObservableSideEffects()); result = NewUncasted<HDiv>(one, sqrt); } else if (exponent == 2.0) { result = NewUncasted<HMul>(left, left); } } if (result == NULL) { result = NewUncasted<HPower>(left, right); } ast_context()->ReturnInstruction(result, expr->id()); return true; } break; case kMathMax: case kMathMin: if (argument_count == 3) { HValue* right = Pop(); HValue* left = Pop(); Drop(2); // Receiver and function. HMathMinMax::Operation op = (id == kMathMin) ? HMathMinMax::kMathMin : HMathMinMax::kMathMax; HInstruction* result = NewUncasted<HMathMinMax>(left, right, op); ast_context()->ReturnInstruction(result, expr->id()); return true; } break; case kMathImul: if (argument_count == 3) { HValue* right = Pop(); HValue* left = Pop(); Drop(2); // Receiver and function. HInstruction* result = HMul::NewImul(zone(), context(), left, right); ast_context()->ReturnInstruction(result, expr->id()); return true; } break; case kArrayPop: { if (receiver_map.is_null()) return false; if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; ElementsKind elements_kind = receiver_map->elements_kind(); if (!IsFastElementsKind(elements_kind)) return false; if (receiver_map->is_observed()) return false; ASSERT(receiver_map->is_extensible()); Drop(expr->arguments()->length()); HValue* result; HValue* reduced_length; HValue* receiver = Pop(); HValue* checked_object = AddCheckMap(receiver, receiver_map); HValue* length = Add<HLoadNamedField>( checked_object, static_cast<HValue*>(NULL), HObjectAccess::ForArrayLength(elements_kind)); Drop(1); // Function. { NoObservableSideEffectsScope scope(this); IfBuilder length_checker(this); HValue* bounds_check = length_checker.If<HCompareNumericAndBranch>( length, graph()->GetConstant0(), Token::EQ); length_checker.Then(); if (!ast_context()->IsEffect()) Push(graph()->GetConstantUndefined()); length_checker.Else(); HValue* elements = AddLoadElements(checked_object); // Ensure that we aren't popping from a copy-on-write array. if (IsFastSmiOrObjectElementsKind(elements_kind)) { elements = BuildCopyElementsOnWrite(checked_object, elements, elements_kind, length); } reduced_length = AddUncasted<HSub>(length, graph()->GetConstant1()); result = AddElementAccess(elements, reduced_length, NULL, bounds_check, elements_kind, LOAD); Factory* factory = isolate()->factory(); double nan_double = FixedDoubleArray::hole_nan_as_double(); HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind) ? Add<HConstant>(factory->the_hole_value()) : Add<HConstant>(nan_double); if (IsFastSmiOrObjectElementsKind(elements_kind)) { elements_kind = FAST_HOLEY_ELEMENTS; } AddElementAccess( elements, reduced_length, hole, bounds_check, elements_kind, STORE); Add<HStoreNamedField>( checked_object, HObjectAccess::ForArrayLength(elements_kind), reduced_length, STORE_TO_INITIALIZED_ENTRY); if (!ast_context()->IsEffect()) Push(result); length_checker.End(); } result = ast_context()->IsEffect() ? graph()->GetConstant0() : Top(); Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); if (!ast_context()->IsEffect()) Drop(1); ast_context()->ReturnValue(result); return true; } case kArrayPush: { if (receiver_map.is_null()) return false; if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; ElementsKind elements_kind = receiver_map->elements_kind(); if (!IsFastElementsKind(elements_kind)) return false; if (receiver_map->is_observed()) return false; if (JSArray::IsReadOnlyLengthDescriptor(receiver_map)) return false; ASSERT(receiver_map->is_extensible()); // If there may be elements accessors in the prototype chain, the fast // inlined version can't be used. if (receiver_map->DictionaryElementsInPrototypeChainOnly()) return false; // If there currently can be no elements accessors on the prototype chain, // it doesn't mean that there won't be any later. Install a full prototype // chain check to trap element accessors being installed on the prototype // chain, which would cause elements to go to dictionary mode and result // in a map change. Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype())); BuildCheckPrototypeMaps(prototype, Handle<JSObject>()); const int argc = expr->arguments()->length(); if (argc != 1) return false; HValue* value_to_push = Pop(); HValue* array = Pop(); Drop(1); // Drop function. HInstruction* new_size = NULL; HValue* length = NULL; { NoObservableSideEffectsScope scope(this); length = Add<HLoadNamedField>(array, static_cast<HValue*>(NULL), HObjectAccess::ForArrayLength(elements_kind)); new_size = AddUncasted<HAdd>(length, graph()->GetConstant1()); bool is_array = receiver_map->instance_type() == JS_ARRAY_TYPE; BuildUncheckedMonomorphicElementAccess(array, length, value_to_push, is_array, elements_kind, STORE, NEVER_RETURN_HOLE, STORE_AND_GROW_NO_TRANSITION); if (!ast_context()->IsEffect()) Push(new_size); Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); if (!ast_context()->IsEffect()) Drop(1); } ast_context()->ReturnValue(new_size); return true; } case kArrayShift: { if (receiver_map.is_null()) return false; if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; ElementsKind kind = receiver_map->elements_kind(); if (!IsFastElementsKind(kind)) return false; if (receiver_map->is_observed()) return false; ASSERT(receiver_map->is_extensible()); // If there may be elements accessors in the prototype chain, the fast // inlined version can't be used. if (receiver_map->DictionaryElementsInPrototypeChainOnly()) return false; // If there currently can be no elements accessors on the prototype chain, // it doesn't mean that there won't be any later. Install a full prototype // chain check to trap element accessors being installed on the prototype // chain, which would cause elements to go to dictionary mode and result // in a map change. BuildCheckPrototypeMaps( handle(JSObject::cast(receiver_map->prototype()), isolate()), Handle<JSObject>::null()); // Threshold for fast inlined Array.shift(). HConstant* inline_threshold = Add<HConstant>(static_cast<int32_t>(16)); Drop(expr->arguments()->length()); HValue* receiver = Pop(); HValue* function = Pop(); HValue* result; { NoObservableSideEffectsScope scope(this); HValue* length = Add<HLoadNamedField>( receiver, static_cast<HValue*>(NULL), HObjectAccess::ForArrayLength(kind)); IfBuilder if_lengthiszero(this); HValue* lengthiszero = if_lengthiszero.If<HCompareNumericAndBranch>( length, graph()->GetConstant0(), Token::EQ); if_lengthiszero.Then(); { if (!ast_context()->IsEffect()) Push(graph()->GetConstantUndefined()); } if_lengthiszero.Else(); { HValue* elements = AddLoadElements(receiver); // Check if we can use the fast inlined Array.shift(). IfBuilder if_inline(this); if_inline.If<HCompareNumericAndBranch>( length, inline_threshold, Token::LTE); if (IsFastSmiOrObjectElementsKind(kind)) { // We cannot handle copy-on-write backing stores here. if_inline.AndIf<HCompareMap>( elements, isolate()->factory()->fixed_array_map()); } if_inline.Then(); { // Remember the result. if (!ast_context()->IsEffect()) { Push(AddElementAccess(elements, graph()->GetConstant0(), NULL, lengthiszero, kind, LOAD)); } // Compute the new length. HValue* new_length = AddUncasted<HSub>( length, graph()->GetConstant1()); new_length->ClearFlag(HValue::kCanOverflow); // Copy the remaining elements. LoopBuilder loop(this, context(), LoopBuilder::kPostIncrement); { HValue* new_key = loop.BeginBody( graph()->GetConstant0(), new_length, Token::LT); HValue* key = AddUncasted<HAdd>(new_key, graph()->GetConstant1()); key->ClearFlag(HValue::kCanOverflow); HValue* element = AddUncasted<HLoadKeyed>( elements, key, lengthiszero, kind, ALLOW_RETURN_HOLE); HStoreKeyed* store = Add<HStoreKeyed>( elements, new_key, element, kind); store->SetFlag(HValue::kAllowUndefinedAsNaN); } loop.EndBody(); // Put a hole at the end. HValue* hole = IsFastSmiOrObjectElementsKind(kind) ? Add<HConstant>(isolate()->factory()->the_hole_value()) : Add<HConstant>(FixedDoubleArray::hole_nan_as_double()); if (IsFastSmiOrObjectElementsKind(kind)) kind = FAST_HOLEY_ELEMENTS; Add<HStoreKeyed>( elements, new_length, hole, kind, INITIALIZING_STORE); // Remember new length. Add<HStoreNamedField>( receiver, HObjectAccess::ForArrayLength(kind), new_length, STORE_TO_INITIALIZED_ENTRY); } if_inline.Else(); { Add<HPushArguments>(receiver); result = Add<HCallJSFunction>(function, 1, true); if (!ast_context()->IsEffect()) Push(result); } if_inline.End(); } if_lengthiszero.End(); } result = ast_context()->IsEffect() ? graph()->GetConstant0() : Top(); Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); if (!ast_context()->IsEffect()) Drop(1); ast_context()->ReturnValue(result); return true; } case kArrayIndexOf: case kArrayLastIndexOf: { if (receiver_map.is_null()) return false; if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false; ElementsKind kind = receiver_map->elements_kind(); if (!IsFastElementsKind(kind)) return false; if (receiver_map->is_observed()) return false; if (argument_count != 2) return false; ASSERT(receiver_map->is_extensible()); // If there may be elements accessors in the prototype chain, the fast // inlined version can't be used. if (receiver_map->DictionaryElementsInPrototypeChainOnly()) return false; // If there currently can be no elements accessors on the prototype chain, // it doesn't mean that there won't be any later. Install a full prototype // chain check to trap element accessors being installed on the prototype // chain, which would cause elements to go to dictionary mode and result // in a map change. BuildCheckPrototypeMaps( handle(JSObject::cast(receiver_map->prototype()), isolate()), Handle<JSObject>::null()); HValue* search_element = Pop(); HValue* receiver = Pop(); Drop(1); // Drop function. ArrayIndexOfMode mode = (id == kArrayIndexOf) ? kFirstIndexOf : kLastIndexOf; HValue* index = BuildArrayIndexOf(receiver, search_element, kind, mode); if (!ast_context()->IsEffect()) Push(index); Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); if (!ast_context()->IsEffect()) Drop(1); ast_context()->ReturnValue(index); return true; } default: // Not yet supported for inlining. break; } return false; } bool HOptimizedGraphBuilder::TryInlineApiFunctionCall(Call* expr, HValue* receiver) { Handle<JSFunction> function = expr->target(); int argc = expr->arguments()->length(); SmallMapList receiver_maps; return TryInlineApiCall(function, receiver, &receiver_maps, argc, expr->id(), kCallApiFunction); } bool HOptimizedGraphBuilder::TryInlineApiMethodCall( Call* expr, HValue* receiver, SmallMapList* receiver_maps) { Handle<JSFunction> function = expr->target(); int argc = expr->arguments()->length(); return TryInlineApiCall(function, receiver, receiver_maps, argc, expr->id(), kCallApiMethod); } bool HOptimizedGraphBuilder::TryInlineApiGetter(Handle<JSFunction> function, Handle<Map> receiver_map, BailoutId ast_id) { SmallMapList receiver_maps(1, zone()); receiver_maps.Add(receiver_map, zone()); return TryInlineApiCall(function, NULL, // Receiver is on expression stack. &receiver_maps, 0, ast_id, kCallApiGetter); } bool HOptimizedGraphBuilder::TryInlineApiSetter(Handle<JSFunction> function, Handle<Map> receiver_map, BailoutId ast_id) { SmallMapList receiver_maps(1, zone()); receiver_maps.Add(receiver_map, zone()); return TryInlineApiCall(function, NULL, // Receiver is on expression stack. &receiver_maps, 1, ast_id, kCallApiSetter); } bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function, HValue* receiver, SmallMapList* receiver_maps, int argc, BailoutId ast_id, ApiCallType call_type) { CallOptimization optimization(function); if (!optimization.is_simple_api_call()) return false; Handle<Map> holder_map; if (call_type == kCallApiFunction) { // Cannot embed a direct reference to the global proxy map // as it maybe dropped on deserialization. CHECK(!isolate()->serializer_enabled()); ASSERT_EQ(0, receiver_maps->length()); receiver_maps->Add(handle( function->context()->global_object()->global_receiver()->map()), zone()); } CallOptimization::HolderLookup holder_lookup = CallOptimization::kHolderNotFound; Handle<JSObject> api_holder = optimization.LookupHolderOfExpectedType( receiver_maps->first(), &holder_lookup); if (holder_lookup == CallOptimization::kHolderNotFound) return false; if (FLAG_trace_inlining) { PrintF("Inlining api function "); function->ShortPrint(); PrintF("\n"); } bool drop_extra = false; bool is_store = false; switch (call_type) { case kCallApiFunction: case kCallApiMethod: // Need to check that none of the receiver maps could have changed. Add<HCheckMaps>(receiver, receiver_maps); // Need to ensure the chain between receiver and api_holder is intact. if (holder_lookup == CallOptimization::kHolderFound) { AddCheckPrototypeMaps(api_holder, receiver_maps->first()); } else { ASSERT_EQ(holder_lookup, CallOptimization::kHolderIsReceiver); } // Includes receiver. PushArgumentsFromEnvironment(argc + 1); // Drop function after call. drop_extra = true; break; case kCallApiGetter: // Receiver and prototype chain cannot have changed. ASSERT_EQ(0, argc); ASSERT_EQ(NULL, receiver); // Receiver is on expression stack. receiver = Pop(); Add<HPushArguments>(receiver); break; case kCallApiSetter: { is_store = true; // Receiver and prototype chain cannot have changed. ASSERT_EQ(1, argc); ASSERT_EQ(NULL, receiver); // Receiver and value are on expression stack. HValue* value = Pop(); receiver = Pop(); Add<HPushArguments>(receiver, value); break; } } HValue* holder = NULL; switch (holder_lookup) { case CallOptimization::kHolderFound: holder = Add<HConstant>(api_holder); break; case CallOptimization::kHolderIsReceiver: holder = receiver; break; case CallOptimization::kHolderNotFound: UNREACHABLE(); break; } Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); Handle<Object> call_data_obj(api_call_info->data(), isolate()); bool call_data_is_undefined = call_data_obj->IsUndefined(); HValue* call_data = Add<HConstant>(call_data_obj); ApiFunction fun(v8::ToCData<Address>(api_call_info->callback())); ExternalReference ref = ExternalReference(&fun, ExternalReference::DIRECT_API_CALL, isolate()); HValue* api_function_address = Add<HConstant>(ExternalReference(ref)); HValue* op_vals[] = { Add<HConstant>(function), call_data, holder, api_function_address, context() }; CallInterfaceDescriptor* descriptor = isolate()->call_descriptor(Isolate::ApiFunctionCall); CallApiFunctionStub stub(isolate(), is_store, call_data_is_undefined, argc); Handle<Code> code = stub.GetCode(); HConstant* code_value = Add<HConstant>(code); ASSERT((sizeof(op_vals) / kPointerSize) == descriptor->environment_length()); HInstruction* call = New<HCallWithDescriptor>( code_value, argc + 1, descriptor, Vector<HValue*>(op_vals, descriptor->environment_length())); if (drop_extra) Drop(1); // Drop function. ast_context()->ReturnInstruction(call, ast_id); return true; } bool HOptimizedGraphBuilder::TryCallApply(Call* expr) { ASSERT(expr->expression()->IsProperty()); if (!expr->IsMonomorphic()) { return false; } Handle<Map> function_map = expr->GetReceiverTypes()->first(); if (function_map->instance_type() != JS_FUNCTION_TYPE || !expr->target()->shared()->HasBuiltinFunctionId() || expr->target()->shared()->builtin_function_id() != kFunctionApply) { return false; } if (current_info()->scope()->arguments() == NULL) return false; ZoneList<Expression*>* args = expr->arguments(); if (args->length() != 2) return false; VariableProxy* arg_two = args->at(1)->AsVariableProxy(); if (arg_two == NULL || !arg_two->var()->IsStackAllocated()) return false; HValue* arg_two_value = LookupAndMakeLive(arg_two->var()); if (!arg_two_value->CheckFlag(HValue::kIsArguments)) return false; // Found pattern f.apply(receiver, arguments). CHECK_ALIVE_OR_RETURN(VisitForValue(args->at(0)), true); HValue* receiver = Pop(); // receiver HValue* function = Pop(); // f Drop(1); // apply HValue* checked_function = AddCheckMap(function, function_map); if (function_state()->outer() == NULL) { HInstruction* elements = Add<HArgumentsElements>(false); HInstruction* length = Add<HArgumentsLength>(elements); HValue* wrapped_receiver = BuildWrapReceiver(receiver, checked_function); HInstruction* result = New<HApplyArguments>(function, wrapped_receiver, length, elements); ast_context()->ReturnInstruction(result, expr->id()); return true; } else { // We are inside inlined function and we know exactly what is inside // arguments object. But we need to be able to materialize at deopt. ASSERT_EQ(environment()->arguments_environment()->parameter_count(), function_state()->entry()->arguments_object()->arguments_count()); HArgumentsObject* args = function_state()->entry()->arguments_object(); const ZoneList<HValue*>* arguments_values = args->arguments_values(); int arguments_count = arguments_values->length(); Push(function); Push(BuildWrapReceiver(receiver, checked_function)); for (int i = 1; i < arguments_count; i++) { Push(arguments_values->at(i)); } Handle<JSFunction> known_function; if (function->IsConstant() && HConstant::cast(function)->handle(isolate())->IsJSFunction()) { known_function = Handle<JSFunction>::cast( HConstant::cast(function)->handle(isolate())); int args_count = arguments_count - 1; // Excluding receiver. if (TryInlineApply(known_function, expr, args_count)) return true; } PushArgumentsFromEnvironment(arguments_count); HInvokeFunction* call = New<HInvokeFunction>( function, known_function, arguments_count); Drop(1); // Function. ast_context()->ReturnInstruction(call, expr->id()); return true; } } HValue* HOptimizedGraphBuilder::ImplicitReceiverFor(HValue* function, Handle<JSFunction> target) { SharedFunctionInfo* shared = target->shared(); if (shared->strict_mode() == SLOPPY && !shared->native()) { // Cannot embed a direct reference to the global proxy // as is it dropped on deserialization. CHECK(!isolate()->serializer_enabled()); Handle<JSObject> global_receiver( target->context()->global_object()->global_receiver()); return Add<HConstant>(global_receiver); } return graph()->GetConstantUndefined(); } void HOptimizedGraphBuilder::BuildArrayCall(Expression* expression, int arguments_count, HValue* function, Handle<AllocationSite> site) { Add<HCheckValue>(function, array_function()); if (IsCallArrayInlineable(arguments_count, site)) { BuildInlinedCallArray(expression, arguments_count, site); return; } HInstruction* call = PreProcessCall(New<HCallNewArray>( function, arguments_count + 1, site->GetElementsKind())); if (expression->IsCall()) { Drop(1); } ast_context()->ReturnInstruction(call, expression->id()); } HValue* HOptimizedGraphBuilder::BuildArrayIndexOf(HValue* receiver, HValue* search_element, ElementsKind kind, ArrayIndexOfMode mode) { ASSERT(IsFastElementsKind(kind)); NoObservableSideEffectsScope no_effects(this); HValue* elements = AddLoadElements(receiver); HValue* length = AddLoadArrayLength(receiver, kind); HValue* initial; HValue* terminating; Token::Value token; LoopBuilder::Direction direction; if (mode == kFirstIndexOf) { initial = graph()->GetConstant0(); terminating = length; token = Token::LT; direction = LoopBuilder::kPostIncrement; } else { ASSERT_EQ(kLastIndexOf, mode); initial = length; terminating = graph()->GetConstant0(); token = Token::GT; direction = LoopBuilder::kPreDecrement; } Push(graph()->GetConstantMinus1()); if (IsFastDoubleElementsKind(kind) || IsFastSmiElementsKind(kind)) { LoopBuilder loop(this, context(), direction); { HValue* index = loop.BeginBody(initial, terminating, token); HValue* element = AddUncasted<HLoadKeyed>( elements, index, static_cast<HValue*>(NULL), kind, ALLOW_RETURN_HOLE); IfBuilder if_issame(this); if (IsFastDoubleElementsKind(kind)) { if_issame.If<HCompareNumericAndBranch>( element, search_element, Token::EQ_STRICT); } else { if_issame.If<HCompareObjectEqAndBranch>(element, search_element); } if_issame.Then(); { Drop(1); Push(index); loop.Break(); } if_issame.End(); } loop.EndBody(); } else { IfBuilder if_isstring(this); if_isstring.If<HIsStringAndBranch>(search_element); if_isstring.Then(); { LoopBuilder loop(this, context(), direction); { HValue* index = loop.BeginBody(initial, terminating, token); HValue* element = AddUncasted<HLoadKeyed>( elements, index, static_cast<HValue*>(NULL), kind, ALLOW_RETURN_HOLE); IfBuilder if_issame(this); if_issame.If<HIsStringAndBranch>(element); if_issame.AndIf<HStringCompareAndBranch>( element, search_element, Token::EQ_STRICT); if_issame.Then(); { Drop(1); Push(index); loop.Break(); } if_issame.End(); } loop.EndBody(); } if_isstring.Else(); { IfBuilder if_isnumber(this); if_isnumber.If<HIsSmiAndBranch>(search_element); if_isnumber.OrIf<HCompareMap>( search_element, isolate()->factory()->heap_number_map()); if_isnumber.Then(); { HValue* search_number = AddUncasted<HForceRepresentation>(search_element, Representation::Double()); LoopBuilder loop(this, context(), direction); { HValue* index = loop.BeginBody(initial, terminating, token); HValue* element = AddUncasted<HLoadKeyed>( elements, index, static_cast<HValue*>(NULL), kind, ALLOW_RETURN_HOLE); IfBuilder if_element_isnumber(this); if_element_isnumber.If<HIsSmiAndBranch>(element); if_element_isnumber.OrIf<HCompareMap>( element, isolate()->factory()->heap_number_map()); if_element_isnumber.Then(); { HValue* number = AddUncasted<HForceRepresentation>(element, Representation::Double()); IfBuilder if_issame(this); if_issame.If<HCompareNumericAndBranch>( number, search_number, Token::EQ_STRICT); if_issame.Then(); { Drop(1); Push(index); loop.Break(); } if_issame.End(); } if_element_isnumber.End(); } loop.EndBody(); } if_isnumber.Else(); { LoopBuilder loop(this, context(), direction); { HValue* index = loop.BeginBody(initial, terminating, token); HValue* element = AddUncasted<HLoadKeyed>( elements, index, static_cast<HValue*>(NULL), kind, ALLOW_RETURN_HOLE); IfBuilder if_issame(this); if_issame.If<HCompareObjectEqAndBranch>( element, search_element); if_issame.Then(); { Drop(1); Push(index); loop.Break(); } if_issame.End(); } loop.EndBody(); } if_isnumber.End(); } if_isstring.End(); } return Pop(); } bool HOptimizedGraphBuilder::TryHandleArrayCall(Call* expr, HValue* function) { if (!array_function().is_identical_to(expr->target())) { return false; } Handle<AllocationSite> site = expr->allocation_site(); if (site.is_null()) return false; BuildArrayCall(expr, expr->arguments()->length(), function, site); return true; } bool HOptimizedGraphBuilder::TryHandleArrayCallNew(CallNew* expr, HValue* function) { if (!array_function().is_identical_to(expr->target())) { return false; } BuildArrayCall(expr, expr->arguments()->length(), function, expr->allocation_site()); return true; } void HOptimizedGraphBuilder::VisitCall(Call* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); Expression* callee = expr->expression(); int argument_count = expr->arguments()->length() + 1; // Plus receiver. HInstruction* call = NULL; Property* prop = callee->AsProperty(); if (prop != NULL) { CHECK_ALIVE(VisitForValue(prop->obj())); HValue* receiver = Top(); SmallMapList* types; ComputeReceiverTypes(expr, receiver, &types, zone()); if (prop->key()->IsPropertyName() && types->length() > 0) { Handle<String> name = prop->key()->AsLiteral()->AsPropertyName(); PropertyAccessInfo info(this, LOAD, ToType(types->first()), name); if (!info.CanAccessAsMonomorphic(types)) { HandlePolymorphicCallNamed(expr, receiver, types, name); return; } } HValue* key = NULL; if (!prop->key()->IsPropertyName()) { CHECK_ALIVE(VisitForValue(prop->key())); key = Pop(); } CHECK_ALIVE(PushLoad(prop, receiver, key)); HValue* function = Pop(); if (FLAG_hydrogen_track_positions) SetSourcePosition(expr->position()); // Push the function under the receiver. environment()->SetExpressionStackAt(0, function); Push(receiver); if (function->IsConstant() && HConstant::cast(function)->handle(isolate())->IsJSFunction()) { Handle<JSFunction> known_function = Handle<JSFunction>::cast( HConstant::cast(function)->handle(isolate())); expr->set_target(known_function); if (TryCallApply(expr)) return; CHECK_ALIVE(VisitExpressions(expr->arguments())); Handle<Map> map = types->length() == 1 ? types->first() : Handle<Map>(); if (TryInlineBuiltinMethodCall(expr, receiver, map)) { if (FLAG_trace_inlining) { PrintF("Inlining builtin "); known_function->ShortPrint(); PrintF("\n"); } return; } if (TryInlineApiMethodCall(expr, receiver, types)) return; // Wrap the receiver if necessary. if (NeedsWrappingFor(ToType(types->first()), known_function)) { // Since HWrapReceiver currently cannot actually wrap numbers and // strings, use the regular CallFunctionStub for method calls to wrap // the receiver. // TODO(verwaest): Support creation of value wrappers directly in // HWrapReceiver. call = New<HCallFunction>( function, argument_count, WRAP_AND_CALL); } else if (TryInlineCall(expr)) { return; } else { call = BuildCallConstantFunction(known_function, argument_count); } } else { CHECK_ALIVE(VisitExpressions(expr->arguments())); CallFunctionFlags flags = receiver->type().IsJSObject() ? NO_CALL_FUNCTION_FLAGS : CALL_AS_METHOD; call = New<HCallFunction>(function, argument_count, flags); } PushArgumentsFromEnvironment(argument_count); } else { VariableProxy* proxy = expr->expression()->AsVariableProxy(); if (proxy != NULL && proxy->var()->is_possibly_eval(isolate())) { return Bailout(kPossibleDirectCallToEval); } // The function is on the stack in the unoptimized code during // evaluation of the arguments. CHECK_ALIVE(VisitForValue(expr->expression())); HValue* function = Top(); if (expr->global_call()) { Variable* var = proxy->var(); bool known_global_function = false; // If there is a global property cell for the name at compile time and // access check is not enabled we assume that the function will not change // and generate optimized code for calling the function. LookupResult lookup(isolate()); GlobalPropertyAccess type = LookupGlobalProperty(var, &lookup, LOAD); if (type == kUseCell && !current_info()->global_object()->IsAccessCheckNeeded()) { Handle<GlobalObject> global(current_info()->global_object()); known_global_function = expr->ComputeGlobalTarget(global, &lookup); } if (known_global_function) { Add<HCheckValue>(function, expr->target()); // Placeholder for the receiver. Push(graph()->GetConstantUndefined()); CHECK_ALIVE(VisitExpressions(expr->arguments())); // Patch the global object on the stack by the expected receiver. HValue* receiver = ImplicitReceiverFor(function, expr->target()); const int receiver_index = argument_count - 1; environment()->SetExpressionStackAt(receiver_index, receiver); if (TryInlineBuiltinFunctionCall(expr)) { if (FLAG_trace_inlining) { PrintF("Inlining builtin "); expr->target()->ShortPrint(); PrintF("\n"); } return; } if (TryInlineApiFunctionCall(expr, receiver)) return; if (TryHandleArrayCall(expr, function)) return; if (TryInlineCall(expr)) return; PushArgumentsFromEnvironment(argument_count); call = BuildCallConstantFunction(expr->target(), argument_count); } else { Push(graph()->GetConstantUndefined()); CHECK_ALIVE(VisitExpressions(expr->arguments())); PushArgumentsFromEnvironment(argument_count); call = New<HCallFunction>(function, argument_count); } } else if (expr->IsMonomorphic()) { Add<HCheckValue>(function, expr->target()); Push(graph()->GetConstantUndefined()); CHECK_ALIVE(VisitExpressions(expr->arguments())); HValue* receiver = ImplicitReceiverFor(function, expr->target()); const int receiver_index = argument_count - 1; environment()->SetExpressionStackAt(receiver_index, receiver); if (TryInlineBuiltinFunctionCall(expr)) { if (FLAG_trace_inlining) { PrintF("Inlining builtin "); expr->target()->ShortPrint(); PrintF("\n"); } return; } if (TryInlineApiFunctionCall(expr, receiver)) return; if (TryInlineCall(expr)) return; call = PreProcessCall(New<HInvokeFunction>( function, expr->target(), argument_count)); } else { Push(graph()->GetConstantUndefined()); CHECK_ALIVE(VisitExpressions(expr->arguments())); PushArgumentsFromEnvironment(argument_count); call = New<HCallFunction>(function, argument_count); } } Drop(1); // Drop the function. return ast_context()->ReturnInstruction(call, expr->id()); } void HOptimizedGraphBuilder::BuildInlinedCallArray( Expression* expression, int argument_count, Handle<AllocationSite> site) { ASSERT(!site.is_null()); ASSERT(argument_count >= 0 && argument_count <= 1); NoObservableSideEffectsScope no_effects(this); // We should at least have the constructor on the expression stack. HValue* constructor = environment()->ExpressionStackAt(argument_count); // Register on the site for deoptimization if the transition feedback changes. AllocationSite::AddDependentCompilationInfo( site, AllocationSite::TRANSITIONS, top_info()); ElementsKind kind = site->GetElementsKind(); HInstruction* site_instruction = Add<HConstant>(site); // In the single constant argument case, we may have to adjust elements kind // to avoid creating a packed non-empty array. if (argument_count == 1 && !IsHoleyElementsKind(kind)) { HValue* argument = environment()->Top(); if (argument->IsConstant()) { HConstant* constant_argument = HConstant::cast(argument); ASSERT(constant_argument->HasSmiValue()); int constant_array_size = constant_argument->Integer32Value(); if (constant_array_size != 0) { kind = GetHoleyElementsKind(kind); } } } // Build the array. JSArrayBuilder array_builder(this, kind, site_instruction, constructor, DISABLE_ALLOCATION_SITES); HValue* new_object = argument_count == 0 ? array_builder.AllocateEmptyArray() : BuildAllocateArrayFromLength(&array_builder, Top()); int args_to_drop = argument_count + (expression->IsCall() ? 2 : 1); Drop(args_to_drop); ast_context()->ReturnValue(new_object); } // Checks whether allocation using the given constructor can be inlined. static bool IsAllocationInlineable(Handle<JSFunction> constructor) { return constructor->has_initial_map() && constructor->initial_map()->instance_type() == JS_OBJECT_TYPE && constructor->initial_map()->instance_size() < HAllocate::kMaxInlineSize && constructor->initial_map()->InitialPropertiesLength() == 0; } bool HOptimizedGraphBuilder::IsCallArrayInlineable( int argument_count, Handle<AllocationSite> site) { Handle<JSFunction> caller = current_info()->closure(); Handle<JSFunction> target = array_function(); // We should have the function plus array arguments on the environment stack. ASSERT(environment()->length() >= (argument_count + 1)); ASSERT(!site.is_null()); bool inline_ok = false; if (site->CanInlineCall()) { // We also want to avoid inlining in certain 1 argument scenarios. if (argument_count == 1) { HValue* argument = Top(); if (argument->IsConstant()) { // Do not inline if the constant length argument is not a smi or // outside the valid range for unrolled loop initialization. HConstant* constant_argument = HConstant::cast(argument); if (constant_argument->HasSmiValue()) { int value = constant_argument->Integer32Value(); inline_ok = value >= 0 && value <= kElementLoopUnrollThreshold; if (!inline_ok) { TraceInline(target, caller, "Constant length outside of valid inlining range."); } } } else { TraceInline(target, caller, "Dont inline [new] Array(n) where n isn't constant."); } } else if (argument_count == 0) { inline_ok = true; } else { TraceInline(target, caller, "Too many arguments to inline."); } } else { TraceInline(target, caller, "AllocationSite requested no inlining."); } if (inline_ok) { TraceInline(target, caller, NULL); } return inline_ok; } void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); if (!FLAG_hydrogen_track_positions) SetSourcePosition(expr->position()); int argument_count = expr->arguments()->length() + 1; // Plus constructor. Factory* factory = isolate()->factory(); // The constructor function is on the stack in the unoptimized code // during evaluation of the arguments. CHECK_ALIVE(VisitForValue(expr->expression())); HValue* function = Top(); CHECK_ALIVE(VisitExpressions(expr->arguments())); if (FLAG_inline_construct && expr->IsMonomorphic() && IsAllocationInlineable(expr->target())) { Handle<JSFunction> constructor = expr->target(); HValue* check = Add<HCheckValue>(function, constructor); // Force completion of inobject slack tracking before generating // allocation code to finalize instance size. if (constructor->IsInobjectSlackTrackingInProgress()) { constructor->CompleteInobjectSlackTracking(); } // Calculate instance size from initial map of constructor. ASSERT(constructor->has_initial_map()); Handle<Map> initial_map(constructor->initial_map()); int instance_size = initial_map->instance_size(); ASSERT(initial_map->InitialPropertiesLength() == 0); // Allocate an instance of the implicit receiver object. HValue* size_in_bytes = Add<HConstant>(instance_size); HAllocationMode allocation_mode; if (FLAG_pretenuring_call_new) { if (FLAG_allocation_site_pretenuring) { // Try to use pretenuring feedback. Handle<AllocationSite> allocation_site = expr->allocation_site(); allocation_mode = HAllocationMode(allocation_site); // Take a dependency on allocation site. AllocationSite::AddDependentCompilationInfo(allocation_site, AllocationSite::TENURING, top_info()); } } HAllocate* receiver = BuildAllocate( size_in_bytes, HType::JSObject(), JS_OBJECT_TYPE, allocation_mode); receiver->set_known_initial_map(initial_map); // Initialize map and fields of the newly allocated object. { NoObservableSideEffectsScope no_effects(this); ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); Add<HStoreNamedField>(receiver, HObjectAccess::ForMapAndOffset(initial_map, JSObject::kMapOffset), Add<HConstant>(initial_map)); HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array()); Add<HStoreNamedField>(receiver, HObjectAccess::ForMapAndOffset(initial_map, JSObject::kPropertiesOffset), empty_fixed_array); Add<HStoreNamedField>(receiver, HObjectAccess::ForMapAndOffset(initial_map, JSObject::kElementsOffset), empty_fixed_array); if (initial_map->inobject_properties() != 0) { HConstant* undefined = graph()->GetConstantUndefined(); for (int i = 0; i < initial_map->inobject_properties(); i++) { int property_offset = initial_map->GetInObjectPropertyOffset(i); Add<HStoreNamedField>(receiver, HObjectAccess::ForMapAndOffset(initial_map, property_offset), undefined); } } } // Replace the constructor function with a newly allocated receiver using // the index of the receiver from the top of the expression stack. const int receiver_index = argument_count - 1; ASSERT(environment()->ExpressionStackAt(receiver_index) == function); environment()->SetExpressionStackAt(receiver_index, receiver); if (TryInlineConstruct(expr, receiver)) { // Inlining worked, add a dependency on the initial map to make sure that // this code is deoptimized whenever the initial map of the constructor // changes. Map::AddDependentCompilationInfo( initial_map, DependentCode::kInitialMapChangedGroup, top_info()); return; } // TODO(mstarzinger): For now we remove the previous HAllocate and all // corresponding instructions and instead add HPushArguments for the // arguments in case inlining failed. What we actually should do is for // inlining to try to build a subgraph without mutating the parent graph. HInstruction* instr = current_block()->last(); do { HInstruction* prev_instr = instr->previous(); instr->DeleteAndReplaceWith(NULL); instr = prev_instr; } while (instr != check); environment()->SetExpressionStackAt(receiver_index, function); HInstruction* call = PreProcessCall(New<HCallNew>(function, argument_count)); return ast_context()->ReturnInstruction(call, expr->id()); } else { // The constructor function is both an operand to the instruction and an // argument to the construct call. if (TryHandleArrayCallNew(expr, function)) return; HInstruction* call = PreProcessCall(New<HCallNew>(function, argument_count)); return ast_context()->ReturnInstruction(call, expr->id()); } } // Support for generating inlined runtime functions. // Lookup table for generators for runtime calls that are generated inline. // Elements of the table are member pointers to functions of // HOptimizedGraphBuilder. #define INLINE_FUNCTION_GENERATOR_ADDRESS(Name, argc, ressize) \ &HOptimizedGraphBuilder::Generate##Name, const HOptimizedGraphBuilder::InlineFunctionGenerator HOptimizedGraphBuilder::kInlineFunctionGenerators[] = { INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) INLINE_OPTIMIZED_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) }; #undef INLINE_FUNCTION_GENERATOR_ADDRESS template <class ViewClass> void HGraphBuilder::BuildArrayBufferViewInitialization( HValue* obj, HValue* buffer, HValue* byte_offset, HValue* byte_length) { for (int offset = ViewClass::kSize; offset < ViewClass::kSizeWithInternalFields; offset += kPointerSize) { Add<HStoreNamedField>(obj, HObjectAccess::ForObservableJSObjectOffset(offset), graph()->GetConstant0()); } Add<HStoreNamedField>( obj, HObjectAccess::ForJSArrayBufferViewByteOffset(), byte_offset); Add<HStoreNamedField>( obj, HObjectAccess::ForJSArrayBufferViewByteLength(), byte_length); if (buffer != NULL) { Add<HStoreNamedField>( obj, HObjectAccess::ForJSArrayBufferViewBuffer(), buffer); HObjectAccess weak_first_view_access = HObjectAccess::ForJSArrayBufferWeakFirstView(); Add<HStoreNamedField>(obj, HObjectAccess::ForJSArrayBufferViewWeakNext(), Add<HLoadNamedField>(buffer, static_cast<HValue*>(NULL), weak_first_view_access)); Add<HStoreNamedField>(buffer, weak_first_view_access, obj); } else { Add<HStoreNamedField>( obj, HObjectAccess::ForJSArrayBufferViewBuffer(), Add<HConstant>(static_cast<int32_t>(0))); Add<HStoreNamedField>(obj, HObjectAccess::ForJSArrayBufferViewWeakNext(), graph()->GetConstantUndefined()); } } void HOptimizedGraphBuilder::GenerateDataViewInitialize( CallRuntime* expr) { ZoneList<Expression*>* arguments = expr->arguments(); ASSERT(arguments->length()== 4); CHECK_ALIVE(VisitForValue(arguments->at(0))); HValue* obj = Pop(); CHECK_ALIVE(VisitForValue(arguments->at(1))); HValue* buffer = Pop(); CHECK_ALIVE(VisitForValue(arguments->at(2))); HValue* byte_offset = Pop(); CHECK_ALIVE(VisitForValue(arguments->at(3))); HValue* byte_length = Pop(); { NoObservableSideEffectsScope scope(this); BuildArrayBufferViewInitialization<JSDataView>( obj, buffer, byte_offset, byte_length); } } static Handle<Map> TypedArrayMap(Isolate* isolate, ExternalArrayType array_type, ElementsKind target_kind) { Handle<Context> native_context = isolate->native_context(); Handle<JSFunction> fun; switch (array_type) { #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ case kExternal##Type##Array: \ fun = Handle<JSFunction>(native_context->type##_array_fun()); \ break; TYPED_ARRAYS(TYPED_ARRAY_CASE) #undef TYPED_ARRAY_CASE } Handle<Map> map(fun->initial_map()); return Map::AsElementsKind(map, target_kind); } HValue* HOptimizedGraphBuilder::BuildAllocateExternalElements( ExternalArrayType array_type, bool is_zero_byte_offset, HValue* buffer, HValue* byte_offset, HValue* length) { Handle<Map> external_array_map( isolate()->heap()->MapForExternalArrayType(array_type)); // The HForceRepresentation is to prevent possible deopt on int-smi // conversion after allocation but before the new object fields are set. length = AddUncasted<HForceRepresentation>(length, Representation::Smi()); HValue* elements = Add<HAllocate>( Add<HConstant>(ExternalArray::kAlignedSize), HType::HeapObject(), NOT_TENURED, external_array_map->instance_type()); AddStoreMapConstant(elements, external_array_map); Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), length); HValue* backing_store = Add<HLoadNamedField>( buffer, static_cast<HValue*>(NULL), HObjectAccess::ForJSArrayBufferBackingStore()); HValue* typed_array_start; if (is_zero_byte_offset) { typed_array_start = backing_store; } else { HInstruction* external_pointer = AddUncasted<HAdd>(backing_store, byte_offset); // Arguments are checked prior to call to TypedArrayInitialize, // including byte_offset. external_pointer->ClearFlag(HValue::kCanOverflow); typed_array_start = external_pointer; } Add<HStoreNamedField>(elements, HObjectAccess::ForExternalArrayExternalPointer(), typed_array_start); return elements; } HValue* HOptimizedGraphBuilder::BuildAllocateFixedTypedArray( ExternalArrayType array_type, size_t element_size, ElementsKind fixed_elements_kind, HValue* byte_length, HValue* length) { STATIC_ASSERT( (FixedTypedArrayBase::kHeaderSize & kObjectAlignmentMask) == 0); HValue* total_size; // if fixed array's elements are not aligned to object's alignment, // we need to align the whole array to object alignment. if (element_size % kObjectAlignment != 0) { total_size = BuildObjectSizeAlignment( byte_length, FixedTypedArrayBase::kHeaderSize); } else { total_size = AddUncasted<HAdd>(byte_length, Add<HConstant>(FixedTypedArrayBase::kHeaderSize)); total_size->ClearFlag(HValue::kCanOverflow); } // The HForceRepresentation is to prevent possible deopt on int-smi // conversion after allocation but before the new object fields are set. length = AddUncasted<HForceRepresentation>(length, Representation::Smi()); Handle<Map> fixed_typed_array_map( isolate()->heap()->MapForFixedTypedArray(array_type)); HValue* elements = Add<HAllocate>(total_size, HType::HeapObject(), NOT_TENURED, fixed_typed_array_map->instance_type()); AddStoreMapConstant(elements, fixed_typed_array_map); Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), length); HValue* filler = Add<HConstant>(static_cast<int32_t>(0)); { LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement); HValue* key = builder.BeginBody( Add<HConstant>(static_cast<int32_t>(0)), length, Token::LT); Add<HStoreKeyed>(elements, key, filler, fixed_elements_kind); builder.EndBody(); } return elements; } void HOptimizedGraphBuilder::GenerateTypedArrayInitialize( CallRuntime* expr) { ZoneList<Expression*>* arguments = expr->arguments(); static const int kObjectArg = 0; static const int kArrayIdArg = 1; static const int kBufferArg = 2; static const int kByteOffsetArg = 3; static const int kByteLengthArg = 4; static const int kArgsLength = 5; ASSERT(arguments->length() == kArgsLength); CHECK_ALIVE(VisitForValue(arguments->at(kObjectArg))); HValue* obj = Pop(); if (arguments->at(kArrayIdArg)->IsLiteral()) { // This should never happen in real use, but can happen when fuzzing. // Just bail out. Bailout(kNeedSmiLiteral); return; } Handle<Object> value = static_cast<Literal*>(arguments->at(kArrayIdArg))->value(); if (!value->IsSmi()) { // This should never happen in real use, but can happen when fuzzing. // Just bail out. Bailout(kNeedSmiLiteral); return; } int array_id = Smi::cast(*value)->value(); HValue* buffer; if (!arguments->at(kBufferArg)->IsNullLiteral()) { CHECK_ALIVE(VisitForValue(arguments->at(kBufferArg))); buffer = Pop(); } else { buffer = NULL; } HValue* byte_offset; bool is_zero_byte_offset; if (arguments->at(kByteOffsetArg)->IsLiteral() && Smi::FromInt(0) == *static_cast<Literal*>(arguments->at(kByteOffsetArg))->value()) { byte_offset = Add<HConstant>(static_cast<int32_t>(0)); is_zero_byte_offset = true; } else { CHECK_ALIVE(VisitForValue(arguments->at(kByteOffsetArg))); byte_offset = Pop(); is_zero_byte_offset = false; ASSERT(buffer != NULL); } CHECK_ALIVE(VisitForValue(arguments->at(kByteLengthArg))); HValue* byte_length = Pop(); NoObservableSideEffectsScope scope(this); IfBuilder byte_offset_smi(this); if (!is_zero_byte_offset) { byte_offset_smi.If<HIsSmiAndBranch>(byte_offset); byte_offset_smi.Then(); } ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. size_t element_size = 1; // Bogus initialization. ElementsKind external_elements_kind = // Bogus initialization. EXTERNAL_INT8_ELEMENTS; ElementsKind fixed_elements_kind = // Bogus initialization. INT8_ELEMENTS; Runtime::ArrayIdToTypeAndSize(array_id, &array_type, &external_elements_kind, &fixed_elements_kind, &element_size); { // byte_offset is Smi. BuildArrayBufferViewInitialization<JSTypedArray>( obj, buffer, byte_offset, byte_length); HInstruction* length = AddUncasted<HDiv>(byte_length, Add<HConstant>(static_cast<int32_t>(element_size))); Add<HStoreNamedField>(obj, HObjectAccess::ForJSTypedArrayLength(), length); HValue* elements; if (buffer != NULL) { elements = BuildAllocateExternalElements( array_type, is_zero_byte_offset, buffer, byte_offset, length); Handle<Map> obj_map = TypedArrayMap( isolate(), array_type, external_elements_kind); AddStoreMapConstant(obj, obj_map); } else { ASSERT(is_zero_byte_offset); elements = BuildAllocateFixedTypedArray( array_type, element_size, fixed_elements_kind, byte_length, length); } Add<HStoreNamedField>( obj, HObjectAccess::ForElementsPointer(), elements); } if (!is_zero_byte_offset) { byte_offset_smi.Else(); { // byte_offset is not Smi. Push(obj); CHECK_ALIVE(VisitForValue(arguments->at(kArrayIdArg))); Push(buffer); Push(byte_offset); Push(byte_length); PushArgumentsFromEnvironment(kArgsLength); Add<HCallRuntime>(expr->name(), expr->function(), kArgsLength); } } byte_offset_smi.End(); } void HOptimizedGraphBuilder::GenerateMaxSmi(CallRuntime* expr) { ASSERT(expr->arguments()->length() == 0); HConstant* max_smi = New<HConstant>(static_cast<int32_t>(Smi::kMaxValue)); return ast_context()->ReturnInstruction(max_smi, expr->id()); } void HOptimizedGraphBuilder::GenerateTypedArrayMaxSizeInHeap( CallRuntime* expr) { ASSERT(expr->arguments()->length() == 0); HConstant* result = New<HConstant>(static_cast<int32_t>( FLAG_typed_array_max_size_in_heap)); return ast_context()->ReturnInstruction(result, expr->id()); } void HOptimizedGraphBuilder::GenerateArrayBufferGetByteLength( CallRuntime* expr) { ASSERT(expr->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); HValue* buffer = Pop(); HInstruction* result = New<HLoadNamedField>( buffer, static_cast<HValue*>(NULL), HObjectAccess::ForJSArrayBufferByteLength()); return ast_context()->ReturnInstruction(result, expr->id()); } void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteLength( CallRuntime* expr) { ASSERT(expr->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); HValue* buffer = Pop(); HInstruction* result = New<HLoadNamedField>( buffer, static_cast<HValue*>(NULL), HObjectAccess::ForJSArrayBufferViewByteLength()); return ast_context()->ReturnInstruction(result, expr->id()); } void HOptimizedGraphBuilder::GenerateArrayBufferViewGetByteOffset( CallRuntime* expr) { ASSERT(expr->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); HValue* buffer = Pop(); HInstruction* result = New<HLoadNamedField>( buffer, static_cast<HValue*>(NULL), HObjectAccess::ForJSArrayBufferViewByteOffset()); return ast_context()->ReturnInstruction(result, expr->id()); } void HOptimizedGraphBuilder::GenerateTypedArrayGetLength( CallRuntime* expr) { ASSERT(expr->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(expr->arguments()->at(0))); HValue* buffer = Pop(); HInstruction* result = New<HLoadNamedField>( buffer, static_cast<HValue*>(NULL), HObjectAccess::ForJSTypedArrayLength()); return ast_context()->ReturnInstruction(result, expr->id()); } void HOptimizedGraphBuilder::VisitCallRuntime(CallRuntime* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); if (expr->is_jsruntime()) { return Bailout(kCallToAJavaScriptRuntimeFunction); } const Runtime::Function* function = expr->function(); ASSERT(function != NULL); if (function->intrinsic_type == Runtime::INLINE || function->intrinsic_type == Runtime::INLINE_OPTIMIZED) { ASSERT(expr->name()->length() > 0); ASSERT(expr->name()->Get(0) == '_'); // Call to an inline function. int lookup_index = static_cast<int>(function->function_id) - static_cast<int>(Runtime::kFirstInlineFunction); ASSERT(lookup_index >= 0); ASSERT(static_cast<size_t>(lookup_index) < ARRAY_SIZE(kInlineFunctionGenerators)); InlineFunctionGenerator generator = kInlineFunctionGenerators[lookup_index]; // Call the inline code generator using the pointer-to-member. (this->*generator)(expr); } else { ASSERT(function->intrinsic_type == Runtime::RUNTIME); Handle<String> name = expr->name(); int argument_count = expr->arguments()->length(); CHECK_ALIVE(VisitExpressions(expr->arguments())); PushArgumentsFromEnvironment(argument_count); HCallRuntime* call = New<HCallRuntime>(name, function, argument_count); return ast_context()->ReturnInstruction(call, expr->id()); } } void HOptimizedGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); switch (expr->op()) { case Token::DELETE: return VisitDelete(expr); case Token::VOID: return VisitVoid(expr); case Token::TYPEOF: return VisitTypeof(expr); case Token::NOT: return VisitNot(expr); default: UNREACHABLE(); } } void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { Property* prop = expr->expression()->AsProperty(); VariableProxy* proxy = expr->expression()->AsVariableProxy(); if (prop != NULL) { CHECK_ALIVE(VisitForValue(prop->obj())); CHECK_ALIVE(VisitForValue(prop->key())); HValue* key = Pop(); HValue* obj = Pop(); HValue* function = AddLoadJSBuiltin(Builtins::DELETE); Add<HPushArguments>(obj, key, Add<HConstant>(function_strict_mode())); // TODO(olivf) InvokeFunction produces a check for the parameter count, // even though we are certain to pass the correct number of arguments here. HInstruction* instr = New<HInvokeFunction>(function, 3); return ast_context()->ReturnInstruction(instr, expr->id()); } else if (proxy != NULL) { Variable* var = proxy->var(); if (var->IsUnallocated()) { Bailout(kDeleteWithGlobalVariable); } else if (var->IsStackAllocated() || var->IsContextSlot()) { // Result of deleting non-global variables is false. 'this' is not // really a variable, though we implement it as one. The // subexpression does not have side effects. HValue* value = var->is_this() ? graph()->GetConstantTrue() : graph()->GetConstantFalse(); return ast_context()->ReturnValue(value); } else { Bailout(kDeleteWithNonGlobalVariable); } } else { // Result of deleting non-property, non-variable reference is true. // Evaluate the subexpression for side effects. CHECK_ALIVE(VisitForEffect(expr->expression())); return ast_context()->ReturnValue(graph()->GetConstantTrue()); } } void HOptimizedGraphBuilder::VisitVoid(UnaryOperation* expr) { CHECK_ALIVE(VisitForEffect(expr->expression())); return ast_context()->ReturnValue(graph()->GetConstantUndefined()); } void HOptimizedGraphBuilder::VisitTypeof(UnaryOperation* expr) { CHECK_ALIVE(VisitForTypeOf(expr->expression())); HValue* value = Pop(); HInstruction* instr = New<HTypeof>(value); return ast_context()->ReturnInstruction(instr, expr->id()); } void HOptimizedGraphBuilder::VisitNot(UnaryOperation* expr) { if (ast_context()->IsTest()) { TestContext* context = TestContext::cast(ast_context()); VisitForControl(expr->expression(), context->if_false(), context->if_true()); return; } if (ast_context()->IsEffect()) { VisitForEffect(expr->expression()); return; } ASSERT(ast_context()->IsValue()); HBasicBlock* materialize_false = graph()->CreateBasicBlock(); HBasicBlock* materialize_true = graph()->CreateBasicBlock(); CHECK_BAILOUT(VisitForControl(expr->expression(), materialize_false, materialize_true)); if (materialize_false->HasPredecessor()) { materialize_false->SetJoinId(expr->MaterializeFalseId()); set_current_block(materialize_false); Push(graph()->GetConstantFalse()); } else { materialize_false = NULL; } if (materialize_true->HasPredecessor()) { materialize_true->SetJoinId(expr->MaterializeTrueId()); set_current_block(materialize_true); Push(graph()->GetConstantTrue()); } else { materialize_true = NULL; } HBasicBlock* join = CreateJoin(materialize_false, materialize_true, expr->id()); set_current_block(join); if (join != NULL) return ast_context()->ReturnValue(Pop()); } HInstruction* HOptimizedGraphBuilder::BuildIncrement( bool returns_original_input, CountOperation* expr) { // The input to the count operation is on top of the expression stack. Representation rep = Representation::FromType(expr->type()); if (rep.IsNone() || rep.IsTagged()) { rep = Representation::Smi(); } if (returns_original_input) { // We need an explicit HValue representing ToNumber(input). The // actual HChange instruction we need is (sometimes) added in a later // phase, so it is not available now to be used as an input to HAdd and // as the return value. HInstruction* number_input = AddUncasted<HForceRepresentation>(Pop(), rep); if (!rep.IsDouble()) { number_input->SetFlag(HInstruction::kFlexibleRepresentation); number_input->SetFlag(HInstruction::kCannotBeTagged); } Push(number_input); } // The addition has no side effects, so we do not need // to simulate the expression stack after this instruction. // Any later failures deopt to the load of the input or earlier. HConstant* delta = (expr->op() == Token::INC) ? graph()->GetConstant1() : graph()->GetConstantMinus1(); HInstruction* instr = AddUncasted<HAdd>(Top(), delta); if (instr->IsAdd()) { HAdd* add = HAdd::cast(instr); add->set_observed_input_representation(1, rep); add->set_observed_input_representation(2, Representation::Smi()); } instr->SetFlag(HInstruction::kCannotBeTagged); instr->ClearAllSideEffects(); return instr; } void HOptimizedGraphBuilder::BuildStoreForEffect(Expression* expr, Property* prop, BailoutId ast_id, BailoutId return_id, HValue* object, HValue* key, HValue* value) { EffectContext for_effect(this); Push(object); if (key != NULL) Push(key); Push(value); BuildStore(expr, prop, ast_id, return_id); } void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); if (!FLAG_hydrogen_track_positions) SetSourcePosition(expr->position()); Expression* target = expr->expression(); VariableProxy* proxy = target->AsVariableProxy(); Property* prop = target->AsProperty(); if (proxy == NULL && prop == NULL) { return Bailout(kInvalidLhsInCountOperation); } // Match the full code generator stack by simulating an extra stack // element for postfix operations in a non-effect context. The return // value is ToNumber(input). bool returns_original_input = expr->is_postfix() && !ast_context()->IsEffect(); HValue* input = NULL; // ToNumber(original_input). HValue* after = NULL; // The result after incrementing or decrementing. if (proxy != NULL) { Variable* var = proxy->var(); if (var->mode() == CONST_LEGACY) { return Bailout(kUnsupportedCountOperationWithConst); } // Argument of the count operation is a variable, not a property. ASSERT(prop == NULL); CHECK_ALIVE(VisitForValue(target)); after = BuildIncrement(returns_original_input, expr); input = returns_original_input ? Top() : Pop(); Push(after); switch (var->location()) { case Variable::UNALLOCATED: HandleGlobalVariableAssignment(var, after, expr->AssignmentId()); break; case Variable::PARAMETER: case Variable::LOCAL: BindIfLive(var, after); break; case Variable::CONTEXT: { // Bail out if we try to mutate a parameter value in a function // using the arguments object. We do not (yet) correctly handle the // arguments property of the function. if (current_info()->scope()->arguments() != NULL) { // Parameters will rewrite to context slots. We have no direct // way to detect that the variable is a parameter so we use a // linear search of the parameter list. int count = current_info()->scope()->num_parameters(); for (int i = 0; i < count; ++i) { if (var == current_info()->scope()->parameter(i)) { return Bailout(kAssignmentToParameterInArgumentsObject); } } } HValue* context = BuildContextChainWalk(var); HStoreContextSlot::Mode mode = IsLexicalVariableMode(var->mode()) ? HStoreContextSlot::kCheckDeoptimize : HStoreContextSlot::kNoCheck; HStoreContextSlot* instr = Add<HStoreContextSlot>(context, var->index(), mode, after); if (instr->HasObservableSideEffects()) { Add<HSimulate>(expr->AssignmentId(), REMOVABLE_SIMULATE); } break; } case Variable::LOOKUP: return Bailout(kLookupVariableInCountOperation); } Drop(returns_original_input ? 2 : 1); return ast_context()->ReturnValue(expr->is_postfix() ? input : after); } // Argument of the count operation is a property. ASSERT(prop != NULL); if (returns_original_input) Push(graph()->GetConstantUndefined()); CHECK_ALIVE(VisitForValue(prop->obj())); HValue* object = Top(); HValue* key = NULL; if ((!prop->IsFunctionPrototype() && !prop->key()->IsPropertyName()) || prop->IsStringAccess()) { CHECK_ALIVE(VisitForValue(prop->key())); key = Top(); } CHECK_ALIVE(PushLoad(prop, object, key)); after = BuildIncrement(returns_original_input, expr); if (returns_original_input) { input = Pop(); // Drop object and key to push it again in the effect context below. Drop(key == NULL ? 1 : 2); environment()->SetExpressionStackAt(0, input); CHECK_ALIVE(BuildStoreForEffect( expr, prop, expr->id(), expr->AssignmentId(), object, key, after)); return ast_context()->ReturnValue(Pop()); } environment()->SetExpressionStackAt(0, after); return BuildStore(expr, prop, expr->id(), expr->AssignmentId()); } HInstruction* HOptimizedGraphBuilder::BuildStringCharCodeAt( HValue* string, HValue* index) { if (string->IsConstant() && index->IsConstant()) { HConstant* c_string = HConstant::cast(string); HConstant* c_index = HConstant::cast(index); if (c_string->HasStringValue() && c_index->HasNumberValue()) { int32_t i = c_index->NumberValueAsInteger32(); Handle<String> s = c_string->StringValue(); if (i < 0 || i >= s->length()) { return New<HConstant>(OS::nan_value()); } return New<HConstant>(s->Get(i)); } } string = BuildCheckString(string); index = Add<HBoundsCheck>(index, AddLoadStringLength(string)); return New<HStringCharCodeAt>(string, index); } // Checks if the given shift amounts have following forms: // (N1) and (N2) with N1 + N2 = 32; (sa) and (32 - sa). static bool ShiftAmountsAllowReplaceByRotate(HValue* sa, HValue* const32_minus_sa) { if (sa->IsConstant() && const32_minus_sa->IsConstant()) { const HConstant* c1 = HConstant::cast(sa); const HConstant* c2 = HConstant::cast(const32_minus_sa); return c1->HasInteger32Value() && c2->HasInteger32Value() && (c1->Integer32Value() + c2->Integer32Value() == 32); } if (!const32_minus_sa->IsSub()) return false; HSub* sub = HSub::cast(const32_minus_sa); return sub->left()->EqualsInteger32Constant(32) && sub->right() == sa; } // Checks if the left and the right are shift instructions with the oposite // directions that can be replaced by one rotate right instruction or not. // Returns the operand and the shift amount for the rotate instruction in the // former case. bool HGraphBuilder::MatchRotateRight(HValue* left, HValue* right, HValue** operand, HValue** shift_amount) { HShl* shl; HShr* shr; if (left->IsShl() && right->IsShr()) { shl = HShl::cast(left); shr = HShr::cast(right); } else if (left->IsShr() && right->IsShl()) { shl = HShl::cast(right); shr = HShr::cast(left); } else { return false; } if (shl->left() != shr->left()) return false; if (!ShiftAmountsAllowReplaceByRotate(shl->right(), shr->right()) && !ShiftAmountsAllowReplaceByRotate(shr->right(), shl->right())) { return false; } *operand= shr->left(); *shift_amount = shr->right(); return true; } bool CanBeZero(HValue* right) { if (right->IsConstant()) { HConstant* right_const = HConstant::cast(right); if (right_const->HasInteger32Value() && (right_const->Integer32Value() & 0x1f) != 0) { return false; } } return true; } HValue* HGraphBuilder::EnforceNumberType(HValue* number, Type* expected) { if (expected->Is(Type::SignedSmall())) { return AddUncasted<HForceRepresentation>(number, Representation::Smi()); } if (expected->Is(Type::Signed32())) { return AddUncasted<HForceRepresentation>(number, Representation::Integer32()); } return number; } HValue* HGraphBuilder::TruncateToNumber(HValue* value, Type** expected) { if (value->IsConstant()) { HConstant* constant = HConstant::cast(value); Maybe<HConstant*> number = constant->CopyToTruncatedNumber(zone()); if (number.has_value) { *expected = Type::Number(zone()); return AddInstruction(number.value); } } // We put temporary values on the stack, which don't correspond to anything // in baseline code. Since nothing is observable we avoid recording those // pushes with a NoObservableSideEffectsScope. NoObservableSideEffectsScope no_effects(this); Type* expected_type = *expected; // Separate the number type from the rest. Type* expected_obj = Type::Intersect(expected_type, Type::NonNumber(zone()), zone()); Type* expected_number = Type::Intersect(expected_type, Type::Number(zone()), zone()); // We expect to get a number. // (We need to check first, since Type::None->Is(Type::Any()) == true. if (expected_obj->Is(Type::None())) { ASSERT(!expected_number->Is(Type::None(zone()))); return value; } if (expected_obj->Is(Type::Undefined(zone()))) { // This is already done by HChange. *expected = Type::Union(expected_number, Type::Number(zone()), zone()); return value; } return value; } HValue* HOptimizedGraphBuilder::BuildBinaryOperation( BinaryOperation* expr, HValue* left, HValue* right, PushBeforeSimulateBehavior push_sim_result) { Type* left_type = expr->left()->bounds().lower; Type* right_type = expr->right()->bounds().lower; Type* result_type = expr->bounds().lower; Maybe<int> fixed_right_arg = expr->fixed_right_arg(); Handle<AllocationSite> allocation_site = expr->allocation_site(); HAllocationMode allocation_mode; if (FLAG_allocation_site_pretenuring && !allocation_site.is_null()) { allocation_mode = HAllocationMode(allocation_site); } HValue* result = HGraphBuilder::BuildBinaryOperation( expr->op(), left, right, left_type, right_type, result_type, fixed_right_arg, allocation_mode); // Add a simulate after instructions with observable side effects, and // after phis, which are the result of BuildBinaryOperation when we // inlined some complex subgraph. if (result->HasObservableSideEffects() || result->IsPhi()) { if (push_sim_result == PUSH_BEFORE_SIMULATE) { Push(result); Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); Drop(1); } else { Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE); } } return result; } HValue* HGraphBuilder::BuildBinaryOperation( Token::Value op, HValue* left, HValue* right, Type* left_type, Type* right_type, Type* result_type, Maybe<int> fixed_right_arg, HAllocationMode allocation_mode) { Representation left_rep = Representation::FromType(left_type); Representation right_rep = Representation::FromType(right_type); bool maybe_string_add = op == Token::ADD && (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())); if (left_type->Is(Type::None())) { Add<HDeoptimize>("Insufficient type feedback for LHS of binary operation", Deoptimizer::SOFT); // TODO(rossberg): we should be able to get rid of non-continuous // defaults. left_type = Type::Any(zone()); } else { if (!maybe_string_add) left = TruncateToNumber(left, &left_type); left_rep = Representation::FromType(left_type); } if (right_type->Is(Type::None())) { Add<HDeoptimize>("Insufficient type feedback for RHS of binary operation", Deoptimizer::SOFT); right_type = Type::Any(zone()); } else { if (!maybe_string_add) right = TruncateToNumber(right, &right_type); right_rep = Representation::FromType(right_type); } // Special case for string addition here. if (op == Token::ADD && (left_type->Is(Type::String()) || right_type->Is(Type::String()))) { // Validate type feedback for left argument. if (left_type->Is(Type::String())) { left = BuildCheckString(left); } // Validate type feedback for right argument. if (right_type->Is(Type::String())) { right = BuildCheckString(right); } // Convert left argument as necessary. if (left_type->Is(Type::Number())) { ASSERT(right_type->Is(Type::String())); left = BuildNumberToString(left, left_type); } else if (!left_type->Is(Type::String())) { ASSERT(right_type->Is(Type::String())); HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_RIGHT); Add<HPushArguments>(left, right); return AddUncasted<HInvokeFunction>(function, 2); } // Convert right argument as necessary. if (right_type->Is(Type::Number())) { ASSERT(left_type->Is(Type::String())); right = BuildNumberToString(right, right_type); } else if (!right_type->Is(Type::String())) { ASSERT(left_type->Is(Type::String())); HValue* function = AddLoadJSBuiltin(Builtins::STRING_ADD_LEFT); Add<HPushArguments>(left, right); return AddUncasted<HInvokeFunction>(function, 2); } // Fast path for empty constant strings. if (left->IsConstant() && HConstant::cast(left)->HasStringValue() && HConstant::cast(left)->StringValue()->length() == 0) { return right; } if (right->IsConstant() && HConstant::cast(right)->HasStringValue() && HConstant::cast(right)->StringValue()->length() == 0) { return left; } // Register the dependent code with the allocation site. if (!allocation_mode.feedback_site().is_null()) { ASSERT(!graph()->info()->IsStub()); Handle<AllocationSite> site(allocation_mode.feedback_site()); AllocationSite::AddDependentCompilationInfo( site, AllocationSite::TENURING, top_info()); } // Inline the string addition into the stub when creating allocation // mementos to gather allocation site feedback, or if we can statically // infer that we're going to create a cons string. if ((graph()->info()->IsStub() && allocation_mode.CreateAllocationMementos()) || (left->IsConstant() && HConstant::cast(left)->HasStringValue() && HConstant::cast(left)->StringValue()->length() + 1 >= ConsString::kMinLength) || (right->IsConstant() && HConstant::cast(right)->HasStringValue() && HConstant::cast(right)->StringValue()->length() + 1 >= ConsString::kMinLength)) { return BuildStringAdd(left, right, allocation_mode); } // Fallback to using the string add stub. return AddUncasted<HStringAdd>( left, right, allocation_mode.GetPretenureMode(), STRING_ADD_CHECK_NONE, allocation_mode.feedback_site()); } if (graph()->info()->IsStub()) { left = EnforceNumberType(left, left_type); right = EnforceNumberType(right, right_type); } Representation result_rep = Representation::FromType(result_type); bool is_non_primitive = (left_rep.IsTagged() && !left_rep.IsSmi()) || (right_rep.IsTagged() && !right_rep.IsSmi()); HInstruction* instr = NULL; // Only the stub is allowed to call into the runtime, since otherwise we would // inline several instructions (including the two pushes) for every tagged // operation in optimized code, which is more expensive, than a stub call. if (graph()->info()->IsStub() && is_non_primitive) { HValue* function = AddLoadJSBuiltin(BinaryOpIC::TokenToJSBuiltin(op)); Add<HPushArguments>(left, right); instr = AddUncasted<HInvokeFunction>(function, 2); } else { switch (op) { case Token::ADD: instr = AddUncasted<HAdd>(left, right); break; case Token::SUB: instr = AddUncasted<HSub>(left, right); break; case Token::MUL: instr = AddUncasted<HMul>(left, right); break; case Token::MOD: { if (fixed_right_arg.has_value && !right->EqualsInteger32Constant(fixed_right_arg.value)) { HConstant* fixed_right = Add<HConstant>( static_cast<int>(fixed_right_arg.value)); IfBuilder if_same(this); if_same.If<HCompareNumericAndBranch>(right, fixed_right, Token::EQ); if_same.Then(); if_same.ElseDeopt("Unexpected RHS of binary operation"); right = fixed_right; } instr = AddUncasted<HMod>(left, right); break; } case Token::DIV: instr = AddUncasted<HDiv>(left, right); break; case Token::BIT_XOR: case Token::BIT_AND: instr = AddUncasted<HBitwise>(op, left, right); break; case Token::BIT_OR: { HValue* operand, *shift_amount; if (left_type->Is(Type::Signed32()) && right_type->Is(Type::Signed32()) && MatchRotateRight(left, right, &operand, &shift_amount)) { instr = AddUncasted<HRor>(operand, shift_amount); } else { instr = AddUncasted<HBitwise>(op, left, right); } break; } case Token::SAR: instr = AddUncasted<HSar>(left, right); break; case Token::SHR: instr = AddUncasted<HShr>(left, right); if (FLAG_opt_safe_uint32_operations && instr->IsShr() && CanBeZero(right)) { graph()->RecordUint32Instruction(instr); } break; case Token::SHL: instr = AddUncasted<HShl>(left, right); break; default: UNREACHABLE(); } } if (instr->IsBinaryOperation()) { HBinaryOperation* binop = HBinaryOperation::cast(instr); binop->set_observed_input_representation(1, left_rep); binop->set_observed_input_representation(2, right_rep); binop->initialize_output_representation(result_rep); if (graph()->info()->IsStub()) { // Stub should not call into stub. instr->SetFlag(HValue::kCannotBeTagged); // And should truncate on HForceRepresentation already. if (left->IsForceRepresentation()) { left->CopyFlag(HValue::kTruncatingToSmi, instr); left->CopyFlag(HValue::kTruncatingToInt32, instr); } if (right->IsForceRepresentation()) { right->CopyFlag(HValue::kTruncatingToSmi, instr); right->CopyFlag(HValue::kTruncatingToInt32, instr); } } } return instr; } // Check for the form (%_ClassOf(foo) === 'BarClass'). static bool IsClassOfTest(CompareOperation* expr) { if (expr->op() != Token::EQ_STRICT) return false; CallRuntime* call = expr->left()->AsCallRuntime(); if (call == NULL) return false; Literal* literal = expr->right()->AsLiteral(); if (literal == NULL) return false; if (!literal->value()->IsString()) return false; if (!call->name()->IsOneByteEqualTo(STATIC_ASCII_VECTOR("_ClassOf"))) { return false; } ASSERT(call->arguments()->length() == 1); return true; } void HOptimizedGraphBuilder::VisitBinaryOperation(BinaryOperation* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); switch (expr->op()) { case Token::COMMA: return VisitComma(expr); case Token::OR: case Token::AND: return VisitLogicalExpression(expr); default: return VisitArithmeticExpression(expr); } } void HOptimizedGraphBuilder::VisitComma(BinaryOperation* expr) { CHECK_ALIVE(VisitForEffect(expr->left())); // Visit the right subexpression in the same AST context as the entire // expression. Visit(expr->right()); } void HOptimizedGraphBuilder::VisitLogicalExpression(BinaryOperation* expr) { bool is_logical_and = expr->op() == Token::AND; if (ast_context()->IsTest()) { TestContext* context = TestContext::cast(ast_context()); // Translate left subexpression. HBasicBlock* eval_right = graph()->CreateBasicBlock(); if (is_logical_and) { CHECK_BAILOUT(VisitForControl(expr->left(), eval_right, context->if_false())); } else { CHECK_BAILOUT(VisitForControl(expr->left(), context->if_true(), eval_right)); } // Translate right subexpression by visiting it in the same AST // context as the entire expression. if (eval_right->HasPredecessor()) { eval_right->SetJoinId(expr->RightId()); set_current_block(eval_right); Visit(expr->right()); } } else if (ast_context()->IsValue()) { CHECK_ALIVE(VisitForValue(expr->left())); ASSERT(current_block() != NULL); HValue* left_value = Top(); // Short-circuit left values that always evaluate to the same boolean value. if (expr->left()->ToBooleanIsTrue() || expr->left()->ToBooleanIsFalse()) { // l (evals true) && r -> r // l (evals true) || r -> l // l (evals false) && r -> l // l (evals false) || r -> r if (is_logical_and == expr->left()->ToBooleanIsTrue()) { Drop(1); CHECK_ALIVE(VisitForValue(expr->right())); } return ast_context()->ReturnValue(Pop()); } // We need an extra block to maintain edge-split form. HBasicBlock* empty_block = graph()->CreateBasicBlock(); HBasicBlock* eval_right = graph()->CreateBasicBlock(); ToBooleanStub::Types expected(expr->left()->to_boolean_types()); HBranch* test = is_logical_and ? New<HBranch>(left_value, expected, eval_right, empty_block) : New<HBranch>(left_value, expected, empty_block, eval_right); FinishCurrentBlock(test); set_current_block(eval_right); Drop(1); // Value of the left subexpression. CHECK_BAILOUT(VisitForValue(expr->right())); HBasicBlock* join_block = CreateJoin(empty_block, current_block(), expr->id()); set_current_block(join_block); return ast_context()->ReturnValue(Pop()); } else { ASSERT(ast_context()->IsEffect()); // In an effect context, we don't need the value of the left subexpression, // only its control flow and side effects. We need an extra block to // maintain edge-split form. HBasicBlock* empty_block = graph()->CreateBasicBlock(); HBasicBlock* right_block = graph()->CreateBasicBlock(); if (is_logical_and) { CHECK_BAILOUT(VisitForControl(expr->left(), right_block, empty_block)); } else { CHECK_BAILOUT(VisitForControl(expr->left(), empty_block, right_block)); } // TODO(kmillikin): Find a way to fix this. It's ugly that there are // actually two empty blocks (one here and one inserted by // TestContext::BuildBranch, and that they both have an HSimulate though the // second one is not a merge node, and that we really have no good AST ID to // put on that first HSimulate. if (empty_block->HasPredecessor()) { empty_block->SetJoinId(expr->id()); } else { empty_block = NULL; } if (right_block->HasPredecessor()) { right_block->SetJoinId(expr->RightId()); set_current_block(right_block); CHECK_BAILOUT(VisitForEffect(expr->right())); right_block = current_block(); } else { right_block = NULL; } HBasicBlock* join_block = CreateJoin(empty_block, right_block, expr->id()); set_current_block(join_block); // We did not materialize any value in the predecessor environments, // so there is no need to handle it here. } } void HOptimizedGraphBuilder::VisitArithmeticExpression(BinaryOperation* expr) { CHECK_ALIVE(VisitForValue(expr->left())); CHECK_ALIVE(VisitForValue(expr->right())); SetSourcePosition(expr->position()); HValue* right = Pop(); HValue* left = Pop(); HValue* result = BuildBinaryOperation(expr, left, right, ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE : PUSH_BEFORE_SIMULATE); if (FLAG_hydrogen_track_positions && result->IsBinaryOperation()) { HBinaryOperation::cast(result)->SetOperandPositions( zone(), ScriptPositionToSourcePosition(expr->left()->position()), ScriptPositionToSourcePosition(expr->right()->position())); } return ast_context()->ReturnValue(result); } void HOptimizedGraphBuilder::HandleLiteralCompareTypeof(CompareOperation* expr, Expression* sub_expr, Handle<String> check) { CHECK_ALIVE(VisitForTypeOf(sub_expr)); SetSourcePosition(expr->position()); HValue* value = Pop(); HTypeofIsAndBranch* instr = New<HTypeofIsAndBranch>(value, check); return ast_context()->ReturnControl(instr, expr->id()); } static bool IsLiteralCompareBool(Isolate* isolate, HValue* left, Token::Value op, HValue* right) { return op == Token::EQ_STRICT && ((left->IsConstant() && HConstant::cast(left)->handle(isolate)->IsBoolean()) || (right->IsConstant() && HConstant::cast(right)->handle(isolate)->IsBoolean())); } void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); if (!FLAG_hydrogen_track_positions) SetSourcePosition(expr->position()); // Check for a few fast cases. The AST visiting behavior must be in sync // with the full codegen: We don't push both left and right values onto // the expression stack when one side is a special-case literal. Expression* sub_expr = NULL; Handle<String> check; if (expr->IsLiteralCompareTypeof(&sub_expr, &check)) { return HandleLiteralCompareTypeof(expr, sub_expr, check); } if (expr->IsLiteralCompareUndefined(&sub_expr, isolate())) { return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue); } if (expr->IsLiteralCompareNull(&sub_expr)) { return HandleLiteralCompareNil(expr, sub_expr, kNullValue); } if (IsClassOfTest(expr)) { CallRuntime* call = expr->left()->AsCallRuntime(); ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); Literal* literal = expr->right()->AsLiteral(); Handle<String> rhs = Handle<String>::cast(literal->value()); HClassOfTestAndBranch* instr = New<HClassOfTestAndBranch>(value, rhs); return ast_context()->ReturnControl(instr, expr->id()); } Type* left_type = expr->left()->bounds().lower; Type* right_type = expr->right()->bounds().lower; Type* combined_type = expr->combined_type(); CHECK_ALIVE(VisitForValue(expr->left())); CHECK_ALIVE(VisitForValue(expr->right())); if (FLAG_hydrogen_track_positions) SetSourcePosition(expr->position()); HValue* right = Pop(); HValue* left = Pop(); Token::Value op = expr->op(); if (IsLiteralCompareBool(isolate(), left, op, right)) { HCompareObjectEqAndBranch* result = New<HCompareObjectEqAndBranch>(left, right); return ast_context()->ReturnControl(result, expr->id()); } if (op == Token::INSTANCEOF) { // Check to see if the rhs of the instanceof is a global function not // residing in new space. If it is we assume that the function will stay the // same. Handle<JSFunction> target = Handle<JSFunction>::null(); VariableProxy* proxy = expr->right()->AsVariableProxy(); bool global_function = (proxy != NULL) && proxy->var()->IsUnallocated(); if (global_function && current_info()->has_global_object() && !current_info()->global_object()->IsAccessCheckNeeded()) { Handle<String> name = proxy->name(); Handle<GlobalObject> global(current_info()->global_object()); LookupResult lookup(isolate()); global->Lookup(name, &lookup); if (lookup.IsNormal() && lookup.GetValue()->IsJSFunction()) { Handle<JSFunction> candidate(JSFunction::cast(lookup.GetValue())); // If the function is in new space we assume it's more likely to // change and thus prefer the general IC code. if (!isolate()->heap()->InNewSpace(*candidate)) { target = candidate; } } } // If the target is not null we have found a known global function that is // assumed to stay the same for this instanceof. if (target.is_null()) { HInstanceOf* result = New<HInstanceOf>(left, right); return ast_context()->ReturnInstruction(result, expr->id()); } else { Add<HCheckValue>(right, target); HInstanceOfKnownGlobal* result = New<HInstanceOfKnownGlobal>(left, target); return ast_context()->ReturnInstruction(result, expr->id()); } // Code below assumes that we don't fall through. UNREACHABLE(); } else if (op == Token::IN) { HValue* function = AddLoadJSBuiltin(Builtins::IN); Add<HPushArguments>(left, right); // TODO(olivf) InvokeFunction produces a check for the parameter count, // even though we are certain to pass the correct number of arguments here. HInstruction* result = New<HInvokeFunction>(function, 2); return ast_context()->ReturnInstruction(result, expr->id()); } PushBeforeSimulateBehavior push_behavior = ast_context()->IsEffect() ? NO_PUSH_BEFORE_SIMULATE : PUSH_BEFORE_SIMULATE; HControlInstruction* compare = BuildCompareInstruction( op, left, right, left_type, right_type, combined_type, ScriptPositionToSourcePosition(expr->left()->position()), ScriptPositionToSourcePosition(expr->right()->position()), push_behavior, expr->id()); if (compare == NULL) return; // Bailed out. return ast_context()->ReturnControl(compare, expr->id()); } HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction( Token::Value op, HValue* left, HValue* right, Type* left_type, Type* right_type, Type* combined_type, HSourcePosition left_position, HSourcePosition right_position, PushBeforeSimulateBehavior push_sim_result, BailoutId bailout_id) { // Cases handled below depend on collected type feedback. They should // soft deoptimize when there is no type feedback. if (combined_type->Is(Type::None())) { Add<HDeoptimize>("Insufficient type feedback for combined type " "of binary operation", Deoptimizer::SOFT); combined_type = left_type = right_type = Type::Any(zone()); } Representation left_rep = Representation::FromType(left_type); Representation right_rep = Representation::FromType(right_type); Representation combined_rep = Representation::FromType(combined_type); if (combined_type->Is(Type::Receiver())) { if (Token::IsEqualityOp(op)) { // HCompareObjectEqAndBranch can only deal with object, so // exclude numbers. if ((left->IsConstant() && HConstant::cast(left)->HasNumberValue()) || (right->IsConstant() && HConstant::cast(right)->HasNumberValue())) { Add<HDeoptimize>("Type mismatch between feedback and constant", Deoptimizer::SOFT); // The caller expects a branch instruction, so make it happy. return New<HBranch>(graph()->GetConstantTrue()); } // Can we get away with map check and not instance type check? HValue* operand_to_check = left->block()->block_id() < right->block()->block_id() ? left : right; if (combined_type->IsClass()) { Handle<Map> map = combined_type->AsClass()->Map(); AddCheckMap(operand_to_check, map); HCompareObjectEqAndBranch* result = New<HCompareObjectEqAndBranch>(left, right); if (FLAG_hydrogen_track_positions) { result->set_operand_position(zone(), 0, left_position); result->set_operand_position(zone(), 1, right_position); } return result; } else { BuildCheckHeapObject(operand_to_check); Add<HCheckInstanceType>(operand_to_check, HCheckInstanceType::IS_SPEC_OBJECT); HCompareObjectEqAndBranch* result = New<HCompareObjectEqAndBranch>(left, right); return result; } } else { Bailout(kUnsupportedNonPrimitiveCompare); return NULL; } } else if (combined_type->Is(Type::InternalizedString()) && Token::IsEqualityOp(op)) { // If we have a constant argument, it should be consistent with the type // feedback (otherwise we fail assertions in HCompareObjectEqAndBranch). if ((left->IsConstant() && !HConstant::cast(left)->HasInternalizedStringValue()) || (right->IsConstant() && !HConstant::cast(right)->HasInternalizedStringValue())) { Add<HDeoptimize>("Type mismatch between feedback and constant", Deoptimizer::SOFT); // The caller expects a branch instruction, so make it happy. return New<HBranch>(graph()->GetConstantTrue()); } BuildCheckHeapObject(left); Add<HCheckInstanceType>(left, HCheckInstanceType::IS_INTERNALIZED_STRING); BuildCheckHeapObject(right); Add<HCheckInstanceType>(right, HCheckInstanceType::IS_INTERNALIZED_STRING); HCompareObjectEqAndBranch* result = New<HCompareObjectEqAndBranch>(left, right); return result; } else if (combined_type->Is(Type::String())) { BuildCheckHeapObject(left); Add<HCheckInstanceType>(left, HCheckInstanceType::IS_STRING); BuildCheckHeapObject(right); Add<HCheckInstanceType>(right, HCheckInstanceType::IS_STRING); HStringCompareAndBranch* result = New<HStringCompareAndBranch>(left, right, op); return result; } else { if (combined_rep.IsTagged() || combined_rep.IsNone()) { HCompareGeneric* result = Add<HCompareGeneric>(left, right, op); result->set_observed_input_representation(1, left_rep); result->set_observed_input_representation(2, right_rep); if (result->HasObservableSideEffects()) { if (push_sim_result == PUSH_BEFORE_SIMULATE) { Push(result); AddSimulate(bailout_id, REMOVABLE_SIMULATE); Drop(1); } else { AddSimulate(bailout_id, REMOVABLE_SIMULATE); } } // TODO(jkummerow): Can we make this more efficient? HBranch* branch = New<HBranch>(result); return branch; } else { HCompareNumericAndBranch* result = New<HCompareNumericAndBranch>(left, right, op); result->set_observed_input_representation(left_rep, right_rep); if (FLAG_hydrogen_track_positions) { result->SetOperandPositions(zone(), left_position, right_position); } return result; } } } void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr, Expression* sub_expr, NilValue nil) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); ASSERT(expr->op() == Token::EQ || expr->op() == Token::EQ_STRICT); if (!FLAG_hydrogen_track_positions) SetSourcePosition(expr->position()); CHECK_ALIVE(VisitForValue(sub_expr)); HValue* value = Pop(); if (expr->op() == Token::EQ_STRICT) { HConstant* nil_constant = nil == kNullValue ? graph()->GetConstantNull() : graph()->GetConstantUndefined(); HCompareObjectEqAndBranch* instr = New<HCompareObjectEqAndBranch>(value, nil_constant); return ast_context()->ReturnControl(instr, expr->id()); } else { ASSERT_EQ(Token::EQ, expr->op()); Type* type = expr->combined_type()->Is(Type::None()) ? Type::Any(zone()) : expr->combined_type(); HIfContinuation continuation; BuildCompareNil(value, type, &continuation); return ast_context()->ReturnContinuation(&continuation, expr->id()); } } HInstruction* HOptimizedGraphBuilder::BuildThisFunction() { // If we share optimized code between different closures, the // this-function is not a constant, except inside an inlined body. if (function_state()->outer() != NULL) { return New<HConstant>( function_state()->compilation_info()->closure()); } else { return New<HThisFunction>(); } } HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( Handle<JSObject> boilerplate_object, AllocationSiteUsageContext* site_context) { NoObservableSideEffectsScope no_effects(this); InstanceType instance_type = boilerplate_object->map()->instance_type(); ASSERT(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); HType type = instance_type == JS_ARRAY_TYPE ? HType::JSArray() : HType::JSObject(); HValue* object_size_constant = Add<HConstant>( boilerplate_object->map()->instance_size()); PretenureFlag pretenure_flag = NOT_TENURED; if (FLAG_allocation_site_pretenuring) { pretenure_flag = site_context->current()->GetPretenureMode(); Handle<AllocationSite> site(site_context->current()); AllocationSite::AddDependentCompilationInfo( site, AllocationSite::TENURING, top_info()); } HInstruction* object = Add<HAllocate>(object_size_constant, type, pretenure_flag, instance_type, site_context->current()); // If allocation folding reaches Page::kMaxRegularHeapObjectSize the // elements array may not get folded into the object. Hence, we set the // elements pointer to empty fixed array and let store elimination remove // this store in the folding case. HConstant* empty_fixed_array = Add<HConstant>( isolate()->factory()->empty_fixed_array()); Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), empty_fixed_array); BuildEmitObjectHeader(boilerplate_object, object); Handle<FixedArrayBase> elements(boilerplate_object->elements()); int elements_size = (elements->length() > 0 && elements->map() != isolate()->heap()->fixed_cow_array_map()) ? elements->Size() : 0; if (pretenure_flag == TENURED && elements->map() == isolate()->heap()->fixed_cow_array_map() && isolate()->heap()->InNewSpace(*elements)) { // If we would like to pretenure a fixed cow array, we must ensure that the // array is already in old space, otherwise we'll create too many old-to- // new-space pointers (overflowing the store buffer). elements = Handle<FixedArrayBase>( isolate()->factory()->CopyAndTenureFixedCOWArray( Handle<FixedArray>::cast(elements))); boilerplate_object->set_elements(*elements); } HInstruction* object_elements = NULL; if (elements_size > 0) { HValue* object_elements_size = Add<HConstant>(elements_size); InstanceType instance_type = boilerplate_object->HasFastDoubleElements() ? FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE; object_elements = Add<HAllocate>( object_elements_size, HType::HeapObject(), pretenure_flag, instance_type, site_context->current()); } BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); // Copy object elements if non-COW. if (object_elements != NULL) { BuildEmitElements(boilerplate_object, elements, object_elements, site_context); } // Copy in-object properties. if (boilerplate_object->map()->NumberOfFields() != 0) { BuildEmitInObjectProperties(boilerplate_object, object, site_context, pretenure_flag); } return object; } void HOptimizedGraphBuilder::BuildEmitObjectHeader( Handle<JSObject> boilerplate_object, HInstruction* object) { ASSERT(boilerplate_object->properties()->length() == 0); Handle<Map> boilerplate_object_map(boilerplate_object->map()); AddStoreMapConstant(object, boilerplate_object_map); Handle<Object> properties_field = Handle<Object>(boilerplate_object->properties(), isolate()); ASSERT(*properties_field == isolate()->heap()->empty_fixed_array()); HInstruction* properties = Add<HConstant>(properties_field); HObjectAccess access = HObjectAccess::ForPropertiesPointer(); Add<HStoreNamedField>(object, access, properties); if (boilerplate_object->IsJSArray()) { Handle<JSArray> boilerplate_array = Handle<JSArray>::cast(boilerplate_object); Handle<Object> length_field = Handle<Object>(boilerplate_array->length(), isolate()); HInstruction* length = Add<HConstant>(length_field); ASSERT(boilerplate_array->length()->IsSmi()); Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength( boilerplate_array->GetElementsKind()), length); } } void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader( Handle<JSObject> boilerplate_object, HInstruction* object, HInstruction* object_elements) { ASSERT(boilerplate_object->properties()->length() == 0); if (object_elements == NULL) { Handle<Object> elements_field = Handle<Object>(boilerplate_object->elements(), isolate()); object_elements = Add<HConstant>(elements_field); } Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), object_elements); } void HOptimizedGraphBuilder::BuildEmitInObjectProperties( Handle<JSObject> boilerplate_object, HInstruction* object, AllocationSiteUsageContext* site_context, PretenureFlag pretenure_flag) { Handle<Map> boilerplate_map(boilerplate_object->map()); Handle<DescriptorArray> descriptors(boilerplate_map->instance_descriptors()); int limit = boilerplate_map->NumberOfOwnDescriptors(); int copied_fields = 0; for (int i = 0; i < limit; i++) { PropertyDetails details = descriptors->GetDetails(i); if (details.type() != FIELD) continue; copied_fields++; int index = descriptors->GetFieldIndex(i); int property_offset = boilerplate_object->GetInObjectPropertyOffset(index); Handle<Name> name(descriptors->GetKey(i)); Handle<Object> value = Handle<Object>(boilerplate_object->InObjectPropertyAt(index), isolate()); // The access for the store depends on the type of the boilerplate. HObjectAccess access = boilerplate_object->IsJSArray() ? HObjectAccess::ForJSArrayOffset(property_offset) : HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset); if (value->IsJSObject()) { Handle<JSObject> value_object = Handle<JSObject>::cast(value); Handle<AllocationSite> current_site = site_context->EnterNewScope(); HInstruction* result = BuildFastLiteral(value_object, site_context); site_context->ExitScope(current_site, value_object); Add<HStoreNamedField>(object, access, result); } else { Representation representation = details.representation(); HInstruction* value_instruction; if (representation.IsDouble()) { // Allocate a HeapNumber box and store the value into it. HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); // This heap number alloc does not have a corresponding // AllocationSite. That is okay because // 1) it's a child object of another object with a valid allocation site // 2) we can just use the mode of the parent object for pretenuring HInstruction* double_box = Add<HAllocate>(heap_number_constant, HType::HeapObject(), pretenure_flag, HEAP_NUMBER_TYPE); AddStoreMapConstant(double_box, isolate()->factory()->heap_number_map()); Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(), Add<HConstant>(value)); value_instruction = double_box; } else if (representation.IsSmi()) { value_instruction = value->IsUninitialized() ? graph()->GetConstant0() : Add<HConstant>(value); // Ensure that value is stored as smi. access = access.WithRepresentation(representation); } else { value_instruction = Add<HConstant>(value); } Add<HStoreNamedField>(object, access, value_instruction); } } int inobject_properties = boilerplate_object->map()->inobject_properties(); HInstruction* value_instruction = Add<HConstant>(isolate()->factory()->one_pointer_filler_map()); for (int i = copied_fields; i < inobject_properties; i++) { ASSERT(boilerplate_object->IsJSObject()); int property_offset = boilerplate_object->GetInObjectPropertyOffset(i); HObjectAccess access = HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset); Add<HStoreNamedField>(object, access, value_instruction); } } void HOptimizedGraphBuilder::BuildEmitElements( Handle<JSObject> boilerplate_object, Handle<FixedArrayBase> elements, HValue* object_elements, AllocationSiteUsageContext* site_context) { ElementsKind kind = boilerplate_object->map()->elements_kind(); int elements_length = elements->length(); HValue* object_elements_length = Add<HConstant>(elements_length); BuildInitializeElementsHeader(object_elements, kind, object_elements_length); // Copy elements backing store content. if (elements->IsFixedDoubleArray()) { BuildEmitFixedDoubleArray(elements, kind, object_elements); } else if (elements->IsFixedArray()) { BuildEmitFixedArray(elements, kind, object_elements, site_context); } else { UNREACHABLE(); } } void HOptimizedGraphBuilder::BuildEmitFixedDoubleArray( Handle<FixedArrayBase> elements, ElementsKind kind, HValue* object_elements) { HInstruction* boilerplate_elements = Add<HConstant>(elements); int elements_length = elements->length(); for (int i = 0; i < elements_length; i++) { HValue* key_constant = Add<HConstant>(i); HInstruction* value_instruction = Add<HLoadKeyed>(boilerplate_elements, key_constant, static_cast<HValue*>(NULL), kind, ALLOW_RETURN_HOLE); HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); store->SetFlag(HValue::kAllowUndefinedAsNaN); } } void HOptimizedGraphBuilder::BuildEmitFixedArray( Handle<FixedArrayBase> elements, ElementsKind kind, HValue* object_elements, AllocationSiteUsageContext* site_context) { HInstruction* boilerplate_elements = Add<HConstant>(elements); int elements_length = elements->length(); Handle<FixedArray> fast_elements = Handle<FixedArray>::cast(elements); for (int i = 0; i < elements_length; i++) { Handle<Object> value(fast_elements->get(i), isolate()); HValue* key_constant = Add<HConstant>(i); if (value->IsJSObject()) { Handle<JSObject> value_object = Handle<JSObject>::cast(value); Handle<AllocationSite> current_site = site_context->EnterNewScope(); HInstruction* result = BuildFastLiteral(value_object, site_context); site_context->ExitScope(current_site, value_object); Add<HStoreKeyed>(object_elements, key_constant, result, kind); } else { HInstruction* value_instruction = Add<HLoadKeyed>(boilerplate_elements, key_constant, static_cast<HValue*>(NULL), kind, ALLOW_RETURN_HOLE); Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind); } } } void HOptimizedGraphBuilder::VisitThisFunction(ThisFunction* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); HInstruction* instr = BuildThisFunction(); return ast_context()->ReturnInstruction(instr, expr->id()); } void HOptimizedGraphBuilder::VisitDeclarations( ZoneList<Declaration*>* declarations) { ASSERT(globals_.is_empty()); AstVisitor::VisitDeclarations(declarations); if (!globals_.is_empty()) { Handle<FixedArray> array = isolate()->factory()->NewFixedArray(globals_.length(), TENURED); for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i)); int flags = DeclareGlobalsEvalFlag::encode(current_info()->is_eval()) | DeclareGlobalsNativeFlag::encode(current_info()->is_native()) | DeclareGlobalsStrictMode::encode(current_info()->strict_mode()); Add<HDeclareGlobals>(array, flags); globals_.Rewind(0); } } void HOptimizedGraphBuilder::VisitVariableDeclaration( VariableDeclaration* declaration) { VariableProxy* proxy = declaration->proxy(); VariableMode mode = declaration->mode(); Variable* variable = proxy->var(); bool hole_init = mode == LET || mode == CONST || mode == CONST_LEGACY; switch (variable->location()) { case Variable::UNALLOCATED: globals_.Add(variable->name(), zone()); globals_.Add(variable->binding_needs_init() ? isolate()->factory()->the_hole_value() : isolate()->factory()->undefined_value(), zone()); return; case Variable::PARAMETER: case Variable::LOCAL: if (hole_init) { HValue* value = graph()->GetConstantHole(); environment()->Bind(variable, value); } break; case Variable::CONTEXT: if (hole_init) { HValue* value = graph()->GetConstantHole(); HValue* context = environment()->context(); HStoreContextSlot* store = Add<HStoreContextSlot>( context, variable->index(), HStoreContextSlot::kNoCheck, value); if (store->HasObservableSideEffects()) { Add<HSimulate>(proxy->id(), REMOVABLE_SIMULATE); } } break; case Variable::LOOKUP: return Bailout(kUnsupportedLookupSlotInDeclaration); } } void HOptimizedGraphBuilder::VisitFunctionDeclaration( FunctionDeclaration* declaration) { VariableProxy* proxy = declaration->proxy(); Variable* variable = proxy->var(); switch (variable->location()) { case Variable::UNALLOCATED: { globals_.Add(variable->name(), zone()); Handle<SharedFunctionInfo> function = Compiler::BuildFunctionInfo( declaration->fun(), current_info()->script()); // Check for stack-overflow exception. if (function.is_null()) return SetStackOverflow(); globals_.Add(function, zone()); return; } case Variable::PARAMETER: case Variable::LOCAL: { CHECK_ALIVE(VisitForValue(declaration->fun())); HValue* value = Pop(); BindIfLive(variable, value); break; } case Variable::CONTEXT: { CHECK_ALIVE(VisitForValue(declaration->fun())); HValue* value = Pop(); HValue* context = environment()->context(); HStoreContextSlot* store = Add<HStoreContextSlot>( context, variable->index(), HStoreContextSlot::kNoCheck, value); if (store->HasObservableSideEffects()) { Add<HSimulate>(proxy->id(), REMOVABLE_SIMULATE); } break; } case Variable::LOOKUP: return Bailout(kUnsupportedLookupSlotInDeclaration); } } void HOptimizedGraphBuilder::VisitModuleDeclaration( ModuleDeclaration* declaration) { UNREACHABLE(); } void HOptimizedGraphBuilder::VisitImportDeclaration( ImportDeclaration* declaration) { UNREACHABLE(); } void HOptimizedGraphBuilder::VisitExportDeclaration( ExportDeclaration* declaration) { UNREACHABLE(); } void HOptimizedGraphBuilder::VisitModuleLiteral(ModuleLiteral* module) { UNREACHABLE(); } void HOptimizedGraphBuilder::VisitModuleVariable(ModuleVariable* module) { UNREACHABLE(); } void HOptimizedGraphBuilder::VisitModulePath(ModulePath* module) { UNREACHABLE(); } void HOptimizedGraphBuilder::VisitModuleUrl(ModuleUrl* module) { UNREACHABLE(); } void HOptimizedGraphBuilder::VisitModuleStatement(ModuleStatement* stmt) { UNREACHABLE(); } // Generators for inline runtime functions. // Support for types. void HOptimizedGraphBuilder::GenerateIsSmi(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HIsSmiAndBranch* result = New<HIsSmiAndBranch>(value); return ast_context()->ReturnControl(result, call->id()); } void HOptimizedGraphBuilder::GenerateIsSpecObject(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HHasInstanceTypeAndBranch* result = New<HHasInstanceTypeAndBranch>(value, FIRST_SPEC_OBJECT_TYPE, LAST_SPEC_OBJECT_TYPE); return ast_context()->ReturnControl(result, call->id()); } void HOptimizedGraphBuilder::GenerateIsFunction(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HHasInstanceTypeAndBranch* result = New<HHasInstanceTypeAndBranch>(value, JS_FUNCTION_TYPE); return ast_context()->ReturnControl(result, call->id()); } void HOptimizedGraphBuilder::GenerateIsMinusZero(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HCompareMinusZeroAndBranch* result = New<HCompareMinusZeroAndBranch>(value); return ast_context()->ReturnControl(result, call->id()); } void HOptimizedGraphBuilder::GenerateHasCachedArrayIndex(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HHasCachedArrayIndexAndBranch* result = New<HHasCachedArrayIndexAndBranch>(value); return ast_context()->ReturnControl(result, call->id()); } void HOptimizedGraphBuilder::GenerateIsArray(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HHasInstanceTypeAndBranch* result = New<HHasInstanceTypeAndBranch>(value, JS_ARRAY_TYPE); return ast_context()->ReturnControl(result, call->id()); } void HOptimizedGraphBuilder::GenerateIsRegExp(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HHasInstanceTypeAndBranch* result = New<HHasInstanceTypeAndBranch>(value, JS_REGEXP_TYPE); return ast_context()->ReturnControl(result, call->id()); } void HOptimizedGraphBuilder::GenerateIsObject(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HIsObjectAndBranch* result = New<HIsObjectAndBranch>(value); return ast_context()->ReturnControl(result, call->id()); } void HOptimizedGraphBuilder::GenerateIsNonNegativeSmi(CallRuntime* call) { return Bailout(kInlinedRuntimeFunctionIsNonNegativeSmi); } void HOptimizedGraphBuilder::GenerateIsUndetectableObject(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HIsUndetectableAndBranch* result = New<HIsUndetectableAndBranch>(value); return ast_context()->ReturnControl(result, call->id()); } void HOptimizedGraphBuilder::GenerateIsStringWrapperSafeForDefaultValueOf( CallRuntime* call) { return Bailout(kInlinedRuntimeFunctionIsStringWrapperSafeForDefaultValueOf); } // Support for construct call checks. void HOptimizedGraphBuilder::GenerateIsConstructCall(CallRuntime* call) { ASSERT(call->arguments()->length() == 0); if (function_state()->outer() != NULL) { // We are generating graph for inlined function. HValue* value = function_state()->inlining_kind() == CONSTRUCT_CALL_RETURN ? graph()->GetConstantTrue() : graph()->GetConstantFalse(); return ast_context()->ReturnValue(value); } else { return ast_context()->ReturnControl(New<HIsConstructCallAndBranch>(), call->id()); } } // Support for arguments.length and arguments[?]. void HOptimizedGraphBuilder::GenerateArgumentsLength(CallRuntime* call) { // Our implementation of arguments (based on this stack frame or an // adapter below it) does not work for inlined functions. This runtime // function is blacklisted by AstNode::IsInlineable. ASSERT(function_state()->outer() == NULL); ASSERT(call->arguments()->length() == 0); HInstruction* elements = Add<HArgumentsElements>(false); HArgumentsLength* result = New<HArgumentsLength>(elements); return ast_context()->ReturnInstruction(result, call->id()); } void HOptimizedGraphBuilder::GenerateArguments(CallRuntime* call) { // Our implementation of arguments (based on this stack frame or an // adapter below it) does not work for inlined functions. This runtime // function is blacklisted by AstNode::IsInlineable. ASSERT(function_state()->outer() == NULL); ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* index = Pop(); HInstruction* elements = Add<HArgumentsElements>(false); HInstruction* length = Add<HArgumentsLength>(elements); HInstruction* checked_index = Add<HBoundsCheck>(index, length); HAccessArgumentsAt* result = New<HAccessArgumentsAt>( elements, length, checked_index); return ast_context()->ReturnInstruction(result, call->id()); } // Support for accessing the class and value fields of an object. void HOptimizedGraphBuilder::GenerateClassOf(CallRuntime* call) { // The special form detected by IsClassOfTest is detected before we get here // and does not cause a bailout. return Bailout(kInlinedRuntimeFunctionClassOf); } void HOptimizedGraphBuilder::GenerateValueOf(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* object = Pop(); IfBuilder if_objectisvalue(this); HValue* objectisvalue = if_objectisvalue.If<HHasInstanceTypeAndBranch>( object, JS_VALUE_TYPE); if_objectisvalue.Then(); { // Return the actual value. Push(Add<HLoadNamedField>( object, objectisvalue, HObjectAccess::ForObservableJSObjectOffset( JSValue::kValueOffset))); Add<HSimulate>(call->id(), FIXED_SIMULATE); } if_objectisvalue.Else(); { // If the object is not a value return the object. Push(object); Add<HSimulate>(call->id(), FIXED_SIMULATE); } if_objectisvalue.End(); return ast_context()->ReturnValue(Pop()); } void HOptimizedGraphBuilder::GenerateDateField(CallRuntime* call) { ASSERT(call->arguments()->length() == 2); ASSERT_NE(NULL, call->arguments()->at(1)->AsLiteral()); Smi* index = Smi::cast(*(call->arguments()->at(1)->AsLiteral()->value())); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* date = Pop(); HDateField* result = New<HDateField>(date, index); return ast_context()->ReturnInstruction(result, call->id()); } void HOptimizedGraphBuilder::GenerateOneByteSeqStringSetChar( CallRuntime* call) { ASSERT(call->arguments()->length() == 3); // We need to follow the evaluation order of full codegen. CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); CHECK_ALIVE(VisitForValue(call->arguments()->at(2))); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* string = Pop(); HValue* value = Pop(); HValue* index = Pop(); Add<HSeqStringSetChar>(String::ONE_BYTE_ENCODING, string, index, value); Add<HSimulate>(call->id(), FIXED_SIMULATE); return ast_context()->ReturnValue(graph()->GetConstantUndefined()); } void HOptimizedGraphBuilder::GenerateTwoByteSeqStringSetChar( CallRuntime* call) { ASSERT(call->arguments()->length() == 3); // We need to follow the evaluation order of full codegen. CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); CHECK_ALIVE(VisitForValue(call->arguments()->at(2))); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* string = Pop(); HValue* value = Pop(); HValue* index = Pop(); Add<HSeqStringSetChar>(String::TWO_BYTE_ENCODING, string, index, value); Add<HSimulate>(call->id(), FIXED_SIMULATE); return ast_context()->ReturnValue(graph()->GetConstantUndefined()); } void HOptimizedGraphBuilder::GenerateSetValueOf(CallRuntime* call) { ASSERT(call->arguments()->length() == 2); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); HValue* value = Pop(); HValue* object = Pop(); // Check if object is a JSValue. IfBuilder if_objectisvalue(this); if_objectisvalue.If<HHasInstanceTypeAndBranch>(object, JS_VALUE_TYPE); if_objectisvalue.Then(); { // Create in-object property store to kValueOffset. Add<HStoreNamedField>(object, HObjectAccess::ForObservableJSObjectOffset(JSValue::kValueOffset), value); if (!ast_context()->IsEffect()) { Push(value); } Add<HSimulate>(call->id(), FIXED_SIMULATE); } if_objectisvalue.Else(); { // Nothing to do in this case. if (!ast_context()->IsEffect()) { Push(value); } Add<HSimulate>(call->id(), FIXED_SIMULATE); } if_objectisvalue.End(); if (!ast_context()->IsEffect()) { Drop(1); } return ast_context()->ReturnValue(value); } // Fast support for charCodeAt(n). void HOptimizedGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) { ASSERT(call->arguments()->length() == 2); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); HValue* index = Pop(); HValue* string = Pop(); HInstruction* result = BuildStringCharCodeAt(string, index); return ast_context()->ReturnInstruction(result, call->id()); } // Fast support for string.charAt(n) and string[n]. void HOptimizedGraphBuilder::GenerateStringCharFromCode(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* char_code = Pop(); HInstruction* result = NewUncasted<HStringCharFromCode>(char_code); return ast_context()->ReturnInstruction(result, call->id()); } // Fast support for string.charAt(n) and string[n]. void HOptimizedGraphBuilder::GenerateStringCharAt(CallRuntime* call) { ASSERT(call->arguments()->length() == 2); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); HValue* index = Pop(); HValue* string = Pop(); HInstruction* char_code = BuildStringCharCodeAt(string, index); AddInstruction(char_code); HInstruction* result = NewUncasted<HStringCharFromCode>(char_code); return ast_context()->ReturnInstruction(result, call->id()); } // Fast support for object equality testing. void HOptimizedGraphBuilder::GenerateObjectEquals(CallRuntime* call) { ASSERT(call->arguments()->length() == 2); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); HValue* right = Pop(); HValue* left = Pop(); HCompareObjectEqAndBranch* result = New<HCompareObjectEqAndBranch>(left, right); return ast_context()->ReturnControl(result, call->id()); } // Fast support for StringAdd. void HOptimizedGraphBuilder::GenerateStringAdd(CallRuntime* call) { ASSERT_EQ(2, call->arguments()->length()); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); HValue* right = Pop(); HValue* left = Pop(); HInstruction* result = NewUncasted<HStringAdd>(left, right); return ast_context()->ReturnInstruction(result, call->id()); } // Fast support for SubString. void HOptimizedGraphBuilder::GenerateSubString(CallRuntime* call) { ASSERT_EQ(3, call->arguments()->length()); CHECK_ALIVE(VisitExpressions(call->arguments())); PushArgumentsFromEnvironment(call->arguments()->length()); HCallStub* result = New<HCallStub>(CodeStub::SubString, 3); return ast_context()->ReturnInstruction(result, call->id()); } // Fast support for StringCompare. void HOptimizedGraphBuilder::GenerateStringCompare(CallRuntime* call) { ASSERT_EQ(2, call->arguments()->length()); CHECK_ALIVE(VisitExpressions(call->arguments())); PushArgumentsFromEnvironment(call->arguments()->length()); HCallStub* result = New<HCallStub>(CodeStub::StringCompare, 2); return ast_context()->ReturnInstruction(result, call->id()); } // Support for direct calls from JavaScript to native RegExp code. void HOptimizedGraphBuilder::GenerateRegExpExec(CallRuntime* call) { ASSERT_EQ(4, call->arguments()->length()); CHECK_ALIVE(VisitExpressions(call->arguments())); PushArgumentsFromEnvironment(call->arguments()->length()); HCallStub* result = New<HCallStub>(CodeStub::RegExpExec, 4); return ast_context()->ReturnInstruction(result, call->id()); } void HOptimizedGraphBuilder::GenerateDoubleLo(CallRuntime* call) { ASSERT_EQ(1, call->arguments()->length()); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HInstruction* result = NewUncasted<HDoubleBits>(value, HDoubleBits::LOW); return ast_context()->ReturnInstruction(result, call->id()); } void HOptimizedGraphBuilder::GenerateDoubleHi(CallRuntime* call) { ASSERT_EQ(1, call->arguments()->length()); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HInstruction* result = NewUncasted<HDoubleBits>(value, HDoubleBits::HIGH); return ast_context()->ReturnInstruction(result, call->id()); } void HOptimizedGraphBuilder::GenerateConstructDouble(CallRuntime* call) { ASSERT_EQ(2, call->arguments()->length()); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); HValue* lo = Pop(); HValue* hi = Pop(); HInstruction* result = NewUncasted<HConstructDouble>(hi, lo); return ast_context()->ReturnInstruction(result, call->id()); } // Construct a RegExp exec result with two in-object properties. void HOptimizedGraphBuilder::GenerateRegExpConstructResult(CallRuntime* call) { ASSERT_EQ(3, call->arguments()->length()); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); CHECK_ALIVE(VisitForValue(call->arguments()->at(2))); HValue* input = Pop(); HValue* index = Pop(); HValue* length = Pop(); HValue* result = BuildRegExpConstructResult(length, index, input); return ast_context()->ReturnValue(result); } // Support for fast native caches. void HOptimizedGraphBuilder::GenerateGetFromCache(CallRuntime* call) { return Bailout(kInlinedRuntimeFunctionGetFromCache); } // Fast support for number to string. void HOptimizedGraphBuilder::GenerateNumberToString(CallRuntime* call) { ASSERT_EQ(1, call->arguments()->length()); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* number = Pop(); HValue* result = BuildNumberToString(number, Type::Any(zone())); return ast_context()->ReturnValue(result); } // Fast call for custom callbacks. void HOptimizedGraphBuilder::GenerateCallFunction(CallRuntime* call) { // 1 ~ The function to call is not itself an argument to the call. int arg_count = call->arguments()->length() - 1; ASSERT(arg_count >= 1); // There's always at least a receiver. CHECK_ALIVE(VisitExpressions(call->arguments())); // The function is the last argument HValue* function = Pop(); // Push the arguments to the stack PushArgumentsFromEnvironment(arg_count); IfBuilder if_is_jsfunction(this); if_is_jsfunction.If<HHasInstanceTypeAndBranch>(function, JS_FUNCTION_TYPE); if_is_jsfunction.Then(); { HInstruction* invoke_result = Add<HInvokeFunction>(function, arg_count); if (!ast_context()->IsEffect()) { Push(invoke_result); } Add<HSimulate>(call->id(), FIXED_SIMULATE); } if_is_jsfunction.Else(); { HInstruction* call_result = Add<HCallFunction>(function, arg_count); if (!ast_context()->IsEffect()) { Push(call_result); } Add<HSimulate>(call->id(), FIXED_SIMULATE); } if_is_jsfunction.End(); if (ast_context()->IsEffect()) { // EffectContext::ReturnValue ignores the value, so we can just pass // 'undefined' (as we do not have the call result anymore). return ast_context()->ReturnValue(graph()->GetConstantUndefined()); } else { return ast_context()->ReturnValue(Pop()); } } // Fast call to math functions. void HOptimizedGraphBuilder::GenerateMathPow(CallRuntime* call) { ASSERT_EQ(2, call->arguments()->length()); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); HValue* right = Pop(); HValue* left = Pop(); HInstruction* result = NewUncasted<HPower>(left, right); return ast_context()->ReturnInstruction(result, call->id()); } void HOptimizedGraphBuilder::GenerateMathLogRT(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HInstruction* result = NewUncasted<HUnaryMathOperation>(value, kMathLog); return ast_context()->ReturnInstruction(result, call->id()); } void HOptimizedGraphBuilder::GenerateMathSqrtRT(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HInstruction* result = NewUncasted<HUnaryMathOperation>(value, kMathSqrt); return ast_context()->ReturnInstruction(result, call->id()); } void HOptimizedGraphBuilder::GenerateGetCachedArrayIndex(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); HValue* value = Pop(); HGetCachedArrayIndex* result = New<HGetCachedArrayIndex>(value); return ast_context()->ReturnInstruction(result, call->id()); } void HOptimizedGraphBuilder::GenerateFastAsciiArrayJoin(CallRuntime* call) { return Bailout(kInlinedRuntimeFunctionFastAsciiArrayJoin); } // Support for generators. void HOptimizedGraphBuilder::GenerateGeneratorNext(CallRuntime* call) { return Bailout(kInlinedRuntimeFunctionGeneratorNext); } void HOptimizedGraphBuilder::GenerateGeneratorThrow(CallRuntime* call) { return Bailout(kInlinedRuntimeFunctionGeneratorThrow); } void HOptimizedGraphBuilder::GenerateDebugBreakInOptimizedCode( CallRuntime* call) { Add<HDebugBreak>(); return ast_context()->ReturnValue(graph()->GetConstant0()); } void HOptimizedGraphBuilder::GenerateDebugIsActive(CallRuntime* call) { ASSERT(call->arguments()->length() == 0); HValue* ref = Add<HConstant>(ExternalReference::debug_is_active_address(isolate())); HValue* value = Add<HLoadNamedField>( ref, static_cast<HValue*>(NULL), HObjectAccess::ForExternalUInteger8()); return ast_context()->ReturnValue(value); } #undef CHECK_BAILOUT #undef CHECK_ALIVE HEnvironment::HEnvironment(HEnvironment* outer, Scope* scope, Handle<JSFunction> closure, Zone* zone) : closure_(closure), values_(0, zone), frame_type_(JS_FUNCTION), parameter_count_(0), specials_count_(1), local_count_(0), outer_(outer), entry_(NULL), pop_count_(0), push_count_(0), ast_id_(BailoutId::None()), zone_(zone) { Scope* declaration_scope = scope->DeclarationScope(); Initialize(declaration_scope->num_parameters() + 1, declaration_scope->num_stack_slots(), 0); } HEnvironment::HEnvironment(Zone* zone, int parameter_count) : values_(0, zone), frame_type_(STUB), parameter_count_(parameter_count), specials_count_(1), local_count_(0), outer_(NULL), entry_(NULL), pop_count_(0), push_count_(0), ast_id_(BailoutId::None()), zone_(zone) { Initialize(parameter_count, 0, 0); } HEnvironment::HEnvironment(const HEnvironment* other, Zone* zone) : values_(0, zone), frame_type_(JS_FUNCTION), parameter_count_(0), specials_count_(0), local_count_(0), outer_(NULL), entry_(NULL), pop_count_(0), push_count_(0), ast_id_(other->ast_id()), zone_(zone) { Initialize(other); } HEnvironment::HEnvironment(HEnvironment* outer, Handle<JSFunction> closure, FrameType frame_type, int arguments, Zone* zone) : closure_(closure), values_(arguments, zone), frame_type_(frame_type), parameter_count_(arguments), specials_count_(0), local_count_(0), outer_(outer), entry_(NULL), pop_count_(0), push_count_(0), ast_id_(BailoutId::None()), zone_(zone) { } void HEnvironment::Initialize(int parameter_count, int local_count, int stack_height) { parameter_count_ = parameter_count; local_count_ = local_count; // Avoid reallocating the temporaries' backing store on the first Push. int total = parameter_count + specials_count_ + local_count + stack_height; values_.Initialize(total + 4, zone()); for (int i = 0; i < total; ++i) values_.Add(NULL, zone()); } void HEnvironment::Initialize(const HEnvironment* other) { closure_ = other->closure(); values_.AddAll(other->values_, zone()); assigned_variables_.Union(other->assigned_variables_, zone()); frame_type_ = other->frame_type_; parameter_count_ = other->parameter_count_; local_count_ = other->local_count_; if (other->outer_ != NULL) outer_ = other->outer_->Copy(); // Deep copy. entry_ = other->entry_; pop_count_ = other->pop_count_; push_count_ = other->push_count_; specials_count_ = other->specials_count_; ast_id_ = other->ast_id_; } void HEnvironment::AddIncomingEdge(HBasicBlock* block, HEnvironment* other) { ASSERT(!block->IsLoopHeader()); ASSERT(values_.length() == other->values_.length()); int length = values_.length(); for (int i = 0; i < length; ++i) { HValue* value = values_[i]; if (value != NULL && value->IsPhi() && value->block() == block) { // There is already a phi for the i'th value. HPhi* phi = HPhi::cast(value); // Assert index is correct and that we haven't missed an incoming edge. ASSERT(phi->merged_index() == i || !phi->HasMergedIndex()); ASSERT(phi->OperandCount() == block->predecessors()->length()); phi->AddInput(other->values_[i]); } else if (values_[i] != other->values_[i]) { // There is a fresh value on the incoming edge, a phi is needed. ASSERT(values_[i] != NULL && other->values_[i] != NULL); HPhi* phi = block->AddNewPhi(i); HValue* old_value = values_[i]; for (int j = 0; j < block->predecessors()->length(); j++) { phi->AddInput(old_value); } phi->AddInput(other->values_[i]); this->values_[i] = phi; } } } void HEnvironment::Bind(int index, HValue* value) { ASSERT(value != NULL); assigned_variables_.Add(index, zone()); values_[index] = value; } bool HEnvironment::HasExpressionAt(int index) const { return index >= parameter_count_ + specials_count_ + local_count_; } bool HEnvironment::ExpressionStackIsEmpty() const { ASSERT(length() >= first_expression_index()); return length() == first_expression_index(); } void HEnvironment::SetExpressionStackAt(int index_from_top, HValue* value) { int count = index_from_top + 1; int index = values_.length() - count; ASSERT(HasExpressionAt(index)); // The push count must include at least the element in question or else // the new value will not be included in this environment's history. if (push_count_ < count) { // This is the same effect as popping then re-pushing 'count' elements. pop_count_ += (count - push_count_); push_count_ = count; } values_[index] = value; } void HEnvironment::Drop(int count) { for (int i = 0; i < count; ++i) { Pop(); } } HEnvironment* HEnvironment::Copy() const { return new(zone()) HEnvironment(this, zone()); } HEnvironment* HEnvironment::CopyWithoutHistory() const { HEnvironment* result = Copy(); result->ClearHistory(); return result; } HEnvironment* HEnvironment::CopyAsLoopHeader(HBasicBlock* loop_header) const { HEnvironment* new_env = Copy(); for (int i = 0; i < values_.length(); ++i) { HPhi* phi = loop_header->AddNewPhi(i); phi->AddInput(values_[i]); new_env->values_[i] = phi; } new_env->ClearHistory(); return new_env; } HEnvironment* HEnvironment::CreateStubEnvironment(HEnvironment* outer, Handle<JSFunction> target, FrameType frame_type, int arguments) const { HEnvironment* new_env = new(zone()) HEnvironment(outer, target, frame_type, arguments + 1, zone()); for (int i = 0; i <= arguments; ++i) { // Include receiver. new_env->Push(ExpressionStackAt(arguments - i)); } new_env->ClearHistory(); return new_env; } HEnvironment* HEnvironment::CopyForInlining( Handle<JSFunction> target, int arguments, FunctionLiteral* function, HConstant* undefined, InliningKind inlining_kind) const { ASSERT(frame_type() == JS_FUNCTION); // Outer environment is a copy of this one without the arguments. int arity = function->scope()->num_parameters(); HEnvironment* outer = Copy(); outer->Drop(arguments + 1); // Including receiver. outer->ClearHistory(); if (inlining_kind == CONSTRUCT_CALL_RETURN) { // Create artificial constructor stub environment. The receiver should // actually be the constructor function, but we pass the newly allocated // object instead, DoComputeConstructStubFrame() relies on that. outer = CreateStubEnvironment(outer, target, JS_CONSTRUCT, arguments); } else if (inlining_kind == GETTER_CALL_RETURN) { // We need an additional StackFrame::INTERNAL frame for restoring the // correct context. outer = CreateStubEnvironment(outer, target, JS_GETTER, arguments); } else if (inlining_kind == SETTER_CALL_RETURN) { // We need an additional StackFrame::INTERNAL frame for temporarily saving // the argument of the setter, see StoreStubCompiler::CompileStoreViaSetter. outer = CreateStubEnvironment(outer, target, JS_SETTER, arguments); } if (arity != arguments) { // Create artificial arguments adaptation environment. outer = CreateStubEnvironment(outer, target, ARGUMENTS_ADAPTOR, arguments); } HEnvironment* inner = new(zone()) HEnvironment(outer, function->scope(), target, zone()); // Get the argument values from the original environment. for (int i = 0; i <= arity; ++i) { // Include receiver. HValue* push = (i <= arguments) ? ExpressionStackAt(arguments - i) : undefined; inner->SetValueAt(i, push); } inner->SetValueAt(arity + 1, context()); for (int i = arity + 2; i < inner->length(); ++i) { inner->SetValueAt(i, undefined); } inner->set_ast_id(BailoutId::FunctionEntry()); return inner; } void HEnvironment::PrintTo(StringStream* stream) { for (int i = 0; i < length(); i++) { if (i == 0) stream->Add("parameters\n"); if (i == parameter_count()) stream->Add("specials\n"); if (i == parameter_count() + specials_count()) stream->Add("locals\n"); if (i == parameter_count() + specials_count() + local_count()) { stream->Add("expressions\n"); } HValue* val = values_.at(i); stream->Add("%d: ", i); if (val != NULL) { val->PrintNameTo(stream); } else { stream->Add("NULL"); } stream->Add("\n"); } PrintF("\n"); } void HEnvironment::PrintToStd() { HeapStringAllocator string_allocator; StringStream trace(&string_allocator); PrintTo(&trace); PrintF("%s", trace.ToCString().get()); } void HTracer::TraceCompilation(CompilationInfo* info) { Tag tag(this, "compilation"); if (info->IsOptimizing()) { Handle<String> name = info->function()->debug_name(); PrintStringProperty("name", name->ToCString().get()); PrintIndent(); trace_.Add("method \"%s:%d\"\n", name->ToCString().get(), info->optimization_id()); } else { CodeStub::Major major_key = info->code_stub()->MajorKey(); PrintStringProperty("name", CodeStub::MajorName(major_key, false)); PrintStringProperty("method", "stub"); } PrintLongProperty("date", static_cast<int64_t>(OS::TimeCurrentMillis())); } void HTracer::TraceLithium(const char* name, LChunk* chunk) { ASSERT(!chunk->isolate()->concurrent_recompilation_enabled()); AllowHandleDereference allow_deref; AllowDeferredHandleDereference allow_deferred_deref; Trace(name, chunk->graph(), chunk); } void HTracer::TraceHydrogen(const char* name, HGraph* graph) { ASSERT(!graph->isolate()->concurrent_recompilation_enabled()); AllowHandleDereference allow_deref; AllowDeferredHandleDereference allow_deferred_deref; Trace(name, graph, NULL); } void HTracer::Trace(const char* name, HGraph* graph, LChunk* chunk) { Tag tag(this, "cfg"); PrintStringProperty("name", name); const ZoneList<HBasicBlock*>* blocks = graph->blocks(); for (int i = 0; i < blocks->length(); i++) { HBasicBlock* current = blocks->at(i); Tag block_tag(this, "block"); PrintBlockProperty("name", current->block_id()); PrintIntProperty("from_bci", -1); PrintIntProperty("to_bci", -1); if (!current->predecessors()->is_empty()) { PrintIndent(); trace_.Add("predecessors"); for (int j = 0; j < current->predecessors()->length(); ++j) { trace_.Add(" \"B%d\"", current->predecessors()->at(j)->block_id()); } trace_.Add("\n"); } else { PrintEmptyProperty("predecessors"); } if (current->end()->SuccessorCount() == 0) { PrintEmptyProperty("successors"); } else { PrintIndent(); trace_.Add("successors"); for (HSuccessorIterator it(current->end()); !it.Done(); it.Advance()) { trace_.Add(" \"B%d\"", it.Current()->block_id()); } trace_.Add("\n"); } PrintEmptyProperty("xhandlers"); { PrintIndent(); trace_.Add("flags"); if (current->IsLoopSuccessorDominator()) { trace_.Add(" \"dom-loop-succ\""); } if (current->IsUnreachable()) { trace_.Add(" \"dead\""); } if (current->is_osr_entry()) { trace_.Add(" \"osr\""); } trace_.Add("\n"); } if (current->dominator() != NULL) { PrintBlockProperty("dominator", current->dominator()->block_id()); } PrintIntProperty("loop_depth", current->LoopNestingDepth()); if (chunk != NULL) { int first_index = current->first_instruction_index(); int last_index = current->last_instruction_index(); PrintIntProperty( "first_lir_id", LifetimePosition::FromInstructionIndex(first_index).Value()); PrintIntProperty( "last_lir_id", LifetimePosition::FromInstructionIndex(last_index).Value()); } { Tag states_tag(this, "states"); Tag locals_tag(this, "locals"); int total = current->phis()->length(); PrintIntProperty("size", current->phis()->length()); PrintStringProperty("method", "None"); for (int j = 0; j < total; ++j) { HPhi* phi = current->phis()->at(j); PrintIndent(); trace_.Add("%d ", phi->merged_index()); phi->PrintNameTo(&trace_); trace_.Add(" "); phi->PrintTo(&trace_); trace_.Add("\n"); } } { Tag HIR_tag(this, "HIR"); for (HInstructionIterator it(current); !it.Done(); it.Advance()) { HInstruction* instruction = it.Current(); int uses = instruction->UseCount(); PrintIndent(); trace_.Add("0 %d ", uses); instruction->PrintNameTo(&trace_); trace_.Add(" "); instruction->PrintTo(&trace_); if (FLAG_hydrogen_track_positions && instruction->has_position() && instruction->position().raw() != 0) { const HSourcePosition pos = instruction->position(); trace_.Add(" pos:"); if (pos.inlining_id() != 0) { trace_.Add("%d_", pos.inlining_id()); } trace_.Add("%d", pos.position()); } trace_.Add(" <|@\n"); } } if (chunk != NULL) { Tag LIR_tag(this, "LIR"); int first_index = current->first_instruction_index(); int last_index = current->last_instruction_index(); if (first_index != -1 && last_index != -1) { const ZoneList<LInstruction*>* instructions = chunk->instructions(); for (int i = first_index; i <= last_index; ++i) { LInstruction* linstr = instructions->at(i); if (linstr != NULL) { PrintIndent(); trace_.Add("%d ", LifetimePosition::FromInstructionIndex(i).Value()); linstr->PrintTo(&trace_); trace_.Add(" [hir:"); linstr->hydrogen_value()->PrintNameTo(&trace_); trace_.Add("]"); trace_.Add(" <|@\n"); } } } } } } void HTracer::TraceLiveRanges(const char* name, LAllocator* allocator) { Tag tag(this, "intervals"); PrintStringProperty("name", name); const Vector<LiveRange*>* fixed_d = allocator->fixed_double_live_ranges(); for (int i = 0; i < fixed_d->length(); ++i) { TraceLiveRange(fixed_d->at(i), "fixed", allocator->zone()); } const Vector<LiveRange*>* fixed = allocator->fixed_live_ranges(); for (int i = 0; i < fixed->length(); ++i) { TraceLiveRange(fixed->at(i), "fixed", allocator->zone()); } const ZoneList<LiveRange*>* live_ranges = allocator->live_ranges(); for (int i = 0; i < live_ranges->length(); ++i) { TraceLiveRange(live_ranges->at(i), "object", allocator->zone()); } } void HTracer::TraceLiveRange(LiveRange* range, const char* type, Zone* zone) { if (range != NULL && !range->IsEmpty()) { PrintIndent(); trace_.Add("%d %s", range->id(), type); if (range->HasRegisterAssigned()) { LOperand* op = range->CreateAssignedOperand(zone); int assigned_reg = op->index(); if (op->IsDoubleRegister()) { trace_.Add(" \"%s\"", DoubleRegister::AllocationIndexToString(assigned_reg)); } else { ASSERT(op->IsRegister()); trace_.Add(" \"%s\"", Register::AllocationIndexToString(assigned_reg)); } } else if (range->IsSpilled()) { LOperand* op = range->TopLevel()->GetSpillOperand(); if (op->IsDoubleStackSlot()) { trace_.Add(" \"double_stack:%d\"", op->index()); } else { ASSERT(op->IsStackSlot()); trace_.Add(" \"stack:%d\"", op->index()); } } int parent_index = -1; if (range->IsChild()) { parent_index = range->parent()->id(); } else { parent_index = range->id(); } LOperand* op = range->FirstHint(); int hint_index = -1; if (op != NULL && op->IsUnallocated()) { hint_index = LUnallocated::cast(op)->virtual_register(); } trace_.Add(" %d %d", parent_index, hint_index); UseInterval* cur_interval = range->first_interval(); while (cur_interval != NULL && range->Covers(cur_interval->start())) { trace_.Add(" [%d, %d[", cur_interval->start().Value(), cur_interval->end().Value()); cur_interval = cur_interval->next(); } UsePosition* current_pos = range->first_pos(); while (current_pos != NULL) { if (current_pos->RegisterIsBeneficial() || FLAG_trace_all_uses) { trace_.Add(" %d M", current_pos->pos().Value()); } current_pos = current_pos->next(); } trace_.Add(" \"\"\n"); } } void HTracer::FlushToFile() { AppendChars(filename_.start(), trace_.ToCString().get(), trace_.length(), false); trace_.Reset(); } void HStatistics::Initialize(CompilationInfo* info) { if (info->shared_info().is_null()) return; source_size_ += info->shared_info()->SourceSize(); } void HStatistics::Print() { PrintF("Timing results:\n"); TimeDelta sum; for (int i = 0; i < times_.length(); ++i) { sum += times_[i]; } for (int i = 0; i < names_.length(); ++i) { PrintF("%32s", names_[i]); double ms = times_[i].InMillisecondsF(); double percent = times_[i].PercentOf(sum); PrintF(" %8.3f ms / %4.1f %% ", ms, percent); unsigned size = sizes_[i]; double size_percent = static_cast<double>(size) * 100 / total_size_; PrintF(" %9u bytes / %4.1f %%\n", size, size_percent); } PrintF("----------------------------------------" "---------------------------------------\n"); TimeDelta total = create_graph_ + optimize_graph_ + generate_code_; PrintF("%32s %8.3f ms / %4.1f %% \n", "Create graph", create_graph_.InMillisecondsF(), create_graph_.PercentOf(total)); PrintF("%32s %8.3f ms / %4.1f %% \n", "Optimize graph", optimize_graph_.InMillisecondsF(), optimize_graph_.PercentOf(total)); PrintF("%32s %8.3f ms / %4.1f %% \n", "Generate and install code", generate_code_.InMillisecondsF(), generate_code_.PercentOf(total)); PrintF("----------------------------------------" "---------------------------------------\n"); PrintF("%32s %8.3f ms (%.1f times slower than full code gen)\n", "Total", total.InMillisecondsF(), total.TimesOf(full_code_gen_)); double source_size_in_kb = static_cast<double>(source_size_) / 1024; double normalized_time = source_size_in_kb > 0 ? total.InMillisecondsF() / source_size_in_kb : 0; double normalized_size_in_kb = source_size_in_kb > 0 ? total_size_ / 1024 / source_size_in_kb : 0; PrintF("%32s %8.3f ms %7.3f kB allocated\n", "Average per kB source", normalized_time, normalized_size_in_kb); } void HStatistics::SaveTiming(const char* name, TimeDelta time, unsigned size) { total_size_ += size; for (int i = 0; i < names_.length(); ++i) { if (strcmp(names_[i], name) == 0) { times_[i] += time; sizes_[i] += size; return; } } names_.Add(name); times_.Add(time); sizes_.Add(size); } HPhase::~HPhase() { if (ShouldProduceTraceOutput()) { isolate()->GetHTracer()->TraceHydrogen(name(), graph_); } #ifdef DEBUG graph_->Verify(false); // No full verify. #endif } } } // namespace v8::internal
35.463436
80
0.654931
Myrannas
339e40e5fab70166359edc36a8c25359479c08d0
470
cpp
C++
Exemplo13/sources/data/Face.cpp
alencarrh/ComputacaoGrafica
b7ea6b46956e47f695e4437fe254fd974a2b90de
[ "MIT" ]
null
null
null
Exemplo13/sources/data/Face.cpp
alencarrh/ComputacaoGrafica
b7ea6b46956e47f695e4437fe254fd974a2b90de
[ "MIT" ]
null
null
null
Exemplo13/sources/data/Face.cpp
alencarrh/ComputacaoGrafica
b7ea6b46956e47f695e4437fe254fd974a2b90de
[ "MIT" ]
null
null
null
#include "../../headers/data/Face.h" Face::Face() {} Face::~Face() { vertices.clear(); vertices.shrink_to_fit(); normais.clear(); normais.shrink_to_fit(); textures.clear(); textures.shrink_to_fit(); } void Face::addVerticeId(int idVertice) { this->vertices.push_back(idVertice); } void Face::addNormalId(int idNormal) { this->normais.push_back(idNormal); } void Face::addTextureId(int idTexture) { this->textures.push_back(idTexture); }
17.407407
40
0.682979
alencarrh
339f12faeca90e0dda5926fb9e53fdad5c1fabea
177
cpp
C++
src/Example/project_WhiteBoxStudio/code/WhiteboxTestingPlatform/WhiteboxTestingPlatform/WhiteboxTestingPlatform/ThirdStandardDataModel.cpp
yds086/HereticOS-ObjectSystem
bdbf48bc3a5ef96c54b3d1652b90740c28c5cf49
[ "Apache-2.0" ]
5
2017-09-07T06:58:34.000Z
2021-07-21T08:41:26.000Z
src/Example/project_WhiteBoxStudio/code/WhiteboxTestingPlatform/WhiteboxTestingPlatform/WhiteboxTestingPlatform/ThirdStandardDataModel.cpp
yds086/HereticOS-ObjectSystem
bdbf48bc3a5ef96c54b3d1652b90740c28c5cf49
[ "Apache-2.0" ]
null
null
null
src/Example/project_WhiteBoxStudio/code/WhiteboxTestingPlatform/WhiteboxTestingPlatform/WhiteboxTestingPlatform/ThirdStandardDataModel.cpp
yds086/HereticOS-ObjectSystem
bdbf48bc3a5ef96c54b3d1652b90740c28c5cf49
[ "Apache-2.0" ]
2
2017-09-27T06:31:11.000Z
2020-05-13T12:29:58.000Z
#include "StdAfx.h" #include "ThirdStandardDataModel.h" CThirdStandardDataModel::CThirdStandardDataModel(void) { } CThirdStandardDataModel::~CThirdStandardDataModel(void) { }
16.090909
55
0.813559
yds086
339fd28879d12676327871f30ea0de3c01012193
4,667
cpp
C++
Nacro/SDK/FN_GA_DefaultPlayer_InteractSearch_functions.cpp
Milxnor/Nacro
eebabf662bbce6d5af41820ea0342d3567a0aecc
[ "BSD-2-Clause" ]
11
2021-08-08T23:25:10.000Z
2022-02-19T23:07:22.000Z
Nacro/SDK/FN_GA_DefaultPlayer_InteractSearch_functions.cpp
Milxnor/Nacro
eebabf662bbce6d5af41820ea0342d3567a0aecc
[ "BSD-2-Clause" ]
1
2022-01-01T22:51:59.000Z
2022-01-08T16:14:15.000Z
Nacro/SDK/FN_GA_DefaultPlayer_InteractSearch_functions.cpp
Milxnor/Nacro
eebabf662bbce6d5af41820ea0342d3567a0aecc
[ "BSD-2-Clause" ]
8
2021-08-09T13:51:54.000Z
2022-01-26T20:33:37.000Z
// Fortnite (1.8) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "../SDK.hpp" namespace SDK { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function GA_DefaultPlayer_InteractSearch.GA_DefaultPlayer_InteractSearch_C.Completed_B697D9B445CA2BFDB1328D93C33FBCF3 // (HasOutParms, BlueprintCallable, BlueprintEvent) // Parameters: // struct FGameplayAbilityTargetDataHandle TargetData (ConstParm, Parm, OutParm, ReferenceParm) // struct FGameplayTag ApplicationTag (Parm) void UGA_DefaultPlayer_InteractSearch_C::Completed_B697D9B445CA2BFDB1328D93C33FBCF3(const struct FGameplayAbilityTargetDataHandle& TargetData, const struct FGameplayTag& ApplicationTag) { static auto fn = UObject::FindObject<UFunction>("Function GA_DefaultPlayer_InteractSearch.GA_DefaultPlayer_InteractSearch_C.Completed_B697D9B445CA2BFDB1328D93C33FBCF3"); UGA_DefaultPlayer_InteractSearch_C_Completed_B697D9B445CA2BFDB1328D93C33FBCF3_Params params; params.TargetData = TargetData; params.ApplicationTag = ApplicationTag; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function GA_DefaultPlayer_InteractSearch.GA_DefaultPlayer_InteractSearch_C.Cancelled_B697D9B445CA2BFDB1328D93C33FBCF3 // (HasOutParms, BlueprintCallable, BlueprintEvent) // Parameters: // struct FGameplayAbilityTargetDataHandle TargetData (ConstParm, Parm, OutParm, ReferenceParm) // struct FGameplayTag ApplicationTag (Parm) void UGA_DefaultPlayer_InteractSearch_C::Cancelled_B697D9B445CA2BFDB1328D93C33FBCF3(const struct FGameplayAbilityTargetDataHandle& TargetData, const struct FGameplayTag& ApplicationTag) { static auto fn = UObject::FindObject<UFunction>("Function GA_DefaultPlayer_InteractSearch.GA_DefaultPlayer_InteractSearch_C.Cancelled_B697D9B445CA2BFDB1328D93C33FBCF3"); UGA_DefaultPlayer_InteractSearch_C_Cancelled_B697D9B445CA2BFDB1328D93C33FBCF3_Params params; params.TargetData = TargetData; params.ApplicationTag = ApplicationTag; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function GA_DefaultPlayer_InteractSearch.GA_DefaultPlayer_InteractSearch_C.Triggered_B697D9B445CA2BFDB1328D93C33FBCF3 // (HasOutParms, BlueprintCallable, BlueprintEvent) // Parameters: // struct FGameplayAbilityTargetDataHandle TargetData (ConstParm, Parm, OutParm, ReferenceParm) // struct FGameplayTag ApplicationTag (Parm) void UGA_DefaultPlayer_InteractSearch_C::Triggered_B697D9B445CA2BFDB1328D93C33FBCF3(const struct FGameplayAbilityTargetDataHandle& TargetData, const struct FGameplayTag& ApplicationTag) { static auto fn = UObject::FindObject<UFunction>("Function GA_DefaultPlayer_InteractSearch.GA_DefaultPlayer_InteractSearch_C.Triggered_B697D9B445CA2BFDB1328D93C33FBCF3"); UGA_DefaultPlayer_InteractSearch_C_Triggered_B697D9B445CA2BFDB1328D93C33FBCF3_Params params; params.TargetData = TargetData; params.ApplicationTag = ApplicationTag; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function GA_DefaultPlayer_InteractSearch.GA_DefaultPlayer_InteractSearch_C.K2_ActivateAbility // (Event, Protected, BlueprintEvent) void UGA_DefaultPlayer_InteractSearch_C::K2_ActivateAbility() { static auto fn = UObject::FindObject<UFunction>("Function GA_DefaultPlayer_InteractSearch.GA_DefaultPlayer_InteractSearch_C.K2_ActivateAbility"); UGA_DefaultPlayer_InteractSearch_C_K2_ActivateAbility_Params params; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function GA_DefaultPlayer_InteractSearch.GA_DefaultPlayer_InteractSearch_C.ExecuteUbergraph_GA_DefaultPlayer_InteractSearch // (HasDefaults) // Parameters: // int EntryPoint (Parm, ZeroConstructor, IsPlainOldData) void UGA_DefaultPlayer_InteractSearch_C::ExecuteUbergraph_GA_DefaultPlayer_InteractSearch(int EntryPoint) { static auto fn = UObject::FindObject<UFunction>("Function GA_DefaultPlayer_InteractSearch.GA_DefaultPlayer_InteractSearch_C.ExecuteUbergraph_GA_DefaultPlayer_InteractSearch"); UGA_DefaultPlayer_InteractSearch_C_ExecuteUbergraph_GA_DefaultPlayer_InteractSearch_Params params; params.EntryPoint = EntryPoint; auto flags = fn->FunctionFlags; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
37.943089
185
0.78573
Milxnor
33a03b45d3a7f9aad320034c272f015d93063494
208
cpp
C++
ue/Drone_Simulator/Drone_Simulator.cpp
gabriserra/CatchingDrone
65bab95d3dbd8085f79082db672954f752c77b12
[ "MIT" ]
null
null
null
ue/Drone_Simulator/Drone_Simulator.cpp
gabriserra/CatchingDrone
65bab95d3dbd8085f79082db672954f752c77b12
[ "MIT" ]
null
null
null
ue/Drone_Simulator/Drone_Simulator.cpp
gabriserra/CatchingDrone
65bab95d3dbd8085f79082db672954f752c77b12
[ "MIT" ]
null
null
null
// Fill out your copyright notice in the Description page of Project Settings. #include "Drone_Simulator.h" IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, Drone_Simulator, "Drone_Simulator" );
34.666667
93
0.802885
gabriserra
33a08d1dba7069d2c5790e63ee7974f3c9c0fb3f
83,350
cpp
C++
src/PE/EnumToString.cpp
junghee/LIEF
de7492ee49ef813cd8db3a858892e4ed5a5638c5
[ "Apache-2.0" ]
2,999
2017-04-03T13:43:23.000Z
2022-03-31T15:24:27.000Z
src/PE/EnumToString.cpp
junghee/LIEF
de7492ee49ef813cd8db3a858892e4ed5a5638c5
[ "Apache-2.0" ]
626
2017-04-04T15:57:04.000Z
2022-03-31T19:25:18.000Z
src/PE/EnumToString.cpp
junghee/LIEF
de7492ee49ef813cd8db3a858892e4ed5a5638c5
[ "Apache-2.0" ]
498
2017-04-04T14:18:25.000Z
2022-03-29T19:31:38.000Z
/* Copyright 2017 - 2021 R. Thomas * Copyright 2017 - 2021 Quarkslab * * 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 "LIEF/PE/Structures.hpp" #include "LIEF/PE/EnumToString.hpp" #include "frozen.hpp" namespace LIEF { namespace PE { const char* to_string(PE_TYPE e) { CONST_MAP(PE_TYPE, const char*, 2) enumStrings { { PE_TYPE::PE32, "PE32" }, { PE_TYPE::PE32_PLUS,"PE32_PLUS" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(DATA_DIRECTORY e) { CONST_MAP(DATA_DIRECTORY, const char*, 15) enumStrings { { DATA_DIRECTORY::EXPORT_TABLE, "EXPORT_TABLE" }, { DATA_DIRECTORY::IMPORT_TABLE, "IMPORT_TABLE" }, { DATA_DIRECTORY::RESOURCE_TABLE, "RESOURCE_TABLE" }, { DATA_DIRECTORY::EXCEPTION_TABLE, "EXCEPTION_TABLE" }, { DATA_DIRECTORY::CERTIFICATE_TABLE, "CERTIFICATE_TABLE" }, { DATA_DIRECTORY::BASE_RELOCATION_TABLE, "BASE_RELOCATION_TABLE" }, { DATA_DIRECTORY::DEBUG, "DEBUG" }, { DATA_DIRECTORY::ARCHITECTURE, "ARCHITECTURE" }, { DATA_DIRECTORY::GLOBAL_PTR, "GLOBAL_PTR" }, { DATA_DIRECTORY::TLS_TABLE, "TLS_TABLE" }, { DATA_DIRECTORY::LOAD_CONFIG_TABLE, "LOAD_CONFIG_TABLE" }, { DATA_DIRECTORY::BOUND_IMPORT, "BOUND_IMPORT" }, { DATA_DIRECTORY::IAT, "IAT" }, { DATA_DIRECTORY::DELAY_IMPORT_DESCRIPTOR, "DELAY_IMPORT_DESCRIPTOR" }, { DATA_DIRECTORY::CLR_RUNTIME_HEADER, "CLR_RUNTIME_HEADER" } }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(MACHINE_TYPES e) { CONST_MAP(MACHINE_TYPES, const char*, 26) enumStrings { { MACHINE_TYPES::MT_Invalid, "INVALID" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_UNKNOWN, "UNKNOWN" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_AM33, "AM33" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_AMD64, "AMD64" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_ARM, "ARM" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_ARMNT, "ARMNT" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_ARM64, "ARM64" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_EBC, "EBC" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_I386, "I386" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_IA64, "IA64" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_M32R, "M32R" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_MIPS16, "MIPS16" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_MIPSFPU, "MIPSFPU" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_MIPSFPU16, "MIPSFPU16" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_POWERPC, "POWERPC" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_POWERPCFP, "POWERPCFP" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_R4000, "R4000" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_RISCV32, "RISCV32" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_RISCV64, "RISCV64" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_RISCV128, "RISCV128" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_SH3, "SH3" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_SH3DSP, "SH3DSP" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_SH4, "SH4" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_SH5, "SH5" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_THUMB, "THUMB" }, { MACHINE_TYPES::IMAGE_FILE_MACHINE_WCEMIPSV2, "WCEMIPSV2" } }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(HEADER_CHARACTERISTICS e) { CONST_MAP(HEADER_CHARACTERISTICS, const char*, 15) enumStrings { { HEADER_CHARACTERISTICS::IMAGE_FILE_RELOCS_STRIPPED, "RELOCS_STRIPPED" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_EXECUTABLE_IMAGE, "EXECUTABLE_IMAGE" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_LINE_NUMS_STRIPPED, "LINE_NUMS_STRIPPED" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_LOCAL_SYMS_STRIPPED, "LOCAL_SYMS_STRIPPED" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_AGGRESSIVE_WS_TRIM, "AGGRESSIVE_WS_TRIM" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_LARGE_ADDRESS_AWARE, "LARGE_ADDRESS_AWARE" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_BYTES_REVERSED_LO, "BYTES_REVERSED_LO" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_32BIT_MACHINE, "CHARA_32BIT_MACHINE" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_DEBUG_STRIPPED, "DEBUG_STRIPPED" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP, "REMOVABLE_RUN_FROM_SWAP" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_NET_RUN_FROM_SWAP, "NET_RUN_FROM_SWAP" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_SYSTEM, "SYSTEM" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_DLL, "DLL" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_UP_SYSTEM_ONLY, "UP_SYSTEM_ONLY" }, { HEADER_CHARACTERISTICS::IMAGE_FILE_BYTES_REVERSED_HI, "BYTES_REVERSED_HI" } }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(SUBSYSTEM e) { CONST_MAP(SUBSYSTEM, const char*, 14) enumStrings { { SUBSYSTEM::IMAGE_SUBSYSTEM_UNKNOWN, "UNKNOWN" }, { SUBSYSTEM::IMAGE_SUBSYSTEM_NATIVE, "NATIVE" }, { SUBSYSTEM::IMAGE_SUBSYSTEM_WINDOWS_GUI, "WINDOWS_GUI" }, { SUBSYSTEM::IMAGE_SUBSYSTEM_WINDOWS_CUI, "WINDOWS_CUI" }, { SUBSYSTEM::IMAGE_SUBSYSTEM_OS2_CUI, "OS2_CUI" }, { SUBSYSTEM::IMAGE_SUBSYSTEM_POSIX_CUI, "POSIX_CUI" }, { SUBSYSTEM::IMAGE_SUBSYSTEM_NATIVE_WINDOWS, "NATIVE_WINDOWS" }, { SUBSYSTEM::IMAGE_SUBSYSTEM_WINDOWS_CE_GUI, "WINDOWS_CE_GUI" }, { SUBSYSTEM::IMAGE_SUBSYSTEM_EFI_APPLICATION, "EFI_APPLICATION" }, { SUBSYSTEM::IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER, "EFI_BOOT_SERVICE_DRIVER" }, { SUBSYSTEM::IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER, "EFI_RUNTIME_DRIVER" }, { SUBSYSTEM::IMAGE_SUBSYSTEM_EFI_ROM, "EFI_ROM" }, { SUBSYSTEM::IMAGE_SUBSYSTEM_XBOX, "XBOX" }, { SUBSYSTEM::IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION, "WINDOWS_BOOT_APPLICATION" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(DLL_CHARACTERISTICS e) { CONST_MAP(DLL_CHARACTERISTICS, const char*, 11) enumStrings { { DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA, "HIGH_ENTROPY_VA" }, { DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, "DYNAMIC_BASE" }, { DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY, "FORCE_INTEGRITY" }, { DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, "NX_COMPAT" }, { DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION, "NO_ISOLATION" }, { DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_NO_SEH, "NO_SEH" }, { DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_NO_BIND, "NO_BIND" }, { DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_APPCONTAINER, "APPCONTAINER" }, { DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER, "WDM_DRIVER" }, { DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_GUARD_CF, "GUARD_CF" }, { DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE, "TERMINAL_SERVER_AWARE" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(SECTION_CHARACTERISTICS e) { CONST_MAP(SECTION_CHARACTERISTICS, const char*, 35) enumStrings { { SECTION_CHARACTERISTICS::IMAGE_SCN_TYPE_NO_PAD, "TYPE_NO_PAD" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_CNT_CODE, "CNT_CODE" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_CNT_INITIALIZED_DATA, "CNT_INITIALIZED_DATA" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_CNT_UNINITIALIZED_DATA, "CNT_UNINITIALIZED_DATA" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_LNK_OTHER, "LNK_OTHER" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_LNK_INFO, "LNK_INFO" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_LNK_REMOVE, "LNK_REMOVE" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_LNK_COMDAT, "LNK_COMDAT" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_GPREL, "GPREL" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_PURGEABLE, "MEM_PURGEABLE" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_16BIT, "MEM_16BIT" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_LOCKED, "MEM_LOCKED" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_PRELOAD, "MEM_PRELOAD" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_1BYTES, "ALIGN_1BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_2BYTES, "ALIGN_2BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_4BYTES, "ALIGN_4BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_8BYTES, "ALIGN_8BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_16BYTES, "ALIGN_16BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_32BYTES, "ALIGN_32BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_64BYTES, "ALIGN_64BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_128BYTES, "ALIGN_128BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_256BYTES, "ALIGN_256BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_512BYTES, "ALIGN_512BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_1024BYTES, "ALIGN_1024BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_2048BYTES, "ALIGN_2048BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_4096BYTES, "ALIGN_4096BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_8192BYTES, "ALIGN_8192BYTES" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_LNK_NRELOC_OVFL, "LNK_NRELOC_OVFL" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_DISCARDABLE, "MEM_DISCARDABLE" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_NOT_CACHED, "MEM_NOT_CACHED" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_NOT_PAGED, "MEM_NOT_PAGED" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_SHARED, "MEM_SHARED" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_EXECUTE, "MEM_EXECUTE" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_READ, "MEM_READ" }, { SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_WRITE, "MEM_WRITE" } }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(PE_SECTION_TYPES e) { CONST_MAP(PE_SECTION_TYPES, const char*, 10) enumStrings { { PE_SECTION_TYPES::TEXT, "TEXT" }, { PE_SECTION_TYPES::TLS, "TLS_" }, { PE_SECTION_TYPES::IMPORT, "IDATA" }, { PE_SECTION_TYPES::DATA, "DATA" }, { PE_SECTION_TYPES::BSS, "BSS" }, { PE_SECTION_TYPES::RESOURCE, "RESOURCE" }, { PE_SECTION_TYPES::RELOCATION, "RELOCATION" }, { PE_SECTION_TYPES::EXPORT, "EXPORT" }, { PE_SECTION_TYPES::DEBUG, "DEBUG" }, { PE_SECTION_TYPES::UNKNOWN, "UNKNOWN" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(SYMBOL_BASE_TYPES e) { CONST_MAP(SYMBOL_BASE_TYPES, const char*, 16) enumStrings { { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_NULL, "NULL" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_VOID, "VOID" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_CHAR, "CHAR" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_SHORT, "SHORT" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_INT, "INT" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_LONG, "LONG" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_FLOAT, "FLOAT" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_DOUBLE, "DOUBLE" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_STRUCT, "STRUCT" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_UNION, "UNION" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_ENUM, "ENUM" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_MOE, "MOE" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_BYTE, "BYTE" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_WORD, "WORD" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_UINT, "UINT" }, { SYMBOL_BASE_TYPES::IMAGE_SYM_TYPE_DWORD, "DWORD" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(SYMBOL_COMPLEX_TYPES e) { CONST_MAP(SYMBOL_COMPLEX_TYPES, const char*, 5) enumStrings { { SYMBOL_COMPLEX_TYPES::IMAGE_SYM_DTYPE_NULL, "NULL" }, { SYMBOL_COMPLEX_TYPES::IMAGE_SYM_DTYPE_POINTER, "POINTER" }, { SYMBOL_COMPLEX_TYPES::IMAGE_SYM_DTYPE_FUNCTION, "FUNCTION" }, { SYMBOL_COMPLEX_TYPES::IMAGE_SYM_DTYPE_ARRAY, "ARRAY" }, { SYMBOL_COMPLEX_TYPES::SCT_COMPLEX_TYPE_SHIFT, "COMPLEX_TYPE_SHIFT" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(SYMBOL_SECTION_NUMBER e) { CONST_MAP(SYMBOL_SECTION_NUMBER, const char*, 3) enumStrings { { SYMBOL_SECTION_NUMBER::IMAGE_SYM_DEBUG, "DEBUG" }, { SYMBOL_SECTION_NUMBER::IMAGE_SYM_ABSOLUTE, "ABSOLUTE" }, { SYMBOL_SECTION_NUMBER::IMAGE_SYM_UNDEFINED, "UNDEFINED" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(SYMBOL_STORAGE_CLASS e) { CONST_MAP(SYMBOL_STORAGE_CLASS, const char*, 24) enumStrings { { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_END_OF_FUNCTION, "END_OF_FUNCTION" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_NULL, "NULL" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_AUTOMATIC, "AUTOMATIC" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_EXTERNAL, "EXTERNAL" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_STATIC, "STATIC" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_REGISTER, "REGISTER" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_EXTERNAL_DEF, "EXTERNAL_DEF" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_LABEL, "LABEL" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_UNDEFINED_LABEL, "UNDEFINED_LABEL" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_MEMBER_OF_STRUCT, "MEMBER_OF_STRUCT" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_UNION_TAG, "UNION_TAG" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_TYPE_DEFINITION, "TYPE_DEFINITION" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_UNDEFINED_STATIC, "UDEFINED_STATIC" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_ENUM_TAG, "ENUM_TAG" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_MEMBER_OF_ENUM, "MEMBER_OF_ENUM" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_REGISTER_PARAM, "REGISTER_PARAM" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_BIT_FIELD, "BIT_FIELD" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_BLOCK, "BLOCK" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_FUNCTION, "FUNCTION" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_END_OF_STRUCT, "END_OF_STRUCT" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_FILE, "FILE" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_SECTION, "SECTION" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_WEAK_EXTERNAL, "WEAK_EXTERNAL" }, { SYMBOL_STORAGE_CLASS::IMAGE_SYM_CLASS_CLR_TOKEN, "CLR_TOKEN" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(RELOCATIONS_I386 e) { CONST_MAP(RELOCATIONS_I386, const char*, 11) enumStrings { { RELOCATIONS_I386::IMAGE_REL_I386_ABSOLUTE, "ABSOLUTE" }, { RELOCATIONS_I386::IMAGE_REL_I386_DIR16, "DIR16" }, { RELOCATIONS_I386::IMAGE_REL_I386_REL16, "REL16" }, { RELOCATIONS_I386::IMAGE_REL_I386_DIR32, "DIR32" }, { RELOCATIONS_I386::IMAGE_REL_I386_DIR32NB, "DIR32NB" }, { RELOCATIONS_I386::IMAGE_REL_I386_SEG12, "SEG12" }, { RELOCATIONS_I386::IMAGE_REL_I386_SECTION, "SECTION" }, { RELOCATIONS_I386::IMAGE_REL_I386_SECREL, "SECREL" }, { RELOCATIONS_I386::IMAGE_REL_I386_TOKEN, "TOKEN" }, { RELOCATIONS_I386::IMAGE_REL_I386_SECREL7, "SECREL7" }, { RELOCATIONS_I386::IMAGE_REL_I386_REL32, "REL32" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(RELOCATIONS_AMD64 e) { CONST_MAP(RELOCATIONS_AMD64, const char*, 17) enumStrings { { RELOCATIONS_AMD64::IMAGE_REL_AMD64_ABSOLUTE, "ABSOLUTE" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_ADDR64, "ADDR64" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_ADDR32, "ADDR32" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_ADDR32NB, "ADDR32NB" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_REL32, "REL32" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_REL32_1, "REL32_1" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_REL32_2, "REL32_2" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_REL32_3, "REL32_3" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_REL32_4, "REL32_4" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_REL32_5, "REL32_5" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_SECTION, "SECTION" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_SECREL, "SECREL" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_SECREL7, "SECREL7" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_TOKEN, "TOKEN" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_SREL32, "SREL32" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_PAIR, "PAIR" }, { RELOCATIONS_AMD64::IMAGE_REL_AMD64_SSPAN32, "SSPAN32" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(RELOCATIONS_ARM e) { CONST_MAP(RELOCATIONS_ARM, const char*, 15) enumStrings { { RELOCATIONS_ARM::IMAGE_REL_ARM_ABSOLUTE, "ABSOLUTE" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_ADDR32, "ADDR32" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_ADDR32NB, "ADDR32NB" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_BRANCH24, "BRANCH24" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_BRANCH11, "BRANCH11" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_TOKEN, "TOKEN" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_BLX24, "BLX24" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_BLX11, "BLX11" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_SECTION, "SECTION" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_SECREL, "SECREL" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_MOV32A, "MOV32A" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_MOV32T, "MOV32T" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_BRANCH20T, "BRANCH20T" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_BRANCH24T, "BRANCH24T" }, { RELOCATIONS_ARM::IMAGE_REL_ARM_BLX23T, "BLX23T" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(RELOCATIONS_BASE_TYPES e) { CONST_MAP(RELOCATIONS_BASE_TYPES, const char*, 19) enumStrings { { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_ABSOLUTE, "ABSOLUTE" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_HIGH, "HIGH" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_LOW, "LOW" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_HIGHLOW, "HIGHLOW" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_HIGHADJ, "HIGHADJ" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_MIPS_JMPADDR, "MIPS_JMPADDR | ARM_MOV32A | ARM_MOV32 | RISCV_HI20" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_ARM_MOV32A, "MIPS_JMPADDR | ARM_MOV32A | ARM_MOV32 | RISCV_HI20" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_ARM_MOV32, "MIPS_JMPADDR | ARM_MOV32A | ARM_MOV32 | RISCV_HI20" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_RISCV_HI20, "MIPS_JMPADDR | ARM_MOV32A | ARM_MOV32 | RISCV_HI20" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_SECTION, "SECTION" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_REL, "REL | ARM_MOV32T | THUMB_MOV32 | RISCV_LOW12I" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_ARM_MOV32T, "REL | ARM_MOV32T | THUMB_MOV32 | RISCV_LOW12I" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_THUMB_MOV32, "REL | ARM_MOV32T | THUMB_MOV32 | RISCV_LOW12I" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_RISCV_LOW12I, "REL | ARM_MOV32T | THUMB_MOV32 | RISCV_LOW12I" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_RISCV_LOW12S, "RISCV_LOW12S" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_MIPS_JMPADDR16, "MIPS_JMPADDR16 | IA64_IMM64" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_IA64_IMM64, "MIPS_JMPADDR16 | IA64_IMM64" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_DIR64, "DIR64" }, { RELOCATIONS_BASE_TYPES::IMAGE_REL_BASED_HIGH3ADJ, "HIGH3ADJ" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(DEBUG_TYPES e) { CONST_MAP(DEBUG_TYPES, const char*, 18) enumStrings { { DEBUG_TYPES::IMAGE_DEBUG_TYPE_UNKNOWN, "UNKNOWN" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_COFF, "COFF" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_CODEVIEW, "CODEVIEW" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_FPO, "FPO" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_MISC, "MISC" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_EXCEPTION, "EXCEPTION" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_FIXUP, "FIXUP" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_OMAP_TO_SRC, "OMAP_TO_SRC" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_OMAP_FROM_SRC, "OMAP_FROM_SRC" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_BORLAND, "BORLAND" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_RESERVED10, "RESERVED" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_CLSID, "CLSID" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_VC_FEATURE, "VC_FEATURE" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_POGO, "POGO" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_ILTCG, "ILTCG" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_MPX, "MPX" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_REPRO, "REPRO" }, { DEBUG_TYPES::IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS, "EX_DLLCHARACTERISTICS" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(RESOURCE_TYPES e) { CONST_MAP(RESOURCE_TYPES, const char*, 21) enumStrings { { RESOURCE_TYPES::CURSOR, "CURSOR" }, { RESOURCE_TYPES::BITMAP, "BITMAP" }, { RESOURCE_TYPES::ICON, "ICON" }, { RESOURCE_TYPES::MENU, "MENU" }, { RESOURCE_TYPES::DIALOG, "DIALOG" }, { RESOURCE_TYPES::STRING, "STRING" }, { RESOURCE_TYPES::FONTDIR, "FONTDIR" }, { RESOURCE_TYPES::FONT, "FONT" }, { RESOURCE_TYPES::ACCELERATOR, "ACCELERATOR" }, { RESOURCE_TYPES::RCDATA, "RCDATA" }, { RESOURCE_TYPES::MESSAGETABLE, "MESSAGETABLE" }, { RESOURCE_TYPES::GROUP_CURSOR, "GROUP_CURSOR" }, { RESOURCE_TYPES::GROUP_ICON, "GROUP_ICON" }, { RESOURCE_TYPES::VERSION, "VERSION" }, { RESOURCE_TYPES::DLGINCLUDE, "DLGINCLUDE" }, { RESOURCE_TYPES::PLUGPLAY, "PLUGPLAY" }, { RESOURCE_TYPES::VXD, "VXD" }, { RESOURCE_TYPES::ANICURSOR, "ANICURSOR" }, { RESOURCE_TYPES::ANIICON, "ANIICON" }, { RESOURCE_TYPES::HTML, "HTML" }, { RESOURCE_TYPES::MANIFEST, "MANIFEST" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(RESOURCE_LANGS e) { CONST_MAP(RESOURCE_LANGS, const char*, 98) enumStrings { { RESOURCE_LANGS::LANG_NEUTRAL, "NEUTRAL" }, { RESOURCE_LANGS::LANG_INVARIANT, "INVARIANT" }, { RESOURCE_LANGS::LANG_AFRIKAANS, "AFRIKAANS" }, { RESOURCE_LANGS::LANG_ALBANIAN, "ALBANIAN" }, { RESOURCE_LANGS::LANG_ARABIC, "ARABIC" }, { RESOURCE_LANGS::LANG_ARMENIAN, "ARMENIAN" }, { RESOURCE_LANGS::LANG_ASSAMESE, "ASSAMESE" }, { RESOURCE_LANGS::LANG_AZERI, "AZERI" }, { RESOURCE_LANGS::LANG_BASQUE, "BASQUE" }, { RESOURCE_LANGS::LANG_BELARUSIAN, "BELARUSIAN" }, { RESOURCE_LANGS::LANG_BANGLA, "BANGLA" }, { RESOURCE_LANGS::LANG_BULGARIAN, "BULGARIAN" }, { RESOURCE_LANGS::LANG_CATALAN, "CATALAN" }, { RESOURCE_LANGS::LANG_CHINESE, "CHINESE" }, { RESOURCE_LANGS::LANG_CROATIAN, "CROATIAN" }, { RESOURCE_LANGS::LANG_CZECH, "CZECH" }, { RESOURCE_LANGS::LANG_DANISH, "DANISH" }, { RESOURCE_LANGS::LANG_DIVEHI, "DIVEHI" }, { RESOURCE_LANGS::LANG_DUTCH, "DUTCH" }, { RESOURCE_LANGS::LANG_ENGLISH, "ENGLISH" }, { RESOURCE_LANGS::LANG_ESTONIAN, "ESTONIAN" }, { RESOURCE_LANGS::LANG_FAEROESE, "FAEROESE" }, { RESOURCE_LANGS::LANG_FARSI, "FARSI" }, { RESOURCE_LANGS::LANG_FINNISH, "FINNISH" }, { RESOURCE_LANGS::LANG_FRENCH, "FRENCH" }, { RESOURCE_LANGS::LANG_GALICIAN, "GALICIAN" }, { RESOURCE_LANGS::LANG_GEORGIAN, "GEORGIAN" }, { RESOURCE_LANGS::LANG_GERMAN, "GERMAN" }, { RESOURCE_LANGS::LANG_GREEK, "GREEK" }, { RESOURCE_LANGS::LANG_GUJARATI, "GUJARATI" }, { RESOURCE_LANGS::LANG_HEBREW, "HEBREW" }, { RESOURCE_LANGS::LANG_HINDI, "HINDI" }, { RESOURCE_LANGS::LANG_HUNGARIAN, "HUNGARIAN" }, { RESOURCE_LANGS::LANG_ICELANDIC, "ICELANDIC" }, { RESOURCE_LANGS::LANG_INDONESIAN, "INDONESIAN" }, { RESOURCE_LANGS::LANG_ITALIAN, "ITALIAN" }, { RESOURCE_LANGS::LANG_JAPANESE, "JAPANESE" }, { RESOURCE_LANGS::LANG_KANNADA, "KANNADA" }, { RESOURCE_LANGS::LANG_KASHMIRI, "KASHMIRI" }, { RESOURCE_LANGS::LANG_KAZAK, "KAZAK" }, { RESOURCE_LANGS::LANG_KONKANI, "KONKANI" }, { RESOURCE_LANGS::LANG_KOREAN, "KOREAN" }, { RESOURCE_LANGS::LANG_KYRGYZ, "KYRGYZ" }, { RESOURCE_LANGS::LANG_LATVIAN, "LATVIAN" }, { RESOURCE_LANGS::LANG_LITHUANIAN, "LITHUANIAN" }, { RESOURCE_LANGS::LANG_MACEDONIAN, "MACEDONIAN" }, { RESOURCE_LANGS::LANG_MALAY, "MALAY" }, { RESOURCE_LANGS::LANG_MALAYALAM, "MALAYALAM" }, { RESOURCE_LANGS::LANG_MANIPURI, "MANIPURI" }, { RESOURCE_LANGS::LANG_MARATHI, "MARATHI" }, { RESOURCE_LANGS::LANG_MONGOLIAN, "MONGOLIAN" }, { RESOURCE_LANGS::LANG_NEPALI, "NEPALI" }, { RESOURCE_LANGS::LANG_NORWEGIAN, "NORWEGIAN" }, { RESOURCE_LANGS::LANG_ORIYA, "ORIYA" }, { RESOURCE_LANGS::LANG_POLISH, "POLISH" }, { RESOURCE_LANGS::LANG_PORTUGUESE, "PORTUGUESE" }, { RESOURCE_LANGS::LANG_PUNJABI, "PUNJABI" }, { RESOURCE_LANGS::LANG_ROMANIAN, "ROMANIAN" }, { RESOURCE_LANGS::LANG_RUSSIAN, "RUSSIAN" }, { RESOURCE_LANGS::LANG_SANSKRIT, "SANSKRIT" }, { RESOURCE_LANGS::LANG_SINDHI, "SINDHI" }, { RESOURCE_LANGS::LANG_SLOVAK, "SLOVAK" }, { RESOURCE_LANGS::LANG_SLOVENIAN, "SLOVENIAN" }, { RESOURCE_LANGS::LANG_SPANISH, "SPANISH" }, { RESOURCE_LANGS::LANG_SWAHILI, "SWAHILI" }, { RESOURCE_LANGS::LANG_SWEDISH, "SWEDISH" }, { RESOURCE_LANGS::LANG_SYRIAC, "SYRIAC" }, { RESOURCE_LANGS::LANG_TAMIL, "TAMIL" }, { RESOURCE_LANGS::LANG_TATAR, "TATAR" }, { RESOURCE_LANGS::LANG_TELUGU, "TELUGU" }, { RESOURCE_LANGS::LANG_THAI, "THAI" }, { RESOURCE_LANGS::LANG_TURKISH, "TURKISH" }, { RESOURCE_LANGS::LANG_UKRAINIAN, "UKRAINIAN" }, { RESOURCE_LANGS::LANG_URDU, "URDU" }, { RESOURCE_LANGS::LANG_UZBEK, "UZBEK" }, { RESOURCE_LANGS::LANG_VIETNAMESE, "VIETNAMESE" }, { RESOURCE_LANGS::LANG_MALTESE, "MALTESE" }, { RESOURCE_LANGS::LANG_MAORI, "MAORI" }, { RESOURCE_LANGS::LANG_RHAETO_ROMANCE, "RHAETO_ROMANCE" }, { RESOURCE_LANGS::LANG_SAMI, "SAMI" }, { RESOURCE_LANGS::LANG_SORBIAN, "SORBIAN" }, { RESOURCE_LANGS::LANG_SUTU, "SUTU" }, { RESOURCE_LANGS::LANG_TSONGA, "TSONGA" }, { RESOURCE_LANGS::LANG_TSWANA, "TSWANA" }, { RESOURCE_LANGS::LANG_VENDA, "VENDA" }, { RESOURCE_LANGS::LANG_XHOSA, "XHOSA" }, { RESOURCE_LANGS::LANG_ZULU, "ZULU" }, { RESOURCE_LANGS::LANG_ESPERANTO, "ESPERANTO" }, { RESOURCE_LANGS::LANG_WALON, "WALON" }, { RESOURCE_LANGS::LANG_CORNISH, "CORNISH" }, { RESOURCE_LANGS::LANG_WELSH, "WELSH" }, { RESOURCE_LANGS::LANG_BRETON, "BRETON" }, { RESOURCE_LANGS::LANG_INUKTITUT, "INUKTITUT" }, { RESOURCE_LANGS::LANG_IRISH, "IRISH" }, { RESOURCE_LANGS::LANG_PULAR, "PULAR" }, { RESOURCE_LANGS::LANG_QUECHUA, "QUECHUA" }, { RESOURCE_LANGS::LANG_TAMAZIGHT, "TAMAZIGHT" }, { RESOURCE_LANGS::LANG_TIGRINYA, "TIGRINYA" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(RESOURCE_SUBLANGS e) { CONST_MAP(RESOURCE_SUBLANGS, const char*, 229) enumStrings { { RESOURCE_SUBLANGS::SUBLANG_AFRIKAANS_SOUTH_AFRICA, "AFRIKAANS_SOUTH_AFRICA" }, { RESOURCE_SUBLANGS::SUBLANG_ALBANIAN_ALBANIA, "ALBANIAN_ALBANIA" }, { RESOURCE_SUBLANGS::SUBLANG_ALSATIAN_FRANCE, "ALSATIAN_FRANCE" }, { RESOURCE_SUBLANGS::SUBLANG_AMHARIC_ETHIOPIA, "AMHARIC_ETHIOPIA" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_ALGERIA, "ARABIC_ALGERIA" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_BAHRAIN, "ARABIC_BAHRAIN" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_EGYPT, "ARABIC_EGYPT" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_IRAQ, "ARABIC_IRAQ" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_JORDAN, "ARABIC_JORDAN" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_KUWAIT, "ARABIC_KUWAIT" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_LEBANON, "ARABIC_LEBANON" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_LIBYA, "ARABIC_LIBYA" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_MOROCCO, "ARABIC_MOROCCO" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_OMAN, "ARABIC_OMAN" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_QATAR, "ARABIC_QATAR" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_SAUDI_ARABIA, "ARABIC_SAUDI_ARABIA" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_SYRIA, "ARABIC_SYRIA" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_TUNISIA, "ARABIC_TUNISIA" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_UAE, "ARABIC_UAE" }, { RESOURCE_SUBLANGS::SUBLANG_ARABIC_YEMEN, "ARABIC_YEMEN" }, { RESOURCE_SUBLANGS::SUBLANG_ARMENIAN_ARMENIA, "ARMENIAN_ARMENIA" }, { RESOURCE_SUBLANGS::SUBLANG_ASSAMESE_INDIA, "ASSAMESE_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_AZERI_CYRILLIC, "AZERI_CYRILLIC" }, { RESOURCE_SUBLANGS::SUBLANG_AZERI_LATIN, "AZERI_LATIN" }, { RESOURCE_SUBLANGS::SUBLANG_BASHKIR_RUSSIA, "BASHKIR_RUSSIA" }, { RESOURCE_SUBLANGS::SUBLANG_BASQUE_BASQUE, "BASQUE_BASQUE" }, { RESOURCE_SUBLANGS::SUBLANG_BELARUSIAN_BELARUS, "BELARUSIAN_BELARUS" }, { RESOURCE_SUBLANGS::SUBLANG_BANGLA_BANGLADESH, "BANGLA_BANGLADESH" }, { RESOURCE_SUBLANGS::SUBLANG_BANGLA_INDIA, "BANGLA_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC, "BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC" }, { RESOURCE_SUBLANGS::SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN, "BOSNIAN_BOSNIA_HERZEGOVINA_LATIN" }, { RESOURCE_SUBLANGS::SUBLANG_BRETON_FRANCE, "BRETON_FRANCE" }, { RESOURCE_SUBLANGS::SUBLANG_BULGARIAN_BULGARIA, "BULGARIAN_BULGARIA" }, { RESOURCE_SUBLANGS::SUBLANG_CATALAN_CATALAN, "CATALAN_CATALAN" }, { RESOURCE_SUBLANGS::SUBLANG_CHINESE_HONGKONG, "CHINESE_HONGKONG" }, { RESOURCE_SUBLANGS::SUBLANG_CHINESE_MACAU, "CHINESE_MACAU" }, { RESOURCE_SUBLANGS::SUBLANG_CHINESE_SIMPLIFIED, "CHINESE_SIMPLIFIED" }, { RESOURCE_SUBLANGS::SUBLANG_CHINESE_SINGAPORE, "CHINESE_SINGAPORE" }, { RESOURCE_SUBLANGS::SUBLANG_CHINESE_TRADITIONAL, "CHINESE_TRADITIONAL" }, { RESOURCE_SUBLANGS::SUBLANG_CORSICAN_FRANCE, "CORSICAN_FRANCE" }, { RESOURCE_SUBLANGS::SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN, "CROATIAN_BOSNIA_HERZEGOVINA_LATIN" }, { RESOURCE_SUBLANGS::SUBLANG_CROATIAN_CROATIA, "CROATIAN_CROATIA" }, { RESOURCE_SUBLANGS::SUBLANG_CUSTOM_DEFAULT, "CUSTOM_DEFAULT" }, { RESOURCE_SUBLANGS::SUBLANG_CUSTOM_UNSPECIFIED, "CUSTOM_UNSPECIFIED" }, { RESOURCE_SUBLANGS::SUBLANG_CZECH_CZECH_REPUBLIC, "CZECH_CZECH_REPUBLIC" }, { RESOURCE_SUBLANGS::SUBLANG_DANISH_DENMARK, "DANISH_DENMARK" }, { RESOURCE_SUBLANGS::SUBLANG_DARI_AFGHANISTAN, "DARI_AFGHANISTAN" }, { RESOURCE_SUBLANGS::SUBLANG_DEFAULT, "DEFAULT" }, { RESOURCE_SUBLANGS::SUBLANG_DIVEHI_MALDIVES, "DIVEHI_MALDIVES" }, { RESOURCE_SUBLANGS::SUBLANG_DUTCH_BELGIAN, "DUTCH_BELGIAN" }, { RESOURCE_SUBLANGS::SUBLANG_DUTCH, "DUTCH" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_AUS, "ENGLISH_AUS" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_BELIZE, "ENGLISH_BELIZE" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_CAN, "ENGLISH_CAN" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_CARIBBEAN, "ENGLISH_CARIBBEAN" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_EIRE, "ENGLISH_EIRE" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_INDIA, "ENGLISH_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_JAMAICA, "ENGLISH_JAMAICA" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_MALAYSIA, "ENGLISH_MALAYSIA" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_NZ, "ENGLISH_NZ" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_PHILIPPINES, "ENGLISH_PHILIPPINES" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_SINGAPORE, "ENGLISH_SINGAPORE" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_SOUTH_AFRICA, "ENGLISH_SOUTH_AFRICA" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_TRINIDAD, "ENGLISH_TRINIDAD" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_UK, "ENGLISH_UK" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_US, "ENGLISH_US" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_ZIMBABWE, "ENGLISH_ZIMBABWE" }, { RESOURCE_SUBLANGS::SUBLANG_ENGLISH_IRELAND, "ENGLISH_IRELAND" }, { RESOURCE_SUBLANGS::SUBLANG_ESTONIAN_ESTONIA, "ESTONIAN_ESTONIA" }, { RESOURCE_SUBLANGS::SUBLANG_FAEROESE_FAROE_ISLANDS, "FAEROESE_FAROE_ISLANDS" }, { RESOURCE_SUBLANGS::SUBLANG_FILIPINO_PHILIPPINES, "FILIPINO_PHILIPPINES" }, { RESOURCE_SUBLANGS::SUBLANG_FINNISH_FINLAND, "FINNISH_FINLAND" }, { RESOURCE_SUBLANGS::SUBLANG_FRENCH_BELGIAN, "FRENCH_BELGIAN" }, { RESOURCE_SUBLANGS::SUBLANG_FRENCH_CANADIAN, "FRENCH_CANADIAN" }, { RESOURCE_SUBLANGS::SUBLANG_FRENCH_LUXEMBOURG, "FRENCH_LUXEMBOURG" }, { RESOURCE_SUBLANGS::SUBLANG_FRENCH_MONACO, "FRENCH_MONACO" }, { RESOURCE_SUBLANGS::SUBLANG_FRENCH_SWISS, "FRENCH_SWISS" }, { RESOURCE_SUBLANGS::SUBLANG_FRENCH, "FRENCH" }, { RESOURCE_SUBLANGS::SUBLANG_FRISIAN_NETHERLANDS, "FRISIAN_NETHERLANDS" }, { RESOURCE_SUBLANGS::SUBLANG_GALICIAN_GALICIAN, "GALICIAN_GALICIAN" }, { RESOURCE_SUBLANGS::SUBLANG_GEORGIAN_GEORGIA, "GEORGIAN_GEORGIA" }, { RESOURCE_SUBLANGS::SUBLANG_GERMAN_AUSTRIAN, "GERMAN_AUSTRIAN" }, { RESOURCE_SUBLANGS::SUBLANG_GERMAN_LIECHTENSTEIN, "GERMAN_LIECHTENSTEIN" }, { RESOURCE_SUBLANGS::SUBLANG_GERMAN_LUXEMBOURG, "GERMAN_LUXEMBOURG" }, { RESOURCE_SUBLANGS::SUBLANG_GERMAN_SWISS, "GERMAN_SWISS" }, { RESOURCE_SUBLANGS::SUBLANG_GERMAN, "GERMAN" }, { RESOURCE_SUBLANGS::SUBLANG_GREEK_GREECE, "GREEK_GREECE" }, { RESOURCE_SUBLANGS::SUBLANG_GREENLANDIC_GREENLAND, "GREENLANDIC_GREENLAND" }, { RESOURCE_SUBLANGS::SUBLANG_GUJARATI_INDIA, "GUJARATI_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_HAUSA_NIGERIA_LATIN, "HAUSA_NIGERIA_LATIN" }, { RESOURCE_SUBLANGS::SUBLANG_HEBREW_ISRAEL, "HEBREW_ISRAEL" }, { RESOURCE_SUBLANGS::SUBLANG_HINDI_INDIA, "HINDI_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_HUNGARIAN_HUNGARY, "HUNGARIAN_HUNGARY" }, { RESOURCE_SUBLANGS::SUBLANG_ICELANDIC_ICELAND, "ICELANDIC_ICELAND" }, { RESOURCE_SUBLANGS::SUBLANG_IGBO_NIGERIA, "IGBO_NIGERIA" }, { RESOURCE_SUBLANGS::SUBLANG_INDONESIAN_INDONESIA, "INDONESIAN_INDONESIA" }, { RESOURCE_SUBLANGS::SUBLANG_INUKTITUT_CANADA_LATIN, "INUKTITUT_CANADA_LATIN" }, { RESOURCE_SUBLANGS::SUBLANG_INUKTITUT_CANADA, "INUKTITUT_CANADA" }, { RESOURCE_SUBLANGS::SUBLANG_IRISH_IRELAND, "IRISH_IRELAND" }, { RESOURCE_SUBLANGS::SUBLANG_ITALIAN_SWISS, "ITALIAN_SWISS" }, { RESOURCE_SUBLANGS::SUBLANG_ITALIAN, "ITALIAN" }, { RESOURCE_SUBLANGS::SUBLANG_JAPANESE_JAPAN, "JAPANESE_JAPAN" }, { RESOURCE_SUBLANGS::SUBLANG_KANNADA_INDIA, "KANNADA_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_KASHMIRI_INDIA, "KASHMIRI_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_KASHMIRI_SASIA, "KASHMIRI_SASIA" }, { RESOURCE_SUBLANGS::SUBLANG_KAZAK_KAZAKHSTAN, "KAZAK_KAZAKHSTAN" }, { RESOURCE_SUBLANGS::SUBLANG_KHMER_CAMBODIA, "KHMER_CAMBODIA" }, { RESOURCE_SUBLANGS::SUBLANG_KICHE_GUATEMALA, "KICHE_GUATEMALA" }, { RESOURCE_SUBLANGS::SUBLANG_KINYARWANDA_RWANDA, "KINYARWANDA_RWANDA" }, { RESOURCE_SUBLANGS::SUBLANG_KONKANI_INDIA, "KONKANI_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_KOREAN, "KOREAN" }, { RESOURCE_SUBLANGS::SUBLANG_KYRGYZ_KYRGYZSTAN, "KYRGYZ_KYRGYZSTAN" }, { RESOURCE_SUBLANGS::SUBLANG_LAO_LAO, "LAO_LAO" }, { RESOURCE_SUBLANGS::SUBLANG_LATVIAN_LATVIA, "LATVIAN_LATVIA" }, { RESOURCE_SUBLANGS::SUBLANG_LITHUANIAN_CLASSIC, "LITHUANIAN_CLASSIC" }, { RESOURCE_SUBLANGS::SUBLANG_LITHUANIAN, "LITHUANIAN" }, { RESOURCE_SUBLANGS::SUBLANG_LOWER_SORBIAN_GERMANY, "LOWER_SORBIAN_GERMANY" }, { RESOURCE_SUBLANGS::SUBLANG_LUXEMBOURGISH_LUXEMBOURG, "LUXEMBOURGISH_LUXEMBOURG" }, { RESOURCE_SUBLANGS::SUBLANG_MACEDONIAN_MACEDONIA, "MACEDONIAN_MACEDONIA" }, { RESOURCE_SUBLANGS::SUBLANG_MALAY_BRUNEI_DARUSSALAM, "MALAY_BRUNEI_DARUSSALAM" }, { RESOURCE_SUBLANGS::SUBLANG_MALAY_MALAYSIA, "MALAY_MALAYSIA" }, { RESOURCE_SUBLANGS::SUBLANG_MALAYALAM_INDIA, "MALAYALAM_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_MALTESE_MALTA, "MALTESE_MALTA" }, { RESOURCE_SUBLANGS::SUBLANG_MAORI_NEW_ZEALAND, "MAORI_NEW_ZEALAND" }, { RESOURCE_SUBLANGS::SUBLANG_MAPUDUNGUN_CHILE, "MAPUDUNGUN_CHILE" }, { RESOURCE_SUBLANGS::SUBLANG_MARATHI_INDIA, "MARATHI_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_MOHAWK_MOHAWK, "MOHAWK_MOHAWK" }, { RESOURCE_SUBLANGS::SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA, "MONGOLIAN_CYRILLIC_MONGOLIA" }, { RESOURCE_SUBLANGS::SUBLANG_MONGOLIAN_PRC, "MONGOLIAN_PRC" }, { RESOURCE_SUBLANGS::SUBLANG_NEPALI_INDIA, "NEPALI_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_NEPALI_NEPAL, "NEPALI_NEPAL" }, { RESOURCE_SUBLANGS::SUBLANG_NEUTRAL, "NEUTRAL" }, { RESOURCE_SUBLANGS::SUBLANG_NORWEGIAN_BOKMAL, "NORWEGIAN_BOKMAL" }, { RESOURCE_SUBLANGS::SUBLANG_NORWEGIAN_NYNORSK, "NORWEGIAN_NYNORSK" }, { RESOURCE_SUBLANGS::SUBLANG_OCCITAN_FRANCE, "OCCITAN_FRANCE" }, { RESOURCE_SUBLANGS::SUBLANG_ORIYA_INDIA, "ORIYA_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_PASHTO_AFGHANISTAN, "PASHTO_AFGHANISTAN" }, { RESOURCE_SUBLANGS::SUBLANG_PERSIAN_IRAN, "PERSIAN_IRAN" }, { RESOURCE_SUBLANGS::SUBLANG_POLISH_POLAND, "POLISH_POLAND" }, { RESOURCE_SUBLANGS::SUBLANG_PORTUGUESE_BRAZILIAN, "PORTUGUESE_BRAZILIAN" }, { RESOURCE_SUBLANGS::SUBLANG_PORTUGUESE, "PORTUGUESE" }, { RESOURCE_SUBLANGS::SUBLANG_PUNJABI_INDIA, "PUNJABI_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_QUECHUA_BOLIVIA, "QUECHUA_BOLIVIA" }, { RESOURCE_SUBLANGS::SUBLANG_QUECHUA_ECUADOR, "QUECHUA_ECUADOR" }, { RESOURCE_SUBLANGS::SUBLANG_QUECHUA_PERU, "QUECHUA_PERU" }, { RESOURCE_SUBLANGS::SUBLANG_ROMANIAN_ROMANIA, "ROMANIAN_ROMANIA" }, { RESOURCE_SUBLANGS::SUBLANG_ROMANSH_SWITZERLAND, "ROMANSH_SWITZERLAND" }, { RESOURCE_SUBLANGS::SUBLANG_RUSSIAN_RUSSIA, "RUSSIAN_RUSSIA" }, { RESOURCE_SUBLANGS::SUBLANG_SAMI_INARI_FINLAND, "SAMI_INARI_FINLAND" }, { RESOURCE_SUBLANGS::SUBLANG_SAMI_LULE_NORWAY, "SAMI_LULE_NORWAY" }, { RESOURCE_SUBLANGS::SUBLANG_SAMI_LULE_SWEDEN, "SAMI_LULE_SWEDEN" }, { RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_FINLAND, "SAMI_NORTHERN_FINLAND" }, { RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_NORWAY, "SAMI_NORTHERN_NORWAY" }, { RESOURCE_SUBLANGS::SUBLANG_SAMI_NORTHERN_SWEDEN, "SAMI_NORTHERN_SWEDEN" }, { RESOURCE_SUBLANGS::SUBLANG_SAMI_SKOLT_FINLAND, "SAMI_SKOLT_FINLAND" }, { RESOURCE_SUBLANGS::SUBLANG_SAMI_SOUTHERN_NORWAY, "SAMI_SOUTHERN_NORWAY" }, { RESOURCE_SUBLANGS::SUBLANG_SAMI_SOUTHERN_SWEDEN, "SAMI_SOUTHERN_SWEDEN" }, { RESOURCE_SUBLANGS::SUBLANG_SANSKRIT_INDIA, "SANSKRIT_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC, "SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC" }, { RESOURCE_SUBLANGS::SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN, "SERBIAN_BOSNIA_HERZEGOVINA_LATIN" }, { RESOURCE_SUBLANGS::SUBLANG_SERBIAN_CROATIA, "SERBIAN_CROATIA" }, { RESOURCE_SUBLANGS::SUBLANG_SERBIAN_CYRILLIC, "SERBIAN_CYRILLIC" }, { RESOURCE_SUBLANGS::SUBLANG_SERBIAN_LATIN, "SERBIAN_LATIN" }, { RESOURCE_SUBLANGS::SUBLANG_SINDHI_AFGHANISTAN, "SINDHI_AFGHANISTAN" }, { RESOURCE_SUBLANGS::SUBLANG_SINDHI_INDIA, "SINDHI_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_SINDHI_PAKISTAN, "SINDHI_PAKISTAN" }, { RESOURCE_SUBLANGS::SUBLANG_SINHALESE_SRI_LANKA, "SINHALESE_SRI_LANKA" }, { RESOURCE_SUBLANGS::SUBLANG_SLOVAK_SLOVAKIA, "SLOVAK_SLOVAKIA" }, { RESOURCE_SUBLANGS::SUBLANG_SLOVENIAN_SLOVENIA, "SLOVENIAN_SLOVENIA" }, { RESOURCE_SUBLANGS::SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA, "SOTHO_NORTHERN_SOUTH_AFRICA" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_ARGENTINA, "SPANISH_ARGENTINA" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_BOLIVIA, "SPANISH_BOLIVIA" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_CHILE, "SPANISH_CHILE" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_COLOMBIA, "SPANISH_COLOMBIA" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_COSTA_RICA, "SPANISH_COSTA_RICA" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_DOMINICAN_REPUBLIC, "SPANISH_DOMINICAN_REPUBLIC" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_ECUADOR, "SPANISH_ECUADOR" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_EL_SALVADOR, "SPANISH_EL_SALVADOR" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_GUATEMALA, "SPANISH_GUATEMALA" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_HONDURAS, "SPANISH_HONDURAS" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_MEXICAN, "SPANISH_MEXICAN" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_MODERN, "SPANISH_MODERN" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_NICARAGUA, "SPANISH_NICARAGUA" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_PANAMA, "SPANISH_PANAMA" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_PARAGUAY, "SPANISH_PARAGUAY" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_PERU, "SPANISH_PERU" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_PUERTO_RICO, "SPANISH_PUERTO_RICO" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_URUGUAY, "SPANISH_URUGUAY" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_US, "SPANISH_US" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH_VENEZUELA, "SPANISH_VENEZUELA" }, { RESOURCE_SUBLANGS::SUBLANG_SPANISH, "SPANISH" }, { RESOURCE_SUBLANGS::SUBLANG_SWAHILI_KENYA, "SWAHILI_KENYA" }, { RESOURCE_SUBLANGS::SUBLANG_SWEDISH_FINLAND, "SWEDISH_FINLAND" }, { RESOURCE_SUBLANGS::SUBLANG_SWEDISH, "SWEDISH" }, { RESOURCE_SUBLANGS::SUBLANG_SYRIAC_SYRIA, "SYRIAC_SYRIA" }, { RESOURCE_SUBLANGS::SUBLANG_SYS_DEFAULT, "SYS_DEFAULT" }, { RESOURCE_SUBLANGS::SUBLANG_TAJIK_TAJIKISTAN, "TAJIK_TAJIKISTAN" }, { RESOURCE_SUBLANGS::SUBLANG_TAMAZIGHT_ALGERIA_LATIN, "TAMAZIGHT_ALGERIA_LATIN" }, { RESOURCE_SUBLANGS::SUBLANG_TAMIL_INDIA, "TAMIL_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_TATAR_RUSSIA, "TATAR_RUSSIA" }, { RESOURCE_SUBLANGS::SUBLANG_TELUGU_INDIA, "TELUGU_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_THAI_THAILAND, "THAI_THAILAND" }, { RESOURCE_SUBLANGS::SUBLANG_TIBETAN_PRC, "TIBETAN_PRC" }, { RESOURCE_SUBLANGS::SUBLANG_TIGRIGNA_ERITREA, "TIGRIGNA_ERITREA" }, { RESOURCE_SUBLANGS::SUBLANG_TSWANA_SOUTH_AFRICA, "TSWANA_SOUTH_AFRICA" }, { RESOURCE_SUBLANGS::SUBLANG_TURKISH_TURKEY, "TURKISH_TURKEY" }, { RESOURCE_SUBLANGS::SUBLANG_TURKMEN_TURKMENISTAN, "TURKMEN_TURKMENISTAN" }, { RESOURCE_SUBLANGS::SUBLANG_UI_CUSTOM_DEFAULT, "UI_CUSTOM_DEFAULT" }, { RESOURCE_SUBLANGS::SUBLANG_UIGHUR_PRC, "UIGHUR_PRC" }, { RESOURCE_SUBLANGS::SUBLANG_UKRAINIAN_UKRAINE, "UKRAINIAN_UKRAINE" }, { RESOURCE_SUBLANGS::SUBLANG_UPPER_SORBIAN_GERMANY, "UPPER_SORBIAN_GERMANY" }, { RESOURCE_SUBLANGS::SUBLANG_URDU_INDIA, "URDU_INDIA" }, { RESOURCE_SUBLANGS::SUBLANG_URDU_PAKISTAN, "URDU_PAKISTAN" }, { RESOURCE_SUBLANGS::SUBLANG_UZBEK_CYRILLIC, "UZBEK_CYRILLIC" }, { RESOURCE_SUBLANGS::SUBLANG_UZBEK_LATIN, "UZBEK_LATIN" }, { RESOURCE_SUBLANGS::SUBLANG_VIETNAMESE_VIETNAM, "VIETNAMESE_VIETNAM" }, { RESOURCE_SUBLANGS::SUBLANG_WELSH_UNITED_KINGDOM, "WELSH_UNITED_KINGDOM" }, { RESOURCE_SUBLANGS::SUBLANG_WOLOF_SENEGAL, "WOLOF_SENEGAL" }, { RESOURCE_SUBLANGS::SUBLANG_XHOSA_SOUTH_AFRICA, "XHOSA_SOUTH_AFRICA" }, { RESOURCE_SUBLANGS::SUBLANG_YAKUT_RUSSIA, "YAKUT_RUSSIA" }, { RESOURCE_SUBLANGS::SUBLANG_YI_PRC, "YI_PRC" }, { RESOURCE_SUBLANGS::SUBLANG_YORUBA_NIGERIA, "YORUBA_NIGERIA" }, { RESOURCE_SUBLANGS::SUBLANG_ZULU_SOUTH_AFRICA, "ZULU_SOUTH_AFRICA" }, { RESOURCE_SUBLANGS::SUBLANG_PUNJABI_PAKISTAN, "PUNJABI_PAKISTAN" }, { RESOURCE_SUBLANGS::SUBLANG_TSWANA_BOTSWANA, "TSWANA_BOTSWANA" }, { RESOURCE_SUBLANGS::SUBLANG_TAMIL_SRI_LANKA, "TAMIL_SRI_LANKA" }, { RESOURCE_SUBLANGS::SUBLANG_TIGRINYA_ETHIOPIA, "TIGRINYA_ETHIOPIA" }, { RESOURCE_SUBLANGS::SUBLANG_TIGRINYA_ERITREA, "TIGRINYA_ERITREA" }, { RESOURCE_SUBLANGS::SUBLANG_VALENCIAN_VALENCIA, "VALENCIAN_VALENCIA" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(EXTENDED_WINDOW_STYLES e) { CONST_MAP(EXTENDED_WINDOW_STYLES, const char*, 17) enumStrings { { EXTENDED_WINDOW_STYLES::WS_EX_DLGMODALFRAME, "DLGMODALFRAME" }, { EXTENDED_WINDOW_STYLES::WS_EX_NOPARENTNOTIFY, "NOPARENTNOTIFY" }, { EXTENDED_WINDOW_STYLES::WS_EX_TOPMOST, "TOPMOST" }, { EXTENDED_WINDOW_STYLES::WS_EX_ACCEPTFILES, "ACCEPTFILES" }, { EXTENDED_WINDOW_STYLES::WS_EX_TRANSPARENT, "TRANSPARENT" }, { EXTENDED_WINDOW_STYLES::WS_EX_MDICHILD, "MDICHILD" }, { EXTENDED_WINDOW_STYLES::WS_EX_TOOLWINDOW, "TOOLWINDOW" }, { EXTENDED_WINDOW_STYLES::WS_EX_WINDOWEDGE, "WINDOWEDGE" }, { EXTENDED_WINDOW_STYLES::WS_EX_CLIENTEDGE, "CLIENTEDGE" }, { EXTENDED_WINDOW_STYLES::WS_EX_CONTEXTHELP, "CONTEXTHELP" }, { EXTENDED_WINDOW_STYLES::WS_EX_RIGHT, "RIGHT" }, { EXTENDED_WINDOW_STYLES::WS_EX_LEFT, "LEFT" }, { EXTENDED_WINDOW_STYLES::WS_EX_RTLREADING, "RTLREADING" }, { EXTENDED_WINDOW_STYLES::WS_EX_LEFTSCROLLBAR, "LEFTSCROLLBAR" }, { EXTENDED_WINDOW_STYLES::WS_EX_CONTROLPARENT, "CONTROLPARENT" }, { EXTENDED_WINDOW_STYLES::WS_EX_STATICEDGE, "STATICEDGE" }, { EXTENDED_WINDOW_STYLES::WS_EX_APPWINDOW, "APPWINDOW" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(WINDOW_STYLES e) { CONST_MAP(WINDOW_STYLES, const char*, 18) enumStrings { { WINDOW_STYLES::WS_OVERLAPPED, "OVERLAPPED" }, { WINDOW_STYLES::WS_POPUP, "POPUP" }, { WINDOW_STYLES::WS_CHILD, "CHILD" }, { WINDOW_STYLES::WS_MINIMIZE, "MINIMIZE" }, { WINDOW_STYLES::WS_VISIBLE, "VISIBLE" }, { WINDOW_STYLES::WS_DISABLED, "DISABLED" }, { WINDOW_STYLES::WS_CLIPSIBLINGS, "CLIPSIBLINGS" }, { WINDOW_STYLES::WS_CLIPCHILDREN, "CLIPCHILDREN" }, { WINDOW_STYLES::WS_MAXIMIZE, "MAXIMIZE" }, { WINDOW_STYLES::WS_CAPTION, "CAPTION" }, { WINDOW_STYLES::WS_BORDER, "BORDER" }, { WINDOW_STYLES::WS_DLGFRAME, "DLGFRAME" }, { WINDOW_STYLES::WS_VSCROLL, "VSCROLL" }, { WINDOW_STYLES::WS_HSCROLL, "HSCROLL" }, { WINDOW_STYLES::WS_SYSMENU, "SYSMENU" }, { WINDOW_STYLES::WS_THICKFRAME, "THICKFRAME" }, { WINDOW_STYLES::WS_MINIMIZEBOX, "MINIMIZEBOX" }, { WINDOW_STYLES::WS_MAXIMIZEBOX, "MAXIMIZEBOX" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(DIALOG_BOX_STYLES e) { CONST_MAP(DIALOG_BOX_STYLES, const char*, 15) enumStrings { { DIALOG_BOX_STYLES::DS_ABSALIGN, "ABSALIGN" }, { DIALOG_BOX_STYLES::DS_SYSMODAL, "SYSMODAL" }, { DIALOG_BOX_STYLES::DS_LOCALEDIT, "LOCALEDIT" }, { DIALOG_BOX_STYLES::DS_SETFONT, "SETFONT" }, { DIALOG_BOX_STYLES::DS_MODALFRAME, "MODALFRAME" }, { DIALOG_BOX_STYLES::DS_NOIDLEMSG, "NOIDLEMSG" }, { DIALOG_BOX_STYLES::DS_SETFOREGROUND, "SETFOREGROUND" }, { DIALOG_BOX_STYLES::DS_3DLOOK, "D3DLOOK" }, { DIALOG_BOX_STYLES::DS_FIXEDSYS, "FIXEDSYS" }, { DIALOG_BOX_STYLES::DS_NOFAILCREATE, "NOFAILCREATE" }, { DIALOG_BOX_STYLES::DS_CONTROL, "CONTROL" }, { DIALOG_BOX_STYLES::DS_CENTER, "CENTER" }, { DIALOG_BOX_STYLES::DS_CENTERMOUSE, "CENTERMOUSE" }, { DIALOG_BOX_STYLES::DS_CONTEXTHELP, "CONTEXTHELP" }, { DIALOG_BOX_STYLES::DS_SHELLFONT, "SHELLFONT" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(FIXED_VERSION_OS e) { CONST_MAP(FIXED_VERSION_OS, const char*, 14) enumStrings { { FIXED_VERSION_OS::VOS_UNKNOWN, "UNKNOWN" }, { FIXED_VERSION_OS::VOS_DOS, "DOS" }, { FIXED_VERSION_OS::VOS_NT, "NT" }, { FIXED_VERSION_OS::VOS__WINDOWS16, "WINDOWS16" }, { FIXED_VERSION_OS::VOS__WINDOWS32, "WINDOWS32" }, { FIXED_VERSION_OS::VOS_OS216, "OS216" }, { FIXED_VERSION_OS::VOS_OS232, "OS232" }, { FIXED_VERSION_OS::VOS__PM16, "PM16" }, { FIXED_VERSION_OS::VOS__PM32, "PM32" }, { FIXED_VERSION_OS::VOS_DOS_WINDOWS16, "DOS_WINDOWS16" }, { FIXED_VERSION_OS::VOS_DOS_WINDOWS32, "DOS_WINDOWS32" }, { FIXED_VERSION_OS::VOS_NT_WINDOWS32, "NT_WINDOWS32" }, { FIXED_VERSION_OS::VOS_OS216_PM16, "OS216_PM16" }, { FIXED_VERSION_OS::VOS_OS232_PM32, "OS232_PM32" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(FIXED_VERSION_FILE_FLAGS e) { CONST_MAP(FIXED_VERSION_FILE_FLAGS, const char*, 6) enumStrings { { FIXED_VERSION_FILE_FLAGS::VS_FF_DEBUG, "DEBUG" }, { FIXED_VERSION_FILE_FLAGS::VS_FF_INFOINFERRED, "INFOINFERRED" }, { FIXED_VERSION_FILE_FLAGS::VS_FF_PATCHED, "PATCHED" }, { FIXED_VERSION_FILE_FLAGS::VS_FF_PRERELEASE, "PRERELEASE" }, { FIXED_VERSION_FILE_FLAGS::VS_FF_PRIVATEBUILD, "PRIVATEBUILD" }, { FIXED_VERSION_FILE_FLAGS::VS_FF_SPECIALBUILD, "SPECIALBUILD" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(FIXED_VERSION_FILE_TYPES e) { CONST_MAP(FIXED_VERSION_FILE_TYPES, const char*, 7) enumStrings { { FIXED_VERSION_FILE_TYPES::VFT_APP, "APP" }, { FIXED_VERSION_FILE_TYPES::VFT_DLL, "DLL" }, { FIXED_VERSION_FILE_TYPES::VFT_DRV, "DRV" }, { FIXED_VERSION_FILE_TYPES::VFT_FONT, "FONT" }, { FIXED_VERSION_FILE_TYPES::VFT_STATIC_LIB, "STATIC_LIB" }, { FIXED_VERSION_FILE_TYPES::VFT_UNKNOWN, "UNKNOWN" }, { FIXED_VERSION_FILE_TYPES::VFT_VXD, "VXD" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(FIXED_VERSION_FILE_SUB_TYPES e) { CONST_MAP(FIXED_VERSION_FILE_SUB_TYPES, const char*, 12) enumStrings { { FIXED_VERSION_FILE_SUB_TYPES::VFT2_DRV_COMM, "DRV_COMM" }, { FIXED_VERSION_FILE_SUB_TYPES::VFT2_DRV_DISPLAY, "DRV_DISPLAY" }, { FIXED_VERSION_FILE_SUB_TYPES::VFT2_DRV_INSTALLABLE, "DRV_INSTALLABLE" }, { FIXED_VERSION_FILE_SUB_TYPES::VFT2_DRV_KEYBOARD, "DRV_KEYBOARD" }, { FIXED_VERSION_FILE_SUB_TYPES::VFT2_DRV_LANGUAGE, "DRV_LANGUAGE" }, { FIXED_VERSION_FILE_SUB_TYPES::VFT2_DRV_MOUSE, "DRV_MOUSE" }, { FIXED_VERSION_FILE_SUB_TYPES::VFT2_DRV_NETWORK, "DRV_NETWORK" }, { FIXED_VERSION_FILE_SUB_TYPES::VFT2_DRV_PRINTER, "DRV_PRINTER" }, { FIXED_VERSION_FILE_SUB_TYPES::VFT2_DRV_SOUND, "DRV_SOUND" }, { FIXED_VERSION_FILE_SUB_TYPES::VFT2_DRV_SYSTEM, "DRV_SYSTEM" }, { FIXED_VERSION_FILE_SUB_TYPES::VFT2_DRV_VERSIONED_PRINTER, "DRV_VERSIONED_PRINTER" }, { FIXED_VERSION_FILE_SUB_TYPES::VFT2_UNKNOWN, "UNKNOWN" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(CODE_PAGES e) { CONST_MAP(CODE_PAGES, const char*, 140) enumStrings { { CODE_PAGES::CP_IBM037, "IBM037"}, { CODE_PAGES::CP_IBM437, "IBM437"}, { CODE_PAGES::CP_IBM500, "IBM500"}, { CODE_PAGES::CP_ASMO_708, "ASMO_708"}, { CODE_PAGES::CP_DOS_720, "DOS_720"}, { CODE_PAGES::CP_IBM737, "IBM737"}, { CODE_PAGES::CP_IBM775, "IBM775"}, { CODE_PAGES::CP_IBM850, "IBM850"}, { CODE_PAGES::CP_IBM852, "IBM852"}, { CODE_PAGES::CP_IBM855, "IBM855"}, { CODE_PAGES::CP_IBM857, "IBM857"}, { CODE_PAGES::CP_IBM00858, "IBM00858"}, { CODE_PAGES::CP_IBM860, "IBM860"}, { CODE_PAGES::CP_IBM861, "IBM861"}, { CODE_PAGES::CP_DOS_862, "DOS_862"}, { CODE_PAGES::CP_IBM863, "IBM863"}, { CODE_PAGES::CP_IBM864, "IBM864"}, { CODE_PAGES::CP_IBM865, "IBM865"}, { CODE_PAGES::CP_CP866, "CP866"}, { CODE_PAGES::CP_IBM869, "IBM869"}, { CODE_PAGES::CP_IBM870, "IBM870"}, { CODE_PAGES::CP_WINDOWS_874, "WINDOWS_874"}, { CODE_PAGES::CP_CP875, "CP875"}, { CODE_PAGES::CP_SHIFT_JIS, "SHIFT_JIS"}, { CODE_PAGES::CP_GB2312, "GB2312"}, { CODE_PAGES::CP_KS_C_5601_1987, "KS_C_5601_1987"}, { CODE_PAGES::CP_BIG5, "BIG5"}, { CODE_PAGES::CP_IBM1026, "IBM1026"}, { CODE_PAGES::CP_IBM01047, "IBM01047"}, { CODE_PAGES::CP_IBM01140, "IBM01140"}, { CODE_PAGES::CP_IBM01141, "IBM01141"}, { CODE_PAGES::CP_IBM01142, "IBM01142"}, { CODE_PAGES::CP_IBM01143, "IBM01143"}, { CODE_PAGES::CP_IBM01144, "IBM01144"}, { CODE_PAGES::CP_IBM01145, "IBM01145"}, { CODE_PAGES::CP_IBM01146, "IBM01146"}, { CODE_PAGES::CP_IBM01147, "IBM01147"}, { CODE_PAGES::CP_IBM01148, "IBM01148"}, { CODE_PAGES::CP_IBM01149, "IBM01149"}, { CODE_PAGES::CP_UTF_16, "UTF_16"}, { CODE_PAGES::CP_UNICODEFFFE, "UNICODEFFFE"}, { CODE_PAGES::CP_WINDOWS_1250, "WINDOWS_1250"}, { CODE_PAGES::CP_WINDOWS_1251, "WINDOWS_1251"}, { CODE_PAGES::CP_WINDOWS_1252, "WINDOWS_1252"}, { CODE_PAGES::CP_WINDOWS_1253, "WINDOWS_1253"}, { CODE_PAGES::CP_WINDOWS_1254, "WINDOWS_1254"}, { CODE_PAGES::CP_WINDOWS_1255, "WINDOWS_1255"}, { CODE_PAGES::CP_WINDOWS_1256, "WINDOWS_1256"}, { CODE_PAGES::CP_WINDOWS_1257, "WINDOWS_1257"}, { CODE_PAGES::CP_WINDOWS_1258, "WINDOWS_1258"}, { CODE_PAGES::CP_JOHAB, "JOHAB"}, { CODE_PAGES::CP_MACINTOSH, "MACINTOSH"}, { CODE_PAGES::CP_X_MAC_JAPANESE, "X_MAC_JAPANESE"}, { CODE_PAGES::CP_X_MAC_CHINESETRAD, "X_MAC_CHINESETRAD"}, { CODE_PAGES::CP_X_MAC_KOREAN, "X_MAC_KOREAN"}, { CODE_PAGES::CP_X_MAC_ARABIC, "X_MAC_ARABIC"}, { CODE_PAGES::CP_X_MAC_HEBREW, "X_MAC_HEBREW"}, { CODE_PAGES::CP_X_MAC_GREEK, "X_MAC_GREEK"}, { CODE_PAGES::CP_X_MAC_CYRILLIC, "X_MAC_CYRILLIC"}, { CODE_PAGES::CP_X_MAC_CHINESESIMP, "X_MAC_CHINESESIMP"}, { CODE_PAGES::CP_X_MAC_ROMANIAN, "X_MAC_ROMANIAN"}, { CODE_PAGES::CP_X_MAC_UKRAINIAN, "X_MAC_UKRAINIAN"}, { CODE_PAGES::CP_X_MAC_THAI, "X_MAC_THAI"}, { CODE_PAGES::CP_X_MAC_CE, "X_MAC_CE"}, { CODE_PAGES::CP_X_MAC_ICELANDIC, "X_MAC_ICELANDIC"}, { CODE_PAGES::CP_X_MAC_TURKISH, "X_MAC_TURKISH"}, { CODE_PAGES::CP_X_MAC_CROATIAN, "X_MAC_CROATIAN"}, { CODE_PAGES::CP_UTF_32, "UTF_32"}, { CODE_PAGES::CP_UTF_32BE, "UTF_32BE"}, { CODE_PAGES::CP_X_CHINESE_CNS, "X_CHINESE_CNS"}, { CODE_PAGES::CP_X_CP20001, "X_CP20001"}, { CODE_PAGES::CP_X_CHINESE_ETEN, "X_CHINESE_ETEN"}, { CODE_PAGES::CP_X_CP20003, "X_CP20003"}, { CODE_PAGES::CP_X_CP20004, "X_CP20004"}, { CODE_PAGES::CP_X_CP20005, "X_CP20005"}, { CODE_PAGES::CP_X_IA5, "X_IA5"}, { CODE_PAGES::CP_X_IA5_GERMAN, "X_IA5_GERMAN"}, { CODE_PAGES::CP_X_IA5_SWEDISH, "X_IA5_SWEDISH"}, { CODE_PAGES::CP_X_IA5_NORWEGIAN, "X_IA5_NORWEGIAN"}, { CODE_PAGES::CP_US_ASCII, "US_ASCII"}, { CODE_PAGES::CP_X_CP20261, "X_CP20261"}, { CODE_PAGES::CP_X_CP20269, "X_CP20269"}, { CODE_PAGES::CP_IBM273, "IBM273"}, { CODE_PAGES::CP_IBM277, "IBM277"}, { CODE_PAGES::CP_IBM278, "IBM278"}, { CODE_PAGES::CP_IBM280, "IBM280"}, { CODE_PAGES::CP_IBM284, "IBM284"}, { CODE_PAGES::CP_IBM285, "IBM285"}, { CODE_PAGES::CP_IBM290, "IBM290"}, { CODE_PAGES::CP_IBM297, "IBM297"}, { CODE_PAGES::CP_IBM420, "IBM420"}, { CODE_PAGES::CP_IBM423, "IBM423"}, { CODE_PAGES::CP_IBM424, "IBM424"}, { CODE_PAGES::CP_X_EBCDIC_KOREANEXTENDED, "X_EBCDIC_KOREANEXTENDED"}, { CODE_PAGES::CP_IBM_THAI, "IBM_THAI"}, { CODE_PAGES::CP_KOI8_R, "KOI8_R"}, { CODE_PAGES::CP_IBM871, "IBM871"}, { CODE_PAGES::CP_IBM880, "IBM880"}, { CODE_PAGES::CP_IBM905, "IBM905"}, { CODE_PAGES::CP_IBM00924, "IBM00924"}, { CODE_PAGES::CP_EUC_JP_JIS, "EUC_JP_JIS"}, { CODE_PAGES::CP_X_CP20936, "X_CP20936"}, { CODE_PAGES::CP_X_CP20949, "X_CP20949"}, { CODE_PAGES::CP_CP1025, "CP1025"}, { CODE_PAGES::CP_KOI8_U, "KOI8_U"}, { CODE_PAGES::CP_ISO_8859_1, "ISO_8859_1"}, { CODE_PAGES::CP_ISO_8859_2, "ISO_8859_2"}, { CODE_PAGES::CP_ISO_8859_3, "ISO_8859_3"}, { CODE_PAGES::CP_ISO_8859_4, "ISO_8859_4"}, { CODE_PAGES::CP_ISO_8859_5, "ISO_8859_5"}, { CODE_PAGES::CP_ISO_8859_6, "ISO_8859_6"}, { CODE_PAGES::CP_ISO_8859_7, "ISO_8859_7"}, { CODE_PAGES::CP_ISO_8859_8, "ISO_8859_8"}, { CODE_PAGES::CP_ISO_8859_9, "ISO_8859_9"}, { CODE_PAGES::CP_ISO_8859_13, "ISO_8859_13"}, { CODE_PAGES::CP_ISO_8859_15, "ISO_8859_15"}, { CODE_PAGES::CP_X_EUROPA, "X_EUROPA"}, { CODE_PAGES::CP_ISO_8859_8_I, "ISO_8859_8_I"}, { CODE_PAGES::CP_ISO_2022_JP, "ISO_2022_JP"}, { CODE_PAGES::CP_CSISO2022JP, "CSISO2022JP"}, { CODE_PAGES::CP_ISO_2022_JP_JIS, "ISO_2022_JP_JIS"}, { CODE_PAGES::CP_ISO_2022_KR, "ISO_2022_KR"}, { CODE_PAGES::CP_X_CP50227, "X_CP50227"}, { CODE_PAGES::CP_EUC_JP, "EUC_JP"}, { CODE_PAGES::CP_EUC_CN, "EUC_CN"}, { CODE_PAGES::CP_EUC_KR, "EUC_KR"}, { CODE_PAGES::CP_HZ_GB_2312, "HZ_GB_2312"}, { CODE_PAGES::CP_GB18030, "GB18030"}, { CODE_PAGES::CP_X_ISCII_DE, "X_ISCII_DE"}, { CODE_PAGES::CP_X_ISCII_BE, "X_ISCII_BE"}, { CODE_PAGES::CP_X_ISCII_TA, "X_ISCII_TA"}, { CODE_PAGES::CP_X_ISCII_TE, "X_ISCII_TE"}, { CODE_PAGES::CP_X_ISCII_AS, "X_ISCII_AS"}, { CODE_PAGES::CP_X_ISCII_OR, "X_ISCII_OR"}, { CODE_PAGES::CP_X_ISCII_KA, "X_ISCII_KA"}, { CODE_PAGES::CP_X_ISCII_MA, "X_ISCII_MA"}, { CODE_PAGES::CP_X_ISCII_GU, "X_ISCII_GU"}, { CODE_PAGES::CP_X_ISCII_PA, "X_ISCII_PA"}, { CODE_PAGES::CP_UTF_7, "UTF_7"}, { CODE_PAGES::CP_UTF_8, "UTF_8"}, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(WIN_VERSION e) { CONST_MAP(WIN_VERSION, const char*, 9) enumStrings { { WIN_VERSION::WIN_UNKNOWN, "UNKNOWN" }, { WIN_VERSION::WIN_SEH, "SEH" }, { WIN_VERSION::WIN8_1, "WIN_8_1" }, { WIN_VERSION::WIN10_0_9879, "WIN10_0_9879" }, { WIN_VERSION::WIN10_0_14286, "WIN10_0_14286" }, { WIN_VERSION::WIN10_0_14383, "WIN10_0_14383" }, { WIN_VERSION::WIN10_0_14901, "WIN10_0_14901" }, { WIN_VERSION::WIN10_0_15002, "WIN10_0_15002" }, { WIN_VERSION::WIN10_0_16237, "WIN10_0_16237" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(GUARD_CF_FLAGS e) { CONST_MAP(GUARD_CF_FLAGS, const char*, 10) enumStrings { { GUARD_CF_FLAGS::GCF_NONE, "GCF_NONE" }, { GUARD_CF_FLAGS::GCF_INSTRUMENTED, "GCF_INSTRUMENTED" }, { GUARD_CF_FLAGS::GCF_W_INSTRUMENTED, "GCF_W_INSTRUMENTED" }, { GUARD_CF_FLAGS::GCF_FUNCTION_TABLE_PRESENT, "GCF_FUNCTION_TABLE_PRESENT" }, { GUARD_CF_FLAGS::GCF_EXPORT_SUPPRESSION_INFO_PRESENT, "GCF_EXPORT_SUPPRESSION_INFO_PRESENT" }, { GUARD_CF_FLAGS::GCF_ENABLE_EXPORT_SUPPRESSION, "GCF_ENABLE_EXPORT_SUPPRESSION" }, { GUARD_CF_FLAGS::GCF_LONGJUMP_TABLE_PRESENT, "GCF_LONGJUMP_TABLE_PRESENT" }, { GUARD_CF_FLAGS::GRF_INSTRUMENTED, "GRF_INSTRUMENTED" }, { GUARD_CF_FLAGS::GRF_ENABLE, "GRF_ENABLE" }, { GUARD_CF_FLAGS::GRF_STRICT, "GRF_STRICT" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(CODE_VIEW_SIGNATURES e) { CONST_MAP(CODE_VIEW_SIGNATURES, const char*, 5) enumStrings { { CODE_VIEW_SIGNATURES::CVS_UNKNOWN, "UNKNOWN" }, { CODE_VIEW_SIGNATURES::CVS_PDB_70, "PDB_70" }, { CODE_VIEW_SIGNATURES::CVS_PDB_20, "PDB_20" }, { CODE_VIEW_SIGNATURES::CVS_CV_50, "CV_50" }, { CODE_VIEW_SIGNATURES::CVS_CV_41, "CV_41" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? to_string(CODE_VIEW_SIGNATURES::CVS_UNKNOWN) : it->second; } const char* to_string(POGO_SIGNATURES e) { CONST_MAP(POGO_SIGNATURES, const char*, 3) enumStrings { { POGO_SIGNATURES::POGO_UNKNOWN, "UNKNOWN" }, { POGO_SIGNATURES::POGO_LCTG, "LCTG" }, { POGO_SIGNATURES::POGO_PGI, "PGI" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? to_string(POGO_SIGNATURES::POGO_UNKNOWN) : it->second; } const char* to_string(ACCELERATOR_FLAGS e) { CONST_MAP(ACCELERATOR_FLAGS, const char*, 6) enumStrings { { ACCELERATOR_FLAGS::FVIRTKEY, "FVIRTKEY" }, { ACCELERATOR_FLAGS::FNOINVERT, "FNOINVERT" }, { ACCELERATOR_FLAGS::FSHIFT, "FSHIFT" }, { ACCELERATOR_FLAGS::FCONTROL, "FCONTROL" }, { ACCELERATOR_FLAGS::FALT, "FALT" }, { ACCELERATOR_FLAGS::END, "END" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "Out of range" : it->second; } const char* to_string(ACCELERATOR_VK_CODES e) { CONST_MAP(ACCELERATOR_VK_CODES, const char*, 174) enumStrings { { ACCELERATOR_VK_CODES::VK_LBUTTON, "VK_LBUTTON" }, { ACCELERATOR_VK_CODES::VK_RBUTTON, "VK_RBUTTON" }, { ACCELERATOR_VK_CODES::VK_CANCEL, "VK_CANCEL" }, { ACCELERATOR_VK_CODES::VK_MBUTTON, "VK_MBUTTON" }, { ACCELERATOR_VK_CODES::VK_XBUTTON1, "VK_XBUTTON1" }, { ACCELERATOR_VK_CODES::VK_XBUTTON2, "VK_XBUTTON2" }, { ACCELERATOR_VK_CODES::VK_BACK, "VK_BACK" }, { ACCELERATOR_VK_CODES::VK_TAB, "VK_TAB" }, { ACCELERATOR_VK_CODES::VK_CLEAR, "VK_CLEAR" }, { ACCELERATOR_VK_CODES::VK_RETURN, "VK_RETURN" }, { ACCELERATOR_VK_CODES::VK_SHIFT, "VK_SHIFT" }, { ACCELERATOR_VK_CODES::VK_CONTROL, "VK_CONTROL" }, { ACCELERATOR_VK_CODES::VK_MENU, "VK_MENU" }, { ACCELERATOR_VK_CODES::VK_PAUSE, "VK_PAUSE" }, { ACCELERATOR_VK_CODES::VK_CAPITAL, "VK_CAPITAL" }, { ACCELERATOR_VK_CODES::VK_KANA, "VK_KANA" }, { ACCELERATOR_VK_CODES::VK_HANGUEL, "VK_HANGUEL" }, { ACCELERATOR_VK_CODES::VK_HANGUL, "VK_HANGUL" }, { ACCELERATOR_VK_CODES::VK_IME_ON, "VK_IME_ON" }, { ACCELERATOR_VK_CODES::VK_JUNJA, "VK_JUNJA" }, { ACCELERATOR_VK_CODES::VK_FINAL, "VK_FINAL" }, { ACCELERATOR_VK_CODES::VK_HANJA, "VK_HANJA" }, { ACCELERATOR_VK_CODES::VK_KANJI, "VK_KANJI" }, { ACCELERATOR_VK_CODES::VK_IME_OFF, "VK_IME_OFF" }, { ACCELERATOR_VK_CODES::VK_ESCAPE, "VK_ESCAPE" }, { ACCELERATOR_VK_CODES::VK_CONVERT, "VK_CONVERT" }, { ACCELERATOR_VK_CODES::VK_NONCONVERT, "VK_NONCONVERT" }, { ACCELERATOR_VK_CODES::VK_ACCEPT, "VK_ACCEPT" }, { ACCELERATOR_VK_CODES::VK_MODECHANGE, "VK_MODECHANGE" }, { ACCELERATOR_VK_CODES::VK_SPACE, "VK_SPACE" }, { ACCELERATOR_VK_CODES::VK_PRIOR, "VK_PRIOR" }, { ACCELERATOR_VK_CODES::VK_NEXT, "VK_NEXT" }, { ACCELERATOR_VK_CODES::VK_END, "VK_END" }, { ACCELERATOR_VK_CODES::VK_HOME, "VK_HOME" }, { ACCELERATOR_VK_CODES::VK_LEFT, "VK_LEFT" }, { ACCELERATOR_VK_CODES::VK_UP, "VK_UP" }, { ACCELERATOR_VK_CODES::VK_RIGHT, "VK_RIGHT" }, { ACCELERATOR_VK_CODES::VK_DOWN, "VK_DOWN" }, { ACCELERATOR_VK_CODES::VK_SELECT, "VK_SELECT" }, { ACCELERATOR_VK_CODES::VK_PRINT, "VK_PRINT" }, { ACCELERATOR_VK_CODES::VK_EXECUTE, "VK_EXECUTE" }, { ACCELERATOR_VK_CODES::VK_SNAPSHOT, "VK_SNAPSHOT" }, { ACCELERATOR_VK_CODES::VK_INSERT, "VK_INSERT" }, { ACCELERATOR_VK_CODES::VK_DELETE, "VK_DELETE" }, { ACCELERATOR_VK_CODES::VK_HELP, "VK_HELP" }, { ACCELERATOR_VK_CODES::VK_0, "VK_0" }, { ACCELERATOR_VK_CODES::VK_1, "VK_1" }, { ACCELERATOR_VK_CODES::VK_2, "VK_2" }, { ACCELERATOR_VK_CODES::VK_3, "VK_3" }, { ACCELERATOR_VK_CODES::VK_4, "VK_4" }, { ACCELERATOR_VK_CODES::VK_5, "VK_5" }, { ACCELERATOR_VK_CODES::VK_6, "VK_6" }, { ACCELERATOR_VK_CODES::VK_7, "VK_7" }, { ACCELERATOR_VK_CODES::VK_8, "VK_8" }, { ACCELERATOR_VK_CODES::VK_9, "VK_9" }, { ACCELERATOR_VK_CODES::VK_A, "VK_A" }, { ACCELERATOR_VK_CODES::VK_B, "VK_B" }, { ACCELERATOR_VK_CODES::VK_C, "VK_C" }, { ACCELERATOR_VK_CODES::VK_D, "VK_D" }, { ACCELERATOR_VK_CODES::VK_E, "VK_E" }, { ACCELERATOR_VK_CODES::VK_F, "VK_F" }, { ACCELERATOR_VK_CODES::VK_G, "VK_G" }, { ACCELERATOR_VK_CODES::VK_H, "VK_H" }, { ACCELERATOR_VK_CODES::VK_I, "VK_I" }, { ACCELERATOR_VK_CODES::VK_J, "VK_J" }, { ACCELERATOR_VK_CODES::VK_K, "VK_K" }, { ACCELERATOR_VK_CODES::VK_L, "VK_L" }, { ACCELERATOR_VK_CODES::VK_M, "VK_M" }, { ACCELERATOR_VK_CODES::VK_N, "VK_N" }, { ACCELERATOR_VK_CODES::VK_O, "VK_O" }, { ACCELERATOR_VK_CODES::VK_P, "VK_P" }, { ACCELERATOR_VK_CODES::VK_Q, "VK_Q" }, { ACCELERATOR_VK_CODES::VK_R, "VK_R" }, { ACCELERATOR_VK_CODES::VK_S, "VK_S" }, { ACCELERATOR_VK_CODES::VK_T, "VK_T" }, { ACCELERATOR_VK_CODES::VK_U, "VK_U" }, { ACCELERATOR_VK_CODES::VK_V, "VK_V" }, { ACCELERATOR_VK_CODES::VK_W, "VK_W" }, { ACCELERATOR_VK_CODES::VK_X, "VK_X" }, { ACCELERATOR_VK_CODES::VK_Y, "VK_Y" }, { ACCELERATOR_VK_CODES::VK_Z, "VK_Z" }, { ACCELERATOR_VK_CODES::VK_LWIN, "VK_LWIN" }, { ACCELERATOR_VK_CODES::VK_RWIN, "VK_RWIN" }, { ACCELERATOR_VK_CODES::VK_APPS, "VK_APPS" }, { ACCELERATOR_VK_CODES::VK_SLEEP, "VK_SLEEP" }, { ACCELERATOR_VK_CODES::VK_NUMPAD0, "VK_NUMPAD0" }, { ACCELERATOR_VK_CODES::VK_NUMPAD1, "VK_NUMPAD1" }, { ACCELERATOR_VK_CODES::VK_NUMPAD2, "VK_NUMPAD2" }, { ACCELERATOR_VK_CODES::VK_NUMPAD3, "VK_NUMPAD3" }, { ACCELERATOR_VK_CODES::VK_NUMPAD4, "VK_NUMPAD4" }, { ACCELERATOR_VK_CODES::VK_NUMPAD5, "VK_NUMPAD5" }, { ACCELERATOR_VK_CODES::VK_NUMPAD6, "VK_NUMPAD6" }, { ACCELERATOR_VK_CODES::VK_NUMPAD7, "VK_NUMPAD7" }, { ACCELERATOR_VK_CODES::VK_NUMPAD8, "VK_NUMPAD8" }, { ACCELERATOR_VK_CODES::VK_NUMPAD9, "VK_NUMPAD9" }, { ACCELERATOR_VK_CODES::VK_MULTIPLY, "VK_MULTIPLY" }, { ACCELERATOR_VK_CODES::VK_ADD, "VK_ADD" }, { ACCELERATOR_VK_CODES::VK_SEPARATOR, "VK_SEPARATOR" }, { ACCELERATOR_VK_CODES::VK_SUBTRACT, "VK_SUBTRACT" }, { ACCELERATOR_VK_CODES::VK_DECIMAL, "VK_DECIMAL" }, { ACCELERATOR_VK_CODES::VK_DIVIDE, "VK_DIVIDE" }, { ACCELERATOR_VK_CODES::VK_F1, "VK_F1" }, { ACCELERATOR_VK_CODES::VK_F2, "VK_F2" }, { ACCELERATOR_VK_CODES::VK_F3, "VK_F3" }, { ACCELERATOR_VK_CODES::VK_F4, "VK_F4" }, { ACCELERATOR_VK_CODES::VK_F5, "VK_F5" }, { ACCELERATOR_VK_CODES::VK_F6, "VK_F6" }, { ACCELERATOR_VK_CODES::VK_F7, "VK_F7" }, { ACCELERATOR_VK_CODES::VK_F8, "VK_F8" }, { ACCELERATOR_VK_CODES::VK_F9, "VK_F9" }, { ACCELERATOR_VK_CODES::VK_F10, "VK_F10" }, { ACCELERATOR_VK_CODES::VK_F11, "VK_F11" }, { ACCELERATOR_VK_CODES::VK_F12, "VK_F12" }, { ACCELERATOR_VK_CODES::VK_F13, "VK_F13" }, { ACCELERATOR_VK_CODES::VK_F14, "VK_F14" }, { ACCELERATOR_VK_CODES::VK_F15, "VK_F15" }, { ACCELERATOR_VK_CODES::VK_F16, "VK_F16" }, { ACCELERATOR_VK_CODES::VK_F17, "VK_F17" }, { ACCELERATOR_VK_CODES::VK_F18, "VK_F18" }, { ACCELERATOR_VK_CODES::VK_F19, "VK_F19" }, { ACCELERATOR_VK_CODES::VK_F20, "VK_F20" }, { ACCELERATOR_VK_CODES::VK_F21, "VK_F21" }, { ACCELERATOR_VK_CODES::VK_F22, "VK_F22" }, { ACCELERATOR_VK_CODES::VK_F23, "VK_F23" }, { ACCELERATOR_VK_CODES::VK_F24, "VK_F24" }, { ACCELERATOR_VK_CODES::VK_NUMLOCK, "VK_NUMLOCK" }, { ACCELERATOR_VK_CODES::VK_SCROLL, "VK_SCROLL" }, { ACCELERATOR_VK_CODES::VK_LSHIFT, "VK_LSHIFT" }, { ACCELERATOR_VK_CODES::VK_RSHIFT, "VK_RSHIFT" }, { ACCELERATOR_VK_CODES::VK_LCONTROL, "VK_LCONTROL" }, { ACCELERATOR_VK_CODES::VK_RCONTROL, "VK_RCONTROL" }, { ACCELERATOR_VK_CODES::VK_LMENU, "VK_LMENU" }, { ACCELERATOR_VK_CODES::VK_RMENU, "VK_RMENU" }, { ACCELERATOR_VK_CODES::VK_BROWSER_BACK, "VK_BROWSER_BACK" }, { ACCELERATOR_VK_CODES::VK_BROWSER_FORWARD, "VK_BROWSER_FORWARD" }, { ACCELERATOR_VK_CODES::VK_BROWSER_REFRESH, "VK_BROWSER_REFRESH" }, { ACCELERATOR_VK_CODES::VK_BROWSER_STOP, "VK_BROWSER_STOP" }, { ACCELERATOR_VK_CODES::VK_BROWSER_SEARCH, "VK_BROWSER_SEARCH" }, { ACCELERATOR_VK_CODES::VK_BROWSER_FAVORITES, "VK_BROWSER_FAVORITES" }, { ACCELERATOR_VK_CODES::VK_BROWSER_HOME, "VK_BROWSER_HOME" }, { ACCELERATOR_VK_CODES::VK_VOLUME_MUTE, "VK_VOLUME_MUTE" }, { ACCELERATOR_VK_CODES::VK_VOLUME_DOWN, "VK_VOLUME_DOWN" }, { ACCELERATOR_VK_CODES::VK_VOLUME_UP, "VK_VOLUME_UP" }, { ACCELERATOR_VK_CODES::VK_MEDIA_NEXT_TRACK, "VK_MEDIA_NEXT_TRACK" }, { ACCELERATOR_VK_CODES::VK_MEDIA_PREV_TRACK, "VK_MEDIA_PREV_TRACK" }, { ACCELERATOR_VK_CODES::VK_MEDIA_STOP, "VK_MEDIA_STOP" }, { ACCELERATOR_VK_CODES::VK_MEDIA_PLAY_PAUSE, "VK_MEDIA_PLAY_PAUSE" }, { ACCELERATOR_VK_CODES::VK_LAUNCH_MAIL, "VK_LAUNCH_MAIL" }, { ACCELERATOR_VK_CODES::VK_LAUNCH_MEDIA_SELECT, "VK_LAUNCH_MEDIA_SELECT" }, { ACCELERATOR_VK_CODES::VK_LAUNCH_APP1, "VK_LAUNCH_APP1" }, { ACCELERATOR_VK_CODES::VK_LAUNCH_APP2, "VK_LAUNCH_APP2" }, { ACCELERATOR_VK_CODES::VK_OEM_1, "VK_OEM_1" }, { ACCELERATOR_VK_CODES::VK_OEM_PLUS, "VK_OEM_PLUS" }, { ACCELERATOR_VK_CODES::VK_OEM_COMMA, "VK_OEM_COMMA" }, { ACCELERATOR_VK_CODES::VK_OEM_MINUS, "VK_OEM_MINUS" }, { ACCELERATOR_VK_CODES::VK_OEM_PERIOD, "VK_OEM_PERIOD" }, { ACCELERATOR_VK_CODES::VK_OEM_2, "VK_OEM_2" }, { ACCELERATOR_VK_CODES::VK_OEM_4, "VK_OEM_4" }, { ACCELERATOR_VK_CODES::VK_OEM_5, "VK_OEM_5" }, { ACCELERATOR_VK_CODES::VK_OEM_6, "VK_OEM_6" }, { ACCELERATOR_VK_CODES::VK_OEM_7, "VK_OEM_7" }, { ACCELERATOR_VK_CODES::VK_OEM_8, "VK_OEM_8" }, { ACCELERATOR_VK_CODES::VK_OEM_102, "VK_OEM_102" }, { ACCELERATOR_VK_CODES::VK_PROCESSKEY, "VK_PROCESSKEY" }, { ACCELERATOR_VK_CODES::VK_PACKET, "VK_PACKET" }, { ACCELERATOR_VK_CODES::VK_ATTN, "VK_ATTN" }, { ACCELERATOR_VK_CODES::VK_CRSEL, "VK_CRSEL" }, { ACCELERATOR_VK_CODES::VK_EXSEL, "VK_EXSEL" }, { ACCELERATOR_VK_CODES::VK_EREOF, "VK_EREOF" }, { ACCELERATOR_VK_CODES::VK_PLAY, "VK_PLAY" }, { ACCELERATOR_VK_CODES::VK_ZOOM, "VK_ZOOM" }, { ACCELERATOR_VK_CODES::VK_NONAME, "VK_NONAME" }, { ACCELERATOR_VK_CODES::VK_PA1, "VK_PA1" }, { ACCELERATOR_VK_CODES::VK_OEM_CLEAR, "VK_OEM_CLEAR" }, }; auto it = enumStrings.find(e); return it != enumStrings.end() ? it->second : "Undefined or reserved"; } const char* to_string(ALGORITHMS e) { CONST_MAP(ALGORITHMS, const char*, 20) enumStrings { { ALGORITHMS::UNKNOWN, "UNKNOWN" }, { ALGORITHMS::SHA_512, "SHA_512" }, { ALGORITHMS::SHA_384, "SHA_384" }, { ALGORITHMS::SHA_256, "SHA_256" }, { ALGORITHMS::SHA_1, "SHA_1" }, { ALGORITHMS::MD5, "MD5" }, { ALGORITHMS::MD4, "MD4" }, { ALGORITHMS::MD2, "MD2" }, { ALGORITHMS::RSA, "RSA" }, { ALGORITHMS::EC, "EC" }, { ALGORITHMS::MD5_RSA, "MD5_RSA" }, { ALGORITHMS::SHA1_DSA, "SHA1_DSA" }, { ALGORITHMS::SHA1_RSA, "SHA1_RSA" }, { ALGORITHMS::SHA_256_RSA, "SHA_256_RSA" }, { ALGORITHMS::SHA_384_RSA, "SHA_384_RSA" }, { ALGORITHMS::SHA_512_RSA, "SHA_512_RSA" }, { ALGORITHMS::SHA1_ECDSA, "SHA1_ECDSA" }, { ALGORITHMS::SHA_256_ECDSA, "SHA_256_ECDSA" }, { ALGORITHMS::SHA_384_ECDSA, "SHA_384_ECDSA" }, { ALGORITHMS::SHA_512_ECDSA, "SHA_512_ECDSA" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "UNKNOWN" : it->second; } const char* to_string(SIG_ATTRIBUTE_TYPES e) { CONST_MAP(SIG_ATTRIBUTE_TYPES, const char*, 11) enumStrings { { SIG_ATTRIBUTE_TYPES::UNKNOWN, "UNKNOWN" }, { SIG_ATTRIBUTE_TYPES::CONTENT_TYPE, "CONTENT_TYPE" }, { SIG_ATTRIBUTE_TYPES::GENERIC_TYPE, "GENERIC_TYPE" }, { SIG_ATTRIBUTE_TYPES::SPC_SP_OPUS_INFO, "SPC_SP_OPUS_INFO" }, { SIG_ATTRIBUTE_TYPES::MS_COUNTER_SIGN, "MS_COUNTER_SIGN" }, { SIG_ATTRIBUTE_TYPES::MS_SPC_NESTED_SIGN, "MS_SPC_NESTED_SIGN" }, { SIG_ATTRIBUTE_TYPES::MS_SPC_STATEMENT_TYPE, "MS_SPC_STATEMENT_TYPE" }, { SIG_ATTRIBUTE_TYPES::PKCS9_AT_SEQUENCE_NUMBER, "PKCS9_AT_SEQUENCE_NUMBER" }, { SIG_ATTRIBUTE_TYPES::PKCS9_COUNTER_SIGNATURE, "PKCS9_COUNTER_SIGNATURE" }, { SIG_ATTRIBUTE_TYPES::PKCS9_MESSAGE_DIGEST, "PKCS9_MESSAGE_DIGEST" }, { SIG_ATTRIBUTE_TYPES::PKCS9_SIGNING_TIME, "PKCS9_SIGNING_TIME" }, }; auto it = enumStrings.find(e); return it == enumStrings.end() ? "UNKNOWN" : it->second; } } // namespace PE } // namespace LIEF
59.92092
117
0.623863
junghee
33a1533625818e7d82b92ebf0eadfb77d6937f29
3,749
cpp
C++
TabGraph/src/Driver/OpenGL/Renderer/Light/PointLightRenderer.cpp
Gpinchon/TabGraph
29eae2d9982b6ce3e4ff43c707c87c2f57ab39bb
[ "Apache-2.0" ]
1
2020-08-28T09:35:18.000Z
2020-08-28T09:35:18.000Z
TabGraph/src/Driver/OpenGL/Renderer/Light/PointLightRenderer.cpp
Gpinchon/TabGraph
29eae2d9982b6ce3e4ff43c707c87c2f57ab39bb
[ "Apache-2.0" ]
null
null
null
TabGraph/src/Driver/OpenGL/Renderer/Light/PointLightRenderer.cpp
Gpinchon/TabGraph
29eae2d9982b6ce3e4ff43c707c87c2f57ab39bb
[ "Apache-2.0" ]
1
2020-10-08T11:21:13.000Z
2020-10-08T11:21:13.000Z
/* * @Author: gpinchon * @Date: 2021-04-11 20:53:00 * @Last Modified by: gpinchon * @Last Modified time: 2021-04-11 20:53:22 */ #include <Driver/OpenGL/Renderer/Light/PointLightRenderer.hpp> #include <Light/PointLight.hpp> #include <Surface/SphereMesh.hpp> #include <Renderer/Surface/GeometryRenderer.hpp> #include <Renderer/Renderer.hpp> #include <Shader/Program.hpp> #include <Shader/Stage.hpp> #include <Texture/Framebuffer.hpp> #include <Texture/Texture2D.hpp> #include <GL/glew.h> namespace Renderer { static inline auto PointLightGeometry() { static std::weak_ptr<Geometry> s_geometry; auto geometryPtr = s_geometry.lock(); if (geometryPtr == nullptr) { geometryPtr = SphereMesh::CreateGeometry("PointLightGeometry", 1, 1); s_geometry = geometryPtr; } return geometryPtr; } static inline auto PointLightVertexCode() { auto deferred_vert_code = #include "deferred.vert" ; auto lightVertexCode = #include "Lights/TransformGeometry.vert" ; Shader::Stage::Code shaderCode = Shader::Stage::Code{ lightVertexCode, "TransformGeometry();" }; return shaderCode; } static inline auto PointLightFragmentCode() { auto deferred_frag_code = #include "deferred.frag" ; auto lightFragmentShader = #include "Lights/DeferredPointLight.frag" ; Shader::Stage::Code shaderCode = Shader::Stage::Code{ deferred_frag_code, "FillFragmentData();" } + Shader::Stage::Code{ lightFragmentShader, "Lighting();" }; return shaderCode; } static inline auto PointLightShader() { auto shader = Component::Create<Shader::Program>("PointLightShader"); shader->SetDefine("Pass", "DeferredLighting"); shader->Attach(Shader::Stage(Shader::Stage::Type::Fragment, PointLightFragmentCode())); shader->Attach(Shader::Stage(Shader::Stage::Type::Vertex, PointLightVertexCode())); return shader; } PointLightRenderer::PointLightRenderer(PointLight &light) : LightRenderer(light) { _deferredShader = PointLightShader(); _deferredGeometry = PointLightGeometry(); } void PointLightRenderer::Render(const Renderer::Options& options) { if (options.pass == Renderer::Options::Pass::DeferredLighting) _RenderDeferredLighting(static_cast<PointLight&>(_light), options); else if (options.pass == Renderer::Options::Pass::ShadowDepth) _RenderShadow(static_cast<PointLight&>(_light), options); } void PointLightRenderer::UpdateLightProbe(const Renderer::Options&, LightProbe&) { } void PointLightRenderer::_RenderDeferredLighting(PointLight& light, const Renderer::Options& options) { auto geometryBuffer = options.renderer->DeferredGeometryBuffer(); _deferredShader->Use() .SetUniform("Light.DiffuseFactor", light.GetDiffuseFactor()) .SetUniform("Light.SpecularFactor", light.GetSpecularFactor()) .SetUniform("Light.Power", light.GetPower()) .SetUniform("Light.Radius", light.GetRadius()) .SetUniform("Light.Color", light.GetColor()) .SetUniform("Light.Position", light.WorldPosition()) .SetUniform("GeometryMatrix", light.WorldTranslationMatrix() * glm::scale(glm::vec3(light.GetRadius()))) .SetTexture("Texture.Geometry.F0", geometryBuffer->GetColorBuffer(1)) .SetTexture("Texture.Geometry.Normal", geometryBuffer->GetColorBuffer(2)) .SetTexture("Texture.Geometry.Depth", geometryBuffer->GetDepthBuffer()); glCullFace(GL_FRONT); Renderer::Render(_deferredGeometry); glCullFace(GL_BACK); _deferredShader->Done(); } void PointLightRenderer::_RenderShadow(PointLight&, const Renderer::Options&) { } }
34.081818
113
0.696452
Gpinchon
33a6f4edb73161265f12cd527183a5926bdfc4e1
21,467
cpp
C++
iyan3d/trunk/assimp-master/code/ComputeUVMappingProcess.cpp
RCGamer21/appanimar
4161f1c2dc319256b5e489cdbb439757e03bcd07
[ "MIT" ]
1
2019-12-21T08:15:08.000Z
2019-12-21T08:15:08.000Z
iyan3d/trunk/assimp-master/code/ComputeUVMappingProcess.cpp
lanping100/Iyan3d
c21bb191cec06039a3f6e9b2f19381cbd7537757
[ "MIT" ]
null
null
null
iyan3d/trunk/assimp-master/code/ComputeUVMappingProcess.cpp
lanping100/Iyan3d
c21bb191cec06039a3f6e9b2f19381cbd7537757
[ "MIT" ]
null
null
null
/* Open Asset Import Library (assimp) ---------------------------------------------------------------------- Copyright (c) 2006-2016, assimp team All rights reserved. Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the assimp team, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of the assimp team. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------- */ /** @file GenUVCoords step */ #include "ComputeUVMappingProcess.h" #include "ProcessHelper.h" #include "Exceptional.h" using namespace Assimp; namespace { const static aiVector3D base_axis_y(0.0,1.0,0.0); const static aiVector3D base_axis_x(1.0,0.0,0.0); const static aiVector3D base_axis_z(0.0,0.0,1.0); const static ai_real angle_epsilon = 0.95; } // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer ComputeUVMappingProcess::ComputeUVMappingProcess() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Destructor, private as well ComputeUVMappingProcess::~ComputeUVMappingProcess() { // nothing to do here } // ------------------------------------------------------------------------------------------------ // Returns whether the processing step is present in the given flag field. bool ComputeUVMappingProcess::IsActive( unsigned int pFlags) const { return (pFlags & aiProcess_GenUVCoords) != 0; } // ------------------------------------------------------------------------------------------------ // Check whether a ray intersects a plane and find the intersection point inline bool PlaneIntersect(const aiRay& ray, const aiVector3D& planePos, const aiVector3D& planeNormal, aiVector3D& pos) { const ai_real b = planeNormal * (planePos - ray.pos); ai_real h = ray.dir * planeNormal; if ((h < 10e-5 && h > -10e-5) || (h = b/h) < 0) return false; pos = ray.pos + (ray.dir * h); return true; } // ------------------------------------------------------------------------------------------------ // Find the first empty UV channel in a mesh inline unsigned int FindEmptyUVChannel (aiMesh* mesh) { for (unsigned int m = 0; m < AI_MAX_NUMBER_OF_TEXTURECOORDS;++m) if (!mesh->mTextureCoords[m])return m; DefaultLogger::get()->error("Unable to compute UV coordinates, no free UV slot found"); return UINT_MAX; } // ------------------------------------------------------------------------------------------------ // Try to remove UV seams void RemoveUVSeams (aiMesh* mesh, aiVector3D* out) { // TODO: just a very rough algorithm. I think it could be done // much easier, but I don't know how and am currently too tired to // to think about a better solution. const static ai_real LOWER_LIMIT = 0.1; const static ai_real UPPER_LIMIT = 0.9; const static ai_real LOWER_EPSILON = 10e-3; const static ai_real UPPER_EPSILON = 1.0-10e-3; for (unsigned int fidx = 0; fidx < mesh->mNumFaces;++fidx) { const aiFace& face = mesh->mFaces[fidx]; if (face.mNumIndices < 3) continue; // triangles and polygons only, please unsigned int small = face.mNumIndices, large = small; bool zero = false, one = false, round_to_zero = false; // Check whether this face lies on a UV seam. We can just guess, // but the assumption that a face with at least one very small // on the one side and one very large U coord on the other side // lies on a UV seam should work for most cases. for (unsigned int n = 0; n < face.mNumIndices;++n) { if (out[face.mIndices[n]].x < LOWER_LIMIT) { small = n; // If we have a U value very close to 0 we can't // round the others to 0, too. if (out[face.mIndices[n]].x <= LOWER_EPSILON) zero = true; else round_to_zero = true; } if (out[face.mIndices[n]].x > UPPER_LIMIT) { large = n; // If we have a U value very close to 1 we can't // round the others to 1, too. if (out[face.mIndices[n]].x >= UPPER_EPSILON) one = true; } } if (small != face.mNumIndices && large != face.mNumIndices) { for (unsigned int n = 0; n < face.mNumIndices;++n) { // If the u value is over the upper limit and no other u // value of that face is 0, round it to 0 if (out[face.mIndices[n]].x > UPPER_LIMIT && !zero) out[face.mIndices[n]].x = 0.0; // If the u value is below the lower limit and no other u // value of that face is 1, round it to 1 else if (out[face.mIndices[n]].x < LOWER_LIMIT && !one) out[face.mIndices[n]].x = 1.0; // The face contains both 0 and 1 as UV coords. This can occur // for faces which have an edge that lies directly on the seam. // Due to numerical inaccuracies one U coord becomes 0, the // other 1. But we do still have a third UV coord to determine // to which side we must round to. else if (one && zero) { if (round_to_zero && out[face.mIndices[n]].x >= UPPER_EPSILON) out[face.mIndices[n]].x = 0.0; else if (!round_to_zero && out[face.mIndices[n]].x <= LOWER_EPSILON) out[face.mIndices[n]].x = 1.0; } } } } } // ------------------------------------------------------------------------------------------------ void ComputeUVMappingProcess::ComputeSphereMapping(aiMesh* mesh,const aiVector3D& axis, aiVector3D* out) { aiVector3D center, min, max; FindMeshCenter(mesh, center, min, max); // If the axis is one of x,y,z run a faster code path. It's worth the extra effort ... // currently the mapping axis will always be one of x,y,z, except if the // PretransformVertices step is used (it transforms the meshes into worldspace, // thus changing the mapping axis) if (axis * base_axis_x >= angle_epsilon) { // For each point get a normalized projection vector in the sphere, // get its longitude and latitude and map them to their respective // UV axes. Problems occur around the poles ... unsolvable. // // The spherical coordinate system looks like this: // x = cos(lon)*cos(lat) // y = sin(lon)*cos(lat) // z = sin(lat) // // Thus we can derive: // lat = arcsin (z) // lon = arctan (y/x) for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D diff = (mesh->mVertices[pnt]-center).Normalize(); out[pnt] = aiVector3D((atan2 (diff.z, diff.y) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, (std::asin (diff.x) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.0); } } else if (axis * base_axis_y >= angle_epsilon) { // ... just the same again for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D diff = (mesh->mVertices[pnt]-center).Normalize(); out[pnt] = aiVector3D((atan2 (diff.x, diff.z) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, (std::asin (diff.y) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.0); } } else if (axis * base_axis_z >= angle_epsilon) { // ... just the same again for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D diff = (mesh->mVertices[pnt]-center).Normalize(); out[pnt] = aiVector3D((atan2 (diff.y, diff.x) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, (std::asin (diff.z) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.0); } } // slower code path in case the mapping axis is not one of the coordinate system axes else { aiMatrix4x4 mTrafo; aiMatrix4x4::FromToMatrix(axis,base_axis_y,mTrafo); // again the same, except we're applying a transformation now for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D diff = ((mTrafo*mesh->mVertices[pnt])-center).Normalize(); out[pnt] = aiVector3D((atan2 (diff.y, diff.x) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, (asin (diff.z) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.0); } } // Now find and remove UV seams. A seam occurs if a face has a tcoord // close to zero on the one side, and a tcoord close to one on the // other side. RemoveUVSeams(mesh,out); } // ------------------------------------------------------------------------------------------------ void ComputeUVMappingProcess::ComputeCylinderMapping(aiMesh* mesh,const aiVector3D& axis, aiVector3D* out) { aiVector3D center, min, max; // If the axis is one of x,y,z run a faster code path. It's worth the extra effort ... // currently the mapping axis will always be one of x,y,z, except if the // PretransformVertices step is used (it transforms the meshes into worldspace, // thus changing the mapping axis) if (axis * base_axis_x >= angle_epsilon) { FindMeshCenter(mesh, center, min, max); const ai_real diff = max.x - min.x; // If the main axis is 'z', the z coordinate of a point 'p' is mapped // directly to the texture V axis. The other axis is derived from // the angle between ( p.x - c.x, p.y - c.y ) and (1,0), where // 'c' is the center point of the mesh. for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D& pos = mesh->mVertices[pnt]; aiVector3D& uv = out[pnt]; uv.y = (pos.x - min.x) / diff; uv.x = (atan2 ( pos.z - center.z, pos.y - center.y) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; } } else if (axis * base_axis_y >= angle_epsilon) { FindMeshCenter(mesh, center, min, max); const ai_real diff = max.y - min.y; // just the same ... for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D& pos = mesh->mVertices[pnt]; aiVector3D& uv = out[pnt]; uv.y = (pos.y - min.y) / diff; uv.x = (atan2 ( pos.x - center.x, pos.z - center.z) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; } } else if (axis * base_axis_z >= angle_epsilon) { FindMeshCenter(mesh, center, min, max); const ai_real diff = max.z - min.z; // just the same ... for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D& pos = mesh->mVertices[pnt]; aiVector3D& uv = out[pnt]; uv.y = (pos.z - min.z) / diff; uv.x = (atan2 ( pos.y - center.y, pos.x - center.x) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; } } // slower code path in case the mapping axis is not one of the coordinate system axes else { aiMatrix4x4 mTrafo; aiMatrix4x4::FromToMatrix(axis,base_axis_y,mTrafo); FindMeshCenterTransformed(mesh, center, min, max,mTrafo); const ai_real diff = max.y - min.y; // again the same, except we're applying a transformation now for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt){ const aiVector3D pos = mTrafo* mesh->mVertices[pnt]; aiVector3D& uv = out[pnt]; uv.y = (pos.y - min.y) / diff; uv.x = (atan2 ( pos.x - center.x, pos.z - center.z) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; } } // Now find and remove UV seams. A seam occurs if a face has a tcoord // close to zero on the one side, and a tcoord close to one on the // other side. RemoveUVSeams(mesh,out); } // ------------------------------------------------------------------------------------------------ void ComputeUVMappingProcess::ComputePlaneMapping(aiMesh* mesh,const aiVector3D& axis, aiVector3D* out) { ai_real diffu,diffv; aiVector3D center, min, max; // If the axis is one of x,y,z run a faster code path. It's worth the extra effort ... // currently the mapping axis will always be one of x,y,z, except if the // PretransformVertices step is used (it transforms the meshes into worldspace, // thus changing the mapping axis) if (axis * base_axis_x >= angle_epsilon) { FindMeshCenter(mesh, center, min, max); diffu = max.z - min.z; diffv = max.y - min.y; for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D& pos = mesh->mVertices[pnt]; out[pnt].Set((pos.z - min.z) / diffu,(pos.y - min.y) / diffv,0.0); } } else if (axis * base_axis_y >= angle_epsilon) { FindMeshCenter(mesh, center, min, max); diffu = max.x - min.x; diffv = max.z - min.z; for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D& pos = mesh->mVertices[pnt]; out[pnt].Set((pos.x - min.x) / diffu,(pos.z - min.z) / diffv,0.0); } } else if (axis * base_axis_z >= angle_epsilon) { FindMeshCenter(mesh, center, min, max); diffu = max.y - min.y; diffv = max.z - min.z; for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D& pos = mesh->mVertices[pnt]; out[pnt].Set((pos.y - min.y) / diffu,(pos.x - min.x) / diffv,0.0); } } // slower code path in case the mapping axis is not one of the coordinate system axes else { aiMatrix4x4 mTrafo; aiMatrix4x4::FromToMatrix(axis,base_axis_y,mTrafo); FindMeshCenterTransformed(mesh, center, min, max,mTrafo); diffu = max.x - min.x; diffv = max.z - min.z; // again the same, except we're applying a transformation now for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D pos = mTrafo * mesh->mVertices[pnt]; out[pnt].Set((pos.x - min.x) / diffu,(pos.z - min.z) / diffv,0.0); } } // shouldn't be necessary to remove UV seams ... } // ------------------------------------------------------------------------------------------------ void ComputeUVMappingProcess::ComputeBoxMapping( aiMesh*, aiVector3D* ) { DefaultLogger::get()->error("Mapping type currently not implemented"); } // ------------------------------------------------------------------------------------------------ void ComputeUVMappingProcess::Execute( aiScene* pScene) { DefaultLogger::get()->debug("GenUVCoordsProcess begin"); char buffer[1024]; if (pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) throw DeadlyImportError("Post-processing order mismatch: expecting pseudo-indexed (\"verbose\") vertices here"); std::list<MappingInfo> mappingStack; /* Iterate through all materials and search for non-UV mapped textures */ for (unsigned int i = 0; i < pScene->mNumMaterials;++i) { mappingStack.clear(); aiMaterial* mat = pScene->mMaterials[i]; for (unsigned int a = 0; a < mat->mNumProperties;++a) { aiMaterialProperty* prop = mat->mProperties[a]; if (!::strcmp( prop->mKey.data, "$tex.mapping")) { aiTextureMapping& mapping = *((aiTextureMapping*)prop->mData); if (aiTextureMapping_UV != mapping) { if (!DefaultLogger::isNullLogger()) { ai_snprintf(buffer, 1024, "Found non-UV mapped texture (%s,%u). Mapping type: %s", TextureTypeToString((aiTextureType)prop->mSemantic),prop->mIndex, MappingTypeToString(mapping)); DefaultLogger::get()->info(buffer); } if (aiTextureMapping_OTHER == mapping) continue; MappingInfo info (mapping); // Get further properties - currently only the major axis for (unsigned int a2 = 0; a2 < mat->mNumProperties;++a2) { aiMaterialProperty* prop2 = mat->mProperties[a2]; if (prop2->mSemantic != prop->mSemantic || prop2->mIndex != prop->mIndex) continue; if ( !::strcmp( prop2->mKey.data, "$tex.mapaxis")) { info.axis = *((aiVector3D*)prop2->mData); break; } } unsigned int idx; // Check whether we have this mapping mode already std::list<MappingInfo>::iterator it = std::find (mappingStack.begin(),mappingStack.end(), info); if (mappingStack.end() != it) { idx = (*it).uv; } else { /* We have found a non-UV mapped texture. Now * we need to find all meshes using this material * that we can compute UV channels for them. */ for (unsigned int m = 0; m < pScene->mNumMeshes;++m) { aiMesh* mesh = pScene->mMeshes[m]; unsigned int outIdx = 0; if ( mesh->mMaterialIndex != i || ( outIdx = FindEmptyUVChannel(mesh) ) == UINT_MAX || !mesh->mNumVertices) { continue; } // Allocate output storage aiVector3D* p = mesh->mTextureCoords[outIdx] = new aiVector3D[mesh->mNumVertices]; switch (mapping) { case aiTextureMapping_SPHERE: ComputeSphereMapping(mesh,info.axis,p); break; case aiTextureMapping_CYLINDER: ComputeCylinderMapping(mesh,info.axis,p); break; case aiTextureMapping_PLANE: ComputePlaneMapping(mesh,info.axis,p); break; case aiTextureMapping_BOX: ComputeBoxMapping(mesh,p); break; default: ai_assert(false); } if (m && idx != outIdx) { DefaultLogger::get()->warn("UV index mismatch. Not all meshes assigned to " "this material have equal numbers of UV channels. The UV index stored in " "the material structure does therefore not apply for all meshes. "); } idx = outIdx; } info.uv = idx; mappingStack.push_back(info); } // Update the material property list mapping = aiTextureMapping_UV; ((aiMaterial*)mat)->AddProperty(&idx,1,AI_MATKEY_UVWSRC(prop->mSemantic,prop->mIndex)); } } } } DefaultLogger::get()->debug("GenUVCoordsProcess finished"); }
42.508911
120
0.532026
RCGamer21
33a7bb186eb03cb7a7360dc6d49ac69078089216
3,126
cpp
C++
source/Core/AddressResolverFileLine.cpp
xiaobai/swift-lldb
9238527ce430e6837108a16d2a91b147551fb83c
[ "Apache-2.0" ]
765
2015-12-03T16:44:59.000Z
2022-03-07T12:41:10.000Z
source/Core/AddressResolverFileLine.cpp
xiaobai/swift-lldb
9238527ce430e6837108a16d2a91b147551fb83c
[ "Apache-2.0" ]
1,815
2015-12-11T23:56:05.000Z
2020-01-10T19:28:43.000Z
source/Core/AddressResolverFileLine.cpp
xiaobai/swift-lldb
9238527ce430e6837108a16d2a91b147551fb83c
[ "Apache-2.0" ]
284
2015-12-03T16:47:25.000Z
2022-03-12T05:39:48.000Z
//===-- AddressResolverFileLine.cpp -----------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/Core/AddressResolverFileLine.h" #include "lldb/Core/Address.h" #include "lldb/Core/AddressRange.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Logging.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-types.h" #include <inttypes.h> #include <vector> using namespace lldb; using namespace lldb_private; // AddressResolverFileLine: AddressResolverFileLine::AddressResolverFileLine(const FileSpec &file_spec, uint32_t line_no, bool check_inlines) : AddressResolver(), m_file_spec(file_spec), m_line_number(line_no), m_inlines(check_inlines) {} AddressResolverFileLine::~AddressResolverFileLine() {} Searcher::CallbackReturn AddressResolverFileLine::SearchCallback(SearchFilter &filter, SymbolContext &context, Address *addr, bool containing) { SymbolContextList sc_list; uint32_t sc_list_size; CompileUnit *cu = context.comp_unit; Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); sc_list_size = cu->ResolveSymbolContext(m_file_spec, m_line_number, m_inlines, false, eSymbolContextEverything, sc_list); for (uint32_t i = 0; i < sc_list_size; i++) { SymbolContext sc; if (sc_list.GetContextAtIndex(i, sc)) { Address line_start = sc.line_entry.range.GetBaseAddress(); addr_t byte_size = sc.line_entry.range.GetByteSize(); if (line_start.IsValid()) { AddressRange new_range(line_start, byte_size); m_address_ranges.push_back(new_range); if (log) { StreamString s; // new_bp_loc->GetDescription (&s, lldb::eDescriptionLevelVerbose); // LLDB_LOGF(log, "Added address: %s\n", s.GetData()); } } else { LLDB_LOGF(log, "error: Unable to resolve address at file address 0x%" PRIx64 " for %s:%d\n", line_start.GetFileAddress(), m_file_spec.GetFilename().AsCString("<Unknown>"), m_line_number); } } } return Searcher::eCallbackReturnContinue; } lldb::SearchDepth AddressResolverFileLine::GetDepth() { return lldb::eSearchDepthCompUnit; } void AddressResolverFileLine::GetDescription(Stream *s) { s->Printf("File and line address - file: \"%s\" line: %u", m_file_spec.GetFilename().AsCString("<Unknown>"), m_line_number); }
36.348837
80
0.631798
xiaobai
33a81c2af4a95b2a563fb7c3d993bbd10e9e2c52
6,236
cpp
C++
libs/StateSync-pinvoke-cpp/src/ReplicatedState-pinvoke.cpp
ivte-ms/MixedReality-Sharing
edb38467be6dcd09447962a3c1f998fe700b8832
[ "MIT" ]
24
2019-12-11T18:56:39.000Z
2021-12-28T02:48:59.000Z
libs/StateSync-pinvoke-cpp/src/ReplicatedState-pinvoke.cpp
ivte-ms/MixedReality-Sharing
edb38467be6dcd09447962a3c1f998fe700b8832
[ "MIT" ]
23
2019-12-11T20:21:30.000Z
2020-02-12T12:12:05.000Z
libs/StateSync-pinvoke-cpp/src/ReplicatedState-pinvoke.cpp
ivte-ms/MixedReality-Sharing
edb38467be6dcd09447962a3c1f998fe700b8832
[ "MIT" ]
14
2019-12-11T18:56:44.000Z
2021-06-09T18:13:10.000Z
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. #include "src/pch.h" #include <Microsoft/MixedReality/Sharing/StateSync/NetworkConnection.h> #include <Microsoft/MixedReality/Sharing/StateSync/NetworkListener.h> #include <Microsoft/MixedReality/Sharing/StateSync/NetworkManager.h> #include <Microsoft/MixedReality/Sharing/StateSync/ReplicatedState.h> #include <Microsoft/MixedReality/Sharing/StateSync/export.h> #include <Microsoft/MixedReality/Sharing/Common/bit_cast.h> using namespace Microsoft::MixedReality::Sharing; using namespace Microsoft::MixedReality::Sharing::StateSync; namespace { class PInvokeNetworkManager; using ReleaseGCHandleDelegate = void(__stdcall*)(intptr_t gc_handle); using GetConnectionDelegate = void(__stdcall*)(intptr_t connection_string_blob, intptr_t manager_gc_handle, PInvokeNetworkManager* pinvoke_network_manager, std::shared_ptr<NetworkConnection>* result_location); using PollMessageDelegate = bool(__stdcall*)(intptr_t manager_gc_handle, void* listener); using SendMessageDelegate = intptr_t(__stdcall*)(intptr_t connection_gc_handle, const char* message_begin, int message_size); class PInvokeNetworkManager : public NetworkManager { public: PInvokeNetworkManager(intptr_t manager_gc_handle, ReleaseGCHandleDelegate release_gc_handle_delegate, GetConnectionDelegate get_connection_delegate, PollMessageDelegate poll_message_delegate, SendMessageDelegate send_message_delegate) : manager_gc_handle_{manager_gc_handle}, release_gc_handle_delegate_{release_gc_handle_delegate}, get_connection_delegate_{get_connection_delegate}, poll_message_delegate_{poll_message_delegate}, send_message_delegate_{send_message_delegate} {} ~PInvokeNetworkManager() noexcept override { release_gc_handle_delegate_(manager_gc_handle_); } std::shared_ptr<NetworkConnection> GetConnection( const InternedBlob& connection_string) override; bool PollMessage(NetworkListener& listener) override { return poll_message_delegate_(manager_gc_handle_, &listener); } std::shared_ptr<NetworkConnection> CreateConnectionWrapper( const InternedBlob& connection_string, intptr_t connection_handle) { return std::make_shared<Connection>(&connection_string, this, connection_handle); } private: class Connection : public NetworkConnection { public: Connection(RefPtr<const InternedBlob> connection_string, RefPtr<PInvokeNetworkManager> manager, intptr_t connection_handle); ~Connection() noexcept override; void SendMessage(std::string_view message) override; private: RefPtr<PInvokeNetworkManager> manager_; intptr_t connection_handle_; }; intptr_t manager_gc_handle_; ReleaseGCHandleDelegate release_gc_handle_delegate_; GetConnectionDelegate get_connection_delegate_; PollMessageDelegate poll_message_delegate_; SendMessageDelegate send_message_delegate_; }; std::shared_ptr<NetworkConnection> PInvokeNetworkManager::GetConnection( const InternedBlob& connection_string) { std::shared_ptr<NetworkConnection> result; get_connection_delegate_(bit_cast<intptr_t>(&connection_string), manager_gc_handle_, this, &result); return result; } PInvokeNetworkManager::Connection::Connection( RefPtr<const InternedBlob> connection_string, RefPtr<PInvokeNetworkManager> manager, intptr_t connection_handle) : NetworkConnection{std::move(connection_string)}, manager_{std::move(manager)}, connection_handle_{connection_handle} {} PInvokeNetworkManager::Connection::~Connection() noexcept { manager_->release_gc_handle_delegate_(connection_handle_); } void PInvokeNetworkManager::Connection::SendMessage(std::string_view message) { if (message.size() > std::numeric_limits<int>::max()) { throw std::invalid_argument{ "The message is too large to be marshaled to C#"}; } manager_->send_message_delegate_(connection_handle_, message.data(), static_cast<int>(message.size())); } } // namespace extern "C" { MS_MR_SHARING_STATESYNC_API intptr_t MS_MR_CALL Microsoft_MixedReality_Sharing_StateSync_CppNetworkConnectionWeakPtr_Create() noexcept { return bit_cast<intptr_t>(new std::weak_ptr<NetworkConnection>); } MS_MR_SHARING_STATESYNC_API void MS_MR_CALL Microsoft_MixedReality_Sharing_StateSync_CppNetworkConnectionWeakPtr_Destroy( intptr_t weak_ptr_handle) noexcept { auto* wptr = bit_cast<std::weak_ptr<NetworkConnection>*>(weak_ptr_handle); delete wptr; } MS_MR_SHARING_STATESYNC_API bool MS_MR_CALL Microsoft_MixedReality_Sharing_StateSync_CppNetworkConnectionWeakPtr_Lock( intptr_t weak_ptr_handle, std::shared_ptr<NetworkConnection>* result) noexcept { auto* wptr = bit_cast<std::weak_ptr<NetworkConnection>*>(weak_ptr_handle); *result = wptr->lock(); return result; } MS_MR_SHARING_STATESYNC_API void MS_MR_CALL Microsoft_MixedReality_Sharing_StateSync_CppNetworkConnectionWeakPtr_Update( intptr_t weak_ptr_handle, PInvokeNetworkManager* manager, intptr_t connection_string_blob, intptr_t connecton_gc_handle, std::shared_ptr<NetworkConnection>* result) noexcept { *result = manager->CreateConnectionWrapper( *bit_cast<const InternedBlob*>(connection_string_blob), connecton_gc_handle); auto* wptr = bit_cast<std::weak_ptr<NetworkConnection>*>(weak_ptr_handle); *wptr = *result; // Updating the cache. } MS_MR_SHARING_STATESYNC_API void MS_MR_CALL Microsoft_MixedReality_Sharing_StateSync_NetworkListener_OnMessage( NetworkListener* listener, intptr_t sender, const char* messageBegin, int messageSize) noexcept { std::string_view message{messageBegin, static_cast<size_t>(messageSize)}; listener->OnMessage(*bit_cast<const InternedBlob*>(sender), message); } } // extern "C"
37.119048
88
0.747915
ivte-ms
33a8b6d7bde33154b777c11f6be691b84d5f1873
23,824
cc
C++
chrome/browser/safe_browsing/safe_browsing_test.cc
robclark/chromium
f097b6ea775c27e5352c94ddddd264dd2af21479
[ "BSD-3-Clause" ]
1
2019-07-22T23:03:26.000Z
2019-07-22T23:03:26.000Z
chrome/browser/safe_browsing/safe_browsing_test.cc
robclark/chromium
f097b6ea775c27e5352c94ddddd264dd2af21479
[ "BSD-3-Clause" ]
null
null
null
chrome/browser/safe_browsing/safe_browsing_test.cc
robclark/chromium
f097b6ea775c27e5352c94ddddd264dd2af21479
[ "BSD-3-Clause" ]
null
null
null
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // This test uses the safebrowsing test server published at // http://code.google.com/p/google-safe-browsing/ to test the safebrowsing // protocol implemetation. Details of the safebrowsing testing flow is // documented at // http://code.google.com/p/google-safe-browsing/wiki/ProtocolTesting // // This test launches safebrowsing test server and issues several update // requests against that server. Each update would get different data and after // each update, the test will get a list of URLs from the test server to verify // its repository. The test will succeed only if all updates are performed and // URLs match what the server expected. #include <vector> #include "base/bind.h" #include "base/command_line.h" #include "base/environment.h" #include "base/path_service.h" #include "base/process_util.h" #include "base/string_number_conversions.h" #include "base/string_split.h" #include "base/stringprintf.h" #include "base/synchronization/lock.h" #include "base/test/test_timeouts.h" #include "base/threading/platform_thread.h" #include "base/threading/thread.h" #include "base/time.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/safe_browsing/protocol_manager.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/browser_context.h" #include "content/public/common/url_fetcher.h" #include "content/public/common/url_fetcher_delegate.h" #include "content/test/test_browser_thread.h" #include "net/base/host_resolver.h" #include "net/base/load_flags.h" #include "net/base/net_log.h" #include "net/test/python_utils.h" #include "net/url_request/url_request_status.h" #include "testing/gtest/include/gtest/gtest.h" using content::BrowserThread; namespace { const FilePath::CharType kDataFile[] = FILE_PATH_LITERAL("testing_input_nomac.dat"); const char kUrlVerifyPath[] = "/safebrowsing/verify_urls"; const char kDBVerifyPath[] = "/safebrowsing/verify_database"; const char kDBResetPath[] = "/reset"; const char kTestCompletePath[] = "/test_complete"; struct PhishingUrl { std::string url; std::string list_name; bool is_phishing; }; // Parses server response for verify_urls. The expected format is: // // first.random.url.com/ internal-test-shavar yes // second.random.url.com/ internal-test-shavar yes // ... bool ParsePhishingUrls(const std::string& data, std::vector<PhishingUrl>* phishing_urls) { if (data.empty()) return false; std::vector<std::string> urls; base::SplitString(data, '\n', &urls); for (size_t i = 0; i < urls.size(); ++i) { if (urls[i].empty()) continue; PhishingUrl phishing_url; std::vector<std::string> record_parts; base::SplitString(urls[i], '\t', &record_parts); if (record_parts.size() != 3) { LOG(ERROR) << "Unexpected URL format in phishing URL list: " << urls[i]; return false; } phishing_url.url = std::string(chrome::kHttpScheme) + "://" + record_parts[0]; phishing_url.list_name = record_parts[1]; if (record_parts[2] == "yes") { phishing_url.is_phishing = true; } else if (record_parts[2] == "no") { phishing_url.is_phishing = false; } else { LOG(ERROR) << "Unrecognized expectation in " << urls[i] << ": " << record_parts[2]; return false; } phishing_urls->push_back(phishing_url); } return true; } } // namespace class SafeBrowsingTestServer { public: explicit SafeBrowsingTestServer(const FilePath& datafile) : datafile_(datafile), server_handle_(base::kNullProcessHandle) { } ~SafeBrowsingTestServer() { EXPECT_EQ(base::kNullProcessHandle, server_handle_); } // Start the python server test suite. bool Start() { // Get path to python server script FilePath testserver_path; if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_path)) { LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; return false; } testserver_path = testserver_path .Append(FILE_PATH_LITERAL("third_party")) .Append(FILE_PATH_LITERAL("safe_browsing")) .Append(FILE_PATH_LITERAL("testing")); AppendToPythonPath(testserver_path); FilePath testserver = testserver_path.Append( FILE_PATH_LITERAL("safebrowsing_test_server.py")); FilePath pyproto_code_dir; if (!GetPyProtoPath(&pyproto_code_dir)) { LOG(ERROR) << "Failed to get generated python protobuf dir"; return false; } AppendToPythonPath(pyproto_code_dir); pyproto_code_dir = pyproto_code_dir.Append(FILE_PATH_LITERAL("google")); AppendToPythonPath(pyproto_code_dir); FilePath python_runtime; EXPECT_TRUE(GetPythonRunTime(&python_runtime)); CommandLine cmd_line(python_runtime); // Make python stdout and stderr unbuffered, to prevent incomplete stderr on // win bots, and also fix mixed up ordering of stdout and stderr. cmd_line.AppendSwitch("-u"); FilePath datafile = testserver_path.Append(datafile_); cmd_line.AppendArgPath(testserver); cmd_line.AppendArg(base::StringPrintf("--port=%d", kPort_)); cmd_line.AppendArgNative(FILE_PATH_LITERAL("--datafile=") + datafile.value()); base::LaunchOptions options; #if defined(OS_WIN) options.start_hidden = true; #endif if (!base::LaunchProcess(cmd_line, options, &server_handle_)) { LOG(ERROR) << "Failed to launch server: " << cmd_line.GetCommandLineString(); return false; } return true; } // Stop the python server test suite. bool Stop() { if (server_handle_ == base::kNullProcessHandle) return true; // First check if the process has already terminated. if (!base::WaitForSingleProcess(server_handle_, 0) && !base::KillProcess(server_handle_, 1, true)) { VLOG(1) << "Kill failed?"; return false; } base::CloseProcessHandle(server_handle_); server_handle_ = base::kNullProcessHandle; VLOG(1) << "Stopped."; return true; } static const char* Host() { return kHost_; } static int Port() { return kPort_; } private: static const char kHost_[]; static const int kPort_; FilePath datafile_; base::ProcessHandle server_handle_; DISALLOW_COPY_AND_ASSIGN(SafeBrowsingTestServer); }; const char SafeBrowsingTestServer::kHost_[] = "localhost"; const int SafeBrowsingTestServer::kPort_ = 40102; // This starts the browser and keeps status of states related to SafeBrowsing. class SafeBrowsingServiceTest : public InProcessBrowserTest { public: SafeBrowsingServiceTest() : safe_browsing_service_(NULL), is_database_ready_(true), is_update_scheduled_(false), is_checked_url_in_db_(false), is_checked_url_safe_(false) { } virtual ~SafeBrowsingServiceTest() { } void UpdateSafeBrowsingStatus() { ASSERT_TRUE(safe_browsing_service_); base::AutoLock lock(update_status_mutex_); last_update_ = safe_browsing_service_->protocol_manager_->last_update(); is_update_scheduled_ = safe_browsing_service_->protocol_manager_->update_timer_.IsRunning(); } void ForceUpdate() { ASSERT_TRUE(safe_browsing_service_); safe_browsing_service_->protocol_manager_->ForceScheduleNextUpdate(0); } void CheckIsDatabaseReady() { base::AutoLock lock(update_status_mutex_); is_database_ready_ = !safe_browsing_service_->database_update_in_progress_; } void CheckUrl(SafeBrowsingService::Client* helper, const GURL& url) { ASSERT_TRUE(safe_browsing_service_); base::AutoLock lock(update_status_mutex_); if (safe_browsing_service_->CheckBrowseUrl(url, helper)) { is_checked_url_in_db_ = false; is_checked_url_safe_ = true; } else { // In this case, Safebrowsing service will fetch the full hash // from the server and examine that. Once it is done, // set_is_checked_url_safe() will be called via callback. is_checked_url_in_db_ = true; } } bool is_checked_url_in_db() { base::AutoLock l(update_status_mutex_); return is_checked_url_in_db_; } void set_is_checked_url_safe(bool safe) { base::AutoLock l(update_status_mutex_); is_checked_url_safe_ = safe; } bool is_checked_url_safe() { base::AutoLock l(update_status_mutex_); return is_checked_url_safe_; } bool is_database_ready() { base::AutoLock l(update_status_mutex_); return is_database_ready_; } base::Time last_update() { base::AutoLock l(update_status_mutex_); return last_update_; } bool is_update_scheduled() { base::AutoLock l(update_status_mutex_); return is_update_scheduled_; } MessageLoop* SafeBrowsingMessageLoop() { return safe_browsing_service_->safe_browsing_thread_->message_loop(); } protected: bool InitSafeBrowsingService() { safe_browsing_service_ = g_browser_process->safe_browsing_service(); return safe_browsing_service_ != NULL; } virtual void SetUpCommandLine(CommandLine* command_line) { // Makes sure the auto update is not triggered. This test will force the // update when needed. command_line->AppendSwitch(switches::kSbDisableAutoUpdate); // This test uses loopback. No need to use IPv6 especially it makes // local requests slow on Windows trybot when ipv6 local address [::1] // is not setup. command_line->AppendSwitch(switches::kDisableIPv6); // TODO(lzheng): The test server does not understand download related // requests. We need to fix the server. command_line->AppendSwitch(switches::kSbDisableDownloadProtection); // TODO(gcasto): Generate new testing data that includes the // client-side phishing whitelist. command_line->AppendSwitch( switches::kDisableClientSidePhishingDetection); // Point to the testing server for all SafeBrowsing requests. std::string url_prefix = base::StringPrintf("http://%s:%d/safebrowsing", SafeBrowsingTestServer::Host(), SafeBrowsingTestServer::Port()); command_line->AppendSwitchASCII(switches::kSbURLPrefix, url_prefix); } void SetTestStep(int step) { std::string test_step = base::StringPrintf("test_step=%d", step); safe_browsing_service_->protocol_manager_->set_additional_query(test_step); } private: SafeBrowsingService* safe_browsing_service_; // Protects all variables below since they are read on UI thread // but updated on IO thread or safebrowsing thread. base::Lock update_status_mutex_; // States associated with safebrowsing service updates. bool is_database_ready_; base::Time last_update_; bool is_update_scheduled_; // Indicates if there is a match between a URL's prefix and safebrowsing // database (thus potentially it is a phishing URL). bool is_checked_url_in_db_; // True if last verified URL is not a phishing URL and thus it is safe. bool is_checked_url_safe_; DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceTest); }; // A ref counted helper class that handles callbacks between IO thread and UI // thread. class SafeBrowsingServiceTestHelper : public base::RefCountedThreadSafe<SafeBrowsingServiceTestHelper>, public SafeBrowsingService::Client, public content::URLFetcherDelegate { public: SafeBrowsingServiceTestHelper(SafeBrowsingServiceTest* safe_browsing_test, net::URLRequestContextGetter* request_context) : safe_browsing_test_(safe_browsing_test), response_status_(net::URLRequestStatus::FAILED), request_context_(request_context) { } // Callbacks for SafeBrowsingService::Client. virtual void OnBrowseUrlCheckResult( const GURL& url, SafeBrowsingService::UrlCheckResult result) { EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); EXPECT_TRUE(safe_browsing_test_->is_checked_url_in_db()); safe_browsing_test_->set_is_checked_url_safe( result == SafeBrowsingService::SAFE); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(&SafeBrowsingServiceTestHelper::OnCheckUrlDone, this)); } virtual void OnDownloadUrlCheckResult( const std::vector<GURL>& url_chain, SafeBrowsingService::UrlCheckResult result) { // TODO(lzheng): Add test for DownloadUrl. } virtual void OnBlockingPageComplete(bool proceed) { NOTREACHED() << "Not implemented."; } // Functions and callbacks to start the safebrowsing database update. void ForceUpdate() { BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(&SafeBrowsingServiceTestHelper::ForceUpdateInIOThread, this)); // Will continue after OnForceUpdateDone(). ui_test_utils::RunMessageLoop(); } void ForceUpdateInIOThread() { EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); safe_browsing_test_->ForceUpdate(); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(&SafeBrowsingServiceTestHelper::OnForceUpdateDone, this)); } void OnForceUpdateDone() { StopUILoop(); } // Functions and callbacks related to CheckUrl. These are used to verify // phishing URLs. void CheckUrl(const GURL& url) { BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(&SafeBrowsingServiceTestHelper::CheckUrlOnIOThread, this, url)); ui_test_utils::RunMessageLoop(); } void CheckUrlOnIOThread(const GURL& url) { EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); safe_browsing_test_->CheckUrl(this, url); if (!safe_browsing_test_->is_checked_url_in_db()) { // Ends the checking since this URL's prefix is not in database. BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(&SafeBrowsingServiceTestHelper::OnCheckUrlDone, this)); } // Otherwise, OnCheckUrlDone is called in OnUrlCheckResult since // safebrowsing service further fetches hashes from safebrowsing server. } void OnCheckUrlDone() { StopUILoop(); } // Updates status from IO Thread. void CheckStatusOnIOThread() { EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); safe_browsing_test_->UpdateSafeBrowsingStatus(); safe_browsing_test_->SafeBrowsingMessageLoop()->PostTask(FROM_HERE, base::Bind(&SafeBrowsingServiceTestHelper::CheckIsDatabaseReady, this)); } // Checks status in SafeBrowsing Thread. void CheckIsDatabaseReady() { EXPECT_EQ(MessageLoop::current(), safe_browsing_test_->SafeBrowsingMessageLoop()); safe_browsing_test_->CheckIsDatabaseReady(); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(&SafeBrowsingServiceTestHelper::OnWaitForStatusUpdateDone, this)); } void OnWaitForStatusUpdateDone() { StopUILoop(); } // Wait for a given period to get safebrowsing status updated. void WaitForStatusUpdate(int64 wait_time_msec) { BrowserThread::PostDelayedTask( BrowserThread::IO, FROM_HERE, base::Bind(&SafeBrowsingServiceTestHelper::CheckStatusOnIOThread, this), base::TimeDelta::FromMilliseconds(wait_time_msec)); // Will continue after OnWaitForStatusUpdateDone(). ui_test_utils::RunMessageLoop(); } void WaitTillServerReady(const char* host, int port) { response_status_ = net::URLRequestStatus::FAILED; GURL url(base::StringPrintf("http://%s:%d%s?test_step=0", host, port, kDBResetPath)); // TODO(lzheng): We should have a way to reliably tell when a server is // ready so we could get rid of the Sleep and retry loop. while (true) { if (FetchUrl(url) == net::URLRequestStatus::SUCCESS) break; // Wait and try again if last fetch was failed. The loop will hit the // timeout in OutOfProcTestRunner if the fetch can not get success // response. base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); } } // Calls test server to fetch database for verification. net::URLRequestStatus::Status FetchDBToVerify(const char* host, int port, int test_step) { // TODO(lzheng): Remove chunk_type=add once it is not needed by the server. GURL url(base::StringPrintf( "http://%s:%d%s?" "client=chromium&appver=1.0&pver=2.2&test_step=%d&" "chunk_type=add", host, port, kDBVerifyPath, test_step)); return FetchUrl(url); } // Calls test server to fetch URLs for verification. net::URLRequestStatus::Status FetchUrlsToVerify(const char* host, int port, int test_step) { GURL url(base::StringPrintf( "http://%s:%d%s?" "client=chromium&appver=1.0&pver=2.2&test_step=%d", host, port, kUrlVerifyPath, test_step)); return FetchUrl(url); } // Calls test server to check if test data is done. E.g.: if there is a // bad URL that server expects test to fetch full hash but the test didn't, // this verification will fail. net::URLRequestStatus::Status VerifyTestComplete(const char* host, int port, int test_step) { GURL url(StringPrintf("http://%s:%d%s?test_step=%d", host, port, kTestCompletePath, test_step)); return FetchUrl(url); } // Callback for URLFetcher. virtual void OnURLFetchComplete(const net::URLFetcher* source) { source->GetResponseAsString(&response_data_); response_status_ = source->GetStatus().status(); StopUILoop(); } const std::string& response_data() { return response_data_; } private: friend class base::RefCountedThreadSafe<SafeBrowsingServiceTestHelper>; virtual ~SafeBrowsingServiceTestHelper() {} // Stops UI loop after desired status is updated. void StopUILoop() { EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); MessageLoopForUI::current()->Quit(); } // Fetch a URL. If message_loop_started is true, starts the message loop // so the caller could wait till OnURLFetchComplete is called. net::URLRequestStatus::Status FetchUrl(const GURL& url) { url_fetcher_.reset(content::URLFetcher::Create( url, content::URLFetcher::GET, this)); url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); url_fetcher_->SetRequestContext(request_context_); url_fetcher_->Start(); ui_test_utils::RunMessageLoop(); return response_status_; } base::OneShotTimer<SafeBrowsingServiceTestHelper> check_update_timer_; SafeBrowsingServiceTest* safe_browsing_test_; scoped_ptr<content::URLFetcher> url_fetcher_; std::string response_data_; net::URLRequestStatus::Status response_status_; net::URLRequestContextGetter* request_context_; DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceTestHelper); }; // See http://crbug.com/96459 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, DISABLED_SafeBrowsingSystemTest) { LOG(INFO) << "Start test"; const char* server_host = SafeBrowsingTestServer::Host(); int server_port = SafeBrowsingTestServer::Port(); ASSERT_TRUE(InitSafeBrowsingService()); net::URLRequestContextGetter* request_context = GetBrowserContext()->GetRequestContext(); scoped_refptr<SafeBrowsingServiceTestHelper> safe_browsing_helper( new SafeBrowsingServiceTestHelper(this, request_context)); int last_step = 0; FilePath datafile_path = FilePath(kDataFile); SafeBrowsingTestServer test_server(datafile_path); ASSERT_TRUE(test_server.Start()); // Make sure the server is running. safe_browsing_helper->WaitTillServerReady(server_host, server_port); // Waits and makes sure safebrowsing update is not happening. // The wait will stop once OnWaitForStatusUpdateDone in // safe_browsing_helper is called and status from safe_browsing_service_ // is checked. safe_browsing_helper->WaitForStatusUpdate(0); EXPECT_TRUE(is_database_ready()); EXPECT_FALSE(is_update_scheduled()); EXPECT_TRUE(last_update().is_null()); // Starts updates. After each update, the test will fetch a list of URLs with // expected results to verify with safebrowsing service. If there is no error, // the test moves on to the next step to get more update chunks. // This repeats till there is no update data. for (int step = 1;; step++) { // Every step should be a fresh start. SCOPED_TRACE(base::StringPrintf("step=%d", step)); EXPECT_TRUE(is_database_ready()); EXPECT_FALSE(is_update_scheduled()); // Starts safebrowsing update on IO thread. Waits till scheduled // update finishes. Stops waiting after kMaxWaitSecPerStep if the update // could not finish. base::Time now = base::Time::Now(); SetTestStep(step); safe_browsing_helper->ForceUpdate(); do { // Periodically pull the status. safe_browsing_helper->WaitForStatusUpdate( TestTimeouts::tiny_timeout_ms()); } while (is_update_scheduled() || !is_database_ready()); if (last_update() < now) { // This means no data available anymore. break; } // Fetches URLs to verify and waits till server responses with data. EXPECT_EQ(net::URLRequestStatus::SUCCESS, safe_browsing_helper->FetchUrlsToVerify(server_host, server_port, step)); std::vector<PhishingUrl> phishing_urls; EXPECT_TRUE(ParsePhishingUrls(safe_browsing_helper->response_data(), &phishing_urls)); EXPECT_GT(phishing_urls.size(), 0U); for (size_t j = 0; j < phishing_urls.size(); ++j) { // Verifes with server if a URL is a phishing URL and waits till server // responses. safe_browsing_helper->CheckUrl(GURL(phishing_urls[j].url)); if (phishing_urls[j].is_phishing) { EXPECT_TRUE(is_checked_url_in_db()) << phishing_urls[j].url << " is_phishing: " << phishing_urls[j].is_phishing << " test step: " << step; EXPECT_FALSE(is_checked_url_safe()) << phishing_urls[j].url << " is_phishing: " << phishing_urls[j].is_phishing << " test step: " << step; } else { EXPECT_TRUE(is_checked_url_safe()) << phishing_urls[j].url << " is_phishing: " << phishing_urls[j].is_phishing << " test step: " << step; } } // TODO(lzheng): We should verify the fetched database with local // database to make sure they match. EXPECT_EQ(net::URLRequestStatus::SUCCESS, safe_browsing_helper->FetchDBToVerify(server_host, server_port, step)); EXPECT_GT(safe_browsing_helper->response_data().size(), 0U); last_step = step; } // Verifies with server if test is done and waits till server responses. EXPECT_EQ(net::URLRequestStatus::SUCCESS, safe_browsing_helper->VerifyTestComplete(server_host, server_port, last_step)); EXPECT_EQ("yes", safe_browsing_helper->response_data()); test_server.Stop(); }
36.428135
80
0.694384
robclark
33aa7913d2ba041c244e75a53cf72d2ae073a76e
3,385
cpp
C++
src/plugins/nacheku/directorywatcher.cpp
MellonQ/leechcraft
71cbb238d2dade56b3865278a6a8e6a58c217fc5
[ "BSL-1.0" ]
1
2017-01-12T07:05:45.000Z
2017-01-12T07:05:45.000Z
src/plugins/nacheku/directorywatcher.cpp
MellonQ/leechcraft
71cbb238d2dade56b3865278a6a8e6a58c217fc5
[ "BSL-1.0" ]
null
null
null
src/plugins/nacheku/directorywatcher.cpp
MellonQ/leechcraft
71cbb238d2dade56b3865278a6a8e6a58c217fc5
[ "BSL-1.0" ]
null
null
null
/********************************************************************** * LeechCraft - modular cross-platform feature rich internet client. * Copyright (C) 2006-2014 Georg Rudoy * * Boost Software License - Version 1.0 - August 17th, 2003 * * Permission is hereby granted, free of charge, to any person or organization * obtaining a copy of the software and accompanying documentation covered by * this license (the "Software") to use, reproduce, display, distribute, * execute, and transmit the Software, and to prepare derivative works of the * Software, and to permit third-parties to whom the Software is furnished to * do so, all subject to the following: * * The copyright notices in the Software and this entire statement, including * the above license grant, this restriction and the following disclaimer, * must be included in all copies of the Software, in whole or in part, and * all derivative works of the Software, unless such copies or derivative * works are solely in the form of machine-executable object code generated by * a source language processor. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. **********************************************************************/ #include "directorywatcher.h" #include <QDir> #include <QTimer> #include <QUrl> #include <util/xpc/util.h> #include "xmlsettingsmanager.h" namespace LeechCraft { namespace Nacheku { DirectoryWatcher::DirectoryWatcher (QObject *parent) : QObject (parent) , Watcher_ (new QFileSystemWatcher) { XmlSettingsManager::Instance ().RegisterObject ("WatchDirectory", this, "settingsChanged"); QTimer::singleShot (5000, this, SLOT (settingsChanged ())); connect (Watcher_.get (), SIGNAL (directoryChanged (const QString&)), this, SLOT (handleDirectoryChanged (const QString&)), Qt::QueuedConnection); } void DirectoryWatcher::settingsChanged () { const QString& path = XmlSettingsManager::Instance () .property ("WatchDirectory").toString (); const QStringList& dirs = Watcher_->directories (); if (dirs.size () == 1 && dirs.at (0) == path) return; if (!dirs.isEmpty ()) Watcher_->removePaths (dirs); if (!path.isEmpty ()) { QDir dir (path); Olds_ = dir.entryInfoList (QDir::Files); Watcher_->addPath (path); handleDirectoryChanged (path); } } void DirectoryWatcher::handleDirectoryChanged (const QString& path) { QDir dir (path); const auto& cur = dir.entryInfoList (QDir::Files); auto nl = cur; Q_FOREACH (const QFileInfo& oldFi, Olds_) { const QString& fname = oldFi.absoluteFilePath (); Q_FOREACH (const QFileInfo& newFi, nl) if (newFi.absoluteFilePath () == fname) { nl.removeOne (newFi); break; } } Olds_ = cur; Q_FOREACH (const QFileInfo& newFi, nl) emit gotEntity (Util::MakeEntity (QUrl::fromLocalFile (newFi.absoluteFilePath ()), path, FromUserInitiated)); } } }
31.055046
85
0.684195
MellonQ
33abe561f89c1c591a40feb8a2272c0547fb96f2
2,528
cpp
C++
src/client/particles/FireworkParticle.cpp
AzariasB/MultiPlayerPong
4b9af38198945b31b05ca83acadccef333e32284
[ "MIT" ]
null
null
null
src/client/particles/FireworkParticle.cpp
AzariasB/MultiPlayerPong
4b9af38198945b31b05ca83acadccef333e32284
[ "MIT" ]
null
null
null
src/client/particles/FireworkParticle.cpp
AzariasB/MultiPlayerPong
4b9af38198945b31b05ca83acadccef333e32284
[ "MIT" ]
null
null
null
/* * The MIT License * * Copyright 2017-2019 azarias. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ /* * File: Fireworkparticle.cpp * Author: azarias * * Created on 08/05/2019 */ #include "FireworkParticle.hpp" #include "src/client/Renderer.hpp" #include "src/common/Config.hpp" namespace mp { FireworkParticle::FireworkParticle(): Particle (this), m_line(sf::PrimitiveType::Lines, 2) { } const sf::Vector2f &FireworkParticle::getExplosionPosition() const { return m_target; } void FireworkParticle::init(const sf::Vector2f &target, const sf::Time &climbTime) { m_target = target; const sf::Time added = sf::milliseconds(static_cast<sf::Int32>(ARENA_HEIGHT - target.y)) * ARENA_HEIGHT; m_length = twin::makeTwin(10.f, 0.f, added + climbTime, twin::easing::quadIn); m_yPos = twin::makeTwin(ARENA_HEIGHT, target.y, added + climbTime, twin::easing::quadOut); m_line[0] = sf::Vertex(sf::Vector2f(m_target.x, ARENA_HEIGHT), sf::Color::White); m_line[1] = sf::Vertex(sf::Vector2f(m_target.x, ARENA_HEIGHT) , sf::Color::Transparent); } bool FireworkParticle::isFinished() const { return m_yPos.progress() == 1.f; } void FireworkParticle::render(Renderer &renderer) const { renderer.draw(m_line); } void FireworkParticle::update(const sf::Time &elapsed) { m_length.step(elapsed); m_yPos.step(elapsed); const float yPos = m_yPos.get(); m_line[0].position.y = yPos; m_line[1].position.y = yPos + m_length.get(); } }
30.095238
108
0.721915
AzariasB
33acac7974d9e7125b1d23005899f74f4db4c16f
2,616
cpp
C++
ls_base/malloc_hook.cpp
bbxionglei/LoveSnow
f6f4b73e9cc18817480cb53a08d936c0e0cc8029
[ "MIT" ]
3
2019-04-19T02:59:36.000Z
2019-10-16T05:55:28.000Z
ls_base/malloc_hook.cpp
bbxionglei/LoveSnow
f6f4b73e9cc18817480cb53a08d936c0e0cc8029
[ "MIT" ]
2
2019-11-11T04:28:42.000Z
2019-11-11T04:30:54.000Z
ls_base/malloc_hook.cpp
bbxionglei/LoveSnow
f6f4b73e9cc18817480cb53a08d936c0e0cc8029
[ "MIT" ]
null
null
null
#include <stdio.h> #include <string.h> #include <assert.h> #include <stdlib.h> #include <lua.hpp> #include <stdio.h> #include "malloc_hook.h" #include "ls.h" // turn on MEMORY_CHECK can do more memory check, such as double free // #define MEMORY_CHECK #define MEMORY_ALLOCTAG 0x20140605 #define MEMORY_FREETAG 0x0badf00d static size_t _used_memory = 0; static size_t _memory_block = 0; struct mem_data { uint32_t handle; size_t allocated; }; struct mem_cookie { uint32_t handle; }; #define SLOT_SIZE 0x10000 #define PREFIX_SIZE sizeof(struct mem_cookie) static struct mem_data mem_stats[SLOT_SIZE]; // for ls_lalloc use #define raw_realloc realloc #define raw_free free void memory_info_dump(void) { ls_error(NULL, "No jemalloc"); } size_t mallctl_int64(const char* name, size_t* newval) { ls_error(NULL, "No jemalloc : mallctl_int64 %s.", name); return 0; } int mallctl_opt(const char* name, int* newval) { ls_error(NULL, "No jemalloc : mallctl_opt %s.", name); return 0; } size_t malloc_used_memory(void) { return _used_memory; } size_t malloc_memory_block(void) { return _memory_block; } void dump_c_mem() { int i; size_t total = 0; ls_error(NULL, "dump all service mem:"); for (i = 0; i < SLOT_SIZE; i++) { struct mem_data* data = &mem_stats[i]; if (data->handle != 0 && data->allocated != 0) { total += data->allocated; ls_error(NULL, ":%08x -> %zdkb %db", data->handle, data->allocated >> 10, (int)(data->allocated % 1024)); } } ls_error(NULL, "+total: %zdkb", total >> 10); } char* ls_strdup(const char* str) { size_t sz = strlen(str); char* ret = (char*)ls_malloc(sz + 1); memcpy(ret, str, sz + 1); return ret; } void* ls_lalloc(void* ptr, size_t osize, size_t nsize) { if (nsize == 0) { raw_free(ptr); return NULL; } else { return raw_realloc(ptr, nsize); } } int dump_mem_lua(lua_State * L) { int i; lua_newtable(L); for (i = 0; i < SLOT_SIZE; i++) { struct mem_data* data = &mem_stats[i]; if (data->handle != 0 && data->allocated != 0) { lua_pushinteger(L, data->allocated); lua_rawseti(L, -2, (lua_Integer)data->handle); } } return 1; } size_t malloc_current_memory(void) { uint32_t handle = ls_current_handle(); int i; for (i = 0; i < SLOT_SIZE; i++) { struct mem_data* data = &mem_stats[i]; if (data->handle == (uint32_t)handle && data->allocated != 0) { return (size_t)data->allocated; } } return 0; } void ls_debug_memory(const char* info) { // for debug use uint32_t handle = ls_current_handle(); size_t mem = malloc_current_memory(); fprintf(stderr, "[:%08x] %s %p\n", handle, info, (void*)mem); }
19.235294
108
0.676988
bbxionglei
33ad6e203837391221313ed27c618f0e5d0a08ed
3,280
cpp
C++
extensions/http-curl/tests/C2VerifyServeResults.cpp
kevdoran/nifi-minifi-cpp
4bb1fd97f5df103d5bee9a884839b24e2f77a2c5
[ "Apache-2.0", "OpenSSL" ]
null
null
null
extensions/http-curl/tests/C2VerifyServeResults.cpp
kevdoran/nifi-minifi-cpp
4bb1fd97f5df103d5bee9a884839b24e2f77a2c5
[ "Apache-2.0", "OpenSSL" ]
null
null
null
extensions/http-curl/tests/C2VerifyServeResults.cpp
kevdoran/nifi-minifi-cpp
4bb1fd97f5df103d5bee9a884839b24e2f77a2c5
[ "Apache-2.0", "OpenSSL" ]
null
null
null
/** * * 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. */ #undef NDEBUG #include <cstdio> #include <memory> #include <string> #include <sstream> #include "processors/InvokeHTTP.h" #include "TestBase.h" #include "core/ProcessGroup.h" #include "properties/Configure.h" #include "TestServer.h" #include "HTTPIntegrationBase.h" #include "utils/IntegrationTestUtils.h" class VerifyC2Server : public HTTPIntegrationBase { public: explicit VerifyC2Server() { char format[] = "/tmp/ssth.XXXXXX"; dir = testController.createTempDirectory(format); } void testSetup() override { LogTestController::getInstance().setDebug<processors::InvokeHTTP>(); LogTestController::getInstance().setDebug<minifi::core::ProcessSession>(); std::fstream file; ss << dir << "/" << "tstFile.ext"; file.open(ss.str(), std::ios::out); file << "tempFile"; file.close(); } void cleanup() override { std::remove(ss.str().c_str()); IntegrationBase::cleanup(); } void runAssertions() override { using org::apache::nifi::minifi::utils::verifyLogLinePresenceInPollTime; assert(verifyLogLinePresenceInPollTime(std::chrono::milliseconds(wait_time_), "Import offset 0", "Outputting success and response")); } void queryRootProcessGroup(std::shared_ptr<core::ProcessGroup> pg) override { std::shared_ptr<core::Processor> proc = pg->findProcessorByName("invoke"); assert(proc != nullptr); std::shared_ptr<minifi::processors::InvokeHTTP> inv = std::dynamic_pointer_cast<minifi::processors::InvokeHTTP>(proc); assert(inv != nullptr); std::string url; inv->getProperty(minifi::processors::InvokeHTTP::URL.getName(), url); std::string port, scheme, path; parse_http_components(url, port, scheme, path); configuration->set("nifi.c2.enable", "true"); configuration->set("nifi.c2.agent.class", "test"); configuration->set("nifi.c2.agent.heartbeat.reporter.classes", "RESTReceiver"); configuration->set("nifi.c2.agent.protocol.class", "RESTSender"); configuration->set("nifi.c2.rest.listener.port", port); configuration->set("nifi.c2.agent.heartbeat.period", "10"); configuration->set("nifi.c2.rest.listener.heartbeat.rooturi", path); } protected: std::string dir; std::stringstream ss; TestController testController; }; int main(int argc, char **argv) { const cmd_args args = parse_cmdline_args(argc, argv); VerifyC2Server harness; harness.setKeyDir(args.key_dir); harness.run(args.test_file); return 0; }
33.814433
122
0.716159
kevdoran
33aedd12a0d47e9eb26bfe0db53dbf7f807298da
9,214
hh
C++
centreon-engine/modules/external_commands/inc/com/centreon/engine/modules/external_commands/processing.hh
centreon/centreon-collect
e63fc4d888a120d588a93169e7d36b360616bdee
[ "Unlicense" ]
8
2020-07-26T09:12:02.000Z
2022-03-30T17:24:29.000Z
centreon-engine/modules/external_commands/inc/com/centreon/engine/modules/external_commands/processing.hh
centreon/centreon-collect
e63fc4d888a120d588a93169e7d36b360616bdee
[ "Unlicense" ]
47
2020-06-18T12:11:37.000Z
2022-03-16T10:28:56.000Z
centreon-engine/modules/external_commands/inc/com/centreon/engine/modules/external_commands/processing.hh
centreon/centreon-collect
e63fc4d888a120d588a93169e7d36b360616bdee
[ "Unlicense" ]
5
2020-06-29T14:22:02.000Z
2022-03-17T10:34:10.000Z
/* ** Copyright 2011-2019 Centreon ** ** This file is part of Centreon Engine. ** ** Centreon Engine is free software: you can redistribute it and/or ** modify it under the terms of the GNU General Public License version 2 ** as published by the Free Software Foundation. ** ** Centreon Engine 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 Centreon Engine. If not, see ** <http://www.gnu.org/licenses/>. */ #ifndef CCE_MOD_EXTCMD_PROCESSING_HH #define CCE_MOD_EXTCMD_PROCESSING_HH #include <cstring> #include <map> #include <mutex> #include <string> #include <unordered_map> #include "com/centreon/engine/configuration/applier/state.hh" #include "com/centreon/engine/contact.hh" #include "com/centreon/engine/contactgroup.hh" #include "com/centreon/engine/host.hh" #include "com/centreon/engine/hostgroup.hh" #include "com/centreon/engine/namespace.hh" #include "com/centreon/engine/service.hh" #include "com/centreon/engine/servicegroup.hh" CCE_BEGIN() namespace modules { namespace external_commands { class processing { public: processing(); ~processing() throw(); bool execute(std::string const& cmd) const; bool is_thread_safe(char const* cmd) const; private: struct command_info { command_info(int _id = 0, void (*_func)(int, time_t, char*) = NULL, bool is_thread_safe = false) : id(_id), func(_func), thread_safe(is_thread_safe) {} ~command_info() throw() {} int id; void (*func)(int id, time_t entry_time, char* args); bool thread_safe; }; static void _wrapper_read_state_information(); static void _wrapper_save_state_information(); static void _wrapper_enable_host_and_child_notifications(host* hst); static void _wrapper_disable_host_and_child_notifications(host* hst); static void _wrapper_enable_all_notifications_beyond_host(host* hst); static void _wrapper_disable_all_notifications_beyond_host(host* hst); static void _wrapper_enable_host_svc_notifications(host* hst); static void _wrapper_disable_host_svc_notifications(host* hst); static void _wrapper_enable_host_svc_checks(host* hst); static void _wrapper_disable_host_svc_checks(host* hst); static void _wrapper_set_host_notification_number(host* hst, char* args); static void _wrapper_send_custom_host_notification(host* hst, char* args); static void _wrapper_enable_service_notifications(host* hst); static void _wrapper_disable_service_notifications(host* hst); static void _wrapper_enable_service_checks(host* hst); static void _wrapper_disable_service_checks(host* hst); static void _wrapper_enable_passive_service_checks(host* hst); static void _wrapper_disable_passive_service_checks(host* hst); static void _wrapper_set_service_notification_number(service* svc, char* args); static void _wrapper_send_custom_service_notification(service* svc, char* args); template <void (*fptr)()> static void _redirector(int id, time_t entry_time, char* args) { (void)id; (void)entry_time; (void)args; (*fptr)(); } template <int (*fptr)()> static void _redirector(int id, time_t entry_time, char* args) { (void)id; (void)entry_time; (void)args; (*fptr)(); } template <void (*fptr)(int, char*)> static void _redirector(int id, time_t entry_time, char* args) { (void)entry_time; (*fptr)(id, args); } template <int (*fptr)(int, char*)> static void _redirector(int id, time_t entry_time, char* args) { (void)entry_time; (*fptr)(id, args); } template <int (*fptr)(int, time_t, char*)> static void _redirector(int id, time_t entry_time, char* args) { (*fptr)(id, entry_time, args); } template <void (*fptr)(host*)> static void _redirector_host(int id, time_t entry_time, char* args) { (void)id; (void)entry_time; char* name(my_strtok(args, ";")); host* hst{nullptr}; host_map::const_iterator it(host::hosts.find(name)); if (it != host::hosts.end()) hst = it->second.get(); if (!hst) return; (*fptr)(hst); } template <void (*fptr)(host*, char*)> static void _redirector_host(int id, time_t entry_time, char* args) { (void)id; (void)entry_time; char* name(my_strtok(args, ";")); host* hst{nullptr}; host_map::const_iterator it(host::hosts.find(name)); if (it != host::hosts.end()) hst = it->second.get(); if (!hst) return; (*fptr)(hst, args + strlen(name) + 1); } template <void (*fptr)(host*)> static void _redirector_hostgroup(int id, time_t entry_time, char* args) { (void)id; (void)entry_time; char* group_name(my_strtok(args, ";")); hostgroup* group(nullptr); hostgroup_map::const_iterator it{hostgroup::hostgroups.find(group_name)}; if (it != hostgroup::hostgroups.end()) group = it->second.get(); if (!group) return; for (host_map_unsafe::iterator it(group->members.begin()), end(group->members.begin()); it != end; ++it) if (it->second) (*fptr)(it->second); } template <void (*fptr)(service*)> static void _redirector_service(int id, time_t entry_time, char* args) { (void)id; (void)entry_time; char* name(my_strtok(args, ";")); char* description(my_strtok(NULL, ";")); service_map::const_iterator found( service::services.find({name, description})); if (found == service::services.end() || !found->second) return; (*fptr)(found->second.get()); } template <void (*fptr)(service*, char*)> static void _redirector_service(int id, time_t entry_time, char* args) { (void)id; (void)entry_time; char* name{my_strtok(args, ";")}; char* description{my_strtok(NULL, ";")}; service_map::const_iterator found{ service::services.find({name, description})}; if (found == service::services.end() || !found->second) return; (*fptr)(found->second.get(), args + strlen(name) + strlen(description) + 2); } template <void (*fptr)(service*)> static void _redirector_servicegroup(int id, time_t entry_time, char* args) { (void)id; (void)entry_time; char* group_name(my_strtok(args, ";")); servicegroup_map::const_iterator sg_it{ servicegroup::servicegroups.find(group_name)}; if (sg_it == servicegroup::servicegroups.end() || !sg_it->second) return; for (service_map_unsafe::iterator it2(sg_it->second->members.begin()), end2(sg_it->second->members.end()); it2 != end2; ++it2) if (it2->second) (*fptr)(it2->second); } template <void (*fptr)(host*)> static void _redirector_servicegroup(int id, time_t entry_time, char* args) { (void)id; (void)entry_time; char* group_name(my_strtok(args, ";")); servicegroup_map::const_iterator sg_it{ servicegroup::servicegroups.find(group_name)}; if (sg_it == servicegroup::servicegroups.end() || !sg_it->second) return; host* last_host{nullptr}; for (service_map_unsafe::iterator it2(sg_it->second->members.begin()), end2(sg_it->second->members.end()); it2 != end2; ++it2) { host* hst{nullptr}; host_map::const_iterator found(host::hosts.find(it2->first.first)); if (found != host::hosts.end()) hst = found->second.get(); if (!hst || hst == last_host) continue; (*fptr)(hst); last_host = hst; } } template <void (*fptr)(contact*)> static void _redirector_contact(int id, time_t entry_time, char* args) { (void)id; (void)entry_time; char* name(my_strtok(args, ";")); contact_map::const_iterator ct_it{contact::contacts.find(name)}; if (ct_it == contact::contacts.end()) return; (*fptr)(ct_it->second.get()); } template <void (*fptr)(char*)> static void _redirector_file(int id __attribute__((unused)), time_t entry_time __attribute__((unused)), char* args) { char* filename(my_strtok(args, ";")); (*fptr)(filename); } template <void (*fptr)(contact*)> static void _redirector_contactgroup(int id, time_t entry_time, char* args) { (void)id; (void)entry_time; char* group_name(my_strtok(args, ";")); contactgroup_map::iterator it_cg{ contactgroup::contactgroups.find(group_name)}; if (it_cg == contactgroup::contactgroups.end() || !it_cg->second) return; for (contact_map_unsafe::const_iterator it(it_cg->second->get_members().begin()), end(it_cg->second->get_members().end()); it != end; ++it) if (it->second) (*fptr)(it->second); } std::unordered_map<std::string, command_info> _lst_command; mutable std::mutex _mutex; }; } // namespace external_commands } // namespace modules CCE_END() #endif // !CCE_MOD_EXTCMD_PROCESSING_HH
31.233898
80
0.661059
centreon
33af8d76293ddeefd555843efc6a527f36cbe0df
32,679
cpp
C++
lib/AST/DeclContext.cpp
arguiot/swift
dbe99d771e4eb3d3d9472201746ddc7950036dc7
[ "Apache-2.0" ]
1
2020-10-13T07:26:20.000Z
2020-10-13T07:26:20.000Z
lib/AST/DeclContext.cpp
arguiot/swift
dbe99d771e4eb3d3d9472201746ddc7950036dc7
[ "Apache-2.0" ]
null
null
null
lib/AST/DeclContext.cpp
arguiot/swift
dbe99d771e4eb3d3d9472201746ddc7950036dc7
[ "Apache-2.0" ]
null
null
null
//===--- DeclContext.cpp - DeclContext implementation ---------------------===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// #include "swift/AST/DeclContext.h" #include "swift/AST/AccessScope.h" #include "swift/AST/ASTContext.h" #include "swift/AST/ASTWalker.h" #include "swift/AST/Expr.h" #include "swift/AST/GenericEnvironment.h" #include "swift/AST/Initializer.h" #include "swift/AST/LazyResolver.h" #include "swift/AST/Module.h" #include "swift/AST/Types.h" #include "swift/Basic/SourceManager.h" #include "swift/Basic/Statistic.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/SaveAndRestore.h" using namespace swift; #define DEBUG_TYPE "Name lookup" STATISTIC(NumLazyIterableDeclContexts, "# of serialized iterable declaration contexts"); STATISTIC(NumUnloadedLazyIterableDeclContexts, "# of serialized iterable declaration contexts never loaded"); // Only allow allocation of DeclContext using the allocator in ASTContext. void *DeclContext::operator new(size_t Bytes, ASTContext &C, unsigned Alignment) { return C.Allocate(Bytes, Alignment); } ASTContext &DeclContext::getASTContext() const { return getParentModule()->getASTContext(); } GenericTypeDecl *DeclContext::getSelfTypeDecl() const { auto decl = const_cast<Decl*>(getAsDecl()); if (!decl) return nullptr; auto ext = dyn_cast<ExtensionDecl>(decl); if (!ext) return dyn_cast<GenericTypeDecl>(decl); return ext->getExtendedNominal(); } /// If this DeclContext is a NominalType declaration or an /// extension thereof, return the NominalTypeDecl. NominalTypeDecl *DeclContext::getSelfNominalTypeDecl() const { return dyn_cast_or_null<NominalTypeDecl>(getSelfTypeDecl()); } ClassDecl *DeclContext::getSelfClassDecl() const { return dyn_cast_or_null<ClassDecl>(getSelfTypeDecl()); } EnumDecl *DeclContext::getSelfEnumDecl() const { return dyn_cast_or_null<EnumDecl>(getSelfTypeDecl()); } StructDecl *DeclContext::getSelfStructDecl() const { return dyn_cast_or_null<StructDecl>(getSelfTypeDecl()); } ProtocolDecl *DeclContext::getSelfProtocolDecl() const { return dyn_cast_or_null<ProtocolDecl>(getSelfTypeDecl()); } ProtocolDecl *DeclContext::getExtendedProtocolDecl() const { if (auto decl = const_cast<Decl*>(getAsDecl())) if (auto ED = dyn_cast<ExtensionDecl>(decl)) return dyn_cast_or_null<ProtocolDecl>(ED->getExtendedNominal()); return nullptr; } GenericTypeParamType *DeclContext::getProtocolSelfType() const { assert(getSelfProtocolDecl() && "not a protocol"); GenericParamList *genericParams; if (auto proto = dyn_cast<ProtocolDecl>(this)) { genericParams = proto->getGenericParams(); } else { genericParams = cast<ExtensionDecl>(this)->getGenericParams(); } if (genericParams == nullptr) return nullptr; return genericParams->getParams().front() ->getDeclaredInterfaceType() ->castTo<GenericTypeParamType>(); } Type DeclContext::getDeclaredTypeInContext() const { if (auto *ED = dyn_cast<ExtensionDecl>(this)) return ED->mapTypeIntoContext(getDeclaredInterfaceType()); if (auto *NTD = dyn_cast<NominalTypeDecl>(this)) return NTD->getDeclaredTypeInContext(); return Type(); } Type DeclContext::getDeclaredInterfaceType() const { if (auto *ED = dyn_cast<ExtensionDecl>(this)) { auto *NTD = ED->getExtendedNominal(); if (NTD == nullptr) return ErrorType::get(ED->getASTContext()); return NTD->getDeclaredInterfaceType(); } if (auto *NTD = dyn_cast<NominalTypeDecl>(this)) return NTD->getDeclaredInterfaceType(); return Type(); } void DeclContext::forEachGenericContext( llvm::function_ref<void (GenericParamList *)> fn) const { auto dc = this; do { if (auto decl = dc->getAsDecl()) { // Extensions do not capture outer generic parameters. if (auto *ext = dyn_cast<ExtensionDecl>(decl)) { for (auto *gpList = ext->getGenericParams(); gpList != nullptr; gpList = gpList->getOuterParameters()) { fn(gpList); } return; } if (auto genericCtx = decl->getAsGenericContext()) if (auto *gpList = genericCtx->getGenericParams()) fn(gpList); } } while ((dc = dc->getParent())); } unsigned DeclContext::getGenericContextDepth() const { unsigned depth = -1; forEachGenericContext([&](GenericParamList *) { ++depth; }); return depth; } GenericSignature *DeclContext::getGenericSignatureOfContext() const { auto dc = this; do { if (auto decl = dc->getAsDecl()) if (auto GC = decl->getAsGenericContext()) return GC->getGenericSignature(); } while ((dc = dc->getParent())); return nullptr; } GenericEnvironment *DeclContext::getGenericEnvironmentOfContext() const { auto dc = this; do { if (auto decl = dc->getAsDecl()) if (auto GC = decl->getAsGenericContext()) return GC->getGenericEnvironment(); } while ((dc = dc->getParent())); return nullptr; } bool DeclContext::contextHasLazyGenericEnvironment() const { auto dc = this; do { if (auto decl = dc->getAsDecl()) if (auto GC = decl->getAsGenericContext()) return GC->hasLazyGenericEnvironment(); } while ((dc = dc->getParent())); return false; } Type DeclContext::mapTypeIntoContext(Type type) const { return GenericEnvironment::mapTypeIntoContext( getGenericEnvironmentOfContext(), type); } DeclContext *DeclContext::getLocalContext() { if (isLocalContext()) return this; if (isModuleContext()) return nullptr; return getParent()->getLocalContext(); } AbstractFunctionDecl *DeclContext::getInnermostMethodContext() { auto dc = this; do { if (auto decl = dc->getAsDecl()) { auto func = dyn_cast<AbstractFunctionDecl>(decl); // If we found a non-func decl, we're done. if (func == nullptr) return nullptr; if (func->getDeclContext()->isTypeContext()) return func; } } while ((dc = dc->getParent())); return nullptr; } bool DeclContext::isTypeContext() const { if (auto decl = getAsDecl()) return isa<NominalTypeDecl>(decl) || isa<ExtensionDecl>(decl); return false; } DeclContext *DeclContext::getInnermostTypeContext() { auto dc = this; do { if (dc->isTypeContext()) return dc; } while ((dc = dc->getParent())); return nullptr; } Decl *DeclContext::getInnermostDeclarationDeclContext() { auto DC = this; do { if (auto decl = DC->getAsDecl()) return isa<ModuleDecl>(decl) ? nullptr : decl; } while ((DC = DC->getParent())); return nullptr; } DeclContext *DeclContext::getParentForLookup() const { if (isa<ProtocolDecl>(this) || isa<ExtensionDecl>(this)) { // If we are inside a protocol or an extension, skip directly // to the module scope context, without looking at any (invalid) // outer types. return getModuleScopeContext(); } if (isa<NominalTypeDecl>(this)) { // If we are inside a nominal type that is inside a protocol, // skip the protocol. if (isa<ProtocolDecl>(getParent())) return getModuleScopeContext(); } return getParent(); } ModuleDecl *DeclContext::getParentModule() const { const DeclContext *DC = this; while (!DC->isModuleContext()) DC = DC->getParent(); return const_cast<ModuleDecl *>(cast<ModuleDecl>(DC)); } SourceFile *DeclContext::getParentSourceFile() const { const DeclContext *DC = this; while (!DC->isModuleScopeContext()) DC = DC->getParent(); return const_cast<SourceFile *>(dyn_cast<SourceFile>(DC)); } DeclContext *DeclContext::getModuleScopeContext() const { auto DC = const_cast<DeclContext*>(this); while (true) { if (DC->ParentAndKind.getInt() == ASTHierarchy::FileUnit) return DC; if (auto NextDC = DC->getParent()) { DC = NextDC; } else { assert(isa<ModuleDecl>(DC->getAsDecl())); return DC; } } } /// Determine whether the given context is generic at any level. bool DeclContext::isGenericContext() const { auto dc = this; do { if (auto decl = dc->getAsDecl()) { if (auto GC = decl->getAsGenericContext()) { if (GC->getGenericParams()) return true; // Extensions do not capture outer generic parameters. if (isa<ExtensionDecl>(decl)) break; } } } while ((dc = dc->getParent())); return false; } /// Get the most optimal resilience expansion for the body of this function. /// If the body is able to be inlined into functions in other resilience /// domains, this ensures that only sufficiently-conservative access patterns /// are used. ResilienceExpansion DeclContext::getResilienceExpansion() const { for (const auto *dc = this; dc->isLocalContext(); dc = dc->getParent()) { // Default argument initializer contexts have their resilience expansion // set when they're type checked. if (isa<DefaultArgumentInitializer>(dc)) { if (auto *EED = dyn_cast<EnumElementDecl>(dc->getParent())) { return EED->getDefaultArgumentResilienceExpansion(); } return cast<AbstractFunctionDecl>(dc->getParent()) ->getDefaultArgumentResilienceExpansion(); } // Stored property initializer contexts use minimal resilience expansion // if the type is formally fixed layout. if (isa<PatternBindingInitializer>(dc)) { if (auto *NTD = dyn_cast<NominalTypeDecl>(dc->getParent())) { auto nominalAccess = NTD->getFormalAccessScope(/*useDC=*/nullptr, /*treatUsableFromInlineAsPublic=*/true); if (!nominalAccess.isPublic()) return ResilienceExpansion::Maximal; if (NTD->isFormallyResilient()) return ResilienceExpansion::Maximal; return ResilienceExpansion::Minimal; } } if (auto *AFD = dyn_cast<AbstractFunctionDecl>(dc)) { // If the function is a nested function, we will serialize its body if // we serialize the parent's body. if (AFD->getDeclContext()->isLocalContext()) continue; auto funcAccess = AFD->getFormalAccessScope(/*useDC=*/nullptr, /*treatUsableFromInlineAsPublic=*/true); // If the function is not externally visible, we will not be serializing // its body. if (!funcAccess.isPublic()) break; // If the function is public, @_transparent implies @inlinable. if (AFD->isTransparent()) return ResilienceExpansion::Minimal; if (AFD->getAttrs().hasAttribute<InlinableAttr>()) return ResilienceExpansion::Minimal; if (AFD->getAttrs().hasAttribute<AlwaysEmitIntoClientAttr>()) return ResilienceExpansion::Minimal; // If a property or subscript is @inlinable or @_alwaysEmitIntoClient, // the accessors are @inlinable or @_alwaysEmitIntoClient also. if (auto accessor = dyn_cast<AccessorDecl>(AFD)) { auto *storage = accessor->getStorage(); if (storage->getAttrs().getAttribute<InlinableAttr>()) return ResilienceExpansion::Minimal; if (storage->getAttrs().hasAttribute<AlwaysEmitIntoClientAttr>()) return ResilienceExpansion::Minimal; } } } return ResilienceExpansion::Maximal; } /// Determine whether the innermost context is generic. bool DeclContext::isInnermostContextGeneric() const { if (auto Decl = getAsDecl()) if (auto GC = Decl->getAsGenericContext()) return GC->isGeneric(); return false; } bool DeclContext::isCascadingContextForLookup(bool functionsAreNonCascading) const { // FIXME: This is explicitly checking for attributes in some cases because // it can be called before access control is computed. switch (getContextKind()) { case DeclContextKind::AbstractClosureExpr: break; case DeclContextKind::SerializedLocal: llvm_unreachable("should not perform lookups in deserialized contexts"); case DeclContextKind::Initializer: // Default arguments still require a type. if (isa<DefaultArgumentInitializer>(this)) return false; break; case DeclContextKind::TopLevelCodeDecl: // FIXME: Pattern initializers at top-level scope end up here. return true; case DeclContextKind::AbstractFunctionDecl: if (functionsAreNonCascading) return false; break; case DeclContextKind::SubscriptDecl: break; case DeclContextKind::EnumElementDecl: break; case DeclContextKind::Module: case DeclContextKind::FileUnit: return true; case DeclContextKind::GenericTypeDecl: break; case DeclContextKind::ExtensionDecl: return true; } return getParent()->isCascadingContextForLookup(true); } unsigned DeclContext::getSyntacticDepth() const { // Module scope == depth 0. if (isModuleScopeContext()) return 0; return 1 + getParent()->getSyntacticDepth(); } unsigned DeclContext::getSemanticDepth() const { // For extensions, count the depth of the nominal type being extended. if (isa<ExtensionDecl>(this)) { if (auto nominal = getSelfNominalTypeDecl()) return nominal->getSemanticDepth(); return 1; } // Module scope == depth 0. if (isModuleScopeContext()) return 0; return 1 + getParent()->getSemanticDepth(); } bool DeclContext::walkContext(ASTWalker &Walker) { switch (getContextKind()) { case DeclContextKind::Module: return cast<ModuleDecl>(this)->walk(Walker); case DeclContextKind::FileUnit: return cast<FileUnit>(this)->walk(Walker); case DeclContextKind::AbstractClosureExpr: return cast<AbstractClosureExpr>(this)->walk(Walker); case DeclContextKind::GenericTypeDecl: return cast<GenericTypeDecl>(this)->walk(Walker); case DeclContextKind::ExtensionDecl: return cast<ExtensionDecl>(this)->walk(Walker); case DeclContextKind::TopLevelCodeDecl: return cast<TopLevelCodeDecl>(this)->walk(Walker); case DeclContextKind::AbstractFunctionDecl: return cast<AbstractFunctionDecl>(this)->walk(Walker); case DeclContextKind::SubscriptDecl: return cast<SubscriptDecl>(this)->walk(Walker); case DeclContextKind::EnumElementDecl: return cast<EnumElementDecl>(this)->walk(Walker); case DeclContextKind::SerializedLocal: llvm_unreachable("walk is unimplemented for deserialized contexts"); case DeclContextKind::Initializer: // Is there any point in trying to walk the expression? return false; } llvm_unreachable("bad DeclContextKind"); } void DeclContext::dumpContext() const { printContext(llvm::errs()); } void AccessScope::dump() const { llvm::errs() << getAccessLevelSpelling(accessLevelForDiagnostics()) << ": "; if (isPublic()) { llvm::errs() << "(null)\n"; return; } if (auto *file = dyn_cast<SourceFile>(getDeclContext())) { llvm::errs() << "file '" << file->getFilename() << "'\n"; return; } if (auto *decl = getDeclContext()->getAsDecl()) { llvm::errs() << Decl::getKindName(decl->getKind()) << " "; if (auto *ext = dyn_cast<ExtensionDecl>(decl)) llvm::errs() << ext->getExtendedNominal()->getName(); else if (auto *named = dyn_cast<ValueDecl>(decl)) llvm::errs() << named->getFullName(); else llvm::errs() << (const void *)decl; SourceLoc loc = decl->getLoc(); if (loc.isValid()) { llvm::errs() << " at "; loc.print(llvm::errs(), decl->getASTContext().SourceMgr); } llvm::errs() << "\n"; return; } // If all else fails, dump the DeclContext tree. getDeclContext()->printContext(llvm::errs()); } template <typename DCType> static unsigned getLineNumber(DCType *DC) { SourceLoc loc = DC->getLoc(); if (loc.isInvalid()) return 0; const ASTContext &ctx = static_cast<const DeclContext *>(DC)->getASTContext(); return ctx.SourceMgr.getLineAndColumn(loc).first; } unsigned DeclContext::printContext(raw_ostream &OS, const unsigned indent, const bool onlyAPartialLine) const { unsigned Depth = 0; if (!onlyAPartialLine) if (auto *P = getParent()) Depth = P->printContext(OS, indent); const char *Kind; switch (getContextKind()) { case DeclContextKind::Module: Kind = "Module"; break; case DeclContextKind::FileUnit: Kind = "FileUnit"; break; case DeclContextKind::SerializedLocal: Kind = "Serialized Local"; break; case DeclContextKind::AbstractClosureExpr: Kind = "AbstractClosureExpr"; break; case DeclContextKind::GenericTypeDecl: switch (cast<GenericTypeDecl>(this)->getKind()) { #define DECL(ID, PARENT) \ case DeclKind::ID: Kind = #ID "Decl"; break; #include "swift/AST/DeclNodes.def" } break; case DeclContextKind::ExtensionDecl: Kind = "ExtensionDecl"; break; case DeclContextKind::TopLevelCodeDecl: Kind = "TopLevelCodeDecl"; break; case DeclContextKind::Initializer: Kind = "Initializer"; break; case DeclContextKind::AbstractFunctionDecl: Kind = "AbstractFunctionDecl"; break; case DeclContextKind::SubscriptDecl: Kind = "SubscriptDecl"; break; case DeclContextKind::EnumElementDecl: Kind = "EnumElementDecl"; break; } OS.indent(Depth*2 + indent) << (void*)this << " " << Kind; switch (getContextKind()) { case DeclContextKind::Module: OS << " name=" << cast<ModuleDecl>(this)->getName(); break; case DeclContextKind::FileUnit: switch (cast<FileUnit>(this)->getKind()) { case FileUnitKind::Builtin: OS << " Builtin"; break; case FileUnitKind::Source: OS << " file=\"" << cast<SourceFile>(this)->getFilename() << "\""; break; case FileUnitKind::SerializedAST: case FileUnitKind::ClangModule: case FileUnitKind::DWARFModule: OS << " file=\"" << cast<LoadedFile>(this)->getFilename() << "\""; break; } break; case DeclContextKind::AbstractClosureExpr: OS << " line=" << getLineNumber(cast<AbstractClosureExpr>(this)); OS << " : " << cast<AbstractClosureExpr>(this)->getType(); break; case DeclContextKind::GenericTypeDecl: OS << " name=" << cast<GenericTypeDecl>(this)->getName(); break; case DeclContextKind::ExtensionDecl: OS << " line=" << getLineNumber(cast<ExtensionDecl>(this)); OS << " base=" << cast<ExtensionDecl>(this)->getExtendedType(); break; case DeclContextKind::TopLevelCodeDecl: OS << " line=" << getLineNumber(cast<TopLevelCodeDecl>(this)); break; case DeclContextKind::AbstractFunctionDecl: { auto *AFD = cast<AbstractFunctionDecl>(this); OS << " name=" << AFD->getFullName(); if (AFD->hasInterfaceType()) OS << " : " << AFD->getInterfaceType(); else OS << " : (no type set)"; break; } case DeclContextKind::SubscriptDecl: { auto *SD = cast<SubscriptDecl>(this); OS << " name=" << SD->getBaseName(); if (SD->hasInterfaceType()) OS << " : " << SD->getInterfaceType(); else OS << " : (no type set)"; break; } case DeclContextKind::EnumElementDecl: { auto *EED = cast<EnumElementDecl>(this); OS << " name=" << EED->getBaseName(); if (EED->hasInterfaceType()) OS << " : " << EED->getInterfaceType(); else OS << " : (no type set)"; break; } case DeclContextKind::Initializer: switch (cast<Initializer>(this)->getInitializerKind()) { case InitializerKind::PatternBinding: { auto init = cast<PatternBindingInitializer>(this); OS << " PatternBinding 0x" << (void*) init->getBinding() << " #" << init->getBindingIndex(); break; } case InitializerKind::DefaultArgument: { auto init = cast<DefaultArgumentInitializer>(this); OS << " DefaultArgument index=" << init->getIndex(); break; } } break; case DeclContextKind::SerializedLocal: { auto local = cast<SerializedLocalDeclContext>(this); switch (local->getLocalDeclContextKind()) { case LocalDeclContextKind::AbstractClosure: { auto serializedClosure = cast<SerializedAbstractClosureExpr>(local); OS << " closure : " << serializedClosure->getType(); break; } case LocalDeclContextKind::DefaultArgumentInitializer: { auto init = cast<SerializedDefaultArgumentInitializer>(local); OS << "DefaultArgument index=" << init->getIndex(); break; } case LocalDeclContextKind::PatternBindingInitializer: { auto init = cast<SerializedPatternBindingInitializer>(local); OS << " PatternBinding 0x" << (void*) init->getBinding() << " #" << init->getBindingIndex(); break; } case LocalDeclContextKind::TopLevelCodeDecl: OS << " TopLevelCode"; break; } } } if (!onlyAPartialLine) OS << "\n"; return Depth + 1; } const Decl * IterableDeclContext::getDecl() const { switch (getIterableContextKind()) { case IterableDeclContextKind::NominalTypeDecl: return cast<NominalTypeDecl>(this); break; case IterableDeclContextKind::ExtensionDecl: return cast<ExtensionDecl>(this); break; } llvm_unreachable("Unhandled IterableDeclContextKind in switch."); } ASTContext &IterableDeclContext::getASTContext() const { return getDecl()->getASTContext(); } DeclRange IterableDeclContext::getCurrentMembersWithoutLoading() const { return DeclRange(FirstDeclAndLazyMembers.getPointer(), nullptr); } DeclRange IterableDeclContext::getMembers() const { loadAllMembers(); return getCurrentMembersWithoutLoading(); } /// Add a member to this context. void IterableDeclContext::addMember(Decl *member, Decl *Hint) { // Add the member to the list of declarations without notification. addMemberSilently(member, Hint); // Notify our parent declaration that we have added the member, which can // be used to update the lookup tables. switch (getIterableContextKind()) { case IterableDeclContextKind::NominalTypeDecl: { auto nominal = cast<NominalTypeDecl>(this); nominal->addedMember(member); assert(member->getDeclContext() == nominal && "Added member to the wrong context"); break; } case IterableDeclContextKind::ExtensionDecl: { auto ext = cast<ExtensionDecl>(this); ext->addedMember(member); assert(member->getDeclContext() == ext && "Added member to the wrong context"); break; } } } void IterableDeclContext::addMemberSilently(Decl *member, Decl *hint) const { assert(!member->NextDecl && "Already added to a container"); // If there is a hint decl that specifies where to add this, just // link into the chain immediately following it. if (hint) { member->NextDecl = hint->NextDecl; hint->NextDecl = member; // If the hint was the last in the parent context's chain, update it. if (LastDeclAndKind.getPointer() == hint) LastDeclAndKind.setPointer(member); return; } if (auto last = LastDeclAndKind.getPointer()) { last->NextDecl = member; assert(last != member && "Simple cycle in decl list"); } else { FirstDeclAndLazyMembers.setPointer(member); } LastDeclAndKind.setPointer(member); } void IterableDeclContext::setMemberLoader(LazyMemberLoader *loader, uint64_t contextData) { assert(!hasLazyMembers() && "already have lazy members"); ASTContext &ctx = getASTContext(); auto contextInfo = ctx.getOrCreateLazyIterableContextData(this, loader); auto lazyMembers = FirstDeclAndLazyMembers.getInt() | LazyMembers::Present; FirstDeclAndLazyMembers.setInt(LazyMembers(lazyMembers)); contextInfo->memberData = contextData; ++NumLazyIterableDeclContexts; ++NumUnloadedLazyIterableDeclContexts; // FIXME: (transitional) increment the redundant "always-on" counter. if (auto s = ctx.Stats) { ++s->getFrontendCounters().NumLazyIterableDeclContexts; ++s->getFrontendCounters().NumUnloadedLazyIterableDeclContexts; } } void IterableDeclContext::loadAllMembers() const { // Lazily parse members. getASTContext().parseMembers(const_cast<IterableDeclContext*>(this)); if (!hasLazyMembers()) return; // Don't try to load all members re-entrant-ly. ASTContext &ctx = getASTContext(); auto contextInfo = ctx.getOrCreateLazyIterableContextData(this, /*lazyLoader=*/nullptr); auto lazyMembers = FirstDeclAndLazyMembers.getInt() & ~LazyMembers::Present; FirstDeclAndLazyMembers.setInt(LazyMembers(lazyMembers)); const Decl *container = getDecl(); contextInfo->loader->loadAllMembers(const_cast<Decl *>(container), contextInfo->memberData); --NumUnloadedLazyIterableDeclContexts; // FIXME: (transitional) decrement the redundant "always-on" counter. if (auto s = ctx.Stats) s->getFrontendCounters().NumUnloadedLazyIterableDeclContexts--; } bool IterableDeclContext::wasDeserialized() const { const DeclContext *DC = cast<DeclContext>(getDecl()); if (auto F = dyn_cast<FileUnit>(DC->getModuleScopeContext())) { return F->getKind() == FileUnitKind::SerializedAST; } return false; } bool IterableDeclContext::classof(const Decl *D) { switch (D->getKind()) { default: return false; #define DECL(ID, PARENT) // See previous line #define ITERABLE_DECL(ID, PARENT) \ case DeclKind::ID: return true; #include "swift/AST/DeclNodes.def" } } IterableDeclContext * IterableDeclContext::castDeclToIterableDeclContext(const Decl *D) { switch (D->getKind()) { default: llvm_unreachable("Decl is not a IterableDeclContext."); #define DECL(ID, PARENT) // See previous line #define ITERABLE_DECL(ID, PARENT) \ case DeclKind::ID: \ return const_cast<IterableDeclContext *>( \ static_cast<const IterableDeclContext*>(cast<ID##Decl>(D))); #include "swift/AST/DeclNodes.def" } } /// Return the DeclContext to compare when checking private access in /// Swift 4 mode. The context returned is the type declaration if the context /// and the type declaration are in the same file, otherwise it is the types /// last extension in the source file. If the context does not refer to a /// declaration or extension, the supplied context is returned. static const DeclContext * getPrivateDeclContext(const DeclContext *DC, const SourceFile *useSF) { auto NTD = DC->getSelfNominalTypeDecl(); if (!NTD) return DC; // use the type declaration as the private scope if it is in the same // file as useSF. This occurs for both extensions and declarations. if (NTD->getParentSourceFile() == useSF) return NTD; // Otherwise use the last extension declaration in the same file. const DeclContext *lastExtension = nullptr; for (ExtensionDecl *ED : NTD->getExtensions()) if (ED->getParentSourceFile() == useSF) lastExtension = ED; // If there's no last extension, return the supplied context. return lastExtension ? lastExtension : DC; } AccessScope::AccessScope(const DeclContext *DC, bool isPrivate) : Value(DC, isPrivate) { if (isPrivate) { DC = getPrivateDeclContext(DC, DC->getParentSourceFile()); Value.setPointer(DC); } if (!DC || isa<ModuleDecl>(DC)) assert(!isPrivate && "public or internal scope can't be private"); } bool AccessScope::isFileScope() const { auto DC = getDeclContext(); return DC && isa<FileUnit>(DC); } bool AccessScope::isInternal() const { auto DC = getDeclContext(); return DC && isa<ModuleDecl>(DC); } AccessLevel AccessScope::accessLevelForDiagnostics() const { if (isPublic()) return AccessLevel::Public; if (isa<ModuleDecl>(getDeclContext())) return AccessLevel::Internal; if (getDeclContext()->isModuleScopeContext()) { return isPrivate() ? AccessLevel::Private : AccessLevel::FilePrivate; } return AccessLevel::Private; } bool AccessScope::allowsPrivateAccess(const DeclContext *useDC, const DeclContext *sourceDC) { // Check the lexical scope. if (useDC->isChildContextOf(sourceDC)) return true; // Do not allow access if the sourceDC is in a different file auto useSF = useDC->getParentSourceFile(); if (useSF != sourceDC->getParentSourceFile()) return false; // Do not allow access if the sourceDC does not represent a type. auto sourceNTD = sourceDC->getSelfNominalTypeDecl(); if (!sourceNTD) return false; // Compare the private scopes and iterate over the parent types. sourceDC = getPrivateDeclContext(sourceDC, useSF); while (!useDC->isModuleContext()) { useDC = getPrivateDeclContext(useDC, useSF); if (useDC == sourceDC) return true; // Get the parent type. If the context represents a type, look at the types // declaring context instead of the contexts parent. This will crawl up // the type hierarchy in nested extensions correctly. if (auto NTD = useDC->getSelfNominalTypeDecl()) useDC = NTD->getDeclContext(); else useDC = useDC->getParent(); } return false; } DeclContext *Decl::getDeclContextForModule() const { if (auto module = dyn_cast<ModuleDecl>(this)) return const_cast<ModuleDecl *>(module); return nullptr; } DeclContextKind DeclContext::getContextKind() const { switch (ParentAndKind.getInt()) { case ASTHierarchy::Expr: return DeclContextKind::AbstractClosureExpr; case ASTHierarchy::Initializer: return DeclContextKind::Initializer; case ASTHierarchy::SerializedLocal: return DeclContextKind::SerializedLocal; case ASTHierarchy::FileUnit: return DeclContextKind::FileUnit; case ASTHierarchy::Decl: { auto decl = reinterpret_cast<const Decl*>(this + 1); if (isa<AbstractFunctionDecl>(decl)) return DeclContextKind::AbstractFunctionDecl; if (isa<GenericTypeDecl>(decl)) return DeclContextKind::GenericTypeDecl; switch (decl->getKind()) { case DeclKind::Module: return DeclContextKind::Module; case DeclKind::TopLevelCode: return DeclContextKind::TopLevelCodeDecl; case DeclKind::Subscript: return DeclContextKind::SubscriptDecl; case DeclKind::EnumElement: return DeclContextKind::EnumElementDecl; case DeclKind::Extension: return DeclContextKind::ExtensionDecl; default: llvm_unreachable("Unhandled Decl kind"); } } } llvm_unreachable("Unhandled DeclContext ASTHierarchy"); } #define DECL(Id, Parent) \ static_assert(!std::is_base_of<DeclContext, Id##Decl>::value, \ "Non-context Decl node has context?"); #define CONTEXT_DECL(Id, Parent) \ static_assert(alignof(DeclContext) == alignof(Id##Decl), "Alignment error"); \ static_assert(std::is_base_of<DeclContext, Id##Decl>::value, \ "CONTEXT_DECL nodes must inherit from DeclContext"); #define CONTEXT_VALUE_DECL(Id, Parent) \ static_assert(alignof(DeclContext) == alignof(Id##Decl), "Alignment error"); \ static_assert(std::is_base_of<DeclContext, Id##Decl>::value, \ "CONTEXT_VALUE_DECL nodes must inherit from DeclContext"); #include "swift/AST/DeclNodes.def" #define EXPR(Id, Parent) \ static_assert(!std::is_base_of<DeclContext, Id##Expr>::value, \ "Non-context Expr node has context?"); #define CONTEXT_EXPR(Id, Parent) \ static_assert(alignof(DeclContext) == alignof(Id##Expr), "Alignment error"); \ static_assert(std::is_base_of<DeclContext, Id##Expr>::value, \ "CONTEXT_EXPR nodes must inherit from DeclContext"); #include "swift/AST/ExprNodes.def" #ifndef NDEBUG // XXX -- static_cast is not static enough for use with static_assert(). // DO verify this by temporarily breaking a Decl or Expr. // DO NOT assume that the compiler will emit this code blindly. SWIFT_CONSTRUCTOR static void verify_DeclContext_is_start_of_node() { auto decl = reinterpret_cast<Decl*>(0x1000 + sizeof(DeclContext)); #define DECL(Id, Parent) #define CONTEXT_DECL(Id, Parent) \ assert(reinterpret_cast<DeclContext*>(0x1000) == \ static_cast<Id##Decl*>(decl)); #define CONTEXT_VALUE_DECL(Id, Parent) \ assert(reinterpret_cast<DeclContext*>(0x1000) == \ static_cast<Id##Decl*>(decl)); #include "swift/AST/DeclNodes.def" auto expr = reinterpret_cast<Expr*>(0x1000 + sizeof(DeclContext)); #define EXPR(Id, Parent) #define CONTEXT_EXPR(Id, Parent) \ assert(reinterpret_cast<DeclContext*>(0x1000) == \ static_cast<Id##Expr*>(expr)); #include "swift/AST/ExprNodes.def" } #endif
32.419643
94
0.687383
arguiot
33b0d447893668d87306e25e7210c48469f6d67e
23,895
hxx
C++
Modules/IO/ImageBase/include/itkConvertPixelBuffer.hxx
jond01/ITK
88d152f65ff8982d4b926e8ab01f81dddf06291b
[ "Apache-2.0" ]
945
2015-01-09T00:43:52.000Z
2022-03-30T08:23:02.000Z
Modules/IO/ImageBase/include/itkConvertPixelBuffer.hxx
jond01/ITK
88d152f65ff8982d4b926e8ab01f81dddf06291b
[ "Apache-2.0" ]
2,354
2015-02-04T21:54:21.000Z
2022-03-31T20:58:21.000Z
Modules/IO/ImageBase/include/itkConvertPixelBuffer.hxx
jond01/ITK
88d152f65ff8982d4b926e8ab01f81dddf06291b
[ "Apache-2.0" ]
566
2015-01-04T14:26:57.000Z
2022-03-18T20:33:18.000Z
/*========================================================================= * * Copyright NumFOCUS * * 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.txt * * 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 itkConvertPixelBuffer_hxx #define itkConvertPixelBuffer_hxx #include "itkConvertPixelBuffer.h" #include "itkRGBPixel.h" #include "itkDefaultConvertPixelTraits.h" #include <cstddef> namespace itk { template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> template <typename UComponentType> std::enable_if_t<!NumericTraits<UComponentType>::IsInteger, UComponentType> ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::DefaultAlphaValue() { return NumericTraits<UComponentType>::One; } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> template <typename UComponentType> std::enable_if_t<NumericTraits<UComponentType>::IsInteger, UComponentType> ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::DefaultAlphaValue() { return NumericTraits<UComponentType>::max(); } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::Convert(InputPixelType * inputData, int inputNumberOfComponents, OutputPixelType * outputData, size_t size) { switch (OutputConvertTraits::GetNumberOfComponents()) { // output number of components is 1 case 1: { switch (inputNumberOfComponents) { case 1: ConvertGrayToGray(inputData, outputData, size); break; case 3: ConvertRGBToGray(inputData, outputData, size); break; case 4: ConvertRGBAToGray(inputData, outputData, size); break; default: ConvertMultiComponentToGray(inputData, inputNumberOfComponents, outputData, size); break; } break; } // handle the complex case case 2: { switch (inputNumberOfComponents) { case 1: ConvertGrayToComplex(inputData, outputData, size); break; case 2: ConvertComplexToComplex(inputData, outputData, size); break; default: ConvertMultiComponentToComplex(inputData, inputNumberOfComponents, outputData, size); break; } break; } // output number of components is 3 RGB case 3: { switch (inputNumberOfComponents) { case 1: ConvertGrayToRGB(inputData, outputData, size); break; case 3: ConvertRGBToRGB(inputData, outputData, size); break; case 4: ConvertRGBAToRGB(inputData, outputData, size); break; default: ConvertMultiComponentToRGB(inputData, inputNumberOfComponents, outputData, size); } break; } // output number of components is 4 RGBA case 4: { switch (inputNumberOfComponents) { case 1: ConvertGrayToRGBA(inputData, outputData, size); break; case 3: ConvertRGBToRGBA(inputData, outputData, size); break; case 4: ConvertRGBAToRGBA(inputData, outputData, size); break; default: ConvertMultiComponentToRGBA(inputData, inputNumberOfComponents, outputData, size); } break; } // output number of components is 6 (SymmetricSecondRankTensor) case 6: { switch (inputNumberOfComponents) { case 6: ConvertTensor6ToTensor6(inputData, outputData, size); break; case 9: ConvertTensor9ToTensor6(inputData, outputData, size); break; default: itkGenericExceptionMacro("No conversion available from " << inputNumberOfComponents << " components to: 6 components"); break; } break; } default: itkGenericExceptionMacro("No conversion available from " << inputNumberOfComponents << " components to: " << OutputConvertTraits::GetNumberOfComponents() << " components"); break; } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertGrayToGray( InputPixelType * inputData, OutputPixelType * outputData, size_t size) { InputPixelType * endInput = inputData + size; while (inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData++, static_cast<OutputComponentType>(*inputData)); inputData++; } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertRGBToGray(InputPixelType * inputData, OutputPixelType * outputData, size_t size) { // Weights convert from linear RGB to CIE luminance assuming a // modern monitor. See Charles Pontyon's Colour FAQ // http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html // NOTE: The scale factors are converted to whole numbers for precision InputPixelType * endInput = inputData + size * 3; while (inputData != endInput) { auto val = static_cast<OutputComponentType>((2125.0 * static_cast<OutputComponentType>(*inputData) + 7154.0 * static_cast<OutputComponentType>(*(inputData + 1)) + 0721.0 * static_cast<OutputComponentType>(*(inputData + 2))) / 10000.0); inputData += 3; OutputConvertTraits::SetNthComponent(0, *outputData++, val); } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertRGBAToGray( InputPixelType * inputData, OutputPixelType * outputData, size_t size) { // Weights convert from linear RGB to CIE luminance assuming a // modern monitor. See Charles Pontyon's Colour FAQ // http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html // NOTE: The scale factors are converted to whole numbers for // precision InputPixelType * endInput = inputData + size * 4; double maxAlpha(DefaultAlphaValue<InputPixelType>()); // // To be backwards campatible, if the output pixel type // isn't a short or char type, don't fix the problem. if (sizeof(*outputData) > 2) { maxAlpha = 1.0; } while (inputData != endInput) { // this is an ugly implementation of the simple equation // greval = (.2125 * red + .7154 * green + .0721 * blue) / alpha // double tempval = ((2125.0 * static_cast<double>(*inputData) + 7154.0 * static_cast<double>(*(inputData + 1)) + 0721.0 * static_cast<double>(*(inputData + 2))) / 10000.0) * static_cast<double>(*(inputData + 3)) / maxAlpha; inputData += 4; auto val = static_cast<OutputComponentType>(tempval); OutputConvertTraits::SetNthComponent(0, *outputData++, val); } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertMultiComponentToGray( InputPixelType * inputData, int inputNumberOfComponents, OutputPixelType * outputData, size_t size) { // // To be backwards campatible, if the output pixel type // isn't a short or char type, don't fix the problem. double maxAlpha(DefaultAlphaValue<InputPixelType>()); if (sizeof(*outputData) > 2) { maxAlpha = 1.0; } // 2 components assumed intensity and alpha if (inputNumberOfComponents == 2) { InputPixelType * endInput = inputData + size * 2; while (inputData != endInput) { OutputComponentType val = static_cast<OutputComponentType>(*inputData) * static_cast<OutputComponentType>(*(inputData + 1) / maxAlpha); inputData += 2; OutputConvertTraits::SetNthComponent(0, *outputData++, val); } } // just skip the rest of the data else { // Weights convert from linear RGB to CIE luminance assuming a // modern monitor. See Charles Pontyon's Colour FAQ // http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html // NOTE: The scale factors are converted to whole numbers for // precision ptrdiff_t diff = inputNumberOfComponents - 4; InputPixelType * endInput = inputData + size * (size_t)inputNumberOfComponents; while (inputData != endInput) { double tempval = ((2125.0 * static_cast<double>(*inputData) + 7154.0 * static_cast<double>(*(inputData + 1)) + 0721.0 * static_cast<double>(*(inputData + 2))) / 10000.0) * static_cast<double>(*(inputData + 3)) / maxAlpha; inputData += 4; auto val = static_cast<OutputComponentType>(tempval); OutputConvertTraits::SetNthComponent(0, *outputData++, val); inputData += diff; } } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertGrayToRGB(InputPixelType * inputData, OutputPixelType * outputData, size_t size) { InputPixelType * endInput = inputData + size; while (inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(1, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(2, *outputData, static_cast<OutputComponentType>(*inputData)); inputData++; outputData++; } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertRGBToRGB(InputPixelType * inputData, OutputPixelType * outputData, size_t size) { InputPixelType * endInput = inputData + size * 3; while (inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(1, *outputData, static_cast<OutputComponentType>(*(inputData + 1))); OutputConvertTraits::SetNthComponent(2, *outputData, static_cast<OutputComponentType>(*(inputData + 2))); inputData += 3; outputData++; } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertRGBAToRGB(InputPixelType * inputData, OutputPixelType * outputData, size_t size) { InputPixelType * endInput = inputData + size * 4; while (inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(1, *outputData, static_cast<OutputComponentType>(*(inputData + 1))); OutputConvertTraits::SetNthComponent(2, *outputData, static_cast<OutputComponentType>(*(inputData + 2))); inputData += 3; inputData++; // skip alpha outputData++; } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertMultiComponentToRGB( InputPixelType * inputData, int inputNumberOfComponents, OutputPixelType * outputData, size_t size) { // assume intensity alpha if (inputNumberOfComponents == 2) { InputPixelType * endInput = inputData + size * 2; while (inputData != endInput) { OutputComponentType val = static_cast<OutputComponentType>(*inputData) * static_cast<OutputComponentType>(*(inputData + 1)); inputData += 2; OutputConvertTraits::SetNthComponent(0, *outputData, val); OutputConvertTraits::SetNthComponent(1, *outputData, val); OutputConvertTraits::SetNthComponent(2, *outputData, val); outputData++; } } // just skip the rest of the data else { ptrdiff_t diff = inputNumberOfComponents - 3; InputPixelType * endInput = inputData + size * (size_t)inputNumberOfComponents; while (inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(1, *outputData, static_cast<OutputComponentType>(*(inputData + 1))); OutputConvertTraits::SetNthComponent(2, *outputData, static_cast<OutputComponentType>(*(inputData + 2))); inputData += 3; inputData += diff; outputData++; } } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertGrayToRGBA( InputPixelType * inputData, OutputPixelType * outputData, size_t size) { InputPixelType * endInput = inputData + size; while (inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(1, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(2, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent( 3, *outputData, static_cast<OutputComponentType>(DefaultAlphaValue<InputPixelType>())); inputData++; outputData++; } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertRGBToRGBA(InputPixelType * inputData, OutputPixelType * outputData, size_t size) { using InputConvertTraits = itk::DefaultConvertPixelTraits<InputPixelType>; using InputComponentType = typename InputConvertTraits::ComponentType; InputPixelType * endInput = inputData + size * 3; while (inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(1, *outputData, static_cast<OutputComponentType>(*(inputData + 1))); OutputConvertTraits::SetNthComponent(2, *outputData, static_cast<OutputComponentType>(*(inputData + 2))); OutputConvertTraits::SetNthComponent( 3, *outputData, static_cast<OutputComponentType>(DefaultAlphaValue<InputComponentType>())); inputData += 3; outputData++; } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertRGBAToRGBA( InputPixelType * inputData, OutputPixelType * outputData, size_t size) { InputPixelType * endInput = inputData + size * 4; while (inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(1, *outputData, static_cast<OutputComponentType>(*(inputData + 1))); OutputConvertTraits::SetNthComponent(2, *outputData, static_cast<OutputComponentType>(*(inputData + 2))); OutputConvertTraits::SetNthComponent(3, *outputData, static_cast<OutputComponentType>(*(inputData + 3))); inputData += 4; outputData++; } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertMultiComponentToRGBA( InputPixelType * inputData, int inputNumberOfComponents, OutputPixelType * outputData, size_t size) { // equal weights for 2 components?? if (inputNumberOfComponents == 2) { InputPixelType * endInput = inputData + size * 2; while (inputData != endInput) { auto val = static_cast<OutputComponentType>(*inputData); auto alpha = static_cast<OutputComponentType>(*(inputData + 1)); inputData += 2; OutputConvertTraits::SetNthComponent(0, *outputData, val); OutputConvertTraits::SetNthComponent(1, *outputData, val); OutputConvertTraits::SetNthComponent(2, *outputData, val); OutputConvertTraits::SetNthComponent(3, *outputData, alpha); } } else { ptrdiff_t diff = inputNumberOfComponents - 4; InputPixelType * endInput = inputData + size * (size_t)inputNumberOfComponents; while (inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(1, *outputData, static_cast<OutputComponentType>(*(inputData + 1))); OutputConvertTraits::SetNthComponent(2, *outputData, static_cast<OutputComponentType>(*(inputData + 2))); OutputConvertTraits::SetNthComponent(3, *outputData, static_cast<OutputComponentType>(*(inputData + 3))); inputData += 4; inputData += diff; outputData++; } } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertTensor6ToTensor6( InputPixelType * inputData, OutputPixelType * outputData, size_t size) { for (size_t i = 0; i < size; ++i) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(1, *outputData, static_cast<OutputComponentType>(*(inputData + 1))); OutputConvertTraits::SetNthComponent(2, *outputData, static_cast<OutputComponentType>(*(inputData + 2))); OutputConvertTraits::SetNthComponent(3, *outputData, static_cast<OutputComponentType>(*(inputData + 3))); OutputConvertTraits::SetNthComponent(4, *outputData, static_cast<OutputComponentType>(*(inputData + 4))); OutputConvertTraits::SetNthComponent(5, *outputData, static_cast<OutputComponentType>(*(inputData + 5))); ++outputData; inputData += 6; } } // Convert Grayscale to Complex template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertGrayToComplex( InputPixelType * inputData, OutputPixelType * outputData, size_t size) { InputPixelType * endInput = inputData + size; while (inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(1, *outputData, static_cast<OutputComponentType>(*inputData)); inputData++; outputData++; } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertComplexToComplex( InputPixelType * inputData, OutputPixelType * outputData, size_t size) { InputPixelType * endInput = inputData + size * 2; while (inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(1, *outputData, static_cast<OutputComponentType>(*(inputData + 1))); inputData += 2; outputData++; } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertTensor9ToTensor6( InputPixelType * inputData, OutputPixelType * outputData, size_t size) { for (size_t i = 0; i < size; ++i) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(1, *outputData, static_cast<OutputComponentType>(*(inputData + 1))); OutputConvertTraits::SetNthComponent(2, *outputData, static_cast<OutputComponentType>(*(inputData + 2))); OutputConvertTraits::SetNthComponent(3, *outputData, static_cast<OutputComponentType>(*(inputData + 4))); OutputConvertTraits::SetNthComponent(4, *outputData, static_cast<OutputComponentType>(*(inputData + 5))); OutputConvertTraits::SetNthComponent(5, *outputData, static_cast<OutputComponentType>(*(inputData + 8))); ++outputData; inputData += 9; } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertMultiComponentToComplex( InputPixelType * inputData, int inputNumberOfComponents, OutputPixelType * outputData, size_t size) { ptrdiff_t diff = inputNumberOfComponents - 2; InputPixelType * endInput = inputData + size * (size_t)inputNumberOfComponents; while (inputData != endInput) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); OutputConvertTraits::SetNthComponent(1, *outputData, static_cast<OutputComponentType>(*(inputData + 1))); inputData += 2; inputData += diff; outputData++; } } template <typename InputPixelType, typename OutputPixelType, typename OutputConvertTraits> void ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::ConvertVectorImage( InputPixelType * inputData, int inputNumberOfComponents, OutputPixelType * outputData, size_t size) { size_t length = size * (size_t)inputNumberOfComponents; for (size_t i = 0; i < length; ++i) { OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData)); ++outputData; ++inputData; } } } // end namespace itk #endif
39.561258
120
0.670475
jond01
33b14adf56d17d2402ebe668b7e63522721a6d99
35,998
cpp
C++
TEDStore/src/client/chunker.cpp
jingwei87/ted
112ec68b33fd00b4adb89c99af2fe94a9376da47
[ "MIT" ]
4
2020-03-04T18:36:23.000Z
2021-06-11T10:25:25.000Z
TEDStore/src/client/chunker.cpp
jingwei87/ted
112ec68b33fd00b4adb89c99af2fe94a9376da47
[ "MIT" ]
null
null
null
TEDStore/src/client/chunker.cpp
jingwei87/ted
112ec68b33fd00b4adb89c99af2fe94a9376da47
[ "MIT" ]
3
2020-11-22T23:29:52.000Z
2021-11-05T14:00:29.000Z
#include "chunker.hpp" #include "sys/time.h" extern Configure config; struct timeval timestartChunker; struct timeval timeendChunker; struct timeval timestartChunker_VarSizeInsert; struct timeval timeendChunker_VarSizeInsert; struct timeval timestartChunker_VarSizeHash; struct timeval timeendChunker_VarSizeHash; uint32_t DivCeil(uint32_t a, uint32_t b) { uint32_t tmp = a / b; if (a % b == 0) { return tmp; } else { return (tmp + 1); } } uint32_t CompareLimit(uint32_t input, uint32_t lower, uint32_t upper) { if (input <= lower) { return lower; } else if (input >= upper) { return upper; } else { return input; } } Chunker::Chunker(std::string path, keyClient* keyClientObjTemp) { loadChunkFile(path); ChunkerInit(path); cryptoObj = new CryptoPrimitive(); keyClientObj = keyClientObjTemp; } Chunker::~Chunker() { if (powerLUT != NULL) { delete powerLUT; } if (removeLUT != NULL) { delete removeLUT; } if (waitingForChunkingBuffer != NULL) { delete waitingForChunkingBuffer; } if (chunkBuffer != NULL) { delete chunkBuffer; } if (cryptoObj != NULL) { delete cryptoObj; } if (chunkingFile.is_open()) { chunkingFile.close(); } } std::ifstream& Chunker::getChunkingFile() { if (!chunkingFile.is_open()) { cerr << "Chunker : chunking file open failed" << endl; exit(1); } return chunkingFile; } void Chunker::loadChunkFile(std::string path) { if (chunkingFile.is_open()) { chunkingFile.close(); } chunkingFile.open(path, std::ios::binary); if (!chunkingFile.is_open()) { cerr << "Chunker : open file: " << path << "error, client exit now" << endl; exit(1); } } void Chunker::ChunkerInit(string path) { u_char filePathHash[FILE_NAME_HASH_SIZE]; cryptoObj->generateHash((u_char*)&path[0], path.length(), filePathHash); memcpy(fileRecipe.recipe.fileRecipeHead.fileNameHash, filePathHash, FILE_NAME_HASH_SIZE); memcpy(fileRecipe.recipe.keyRecipeHead.fileNameHash, filePathHash, FILE_NAME_HASH_SIZE); ChunkerType = (int)config.getChunkingType(); if (ChunkerType == CHUNKER_VAR_SIZE_TYPE) { int numOfMaskBits; avgChunkSize = (int)config.getAverageChunkSize(); minChunkSize = (int)config.getMinChunkSize(); maxChunkSize = (int)config.getMaxChunkSize(); slidingWinSize = (int)config.getSlidingWinSize(); ReadSize = config.getReadSize(); ReadSize = ReadSize * 1024 * 1024; waitingForChunkingBuffer = new u_char[ReadSize]; chunkBuffer = new u_char[maxChunkSize]; if (waitingForChunkingBuffer == NULL || chunkBuffer == NULL) { cerr << "Chunker : Memory malloc error" << endl; exit(1); } if (minChunkSize >= avgChunkSize) { cerr << "Chunker : minChunkSize should be smaller than avgChunkSize!" << endl; exit(1); } if (maxChunkSize <= avgChunkSize) { cerr << "Chunker : maxChunkSize should be larger than avgChunkSize!" << endl; exit(1); } /*initialize the base and modulus for calculating the fingerprint of a window*/ /*these two values were employed in open-vcdiff: "http://code.google.com/p/open-vcdiff/"*/ polyBase = 257; /*a prime larger than 255, the max value of "unsigned char"*/ polyMOD = (1 << 23) - 1; /*polyMOD - 1 = 0x7fffff: use the last 23 bits of a polynomial as its hash*/ /*initialize the lookup table for accelerating the power calculation in rolling hash*/ powerLUT = (uint32_t*)malloc(sizeof(uint32_t) * slidingWinSize); /*powerLUT[i] = power(polyBase, i) mod polyMOD*/ powerLUT[0] = 1; for (int i = 1; i < slidingWinSize; i++) { /*powerLUT[i] = (powerLUT[i-1] * polyBase) mod polyMOD*/ powerLUT[i] = (powerLUT[i - 1] * polyBase) & polyMOD; } /*initialize the lookup table for accelerating the byte remove in rolling hash*/ removeLUT = (uint32_t*)malloc(sizeof(uint32_t) * 256); /*256 for unsigned char*/ for (int i = 0; i < 256; i++) { /*removeLUT[i] = (- i * powerLUT[_slidingWinSize-1]) mod polyMOD*/ removeLUT[i] = (i * powerLUT[slidingWinSize - 1]) & polyMOD; if (removeLUT[i] != 0) { removeLUT[i] = (polyMOD - removeLUT[i] + 1) & polyMOD; } /*note: % is a remainder (rather than modulus) operator*/ /* if a < 0, -polyMOD < a % polyMOD <= 0 */ } /*initialize the anchorMask for depolytermining an anchor*/ /*note: power(2, numOfanchorMaskBits) = avgChunkSize*/ numOfMaskBits = 1; while ((avgChunkSize >> numOfMaskBits) != 1) { numOfMaskBits++; } anchorMask = (1 << numOfMaskBits) - 1; /*initialize the value for depolytermining an anchor*/ anchorValue = 0; } else if (ChunkerType == CHUNKER_FIX_SIZE_TYPE) { avgChunkSize = (int)config.getAverageChunkSize(); minChunkSize = (int)config.getMinChunkSize(); maxChunkSize = (int)config.getMaxChunkSize(); ReadSize = config.getReadSize(); ReadSize = ReadSize * 1024 * 1024; waitingForChunkingBuffer = new u_char[ReadSize]; chunkBuffer = new u_char[avgChunkSize]; if (waitingForChunkingBuffer == NULL || chunkBuffer == NULL) { cerr << "Chunker : Memory Error" << endl; exit(1); } if (minChunkSize != avgChunkSize || maxChunkSize != avgChunkSize) { cerr << "Chunker : Error: minChunkSize and maxChunkSize should be same in fixed size mode!" << endl; exit(1); } if (ReadSize % avgChunkSize != 0) { cerr << "Chunker : Setting fixed size chunking error : ReadSize not compat with average chunk size" << endl; } } else if (ChunkerType == CHUNKER_FAST_CDC) { avgChunkSize = (int)config.getAverageChunkSize(); minChunkSize = (int)config.getMinChunkSize(); maxChunkSize = (int)config.getMaxChunkSize(); ReadSize = config.getReadSize(); ReadSize = ReadSize * 1024 * 1024; waitingForChunkingBuffer = new u_char[ReadSize]; chunkBuffer = new u_char[maxChunkSize]; if (waitingForChunkingBuffer == NULL || chunkBuffer == NULL) { cerr << "Chunker : Memory malloc error" << endl; exit(1); } if (minChunkSize >= avgChunkSize) { cerr << "Chunker : minChunkSize should be smaller than avgChunkSize!" << endl; exit(1); } if (maxChunkSize <= avgChunkSize) { cerr << "Chunker : maxChunkSize should be larger than avgChunkSize!" << endl; exit(1); } normalSize_ = calNormalSize(minChunkSize, avgChunkSize, maxChunkSize); uint32_t bits = (uint32_t) round(log2(static_cast<double>(avgChunkSize))); maskS_ = generateFastCDCMask(bits + 1); maskL_ = generateFastCDCMask(bits - 1); } else if (ChunkerType == CHUNKER_FIX_SIZE_TYPE) { avgChunkSize = (int)config.getAverageChunkSize(); minChunkSize = (int)config.getMinChunkSize(); maxChunkSize = (int)config.getMaxChunkSize(); ReadSize = config.getReadSize(); ReadSize = ReadSize * 1024 * 1024; waitingForChunkingBuffer = new u_char[ReadSize]; chunkBuffer = new u_char[avgChunkSize]; if (waitingForChunkingBuffer == NULL || chunkBuffer == NULL) { cerr << "Chunker : Memory Error" << endl; exit(1); } if (minChunkSize != avgChunkSize || maxChunkSize != avgChunkSize) { cerr << "Chunker : Error: minChunkSize and maxChunkSize should be same in fixed size mode!" << endl; exit(1); } if (ReadSize % avgChunkSize != 0) { cerr << "Chunker : Setting fixed size chunking error : ReadSize not compat with average chunk size" << endl; } } else if (ChunkerType == CHUNKER_TRACE_DRIVEN_TYPE_FSL) { maxChunkSize = (int)config.getMaxChunkSize(); chunkBuffer = new u_char[maxChunkSize + 6]; } else if (ChunkerType == CHUNKER_TRACE_DRIVEN_TYPE_UBC) { maxChunkSize = (int)config.getMaxChunkSize(); chunkBuffer = new u_char[maxChunkSize + 5]; } else { cerr << "Chunker : Error chunker type.\n"; exit(1); } } bool Chunker::chunking() { /*fixed-size Chunker*/ if (ChunkerType == CHUNKER_FIX_SIZE_TYPE) { fixSizeChunking(); } /*variable-size Chunker*/ if (ChunkerType == CHUNKER_VAR_SIZE_TYPE) { varSizeChunking(); } if (ChunkerType == CHUNKER_TRACE_DRIVEN_TYPE_FSL) { traceDrivenChunkingFSL(); } if (ChunkerType == CHUNKER_TRACE_DRIVEN_TYPE_UBC) { traceDrivenChunkingUBC(); } if (ChunkerType == CHUNKER_FAST_CDC) { fastCDC(); } return true; } void Chunker::fixSizeChunking() { double chunkTime = 0; double hashTime = 0; long diff; double second; std::ifstream& fin = getChunkingFile(); uint64_t chunkIDCounter = 0; memset(chunkBuffer, 0, sizeof(char) * avgChunkSize); uint64_t fileSize = 0; u_char hash[CHUNK_HASH_SIZE]; /*start chunking*/ while (true) { memset((char*)waitingForChunkingBuffer, 0, sizeof(unsigned char) * ReadSize); fin.read((char*)waitingForChunkingBuffer, sizeof(char) * ReadSize); uint64_t totalReadSize = fin.gcount(); fileSize += totalReadSize; uint64_t chunkedSize = 0; if (totalReadSize == ReadSize) { while (chunkedSize < totalReadSize) { #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker, NULL); #endif memset(chunkBuffer, 0, sizeof(char) * avgChunkSize); memcpy(chunkBuffer, waitingForChunkingBuffer + chunkedSize, avgChunkSize); #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker, NULL); diff = 1000000 * (timeendChunker.tv_sec - timestartChunker.tv_sec) + timeendChunker.tv_usec - timestartChunker.tv_usec; second = diff / 1000000.0; chunkTime += second; #endif #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker, NULL); #endif if (!cryptoObj->generateHash(chunkBuffer, avgChunkSize, hash)) { cerr << "Chunker : fixed size chunking: compute hash error" << endl; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker, NULL); diff = 1000000 * (timeendChunker.tv_sec - timestartChunker.tv_sec) + timeendChunker.tv_usec - timestartChunker.tv_usec; second = diff / 1000000.0; hashTime += second; #endif Data_t tempChunk; tempChunk.chunk.ID = chunkIDCounter; tempChunk.chunk.logicDataSize = avgChunkSize; memcpy(tempChunk.chunk.logicData, chunkBuffer, avgChunkSize); memcpy(tempChunk.chunk.chunkHash, hash, CHUNK_HASH_SIZE); tempChunk.dataType = DATA_TYPE_CHUNK; insertMQToKeyClient(tempChunk); chunkIDCounter++; chunkedSize += avgChunkSize; } } else { uint64_t retSize = 0; while (chunkedSize < totalReadSize) { memset(chunkBuffer, 0, sizeof(char) * avgChunkSize); Data_t tempChunk; if (retSize > avgChunkSize) { #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker, NULL); #endif memcpy(chunkBuffer, waitingForChunkingBuffer + chunkedSize, avgChunkSize); #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker, NULL); diff = 1000000 * (timeendChunker.tv_sec - timestartChunker.tv_sec) + timeendChunker.tv_usec - timestartChunker.tv_usec; second = diff / 1000000.0; chunkTime += second; #endif #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker, NULL); #endif if (!cryptoObj->generateHash(chunkBuffer, avgChunkSize, hash)) { cerr << "Chunker : fixed size chunking: compute hash error" << endl; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker, NULL); diff = 1000000 * (timeendChunker.tv_sec - timestartChunker.tv_sec) + timeendChunker.tv_usec - timestartChunker.tv_usec; second = diff / 1000000.0; hashTime += second; #endif tempChunk.chunk.ID = chunkIDCounter; tempChunk.chunk.logicDataSize = avgChunkSize; memcpy(tempChunk.chunk.logicData, chunkBuffer, avgChunkSize); memcpy(tempChunk.chunk.chunkHash, hash, CHUNK_HASH_SIZE); } else { #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker, NULL); #endif memcpy(chunkBuffer, waitingForChunkingBuffer + chunkedSize, retSize); #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker, NULL); diff = 1000000 * (timeendChunker.tv_sec - timestartChunker.tv_sec) + timeendChunker.tv_usec - timestartChunker.tv_usec; second = diff / 1000000.0; chunkTime += second; #endif #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker, NULL); #endif if (!cryptoObj->generateHash(chunkBuffer, retSize, hash)) { cerr << "Chunker : fixed size chunking: compute hash error" << endl; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker, NULL); diff = 1000000 * (timeendChunker.tv_sec - timestartChunker.tv_sec) + timeendChunker.tv_usec - timestartChunker.tv_usec; second = diff / 1000000.0; hashTime += second; #endif tempChunk.chunk.ID = chunkIDCounter; tempChunk.chunk.logicDataSize = retSize; memcpy(tempChunk.chunk.logicData, chunkBuffer, retSize); memcpy(tempChunk.chunk.chunkHash, hash, CHUNK_HASH_SIZE); } retSize = totalReadSize - chunkedSize; tempChunk.dataType = DATA_TYPE_CHUNK; insertMQToKeyClient(tempChunk); chunkIDCounter++; chunkedSize += avgChunkSize; } } if (fin.eof()) { break; } } fileRecipe.recipe.fileRecipeHead.totalChunkNumber = chunkIDCounter; fileRecipe.recipe.keyRecipeHead.totalChunkKeyNumber = chunkIDCounter; fileRecipe.recipe.fileRecipeHead.fileSize = fileSize; fileRecipe.recipe.keyRecipeHead.fileSize = fileRecipe.recipe.fileRecipeHead.fileSize; fileRecipe.dataType = DATA_TYPE_RECIPE; insertMQToKeyClient(fileRecipe); if (setJobDoneFlag() == false) { cerr << "Chunker : set chunking done flag error" << endl; } cout << "Chunker : Fixed chunking over:\nTotal file size = " << fileRecipe.recipe.fileRecipeHead.fileSize << "; Total chunk number = " << fileRecipe.recipe.fileRecipeHead.totalChunkNumber << endl; #if SYSTEM_BREAK_DOWN == 1 cout << "Chunker : total chunking time = " << chunkTime << " s" << endl; cout << "Chunker : total hashing time = " << hashTime << " s" << endl; #endif } void Chunker::traceDrivenChunkingFSL() { double chunkTime = 0; double hashTime = 0; long diff; double second; std::ifstream& fin = getChunkingFile(); uint64_t chunkIDCounter = 0; uint64_t fileSize = 0; u_char hash[CHUNK_HASH_SIZE]; char readLineBuffer[256]; string readLineStr; /*start chunking*/ getline(fin, readLineStr); while (true) { getline(fin, readLineStr); if (fin.eof()) { break; } memset(readLineBuffer, 0, 256); memcpy(readLineBuffer, (char*)readLineStr.c_str(), readLineStr.length()); #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker, NULL); #endif u_char chunkFp[7]; memset(chunkFp, 0, 7); char* item; item = strtok(readLineBuffer, ":\t\n "); for (int index = 0; item != NULL && index < 6; index++) { chunkFp[index] = strtol(item, NULL, 16); item = strtok(NULL, ":\t\n"); } chunkFp[6] = '\0'; auto size = atoi(item); int copySize = 0; memset(chunkBuffer, 0, sizeof(char) * maxChunkSize + 6); if (size > maxChunkSize) { continue; } while (copySize < size) { memcpy(chunkBuffer + copySize, chunkFp, 6); copySize += 6; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker, NULL); diff = 1000000 * (timeendChunker.tv_sec - timestartChunker.tv_sec) + timeendChunker.tv_usec - timestartChunker.tv_usec; second = diff / 1000000.0; chunkTime += second; #endif #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker, NULL); #endif if (!cryptoObj->generateHash(chunkBuffer, size, hash)) { cerr << "Chunker : trace driven chunking: compute hash error" << endl; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker, NULL); diff = 1000000 * (timeendChunker.tv_sec - timestartChunker.tv_sec) + timeendChunker.tv_usec - timestartChunker.tv_usec; second = diff / 1000000.0; hashTime += second; #endif Data_t tempChunk; tempChunk.chunk.ID = chunkIDCounter; tempChunk.chunk.logicDataSize = size; memcpy(tempChunk.chunk.logicData, chunkBuffer, size); memcpy(tempChunk.chunk.chunkHash, hash, CHUNK_HASH_SIZE); tempChunk.dataType = DATA_TYPE_CHUNK; insertMQToKeyClient(tempChunk); chunkIDCounter++; fileSize += size; } fileRecipe.recipe.fileRecipeHead.totalChunkNumber = chunkIDCounter; fileRecipe.recipe.keyRecipeHead.totalChunkKeyNumber = chunkIDCounter; fileRecipe.recipe.fileRecipeHead.fileSize = fileSize; fileRecipe.recipe.keyRecipeHead.fileSize = fileRecipe.recipe.fileRecipeHead.fileSize; fileRecipe.dataType = DATA_TYPE_RECIPE; insertMQToKeyClient(fileRecipe); if (setJobDoneFlag() == false) { cerr << "Chunker : set chunking done flag error" << endl; } cout << "Chunker : trace gen over:\nTotal file size = " << fileRecipe.recipe.fileRecipeHead.fileSize << "; Total chunk number = " << fileRecipe.recipe.fileRecipeHead.totalChunkNumber << endl; #if SYSTEM_BREAK_DOWN == 1 cout << "Chunker : total chunking time = " << chunkTime << " s" << endl; cout << "Chunker : total hashing time = " << hashTime << " s" << endl; #endif } void Chunker::traceDrivenChunkingUBC() { double chunkTime = 0; double hashTime = 0; long diff; double second; std::ifstream& fin = getChunkingFile(); uint64_t chunkIDCounter = 0; uint64_t fileSize = 0; u_char hash[CHUNK_HASH_SIZE]; char readLineBuffer[256]; string readLineStr; /*start chunking*/ getline(fin, readLineStr); while (true) { getline(fin, readLineStr); if (fin.eof()) { break; } memset(readLineBuffer, 0, 256); memcpy(readLineBuffer, (char*)readLineStr.c_str(), readLineStr.length()); #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker, NULL); #endif u_char chunkFp[6]; memset(chunkFp, 0, 6); char* item; item = strtok(readLineBuffer, ":\t\n "); for (int index = 0; item != NULL && index < 5; index++) { chunkFp[index] = strtol(item, NULL, 16); item = strtok(NULL, ":\t\n"); } chunkFp[5] = '\0'; auto size = atoi(item); int copySize = 0; memset(chunkBuffer, 0, sizeof(char) * maxChunkSize + 5); if (size > maxChunkSize) { continue; } while (copySize < size) { memcpy(chunkBuffer + copySize, chunkFp, 5); copySize += 5; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker, NULL); diff = 1000000 * (timeendChunker.tv_sec - timestartChunker.tv_sec) + timeendChunker.tv_usec - timestartChunker.tv_usec; second = diff / 1000000.0; chunkTime += second; #endif #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker, NULL); #endif if (!cryptoObj->generateHash(chunkBuffer, size, hash)) { cerr << "Chunker : trace driven chunking: compute hash error" << endl; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker, NULL); diff = 1000000 * (timeendChunker.tv_sec - timestartChunker.tv_sec) + timeendChunker.tv_usec - timestartChunker.tv_usec; second = diff / 1000000.0; hashTime += second; #endif Data_t tempChunk; tempChunk.chunk.ID = chunkIDCounter; tempChunk.chunk.logicDataSize = size; memcpy(tempChunk.chunk.logicData, chunkBuffer, size); memcpy(tempChunk.chunk.chunkHash, hash, CHUNK_HASH_SIZE); tempChunk.dataType = DATA_TYPE_CHUNK; insertMQToKeyClient(tempChunk); chunkIDCounter++; fileSize += size; } fileRecipe.recipe.fileRecipeHead.totalChunkNumber = chunkIDCounter; fileRecipe.recipe.keyRecipeHead.totalChunkKeyNumber = chunkIDCounter; fileRecipe.recipe.fileRecipeHead.fileSize = fileSize; fileRecipe.recipe.keyRecipeHead.fileSize = fileRecipe.recipe.fileRecipeHead.fileSize; fileRecipe.dataType = DATA_TYPE_RECIPE; insertMQToKeyClient(fileRecipe); if (setJobDoneFlag() == false) { cerr << "Chunker : set chunking done flag error" << endl; } cout << "Chunker : trace gen over:\nTotal file size = " << fileRecipe.recipe.fileRecipeHead.fileSize << "; Total chunk number = " << fileRecipe.recipe.fileRecipeHead.totalChunkNumber << endl; #if SYSTEM_BREAK_DOWN == 1 cout << "Chunker : total chunking time = " << chunkTime << " s" << endl; cout << "Chunker : total hashing time = " << hashTime << " s" << endl; #endif } void Chunker::varSizeChunking() { double insertTime = 0; double hashTime = 0; long diff; double second; uint16_t winFp; uint64_t chunkBufferCnt = 0, chunkIDCnt = 0; ifstream& fin = getChunkingFile(); uint64_t fileSize = 0; u_char hash[CHUNK_HASH_SIZE]; /*start chunking*/ #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker, NULL); #endif while (true) { memset((char*)waitingForChunkingBuffer, 0, sizeof(unsigned char) * ReadSize); fin.read((char*)waitingForChunkingBuffer, sizeof(unsigned char) * ReadSize); int len = fin.gcount(); fileSize += len; for (int i = 0; i < len; i++) { chunkBuffer[chunkBufferCnt] = waitingForChunkingBuffer[i]; /*full fill sliding window*/ if (chunkBufferCnt < slidingWinSize) { winFp = winFp + (chunkBuffer[chunkBufferCnt] * powerLUT[slidingWinSize - chunkBufferCnt - 1]) & polyMOD; //Refer to doc/Chunking.md hash function:RabinChunker chunkBufferCnt++; continue; } winFp &= (polyMOD); /*slide window*/ unsigned short int v = chunkBuffer[chunkBufferCnt - slidingWinSize]; //queue winFp = ((winFp + removeLUT[v]) * polyBase + chunkBuffer[chunkBufferCnt]) & polyMOD; //remove queue front and add queue tail chunkBufferCnt++; /*chunk's size less than minChunkSize*/ if (chunkBufferCnt < minChunkSize) continue; /*find chunk pattern*/ if ((winFp & anchorMask) == anchorValue) { #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker_VarSizeHash, NULL); #endif if (!cryptoObj->generateHash(chunkBuffer, chunkBufferCnt, hash)) { cerr << "Chunker : average size chunking compute hash error" << endl; return; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker_VarSizeHash, NULL); diff = 1000000 * (timeendChunker_VarSizeHash.tv_sec - timestartChunker_VarSizeHash.tv_sec) + timeendChunker_VarSizeHash.tv_usec - timestartChunker_VarSizeHash.tv_usec; second = diff / 1000000.0; hashTime += second; #endif Data_t tempChunk; tempChunk.chunk.ID = chunkIDCnt; tempChunk.chunk.logicDataSize = chunkBufferCnt; memcpy(tempChunk.chunk.logicData, chunkBuffer, chunkBufferCnt); memcpy(tempChunk.chunk.chunkHash, hash, CHUNK_HASH_SIZE); tempChunk.dataType = DATA_TYPE_CHUNK; #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker_VarSizeInsert, NULL); #endif if (!insertMQToKeyClient(tempChunk)) { cerr << "Chunker : error insert chunk to keyClient message queue for chunk ID = " << tempChunk.chunk.ID << endl; return; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker_VarSizeInsert, NULL); diff = 1000000 * (timeendChunker_VarSizeInsert.tv_sec - timestartChunker_VarSizeInsert.tv_sec) + timeendChunker_VarSizeInsert.tv_usec - timestartChunker_VarSizeInsert.tv_usec; second = diff / 1000000.0; insertTime += second; #endif chunkIDCnt++; chunkBufferCnt = winFp = 0; } /*chunk's size exceed maxChunkSize*/ if (chunkBufferCnt >= maxChunkSize) { #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker_VarSizeHash, NULL); #endif if (!cryptoObj->generateHash(chunkBuffer, chunkBufferCnt, hash)) { cerr << "Chunker : average size chunking compute hash error" << endl; return; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker_VarSizeHash, NULL); diff = 1000000 * (timeendChunker_VarSizeHash.tv_sec - timestartChunker_VarSizeHash.tv_sec) + timeendChunker_VarSizeHash.tv_usec - timestartChunker_VarSizeHash.tv_usec; second = diff / 1000000.0; hashTime += second; #endif Data_t tempChunk; tempChunk.chunk.ID = chunkIDCnt; tempChunk.chunk.logicDataSize = chunkBufferCnt; memcpy(tempChunk.chunk.logicData, chunkBuffer, chunkBufferCnt); memcpy(tempChunk.chunk.chunkHash, hash, CHUNK_HASH_SIZE); tempChunk.dataType = DATA_TYPE_CHUNK; #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker_VarSizeInsert, NULL); #endif if (!insertMQToKeyClient(tempChunk)) { cerr << "Chunker : error insert chunk to keyClient message queue for chunk ID = " << tempChunk.chunk.ID << endl; return; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker_VarSizeInsert, NULL); diff = 1000000 * (timeendChunker_VarSizeInsert.tv_sec - timestartChunker_VarSizeInsert.tv_sec) + timeendChunker_VarSizeInsert.tv_usec - timestartChunker_VarSizeInsert.tv_usec; second = diff / 1000000.0; insertTime += second; #endif chunkIDCnt++; chunkBufferCnt = winFp = 0; } } if (fin.eof()) { break; } } /*add final chunk*/ if (chunkBufferCnt != 0) { #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker_VarSizeHash, NULL); #endif if (!cryptoObj->generateHash(chunkBuffer, chunkBufferCnt, hash)) { cerr << "Chunker : average size chunking compute hash error" << endl; return; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker_VarSizeHash, NULL); diff = 1000000 * (timeendChunker_VarSizeHash.tv_sec - timestartChunker_VarSizeHash.tv_sec) + timeendChunker_VarSizeHash.tv_usec - timestartChunker_VarSizeHash.tv_usec; second = diff / 1000000.0; hashTime += second; #endif Data_t tempChunk; tempChunk.chunk.ID = chunkIDCnt; tempChunk.chunk.logicDataSize = chunkBufferCnt; memcpy(tempChunk.chunk.logicData, chunkBuffer, chunkBufferCnt); memcpy(tempChunk.chunk.chunkHash, hash, CHUNK_HASH_SIZE); tempChunk.dataType = DATA_TYPE_CHUNK; #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker_VarSizeInsert, NULL); #endif if (!insertMQToKeyClient(tempChunk)) { cerr << "Chunker : error insert chunk to keyClient message queue for chunk ID = " << tempChunk.chunk.ID << endl; return; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker_VarSizeInsert, NULL); diff = 1000000 * (timeendChunker_VarSizeInsert.tv_sec - timestartChunker_VarSizeInsert.tv_sec) + timeendChunker_VarSizeInsert.tv_usec - timestartChunker_VarSizeInsert.tv_usec; second = diff / 1000000.0; insertTime += second; #endif chunkIDCnt++; chunkBufferCnt = winFp = 0; } fileRecipe.recipe.fileRecipeHead.totalChunkNumber = chunkIDCnt; fileRecipe.recipe.keyRecipeHead.totalChunkKeyNumber = chunkIDCnt; fileRecipe.recipe.fileRecipeHead.fileSize = fileSize; fileRecipe.recipe.keyRecipeHead.fileSize = fileRecipe.recipe.fileRecipeHead.fileSize; fileRecipe.dataType = DATA_TYPE_RECIPE; if (!insertMQToKeyClient(fileRecipe)) { cerr << "Chunker : error insert recipe head to keyClient message queue" << endl; return; } if (setJobDoneFlag() == false) { cerr << "Chunker: set chunking done flag error" << endl; return; } cout << "Chunker : variable size chunking over:\nTotal file size = " << fileRecipe.recipe.fileRecipeHead.fileSize << "; Total chunk number = " << fileRecipe.recipe.fileRecipeHead.totalChunkNumber << endl; #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker, NULL); diff = 1000000 * (timeendChunker.tv_sec - timestartChunker.tv_sec) + timeendChunker.tv_usec - timestartChunker.tv_usec; second = diff / 1000000.0; cout << "Chunker : total chunking time = " << setbase(10) << second - (insertTime + hashTime) << " s" << endl; cout << "Chunker : total hashing time = " << hashTime << " s" << endl; #endif return; } bool Chunker::insertMQToKeyClient(Data_t& newData) { return keyClientObj->insertMQFromChunker(newData); } bool Chunker::setJobDoneFlag() { return keyClientObj->editJobDoneFlag(); } uint32_t Chunker::cutPoint(const uint8_t* src, const uint32_t len) { uint32_t n; uint32_t fp = 0; uint32_t i; i = std::min(len, static_cast<uint32_t>(minChunkSize)); n = std::min(normalSize_, len); for (; i < n; i++) { fp = (fp >> 1) + GEAR[src[i]]; if (!(fp & maskS_)) { return (i + 1); } } n = std::min(static_cast<uint32_t>(maxChunkSize), len); for (; i < n; i++) { fp = (fp >> 1) + GEAR[src[i]]; if (!(fp & maskL_)) { return (i + 1); } } return i; } void Chunker::fastCDC() { double insertTime = 0; double hashTime = 0; long diff; double second; size_t pos = 0; ifstream& fin = getChunkingFile(); uint64_t fileSize = 0; uint64_t chunkIDCnt = 0; size_t totalOffset = 0; bool end = false; /*start chunking*/ #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker, NULL); #endif while (!end) { memset((char*)waitingForChunkingBuffer, 0, sizeof(uint8_t) * ReadSize); fin.read((char*)waitingForChunkingBuffer, sizeof(uint8_t) * ReadSize); end = fin.eof(); size_t len = fin.gcount(); fprintf(stderr, "Chunker: len: %lu\n", len); size_t localOffset = 0; while (((len - localOffset) >= maxChunkSize) || (end && (localOffset < len))) { uint32_t cp = cutPoint(waitingForChunkingBuffer + localOffset, len - localOffset); Data_t tempChunk; tempChunk.chunk.ID = chunkIDCnt; tempChunk.chunk.logicDataSize = cp; memcpy(tempChunk.chunk.logicData, waitingForChunkingBuffer + localOffset, cp); tempChunk.dataType = DATA_TYPE_CHUNK; #if SYSTEM_BREAK_DOWN==1 gettimeofday(&timestartChunker_VarSizeHash, NULL); #endif if (!cryptoObj->generateHash(tempChunk.chunk.logicData, tempChunk.chunk.logicDataSize, tempChunk.chunk.chunkHash)) { cerr << "Chunker : average size chunking compute hash error" << endl; return; } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker_VarSizeHash, NULL); diff = 1000000 * (timeendChunker_VarSizeHash.tv_sec - timestartChunker_VarSizeHash.tv_sec) + timeendChunker_VarSizeHash.tv_usec - timestartChunker_VarSizeHash.tv_usec; second = diff / 1000000.0; hashTime += second; #endif #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timestartChunker_VarSizeInsert, NULL); #endif if (!insertMQToKeyClient(tempChunk)) { fprintf(stderr, "Chunker, error insert chunk to FPWorker MQ for chunkID: %u.\n", tempChunk.chunk.ID); } #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker_VarSizeInsert, NULL); diff = 1000000 * (timeendChunker_VarSizeInsert.tv_sec - timestartChunker_VarSizeInsert.tv_sec) + timeendChunker_VarSizeInsert.tv_usec - timestartChunker_VarSizeInsert.tv_usec; second = diff / 1000000.0; insertTime += second; #endif localOffset += cp; fileSize += cp; chunkIDCnt++; } pos += localOffset; totalOffset += localOffset; fin.seekg(totalOffset, std::ios_base::beg); } fileRecipe.recipe.fileRecipeHead.totalChunkNumber = chunkIDCnt; fileRecipe.recipe.keyRecipeHead.totalChunkKeyNumber = chunkIDCnt; fileRecipe.recipe.fileRecipeHead.fileSize = fileSize; fileRecipe.recipe.keyRecipeHead.fileSize = fileSize; fileRecipe.dataType = DATA_TYPE_RECIPE; if (!insertMQToKeyClient(fileRecipe)) { cerr << "Chunker : error insert recipe head to keyClient message queue" << endl; return; } if (setJobDoneFlag() == false) { cerr << "Chunker: set chunking done flag error" << endl; return; } cout << "Chunker : variable size chunking over:\nTotal file size = " << fileRecipe.recipe.fileRecipeHead.fileSize << "; Total chunk number = " << fileRecipe.recipe.fileRecipeHead.totalChunkNumber << endl; #if SYSTEM_BREAK_DOWN == 1 gettimeofday(&timeendChunker, NULL); diff = 1000000 * (timeendChunker.tv_sec - timestartChunker.tv_sec) + timeendChunker.tv_usec - timestartChunker.tv_usec; second = diff / 1000000.0; cout << "Chunker : total chunking time = " << setbase(10) << second - (insertTime + hashTime) << " s" << endl; cout << "Chunker : total hashing time = " << hashTime << " s" << endl; #endif return ; } uint32_t Chunker::calNormalSize(const uint32_t min, const uint32_t av, const uint32_t max) { uint32_t off = min + DivCeil(min, 2); if (off > av) { off = av; } uint32_t diff = av - off; if (diff > max) { return max; } return diff; } uint32_t Chunker::generateFastCDCMask(uint32_t bits) { uint32_t tmp; tmp = (1 << CompareLimit(bits, 1, 31)) - 1; return tmp; }
39.689085
208
0.617201
jingwei87
33b44f8e28ed0adc0ab594d2485f0e2d63b25e6e
8,664
cpp
C++
libs/base/src/utils/CMHPropertiesValuesList.cpp
tg1716/SLAM
b8583fb98a4241d87ae08ac78b0420c154f5e1a5
[ "BSD-3-Clause" ]
4
2017-08-04T15:44:04.000Z
2021-02-02T02:00:18.000Z
libs/base/src/utils/CMHPropertiesValuesList.cpp
tg1716/SLAM
b8583fb98a4241d87ae08ac78b0420c154f5e1a5
[ "BSD-3-Clause" ]
null
null
null
libs/base/src/utils/CMHPropertiesValuesList.cpp
tg1716/SLAM
b8583fb98a4241d87ae08ac78b0420c154f5e1a5
[ "BSD-3-Clause" ]
2
2017-10-03T23:10:09.000Z
2018-07-29T09:41:33.000Z
/* +------------------------------------------------------------------------+ | Mobile Robot Programming Toolkit (MRPT) | | http://www.mrpt.org/ | | | | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file | | See: http://www.mrpt.org/Authors - All rights reserved. | | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ #include "base-precomp.h" // Precompiled headers #include <mrpt/utils/CMHPropertiesValuesList.h> #include <mrpt/system/os.h> #include <stdio.h> using namespace mrpt::utils; using namespace mrpt::system; // This must be added to any CSerializable class implementation file. IMPLEMENTS_SERIALIZABLE(CMHPropertiesValuesList, CSerializable, mrpt::utils) /*--------------------------------------------------------------- writeToStream ---------------------------------------------------------------*/ void CMHPropertiesValuesList::writeToStream( mrpt::utils::CStream& out, int* out_Version) const { if (out_Version) *out_Version = 0; else { uint32_t i, n = (uint32_t)m_properties.size(); uint8_t isNull; out << n; for (i = 0; i < n; i++) { // Name: out << m_properties[i].name.c_str(); // Object: isNull = !m_properties[i].value; out << isNull; if (!isNull) out << *m_properties[i].value; // Hypot. ID: out << m_properties[i].ID; } } } /*--------------------------------------------------------------- readFromStream ---------------------------------------------------------------*/ void CMHPropertiesValuesList::readFromStream( mrpt::utils::CStream& in, int version) { switch (version) { case 0: { uint32_t i, n; uint8_t isNull; // Erase previous contents: clear(); in >> n; m_properties.resize(n); for (i = 0; i < n; i++) { char nameBuf[1024]; // Name: in >> nameBuf; m_properties[i].name = nameBuf; // Object: in >> isNull; if (isNull) m_properties[i].value.reset(); else in >> m_properties[i].value; // Hypot. ID: in >> m_properties[i].ID; } } break; default: MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(version) }; } /*--------------------------------------------------------------- Constructor ---------------------------------------------------------------*/ CMHPropertiesValuesList::CMHPropertiesValuesList() {} /*--------------------------------------------------------------- Destructor ---------------------------------------------------------------*/ CMHPropertiesValuesList::~CMHPropertiesValuesList() { clear(); } /*--------------------------------------------------------------- clear ---------------------------------------------------------------*/ void CMHPropertiesValuesList::clear() { MRPT_START m_properties.clear(); MRPT_END } /*--------------------------------------------------------------- get ---------------------------------------------------------------*/ CSerializable::Ptr CMHPropertiesValuesList::get( const char* propertyName, const int64_t& hypothesis_ID) const { std::vector<TPropertyValueIDTriplet>::const_iterator it; for (it = m_properties.begin(); it != m_properties.end(); ++it) if (!os::_strcmpi(propertyName, it->name.c_str()) && it->ID == hypothesis_ID) return it->value; for (it = m_properties.begin(); it != m_properties.end(); ++it) if (!os::_strcmpi(propertyName, it->name.c_str()) && it->ID == 0) return it->value; // Not found: return CSerializable::Ptr(); } /*--------------------------------------------------------------- getAnyHypothesis ---------------------------------------------------------------*/ CSerializable::Ptr CMHPropertiesValuesList::getAnyHypothesis( const char* propertyName) const { for (std::vector<TPropertyValueIDTriplet>::const_iterator it = m_properties.begin(); it != m_properties.end(); ++it) { if (!os::_strcmpi(propertyName, it->name.c_str())) return it->value; } // Not found: return CSerializable::Ptr(); } /*--------------------------------------------------------------- set ---------------------------------------------------------------*/ void CMHPropertiesValuesList::set( const char* propertyName, const CSerializable::Ptr& obj, const int64_t& hypothesis_ID) { MRPT_START for (std::vector<TPropertyValueIDTriplet>::iterator it = m_properties.begin(); it != m_properties.end(); ++it) { if (it->ID == hypothesis_ID && !os::_strcmpi(propertyName, it->name.c_str())) { // Delete current contents: // Copy new value: it->value.reset(dynamic_cast<CSerializable*>(obj->clone())); // if (!obj) it->value.clear(); // else it->value = obj; //->clone(); return; } } // Insert: TPropertyValueIDTriplet newPair; newPair.name = std::string(propertyName); newPair.value = obj; newPair.ID = hypothesis_ID; m_properties.push_back(newPair); MRPT_END_WITH_CLEAN_UP( printf("Exception while setting annotation '%s'", propertyName);); } /*--------------------------------------------------------------- setMemoryReference ---------------------------------------------------------------*/ void CMHPropertiesValuesList::setMemoryReference( const char* propertyName, const CSerializable::Ptr& obj, const int64_t& hypothesis_ID) { MRPT_START for (std::vector<TPropertyValueIDTriplet>::iterator it = m_properties.begin(); it != m_properties.end(); ++it) { if (it->ID == hypothesis_ID && !os::_strcmpi(propertyName, it->name.c_str())) { // Delete current contents & set a copy of the same smart pointer: it->value = obj; return; } } // Insert: TPropertyValueIDTriplet newPair; newPair.name = std::string(propertyName); newPair.value = obj; newPair.ID = hypothesis_ID; m_properties.push_back(newPair); MRPT_END_WITH_CLEAN_UP( printf("Exception while setting annotation '%s'", propertyName);); } /*--------------------------------------------------------------- getPropertyNames ---------------------------------------------------------------*/ std::vector<std::string> CMHPropertiesValuesList::getPropertyNames() const { std::vector<std::string> ret; for (std::vector<TPropertyValueIDTriplet>::const_iterator it = m_properties.begin(); it != m_properties.end(); ++it) { bool isNew = true; for (std::vector<std::string>::iterator itS = ret.begin(); itS != ret.end(); ++itS) { if ((*itS) == it->name) { isNew = false; break; } } if (isNew) ret.push_back(it->name); // Yes, it is new: } return ret; } /*--------------------------------------------------------------- remove ---------------------------------------------------------------*/ void CMHPropertiesValuesList::remove( const char* propertyName, const int64_t& hypothesis_ID) { for (std::vector<TPropertyValueIDTriplet>::iterator it = m_properties.begin(); it != m_properties.end();) if (!os::_strcmpi(propertyName, it->name.c_str()) && it->ID == hypothesis_ID) it = m_properties.erase(it); else ++it; } /*--------------------------------------------------------------- removeAll ---------------------------------------------------------------*/ void CMHPropertiesValuesList::removeAll(const int64_t& hypothesis_ID) { for (std::vector<TPropertyValueIDTriplet>::iterator it = m_properties.begin(); it != m_properties.end();) if (it->ID == hypothesis_ID) it = m_properties.erase(it); else ++it; } /*--------------------------------------------------------------- Copy ---------------------------------------------------------------*/ CMHPropertiesValuesList::CMHPropertiesValuesList( const CMHPropertiesValuesList& o) : m_properties(o.m_properties) { for (std::vector<TPropertyValueIDTriplet>::iterator it = m_properties.begin(); it != m_properties.end(); ++it) it->value.reset(dynamic_cast<CSerializable*>(it->value->clone())); } /*--------------------------------------------------------------- Copy ---------------------------------------------------------------*/ CMHPropertiesValuesList& CMHPropertiesValuesList::operator=( const CMHPropertiesValuesList& o) { if (this == &o) return *this; m_properties = o.m_properties; for (std::vector<TPropertyValueIDTriplet>::iterator it = m_properties.begin(); it != m_properties.end(); ++it) it->value.reset(dynamic_cast<CSerializable*>(it->value->clone())); return *this; }
28.221498
80
0.504386
tg1716
33b6d91d17d429a0ffd4bc42d00634c77a91956e
1,647
hpp
C++
generator/maxspeeds_builder.hpp
kudlav/organicmaps
390236365749e0525b9229684132c2888d11369d
[ "Apache-2.0" ]
4,879
2015-09-30T10:56:36.000Z
2022-03-31T18:43:03.000Z
generator/maxspeeds_builder.hpp
mbrukman/omim
d22fe2b6e0beee697f096e931df97a64f9db9dc1
[ "Apache-2.0" ]
7,549
2015-09-30T10:52:53.000Z
2022-03-31T22:04:22.000Z
generator/maxspeeds_builder.hpp
mbrukman/omim
d22fe2b6e0beee697f096e931df97a64f9db9dc1
[ "Apache-2.0" ]
1,493
2015-09-30T10:43:06.000Z
2022-03-21T09:16:49.000Z
#pragma once #include "routing_common/maxspeed_conversion.hpp" #include "platform/measurement_utils.hpp" #include "base/geo_object_id.hpp" #include <cstdint> #include <map> #include <string> #include <vector> namespace routing { using OsmIdToMaxspeed = std::map<base::GeoObjectId, Maxspeed>; /// \brief Parses csv file with path |maxspeedsFilename| and stores the result in |osmIdToMaxspeed|. /// \note There's a detailed description of the csv file in generator/maxspeed_collector.hpp. bool ParseMaxspeeds(std::string const & maxspeedsFilename, OsmIdToMaxspeed & osmIdToMaxspeed); /// \brief Writes |speeds| to maxspeeds section to mwm with |dataPath|. void SerializeMaxspeeds(std::string const & dataPath, std::vector<FeatureMaxspeed> && speeds); void BuildMaxspeedsSection(std::string const & dataPath, std::map<uint32_t, base::GeoObjectId> const & featureIdToOsmId, std::string const & maxspeedsFilename); /// \brief Builds maxspeeds section in mwm with |dataPath|. This section contains max speed limits /// if they are available in file |maxspeedsFilename|. /// \param maxspeedsFilename file name to csv file with maxspeed tag values. /// \note To start building the section, the following steps should be done: /// 1. Calls GenerateIntermediateData(). It stores data about maxspeed tags value of road features // to a csv file. /// 2. Calls GenerateFeatures() /// 3. Generates geometry. void BuildMaxspeedsSection(std::string const & dataPath, std::string const & osmToFeaturePath, std::string const & maxspeedsFilename); } // namespace routing
41.175
100
0.730419
kudlav
33b9d1f934c771c9a9298b4390ca08c246303577
9,199
cpp
C++
MavLinkCom/src/impl/AdHocConnectionImpl.cpp
jeyong/AirSim
1fd6a3fc311c704bbbb0b2b6b245e8fa0ba26c8b
[ "MIT" ]
8
2018-06-13T08:44:13.000Z
2020-06-29T06:43:31.000Z
MavLinkCom/src/impl/AdHocConnectionImpl.cpp
jeyong/AirSim
1fd6a3fc311c704bbbb0b2b6b245e8fa0ba26c8b
[ "MIT" ]
4
2018-05-08T20:40:25.000Z
2018-10-22T13:02:19.000Z
MavLinkCom/src/impl/AdHocConnectionImpl.cpp
jeyong/AirSim
1fd6a3fc311c704bbbb0b2b6b245e8fa0ba26c8b
[ "MIT" ]
5
2018-06-28T13:05:31.000Z
2021-02-04T12:44:53.000Z
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "AdHocConnectionImpl.hpp" #include "Utils.hpp" #include "ThreadUtils.hpp" #include "../serial_com/Port.h" #include "../serial_com/SerialPort.hpp" #include "../serial_com/UdpClientPort.hpp" #include "../serial_com/TcpClientPort.hpp" using namespace mavlink_utils; using namespace mavlinkcom_impl; AdHocConnectionImpl::AdHocConnectionImpl() { closed = true; ::memset(&mavlink_intermediate_status_, 0, sizeof(mavlink_status_t)); ::memset(&mavlink_status_, 0, sizeof(mavlink_status_t)); } std::string AdHocConnectionImpl::getName() { return name; } AdHocConnectionImpl::~AdHocConnectionImpl() { con_.reset(); close(); } std::shared_ptr<AdHocConnection> AdHocConnectionImpl::createConnection(const std::string& nodeName, std::shared_ptr<Port> port) { // std::shared_ptr<MavLinkCom> owner, const std::string& nodeName std::shared_ptr<AdHocConnection> con = std::make_shared<AdHocConnection>(); con->startListening(nodeName, port); return con; } std::shared_ptr<AdHocConnection> AdHocConnectionImpl::connectLocalUdp(const std::string& nodeName, std::string localAddr, int localPort) { std::shared_ptr<UdpClientPort> socket = std::make_shared<UdpClientPort>(); socket->connect(localAddr, localPort, "", 0); return createConnection(nodeName, socket); } std::shared_ptr<AdHocConnection> AdHocConnectionImpl::connectRemoteUdp(const std::string& nodeName, std::string localAddr, std::string remoteAddr, int remotePort) { std::string local = localAddr; // just a little sanity check on the local address, if remoteAddr is localhost then localAddr must be also. if (remoteAddr == "127.0.0.1") { local = "127.0.0.1"; } std::shared_ptr<UdpClientPort> socket = std::make_shared<UdpClientPort>(); socket->connect(local, 0, remoteAddr, remotePort); return createConnection(nodeName, socket); } std::shared_ptr<AdHocConnection> AdHocConnectionImpl::connectTcp(const std::string& nodeName, std::string localAddr, const std::string& remoteIpAddr, int remotePort) { std::string local = localAddr; // just a little sanity check on the local address, if remoteAddr is localhost then localAddr must be also. if (remoteIpAddr == "127.0.0.1") { local = "127.0.0.1"; } std::shared_ptr<TcpClientPort> socket = std::make_shared<TcpClientPort>(); socket->connect(local, 0, remoteIpAddr, remotePort); return createConnection(nodeName, socket); } std::shared_ptr<AdHocConnection> AdHocConnectionImpl::connectSerial(const std::string& nodeName, std::string name, int baudRate, const std::string initString) { std::shared_ptr<SerialPort> serial = std::make_shared<SerialPort>(); int hr = serial->connect(name.c_str(), baudRate); if (hr != 0) throw std::runtime_error(Utils::stringf("Could not open the serial port %s, error=%d", name.c_str(), hr)); // send this right away just in case serial link is not already configured if (initString.size() > 0) { serial->write(reinterpret_cast<const uint8_t*>(initString.c_str()), static_cast<int>(initString.size())); } return createConnection(nodeName, serial); } void AdHocConnectionImpl::startListening(std::shared_ptr<AdHocConnection> parent, const std::string& nodeName, std::shared_ptr<Port> connectedPort) { name = nodeName; con_ = parent; close(); closed = false; port = connectedPort; Utils::cleanupThread(read_thread); read_thread = std::thread{ &AdHocConnectionImpl::readPackets, this }; Utils::cleanupThread(publish_thread_); publish_thread_ = std::thread{ &AdHocConnectionImpl::publishPackets, this }; } void AdHocConnectionImpl::close() { closed = true; if (port != nullptr) { port->close(); port = nullptr; } if (read_thread.joinable()) { read_thread.join(); } if (publish_thread_.joinable()) { msg_available_.post(); publish_thread_.join(); } } bool AdHocConnectionImpl::isOpen() { return !closed; } int AdHocConnectionImpl::getTargetComponentId() { return this->other_component_id; } int AdHocConnectionImpl::getTargetSystemId() { return this->other_system_id; } void AdHocConnectionImpl::sendMessage(const std::vector<uint8_t>& msg) { if (closed) { return; } try { port->write(msg.data(), static_cast<int>(msg.size())); } catch (std::exception& e) { throw std::runtime_error(Utils::stringf("AdHocConnectionImpl: Error sending message on connection '%s', details: %s", name.c_str(), e.what())); } } int AdHocConnectionImpl::subscribe(AdHocMessageHandler handler) { MessageHandlerEntry entry = { static_cast<int>(listeners.size() + 1), handler = handler }; std::lock_guard<std::mutex> guard(listener_mutex); listeners.push_back(entry); snapshot_stale = true; return entry.id; } void AdHocConnectionImpl::unsubscribe(int id) { std::lock_guard<std::mutex> guard(listener_mutex); for (auto ptr = listeners.begin(), end = listeners.end(); ptr != end; ptr++) { if ((*ptr).id == id) { listeners.erase(ptr); snapshot_stale = true; break; } } } void AdHocConnectionImpl::readPackets() { //CurrentThread::setMaximumPriority(); std::shared_ptr<Port> safePort = this->port; const int MAXBUFFER = 512; uint8_t* buffer = new uint8_t[MAXBUFFER]; int channel = 0; int hr = 0; while (hr == 0 && con_ != nullptr && !closed) { int read = 0; if (safePort->isClosed()) { // hmmm, wait till it is opened? std::this_thread::sleep_for(std::chrono::milliseconds(10)); continue; } int count = safePort->read(buffer, MAXBUFFER); if (count <= 0) { // error? well let's try again, but we should be careful not to spin too fast and kill the CPU std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } if (count >= MAXBUFFER) { std::cerr << "GAH KM911 message size (" << std::to_string(count) << ") is bigger than max buffer size! Time to support frame breaks, Moffitt" << std::endl; // error? well let's try again, but we should be careful not to spin too fast and kill the CPU std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } // queue event for publishing. { std::lock_guard<std::mutex> guard(msg_queue_mutex_); std::vector<uint8_t> message(count); memcpy(message.data(), buffer, count); msg_queue_.push(message); } if (waiting_for_msg_) { msg_available_.post(); } } //while delete[] buffer; } //readPackets void AdHocConnectionImpl::drainQueue() { std::vector<uint8_t> message; bool hasMsg = true; while (hasMsg) { hasMsg = false; { std::lock_guard<std::mutex> guard(msg_queue_mutex_); if (!msg_queue_.empty()) { message = msg_queue_.front(); msg_queue_.pop(); hasMsg = true; } } if (!hasMsg) { return; } // publish the message from this thread, this is safer than publishing from the readPackets thread // as it ensures we don't lose messages if the listener is slow. if (snapshot_stale) { // this is tricky, the clear has to be done outside the lock because it is destructing the handlers // and the handler might try and call unsubscribe, which needs to be able to grab the lock, otherwise // we would get a deadlock. snapshot.clear(); std::lock_guard<std::mutex> guard(listener_mutex); snapshot = listeners; snapshot_stale = false; } auto end = snapshot.end(); auto startTime = std::chrono::system_clock::now(); std::shared_ptr<AdHocConnection> sharedPtr = std::shared_ptr<AdHocConnection>(this->con_); for (auto ptr = snapshot.begin(); ptr != end; ptr++) { try { (*ptr).handler(sharedPtr, message); } catch (std::exception& e) { Utils::log(Utils::stringf("AdHocConnectionImpl: Error handling message on connection '%s', details: %s", name.c_str(), e.what()), Utils::kLogLevelError); } } } } void AdHocConnectionImpl::publishPackets() { //CurrentThread::setMaximumPriority(); while (!closed) { drainQueue(); waiting_for_msg_ = true; msg_available_.wait(); waiting_for_msg_ = false; } }
31.83045
168
0.618437
jeyong
33bce9c40270adb9d2ef0ac5de01957f887e7b72
521
hpp
C++
SimipleNetworkProtocol/src/PeriodicExecutor.hpp
DrLk/MultiThreaded-Socket
54d0b4b7c99cf0eeed7c6182501778f1e4a35333
[ "Apache-2.0" ]
null
null
null
SimipleNetworkProtocol/src/PeriodicExecutor.hpp
DrLk/MultiThreaded-Socket
54d0b4b7c99cf0eeed7c6182501778f1e4a35333
[ "Apache-2.0" ]
null
null
null
SimipleNetworkProtocol/src/PeriodicExecutor.hpp
DrLk/MultiThreaded-Socket
54d0b4b7c99cf0eeed7c6182501778f1e4a35333
[ "Apache-2.0" ]
null
null
null
#pragma once #include <chrono> #include <functional> namespace FastTransport::Protocol { class PeriodicExecutor { public: PeriodicExecutor(std::function<void()>, const std::chrono::microseconds& interval); void Run(); private: using clock = std::chrono::steady_clock; std::function<void()> _function; std::chrono::microseconds _interval; std::chrono::microseconds _start; clock::time_point _end; void RunFunction(); }; } // namespace FastTransport::Protocol
20.84
88
0.675624
DrLk
33be1b92715b0dce2bcc58a0178894f7b6dbf2e1
34,188
hpp
C++
lib/gpc/buffer.hpp
bamert/openGPC
ac61f9b0420ddf42bae02a7b9366f3744906cc72
[ "BSD-3-Clause" ]
8
2019-02-13T10:47:28.000Z
2020-09-26T02:36:26.000Z
lib/gpc/buffer.hpp
bamert/openGPC
ac61f9b0420ddf42bae02a7b9366f3744906cc72
[ "BSD-3-Clause" ]
1
2019-05-30T13:39:07.000Z
2020-08-25T09:03:05.000Z
lib/gpc/buffer.hpp
bamert/openGPC
ac61f9b0420ddf42bae02a7b9366f3744906cc72
[ "BSD-3-Clause" ]
3
2020-04-16T06:05:20.000Z
2020-10-28T14:18:06.000Z
// Copyright (c) 2018, ETH Zurich // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its contributors // may be used to endorse or promote products derived from this software without // specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // // Code Author: Niklaus Bamert (bamertn@ethz.ch) #ifndef __NDB_BUFFER #define __NDB_BUFFER #include <vector> #include <png.h> #include <Eigen/Dense> #include <type_traits> using namespace std; namespace ndb { struct RGBColor { uint8_t b, g, r; RGBColor(uint8_t r, uint8_t g, uint8_t b) : r(r), g(g), b(b) {} RGBColor(png_byte* ptr) { this->r = ptr[0]; this->g = ptr[1]; this->b = ptr[2]; } RGBColor() {}; }; struct Point { int x, y; Point(int x, int y) : x(x), y(y) {} Point() {}; }; struct Descriptor { Point point; uint64_t state; bool srcDescr = false; //indicates if this is a descriptor from the source or from the target set Descriptor(ndb::Point point, uint64_t state) : point(point), state(state) {} Descriptor() {}; //ops for sorting and comparing descriptors for matching bool operator==( const Descriptor &d ) const { if (state == d.state ) return true; return false; } //Checks if two descriptors are from different images bool diffImgs(const Descriptor &d) { if (srcDescr != d.srcDescr) return true; return false; } bool operator!=( const Descriptor &d ) const { if (state != d.state) return true; return false; } bool operator<( const Descriptor &d ) const { return state < d.state; } bool operator<=( const Descriptor &d ) const { return state <= d.state; } int operator%( const int &d ) const { return state % d; } }; //Keeps support points with associated disparity //Support points are only used in the left image struct Support { int x, y; float d; Support(int x, int y, float d) : x(x), y(y), d(d) {} Support(int x, int y) : x(x), y(y), d(0.) {} Support() {}; }; // Keeps correspondences in case of non-epipolar matching scenario struct Correspondence{ Point srcPt, tarPt; Correspondence(Point srcPt, Point tarPt) : srcPt(srcPt), tarPt(tarPt) {} }; //The Cg matrix elements used in Disparity Refinement struct ConfidentSupport { int x, y, cost; float d; ConfidentSupport() {}; ConfidentSupport(int x, int y, float d, int cost ) : x(x), y(y), d(d), cost(cost) {} }; struct InvalidMatch { int x, y, cost; InvalidMatch() { cost = 0;}; InvalidMatch(int x, int y, int cost) : x(x), y(y), cost(cost) {} }; struct Triangle { int v1, v2, v3; Triangle(int v1, int v2, int v3) : v1(v1), v2(v2), v3(v3) {} }; struct Edge { Support a, b; Edge(Support& a, Support& b) { if (a.y < b.y) { this->a = a; this->b = b; } else { this->a = b; this->b = a; } } }; struct Span { int x1, x2; Span(int x1, int x2) : x1(x1), x2(x2) {} }; struct Dimension { int w, h; Dimension(int w, int h): w(w), h(h) {} }; #define ALIGN16(X) (X%16) == 0 ? X :((X/16)+1)*16 template<class T> class __attribute__((aligned(32), packed)) Buffer : public Eigen::Array<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> { //The actual height and width of the image. public: int width; int height; EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef Eigen::Array<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> Base; Buffer(const int r, const int c) : Base(r, ALIGN16(c)) { this->width = c; this->height = r; } Buffer(const int r, const int c, T color) : Base(r, ALIGN16(c)) { this->width = c; this->height = r; T *ptr = reinterpret_cast<T *>(Base::data()); for (int i = 0; i < Base::cols()*Base::rows(); i++) { *ptr = color; ptr++; } } //Create new buffer from two side by side Buffer(Buffer& i1, Buffer& i2) : Base(i1.rows(), i1.cols() + i2.cols()) { for (int x = 0; x < i1.cols(); x++) { for (int y = 0; y < i1.rows(); y++) { setPixel(x, y, i1.getPixel(x, y)); setPixel(x + i1.cols(), y, i2.getPixel(x, y)); } } this->height = Base::rows(); this->width = Base::cols(); } Buffer(const Eigen::Vector2i &size = Eigen::Vector2i(0, 0)) : Base(size.y(), ALIGN16(size.x())) { this->width = size.x(); this->height = size.y(); } Buffer(const Eigen::Vector2i &size , T color) : Base(size.y(), ALIGN16(size.x())) { this->width = size.x(); this->height = size.y(); T *ptr = reinterpret_cast<T *>(Base::data()); for (int i = 0; i < Base::cols()*Base::rows(); i++) { *ptr = color; ptr++; } } // original sources provided by Guillaume Cottenceau under the X11 license // from http://zarb.org/~gc/html/libpng.html int readPNG(std::string filename) { unsigned char header[8]; // 8 is the maximum size that can be checked png_byte colorType; png_byte bitDepth; png_structp pngPtr; png_infop infoPtr; png_bytep * rowPointers; // open file and test for it being a png FILE *fp = fopen(filename.c_str(), "rb"); if (!fp) { cout << "ERR: File" << filename << " could not be opened for reading" << endl; return 1; } size_t res = fread(header, 1, 8, fp); if (png_sig_cmp(header, 0, 8)) { cout << "ERR: File" << filename << " is not recognized as a PNG file" << endl; return 1; } // initialize stuff pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!pngPtr) { cout << "ERR: png_create_read_struct failed" << endl; return 1; } infoPtr = png_create_info_struct(pngPtr); if (!infoPtr) { cout << "ERR: png_create_info_struct failed" << endl; return 1; } if (setjmp(png_jmpbuf(pngPtr))) { cout << "ERR: Error during init_io" << endl; return 1; } png_init_io(pngPtr, fp); png_set_sig_bytes(pngPtr, 8); png_read_info(pngPtr, infoPtr); this->width = png_get_image_width(pngPtr, infoPtr); this->height = png_get_image_height(pngPtr, infoPtr); colorType = png_get_color_type(pngPtr, infoPtr); bitDepth = png_get_bit_depth(pngPtr, infoPtr); //We will do a conservative resize after reading in the data, //such that we don't have to translate addresses ourselves Base::resize(this->height, this->width); int numberOfPasses = png_set_interlace_handling(pngPtr); png_read_update_info(pngPtr, infoPtr); // read file if (setjmp(png_jmpbuf(pngPtr))) { cout << "ERR: Error during read_image" << endl; return 1; } rowPointers = (png_bytep*) malloc(sizeof(png_bytep) * height); for (int y = 0; y < height; y++) rowPointers[y] = (png_byte*) malloc(png_get_rowbytes(pngPtr, infoPtr)); png_read_image(pngPtr, rowPointers); fclose(fp); //Read image into buffer (row-major) int nChannels; switch (png_get_color_type(pngPtr, infoPtr)) { case PNG_COLOR_TYPE_GRAY: nChannels = 1; break; case PNG_COLOR_TYPE_RGB: nChannels = 3; break; case PNG_COLOR_TYPE_RGBA: nChannels = 4; break; default: nChannels = 0; break; } T *ptr = reinterpret_cast<T *>(Base::data()); if (bitDepth == 16) { for (int y = 0; y < this->height; y++) { png_byte* row = rowPointers[y]; for (int x = 0; x < this->width; x++) { int val = ((int)row[x * 2] << 8) + row[x * 2 + 1]; *ptr = val; ptr++; } } } else { for (int y = 0; y < this->height; y++) { png_byte* row = rowPointers[y]; for (int x = 0; x < this->width; x++) { int offset = y * this->width + x; if ( nChannels == 1 ) { *ptr = row[x]; ptr++; } else if (nChannels == 3) { //convert to grayscale if color *ptr = (row[3 * x] + row[3 * x + 1] + row[3 * x + 2]) / 3; ptr++; } } } } //Conservative resize of underlying matrix to align with 16 byte boundary Base::conservativeResize(this->height, ALIGN16(this->width)); if (nChannels == 0 || nChannels == 4) { cout << "ERR: found something other than gray or 3 channel color image(" << int(png_get_color_type(pngPtr, infoPtr)) << ") aborting!" << endl; return 1; } for (int y = 0; y < this->height; y++) free(rowPointers[y]); free(rowPointers); return 0; } void writePNG(std::string filename) { png_byte colorType = PNG_COLOR_TYPE_GRAY; int nChannels = 1; png_byte bitDepth = 8; png_structp pngPtr; png_infop infoPtr; png_bytep * rowPointers; //Copy Image matrix such that we can do a conservative resize to its correct size Base img = *this; img.conservativeResize(this->height, this->width); FILE *fp = fopen(filename.c_str(), "wb"); if (!fp) cout << "ERR: File" << filename << " could not be opened for writing" << endl; // init pngPtr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!pngPtr) cout << "ERR: png_create_write_struct failed" << endl; infoPtr = png_create_info_struct(pngPtr); if (!infoPtr) cout << "ERR: png_create_info_struct failed" << endl; if (setjmp(png_jmpbuf(pngPtr))) cout << "ERR: Error during init_io" << endl; png_init_io(pngPtr, fp); // write header if (setjmp(png_jmpbuf(pngPtr))) cout << "ERR: Error during writing header" << endl; png_set_IHDR(pngPtr, infoPtr, img.cols(), img.rows(), bitDepth, colorType, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); png_write_info(pngPtr, infoPtr); // write bytes if (setjmp(png_jmpbuf(pngPtr))) cout << "ERR: Error during writing bytes" << endl; //Allocate row pointers rowPointers = (png_bytep*) malloc(sizeof(png_bytep) * img.rows()); for (int y = 0; y < img.rows(); y++) rowPointers[y] = (png_byte*) malloc(png_get_rowbytes(pngPtr, infoPtr)); T *ptr = reinterpret_cast<T *>(img.data()); //Copy our data from std::vector into allocated memory region for (int y = 0; y < img.rows(); y++) { png_byte* row = rowPointers[y]; for (int x = 0; x < img.cols(); x++) { int offset; offset = y * img.cols() + x; row[x * nChannels] = ptr[offset]; } } png_write_image(pngPtr, rowPointers); // end write if (setjmp(png_jmpbuf(pngPtr))) cout << "ERR: Error during end of write" << endl; png_write_end(pngPtr, NULL); for (int y = 0; y < img.rows(); y++) free(rowPointers[y]); free(rowPointers); fclose(fp); } void writePNGRGB(std::string filename) { png_byte colorType = PNG_COLOR_TYPE_RGB; int nChannels = 3; png_byte bitDepth = 8; png_structp pngPtr; png_infop infoPtr; png_bytep * rowPointers; //Make copy of self that we can resize to actual size Base img = *this; img.conservativeResize(this->height, this->width); // create file FILE *fp = fopen(filename.c_str(), "wb"); if (!fp) cout << "ERR: File" << filename << " could not be opened for writing" << endl; // initialize stuff pngPtr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!pngPtr) cout << "ERR: png_create_write_struct failed" << endl; infoPtr = png_create_info_struct(pngPtr); if (!infoPtr) cout << "ERR: png_create_info_struct failed" << endl; if (setjmp(png_jmpbuf(pngPtr))) cout << "ERR: Error during init_io" << endl; png_init_io(pngPtr, fp); // write header if (setjmp(png_jmpbuf(pngPtr))) cout << "ERR: Error during writing header" << endl; png_set_IHDR(pngPtr, infoPtr, img.cols(), img.rows(), bitDepth, colorType, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); png_write_info(pngPtr, infoPtr); // write bytes if (setjmp(png_jmpbuf(pngPtr))) cout << "ERR: Error during writing bytes" << endl; // Allocate row pointers rowPointers = (png_bytep*) malloc(sizeof(png_bytep) * img.rows()); for (int y = 0; y < img.rows(); y++) rowPointers[y] = (png_byte*) malloc(png_get_rowbytes(pngPtr, infoPtr)); T *ptr = reinterpret_cast<T *>(img.data()); //Copy our data from std::vector into allocated memory region for (int y = 0; y < img.rows(); y++) { png_byte* row = rowPointers[y]; for (int x = 0; x < img.cols(); x++) { int offset; offset = y * img.cols() + x; row[x * nChannels] = ptr[offset].r; row[x * nChannels + 1] = ptr[offset].g; row[x * nChannels + 2] = ptr[offset].b; } } png_write_image(pngPtr, rowPointers); // end write if (setjmp(png_jmpbuf(pngPtr))) cout << "ERR: Error during end of write" << endl; png_write_end(pngPtr, NULL); // cleanup heap allocation for (int y = 0; y < img.rows(); y++) free(rowPointers[y]); free(rowPointers); fclose(fp); } /** * @brief "Unsafe" but fast pixel set method (no dimension check. If you write * outside the bounds, it'll segfault!) * * @param[in] x { parameter_description } * @param[in] y { parameter_description } */ void setPixel(int x, int y, T color) { T *ptr = reinterpret_cast<T *>(Base::data()); *(ptr + Base::cols()*y + x) = color; } /** * @brief Set all values in matrix to same value * * @param[in] color The color */ void set(T color) { T *ptr = reinterpret_cast<T *>(Base::data()); int size = Base::cols() * Base::rows(); for (int i = 0; i < size; i++) { *ptr = color; ptr++; } } /** * @brief Gets the pixel. * * @param[in] x { parameter_description } * @param[in] y { parameter_description } * * @return The pixel. */ T getPixel(int x, int y) { T *ptr = reinterpret_cast<T *>(Base::data()); return *(ptr + Base::cols() * y + x); } /** * @brief Gets the pixel. Const method overload for calls from GPC. * * @param[in] x { parameter_description } * @param[in] y { parameter_description } * * @return The pixel. */ T getPixel(int x, int y) const { T *ptr = const_cast<T *>(Base::data()); return *(ptr + Base::cols() * y + x); } /** * @brief Gets a patch from the buffer * * @param[in] x { parameter_description } * @param[in] y { parameter_description } * @param[in] size The size * * @return The patch. */ void getPatch(ndb::Buffer<uint8_t>& patch, int x, int y, int size) { patch.resize(size, size); //extract patch for (int ix = 0; ix < size; ix++) { for (int iy = 0; iy < size; iy++) { patch(ix, iy) = getPixel(x + ix - (size / 2), y + iy - (size / 2)); } } } Dimension getDimension() { return Dimension(Base::cols(), Base::rows()); } /** * @brief Draws a line. * * @param a { parameter_description } * @param b { parameter_description } * @param[in] color The color */ void drawLine(Support& a, Support& b, T color) { float xdiff = (b.x - a.x); float ydiff = (b.y - a.y); if (xdiff == 0.0f && ydiff == 0.0f) { setPixel(a.x, a.y, color); return; } if (fabs(xdiff) > fabs(ydiff)) { float xmin, xmax; // set xmin to the lower x value given // and xmax to the higher value if (a.x < b.x) { xmin = a.x; xmax = b.x; } else { xmin = b.x; xmax = a.x; } // draw line in terms of y slope float slope = ydiff / xdiff; for (float x = xmin; x <= xmax; x += 1.0f) { float y = a.y + ((x - a.x) * slope); setPixel(x, y, color); } } else { float ymin, ymax; // set ymin to the lower y value given // and ymax to the higher value if (a.y < b.y) { ymin = a.y; ymax = b.y; } else { ymin = b.y; ymax = a.y; } // draw line in terms of x slope float slope = xdiff / ydiff; for (float y = ymin; y <= ymax; y += 1.0f) { float x = a.x + ((y - a.y) * slope); setPixel(x, y, color); } } } void drawLine(Point& a, Point& b, T color) { Support aa(a.x, a.y, 0), bb(b.x, b.y, 0); drawLine(aa, bb, color); } void drawLine(Point a, Point b, T color) { Support aa(a.x, a.y, 0), bb(b.x, b.y, 0); drawLine(aa, bb, color); } /** * @brief Draws a span. * * @param[in] span The span * @param[in] y * @param color The color */ void drawSpan(const Span& span, int y, T& color) { int xdiff = span.x2 - span.x1; if (xdiff == 0) { return; } for (int x = span.x1; x < span.x2; x++) setPixel(x, y, color); } void clearBoundary() { T *ptr = reinterpret_cast<T *>(Base::data()); //Dimension of the (visible) image int h = this->height; int w = this->width; //Width of 16-aligned container int waligned = this->cols(); //first 2 columns contains invalid data -> set them zero. for (int x = 0; x < 2; x++) { for (int y = 0; y < h; y++) { ptr[y * waligned + x] = 0x00; } } //first row for (int x = 0; x < w; x++) ptr[x] = 0x00; //last two rowsrow for (int x = 0; x < w; x++) for (int y = h - 2; y < h; y++) ptr[y * waligned + x] = 0x00; //last column for (int y = 0; y < h; y++) ptr[y * waligned + (waligned - 1)] = 0x00; } /** * @brief Draws spans between edges. * modified from * https://github.com/joshb/triangleraster * @param[in] e1 The e 1 (long edge) * @param[in] e2 The e 2 (short edge) */ void drawSpansBetweenEdges(const Edge &e1, const Edge &e2, T& color) { // calculate difference between the y coordinates // of the first edge and return if 0 float e1ydiff = (float)(e1.b.y - e1.a.y); if (e1ydiff == 0.0f) { return; } // calculate difference between the y coordinates // of the second edge and return if 0 float e2ydiff = (float)(e2.b.y - e2.a.y); if (e2ydiff == 0.0f) { return; } // calculate differences between the x coordinates float e1xdiff = (float)(e1.b.x - e1.a.x); float e2xdiff = (float)(e2.b.x - e2.a.x); // calculate factors to use for interpolation // with the edges and the step values to increase // them by after drawing each span float factor1 = (float)(e2.a.y - e1.a.y) / e1ydiff; float factorStep1 = 1.0f / e1ydiff; float factor2 = 0.0f; float factorStep2 = 1.0f / e2ydiff; // loop through the lines between the edges and draw spans for (int y = e2.a.y; y < e2.b.y; y++) { // create and draw span Span span(e1.a.x + (int)(e1xdiff * factor1), e2.a.x + (int)(e2xdiff * factor2)); if (span.x1 > span.x2) std::swap(span.x1, span.x2); drawSpan(span, y, color); // increase factors factor1 += factorStep1; factor2 += factorStep2; } } /** * @brief Draw a triangle from three vertices and fill it. modified from * https://github.com/joshb/triangleraster * released under BSD licence * * @param a { parameter_description } * @param b { parameter_description } * @param c { parameter_description } * @param[in] color The color */ void fillTriangle(Support a, Support b, Support c, T color) { // create edges for the triangle Edge edges[3] = { Edge(a, b), Edge(b, c), Edge(c, a) }; int maxLength = 0; int longEdge = 0; // find edge with the greatest length in the y axis for (int i = 0; i < 3; i++) { int length = edges[i].b.y - edges[i].a.y; if (length > maxLength) { maxLength = length; longEdge = i; } } int shortEdge1 = (longEdge + 1) % 3; int shortEdge2 = (longEdge + 2) % 3; // draw spans between edges; the long edge can be drawn // with the shorter edges to draw the full triangle drawSpansBetweenEdges(edges[longEdge], edges[shortEdge1], color); drawSpansBetweenEdges(edges[longEdge], edges[shortEdge2], color); } /** * @brief Draws a triangle. * * @param a { parameter_description } * @param b { parameter_description } * @param c { parameter_description } * @param[in] color The color */ void drawTriangle(Support& a, Support& b, Support& c, T color) { drawLine(a, b, color); drawLine(b, c, color); drawLine(c, a, color); } Buffer<RGBColor> convertToRGB() { Buffer<RGBColor> out(Eigen::Vector2i(Base::cols(), Base::rows())); T *ptr = reinterpret_cast<T *>(Base::data()); int width = Base::cols(); int height = Base::rows(); out.width = this->width; //should fail graciously if heights incompatible for (int y = 0; y < height; y++) { for (int x = 0; x < width ; x++) { out(y, x) = ndb::RGBColor(*ptr, *ptr, *ptr); ptr++; } } return out; } }; class RGBBuffer : public Buffer<RGBColor>{ public: RGBBuffer(){ } int readPNGRGB(std::string filename) { unsigned char header[8]; // 8 is the maximum size that can be checked png_byte colorType; png_byte bitDepth; png_structp pngPtr; png_infop infoPtr; png_bytep * rowPointers; // open file and test for it being a png FILE *fp = fopen(filename.c_str(), "rb"); if (!fp) { cout << "ERR: File" << filename << " could not be opened for reading" << endl; return 1; } size_t res = fread(header, 1, 8, fp); if (png_sig_cmp(header, 0, 8)) { cout << "ERR: File" << filename << " is not recognized as a PNG file" << endl; return 1; } pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!pngPtr) { cout << "ERR: png_create_read_struct failed" << endl; return 1; } infoPtr = png_create_info_struct(pngPtr); if (!infoPtr) { cout << "ERR: png_create_info_struct failed" << endl; return 1; } if (setjmp(png_jmpbuf(pngPtr))) { cout << "ERR: Error during init_io" << endl; return 1; } png_init_io(pngPtr, fp); png_set_sig_bytes(pngPtr, 8); png_read_info(pngPtr, infoPtr); this->width = png_get_image_width(pngPtr, infoPtr); this->height = png_get_image_height(pngPtr, infoPtr); colorType = png_get_color_type(pngPtr, infoPtr); bitDepth = png_get_bit_depth(pngPtr, infoPtr); //We will do a conservative resize after reading in the data, //such that we don't have to translate addresses ourselves Base::resize(this->height, this->width); png_read_update_info(pngPtr, infoPtr); if (setjmp(png_jmpbuf(pngPtr))) { cout << "ERR: Error during read_image" << endl; return 1; } rowPointers = (png_bytep*) malloc(sizeof(png_bytep) * height); for (int y = 0; y < height; y++) rowPointers[y] = (png_byte*) malloc(png_get_rowbytes(pngPtr, infoPtr)); png_read_image(pngPtr, rowPointers); fclose(fp); //Read image into buffer (row-major) int nChannels; switch (png_get_color_type(pngPtr, infoPtr)) { case PNG_COLOR_TYPE_GRAY: nChannels = 1; break; case PNG_COLOR_TYPE_RGB: nChannels = 3; break; case PNG_COLOR_TYPE_RGBA: nChannels = 4; break; default: nChannels = 0; break; } RGBColor *ptr = reinterpret_cast<RGBColor *>(Base::data()); if (bitDepth == 8) { if (nChannels == 3) for (int y = 0; y < this->height; y++) { png_byte* row = rowPointers[y]; for (int x = 0; x < this->width; x++) { int offset = y * this->cols() + x; ptr[offset] = RGBColor(row[3 * x], row[3 * x + 1], row[3 * x + 2]); } } } //Conservative resize of underlying matrix to align with 16 byte boundary Base::conservativeResize(this->height, ALIGN16(this->width)); if (nChannels == 0 || nChannels == 4) { cout << "ERR: found something other than gray or 3 channel color image(" << int(png_get_color_type(pngPtr, infoPtr)) << ") aborting!" << endl; return 1; } for (int y = 0; y < this->height; y++) free(rowPointers[y]); free(rowPointers); return 0; } }; Buffer<RGBColor> getDisparityVisualization(ndb::Buffer<uint8_t>& srcImg, std::vector<int>& validEstimateIndices, ndb::Buffer<float>& disparity) { float min_disparity = 0; float max_disparity = 128; Buffer<RGBColor> dispVis(Eigen::Vector2i(srcImg.width, srcImg.rows())); for(int x=0;x<srcImg.width;x++){ for(int y=0;y<srcImg.height;y++) { uint8_t c= srcImg.getPixel(x,y); dispVis.setPixel(x,y,RGBColor(c,c,c)); } } // Create color-coded reconstruction disparity visualization. // This uses Andreas Geiger's color map from the Kitti benchmark: float map[8][4] = {{0, 0, 0, 114}, {0, 0, 1, 185}, {1, 0, 0, 114}, {1, 0, 1, 174}, {0, 1, 0, 114}, {0, 1, 1, 185}, {1, 1, 0, 114}, {1, 1, 1, 0} }; float sum = 0; for (int32_t i = 0; i < 8; ++ i) { sum += map[i][3]; } float weights[8]; // relative weights float cumsum[8]; // cumulative weights cumsum[0] = 0; for (int32_t i = 0; i < 7; ++ i) { weights[i] = sum / map[i][3]; cumsum[i + 1] = cumsum[i] + map[i][3] / sum; } //Copy image into a three channel color image first: for (auto& idx : validEstimateIndices) { //Pixel coords of disparity value int x = idx % srcImg.cols(); int y = idx / srcImg.cols(); uint8_t p = srcImg.getPixel(x, y); dispVis.setPixel(x, y, RGBColor(p, p, p)); //Overwrite pixel in red if we have significant error. float reconstruction_disp = disparity.getPixel(x,y); float value = std::max(0.f, std::min(0.8f, (reconstruction_disp - min_disparity) / (max_disparity - min_disparity))); int32_t bin; for (bin = 0; bin < 7; ++ bin) { if (value < cumsum[bin + 1]) { break; } } uint8_t colR, colG, colB; // Compute red/green/blue values. float w = 1.0f - (value - cumsum[bin]) * weights[bin]; colR = static_cast<uint8_t>( (w * map[bin][0] + (1.0f - w) * map[bin + 1][0]) * 255.0f); colG = static_cast<uint8_t>( (w * map[bin][1] + (1.0f - w) * map[bin + 1][1]) * 255.0f); colB = static_cast<uint8_t>( (w * map[bin][2] + (1.0f - w) * map[bin + 1][2]) * 255.0f); dispVis.setPixel(x, y, RGBColor(colR,colG,colB)); } return dispVis; } Buffer<RGBColor> getDisparityVisualization(ndb::Buffer<uint8_t>& srcImg, std::vector<Support>& support) { float min_disparity = 0; float max_disparity = 128; Buffer<RGBColor> dispVis(Eigen::Vector2i(srcImg.width, srcImg.rows())); dispVis = srcImg.convertToRGB();; for(auto& s:support) dispVis.setPixel(s.x,s.y,RGBColor(s.d,s.d,s.d)); // Create color-coded reconstruction disparity visualization. // This uses Andreas Geiger's color map from the Kitti benchmark: float map[8][4] = { {0, 0, 1, 185}, {1, 0, 0, 114}, {1, 0, 1, 174}, {0, 1, 0, 114}, {0, 1, 1, 185}, {1, 1, 0, 114}, {1, 1, 1, 0} ,{0, 0, 0, 114}, }; float sum = 0; for (int32_t i = 0; i < 8; ++ i) { sum += map[i][3]; } float weights[8]; // relative weights float cumsum[8]; // cumulative weights cumsum[0] = 0; for (int32_t i = 0; i < 7; ++ i) { weights[i] = sum / map[i][3]; cumsum[i + 1] = cumsum[i] + map[i][3] / sum; } //Copy image into a three channel color image first: for (auto& s : support) { //Pixel coords of disparity value int x = s.x; int y = s.y; //Overwrite pixel in red if we have significant error. float reconstruction_disp = s.d; float value = std::max(0.f, std::min(0.8f, (reconstruction_disp - min_disparity) / (max_disparity - min_disparity))); int32_t bin; for (bin = 0; bin < 7; ++ bin) { if (value < cumsum[bin + 1]) { break; } } uint8_t colR, colG, colB; // Compute red/green/blue values. float w = 1.0f - (value - cumsum[bin]) * weights[bin]; colR = static_cast<uint8_t>( (w * map[bin][0] + (1.0f - w) * map[bin + 1][0]) * 255.0f); colG = static_cast<uint8_t>( (w * map[bin][1] + (1.0f - w) * map[bin + 1][1]) * 255.0f); colB = static_cast<uint8_t>( (w * map[bin][2] + (1.0f - w) * map[bin + 1][2]) * 255.0f); dispVis.setPixel(x, y, RGBColor(colR,colG,colB)); } return dispVis; } } #endif
33.616519
118
0.515386
bamert
33bfdf5f02dfd5caff52b16a6d2a98ff3bf2cd43
2,519
cc
C++
android_webview/browser/aw_web_ui_controller_factory.cc
zipated/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
2,151
2020-04-18T07:31:17.000Z
2022-03-31T08:39:18.000Z
android_webview/browser/aw_web_ui_controller_factory.cc
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
395
2020-04-18T08:22:18.000Z
2021-12-08T13:04:49.000Z
android_webview/browser/aw_web_ui_controller_factory.cc
cangulcan/src
2b8388091c71e442910a21ada3d97ae8bc1845d3
[ "BSD-3-Clause" ]
338
2020-04-18T08:03:10.000Z
2022-03-29T12:33:22.000Z
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "android_webview/browser/aw_web_ui_controller_factory.h" #include "components/safe_browsing/web_ui/constants.h" #include "components/safe_browsing/web_ui/safe_browsing_ui.h" #include "content/public/browser/web_ui.h" using content::WebUI; using content::WebUIController; namespace { const WebUI::TypeID kSafeBrowsingID = &kSafeBrowsingID; // A function for creating a new WebUI. The caller owns the return value, which // may be nullptr (for example, if the URL refers to an non-existent extension). typedef WebUIController* (*WebUIFactoryFunctionPointer)(WebUI* web_ui, const GURL& url); // Template for defining WebUIFactoryFunctionPointer. template <class T> WebUIController* NewWebUI(WebUI* web_ui, const GURL& url) { return new T(web_ui); } WebUIFactoryFunctionPointer GetWebUIFactoryFunctionPointer(const GURL& url) { if (url.host() == safe_browsing::kChromeUISafeBrowsingHost) { return &NewWebUI<safe_browsing::SafeBrowsingUI>; } return nullptr; } WebUI::TypeID GetWebUITypeID(const GURL& url) { if (url.host() == safe_browsing::kChromeUISafeBrowsingHost) { return kSafeBrowsingID; } return WebUI::kNoWebUI; } } // namespace namespace android_webview { // static AwWebUIControllerFactory* AwWebUIControllerFactory::GetInstance() { return base::Singleton<AwWebUIControllerFactory>::get(); } AwWebUIControllerFactory::AwWebUIControllerFactory() {} AwWebUIControllerFactory::~AwWebUIControllerFactory() {} WebUI::TypeID AwWebUIControllerFactory::GetWebUIType( content::BrowserContext* browser_context, const GURL& url) const { return GetWebUITypeID(url); } bool AwWebUIControllerFactory::UseWebUIForURL( content::BrowserContext* browser_context, const GURL& url) const { return GetWebUIType(browser_context, url) != WebUI::kNoWebUI; } bool AwWebUIControllerFactory::UseWebUIBindingsForURL( content::BrowserContext* browser_context, const GURL& url) const { return UseWebUIForURL(browser_context, url); } WebUIController* AwWebUIControllerFactory::CreateWebUIControllerForURL( WebUI* web_ui, const GURL& url) const { WebUIFactoryFunctionPointer function = GetWebUIFactoryFunctionPointer(url); if (!function) return nullptr; return (*function)(web_ui, url); } } // namespace android_webview
28.954023
80
0.755855
zipated
33c0d6843bb1f0fd477ec8b7140daa053a9db842
1,609
hpp
C++
src/utility.hpp
BigDataAnalyticsGroup/ACM-SIGMOD-19-Programming-Contest
6193d5db300dad97737fa2438d0c7cede8e3550e
[ "Apache-2.0" ]
2
2020-03-27T21:28:41.000Z
2020-10-29T11:58:21.000Z
src/utility.hpp
BigDataAnalyticsGroup/ACM-SIGMOD-19-Programming-Contest
6193d5db300dad97737fa2438d0c7cede8e3550e
[ "Apache-2.0" ]
null
null
null
src/utility.hpp
BigDataAnalyticsGroup/ACM-SIGMOD-19-Programming-Contest
6193d5db300dad97737fa2438d0c7cede8e3550e
[ "Apache-2.0" ]
null
null
null
//===== utility.hpp ==================================================================================================== // // Author: Immanuel Haffner <haffner.immanuel@gmail.com> // // Licence: // Copyright 2019 Immanuel Haffner // // 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. // // Description: // This file provides utility definitions. // //====================================================================================================================== #pragma once #include <cstdlib> #include <initializer_list> template<typename T> T * allocate(std::size_t count) { return static_cast<T*>(malloc(count * sizeof(T))); } template<typename T> T * reallocate(T *ptr, std::size_t count) { return static_cast<T*>(realloc(ptr, count * sizeof(T))); } template<typename T> void deallocate(T *ptr) { free(static_cast<void*>(ptr)); } template<typename T> T * stack_allocate(std::size_t count) { return static_cast<T*>(alloca(count * sizeof(T))); } void clear_page_cache(); void bind_to_cpus(std::initializer_list<unsigned> cpus);
34.234043
120
0.599751
BigDataAnalyticsGroup
33c12ed0990371e8c51a7019ec7918b9a5b2b7dc
2,460
cpp
C++
examples/3d/pointCloudExample/src/ofApp.cpp
MicrosoftArchive/openFrameworks
4029c12e01e54407f1ee238ce12c52d016a80f5c
[ "MIT" ]
3
2017-12-27T23:02:50.000Z
2018-10-14T00:50:49.000Z
examples/3d/pointCloudExample/src/ofApp.cpp
MicrosoftArchive/openFrameworks
4029c12e01e54407f1ee238ce12c52d016a80f5c
[ "MIT" ]
null
null
null
examples/3d/pointCloudExample/src/ofApp.cpp
MicrosoftArchive/openFrameworks
4029c12e01e54407f1ee238ce12c52d016a80f5c
[ "MIT" ]
null
null
null
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetVerticalSync(true); // load an image from disk img.loadImage("linzer.png"); // we're going to load a ton of points into an ofMesh mesh.setMode(OF_PRIMITIVE_POINTS); // loop through the image in the x and y axes int skip = 4; // load a subset of the points for(int y = 0; y < img.getHeight(); y += skip) { for(int x = 0; x < img.getWidth(); x += skip) { ofColor cur = img.getColor(x, y); if(cur.a > 0) { // the alpha value encodes depth, let's remap it to a good depth range float z = ofMap(cur.a, 0, 255, -300, 300); cur.a = 255; cur.r = 255; cur.g = 255; cur.b = 255; mesh.addColor(cur); ofVec3f pos(x, y, z); mesh.addVertex(pos); } } } ofEnableDepthTest(); //glEnable(GL_POINT_SMOOTH); // use circular points instead of square points //glPointSize(3); // make the points bigger } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { ofBackgroundGradient(ofColor::gray, ofColor::black, OF_GRADIENT_CIRCULAR); // even points can overlap with each other, let's avoid that cam.begin(); ofScale(2, -2, 2); // flip the y axis and zoom in a bit ofRotateY(90); ofTranslate(-img.getWidth() / 2, -img.getHeight() / 2); mesh.draw(); cam.end(); } //-------------------------------------------------------------- void ofApp::keyPressed(int key){ } //-------------------------------------------------------------- void ofApp::keyReleased(int key){ } //-------------------------------------------------------------- void ofApp::mouseMoved(int x, int y){ } //-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void ofApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- void ofApp::dragEvent(ofDragInfo dragInfo){ }
25.102041
77
0.443496
MicrosoftArchive
33c2358a81265eb5e06c41c74703d79ad98a9e97
465
hpp
C++
extensions/arduino/kit/QHRobot/lib/ArduinoJson6_8/src/ArduinoJson/Operators/VariantCasts.hpp
Suku1989/external-resources
5d2b8fba60556d325cd31d29caa02508885910be
[ "MIT" ]
2
2020-01-14T08:38:42.000Z
2020-10-06T15:22:23.000Z
extensions/arduino/kit/QHRobot/lib/ArduinoJson6_8/src/ArduinoJson/Operators/VariantCasts.hpp
Suku1989/external-resources
5d2b8fba60556d325cd31d29caa02508885910be
[ "MIT" ]
6
2022-03-08T04:11:48.000Z
2022-03-11T05:46:05.000Z
extensions/arduino/kit/QHRobot/lib/ArduinoJson6_8/src/ArduinoJson/Operators/VariantCasts.hpp
Suku1989/external-resources
5d2b8fba60556d325cd31d29caa02508885910be
[ "MIT" ]
8
2022-01-19T18:15:39.000Z
2022-03-26T06:07:17.000Z
// ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2018 // MIT License #pragma once #include "../Polyfills/attributes.hpp" namespace ARDUINOJSON_NAMESPACE { template <typename TImpl> class VariantCasts { public: template <typename T> FORCE_INLINE operator T() const { return impl()->template as<T>(); } private: const TImpl *impl() const { return static_cast<const TImpl *>(this); } }; } // namespace ARDUINOJSON_NAMESPACE
18.6
44
0.709677
Suku1989
33c37075e4cc5313304a21b87476bf25bbcff28d
4,845
cpp
C++
game/song1.cpp
kaplaars/gba-sprite-engine
2653846d2c50a4eb57010e389288d23854d34eba
[ "MIT" ]
null
null
null
game/song1.cpp
kaplaars/gba-sprite-engine
2653846d2c50a4eb57010e389288d23854d34eba
[ "MIT" ]
null
null
null
game/song1.cpp
kaplaars/gba-sprite-engine
2653846d2c50a4eb57010e389288d23854d34eba
[ "MIT" ]
1
2019-12-05T10:30:36.000Z
2019-12-05T10:30:36.000Z
#include <libgba-sprite-engine/scene.h> #include <libgba-sprite-engine/sprites/sprite_builder.h> #include <libgba-sprite-engine/background/text_stream.h> #include <libgba-sprite-engine/gba/tonc_memdef.h> #include <libgba-sprite-engine/gba_engine.h> #include "karakter.h" #include "SongSelect.h" #include "song1.h" #include "danceroom1.h" #include "Menu.h" #include "music1.h" #include "data.h" #include "Highscore.h" extern data data1; song1::song1(const std::shared_ptr<GBAEngine> &engine) : Scene(engine) {} std::vector<Sprite *> song1::sprites() { return {animation.get(), animation2.get(), animation3.get(), animation4.get(), buttons.get()}; } std::vector<Background *> song1::backgrounds() { return { bg.get() }; } void song1::tick(u16 keys) { //ga terug naar startscene if (keys & KEY_R) { engine->setScene(new SongSelect(engine)); } //topscore timer if(engine->getTimer()->getMinutes()>=1){ data1.setEndgameScore(score1); engine->setScene(new Highscore(engine)); } TextStream::instance().setText("score:", 1, 1); TextStream::instance().setText(std::to_string(score1), 2, 1); TextStream::instance().setText(std::to_string(60-(engine->getTimer()->getSecs())),3,1); //moving and generating the buttons if(buttons->isOffScreen()) { int frame=(rand()%6+6); buttons->animateToFrame(frame); TextStream::instance().setText(std::to_string(frame), 4, 1); buttons->moveTo((GBA_SCREEN_WIDTH/2)-16,0); pressed = 0; }else{ buttons->setVelocity(0, data1.getFallSpeed()); } //y pos checker /*TextStream::instance().setText("Y-position:", 3, 1); TextStream::instance().setText(std::to_string(buttons->getY()), 4, 1);*/ //points detection if(buttons->getY()>=60 && buttons->getY() <= 75 && pressed == 0){ if(keys & KEY_B && buttons->getCurrentFrame() == 6){ score1+=buttons->getY(); pressed = 1; }else if(keys & KEY_A && buttons->getCurrentFrame() == 7){ score1+=buttons->getY(); pressed = 1; }else if(keys & KEY_LEFT && buttons->getCurrentFrame() == 8){ score1+=buttons->getY(); pressed = 1; }else if(keys & KEY_DOWN && buttons->getCurrentFrame() == 9){ score1+=buttons->getY(); pressed = 1; }else if(keys & KEY_RIGHT && buttons->getCurrentFrame() == 10){ score1+=buttons->getY(); pressed = 1; }else if(keys & KEY_UP && buttons->getCurrentFrame() == 11){ score1+=buttons->getY(); pressed = 1; } } } void song1::load() { foregroundPalette = std::unique_ptr<ForegroundPaletteManager>(new ForegroundPaletteManager(SharedPal, sizeof(SharedPal))); backgroundPalette = std::unique_ptr<BackgroundPaletteManager>(new BackgroundPaletteManager(danceroomPal, sizeof(danceroomPal))); engine.get()->enableText(); engine->getTimer()->reset(); engine->getTimer()->start(); engine->enqueueMusic(music1, music1_bytes, data1.getSpeed()); bg = std::unique_ptr<Background>(new Background(1, danceroomTiles, sizeof(danceroomTiles), danceroomMap, sizeof(danceroomMap))); bg.get()->useMapScreenBlock(16); SpriteBuilder<Sprite> builder; buttons = builder .withData(buttonsTiles, sizeof(buttonsTiles)) .withSize(SIZE_32_32) .withLocation((GBA_SCREEN_WIDTH/2)-16, 0) .buildPtr(); animation = builder .withData(bokmanTiles, sizeof(bokmanTiles)) .withSize(SIZE_32_32) .withAnimated(3, (16-(data1.getFallSpeed()*5))) .withLocation((GBA_SCREEN_WIDTH/4)-16, (GBA_SCREEN_HEIGHT/4)) .withinBounds() .buildPtr(); animation2 = builder .withData(dancingmichmanTiles, sizeof(dancingmichmanTiles)) .withSize(SIZE_32_32) .withAnimated(3, (16-(data1.getFallSpeed()*5))) .withLocation((GBA_SCREEN_WIDTH/4)-16, ((GBA_SCREEN_HEIGHT*3)/4)-32) .withinBounds() .buildPtr(); animation3= builder .withData(nederlandmanTiles, sizeof(nederlandmanTiles)) .withSize(SIZE_32_32) .withAnimated(3, (16-(data1.getFallSpeed()*5))) .withLocation(((GBA_SCREEN_WIDTH*3)/4)-16, (GBA_SCREEN_HEIGHT/4)) .withinBounds() .buildPtr(); animation4 = builder .withData(j_germanTiles, sizeof(j_germanTiles)) .withSize(SIZE_32_32) .withAnimated(3, (16-(data1.getFallSpeed()*5))) .withLocation(((GBA_SCREEN_WIDTH*3)/4)-16, ((GBA_SCREEN_HEIGHT*3)/4)-32) .withinBounds() .buildPtr(); score1 = 0; }
34.361702
132
0.606192
kaplaars
33c3d267c8db8f08c53a219f506a50bee3ca0b84
1,788
cpp
C++
GUI_Framework_JCS/JCS_TreeNode.cpp
jcs090218/JCSCC_Engine
eac6c55203bd804acb439305ff977cfca9365e1e
[ "MIT" ]
4
2019-12-09T05:28:04.000Z
2021-02-18T14:05:09.000Z
GUI_Framework_JCS/JCS_TreeNode.cpp
jcs090218/JCSCC_Engine
eac6c55203bd804acb439305ff977cfca9365e1e
[ "MIT" ]
null
null
null
GUI_Framework_JCS/JCS_TreeNode.cpp
jcs090218/JCSCC_Engine
eac6c55203bd804acb439305ff977cfca9365e1e
[ "MIT" ]
2
2019-12-25T15:05:49.000Z
2021-02-18T14:05:14.000Z
/** * $File: JCS_TreeNode.cpp $ * $Date: $ * $Revision: $ * $Creator: Jen-Chieh Shen $ * $Notice: See LICENSE.txt for modification and distribution information * Copyright (c) 2016 by Shen, Jen-Chieh $ */ #include "JCS_TreeNode.h" #include "JCS_TreeView.h" namespace JCS_GUI { JCS_TreeNode::JCS_TreeNode() { } JCS_TreeNode::~JCS_TreeNode() { } #ifdef _WIN32 void JCS_TreeNode::Create( const HWND treeView, const LPWSTR name, const HTREEITEM node/*= nullptr*/) { TVINSERTSTRUCT tvis = { 0 }; tvis.item.mask = TVIF_TEXT; tvis.item.pszText = name; tvis.hInsertAfter = TVI_LAST; // set default as root if (node == nullptr) tvis.hParent = TVI_ROOT; // if there is root already add it on. else tvis.hParent = node; m_node = reinterpret_cast<HTREEITEM>( SendMessage(treeView, TVM_INSERTITEM, 0, reinterpret_cast<LPARAM>(&tvis))); } void JCS_TreeNode::Create( const JCS_TreeView treeView, const LPWSTR name, const JCS_TreeNode* node/*= nullptr*/) { TVINSERTSTRUCT tvis = { 0 }; tvis.item.mask = TVIF_TEXT; tvis.item.pszText = name; tvis.hInsertAfter = TVI_LAST; // set default as root if (node == nullptr) tvis.hParent = TVI_ROOT; // if there is root already add it on. else tvis.hParent = node->GetNode(); m_node = reinterpret_cast<HTREEITEM>( SendMessage(treeView.GetOwnWindowHandle(), TVM_INSERTITEM, 0, reinterpret_cast<LPARAM>(&tvis))); } #endif // _WIN32 }
21.804878
73
0.555928
jcs090218
33c42ef08a21e70945aa20bc67542f2ddb456dab
12,365
cc
C++
chrome/browser/banners/app_banner_settings_helper.cc
hefen1/chromium
52f0b6830e000ca7c5e9aa19488af85be792cc88
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/banners/app_banner_settings_helper.cc
hefen1/chromium
52f0b6830e000ca7c5e9aa19488af85be792cc88
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chrome/browser/banners/app_banner_settings_helper.cc
hefen1/chromium
52f0b6830e000ca7c5e9aa19488af85be792cc88
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2020-04-04T13:34:56.000Z
2020-11-04T07:17:52.000Z
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/banners/app_banner_settings_helper.h" #include <algorithm> #include <string> #include "base/command_line.h" #include "chrome/browser/banners/app_banner_metrics.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_switches.h" #include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/common/content_settings_pattern.h" #include "content/public/browser/web_contents.h" #include "net/base/escape.h" #include "url/gurl.h" namespace { // Max number of apps (including ServiceWorker based web apps) that a particular // site may show a banner for. const size_t kMaxAppsPerSite = 3; // Oldest could show banner event we care about, in days. const unsigned int kOldestCouldShowBannerEventInDays = 14; // Number of times that the banner could have been shown before the banner will // actually be triggered. const unsigned int kCouldShowEventsToTrigger = 2; // Number of days that showing the banner will prevent it being seen again for. const unsigned int kMinimumDaysBetweenBannerShows = 60; // Number of days that the banner being blocked will prevent it being seen again // for. const unsigned int kMinimumBannerBlockedToBannerShown = 90; // Dictionary keys to use for the events. const char* kBannerEventKeys[] = { "couldShowBannerEvents", "didShowBannerEvent", "didBlockBannerEvent", "didAddToHomescreenEvent", }; // Dictionary key to use whether the banner has been blocked. const char kHasBlockedKey[] = "hasBlocked"; scoped_ptr<base::DictionaryValue> GetOriginDict( HostContentSettingsMap* settings, const GURL& origin_url) { if (!settings) return scoped_ptr<base::DictionaryValue>(); scoped_ptr<base::Value> value = settings->GetWebsiteSetting( origin_url, origin_url, CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), NULL); if (!value.get()) return make_scoped_ptr(new base::DictionaryValue()); if (!value->IsType(base::Value::TYPE_DICTIONARY)) return make_scoped_ptr(new base::DictionaryValue()); return make_scoped_ptr(static_cast<base::DictionaryValue*>(value.release())); } base::DictionaryValue* GetAppDict(base::DictionaryValue* origin_dict, const std::string& key_name) { base::DictionaryValue* app_dict = nullptr; if (!origin_dict->GetDictionaryWithoutPathExpansion(key_name, &app_dict)) { // Don't allow more than kMaxAppsPerSite dictionaries. if (origin_dict->size() < kMaxAppsPerSite) { app_dict = new base::DictionaryValue(); origin_dict->SetWithoutPathExpansion(key_name, make_scoped_ptr(app_dict)); } } return app_dict; } } // namespace void AppBannerSettingsHelper::ClearHistoryForURLs( Profile* profile, const std::set<GURL>& origin_urls) { HostContentSettingsMap* settings = profile->GetHostContentSettingsMap(); for (const GURL& origin_url : origin_urls) { ContentSettingsPattern pattern(ContentSettingsPattern::FromURL(origin_url)); if (!pattern.IsValid()) continue; settings->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), nullptr); } } void AppBannerSettingsHelper::RecordBannerEvent( content::WebContents* web_contents, const GURL& origin_url, const std::string& package_name_or_start_url, AppBannerEvent event, base::Time time) { Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); if (profile->IsOffTheRecord() || web_contents->GetURL() != origin_url || package_name_or_start_url.empty()) { return; } ContentSettingsPattern pattern(ContentSettingsPattern::FromURL(origin_url)); if (!pattern.IsValid()) return; HostContentSettingsMap* settings = profile->GetHostContentSettingsMap(); scoped_ptr<base::DictionaryValue> origin_dict = GetOriginDict(settings, origin_url); if (!origin_dict) return; base::DictionaryValue* app_dict = GetAppDict(origin_dict.get(), package_name_or_start_url); if (!app_dict) return; std::string event_key(kBannerEventKeys[event]); if (event == APP_BANNER_EVENT_COULD_SHOW) { base::ListValue* could_show_list = nullptr; if (!app_dict->GetList(event_key, &could_show_list)) { could_show_list = new base::ListValue(); app_dict->Set(event_key, make_scoped_ptr(could_show_list)); } // Trim any items that are older than we should care about. For comparisons // the times are converted to local dates. base::Time date = time.LocalMidnight(); base::ValueVector::iterator it = could_show_list->begin(); while (it != could_show_list->end()) { if ((*it)->IsType(base::Value::TYPE_DOUBLE)) { double internal_date; (*it)->GetAsDouble(&internal_date); base::Time other_date = base::Time::FromInternalValue(internal_date).LocalMidnight(); // This date has already been added. Don't add the date again, and don't // bother trimming values as it will have been done the first time the // date was added (unless the local date has changed, which we can live // with). if (other_date == date) return; base::TimeDelta delta = date - other_date; if (delta < base::TimeDelta::FromDays(kOldestCouldShowBannerEventInDays)) { ++it; continue; } } // Either this date is older than we care about, or it isn't a date, so // remove it; it = could_show_list->Erase(it, nullptr); } // Dates are stored in their raw form (i.e. not local dates) to be resilient // to time zone changes. could_show_list->AppendDouble(time.ToInternalValue()); } else { app_dict->SetDouble(event_key, time.ToInternalValue()); } settings->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), origin_dict.release()); } bool AppBannerSettingsHelper::ShouldShowBanner( content::WebContents* web_contents, const GURL& origin_url, const std::string& package_name_or_start_url, base::Time time) { if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kBypassAppBannerEngagementChecks)) { return true; } // Don't show if it has been added to the homescreen. base::Time added_time = GetSingleBannerEvent(web_contents, origin_url, package_name_or_start_url, APP_BANNER_EVENT_DID_ADD_TO_HOMESCREEN); if (!added_time.is_null()) { banners::TrackDisplayEvent(banners::DISPLAY_EVENT_INSTALLED_PREVIOUSLY); return false; } base::Time blocked_time = GetSingleBannerEvent(web_contents, origin_url, package_name_or_start_url, APP_BANNER_EVENT_DID_BLOCK); // Null times are in the distant past, so the delta between real times and // null events will always be greater than the limits. if (time - blocked_time < base::TimeDelta::FromDays(kMinimumBannerBlockedToBannerShown)) { banners::TrackDisplayEvent(banners::DISPLAY_EVENT_BLOCKED_PREVIOUSLY); return false; } base::Time shown_time = GetSingleBannerEvent(web_contents, origin_url, package_name_or_start_url, APP_BANNER_EVENT_DID_SHOW); if (time - shown_time < base::TimeDelta::FromDays(kMinimumDaysBetweenBannerShows)) { banners::TrackDisplayEvent(banners::DISPLAY_EVENT_IGNORED_PREVIOUSLY); return false; } std::vector<base::Time> could_show_events = GetCouldShowBannerEvents( web_contents, origin_url, package_name_or_start_url); if (could_show_events.size() < kCouldShowEventsToTrigger) { banners::TrackDisplayEvent(banners::DISPLAY_EVENT_NOT_VISITED_ENOUGH); return false; } return true; } std::vector<base::Time> AppBannerSettingsHelper::GetCouldShowBannerEvents( content::WebContents* web_contents, const GURL& origin_url, const std::string& package_name_or_start_url) { std::vector<base::Time> result; if (package_name_or_start_url.empty()) return result; Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); HostContentSettingsMap* settings = profile->GetHostContentSettingsMap(); scoped_ptr<base::DictionaryValue> origin_dict = GetOriginDict(settings, origin_url); if (!origin_dict) return result; base::DictionaryValue* app_dict = GetAppDict(origin_dict.get(), package_name_or_start_url); if (!app_dict) return result; std::string event_key(kBannerEventKeys[APP_BANNER_EVENT_COULD_SHOW]); base::ListValue* could_show_list = nullptr; if (!app_dict->GetList(event_key, &could_show_list)) return result; for (auto value : *could_show_list) { if (value->IsType(base::Value::TYPE_DOUBLE)) { double internal_date; value->GetAsDouble(&internal_date); base::Time date = base::Time::FromInternalValue(internal_date); result.push_back(date); } } return result; } base::Time AppBannerSettingsHelper::GetSingleBannerEvent( content::WebContents* web_contents, const GURL& origin_url, const std::string& package_name_or_start_url, AppBannerEvent event) { DCHECK(event != APP_BANNER_EVENT_COULD_SHOW); DCHECK(event < APP_BANNER_EVENT_NUM_EVENTS); if (package_name_or_start_url.empty()) return base::Time(); Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); HostContentSettingsMap* settings = profile->GetHostContentSettingsMap(); scoped_ptr<base::DictionaryValue> origin_dict = GetOriginDict(settings, origin_url); if (!origin_dict) return base::Time(); base::DictionaryValue* app_dict = GetAppDict(origin_dict.get(), package_name_or_start_url); if (!app_dict) return base::Time(); std::string event_key(kBannerEventKeys[event]); double internal_time; if (!app_dict->GetDouble(event_key, &internal_time)) return base::Time(); return base::Time::FromInternalValue(internal_time); } bool AppBannerSettingsHelper::IsAllowed( content::WebContents* web_contents, const GURL& origin_url, const std::string& package_name_or_start_url) { Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); if (profile->IsOffTheRecord() || web_contents->GetURL() != origin_url || package_name_or_start_url.empty()) { return false; } HostContentSettingsMap* settings = profile->GetHostContentSettingsMap(); scoped_ptr<base::DictionaryValue> origin_dict = GetOriginDict(settings, origin_url); if (!origin_dict) return true; base::DictionaryValue* app_dict = GetAppDict(origin_dict.get(), package_name_or_start_url); if (!app_dict) return true; bool has_blocked; if (!app_dict->GetBoolean(kHasBlockedKey, &has_blocked)) return true; return !has_blocked; } void AppBannerSettingsHelper::Block( content::WebContents* web_contents, const GURL& origin_url, const std::string& package_name_or_start_url) { Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); if (profile->IsOffTheRecord() || web_contents->GetURL() != origin_url || package_name_or_start_url.empty()) { return; } ContentSettingsPattern pattern(ContentSettingsPattern::FromURL(origin_url)); if (!pattern.IsValid()) return; HostContentSettingsMap* settings = profile->GetHostContentSettingsMap(); scoped_ptr<base::DictionaryValue> origin_dict = GetOriginDict(settings, origin_url); if (!origin_dict) return; base::DictionaryValue* app_dict = GetAppDict(origin_dict.get(), package_name_or_start_url); if (!app_dict) return; // Update the setting and save it back. app_dict->SetBoolean(kHasBlockedKey, true); settings->SetWebsiteSetting(pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), origin_dict.release()); }
34.063361
80
0.71484
hefen1
33c440860bb47ff41cba083cc8f0baa836e92681
465
cpp
C++
Flick/src/Flick/Renderer/VertexArray.cpp
firo1738/FLICK
a6ccb0f23c212d0f1b97f71520beb3a89be57f2d
[ "Apache-2.0" ]
null
null
null
Flick/src/Flick/Renderer/VertexArray.cpp
firo1738/FLICK
a6ccb0f23c212d0f1b97f71520beb3a89be57f2d
[ "Apache-2.0" ]
null
null
null
Flick/src/Flick/Renderer/VertexArray.cpp
firo1738/FLICK
a6ccb0f23c212d0f1b97f71520beb3a89be57f2d
[ "Apache-2.0" ]
null
null
null
#include "fipch.h" #include "VertexArray.h" #include "Renderer.h" #include "Platform/OpenGL/OpenGLVertexArray.h" namespace Flick { VertexArray* VertexArray::Create() { switch (Renderer::GetAPI()) { case RendererAPI::API::None: FI_CORE_ASSERT(false, "RendererAPI::None is not yet supported by Flick!"); return nullptr; case RendererAPI::API::OpenGL: return new OpenGLVertexArray(); } FI_CORE_ASSERT(false, "Unknown RendererAPI!"); return 0; } }
22.142857
121
0.722581
firo1738
33c4473609facd7821cbef2b3c8b6e4c01521e29
28,944
cc
C++
components/password_manager/core/browser/android_affiliation/affiliated_match_helper_unittest.cc
Ron423c/chromium
2edf7b980065b648f8b2a6e52193d83832fe36b7
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
components/password_manager/core/browser/android_affiliation/affiliated_match_helper_unittest.cc
Ron423c/chromium
2edf7b980065b648f8b2a6e52193d83832fe36b7
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
components/password_manager/core/browser/android_affiliation/affiliated_match_helper_unittest.cc
Ron423c/chromium
2edf7b980065b648f8b2a6e52193d83832fe36b7
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1
2021-03-07T14:20:02.000Z
2021-03-07T14:20:02.000Z
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/password_manager/core/browser/android_affiliation/affiliated_match_helper.h" #include <stddef.h> #include <memory> #include <utility> #include "base/bind.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_refptr.h" #include "base/run_loop.h" #include "base/strings/utf_string_conversions.h" #include "base/test/scoped_feature_list.h" #include "base/test/scoped_mock_time_message_loop_task_runner.h" #include "base/test/task_environment.h" #include "components/password_manager/core/browser/android_affiliation/affiliation_utils.h" #include "components/password_manager/core/browser/android_affiliation/android_affiliation_service.h" #include "components/password_manager/core/browser/test_password_store.h" #include "components/password_manager/core/common/password_manager_features.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" namespace password_manager { namespace { using StrategyOnCacheMiss = AndroidAffiliationService::StrategyOnCacheMiss; class MockAndroidAffiliationService : public AndroidAffiliationService { public: MockAndroidAffiliationService() : AndroidAffiliationService(nullptr) { testing::DefaultValue<AffiliatedFacets>::Set(AffiliatedFacets()); } MOCK_METHOD2(OnGetAffiliationsAndBrandingCalled, AffiliatedFacets(const FacetURI&, StrategyOnCacheMiss)); MOCK_METHOD2(Prefetch, void(const FacetURI&, const base::Time&)); MOCK_METHOD2(CancelPrefetch, void(const FacetURI&, const base::Time&)); MOCK_METHOD1(TrimCacheForFacetURI, void(const FacetURI&)); void GetAffiliationsAndBranding(const FacetURI& facet_uri, StrategyOnCacheMiss cache_miss_strategy, ResultCallback result_callback) override { AffiliatedFacets affiliation = OnGetAffiliationsAndBrandingCalled(facet_uri, cache_miss_strategy); std::move(result_callback).Run(affiliation, !affiliation.empty()); } void ExpectCallToGetAffiliationsAndBrandingAndSucceedWithResult( const FacetURI& expected_facet_uri, StrategyOnCacheMiss expected_cache_miss_strategy, const AffiliatedFacets& affiliations_to_return) { EXPECT_CALL(*this, OnGetAffiliationsAndBrandingCalled( expected_facet_uri, expected_cache_miss_strategy)) .WillOnce(testing::Return(affiliations_to_return)); } void ExpectCallToGetAffiliationsAndBrandingAndEmulateFailure( const FacetURI& expected_facet_uri, StrategyOnCacheMiss expected_cache_miss_strategy) { EXPECT_CALL(*this, OnGetAffiliationsAndBrandingCalled( expected_facet_uri, expected_cache_miss_strategy)) .WillOnce(testing::Return(AffiliatedFacets())); } void ExpectCallToPrefetch(const char* expected_facet_uri_spec) { EXPECT_CALL(*this, Prefetch(FacetURI::FromCanonicalSpec(expected_facet_uri_spec), base::Time::Max())) .RetiresOnSaturation(); } void ExpectCallToCancelPrefetch(const char* expected_facet_uri_spec) { EXPECT_CALL(*this, CancelPrefetch( FacetURI::FromCanonicalSpec(expected_facet_uri_spec), base::Time::Max())) .RetiresOnSaturation(); } void ExpectCallToTrimCacheForFacetURI(const char* expected_facet_uri_spec) { EXPECT_CALL(*this, TrimCacheForFacetURI(FacetURI::FromCanonicalSpec( expected_facet_uri_spec))) .RetiresOnSaturation(); } }; const char kTestWebFacetURIAlpha1[] = "https://one.alpha.example.com"; const char kTestWebFacetURIAlpha2[] = "https://two.alpha.example.com"; const char kTestAndroidFacetURIAlpha3[] = "android://hash@com.example.alpha.android"; const char kTestAndroidFacetNameAlpha3[] = "Facet Name Alpha 3"; const char kTestAndroidFacetIconURLAlpha3[] = "https://example.com/alpha_3.png"; const char kTestWebRealmAlpha1[] = "https://one.alpha.example.com/"; const char kTestWebRealmAlpha2[] = "https://two.alpha.example.com/"; const char kTestAndroidRealmAlpha3[] = "android://hash@com.example.alpha.android/"; const char kTestWebFacetURIBeta1[] = "https://one.beta.example.com"; const char kTestAndroidFacetURIBeta2[] = "android://hash@com.example.beta.android"; const char kTestAndroidFacetNameBeta2[] = "Facet Name Beta 2"; const char kTestAndroidFacetIconURLBeta2[] = "https://example.com/beta_2.png"; const char kTestAndroidFacetURIBeta3[] = "android://hash@com.yetanother.beta.android"; const char kTestAndroidFacetNameBeta3[] = "Facet Name Beta 3"; const char kTestAndroidFacetIconURLBeta3[] = "https://example.com/beta_3.png"; const char kTestWebRealmBeta1[] = "https://one.beta.example.com/"; const char kTestAndroidRealmBeta2[] = "android://hash@com.example.beta.android/"; const char kTestAndroidRealmBeta3[] = "android://hash@com.yetanother.beta.android/"; const char kTestAndroidFacetURIGamma[] = "android://hash@com.example.gamma.android"; const char kTestAndroidRealmGamma[] = "android://hash@com.example.gamma.android"; const char kTestUsername[] = "JohnDoe"; const char kTestPassword[] = "secret"; AffiliatedFacets GetTestEquivalenceClassAlpha() { return { {FacetURI::FromCanonicalSpec(kTestWebFacetURIAlpha1)}, {FacetURI::FromCanonicalSpec(kTestWebFacetURIAlpha2)}, {FacetURI::FromCanonicalSpec(kTestAndroidFacetURIAlpha3), FacetBrandingInfo{kTestAndroidFacetNameAlpha3, GURL(kTestAndroidFacetIconURLAlpha3)}}, }; } AffiliatedFacets GetTestEquivalenceClassBeta() { return { {FacetURI::FromCanonicalSpec(kTestWebFacetURIBeta1)}, {FacetURI::FromCanonicalSpec(kTestAndroidFacetURIBeta2), FacetBrandingInfo{kTestAndroidFacetNameBeta2, GURL(kTestAndroidFacetIconURLBeta2)}}, {FacetURI::FromCanonicalSpec(kTestAndroidFacetURIBeta3), FacetBrandingInfo{kTestAndroidFacetNameBeta3, GURL(kTestAndroidFacetIconURLBeta3)}}, }; } PasswordForm GetTestAndroidCredentials(const char* signon_realm) { PasswordForm form; form.scheme = PasswordForm::Scheme::kHtml; form.signon_realm = signon_realm; form.username_value = base::ASCIIToUTF16(kTestUsername); form.password_value = base::ASCIIToUTF16(kTestPassword); return form; } PasswordForm GetTestBlocklistedAndroidCredentials(const char* signon_realm) { PasswordForm form = GetTestAndroidCredentials(signon_realm); form.blocked_by_user = true; return form; } PasswordStore::FormDigest GetTestObservedWebForm(const char* signon_realm, const char* origin) { return {PasswordForm::Scheme::kHtml, signon_realm, origin ? GURL(origin) : GURL()}; } } // namespace class AffiliatedMatchHelperTest : public testing::Test, public ::testing::WithParamInterface<bool> { public: AffiliatedMatchHelperTest() { feature_list_.InitWithFeatureState( features::kFillingAcrossAffiliatedWebsites, GetParam()); } protected: void RunDeferredInitialization() { mock_time_task_runner_->RunUntilIdle(); ASSERT_EQ(AffiliatedMatchHelper::kInitializationDelayOnStartup, mock_time_task_runner_->NextPendingTaskDelay()); mock_time_task_runner_->FastForwardBy( AffiliatedMatchHelper::kInitializationDelayOnStartup); } void ExpectNoDeferredTasks() { mock_time_task_runner_->RunUntilIdle(); ASSERT_FALSE(mock_time_task_runner_->HasPendingTask()); } void RunUntilIdle() { // TODO(gab): Add support for base::RunLoop().RunUntilIdle() in scope of // ScopedMockTimeMessageLoopTaskRunner and use it instead of this helper // method. mock_time_task_runner_->RunUntilIdle(); } void AddLogin(const PasswordForm& form) { password_store_->AddLogin(form); RunUntilIdle(); } void UpdateLoginWithPrimaryKey(const PasswordForm& new_form, const PasswordForm& old_primary_key) { password_store_->UpdateLoginWithPrimaryKey(new_form, old_primary_key); RunUntilIdle(); } void RemoveLogin(const PasswordForm& form) { password_store_->RemoveLogin(form); RunUntilIdle(); } void AddAndroidAndNonAndroidTestLogins() { AddLogin(GetTestAndroidCredentials(kTestAndroidRealmAlpha3)); AddLogin(GetTestAndroidCredentials(kTestAndroidRealmBeta2)); AddLogin(GetTestBlocklistedAndroidCredentials(kTestAndroidRealmBeta3)); AddLogin(GetTestAndroidCredentials(kTestAndroidRealmGamma)); AddLogin(GetTestAndroidCredentials(kTestWebRealmAlpha1)); AddLogin(GetTestAndroidCredentials(kTestWebRealmAlpha2)); } void RemoveAndroidAndNonAndroidTestLogins() { RemoveLogin(GetTestAndroidCredentials(kTestAndroidRealmAlpha3)); RemoveLogin(GetTestAndroidCredentials(kTestAndroidRealmBeta2)); RemoveLogin(GetTestBlocklistedAndroidCredentials(kTestAndroidRealmBeta3)); RemoveLogin(GetTestAndroidCredentials(kTestAndroidRealmGamma)); RemoveLogin(GetTestAndroidCredentials(kTestWebRealmAlpha1)); RemoveLogin(GetTestAndroidCredentials(kTestWebRealmAlpha2)); } void ExpectPrefetchForTestLogins() { mock_affiliation_service()->ExpectCallToPrefetch( kTestAndroidFacetURIAlpha3); mock_affiliation_service()->ExpectCallToPrefetch(kTestAndroidFacetURIBeta2); mock_affiliation_service()->ExpectCallToPrefetch(kTestAndroidFacetURIBeta3); mock_affiliation_service()->ExpectCallToPrefetch(kTestAndroidFacetURIGamma); if (base::FeatureList::IsEnabled( features::kFillingAcrossAffiliatedWebsites)) { mock_affiliation_service()->ExpectCallToPrefetch(kTestWebFacetURIAlpha1); mock_affiliation_service()->ExpectCallToPrefetch(kTestWebFacetURIAlpha2); } } void ExpectCancelPrefetchForTestLogins() { mock_affiliation_service()->ExpectCallToCancelPrefetch( kTestAndroidFacetURIAlpha3); mock_affiliation_service()->ExpectCallToCancelPrefetch( kTestAndroidFacetURIBeta2); mock_affiliation_service()->ExpectCallToCancelPrefetch( kTestAndroidFacetURIBeta3); mock_affiliation_service()->ExpectCallToCancelPrefetch( kTestAndroidFacetURIGamma); if (base::FeatureList::IsEnabled( features::kFillingAcrossAffiliatedWebsites)) { mock_affiliation_service()->ExpectCallToCancelPrefetch( kTestWebFacetURIAlpha1); mock_affiliation_service()->ExpectCallToCancelPrefetch( kTestWebFacetURIAlpha2); } } void ExpectTrimCacheForTestLogins() { mock_affiliation_service()->ExpectCallToTrimCacheForFacetURI( kTestAndroidFacetURIAlpha3); mock_affiliation_service()->ExpectCallToTrimCacheForFacetURI( kTestAndroidFacetURIBeta2); mock_affiliation_service()->ExpectCallToTrimCacheForFacetURI( kTestAndroidFacetURIBeta3); mock_affiliation_service()->ExpectCallToTrimCacheForFacetURI( kTestAndroidFacetURIGamma); if (base::FeatureList::IsEnabled( features::kFillingAcrossAffiliatedWebsites)) { mock_affiliation_service()->ExpectCallToTrimCacheForFacetURI( kTestWebFacetURIAlpha1); mock_affiliation_service()->ExpectCallToTrimCacheForFacetURI( kTestWebFacetURIAlpha2); } } std::vector<std::string> GetAffiliatedAndroidRealms( const PasswordStore::FormDigest& observed_form) { expecting_result_callback_ = true; match_helper()->GetAffiliatedAndroidAndWebRealms( observed_form, base::BindOnce(&AffiliatedMatchHelperTest::OnAffiliatedRealmsCallback, base::Unretained(this))); RunUntilIdle(); EXPECT_FALSE(expecting_result_callback_); return last_result_realms_; } std::vector<std::string> GetAffiliatedWebRealms( const PasswordStore::FormDigest& android_form) { expecting_result_callback_ = true; match_helper()->GetAffiliatedWebRealms( android_form, base::BindOnce(&AffiliatedMatchHelperTest::OnAffiliatedRealmsCallback, base::Unretained(this))); RunUntilIdle(); EXPECT_FALSE(expecting_result_callback_); return last_result_realms_; } std::vector<std::unique_ptr<PasswordForm>> InjectAffiliationAndBrandingInformation( std::vector<std::unique_ptr<PasswordForm>> forms) { expecting_result_callback_ = true; match_helper()->InjectAffiliationAndBrandingInformation( std::move(forms), AndroidAffiliationService::StrategyOnCacheMiss::FAIL, base::BindOnce(&AffiliatedMatchHelperTest::OnFormsCallback, base::Unretained(this))); RunUntilIdle(); EXPECT_FALSE(expecting_result_callback_); return std::move(last_result_forms_); } void DestroyMatchHelper() { match_helper_.reset(); } TestPasswordStore* password_store() { return password_store_.get(); } MockAndroidAffiliationService* mock_affiliation_service() { return mock_affiliation_service_; } AffiliatedMatchHelper* match_helper() { return match_helper_.get(); } private: void OnAffiliatedRealmsCallback( const std::vector<std::string>& affiliated_realms) { EXPECT_TRUE(expecting_result_callback_); expecting_result_callback_ = false; last_result_realms_ = affiliated_realms; } void OnFormsCallback(std::vector<std::unique_ptr<PasswordForm>> forms) { EXPECT_TRUE(expecting_result_callback_); expecting_result_callback_ = false; last_result_forms_.swap(forms); } // testing::Test: void SetUp() override { auto service = std::make_unique<testing::StrictMock<MockAndroidAffiliationService>>(); mock_affiliation_service_ = service.get(); password_store_->Init(nullptr); match_helper_ = std::make_unique<AffiliatedMatchHelper>( password_store_.get(), std::move(service)); } void TearDown() override { match_helper_.reset(); password_store_->ShutdownOnUIThread(); password_store_ = nullptr; // Clean up on the background thread. RunUntilIdle(); } base::test::ScopedFeatureList feature_list_; base::test::SingleThreadTaskEnvironment task_environment_; base::ScopedMockTimeMessageLoopTaskRunner mock_time_task_runner_; std::vector<std::string> last_result_realms_; std::vector<std::unique_ptr<PasswordForm>> last_result_forms_; bool expecting_result_callback_ = false; scoped_refptr<TestPasswordStore> password_store_ = base::MakeRefCounted<TestPasswordStore>(); std::unique_ptr<AffiliatedMatchHelper> match_helper_; // Owned by |match_helper_|. MockAndroidAffiliationService* mock_affiliation_service_ = nullptr; }; // GetAffiliatedAndroidRealm* tests verify that GetAffiliatedAndroidRealms() // returns the realms of affiliated Android applications, but only Android // applications, and only if the observed form is a secure HTML login form. TEST_P(AffiliatedMatchHelperTest, GetAffiliatedAndroidRealmsYieldsResults) { mock_affiliation_service() ->ExpectCallToGetAffiliationsAndBrandingAndSucceedWithResult( FacetURI::FromCanonicalSpec(kTestWebFacetURIBeta1), StrategyOnCacheMiss::FAIL, GetTestEquivalenceClassBeta()); EXPECT_THAT(GetAffiliatedAndroidRealms( GetTestObservedWebForm(kTestWebRealmBeta1, nullptr)), testing::UnorderedElementsAre(kTestAndroidRealmBeta2, kTestAndroidRealmBeta3)); } TEST_P(AffiliatedMatchHelperTest, GetAffiliatedAndroidRealmsYieldsOnlyAndroidApps) { // Disable this test when filling across affiliated websites enabled. if (base::FeatureList::IsEnabled(features::kFillingAcrossAffiliatedWebsites)) return; mock_affiliation_service() ->ExpectCallToGetAffiliationsAndBrandingAndSucceedWithResult( FacetURI::FromCanonicalSpec(kTestWebFacetURIAlpha1), StrategyOnCacheMiss::FAIL, GetTestEquivalenceClassAlpha()); // This verifies that |kTestWebRealmAlpha2| is not returned. EXPECT_THAT(GetAffiliatedAndroidRealms( GetTestObservedWebForm(kTestWebRealmAlpha1, nullptr)), testing::UnorderedElementsAre(kTestAndroidRealmAlpha3)); } TEST_P(AffiliatedMatchHelperTest, GetAffiliatedAndroidRealmsYieldsEmptyResultsForHTTPBasicAuthForms) { PasswordStore::FormDigest http_auth_observed_form( GetTestObservedWebForm(kTestWebRealmAlpha1, nullptr)); http_auth_observed_form.scheme = PasswordForm::Scheme::kBasic; EXPECT_THAT(GetAffiliatedAndroidRealms(http_auth_observed_form), testing::IsEmpty()); } TEST_P(AffiliatedMatchHelperTest, GetAffiliatedAndroidRealmsYieldsEmptyResultsForHTTPDigestAuthForms) { PasswordStore::FormDigest http_auth_observed_form( GetTestObservedWebForm(kTestWebRealmAlpha1, nullptr)); http_auth_observed_form.scheme = PasswordForm::Scheme::kDigest; EXPECT_THAT(GetAffiliatedAndroidRealms(http_auth_observed_form), testing::IsEmpty()); } TEST_P(AffiliatedMatchHelperTest, GetAffiliatedAndroidRealmsYieldsEmptyResultsForAndroidKeyedForms) { PasswordStore::FormDigest android_observed_form( GetTestAndroidCredentials(kTestAndroidRealmBeta2)); EXPECT_THAT(GetAffiliatedAndroidRealms(android_observed_form), testing::IsEmpty()); } TEST_P(AffiliatedMatchHelperTest, GetAffiliatedAndroidRealmsYieldsEmptyResultsWhenNoPrefetch) { mock_affiliation_service() ->ExpectCallToGetAffiliationsAndBrandingAndEmulateFailure( FacetURI::FromCanonicalSpec(kTestWebFacetURIAlpha1), StrategyOnCacheMiss::FAIL); EXPECT_THAT(GetAffiliatedAndroidRealms( GetTestObservedWebForm(kTestWebRealmAlpha1, nullptr)), testing::IsEmpty()); } // GetAffiliatedWebRealms* tests verify that GetAffiliatedWebRealms() returns // the realms of web sites affiliated with the given Android application, but // only web sites, and only if an Android application is queried. TEST_P(AffiliatedMatchHelperTest, GetAffiliatedWebRealmsYieldsResults) { mock_affiliation_service() ->ExpectCallToGetAffiliationsAndBrandingAndSucceedWithResult( FacetURI::FromCanonicalSpec(kTestAndroidFacetURIAlpha3), StrategyOnCacheMiss::FETCH_OVER_NETWORK, GetTestEquivalenceClassAlpha()); PasswordStore::FormDigest android_form( GetTestAndroidCredentials(kTestAndroidRealmAlpha3)); EXPECT_THAT( GetAffiliatedWebRealms(android_form), testing::UnorderedElementsAre(kTestWebRealmAlpha1, kTestWebRealmAlpha2)); } TEST_P(AffiliatedMatchHelperTest, GetAffiliatedWebRealmsYieldsOnlyWebsites) { mock_affiliation_service() ->ExpectCallToGetAffiliationsAndBrandingAndSucceedWithResult( FacetURI::FromCanonicalSpec(kTestAndroidFacetURIBeta2), StrategyOnCacheMiss::FETCH_OVER_NETWORK, GetTestEquivalenceClassBeta()); PasswordStore::FormDigest android_form( GetTestAndroidCredentials(kTestAndroidRealmBeta2)); // This verifies that |kTestAndroidRealmBeta3| is not returned. EXPECT_THAT(GetAffiliatedWebRealms(android_form), testing::UnorderedElementsAre(kTestWebRealmBeta1)); } TEST_P(AffiliatedMatchHelperTest, GetAffiliatedWebRealmsYieldsEmptyResultsForWebKeyedForms) { EXPECT_THAT(GetAffiliatedWebRealms( GetTestObservedWebForm(kTestWebRealmBeta1, nullptr)), testing::IsEmpty()); } // Verifies that InjectAffiliationAndBrandingInformation() injects the realms of // web sites affiliated with the given Android application into the password // forms, as well as branding information corresponding to the application, if // any. TEST_P(AffiliatedMatchHelperTest, InjectAffiliationAndBrandingInformation) { std::vector<std::unique_ptr<PasswordForm>> forms; forms.push_back(std::make_unique<PasswordForm>( GetTestAndroidCredentials(kTestAndroidRealmAlpha3))); mock_affiliation_service() ->ExpectCallToGetAffiliationsAndBrandingAndSucceedWithResult( FacetURI::FromCanonicalSpec(kTestAndroidFacetURIAlpha3), StrategyOnCacheMiss::FAIL, GetTestEquivalenceClassAlpha()); forms.push_back(std::make_unique<PasswordForm>( GetTestAndroidCredentials(kTestAndroidRealmBeta2))); mock_affiliation_service() ->ExpectCallToGetAffiliationsAndBrandingAndSucceedWithResult( FacetURI::FromCanonicalSpec(kTestAndroidFacetURIBeta2), StrategyOnCacheMiss::FAIL, GetTestEquivalenceClassBeta()); forms.push_back(std::make_unique<PasswordForm>( GetTestAndroidCredentials(kTestAndroidRealmBeta3))); mock_affiliation_service() ->ExpectCallToGetAffiliationsAndBrandingAndSucceedWithResult( FacetURI::FromCanonicalSpec(kTestAndroidFacetURIBeta3), StrategyOnCacheMiss::FAIL, GetTestEquivalenceClassBeta()); forms.push_back(std::make_unique<PasswordForm>( GetTestAndroidCredentials(kTestAndroidRealmGamma))); mock_affiliation_service() ->ExpectCallToGetAffiliationsAndBrandingAndEmulateFailure( FacetURI::FromCanonicalSpec(kTestAndroidFacetURIGamma), StrategyOnCacheMiss::FAIL); PasswordStore::FormDigest digest = GetTestObservedWebForm(kTestWebRealmBeta1, nullptr); PasswordForm web_form; web_form.scheme = digest.scheme; web_form.signon_realm = digest.signon_realm; web_form.url = digest.url; forms.push_back(std::make_unique<PasswordForm>(web_form)); size_t expected_form_count = forms.size(); std::vector<std::unique_ptr<PasswordForm>> results( InjectAffiliationAndBrandingInformation(std::move(forms))); ASSERT_EQ(expected_form_count, results.size()); EXPECT_THAT(results[0]->affiliated_web_realm, testing::AnyOf(kTestWebRealmAlpha1, kTestWebRealmAlpha2)); EXPECT_EQ(kTestAndroidFacetNameAlpha3, results[0]->app_display_name); EXPECT_EQ(kTestAndroidFacetIconURLAlpha3, results[0]->app_icon_url.possibly_invalid_spec()); EXPECT_THAT(results[1]->affiliated_web_realm, testing::Eq(kTestWebRealmBeta1)); EXPECT_EQ(kTestAndroidFacetNameBeta2, results[1]->app_display_name); EXPECT_EQ(kTestAndroidFacetIconURLBeta2, results[1]->app_icon_url.possibly_invalid_spec()); EXPECT_THAT(results[2]->affiliated_web_realm, testing::Eq(kTestWebRealmBeta1)); EXPECT_EQ(kTestAndroidFacetNameBeta3, results[2]->app_display_name); EXPECT_EQ(kTestAndroidFacetIconURLBeta3, results[2]->app_icon_url.possibly_invalid_spec()); EXPECT_THAT(results[3]->affiliated_web_realm, testing::IsEmpty()); EXPECT_THAT(results[4]->affiliated_web_realm, testing::IsEmpty()); } // Note: IsValidWebCredential() is tested as part of GetAffiliatedAndroidRealms // tests above. TEST_P(AffiliatedMatchHelperTest, IsValidAndroidCredential) { EXPECT_FALSE(AffiliatedMatchHelper::IsValidAndroidCredential( GetTestObservedWebForm(kTestWebRealmBeta1, nullptr))); PasswordStore::FormDigest android_credential( GetTestAndroidCredentials(kTestAndroidRealmBeta2)); EXPECT_TRUE( AffiliatedMatchHelper::IsValidAndroidCredential(android_credential)); } // Verifies that affiliations for Android applications with pre-existing // credentials on start-up are prefetched. TEST_P( AffiliatedMatchHelperTest, PrefetchAffiliationsAndBrandingForPreexistingAndroidCredentialsOnStartup) { AddAndroidAndNonAndroidTestLogins(); match_helper()->Initialize(); RunUntilIdle(); ExpectPrefetchForTestLogins(); ASSERT_NO_FATAL_FAILURE(RunDeferredInitialization()); } // Stores credentials for Android applications between Initialize() and // DoDeferredInitialization(). Verifies that corresponding affiliation // information gets prefetched. TEST_P(AffiliatedMatchHelperTest, PrefetchAffiliationsForAndroidCredentialsAddedInInitializationDelay) { match_helper()->Initialize(); RunUntilIdle(); AddAndroidAndNonAndroidTestLogins(); ExpectPrefetchForTestLogins(); ASSERT_NO_FATAL_FAILURE(RunDeferredInitialization()); } // Stores credentials for Android applications after DoDeferredInitialization(). // Verifies that corresponding affiliation information gets prefetched. TEST_P(AffiliatedMatchHelperTest, PrefetchAffiliationsForAndroidCredentialsAddedAfterInitialization) { match_helper()->Initialize(); ASSERT_NO_FATAL_FAILURE(RunDeferredInitialization()); ExpectPrefetchForTestLogins(); AddAndroidAndNonAndroidTestLogins(); } TEST_P(AffiliatedMatchHelperTest, CancelPrefetchingAffiliationsAndBrandingForRemovedAndroidCredentials) { AddAndroidAndNonAndroidTestLogins(); match_helper()->Initialize(); ExpectPrefetchForTestLogins(); ASSERT_NO_FATAL_FAILURE(RunDeferredInitialization()); ExpectCancelPrefetchForTestLogins(); ExpectTrimCacheForTestLogins(); RemoveAndroidAndNonAndroidTestLogins(); } // Verify that whenever the primary key is updated for a credential (in which // case both REMOVE and ADD change notifications are sent out), then Prefetch() // is called in response to the addition before the call to // TrimCacheForFacetURI() in response to the removal, so that cached data is not // deleted and then immediately re-fetched. TEST_P(AffiliatedMatchHelperTest, PrefetchBeforeTrimForPrimaryKeyUpdates) { AddAndroidAndNonAndroidTestLogins(); match_helper()->Initialize(); ExpectPrefetchForTestLogins(); ASSERT_NO_FATAL_FAILURE(RunDeferredInitialization()); mock_affiliation_service()->ExpectCallToCancelPrefetch( kTestAndroidFacetURIAlpha3); { testing::InSequence in_sequence; mock_affiliation_service()->ExpectCallToPrefetch( kTestAndroidFacetURIAlpha3); mock_affiliation_service()->ExpectCallToTrimCacheForFacetURI( kTestAndroidFacetURIAlpha3); } PasswordForm old_form(GetTestAndroidCredentials(kTestAndroidRealmAlpha3)); PasswordForm new_form(old_form); new_form.username_value = base::ASCIIToUTF16("NewUserName"); UpdateLoginWithPrimaryKey(new_form, old_form); } // Stores and removes four credentials for the same an Android application, and // expects that Prefetch() and CancelPrefetch() will each be called four times. TEST_P(AffiliatedMatchHelperTest, DuplicateCredentialsArePrefetchWithMultiplicity) { EXPECT_CALL(*mock_affiliation_service(), Prefetch(FacetURI::FromCanonicalSpec(kTestAndroidFacetURIAlpha3), base::Time::Max())) .Times(4); PasswordForm android_form(GetTestAndroidCredentials(kTestAndroidRealmAlpha3)); AddLogin(android_form); // Store two credentials before initialization. PasswordForm android_form2(android_form); android_form2.username_value = base::ASCIIToUTF16("JohnDoe2"); AddLogin(android_form2); match_helper()->Initialize(); RunUntilIdle(); // Store one credential between initialization and deferred initialization. PasswordForm android_form3(android_form); android_form3.username_value = base::ASCIIToUTF16("JohnDoe3"); AddLogin(android_form3); ASSERT_NO_FATAL_FAILURE(RunDeferredInitialization()); // Store one credential after deferred initialization. PasswordForm android_form4(android_form); android_form4.username_value = base::ASCIIToUTF16("JohnDoe4"); AddLogin(android_form4); for (size_t i = 0; i < 4; ++i) { mock_affiliation_service()->ExpectCallToCancelPrefetch( kTestAndroidFacetURIAlpha3); mock_affiliation_service()->ExpectCallToTrimCacheForFacetURI( kTestAndroidFacetURIAlpha3); } RemoveLogin(android_form); RemoveLogin(android_form2); RemoveLogin(android_form3); RemoveLogin(android_form4); } TEST_P(AffiliatedMatchHelperTest, DestroyBeforeDeferredInitialization) { match_helper()->Initialize(); RunUntilIdle(); DestroyMatchHelper(); ASSERT_NO_FATAL_FAILURE(ExpectNoDeferredTasks()); } TEST_P(AffiliatedMatchHelperTest, GetAffiliatedAndroidRealmsAndWebsites) { // Disable this test when filling across affiliated websites disabled. if (!base::FeatureList::IsEnabled(features::kFillingAcrossAffiliatedWebsites)) return; mock_affiliation_service() ->ExpectCallToGetAffiliationsAndBrandingAndSucceedWithResult( FacetURI::FromCanonicalSpec(kTestWebFacetURIAlpha1), StrategyOnCacheMiss::FAIL, GetTestEquivalenceClassAlpha()); // This verifies that |kTestWebRealmAlpha2| is returned. EXPECT_THAT(GetAffiliatedAndroidRealms( GetTestObservedWebForm(kTestWebRealmAlpha1, nullptr)), testing::UnorderedElementsAre(kTestWebRealmAlpha2, kTestAndroidRealmAlpha3)); } INSTANTIATE_TEST_SUITE_P(FillingAcrossAffiliatedWebsites, AffiliatedMatchHelperTest, ::testing::Bool()); } // namespace password_manager
40.311978
101
0.763094
Ron423c
33c46982cc7dc4a9725b31f0be427aef3b71a382
616
cpp
C++
src/osm.ReferenceObject.cpp
rydotyosh/OpenSoundMixer
d81472a79655ba02b2456300f5ba345df8350b14
[ "BSD-3-Clause" ]
3
2018-05-31T11:06:57.000Z
2019-10-13T16:08:44.000Z
src/osm.ReferenceObject.cpp
rydotyosh/OpenSoundMixer
d81472a79655ba02b2456300f5ba345df8350b14
[ "BSD-3-Clause" ]
1
2015-09-13T12:35:23.000Z
2015-09-13T12:35:23.000Z
src/osm.ReferenceObject.cpp
rydotyosh/OpenSoundMixer
d81472a79655ba02b2456300f5ba345df8350b14
[ "BSD-3-Clause" ]
3
2015-12-15T05:10:43.000Z
2019-11-17T10:13:13.000Z
 #include "osm.ReferenceObject.h" namespace osm { ReferenceObject::ReferenceObject() : m_reference(1) {} ReferenceObject::~ReferenceObject() {} int ReferenceObject::AddRef() { std::atomic_fetch_add_explicit(&m_reference, 1, std::memory_order_consume); return m_reference; } int ReferenceObject::GetRef() { return m_reference; } int ReferenceObject::Release() { assert(m_reference > 0); bool destroy = std::atomic_fetch_sub_explicit(&m_reference, 1, std::memory_order_consume) == 1; if (destroy) { delete this; return 0; } return m_reference; } } // namespace osm
22
99
0.694805
rydotyosh
33c4c98476a813dd59ad1452ef1293dfd1abe55b
2,081
cpp
C++
src/qt/qtwebkit/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.cpp
viewdy/phantomjs
eddb0db1d253fd0c546060a4555554c8ee08c13c
[ "BSD-3-Clause" ]
1
2015-05-27T13:52:20.000Z
2015-05-27T13:52:20.000Z
src/qt/qtwebkit/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.cpp
mrampersad/phantomjs
dca6f77a36699eb4e1c46f7600cca618f01b0ac3
[ "BSD-3-Clause" ]
null
null
null
src/qt/qtwebkit/Source/WebCore/rendering/style/StyleDeprecatedFlexibleBoxData.cpp
mrampersad/phantomjs
dca6f77a36699eb4e1c46f7600cca618f01b0ac3
[ "BSD-3-Clause" ]
1
2022-02-18T10:41:38.000Z
2022-02-18T10:41:38.000Z
/* * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #include "config.h" #include "StyleDeprecatedFlexibleBoxData.h" #include "RenderStyle.h" namespace WebCore { StyleDeprecatedFlexibleBoxData::StyleDeprecatedFlexibleBoxData() : flex(RenderStyle::initialBoxFlex()) , flex_group(RenderStyle::initialBoxFlexGroup()) , ordinal_group(RenderStyle::initialBoxOrdinalGroup()) , align(RenderStyle::initialBoxAlign()) , pack(RenderStyle::initialBoxPack()) , orient(RenderStyle::initialBoxOrient()) , lines(RenderStyle::initialBoxLines()) { } StyleDeprecatedFlexibleBoxData::StyleDeprecatedFlexibleBoxData(const StyleDeprecatedFlexibleBoxData& o) : RefCounted<StyleDeprecatedFlexibleBoxData>() , flex(o.flex) , flex_group(o.flex_group) , ordinal_group(o.ordinal_group) , align(o.align) , pack(o.pack) , orient(o.orient) , lines(o.lines) { } bool StyleDeprecatedFlexibleBoxData::operator==(const StyleDeprecatedFlexibleBoxData& o) const { return flex == o.flex && flex_group == o.flex_group && ordinal_group == o.ordinal_group && align == o.align && pack == o.pack && orient == o.orient && lines == o.lines; } } // namespace WebCore
34.683333
103
0.725132
viewdy
33c5628d0344aa34fe0adbc9881b594c10f0ea1d
342
cpp
C++
C++ Programs/Reverse.cpp
Chibi-Shem/Hacktoberfest2020-Expert
324843464aec039e130e85a16e74b76d310f1497
[ "MIT" ]
77
2020-10-01T10:06:59.000Z
2021-11-08T08:57:18.000Z
C++ Programs/Reverse.cpp
Chibi-Shem/Hacktoberfest2020-Expert
324843464aec039e130e85a16e74b76d310f1497
[ "MIT" ]
55
2020-10-05T06:21:13.000Z
2021-09-11T18:06:50.000Z
C++ Programs/Reverse.cpp
Chibi-Shem/Hacktoberfest2020-Expert
324843464aec039e130e85a16e74b76d310f1497
[ "MIT" ]
327
2020-09-26T17:06:03.000Z
2021-10-09T06:04:39.000Z
#include <iostream> using namespace std; int main() { int n, reversedNumber = 0, remainder; cout << "Enter an integer: "; cin >> n; while(n != 0) { remainder = n%10; reversedNumber = reversedNumber*10 + remainder; n /= 10; } cout << "Reversed Number = " << reversedNumber; return 0; }
17.1
55
0.552632
Chibi-Shem
33c79eb81d45de364cab2f21a8e524ccc7d084fc
8,758
cpp
C++
ace/QoS/SOCK_Dgram_Mcast_QoS.cpp
cflowe/ACE
5ff60b41adbe1772372d1a43bcc1f2726ff8f810
[ "DOC" ]
36
2015-01-10T07:27:33.000Z
2022-03-07T03:32:08.000Z
Oem/ACE/ACE_wrappers/ace/QoS/SOCK_Dgram_Mcast_QoS.cpp
achilex/MgDev
f7baf680a88d37659af32ee72b9a2046910b00d8
[ "PHP-3.0" ]
2
2018-08-13T07:30:51.000Z
2019-02-25T03:04:31.000Z
ace/QoS/SOCK_Dgram_Mcast_QoS.cpp
cflowe/ACE
5ff60b41adbe1772372d1a43bcc1f2726ff8f810
[ "DOC" ]
38
2015-01-08T14:12:06.000Z
2022-01-19T08:33:00.000Z
// $Id: SOCK_Dgram_Mcast_QoS.cpp 96985 2013-04-11 15:50:32Z huangh $ #include "SOCK_Dgram_Mcast_QoS.h" #include "ace/Log_Category.h" #include "ace/OS_NS_sys_socket.h" #if defined (ACE_WIN32) #include "ace/Sock_Connect.h" // needed for subscribe_ifs() #endif /* ACE_WIN32 */ #if !defined (__ACE_INLINE__) #include "SOCK_Dgram_Mcast_QoS.inl" #endif /* __ACE_INLINE__ */ // This is a workaround for platforms with non-standard // definitions of the ip_mreq structure #if ! defined (IMR_MULTIADDR) #define IMR_MULTIADDR imr_multiaddr #endif /* ! defined (IMR_MULTIADDR) */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_Dgram_Mcast_QoS) // Dummy default constructor... ACE_SOCK_Dgram_Mcast_QoS::ACE_SOCK_Dgram_Mcast_QoS (options opts) : ACE_SOCK_Dgram_Mcast (opts) { ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::ACE_SOCK_Dgram_Mcast_QoS"); } int ACE_SOCK_Dgram_Mcast_QoS::open (const ACE_INET_Addr &addr, const ACE_QoS_Params &qos_params, int protocol_family, int protocol, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags, int reuse_addr) { ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::open"); ACE_UNUSED_ARG (qos_params); // Only perform the <open> initialization if we haven't been opened // earlier. if (this->get_handle () != ACE_INVALID_HANDLE) return 0; ACELIB_DEBUG ((LM_DEBUG, "Get Handle Returns Invalid Handle\n")); if (ACE_SOCK::open (SOCK_DGRAM, protocol_family, protocol, protocolinfo, g, flags, reuse_addr) == -1) return -1; return this->open_i (addr, 0, reuse_addr); } int ACE_SOCK_Dgram_Mcast_QoS::subscribe_ifs (const ACE_INET_Addr &mcast_addr, const ACE_QoS_Params &qos_params, const ACE_TCHAR *net_if, int protocol_family, int protocol, int reuse_addr, ACE_Protocol_Info *protocolinfo) { ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::subscribe_ifs"); #if defined (ACE_WIN32) // Windows NT's winsock has trouble with multicast subscribes in the // presence of multiple network interfaces when the IP address is // given as INADDR_ANY. It will pick the first interface and only // accept mcast there. So, to work around this, cycle through all // of the interfaces known and subscribe to all the non-loopback // ones. // // Note that this only needs to be done on NT, but there's no way to // tell at this point if the code will be running on NT - only if it // is compiled for NT-only or for NT/95, and that doesn't really // help us. It doesn't hurt to do this on Win95, it's just a little // slower than it normally would be. // // NOTE - <ACE_Sock_Connect::get_ip_interfaces> doesn't always get all // of the interfaces. In particular, it may not get a PPP interface. This // is a limitation of the way <ACE_Sock_Connect::get_ip_interfaces> works // with MSVC. The reliable way of getting the interface list is // available only with MSVC 5. if (net_if == 0) { ACE_INET_Addr *if_addrs = 0; size_t if_cnt; if (ACE::get_ip_interfaces (if_cnt, if_addrs) != 0) return -1; size_t nr_subscribed = 0; if (if_cnt < 2) { if (this->subscribe (mcast_addr, qos_params, reuse_addr, ACE_TEXT ("0.0.0.0"), protocol_family, protocol, protocolinfo) == 0) ++nr_subscribed; } else // Iterate through all the interfaces, figure out which ones // offer multicast service, and subscribe to them. while (if_cnt > 0) { --if_cnt; // Convert to 0-based for indexing, next loop check. if (if_addrs[if_cnt].is_loopback()) continue; if (this->subscribe (mcast_addr, qos_params, reuse_addr, ACE_TEXT_CHAR_TO_TCHAR (if_addrs[if_cnt].get_host_addr()), protocol_family, protocol, protocolinfo) == 0) ++nr_subscribed; } delete [] if_addrs; if (nr_subscribed == 0) { errno = ENODEV; return -1; } else // 1 indicates a "short-circuit" return. This handles the // rather bizarre semantics of checking all the interfaces on // NT. return 1; } #else ACE_UNUSED_ARG (mcast_addr); ACE_UNUSED_ARG (qos_params); ACE_UNUSED_ARG (protocol_family); ACE_UNUSED_ARG (protocol); ACE_UNUSED_ARG (reuse_addr); ACE_UNUSED_ARG (protocolinfo); #endif /* ACE_WIN32 */ // Otherwise, do it like everyone else... // Create multicast request. if (this->make_multicast_ifaddr (0, mcast_addr, net_if) == -1) return -1; else return 0; } int ACE_SOCK_Dgram_Mcast_QoS::subscribe (const ACE_INET_Addr &mcast_addr, const ACE_QoS_Params &qos_params, int reuse_addr, const ACE_TCHAR *net_if, int protocol_family, int protocol, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags, ACE_QoS_Session *qos_session) { ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::subscribe"); if (this->open (mcast_addr, qos_params, protocol_family, protocol, protocolinfo, g, flags, reuse_addr) == -1) return -1; // The following method call only applies to Win32 currently. int result = this->subscribe_ifs (mcast_addr, qos_params, net_if, protocol_family, protocol, reuse_addr, protocolinfo); // Check for the "short-circuit" return value of 1 (for NT). if (result != 0) return result; // Tell network device driver to read datagrams with a // <mcast_request_if_> IP interface. else { // Check if the mcast_addr passed into this method is the // same as the QoS session address. if (qos_session != 0 && mcast_addr == qos_session->dest_addr ()) { // Subscribe to the QoS session. if (this->qos_manager_.join_qos_session (qos_session) == -1) ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Unable to join QoS Session\n")), -1); } else { if (this->close () != 0) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("Unable to close socket\n"))); ACELIB_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Dest Addr in the QoS Session does") ACE_TEXT (" not match the address passed into") ACE_TEXT (" subscribe\n")), -1); } ip_mreq ret_mreq; this->make_multicast_ifaddr (&ret_mreq, mcast_addr, net_if); // XX This is windows stuff only. fredk if (ACE_OS::join_leaf (this->get_handle (), reinterpret_cast<const sockaddr *> (&ret_mreq.IMR_MULTIADDR.s_addr), sizeof ret_mreq.IMR_MULTIADDR.s_addr, qos_params) == ACE_INVALID_HANDLE && errno != ENOTSUP) return -1; else if (qos_params.socket_qos () != 0 && qos_session != 0) qos_session->qos (*(qos_params.socket_qos ())); return 0; } } ACE_END_VERSIONED_NAMESPACE_DECL
34.345098
97
0.523407
cflowe
33c8a08e2877efa578534cb6f768c6ffe6a21d4a
4,589
cpp
C++
src/opengl/debugcontext.cpp
OpenSpace/Ghoul
af5545a13d140b15e7b37f581ea7dde522be2b5b
[ "MIT" ]
8
2016-09-13T12:39:49.000Z
2022-03-21T12:30:50.000Z
src/opengl/debugcontext.cpp
OpenSpace/Ghoul
af5545a13d140b15e7b37f581ea7dde522be2b5b
[ "MIT" ]
33
2016-07-07T20:35:05.000Z
2021-10-15T03:12:13.000Z
src/opengl/debugcontext.cpp
OpenSpace/Ghoul
af5545a13d140b15e7b37f581ea7dde522be2b5b
[ "MIT" ]
16
2015-06-24T20:41:28.000Z
2022-01-08T04:14:03.000Z
/***************************************************************************************** * * * GHOUL * * General Helpful Open Utility Library * * * * Copyright (c) 2012-2021 * * * * 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 <ghoul/opengl/debugcontext.h> #include <ghoul/misc/assert.h> #include <ghoul/misc/exception.h> #include <map> #include <type_traits> namespace ghoul::opengl::debug { namespace { void internalCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei, const GLchar* message, const GLvoid* userParam) { const CallbackFunction& cb = *reinterpret_cast<const CallbackFunction*>(userParam); cb(Source(source), Type(type), Severity(severity), id, std::string(message)); } } // namespace void setDebugOutput(DebugOutput debug, SynchronousOutput synchronous) { if (debug) { glEnable(GL_DEBUG_OUTPUT); } else { glDisable(GL_DEBUG_OUTPUT); } if (synchronous) { glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); } else { glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS); } } void setDebugMessageControl(Source source, Type type, Severity severity, Enabled enabled) { glDebugMessageControl( static_cast<GLenum>(source), static_cast<GLenum>(type), static_cast<GLenum>(severity), 0, nullptr, enabled ? GL_TRUE : GL_FALSE ); } void setDebugMessageControl(Source source, Type type, const std::vector<unsigned int>& identifiers, Enabled enabled) { ghoul_assert(source != Source::DontCare, "source must not be Source::Dontcare"); ghoul_assert(type != Type::DontCare, "type must not be Type::Dontcare"); static_assert( std::is_same<unsigned int, GLuint>::value, "We exploit that 'int' and 'GLsizei' are the same for glDebugMessageControl" ); glDebugMessageControl( static_cast<GLenum>(source), static_cast<GLenum>(type), GL_DONT_CARE, static_cast<GLsizei>(identifiers.size()), identifiers.data(), enabled ? GL_TRUE : GL_FALSE ); } void setDebugCallback(CallbackFunction callback) { // We have to store the function pointer that is passed into this function locally as // it might otherwise be destroyed (and still be referenced by \c internalCallback. // In a perfect world, we'd want to capture the function pointer, but the OpenGL // callback only allows pure C functions static CallbackFunction storage; storage = callback; glDebugMessageCallback(internalCallback, &storage); } } // namespace ghoul::opengl::debug
44.125
90
0.548486
OpenSpace
33c8d159e7f8588c819bf84b5024a9364e2083ed
249
cpp
C++
partitioner/problem/default_partitioner_inputs.cpp
elenabac/dgswemv2
ecc776811de304cbae7bfa696b3d22c513e7d4de
[ "MIT" ]
5
2018-05-30T08:43:10.000Z
2021-12-14T18:33:10.000Z
partitioner/problem/default_partitioner_inputs.cpp
elenabac/dgswemv2
ecc776811de304cbae7bfa696b3d22c513e7d4de
[ "MIT" ]
57
2018-05-08T21:44:14.000Z
2019-11-07T17:13:30.000Z
partitioner/problem/default_partitioner_inputs.cpp
elenabac/dgswemv2
ecc776811de304cbae7bfa696b3d22c513e7d4de
[ "MIT" ]
7
2018-05-07T21:50:49.000Z
2021-04-30T14:02:02.000Z
#include "default_partitioner_inputs.hpp" DefaultPartitionerInputs::DefaultPartitionerInputs(const MeshMetaData& mesh) { for (const auto& elt : mesh.elements) { weights.insert(std::make_pair(elt.first, std::vector<double>{1.})); } }
35.571429
78
0.726908
elenabac
33ca6ee86f02ec007a04d2125f9aabdbea0ea620
1,952
cc
C++
python/paddle/fluid/tests/custom_op/dispatch_test_op.cc
OuyangChao/Paddle
cac9635a6733ffbbd816b33e21c3054e0cd81ab1
[ "Apache-2.0" ]
1
2021-03-04T07:51:32.000Z
2021-03-04T07:51:32.000Z
python/paddle/fluid/tests/custom_op/dispatch_test_op.cc
OuyangChao/Paddle
cac9635a6733ffbbd816b33e21c3054e0cd81ab1
[ "Apache-2.0" ]
1
2021-03-01T18:17:48.000Z
2021-03-01T18:17:48.000Z
python/paddle/fluid/tests/custom_op/dispatch_test_op.cc
OuyangChao/Paddle
cac9635a6733ffbbd816b33e21c3054e0cd81ab1
[ "Apache-2.0" ]
null
null
null
// Copyright (c) 2021 PaddlePaddle Authors. 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 <iostream> #include <vector> #include "paddle/extension.h" template <typename data_t> void assign_cpu_kernel(const data_t* x_data, data_t* out_data, int64_t x_numel) { for (int i = 0; i < x_numel; ++i) { out_data[i] = x_data[i]; } } std::vector<paddle::Tensor> DispatchTestInterger(const paddle::Tensor& x) { auto out = paddle::Tensor(paddle::PlaceType::kCPU); out.reshape(x.shape()); PD_DISPATCH_INTEGRAL_TYPES( x.type(), "assign_cpu_kernel", ([&] { assign_cpu_kernel<data_t>( x.data<data_t>(), out.mutable_data<data_t>(), x.size()); })); return {out}; } PD_BUILD_OP(dispatch_test_integer) .Inputs({"X"}) .Outputs({"Out"}) .SetKernelFn(PD_KERNEL(DispatchTestInterger)); std::vector<paddle::Tensor> DispatchTestFloatAndInteger( const paddle::Tensor& x) { auto out = paddle::Tensor(paddle::PlaceType::kCPU); out.reshape(x.shape()); PD_DISPATCH_FLOATING_AND_INTEGRAL_TYPES( x.type(), "assign_cpu_kernel", ([&] { assign_cpu_kernel<data_t>( x.data<data_t>(), out.mutable_data<data_t>(), x.size()); })); return {out}; } PD_BUILD_OP(dispatch_test_float_and_integer) .Inputs({"X"}) .Outputs({"Out"}) .SetKernelFn(PD_KERNEL(DispatchTestFloatAndInteger));
30.030769
75
0.672643
OuyangChao
33caa8cba2e71a171072eb009157adf123bba03e
18,658
cpp
C++
src/geometry/geometry_ply.cpp
Yoyochen0106/Pangolin
e55463bd2bdd758e46ded7d95332e31f9cdc4f71
[ "MIT" ]
662
2019-09-01T02:16:59.000Z
2022-03-29T19:24:07.000Z
src/geometry/geometry_ply.cpp
Yoyochen0106/Pangolin
e55463bd2bdd758e46ded7d95332e31f9cdc4f71
[ "MIT" ]
38
2019-09-05T05:02:20.000Z
2022-03-30T02:59:49.000Z
src/geometry/geometry_ply.cpp
Yoyochen0106/Pangolin
e55463bd2bdd758e46ded7d95332e31f9cdc4f71
[ "MIT" ]
104
2019-09-01T07:41:58.000Z
2022-03-27T16:24:54.000Z
/* This file is part of the Pangolin Project. * http://github.com/stevenlovegrove/Pangolin * * Copyright (c) 2014 Steven Lovegrove * * 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 <pangolin/geometry/geometry_ply.h> #include <pangolin/utils/file_utils.h> #include <pangolin/utils/variadic_all.h> #include <pangolin/utils/parse.h> #include <pangolin/utils/type_convert.h> #include <pangolin/utils/simple_math.h> // TODO: Should really remove need for GL here. #include <pangolin/gl/gl.h> namespace pangolin { #define FORMAT_STRING_LIST(x) #x, const char* PlyHeaderString[] = { PLY_HEADER_LIST(FORMAT_STRING_LIST) }; const char* PlyFormatString[] = { PLY_FORMAT_LIST(FORMAT_STRING_LIST) }; const char* PlyTypeString[] = { PLY_TYPE_LIST(FORMAT_STRING_LIST) }; #undef FORMAT_STRING_LIST PLY_GROUP_LIST(PANGOLIN_DEFINE_PARSE_TOKEN) void ParsePlyHeader(PlyHeaderDetails& ply, std::istream& is) { // 'Active' element for property definitions. int current_element = -1; // Check header is correct PlyHeader token = ParseTokenPlyHeader(is); if( token != PlyHeader_ply) { throw std::runtime_error("Bad PLY header magic."); } ConsumeToNewline(is); while(is.good() && token != PlyHeader_end_header) { token = ParseTokenPlyHeader(is); switch (token) { case PlyHeader_format: // parse PLY format and version ConsumeWhitespace(is); ply.format = ParseTokenPlyFormat(is); ConsumeWhitespace(is); ply.version = ReadToken(is); break; case PlyHeader_element: { current_element = ply.elements.size(); PlyElementDetails el; el.stride_bytes = 0; ConsumeWhitespace(is); el.name = ReadToken(is); ConsumeWhitespace(is); el.num_items = FromString<int>(ReadToken(is)); ply.elements.push_back(el); break; } case PlyHeader_property: if(current_element >= 0) { PlyElementDetails& el = ply.elements[current_element]; PlyPropertyDetails prop; ConsumeWhitespace(is); const PlyType t = ParseTokenPlyType(is); if( t == PlyType_list) { ConsumeWhitespace(is); const PlyType idtype = ParseTokenPlyType(is); ConsumeWhitespace(is); const PlyType itemtype = ParseTokenPlyType(is); prop.list_index_type = PlyTypeGl[idtype]; prop.type = PlyTypeGl[itemtype]; prop.offset_bytes = el.stride_bytes; prop.num_items = -1; el.stride_bytes = -1; }else{ prop.type = PlyTypeGl[t]; prop.list_index_type = GL_NONE; prop.offset_bytes = el.stride_bytes; prop.num_items = 1; const size_t size_bytes = GlDataTypeBytes(prop.type); if( el.stride_bytes >= 0) { el.stride_bytes += size_bytes; } } ConsumeWhitespace(is); prop.name = ReadToken(is); el.properties.push_back(prop); }else{ pango_print_warn("PLY Parser: property declaration before element. Ignoring line."); } break; case PlyHeader_comment: case PlyHeader_end_header: break; default: pango_print_warn("PLY Parser: Unknown token - ignoring line."); } ConsumeToNewline(is); } } void ParsePlyAscii(pangolin::Geometry& /*geom*/, const PlyHeaderDetails& /*ply*/, std::istream& /*is*/) { throw std::runtime_error("Not implemented."); } void AddVertexNormals(pangolin::Geometry& geom) { auto it_geom = geom.buffers.find("geometry"); auto it_face = geom.objects.find("default"); if(it_geom != geom.buffers.end() && it_face != geom.objects.end()) { const auto it_vbo = it_geom->second.attributes.find("vertex"); const auto it_ibo = it_face->second.attributes.find("vertex_indices"); if(it_vbo != it_geom->second.attributes.end() && it_ibo != it_face->second.attributes.end()) { const auto& ibo = get<Image<uint32_t>>(it_ibo->second); const auto& vbo = get<Image<float>>(it_vbo->second); // Assume we have triangles. PANGO_ASSERT(ibo.w == 3 && vbo.w == 3); ManagedImage<float> vert_normals(3, vbo.h); ManagedImage<size_t> vert_face_count(1, vbo.h); vert_normals.Fill(0.0f); vert_face_count.Fill(0); float ab[3]; float ac[3]; float fn[3]; for(size_t i=0; i < ibo.h; ++i) { uint32_t i0 = ibo(0,i); uint32_t i1 = ibo(1,i); uint32_t i2 = ibo(2,i); MatSub<3,1>(ab, vbo.RowPtr(i1), vbo.RowPtr(i0)); MatSub<3,1>(ac, vbo.RowPtr(i2), vbo.RowPtr(i0)); VecCross3(fn, ab, ac); Normalise<3>(fn); for(size_t v=0; v < 3; ++v) { MatAdd<3,1>(vert_normals.RowPtr(ibo(v,i)), vert_normals.RowPtr(ibo(v,i)), fn); ++vert_face_count(0,ibo(v,i)); } } for(size_t v=0; v < vert_normals.h; ++v) { // Compute average MatMul<3,1>(vert_normals.RowPtr(v), 1.0f / vert_face_count(0,v)); } auto& el = geom.buffers["normal"]; (ManagedImage<float>&)el = std::move(vert_normals); auto& attr_norm = el.attributes["normal"]; attr_norm = MakeAttribute(GL_FLOAT, el.h, 3, el.ptr, el.pitch); } } } void StandardizeXyzToVertex(pangolin::Geometry& geom) { auto it_verts = geom.buffers.find("geometry"); if(it_verts != geom.buffers.end()) { auto& verts = it_verts->second; auto it_x = verts.attributes.find("x"); auto it_y = verts.attributes.find("y"); auto it_z = verts.attributes.find("z"); if(all_found(verts.attributes, it_x, it_y, it_z)) { if(verts.attributes.find("vertex") == verts.attributes.end()) { auto& vertex = verts.attributes["vertex"]; auto& imx = get<Image<float>>(it_x->second); auto& imy = get<Image<float>>(it_y->second); auto& imz = get<Image<float>>(it_z->second); if(imx.ptr + 1 == imy.ptr && imy.ptr + 1 == imz.ptr) { vertex = MakeAttribute(GL_FLOAT, verts.h, 3, imx.ptr, imx.pitch); }else{ throw std::runtime_error("Ooops"); } } verts.attributes.erase(it_x); verts.attributes.erase(it_y); verts.attributes.erase(it_z); } } } void StandardizeRgbToColor(pangolin::Geometry& geom) { auto it_verts = geom.buffers.find("geometry"); if(it_verts != geom.buffers.end()) { auto& verts = it_verts->second; auto it_r = verts.attributes.find("r"); auto it_g = verts.attributes.find("g"); auto it_b = verts.attributes.find("b"); auto it_a = verts.attributes.find("a"); if(!all_found(verts.attributes, it_r, it_b, it_g)) { it_r = verts.attributes.find("red"); it_g = verts.attributes.find("green"); it_b = verts.attributes.find("blue"); it_a = verts.attributes.find("alpha"); } if(all_found(verts.attributes, it_r, it_g, it_b)) { const bool have_alpha = it_a != verts.attributes.end(); if(verts.attributes.find("color") == verts.attributes.end()) { Geometry::Element::Attribute& red = it_r->second; Geometry::Element::Attribute& color = verts.attributes["color"]; // TODO: Check that these really are contiguous in memory... if(auto attrib = get_if<Image<float>>(&red)) { color = Image<float>(attrib->ptr, have_alpha ? 4 : 3, verts.h, verts.pitch); }else if(auto attrib = get_if<Image<uint8_t>>(&red)) { color = Image<uint8_t>(attrib->ptr, have_alpha ? 4 : 3, verts.h, verts.pitch); }else if(auto attrib = get_if<Image<uint16_t>>(&red)) { color = Image<uint16_t>(attrib->ptr, have_alpha ? 4 : 3, verts.h, verts.pitch); }else if(auto attrib = get_if<Image<uint32_t>>(&red)) { color = Image<uint32_t>(attrib->ptr, have_alpha ? 4 : 3, verts.h, verts.pitch); } } verts.attributes.erase(it_r); verts.attributes.erase(it_g); verts.attributes.erase(it_b); if(have_alpha) verts.attributes.erase(it_a); } } } void StandardizeMultiTextureFaceToXyzuv(pangolin::Geometry& geom) { const auto it_multi_texture_face = geom.buffers.find("multi_texture_face"); const auto it_multi_texture_vertex = geom.buffers.find("multi_texture_vertex"); const auto it_geom = geom.buffers.find("geometry"); const auto it_face = geom.objects.find("default"); if(it_geom != geom.buffers.end() && it_face != geom.objects.end()) { const auto it_vbo = it_geom->second.attributes.find("vertex"); const auto it_ibo = it_face->second.attributes.find("vertex_indices"); if(all_found(geom.buffers, it_multi_texture_face, it_multi_texture_vertex) && it_vbo != it_geom->second.attributes.end() && it_ibo != it_face->second.attributes.end() ) { const auto it_uv_ibo = it_multi_texture_face->second.attributes.find("texture_vertex_indices"); const auto it_tx = it_multi_texture_face->second.attributes.find("tx"); const auto it_tn = it_multi_texture_face->second.attributes.find("tn"); const auto it_u = it_multi_texture_vertex->second.attributes.find("u"); const auto it_v = it_multi_texture_vertex->second.attributes.find("v"); if(all_found(it_multi_texture_vertex->second.attributes, it_u, it_v) && it_uv_ibo != it_multi_texture_face->second.attributes.end() ) { // We're going to create a new vertex buffer to hold uv's too auto& orig_ibo = get<Image<uint32_t>>(it_ibo->second); const auto& orig_xyz = get<Image<float>>(it_vbo->second); const auto& uv_ibo = get<Image<uint32_t>>(it_uv_ibo->second); const auto& u = get<Image<float>>(it_u->second); const auto& v = get<Image<float>>(it_v->second); const auto& tx = get<Image<uint8_t>>(it_tx->second); const auto& tn = get<Image<uint32_t>>(it_tn->second); PANGO_ASSERT(u.h == v.h); PANGO_ASSERT(orig_ibo.w == 3 && uv_ibo.w == 3); pangolin::Geometry::Element new_xyzuv(5*sizeof(float), u.h); Image<float> new_xyz = new_xyzuv.UnsafeReinterpret<float>().SubImage(0,0,3,new_xyzuv.h); Image<float> new_uv = new_xyzuv.UnsafeReinterpret<float>().SubImage(3,0,2,new_xyzuv.h); new_xyzuv.attributes["vertex"] = new_xyz; new_xyzuv.attributes["uv"] = new_uv; for(size_t face=0; face < orig_ibo.h; ++face) { uint32_t vtn = tn(0,face); uint8_t vtx = tx(0,face); PANGO_ASSERT(vtx==0, "Haven't implemented multi-texture yet."); for(size_t vert=0; vert < 3; ++vert) { uint32_t& orig_xyz_index = orig_ibo(vert,vtn); const uint32_t uv_index = uv_ibo(vert,face); PANGO_ASSERT(uv_index < new_xyzuv.h && orig_xyz_index < orig_xyz.h); for(int el=0; el < 3; ++el) { new_xyz(el,uv_index) = orig_xyz(el,orig_xyz_index); } new_uv(0,uv_index) = u(0,uv_index); new_uv(1,uv_index) = v(0,uv_index); orig_xyz_index = uv_index; } } geom.buffers["geometry"] = std::move(new_xyzuv); geom.buffers.erase(it_multi_texture_face); geom.buffers.erase(it_multi_texture_vertex); } } } } void Standardize(pangolin::Geometry& geom) { StandardizeXyzToVertex(geom); StandardizeRgbToColor(geom); StandardizeMultiTextureFaceToXyzuv(geom); AddVertexNormals(geom); } inline int ReadGlIntType(GLenum type, std::istream& is) { // TODO: This seems really dodgey... // int may not be big enough and if the datatype is smaller will it be padded? int v = 0; is.read( (char*)&v, GlDataTypeBytes(type)); return v; } inline void ReadInto(std::vector<unsigned char>& vec, std::istream& is, size_t num_bytes) { const size_t current_size = vec.size(); vec.resize(current_size + num_bytes); is.read((char*)vec.data() + current_size, num_bytes); } void ParsePlyLE(pangolin::Geometry& geom, PlyHeaderDetails& ply, std::istream& is) { std::vector<uint8_t> buffer; for(auto& el : ply.elements) { pangolin::Geometry::Element geom_el; if(el.stride_bytes > 0) { // This will usually be the case for vertex buffers with a known number of attributes PANGO_ASSERT(el.num_items > 0); geom_el.Reinitialise(el.stride_bytes, el.num_items); is.read((char*)geom_el.ptr, geom_el.Area()); }else { // This will generally be the case for face data (containing a list of vertex indices) // Reserve enough space for a list of quads buffer.clear(); buffer.reserve(el.num_items * el.properties.size() * 4); for(int i=0; i< el.num_items; ++i) { size_t offset_bytes = 0; for(auto& prop : el.properties) { if(prop.isList()) { const int list_items = ReadGlIntType(prop.list_index_type, is); if(prop.num_items == -1) { prop.num_items = list_items; prop.offset_bytes = offset_bytes; }else{ PANGO_ASSERT(prop.num_items == list_items); } } const size_t num_bytes = prop.num_items * GlDataTypeBytes(prop.type); ReadInto(buffer, is, num_bytes); offset_bytes += num_bytes; } } // Update element stride now we know el.stride_bytes = 0; for(auto& prop : el.properties) { el.stride_bytes += prop.num_items * GlDataTypeBytes(prop.type); } geom_el.Reinitialise(el.stride_bytes, el.num_items); PANGO_ASSERT(geom_el.SizeBytes() == buffer.size()); std::memcpy(geom_el.ptr, buffer.data(), buffer.size()); } for(auto& prop : el.properties) { geom_el.attributes[prop.name] = MakeAttribute( prop.type, el.num_items, prop.num_items, geom_el.ptr + prop.offset_bytes, geom_el.pitch ); } if(el.name == "vertex") { geom.buffers["geometry"] = std::move(geom_el); }else if(el.name == "face") { geom.objects.emplace("default", std::move(geom_el)); }else{ geom.buffers[el.name] = std::move(geom_el); } } Standardize(geom); } void ParsePlyBE(pangolin::Geometry& /*geom*/, const PlyHeaderDetails& /*ply*/, std::istream& /*is*/) { throw std::runtime_error("Not implemented."); } void AttachAssociatedTexturesPly(pangolin::Geometry& geom, const std::string& filename) { // For PLY, texture names are generally implicit auto dot = filename.find_last_of('.'); if(dot != filename.npos) { const std::string base = filename.substr(0, dot); for(int i=0; i < 10; ++i) { const std::string glob = FormatString("%_%.*", base, i); std::vector<std::string> file_vec; if(FilesMatchingWildcard(glob, file_vec)) { for(const auto& file : file_vec) { try { geom.textures[FormatString("texture_%",i)] = LoadImage(file); break; }catch(std::runtime_error&) { } } } } } } pangolin::Geometry LoadGeometryPly(const std::string& filename) { std::ifstream bFile( filename.c_str(), std::ios::in | std::ios::binary ); if( !bFile.is_open() ) throw std::runtime_error("Unable to open PLY file: " + filename); PlyHeaderDetails ply; ParsePlyHeader(ply, bFile); // Initialise geom object pangolin::Geometry geom; // Fill in geometry from file. if(ply.format == PlyFormat_ascii) { ParsePlyAscii(geom, ply, bFile); }else if(ply.format == PlyFormat_binary_little_endian) { ParsePlyLE(geom, ply, bFile); }else if(ply.format == PlyFormat_binary_big_endian) { ParsePlyBE(geom, ply, bFile); } AttachAssociatedTexturesPly(geom, filename); return geom; } }
38.549587
107
0.571873
Yoyochen0106
33cb22cd51682af287618954337dae81db4000a9
2,128
cc
C++
columnar_batch/columnar_batch_encoder_test.cc
google/fusion-power-video
5edaa6549870807b5ca3cb0ead90cd584e745bcd
[ "Apache-2.0" ]
11
2020-03-13T04:18:09.000Z
2021-11-19T21:01:00.000Z
columnar_batch/columnar_batch_encoder_test.cc
google/fusion-power-video
5edaa6549870807b5ca3cb0ead90cd584e745bcd
[ "Apache-2.0" ]
5
2020-03-09T10:24:59.000Z
2020-08-19T09:28:36.000Z
columnar_batch/columnar_batch_encoder_test.cc
google/fusion-power-video
5edaa6549870807b5ca3cb0ead90cd584e745bcd
[ "Apache-2.0" ]
6
2020-03-09T10:00:16.000Z
2020-10-13T16:42:50.000Z
#include <iostream> #include <memory> #include "columnar_batch_encoder.h" std::unique_ptr<fpvc::columnarbatch::ColumnarBatchEncoder> encoder; std::unique_ptr<fpvc::columnarbatch::ColumnarBatchEncoder> encoder2; void printRecordBatch(fpvc::columnarbatch::BatchPtr batch) { if (batch) { std::cout << "Got the Batch! \n" << batch->LatestTimestamp() << std::endl; encoder->ReturnProcessedBatch(batch); } else { std::cout << "Got the NULLPTR!" << std::endl; } } void printRecordBatch2(fpvc::columnarbatch::BatchPtr batch) { if (batch) { for (int i=0;i<10000000;i++) std::cout << ""; std::cout << "Got the Batch!" << batch->LatestTimestamp() << std::endl; encoder2->ReturnProcessedBatch(batch); } else { std::cout << "Got the NULLPTR!" << std::endl; } } int main() { std::cout << "FPV Arrow Encoder Test" << std::endl; encoder = std::make_unique<fpvc::columnarbatch::ColumnarBatchEncoder>(100,100,0,false,&printRecordBatch,2); uint16_t img[100*100]; std::cout << "Pushing frame." << std::endl; encoder->PushFrame(123456,img,img).wait(); std::cout << "Pushing second frame." << std::endl; encoder->PushFrame(234567,img,img).wait(); std::cout << "Frame buffer available again." << std::endl; auto end = encoder->Close().get(); std::cout << "Closed - " << end << "." << std::endl; std::cout << "Second part" << std::endl; encoder2 = std::make_unique<fpvc::columnarbatch::ColumnarBatchEncoder>(100,100,0,false,&printRecordBatch2,13); for (int i=0;i<500;i++) { uint16_t img2[100*100]; img2[0] = i; for (int j=1;j<100*100;j++) { img2[j] = std::rand(); } std::cout << "Pushing frame " << std::to_string(i) << std::endl; std::shared_future<void*> fut = encoder2->PushFrame(i,img2,img2); std::async(std::launch::async, [](std::shared_future<void*> fut_) { fut_.get(); std::cout << "Buffer is back!" << std::endl;}, std::move(fut)); } auto end2 = encoder2->Close().get(); std::cout << "Closed - " << end2 << "." << std::endl; }
40.150943
151
0.603853
google
33ce96f7ea3a91e7332c3a780488ff4a06c1f3e0
14,174
cpp
C++
src/cfdcore_schnorrsig.cpp
ko-matsu/cfd-core
ad07f210cfefe7838a6eaf4ce0e13a27c0d6167e
[ "MIT" ]
5
2019-10-12T11:05:26.000Z
2020-05-10T19:09:19.000Z
src/cfdcore_schnorrsig.cpp
ko-matsu/cfd-core
ad07f210cfefe7838a6eaf4ce0e13a27c0d6167e
[ "MIT" ]
128
2019-10-02T06:33:49.000Z
2022-03-20T02:14:35.000Z
src/cfdcore_schnorrsig.cpp
p2pderivatives/cfd-core
399750cb1fa320f3b203092290ebb9f3ed4fe742
[ "MIT" ]
4
2019-10-22T07:59:43.000Z
2020-05-29T11:06:00.000Z
// Copyright 2020 CryptoGarage #include "cfdcore/cfdcore_schnorrsig.h" #include <cstring> #include <string> #include <vector> #include "cfdcore/cfdcore_exception.h" #include "cfdcore/cfdcore_util.h" #include "secp256k1.h" // NOLINT #include "secp256k1_schnorrsig.h" // NOLINT #include "secp256k1_util.h" // NOLINT #include "wally_core.h" // NOLINT namespace cfd { namespace core { using cfd::core::ByteData; using cfd::core::ByteData256; using cfd::core::CfdError; using cfd::core::CfdException; using cfd::core::HashUtil; // ---------------------------------------------------------------------------- // SchnorrSignature // ---------------------------------------------------------------------------- SchnorrSignature::SchnorrSignature() : data_(), sighash_type_(SigHashAlgorithm::kSigHashDefault) {} SchnorrSignature::SchnorrSignature(const ByteData &data) : data_(data), sighash_type_(SigHashAlgorithm::kSigHashDefault) { if (data_.GetDataSize() == SchnorrSignature::kSchnorrSignatureSize + 1) { auto bytes = data.GetBytes(); uint8_t sighash_type = bytes[SchnorrSignature::kSchnorrSignatureSize]; if ((sighash_type == 0) || (!IsValidSigHashType(sighash_type))) { throw CfdException( CfdError::kCfdIllegalArgumentError, "Invalid Schnorr signature hash type."); } sighash_type_.SetFromSigHashFlag(sighash_type); data_ = ByteData(bytes.data(), SchnorrSignature::kSchnorrSignatureSize); } else if (data_.GetDataSize() != SchnorrSignature::kSchnorrSignatureSize) { throw CfdException( CfdError::kCfdIllegalArgumentError, "Invalid Schnorr signature data."); } } SchnorrSignature::SchnorrSignature(const std::string &data) : SchnorrSignature(ByteData(data)) {} SchnorrSignature::SchnorrSignature(const SchnorrSignature &object) { data_ = object.data_; sighash_type_ = object.sighash_type_; } SchnorrSignature &SchnorrSignature::operator=(const SchnorrSignature &object) { if (this != &object) { data_ = object.data_; sighash_type_ = object.sighash_type_; } return *this; } ByteData SchnorrSignature::GetData(bool append_sighash_type) const { if ((!append_sighash_type) || (sighash_type_.GetSigHashFlag() == 0) || (data_.GetDataSize() != SchnorrSignature::kSchnorrSignatureSize)) { return data_; } uint8_t sighash_type = static_cast<uint8_t>(sighash_type_.GetSigHashFlag()); return data_.Concat(ByteData(sighash_type)); } std::string SchnorrSignature::GetHex(bool append_sighash_type) const { if (sighash_type_.GetSigHashFlag() == 0) return data_.GetHex(); return GetData(append_sighash_type).GetHex(); } SigHashType SchnorrSignature::GetSigHashType() const { return sighash_type_; } SchnorrPubkey SchnorrSignature::GetNonce() const { auto bytes = data_.GetBytes(); return SchnorrPubkey(ByteData(std::vector<uint8_t>( bytes.begin(), bytes.begin() + SchnorrPubkey::kSchnorrPubkeySize))); } Privkey SchnorrSignature::GetPrivkey() const { auto bytes = data_.GetBytes(); auto start = bytes.begin() + SchnorrPubkey::kSchnorrPubkeySize; auto end = start + Privkey::kPrivkeySize; return Privkey(ByteData(std::vector<uint8_t>(start, end))); } void SchnorrSignature::SetSigHashType(const SigHashType &sighash_type) { if (!IsValidSigHashType( static_cast<uint8_t>(sighash_type.GetSigHashFlag()))) { throw CfdException( CfdError::kCfdIllegalArgumentError, "Invalid sighash type for schnorr signature."); } sighash_type_ = sighash_type; } bool SchnorrSignature::IsValidSigHashType(uint8_t sighash_type_value) { bool is_anyone_can_pay = (sighash_type_value & 0x80) ? true : false; if ((is_anyone_can_pay && ((sighash_type_value <= 0x80) || (sighash_type_value > 0x83))) || ((!is_anyone_can_pay) && (sighash_type_value > 0x03))) { return false; } return true; } // ---------------------------------------------------------------------------- // SchnorrPubkey // ---------------------------------------------------------------------------- SchnorrPubkey::SchnorrPubkey() : data_() {} SchnorrPubkey::SchnorrPubkey(const ByteData &data) : data_() { if (Pubkey::IsValid(data)) { auto pk = SchnorrPubkey::FromPubkey(Pubkey(data)); data_ = pk.data_; } else { if (data.GetDataSize() != SchnorrPubkey::kSchnorrPubkeySize) { throw CfdException( CfdError::kCfdIllegalArgumentError, "Invalid Schnorr pubkey length."); } data_ = ByteData256(data); if (data_.IsEmpty()) { throw CfdException( CfdError::kCfdIllegalArgumentError, "Invalid Schnorr pubkey data."); } } } SchnorrPubkey::SchnorrPubkey(const ByteData256 &data) : data_(data) { if (data.IsEmpty()) { throw CfdException( CfdError::kCfdIllegalArgumentError, "Invalid Schnorr pubkey data."); } } SchnorrPubkey::SchnorrPubkey(const std::string &data) : SchnorrPubkey(ByteData(data)) {} SchnorrPubkey SchnorrPubkey::FromPrivkey( const Privkey &privkey, bool *parity) { auto ctx = wally_get_secp_context(); secp256k1_keypair keypair; auto ret = secp256k1_keypair_create( ctx, &keypair, privkey.GetData().GetBytes().data()); if (ret != 1) { throw CfdException( CfdError::kCfdIllegalArgumentError, "Invalid private key"); } secp256k1_xonly_pubkey x_only_pubkey; int pk_parity = 0; ret = secp256k1_keypair_xonly_pub(ctx, &x_only_pubkey, &pk_parity, &keypair); if (ret != 1) { throw CfdException(CfdError::kCfdInternalError); } if (parity != nullptr) *parity = (pk_parity != 0); return SchnorrPubkey(ConvertSchnorrPubkey(x_only_pubkey)); } SchnorrPubkey SchnorrPubkey::FromPubkey(const Pubkey &pubkey, bool *parity) { auto xpk = GetXOnlyPubkeyFromPubkey(ParsePubkey(pubkey), parity); return SchnorrPubkey(ConvertSchnorrPubkey(xpk)); } SchnorrPubkey SchnorrPubkey::CreateTweakAddFromPrivkey( const Privkey &privkey, const ByteData256 &tweak, Privkey *tweaked_privkey, bool *parity) { std::vector<uint8_t> tweak_bytes = tweak.GetBytes(); auto ctx = wally_get_secp_context(); secp256k1_keypair keypair; auto ret = secp256k1_keypair_create( ctx, &keypair, privkey.GetData().GetBytes().data()); if (ret != 1) { throw CfdException( CfdError::kCfdIllegalArgumentError, "Invalid private key"); } ret = secp256k1_keypair_xonly_tweak_add(ctx, &keypair, tweak_bytes.data()); if (ret != 1) { throw CfdException( CfdError::kCfdInternalError, "Could not tweak add key pair"); } secp256k1_xonly_pubkey x_only_pubkey; int pk_parity = 0; ret = secp256k1_keypair_xonly_pub(ctx, &x_only_pubkey, &pk_parity, &keypair); if (ret != 1) { throw CfdException(CfdError::kCfdInternalError); } if (tweaked_privkey != nullptr) { *tweaked_privkey = Privkey(ByteData(keypair.data, Privkey::kPrivkeySize)); } if (parity != nullptr) *parity = (pk_parity != 0); return SchnorrPubkey(ConvertSchnorrPubkey(x_only_pubkey)); } ByteData SchnorrPubkey::GetData() const { return data_.GetData(); } ByteData256 SchnorrPubkey::GetByteData256() const { return ByteData256(data_); } std::string SchnorrPubkey::GetHex() const { return data_.GetHex(); } bool SchnorrPubkey::Equals(const SchnorrPubkey &pubkey) const { return data_.Equals(pubkey.data_); } bool SchnorrPubkey::IsValid() const { return !data_.IsEmpty(); } SchnorrPubkey SchnorrPubkey::CreateTweakAdd( const ByteData256 &tweak, bool *parity) const { return SchnorrPubkey(TweakAddXonlyPubkey(*this, tweak, parity)); } SchnorrPubkey SchnorrPubkey::CreateTweakAdd( const SchnorrPubkey &tweak, bool *parity) const { return CreateTweakAdd(tweak.data_, parity); } bool SchnorrPubkey::IsTweaked( const SchnorrPubkey &base_pubkey, const ByteData256 &tweak, bool parity) const { return CheckTweakAddXonlyPubkey(*this, base_pubkey, tweak, parity); } bool SchnorrPubkey::Verify( const SchnorrSignature &signature, const ByteData256 &msg) const { return SchnorrUtil::Verify(signature, msg, *this); } Pubkey SchnorrPubkey::CreatePubkey(bool parity) const { uint8_t head = (parity) ? 3 : 2; ByteData data = ByteData(head).Concat(data_); return Pubkey(data); } SchnorrPubkey SchnorrPubkey::operator+=(const ByteData256 &right) { SchnorrPubkey key = CreateTweakAdd(right); *this = key; return *this; } SchnorrPubkey SchnorrPubkey::operator-=(const ByteData256 &right) { Privkey sk(right); auto neg = sk.CreateNegate(); SchnorrPubkey key = CreateTweakAdd(ByteData256(neg.GetData())); *this = key; return *this; } SchnorrPubkey operator+(const SchnorrPubkey &left, const ByteData256 &right) { return left.CreateTweakAdd(right); } SchnorrPubkey operator-(const SchnorrPubkey &left, const ByteData256 &right) { SchnorrPubkey key = left; key -= right; return key; } // ---------------------------------------------------------------------------- // SchnorrUtil // ---------------------------------------------------------------------------- /** * @brief A function that simply copies the data into the nonce. * * @param nonce32 the nonce * @param msg32 unused * @param key32 unused * @param algo16 unused * @param xonly_pk32 unused * @param data the data (actually the nonce to use) * @return int always returns 1 */ int ConstantNonceFunction( unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, const unsigned char *xonly_pk32, void *data) { (void)msg32; (void)key32; (void)algo16; (void)xonly_pk32; std::memcpy(nonce32, (const unsigned char *)data, 32); return 1; } /** * @brief Constant nonce function instance to be passed to secp256k1. * */ const secp256k1_nonce_function_hardened ConstantNonce = ConstantNonceFunction; /** * @brief Private function to both create a schnorr signature using the default * bip340 nonce function (and passing aux_rand as ndata) or using the constant * nonce function (and passing the nonce as ndata) * * @param msg the message to sign * @param sk the private key to use * @param nonce_fn the nonce function to use (if null uses bip 340 nonce function) * @param ndata the ndata to pass * @return SchnorrSignature the generated signature */ SchnorrSignature SignCommon( const ByteData256 &msg, const Privkey &sk, const secp256k1_nonce_function_hardened *nonce_fn, const ByteData ndata) { auto ctx = wally_get_secp_context(); secp256k1_keypair keypair; auto ret = secp256k1_keypair_create(ctx, &keypair, sk.GetData().GetBytes().data()); if (ret != 1) { throw CfdException( CfdError::kCfdInternalError, "Could not create keypair."); } secp256k1_nonce_function_hardened nfn = nonce_fn == nullptr ? nullptr : *nonce_fn; std::vector<uint8_t> raw_sig(SchnorrSignature::kSchnorrSignatureSize); ret = secp256k1_schnorrsig_sign( ctx, raw_sig.data(), msg.GetBytes().data(), &keypair, nfn, (ndata.IsEmpty()) ? nullptr : ndata.GetBytes().data()); if (ret != 1) { throw CfdException( CfdError::kCfdInternalError, "Could not create Schnorr signature."); } return SchnorrSignature(raw_sig); } SchnorrSignature SchnorrUtil::Sign(const ByteData256 &msg, const Privkey &sk) { return SignCommon(msg, sk, nullptr, ByteData()); } SchnorrSignature SchnorrUtil::Sign( const ByteData256 &msg, const Privkey &sk, const ByteData256 &aux_rand) { return SignCommon(msg, sk, nullptr, aux_rand.GetData()); } SchnorrSignature SchnorrUtil::SignWithNonce( const ByteData256 &msg, const Privkey &sk, const Privkey &nonce) { return SignCommon(msg, sk, &ConstantNonce, nonce.GetData()); } Pubkey SchnorrUtil::ComputeSigPoint( const ByteData256 &msg, const SchnorrPubkey &nonce, const SchnorrPubkey &pubkey) { auto ctx = wally_get_secp_context(); secp256k1_xonly_pubkey xonly_pubkey = ParseXOnlyPubkey(pubkey); secp256k1_xonly_pubkey secp_nonce = ParseXOnlyPubkey(nonce); secp256k1_pubkey secp_sigpoint; auto ret = secp256k1_schnorrsig_compute_sigpoint( ctx, &secp_sigpoint, msg.GetBytes().data(), &secp_nonce, &xonly_pubkey); if (ret != 1) { throw CfdException( CfdError::kCfdInternalError, "Could not compute sigpoint"); } return ConvertSecpPubkey(secp_sigpoint); } Pubkey SchnorrUtil::ComputeSigPointBatch( const std::vector<ByteData256> &msgs, const std::vector<SchnorrPubkey> &nonces, const SchnorrPubkey &pubkey) { if (msgs.size() != nonces.size() || msgs.empty()) { throw CfdException( CfdError::kCfdIllegalArgumentError, "Expected same number of messages or nonces, and at least one " "message."); } Pubkey rs; if (msgs.size() == 1) { rs = Pubkey(ByteData("02").Concat(nonces[0].GetData())); } else { std::vector<Pubkey> pub_nonces; for (const auto &nonce : nonces) { pub_nonces.push_back(Pubkey(ByteData("02").Concat(nonce.GetData()))); } rs = Pubkey::CombinePubkey(pub_nonces); } auto bip340_challenge = ByteData( "7bb52d7a9fef58323eb1bf7a407db382d2f3f2d81bb1224f49fe518f6d48d37c7bb52d7" "a9fef58323eb1bf7a407db382d2f3f2d81bb1224f49fe518f6d48d37c"); Privkey res; for (size_t i = 0; i < msgs.size(); i++) { auto m_tagged_hash = HashUtil::Sha256(bip340_challenge.Concat(nonces[i].GetData()) .Concat(pubkey.GetData()) .Concat(msgs[i])); if (i == 0) { res = Privkey(m_tagged_hash); } else { res = res.CreateTweakAdd(m_tagged_hash); } } auto xe = Pubkey(ByteData("02").Concat(pubkey.GetData())) .CreateTweakMul(ByteData256(res.GetData())); return Pubkey::CombinePubkey({rs, xe}); } bool SchnorrUtil::Verify( const SchnorrSignature &signature, const ByteData256 &msg, const SchnorrPubkey &pubkey) { auto ctx = wally_get_secp_context(); secp256k1_xonly_pubkey xonly_pubkey = ParseXOnlyPubkey(pubkey); return 1 == secp256k1_schnorrsig_verify( ctx, signature.GetData().GetBytes().data(), msg.GetBytes().data(), &xonly_pubkey); } } // namespace core } // namespace cfd
32.287016
82
0.688655
ko-matsu
33ced71548adf7d6e95c4db8b69f9cf6d7011bd6
525
hpp
C++
util/slave_commun.hpp
Mogami95/GMiner
d80c0fbad2f860d8cf1585440b57a2637993fb42
[ "Apache-2.0" ]
64
2018-05-15T01:57:55.000Z
2021-12-14T01:49:18.000Z
util/slave_commun.hpp
Mogami95/GMiner
d80c0fbad2f860d8cf1585440b57a2637993fb42
[ "Apache-2.0" ]
3
2019-11-28T12:10:09.000Z
2021-11-03T15:16:06.000Z
util/slave_commun.hpp
Mogami95/GMiner
d80c0fbad2f860d8cf1585440b57a2637993fb42
[ "Apache-2.0" ]
24
2018-05-15T01:57:22.000Z
2021-11-24T14:09:14.000Z
//Copyright 2018 Husky Data Lab, CUHK //Authors: Hongzhi Chen, Miao Liu #ifndef SLAVE_COMMUN_HPP_ #define SLAVE_COMMUN_HPP_ #include <mpi.h> #include "util/communication.hpp" #include "util/global.hpp" int slave_all_sum(int my_copy) { int tmp = my_copy; if( _my_rank != SLAVE_LEADER) { send_data(my_copy, SLAVE_LEADER, MSCOMMUN_CHANNEL); } else { for (int i = 0; i < _num_workers - 2; i++) { tmp += recv_data<int>(MPI_ANY_SOURCE, MSCOMMUN_CHANNEL); } } return tmp; } #endif /* SLAVE_COMMUN_HPP_ */
15.909091
59
0.697143
Mogami95
33cfd798a247b5ef564239c78e25a50ba2174e58
3,467
hpp
C++
lib/cpalgo/tree/lca/lca_binary_lifting.hpp
xirc/cp-algorithm
89c67cff2f00459c5bb020ab44bff5ae419a1728
[ "Apache-2.0" ]
8
2020-12-23T07:54:53.000Z
2021-11-23T02:46:35.000Z
lib/cpalgo/tree/lca/lca_binary_lifting.hpp
xirc/cp-algorithm
89c67cff2f00459c5bb020ab44bff5ae419a1728
[ "Apache-2.0" ]
1
2020-11-07T13:22:29.000Z
2020-12-20T12:54:00.000Z
lib/cpalgo/tree/lca/lca_binary_lifting.hpp
xirc/cp-algorithm
89c67cff2f00459c5bb020ab44bff5ae419a1728
[ "Apache-2.0" ]
1
2021-01-16T03:40:10.000Z
2021-01-16T03:40:10.000Z
#pragma once #include <algorithm> #include <cmath> #include <stdexcept> #include <vector> // LCA: Lowest Common Ancestor // using Binary Lifting // // Space: O(V log V + E) // // NOTE: // - undirected // - non-loop // - non-multi-edge // - it can NOT handle a forest // // Verified: // - https://onlinejudge.u-aizu.ac.jp/problems/GRL_5_C // class LCABinaryLifting { private: size_t N, L; std::vector<size_t> tin, tout; std::vector<std::vector<size_t>> up; public: // root = [0,N) // Time: O(N logN) LCABinaryLifting( std::vector<std::vector<size_t>> const& adj = {}, size_t const root = 0 ) { build(adj, root); } // root = [0,N) // O(N logN) void build( std::vector<std::vector<size_t>> const& adj, size_t const root = 0 ) { N = adj.size(); L = std::ceil(std::log2(std::max(size_t(1),N))) + 1; tin.assign(N, 2 * N); tout.assign(N, 2 * N); up.assign(N, std::vector<size_t>(L, 0)); if (N > 0) { size_t timer = 0; if (root >= N) throw std::out_of_range("root"); dfs_euler(adj, root, root, timer); } } // A LCA node of both the node 'u' and the node 'v' // Time: O(logN) size_t query(size_t u, size_t v) const { if (u >= N) throw std::out_of_range("u"); if (v >= N) throw std::out_of_range("v"); if (is_ancestor(u, v)) return u; if (is_ancestor(v, u)) return v; for (size_t i = 0; i < L; ++i) { if (is_ancestor(up[u][L-1-i], v)) continue; u = up[u][L-1-i]; } return up[u][0]; } // A highest ancestor node of the node 'u' // where the ancestor is not an ancestor of the node 'v'. // If 'u' is an ancestor of 'v', return 'N'. // Time: O(logN) size_t upper_bound(size_t u, size_t const v) const { if (u >= N) throw std::out_of_range("u"); if (v >= N) throw std::out_of_range("v"); if (is_ancestor(u, v)) return N; for (size_t i = 0; i < L; ++i) { if (is_ancestor(up[u][L-1-i], v)) continue; u = up[u][L-1-i]; } return u; } // True if the node 'u' is an ancestor of the node 'v' // u = [0,N), v = [0,N) // Time: O(1) bool is_ancestor(size_t const u, size_t const v) const { if (u >= N) throw std::out_of_range("u"); if (v >= N) throw std::out_of_range("v"); return tin[u] <= tin[v] && tout[u] >= tout[v]; } // The In Index of the Euler Tour // u = [0,N) // The In Index = [0,2*N) size_t euler_in(size_t const u) const { if (u >= N) throw std::out_of_range("u"); return tin[u]; } // The Out Index of the Euler Tour // u = [0,N) // The Out Index = [0, 2*N) size_t euler_out(size_t const u) const { if (u >= N) throw std::out_of_range("u"); return tout[u]; } // Time: O(1) size_t size() const { return N; } private: // Time: O(N logN) void dfs_euler(std::vector<std::vector<size_t>> const& adj, size_t v, size_t p, size_t& timer) { tin[v] = timer++; up[v][0] = p; for (size_t i = 1; i < L; ++i) { up[v][i] = up[up[v][i-1]][i-1]; } for (auto const& u : adj[v]) { if (u == p) continue; dfs_euler(adj, u, v, timer); } tout[v] = timer++; } };
26.875969
100
0.498702
xirc
33d2536a885aef96ca0793a12d3dd44ab30976ff
743
hpp
C++
include/freedom/decision_node.hpp
strikles/poker-mcts
6bd1443a7b497cf64fafd4b25e8d3bb64219e18c
[ "MIT" ]
9
2019-08-22T06:25:12.000Z
2021-02-17T16:27:27.000Z
include/freedom/decision_node.hpp
strikles/poker-mcts
6bd1443a7b497cf64fafd4b25e8d3bb64219e18c
[ "MIT" ]
null
null
null
include/freedom/decision_node.hpp
strikles/poker-mcts
6bd1443a7b497cf64fafd4b25e8d3bb64219e18c
[ "MIT" ]
4
2019-09-04T14:20:05.000Z
2022-02-09T06:32:14.000Z
#ifndef DECISION_NODE_H #define DECISION_NODE_H #include "fconfig.hpp" #include "fcontext.hpp" #include <mcts/inner_node.hpp> namespace freedom { using mcts::INode; using mcts::InnerNode; // ---------------------------------------------------------------------- /// @brief Uses a selectionStrategy for nodes in which we (the bot) /// has to make a move. // ---------------------------------------------------------------------- class DecisionNode : public InnerNode<FContext, FConfig> { typedef typename INode<FContext, FConfig>::node_t node_t; public: DecisionNode(const FContext &fcontext_, FConfig *fconfig_, node_t *parent_); void expand(); virtual node_t *select_child(); virtual ~DecisionNode(); }; } #endif
24.766667
78
0.584118
strikles
33d61240fcc8b6a651227bf986c3bf4a0adc8cd1
2,134
cpp
C++
IndexBinary.cpp
yuhonghong66/faiss
21475fb2f34f63f232facdb1f4342f3356dd408c
[ "BSD-3-Clause" ]
51
2018-12-21T14:20:55.000Z
2022-03-08T17:33:28.000Z
IndexBinary.cpp
yuhonghong66/faiss
21475fb2f34f63f232facdb1f4342f3356dd408c
[ "BSD-3-Clause" ]
1
2019-06-24T05:40:47.000Z
2019-06-24T05:40:47.000Z
IndexBinary.cpp
yuhonghong66/faiss
21475fb2f34f63f232facdb1f4342f3356dd408c
[ "BSD-3-Clause" ]
3
2020-04-02T02:42:02.000Z
2021-07-16T09:43:28.000Z
/** * Copyright (c) 2015-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD+Patents license found in the * LICENSE file in the root directory of this source tree. */ // -*- c++ -*- #include "IndexBinary.h" #include "FaissAssert.h" #include <cstring> namespace faiss { IndexBinary::~IndexBinary() {} void IndexBinary::train(idx_t, const uint8_t *) { // Does nothing by default. } void IndexBinary::range_search(idx_t, const uint8_t *, int, RangeSearchResult *) const { FAISS_THROW_MSG("range search not implemented"); } void IndexBinary::assign(idx_t n, const uint8_t *x, idx_t *labels, idx_t k) { int *distances = new int[n * k]; ScopeDeleter<int> del(distances); search(n, x, k, distances, labels); } void IndexBinary::add_with_ids(idx_t, const uint8_t *, const long *) { FAISS_THROW_MSG("add_with_ids not implemented for this type of index"); } long IndexBinary::remove_ids(const IDSelector&) { FAISS_THROW_MSG("remove_ids not implemented for this type of index"); return -1; } void IndexBinary::reconstruct(idx_t, uint8_t *) const { FAISS_THROW_MSG("reconstruct not implemented for this type of index"); } void IndexBinary::reconstruct_n(idx_t i0, idx_t ni, uint8_t *recons) const { for (idx_t i = 0; i < ni; i++) { reconstruct(i0 + i, recons + i * d); } } void IndexBinary::search_and_reconstruct(idx_t n, const uint8_t *x, idx_t k, int32_t *distances, idx_t *labels, uint8_t *recons) const { search(n, x, k, distances, labels); for (idx_t i = 0; i < n; ++i) { for (idx_t j = 0; j < k; ++j) { idx_t ij = i * k + j; idx_t key = labels[ij]; uint8_t *reconstructed = recons + ij * d; if (key < 0) { // Fill with NaNs memset(reconstructed, -1, sizeof(*reconstructed) * d); } else { reconstruct(key, reconstructed); } } } } void IndexBinary::display() const { printf("Index: %s -> %ld elements\n", typeid (*this).name(), ntotal); } } // namespace faiss
27.012658
77
0.625117
yuhonghong66
33d72117ec4bcba4be1c8057e873f602103626df
3,394
cc
C++
src/ppl/nn/models/onnx/model_parser.cc
kuroro-tian/ppl.nn
7b33cd1fd0660540aec483f299b20094425e7138
[ "Apache-2.0" ]
1
2022-03-27T07:55:37.000Z
2022-03-27T07:55:37.000Z
src/ppl/nn/models/onnx/model_parser.cc
kuroro-tian/ppl.nn
7b33cd1fd0660540aec483f299b20094425e7138
[ "Apache-2.0" ]
null
null
null
src/ppl/nn/models/onnx/model_parser.cc
kuroro-tian/ppl.nn
7b33cd1fd0660540aec483f299b20094425e7138
[ "Apache-2.0" ]
null
null
null
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. #include "ppl/nn/models/onnx/model_parser.h" #include "ppl/nn/models/onnx/graph_parser.h" #include "ppl/nn/common/logger.h" #include "ppl/common/file_mapping.h" // large proto file support #include "google/protobuf/io/coded_stream.h" #include "google/protobuf/io/zero_copy_stream.h" #include "google/protobuf/io/zero_copy_stream_impl.h" using namespace std; using namespace ppl::common; namespace ppl { namespace nn { namespace onnx { static bool ParseFromBinaryBuffer(const char* buf, uint64_t buf_len, google::protobuf::MessageLite* pb_model) { if (!buf) { LOG(ERROR) << "buf ptr is nullptr."; return false; } if (buf_len == 0) { LOG(ERROR) << "buf len is 0."; return false; } google::protobuf::io::CodedInputStream cis((uint8_t*)buf, buf_len); cis.SetTotalBytesLimit(INT_MAX); return pb_model->ParseFromCodedStream(&cis); } static map<string, uint64_t> ParseOpSets(const ::onnx::ModelProto pb_model) { map<string, uint64_t> res; for (int i = 0; i < pb_model.opset_import_size(); ++i) { const string& domain = pb_model.opset_import(i).domain(); uint64_t version = pb_model.opset_import(i).version(); auto ref = res.insert(make_pair(domain, 0)); if (version > ref.first->second) { ref.first->second = version; } } return res; } RetCode ModelParser::Parse(const char* buf, uint64_t buf_len, const char* model_file_dir, ir::Graph* graph) { ::onnx::ModelProto pb_model; if (!ParseFromBinaryBuffer(buf, buf_len, &pb_model)) { LOG(ERROR) << "load onnx model from model buffer failed."; return RC_OTHER_ERROR; } if (pb_model.graph().quantization_annotation_size() > 0) { LOG(ERROR) << "quantization in ONNX model is not supported now."; return RC_UNSUPPORTED; } map<string, uint64_t> op_sets = ParseOpSets(pb_model); GraphParser graph_parser; auto status = graph_parser.Parse(pb_model.graph(), op_sets, model_file_dir, graph); if (status != RC_SUCCESS) { LOG(ERROR) << "parse graph failed: " << GetRetCodeStr(status); return status; } if (graph->topo->GetExtraInputCount() > 0) { auto topo = graph->topo.get(); LOG(ERROR) << "unresolved extra input of graph[" << topo->GetName() << "]:"; for (uint32_t i = 0; i < topo->GetExtraInputCount(); ++i) { LOG(ERROR) << " -> " << topo->GetEdge(topo->GetExtraInput(i))->GetName(); } return RC_NOT_FOUND; } return RC_SUCCESS; } }}} // namespace ppl::nn::onnx
34.989691
111
0.671184
kuroro-tian
33d748f9b86e78a130ad0e36f51307ddda600b33
1,001,202
cpp
C++
cisco-ios-xr/ydk/models/cisco_ios_xr/fragmented/Cisco_IOS_XR_mpls_te_oper_40.cpp
CiscoDevNet/ydk-cpp
ef7d75970f2ef1154100e0f7b0a2ee823609b481
[ "ECL-2.0", "Apache-2.0" ]
17
2016-12-02T05:45:49.000Z
2022-02-10T19:32:54.000Z
cisco-ios-xr/ydk/models/cisco_ios_xr/fragmented/Cisco_IOS_XR_mpls_te_oper_40.cpp
CiscoDevNet/ydk-cpp
ef7d75970f2ef1154100e0f7b0a2ee823609b481
[ "ECL-2.0", "Apache-2.0" ]
2
2017-03-27T15:22:38.000Z
2019-11-05T08:30:16.000Z
cisco-ios-xr/ydk/models/cisco_ios_xr/fragmented/Cisco_IOS_XR_mpls_te_oper_40.cpp
CiscoDevNet/ydk-cpp
ef7d75970f2ef1154100e0f7b0a2ee823609b481
[ "ECL-2.0", "Apache-2.0" ]
11
2016-12-02T05:45:52.000Z
2019-11-07T08:28:17.000Z
#include <sstream> #include <iostream> #include <ydk/entity_util.hpp> #include "bundle_info.hpp" #include "generated_entity_lookup.hpp" #include "Cisco_IOS_XR_mpls_te_oper_40.hpp" #include "Cisco_IOS_XR_mpls_te_oper_41.hpp" using namespace ydk; namespace cisco_ios_xr { namespace Cisco_IOS_XR_mpls_te_oper { MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::LabelRroSubObject() : label{YType::uint32, "label"}, is_label_variable_length{YType::boolean, "is-label-variable-length"} , flags(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags>()) , variable_length_label(this, {}) { flags->parent = this; yang_name = "label-rro-sub-object"; yang_parent_name = "resv-rro"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::~LabelRroSubObject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<variable_length_label.len(); index++) { if(variable_length_label[index]->has_data()) return true; } return label.is_set || is_label_variable_length.is_set || (flags != nullptr && flags->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::has_operation() const { for (std::size_t index=0; index<variable_length_label.len(); index++) { if(variable_length_label[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(label.yfilter) || ydk::is_set(is_label_variable_length.yfilter) || (flags != nullptr && flags->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "label-rro-sub-object"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (label.is_set || is_set(label.yfilter)) leaf_name_data.push_back(label.get_name_leafdata()); if (is_label_variable_length.is_set || is_set(is_label_variable_length.yfilter)) leaf_name_data.push_back(is_label_variable_length.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "flags") { if(flags == nullptr) { flags = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags>(); } return flags; } if(child_yang_name == "variable-length-label") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel>(); ent_->parent = this; variable_length_label.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(flags != nullptr) { _children["flags"] = flags; } count_ = 0; for (auto ent_ : variable_length_label.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::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 == "label") { label = value; label.value_namespace = name_space; label.value_namespace_prefix = name_space_prefix; } if(value_path == "is-label-variable-length") { is_label_variable_length = value; is_label_variable_length.value_namespace = name_space; is_label_variable_length.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "label") { label.yfilter = yfilter; } if(value_path == "is-label-variable-length") { is_label_variable_length.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "flags" || name == "variable-length-label" || name == "label" || name == "is-label-variable-length") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::Flags() : is_global_label{YType::boolean, "is-global-label"} { yang_name = "flags"; yang_parent_name = "label-rro-sub-object"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::~Flags() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::has_data() const { if (is_presence_container) return true; return is_global_label.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::has_operation() const { return is_set(yfilter) || ydk::is_set(is_global_label.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "flags"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (is_global_label.is_set || is_set(is_global_label.yfilter)) leaf_name_data.push_back(is_global_label.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::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 == "is-global-label") { is_global_label = value; is_global_label.value_namespace = name_space; is_global_label.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "is-global-label") { is_global_label.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::Flags::has_leaf_or_child_of_name(const std::string & name) const { if(name == "is-global-label") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::VariableLengthLabel() : entry{YType::uint32, "entry"} { yang_name = "variable-length-label"; yang_parent_name = "label-rro-sub-object"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::~VariableLengthLabel() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "variable-length-label"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::LabelRroSubObject::VariableLengthLabel::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::UnnumberedRroSubObject() : interface_address{YType::str, "interface-address"}, interface_id{YType::uint32, "interface-id"} , flags(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags>()) { flags->parent = this; yang_name = "unnumbered-rro-sub-object"; yang_parent_name = "resv-rro"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::~UnnumberedRroSubObject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::has_data() const { if (is_presence_container) return true; return interface_address.is_set || interface_id.is_set || (flags != nullptr && flags->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::has_operation() const { return is_set(yfilter) || ydk::is_set(interface_address.yfilter) || ydk::is_set(interface_id.yfilter) || (flags != nullptr && flags->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "unnumbered-rro-sub-object"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (interface_address.is_set || is_set(interface_address.yfilter)) leaf_name_data.push_back(interface_address.get_name_leafdata()); if (interface_id.is_set || is_set(interface_id.yfilter)) leaf_name_data.push_back(interface_id.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "flags") { if(flags == nullptr) { flags = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags>(); } return flags; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(flags != nullptr) { _children["flags"] = flags; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::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 == "interface-address") { interface_address = value; interface_address.value_namespace = name_space; interface_address.value_namespace_prefix = name_space_prefix; } if(value_path == "interface-id") { interface_id = value; interface_id.value_namespace = name_space; interface_id.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "interface-address") { interface_address.yfilter = yfilter; } if(value_path == "interface-id") { interface_id.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "flags" || name == "interface-address" || name == "interface-id") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::Flags() : is_protection_available{YType::boolean, "is-protection-available"}, is_protection_in_use{YType::boolean, "is-protection-in-use"}, is_bandwidth_protected{YType::boolean, "is-bandwidth-protected"}, is_node_protection_available{YType::boolean, "is-node-protection-available"}, is_node_id{YType::boolean, "is-node-id"} { yang_name = "flags"; yang_parent_name = "unnumbered-rro-sub-object"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::~Flags() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::has_data() const { if (is_presence_container) return true; return is_protection_available.is_set || is_protection_in_use.is_set || is_bandwidth_protected.is_set || is_node_protection_available.is_set || is_node_id.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::has_operation() const { return is_set(yfilter) || ydk::is_set(is_protection_available.yfilter) || ydk::is_set(is_protection_in_use.yfilter) || ydk::is_set(is_bandwidth_protected.yfilter) || ydk::is_set(is_node_protection_available.yfilter) || ydk::is_set(is_node_id.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "flags"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (is_protection_available.is_set || is_set(is_protection_available.yfilter)) leaf_name_data.push_back(is_protection_available.get_name_leafdata()); if (is_protection_in_use.is_set || is_set(is_protection_in_use.yfilter)) leaf_name_data.push_back(is_protection_in_use.get_name_leafdata()); if (is_bandwidth_protected.is_set || is_set(is_bandwidth_protected.yfilter)) leaf_name_data.push_back(is_bandwidth_protected.get_name_leafdata()); if (is_node_protection_available.is_set || is_set(is_node_protection_available.yfilter)) leaf_name_data.push_back(is_node_protection_available.get_name_leafdata()); if (is_node_id.is_set || is_set(is_node_id.yfilter)) leaf_name_data.push_back(is_node_id.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::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 == "is-protection-available") { is_protection_available = value; is_protection_available.value_namespace = name_space; is_protection_available.value_namespace_prefix = name_space_prefix; } if(value_path == "is-protection-in-use") { is_protection_in_use = value; is_protection_in_use.value_namespace = name_space; is_protection_in_use.value_namespace_prefix = name_space_prefix; } if(value_path == "is-bandwidth-protected") { is_bandwidth_protected = value; is_bandwidth_protected.value_namespace = name_space; is_bandwidth_protected.value_namespace_prefix = name_space_prefix; } if(value_path == "is-node-protection-available") { is_node_protection_available = value; is_node_protection_available.value_namespace = name_space; is_node_protection_available.value_namespace_prefix = name_space_prefix; } if(value_path == "is-node-id") { is_node_id = value; is_node_id.value_namespace = name_space; is_node_id.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "is-protection-available") { is_protection_available.yfilter = yfilter; } if(value_path == "is-protection-in-use") { is_protection_in_use.yfilter = yfilter; } if(value_path == "is-bandwidth-protected") { is_bandwidth_protected.yfilter = yfilter; } if(value_path == "is-node-protection-available") { is_node_protection_available.yfilter = yfilter; } if(value_path == "is-node-id") { is_node_id.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::UnnumberedRroSubObject::Flags::has_leaf_or_child_of_name(const std::string & name) const { if(name == "is-protection-available" || name == "is-protection-in-use" || name == "is-bandwidth-protected" || name == "is-node-protection-available" || name == "is-node-id") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlgRroSubObject() : srl_gs(this, {}) { yang_name = "srlg-rro-sub-object"; yang_parent_name = "resv-rro"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::~SrlgRroSubObject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<srl_gs.len(); index++) { if(srl_gs[index]->has_data()) return true; } return false; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::has_operation() const { for (std::size_t index=0; index<srl_gs.len(); index++) { if(srl_gs[index]->has_operation()) return true; } return is_set(yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "srlg-rro-sub-object"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "srl-gs") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs>(); ent_->parent = this; srl_gs.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : srl_gs.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::set_filter(const std::string & value_path, YFilter yfilter) { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "srl-gs") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::SrlGs() : entry{YType::uint32, "entry"} { yang_name = "srl-gs"; yang_parent_name = "srlg-rro-sub-object"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::~SrlGs() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "srl-gs"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ResvRro::SrlgRroSubObject::SrlGs::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::PathAffinityArray() : hop_address{YType::str, "hop-address"}, hop_affinity{YType::uint32, "hop-affinity"} , hop_extended_affinity(this, {}) { yang_name = "path-affinity-array"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::~PathAffinityArray() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<hop_extended_affinity.len(); index++) { if(hop_extended_affinity[index]->has_data()) return true; } return hop_address.is_set || hop_affinity.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::has_operation() const { for (std::size_t index=0; index<hop_extended_affinity.len(); index++) { if(hop_extended_affinity[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(hop_address.yfilter) || ydk::is_set(hop_affinity.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "path-affinity-array"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (hop_address.is_set || is_set(hop_address.yfilter)) leaf_name_data.push_back(hop_address.get_name_leafdata()); if (hop_affinity.is_set || is_set(hop_affinity.yfilter)) leaf_name_data.push_back(hop_affinity.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "hop-extended-affinity") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity>(); ent_->parent = this; hop_extended_affinity.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : hop_extended_affinity.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::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 == "hop-address") { hop_address = value; hop_address.value_namespace = name_space; hop_address.value_namespace_prefix = name_space_prefix; } if(value_path == "hop-affinity") { hop_affinity = value; hop_affinity.value_namespace = name_space; hop_affinity.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "hop-address") { hop_address.yfilter = yfilter; } if(value_path == "hop-affinity") { hop_affinity.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::has_leaf_or_child_of_name(const std::string & name) const { if(name == "hop-extended-affinity" || name == "hop-address" || name == "hop-affinity") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::HopExtendedAffinity() : entry{YType::uint32, "entry"} { yang_name = "hop-extended-affinity"; yang_parent_name = "path-affinity-array"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::~HopExtendedAffinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "hop-extended-affinity"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::PathAffinityArray::HopExtendedAffinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::ReverseEroIn() : ero_type{YType::enumeration, "ero-type"} , ipv4ero_sub_object(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject>()) , unnumbered_ero_sub_object(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject>()) { ipv4ero_sub_object->parent = this; unnumbered_ero_sub_object->parent = this; yang_name = "reverse-ero-in"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::~ReverseEroIn() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::has_data() const { if (is_presence_container) return true; return ero_type.is_set || (ipv4ero_sub_object != nullptr && ipv4ero_sub_object->has_data()) || (unnumbered_ero_sub_object != nullptr && unnumbered_ero_sub_object->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::has_operation() const { return is_set(yfilter) || ydk::is_set(ero_type.yfilter) || (ipv4ero_sub_object != nullptr && ipv4ero_sub_object->has_operation()) || (unnumbered_ero_sub_object != nullptr && unnumbered_ero_sub_object->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "reverse-ero-in"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (ero_type.is_set || is_set(ero_type.yfilter)) leaf_name_data.push_back(ero_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "ipv4ero-sub-object") { if(ipv4ero_sub_object == nullptr) { ipv4ero_sub_object = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject>(); } return ipv4ero_sub_object; } if(child_yang_name == "unnumbered-ero-sub-object") { if(unnumbered_ero_sub_object == nullptr) { unnumbered_ero_sub_object = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject>(); } return unnumbered_ero_sub_object; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(ipv4ero_sub_object != nullptr) { _children["ipv4ero-sub-object"] = ipv4ero_sub_object; } if(unnumbered_ero_sub_object != nullptr) { _children["unnumbered-ero-sub-object"] = unnumbered_ero_sub_object; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::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 == "ero-type") { ero_type = value; ero_type.value_namespace = name_space; ero_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "ero-type") { ero_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::has_leaf_or_child_of_name(const std::string & name) const { if(name == "ipv4ero-sub-object" || name == "unnumbered-ero-sub-object" || name == "ero-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::Ipv4eroSubObject() : is_strict_route{YType::boolean, "is-strict-route"}, ero_address{YType::str, "ero-address"}, prefix_length{YType::uint8, "prefix-length"} { yang_name = "ipv4ero-sub-object"; yang_parent_name = "reverse-ero-in"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::~Ipv4eroSubObject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::has_data() const { if (is_presence_container) return true; return is_strict_route.is_set || ero_address.is_set || prefix_length.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::has_operation() const { return is_set(yfilter) || ydk::is_set(is_strict_route.yfilter) || ydk::is_set(ero_address.yfilter) || ydk::is_set(prefix_length.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv4ero-sub-object"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (is_strict_route.is_set || is_set(is_strict_route.yfilter)) leaf_name_data.push_back(is_strict_route.get_name_leafdata()); if (ero_address.is_set || is_set(ero_address.yfilter)) leaf_name_data.push_back(ero_address.get_name_leafdata()); if (prefix_length.is_set || is_set(prefix_length.yfilter)) leaf_name_data.push_back(prefix_length.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::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 == "is-strict-route") { is_strict_route = value; is_strict_route.value_namespace = name_space; is_strict_route.value_namespace_prefix = name_space_prefix; } if(value_path == "ero-address") { ero_address = value; ero_address.value_namespace = name_space; ero_address.value_namespace_prefix = name_space_prefix; } if(value_path == "prefix-length") { prefix_length = value; prefix_length.value_namespace = name_space; prefix_length.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "is-strict-route") { is_strict_route.yfilter = yfilter; } if(value_path == "ero-address") { ero_address.yfilter = yfilter; } if(value_path == "prefix-length") { prefix_length.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::Ipv4eroSubObject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "is-strict-route" || name == "ero-address" || name == "prefix-length") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::UnnumberedEroSubObject() : is_strict_route{YType::boolean, "is-strict-route"}, ero_interface_id{YType::uint32, "ero-interface-id"}, ero_router_id{YType::str, "ero-router-id"}, status{YType::enumeration, "status"} { yang_name = "unnumbered-ero-sub-object"; yang_parent_name = "reverse-ero-in"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::~UnnumberedEroSubObject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::has_data() const { if (is_presence_container) return true; return is_strict_route.is_set || ero_interface_id.is_set || ero_router_id.is_set || status.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::has_operation() const { return is_set(yfilter) || ydk::is_set(is_strict_route.yfilter) || ydk::is_set(ero_interface_id.yfilter) || ydk::is_set(ero_router_id.yfilter) || ydk::is_set(status.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "unnumbered-ero-sub-object"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (is_strict_route.is_set || is_set(is_strict_route.yfilter)) leaf_name_data.push_back(is_strict_route.get_name_leafdata()); if (ero_interface_id.is_set || is_set(ero_interface_id.yfilter)) leaf_name_data.push_back(ero_interface_id.get_name_leafdata()); if (ero_router_id.is_set || is_set(ero_router_id.yfilter)) leaf_name_data.push_back(ero_router_id.get_name_leafdata()); if (status.is_set || is_set(status.yfilter)) leaf_name_data.push_back(status.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::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 == "is-strict-route") { is_strict_route = value; is_strict_route.value_namespace = name_space; is_strict_route.value_namespace_prefix = name_space_prefix; } if(value_path == "ero-interface-id") { ero_interface_id = value; ero_interface_id.value_namespace = name_space; ero_interface_id.value_namespace_prefix = name_space_prefix; } if(value_path == "ero-router-id") { ero_router_id = value; ero_router_id.value_namespace = name_space; ero_router_id.value_namespace_prefix = name_space_prefix; } if(value_path == "status") { status = value; status.value_namespace = name_space; status.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "is-strict-route") { is_strict_route.yfilter = yfilter; } if(value_path == "ero-interface-id") { ero_interface_id.yfilter = yfilter; } if(value_path == "ero-router-id") { ero_router_id.yfilter = yfilter; } if(value_path == "status") { status.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::ReverseEroIn::UnnumberedEroSubObject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "is-strict-route" || name == "ero-interface-id" || name == "ero-router-id" || name == "status") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::S2lSegmentRoutingPath() : sid_type{YType::enumeration, "sid-type"}, has_ip_addresses{YType::boolean, "has-ip-addresses"}, local_addr{YType::str, "local-addr"}, remote_addr{YType::str, "remote-addr"}, has_mpls_label{YType::boolean, "has-mpls-label"}, mpls_label_value{YType::uint32, "mpls-label-value"}, has_entropy_label{YType::boolean, "has-entropy-label"} { yang_name = "s2l-segment-routing-path"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::~S2lSegmentRoutingPath() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::has_data() const { if (is_presence_container) return true; return sid_type.is_set || has_ip_addresses.is_set || local_addr.is_set || remote_addr.is_set || has_mpls_label.is_set || mpls_label_value.is_set || has_entropy_label.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::has_operation() const { return is_set(yfilter) || ydk::is_set(sid_type.yfilter) || ydk::is_set(has_ip_addresses.yfilter) || ydk::is_set(local_addr.yfilter) || ydk::is_set(remote_addr.yfilter) || ydk::is_set(has_mpls_label.yfilter) || ydk::is_set(mpls_label_value.yfilter) || ydk::is_set(has_entropy_label.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "s2l-segment-routing-path"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (sid_type.is_set || is_set(sid_type.yfilter)) leaf_name_data.push_back(sid_type.get_name_leafdata()); if (has_ip_addresses.is_set || is_set(has_ip_addresses.yfilter)) leaf_name_data.push_back(has_ip_addresses.get_name_leafdata()); if (local_addr.is_set || is_set(local_addr.yfilter)) leaf_name_data.push_back(local_addr.get_name_leafdata()); if (remote_addr.is_set || is_set(remote_addr.yfilter)) leaf_name_data.push_back(remote_addr.get_name_leafdata()); if (has_mpls_label.is_set || is_set(has_mpls_label.yfilter)) leaf_name_data.push_back(has_mpls_label.get_name_leafdata()); if (mpls_label_value.is_set || is_set(mpls_label_value.yfilter)) leaf_name_data.push_back(mpls_label_value.get_name_leafdata()); if (has_entropy_label.is_set || is_set(has_entropy_label.yfilter)) leaf_name_data.push_back(has_entropy_label.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::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 == "sid-type") { sid_type = value; sid_type.value_namespace = name_space; sid_type.value_namespace_prefix = name_space_prefix; } if(value_path == "has-ip-addresses") { has_ip_addresses = value; has_ip_addresses.value_namespace = name_space; has_ip_addresses.value_namespace_prefix = name_space_prefix; } if(value_path == "local-addr") { local_addr = value; local_addr.value_namespace = name_space; local_addr.value_namespace_prefix = name_space_prefix; } if(value_path == "remote-addr") { remote_addr = value; remote_addr.value_namespace = name_space; remote_addr.value_namespace_prefix = name_space_prefix; } if(value_path == "has-mpls-label") { has_mpls_label = value; has_mpls_label.value_namespace = name_space; has_mpls_label.value_namespace_prefix = name_space_prefix; } if(value_path == "mpls-label-value") { mpls_label_value = value; mpls_label_value.value_namespace = name_space; mpls_label_value.value_namespace_prefix = name_space_prefix; } if(value_path == "has-entropy-label") { has_entropy_label = value; has_entropy_label.value_namespace = name_space; has_entropy_label.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "sid-type") { sid_type.yfilter = yfilter; } if(value_path == "has-ip-addresses") { has_ip_addresses.yfilter = yfilter; } if(value_path == "local-addr") { local_addr.yfilter = yfilter; } if(value_path == "remote-addr") { remote_addr.yfilter = yfilter; } if(value_path == "has-mpls-label") { has_mpls_label.yfilter = yfilter; } if(value_path == "mpls-label-value") { mpls_label_value.yfilter = yfilter; } if(value_path == "has-entropy-label") { has_entropy_label.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::TunnelCurrentLsp::S2l::S2lSegmentRoutingPath::has_leaf_or_child_of_name(const std::string & name) const { if(name == "sid-type" || name == "has-ip-addresses" || name == "local-addr" || name == "remote-addr" || name == "has-mpls-label" || name == "mpls-label-value" || name == "has-entropy-label") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::ReoptimizedP2mpLsp() : signaled_name{YType::str, "signaled-name"}, is_frr_failed{YType::boolean, "is-frr-failed"}, frr_active_reason{YType::uint32, "frr-active-reason"}, lsp_bandwidth{YType::uint32, "lsp-bandwidth"}, lsp_setup_priority{YType::uint8, "lsp-setup-priority"}, lsp_hold_priority{YType::uint8, "lsp-hold-priority"}, lsp_bandwidth_type{YType::enumeration, "lsp-bandwidth-type"}, dste_class_match{YType::boolean, "dste-class-match"}, dste_class_index{YType::uint8, "dste-class-index"}, type{YType::enumeration, "type"}, uptime{YType::uint32, "uptime"}, s2_ls_up{YType::uint32, "s2-ls-up"}, s2_ls_proceeding{YType::uint32, "s2-ls-proceeding"}, s2_ls_down{YType::uint32, "s2-ls-down"}, reoptimize_reason{YType::enumeration, "reoptimize-reason"}, reoptimize_trigger{YType::enumeration, "reoptimize-trigger"}, timer_left{YType::uint32, "timer-left"}, is_passive{YType::boolean, "is-passive"}, is_interface{YType::boolean, "is-interface"}, last_path_change{YType::uint32, "last-path-change"}, persistent_bytes{YType::uint64, "persistent-bytes"}, persistent_packets{YType::uint64, "persistent-packets"} , lsp_fec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec>()) , s2l(this, {}) { lsp_fec->parent = this; yang_name = "reoptimized-p2mp-lsp"; yang_parent_name = "nni-tunnel"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::~ReoptimizedP2mpLsp() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<s2l.len(); index++) { if(s2l[index]->has_data()) return true; } return signaled_name.is_set || is_frr_failed.is_set || frr_active_reason.is_set || lsp_bandwidth.is_set || lsp_setup_priority.is_set || lsp_hold_priority.is_set || lsp_bandwidth_type.is_set || dste_class_match.is_set || dste_class_index.is_set || type.is_set || uptime.is_set || s2_ls_up.is_set || s2_ls_proceeding.is_set || s2_ls_down.is_set || reoptimize_reason.is_set || reoptimize_trigger.is_set || timer_left.is_set || is_passive.is_set || is_interface.is_set || last_path_change.is_set || persistent_bytes.is_set || persistent_packets.is_set || (lsp_fec != nullptr && lsp_fec->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::has_operation() const { for (std::size_t index=0; index<s2l.len(); index++) { if(s2l[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(signaled_name.yfilter) || ydk::is_set(is_frr_failed.yfilter) || ydk::is_set(frr_active_reason.yfilter) || ydk::is_set(lsp_bandwidth.yfilter) || ydk::is_set(lsp_setup_priority.yfilter) || ydk::is_set(lsp_hold_priority.yfilter) || ydk::is_set(lsp_bandwidth_type.yfilter) || ydk::is_set(dste_class_match.yfilter) || ydk::is_set(dste_class_index.yfilter) || ydk::is_set(type.yfilter) || ydk::is_set(uptime.yfilter) || ydk::is_set(s2_ls_up.yfilter) || ydk::is_set(s2_ls_proceeding.yfilter) || ydk::is_set(s2_ls_down.yfilter) || ydk::is_set(reoptimize_reason.yfilter) || ydk::is_set(reoptimize_trigger.yfilter) || ydk::is_set(timer_left.yfilter) || ydk::is_set(is_passive.yfilter) || ydk::is_set(is_interface.yfilter) || ydk::is_set(last_path_change.yfilter) || ydk::is_set(persistent_bytes.yfilter) || ydk::is_set(persistent_packets.yfilter) || (lsp_fec != nullptr && lsp_fec->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "reoptimized-p2mp-lsp"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (signaled_name.is_set || is_set(signaled_name.yfilter)) leaf_name_data.push_back(signaled_name.get_name_leafdata()); if (is_frr_failed.is_set || is_set(is_frr_failed.yfilter)) leaf_name_data.push_back(is_frr_failed.get_name_leafdata()); if (frr_active_reason.is_set || is_set(frr_active_reason.yfilter)) leaf_name_data.push_back(frr_active_reason.get_name_leafdata()); if (lsp_bandwidth.is_set || is_set(lsp_bandwidth.yfilter)) leaf_name_data.push_back(lsp_bandwidth.get_name_leafdata()); if (lsp_setup_priority.is_set || is_set(lsp_setup_priority.yfilter)) leaf_name_data.push_back(lsp_setup_priority.get_name_leafdata()); if (lsp_hold_priority.is_set || is_set(lsp_hold_priority.yfilter)) leaf_name_data.push_back(lsp_hold_priority.get_name_leafdata()); if (lsp_bandwidth_type.is_set || is_set(lsp_bandwidth_type.yfilter)) leaf_name_data.push_back(lsp_bandwidth_type.get_name_leafdata()); if (dste_class_match.is_set || is_set(dste_class_match.yfilter)) leaf_name_data.push_back(dste_class_match.get_name_leafdata()); if (dste_class_index.is_set || is_set(dste_class_index.yfilter)) leaf_name_data.push_back(dste_class_index.get_name_leafdata()); if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata()); if (uptime.is_set || is_set(uptime.yfilter)) leaf_name_data.push_back(uptime.get_name_leafdata()); if (s2_ls_up.is_set || is_set(s2_ls_up.yfilter)) leaf_name_data.push_back(s2_ls_up.get_name_leafdata()); if (s2_ls_proceeding.is_set || is_set(s2_ls_proceeding.yfilter)) leaf_name_data.push_back(s2_ls_proceeding.get_name_leafdata()); if (s2_ls_down.is_set || is_set(s2_ls_down.yfilter)) leaf_name_data.push_back(s2_ls_down.get_name_leafdata()); if (reoptimize_reason.is_set || is_set(reoptimize_reason.yfilter)) leaf_name_data.push_back(reoptimize_reason.get_name_leafdata()); if (reoptimize_trigger.is_set || is_set(reoptimize_trigger.yfilter)) leaf_name_data.push_back(reoptimize_trigger.get_name_leafdata()); if (timer_left.is_set || is_set(timer_left.yfilter)) leaf_name_data.push_back(timer_left.get_name_leafdata()); if (is_passive.is_set || is_set(is_passive.yfilter)) leaf_name_data.push_back(is_passive.get_name_leafdata()); if (is_interface.is_set || is_set(is_interface.yfilter)) leaf_name_data.push_back(is_interface.get_name_leafdata()); if (last_path_change.is_set || is_set(last_path_change.yfilter)) leaf_name_data.push_back(last_path_change.get_name_leafdata()); if (persistent_bytes.is_set || is_set(persistent_bytes.yfilter)) leaf_name_data.push_back(persistent_bytes.get_name_leafdata()); if (persistent_packets.is_set || is_set(persistent_packets.yfilter)) leaf_name_data.push_back(persistent_packets.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "lsp-fec") { if(lsp_fec == nullptr) { lsp_fec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec>(); } return lsp_fec; } if(child_yang_name == "s2l") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l>(); ent_->parent = this; s2l.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(lsp_fec != nullptr) { _children["lsp-fec"] = lsp_fec; } count_ = 0; for (auto ent_ : s2l.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::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 == "signaled-name") { signaled_name = value; signaled_name.value_namespace = name_space; signaled_name.value_namespace_prefix = name_space_prefix; } if(value_path == "is-frr-failed") { is_frr_failed = value; is_frr_failed.value_namespace = name_space; is_frr_failed.value_namespace_prefix = name_space_prefix; } if(value_path == "frr-active-reason") { frr_active_reason = value; frr_active_reason.value_namespace = name_space; frr_active_reason.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-bandwidth") { lsp_bandwidth = value; lsp_bandwidth.value_namespace = name_space; lsp_bandwidth.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-setup-priority") { lsp_setup_priority = value; lsp_setup_priority.value_namespace = name_space; lsp_setup_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-hold-priority") { lsp_hold_priority = value; lsp_hold_priority.value_namespace = name_space; lsp_hold_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-bandwidth-type") { lsp_bandwidth_type = value; lsp_bandwidth_type.value_namespace = name_space; lsp_bandwidth_type.value_namespace_prefix = name_space_prefix; } if(value_path == "dste-class-match") { dste_class_match = value; dste_class_match.value_namespace = name_space; dste_class_match.value_namespace_prefix = name_space_prefix; } if(value_path == "dste-class-index") { dste_class_index = value; dste_class_index.value_namespace = name_space; dste_class_index.value_namespace_prefix = name_space_prefix; } if(value_path == "type") { type = value; type.value_namespace = name_space; type.value_namespace_prefix = name_space_prefix; } if(value_path == "uptime") { uptime = value; uptime.value_namespace = name_space; uptime.value_namespace_prefix = name_space_prefix; } if(value_path == "s2-ls-up") { s2_ls_up = value; s2_ls_up.value_namespace = name_space; s2_ls_up.value_namespace_prefix = name_space_prefix; } if(value_path == "s2-ls-proceeding") { s2_ls_proceeding = value; s2_ls_proceeding.value_namespace = name_space; s2_ls_proceeding.value_namespace_prefix = name_space_prefix; } if(value_path == "s2-ls-down") { s2_ls_down = value; s2_ls_down.value_namespace = name_space; s2_ls_down.value_namespace_prefix = name_space_prefix; } if(value_path == "reoptimize-reason") { reoptimize_reason = value; reoptimize_reason.value_namespace = name_space; reoptimize_reason.value_namespace_prefix = name_space_prefix; } if(value_path == "reoptimize-trigger") { reoptimize_trigger = value; reoptimize_trigger.value_namespace = name_space; reoptimize_trigger.value_namespace_prefix = name_space_prefix; } if(value_path == "timer-left") { timer_left = value; timer_left.value_namespace = name_space; timer_left.value_namespace_prefix = name_space_prefix; } if(value_path == "is-passive") { is_passive = value; is_passive.value_namespace = name_space; is_passive.value_namespace_prefix = name_space_prefix; } if(value_path == "is-interface") { is_interface = value; is_interface.value_namespace = name_space; is_interface.value_namespace_prefix = name_space_prefix; } if(value_path == "last-path-change") { last_path_change = value; last_path_change.value_namespace = name_space; last_path_change.value_namespace_prefix = name_space_prefix; } if(value_path == "persistent-bytes") { persistent_bytes = value; persistent_bytes.value_namespace = name_space; persistent_bytes.value_namespace_prefix = name_space_prefix; } if(value_path == "persistent-packets") { persistent_packets = value; persistent_packets.value_namespace = name_space; persistent_packets.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "signaled-name") { signaled_name.yfilter = yfilter; } if(value_path == "is-frr-failed") { is_frr_failed.yfilter = yfilter; } if(value_path == "frr-active-reason") { frr_active_reason.yfilter = yfilter; } if(value_path == "lsp-bandwidth") { lsp_bandwidth.yfilter = yfilter; } if(value_path == "lsp-setup-priority") { lsp_setup_priority.yfilter = yfilter; } if(value_path == "lsp-hold-priority") { lsp_hold_priority.yfilter = yfilter; } if(value_path == "lsp-bandwidth-type") { lsp_bandwidth_type.yfilter = yfilter; } if(value_path == "dste-class-match") { dste_class_match.yfilter = yfilter; } if(value_path == "dste-class-index") { dste_class_index.yfilter = yfilter; } if(value_path == "type") { type.yfilter = yfilter; } if(value_path == "uptime") { uptime.yfilter = yfilter; } if(value_path == "s2-ls-up") { s2_ls_up.yfilter = yfilter; } if(value_path == "s2-ls-proceeding") { s2_ls_proceeding.yfilter = yfilter; } if(value_path == "s2-ls-down") { s2_ls_down.yfilter = yfilter; } if(value_path == "reoptimize-reason") { reoptimize_reason.yfilter = yfilter; } if(value_path == "reoptimize-trigger") { reoptimize_trigger.yfilter = yfilter; } if(value_path == "timer-left") { timer_left.yfilter = yfilter; } if(value_path == "is-passive") { is_passive.yfilter = yfilter; } if(value_path == "is-interface") { is_interface.yfilter = yfilter; } if(value_path == "last-path-change") { last_path_change.yfilter = yfilter; } if(value_path == "persistent-bytes") { persistent_bytes.yfilter = yfilter; } if(value_path == "persistent-packets") { persistent_packets.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::has_leaf_or_child_of_name(const std::string & name) const { if(name == "lsp-fec" || name == "s2l" || name == "signaled-name" || name == "is-frr-failed" || name == "frr-active-reason" || name == "lsp-bandwidth" || name == "lsp-setup-priority" || name == "lsp-hold-priority" || name == "lsp-bandwidth-type" || name == "dste-class-match" || name == "dste-class-index" || name == "type" || name == "uptime" || name == "s2-ls-up" || name == "s2-ls-proceeding" || name == "s2-ls-down" || name == "reoptimize-reason" || name == "reoptimize-trigger" || name == "timer-left" || name == "is-passive" || name == "is-interface" || name == "last-path-change" || name == "persistent-bytes" || name == "persistent-packets") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::LspFec() : fec_lsp_id{YType::uint16, "fec-lsp-id"}, fec_tunnel_id{YType::uint16, "fec-tunnel-id"}, fec_extended_tunnel_id{YType::str, "fec-extended-tunnel-id"}, fec_source{YType::str, "fec-source"}, fec_vrf{YType::str, "fec-vrf"} , fec_destination_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo>()) { fec_destination_info->parent = this; yang_name = "lsp-fec"; yang_parent_name = "reoptimized-p2mp-lsp"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::~LspFec() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::has_data() const { if (is_presence_container) return true; return fec_lsp_id.is_set || fec_tunnel_id.is_set || fec_extended_tunnel_id.is_set || fec_source.is_set || fec_vrf.is_set || (fec_destination_info != nullptr && fec_destination_info->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::has_operation() const { return is_set(yfilter) || ydk::is_set(fec_lsp_id.yfilter) || ydk::is_set(fec_tunnel_id.yfilter) || ydk::is_set(fec_extended_tunnel_id.yfilter) || ydk::is_set(fec_source.yfilter) || ydk::is_set(fec_vrf.yfilter) || (fec_destination_info != nullptr && fec_destination_info->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "lsp-fec"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (fec_lsp_id.is_set || is_set(fec_lsp_id.yfilter)) leaf_name_data.push_back(fec_lsp_id.get_name_leafdata()); if (fec_tunnel_id.is_set || is_set(fec_tunnel_id.yfilter)) leaf_name_data.push_back(fec_tunnel_id.get_name_leafdata()); if (fec_extended_tunnel_id.is_set || is_set(fec_extended_tunnel_id.yfilter)) leaf_name_data.push_back(fec_extended_tunnel_id.get_name_leafdata()); if (fec_source.is_set || is_set(fec_source.yfilter)) leaf_name_data.push_back(fec_source.get_name_leafdata()); if (fec_vrf.is_set || is_set(fec_vrf.yfilter)) leaf_name_data.push_back(fec_vrf.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "fec-destination-info") { if(fec_destination_info == nullptr) { fec_destination_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo>(); } return fec_destination_info; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(fec_destination_info != nullptr) { _children["fec-destination-info"] = fec_destination_info; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::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 == "fec-lsp-id") { fec_lsp_id = value; fec_lsp_id.value_namespace = name_space; fec_lsp_id.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-tunnel-id") { fec_tunnel_id = value; fec_tunnel_id.value_namespace = name_space; fec_tunnel_id.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-extended-tunnel-id") { fec_extended_tunnel_id = value; fec_extended_tunnel_id.value_namespace = name_space; fec_extended_tunnel_id.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-source") { fec_source = value; fec_source.value_namespace = name_space; fec_source.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-vrf") { fec_vrf = value; fec_vrf.value_namespace = name_space; fec_vrf.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "fec-lsp-id") { fec_lsp_id.yfilter = yfilter; } if(value_path == "fec-tunnel-id") { fec_tunnel_id.yfilter = yfilter; } if(value_path == "fec-extended-tunnel-id") { fec_extended_tunnel_id.yfilter = yfilter; } if(value_path == "fec-source") { fec_source.yfilter = yfilter; } if(value_path == "fec-vrf") { fec_vrf.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::has_leaf_or_child_of_name(const std::string & name) const { if(name == "fec-destination-info" || name == "fec-lsp-id" || name == "fec-tunnel-id" || name == "fec-extended-tunnel-id" || name == "fec-source" || name == "fec-vrf") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::FecDestinationInfo() : fec_ctype{YType::enumeration, "fec-ctype"}, p2p_lsp_destination{YType::str, "p2p-lsp-destination"}, fec_destination_p2mp_id{YType::uint32, "fec-destination-p2mp-id"} { yang_name = "fec-destination-info"; yang_parent_name = "lsp-fec"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::~FecDestinationInfo() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::has_data() const { if (is_presence_container) return true; return fec_ctype.is_set || p2p_lsp_destination.is_set || fec_destination_p2mp_id.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::has_operation() const { return is_set(yfilter) || ydk::is_set(fec_ctype.yfilter) || ydk::is_set(p2p_lsp_destination.yfilter) || ydk::is_set(fec_destination_p2mp_id.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "fec-destination-info"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (fec_ctype.is_set || is_set(fec_ctype.yfilter)) leaf_name_data.push_back(fec_ctype.get_name_leafdata()); if (p2p_lsp_destination.is_set || is_set(p2p_lsp_destination.yfilter)) leaf_name_data.push_back(p2p_lsp_destination.get_name_leafdata()); if (fec_destination_p2mp_id.is_set || is_set(fec_destination_p2mp_id.yfilter)) leaf_name_data.push_back(fec_destination_p2mp_id.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::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 == "fec-ctype") { fec_ctype = value; fec_ctype.value_namespace = name_space; fec_ctype.value_namespace_prefix = name_space_prefix; } if(value_path == "p2p-lsp-destination") { p2p_lsp_destination = value; p2p_lsp_destination.value_namespace = name_space; p2p_lsp_destination.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-destination-p2mp-id") { fec_destination_p2mp_id = value; fec_destination_p2mp_id.value_namespace = name_space; fec_destination_p2mp_id.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "fec-ctype") { fec_ctype.yfilter = yfilter; } if(value_path == "p2p-lsp-destination") { p2p_lsp_destination.yfilter = yfilter; } if(value_path == "fec-destination-p2mp-id") { fec_destination_p2mp_id.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::LspFec::FecDestinationInfo::has_leaf_or_child_of_name(const std::string & name) const { if(name == "fec-ctype" || name == "p2p-lsp-destination" || name == "fec-destination-p2mp-id") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2l() : pcalc_area{YType::str, "pcalc-area"}, is_expanded_ero{YType::boolean, "is-expanded-ero"}, path_reeval_query_mid{YType::uint32, "path-reeval-query-mid"}, time_since_last_query_received_mid{YType::uint32, "time-since-last-query-received-mid"}, time_since_last_preferred_path_exists_send_mid{YType::uint32, "time-since-last-preferred-path-exists-send-mid"}, time_since_last_preferred_tree_exists_send_mid{YType::uint32, "time-since-last-preferred-tree-exists-send-mid"}, expanded_ero_area_id{YType::str, "expanded-ero-area-id"}, expanded_ero_affinity_bits{YType::uint32, "expanded-ero-affinity-bits"}, expanded_ero_affinity_mask{YType::uint32, "expanded-ero-affinity-mask"}, expanded_ero_metric_type{YType::enumeration, "expanded-ero-metric-type"}, expanded_ero_metric{YType::uint32, "expanded-ero-metric"}, abr_auto_discovered{YType::str, "abr-auto-discovered"}, is_frr_enabled{YType::boolean, "is-frr-enabled"}, is_node_protected{YType::boolean, "is-node-protected"}, is_bandwidth_protect{YType::boolean, "is-bandwidth-protect"}, path_rro_enabled{YType::boolean, "path-rro-enabled"}, weight{YType::uint64, "weight"}, reverse_weight{YType::uint64, "reverse-weight"}, uptime{YType::uint32, "uptime"}, egress_interface{YType::str, "egress-interface"}, egress_interface_state{YType::enumeration, "egress-interface-state"}, egress_interface_brief{YType::str, "egress-interface-brief"}, ingress_interface{YType::str, "ingress-interface"}, ingress_interface_state{YType::enumeration, "ingress-interface-state"}, ingress_interface_brief{YType::str, "ingress-interface-brief"}, s2l_local_label{YType::uint32, "s2l-local-label"}, s2l_out_label{YType::uint32, "s2l-out-label"}, outbound_frr_state{YType::enumeration, "outbound-frr-state"}, frr_out_tunnel_interface{YType::str, "frr-out-tunnel-interface"}, role{YType::enumeration, "role"}, signalling_status{YType::enumeration, "signalling-status"}, local_router_id{YType::str, "local-router-id"}, upstream_router_id{YType::str, "upstream-router-id"}, downstream_router_id{YType::str, "downstream-router-id"}, next_hop_address{YType::str, "next-hop-address"}, next_next_hop_address{YType::str, "next-next-hop-address"}, previous_hop_address{YType::str, "previous-hop-address"}, incoming_address{YType::str, "incoming-address"}, backup_tunnel_interface{YType::str, "backup-tunnel-interface"}, node_hop_count{YType::uint8, "node-hop-count"}, is_optical{YType::boolean, "is-optical"}, s2l_reverse_ero_obj_present{YType::boolean, "s2l-reverse-ero-obj-present"}, reverse_lsp_present{YType::boolean, "reverse-lsp-present"}, reverse_lsp_connected{YType::boolean, "reverse-lsp-connected"}, reverse_lsp_name{YType::str, "reverse-lsp-name"}, s2l_reverse_tspec_obj_present{YType::boolean, "s2l-reverse-tspec-obj-present"}, path_using_strict_spf{YType::boolean, "path-using-strict-spf"} , s2l_fec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec>()) , active_path_option(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption>()) , out_xro(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro>()) , in_xro(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro>()) , tspec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Tspec>()) , generic_tspec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::GenericTspec>()) , fspec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Fspec>()) , generic_fspec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::GenericFspec>()) , next_hop_address_generic(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::NextHopAddressGeneric>()) , previous_hop_address_generic(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::PreviousHopAddressGeneric>()) , incoming_address_generic(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::IncomingAddressGeneric>()) , s2l_convergence(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lConvergence>()) , soft_preemption(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::SoftPreemption>()) , gmpls_labels(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::GmplsLabels>()) , otn_s2l(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OtnS2l>()) , head_end_bfd_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::HeadEndBfdInfo>()) , tail_end_bfd_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::TailEndBfdInfo>()) , srlg_collection(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::SrlgCollection>()) , association(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Association>()) , protection(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Protection>()) , reverse_lsp_fec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ReverseLspFec>()) , reverse_tspec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ReverseTspec>()) , flex_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::FlexInfo>()) , lsp_wrap_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::LspWrapInfo>()) , diversity_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::DiversityInfo>()) , accumulated_path_metrics(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::AccumulatedPathMetrics>()) , accumulated_reverse_path_metrics(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::AccumulatedReversePathMetrics>()) , s2l_reverse_lsp_sub_obj(this, {}) , shared_risk_link_group(this, {}) , out_ero(this, {}) , in_ero(this, {}) , path_rro(this, {}) , resv_rro(this, {}) , path_affinity_array(this, {}) , reverse_ero_in(this, {}) , s2l_segment_routing_path(this, {}) { s2l_fec->parent = this; active_path_option->parent = this; out_xro->parent = this; in_xro->parent = this; tspec->parent = this; generic_tspec->parent = this; fspec->parent = this; generic_fspec->parent = this; next_hop_address_generic->parent = this; previous_hop_address_generic->parent = this; incoming_address_generic->parent = this; s2l_convergence->parent = this; soft_preemption->parent = this; gmpls_labels->parent = this; otn_s2l->parent = this; head_end_bfd_info->parent = this; tail_end_bfd_info->parent = this; srlg_collection->parent = this; association->parent = this; protection->parent = this; reverse_lsp_fec->parent = this; reverse_tspec->parent = this; flex_info->parent = this; lsp_wrap_info->parent = this; diversity_info->parent = this; accumulated_path_metrics->parent = this; accumulated_reverse_path_metrics->parent = this; yang_name = "s2l"; yang_parent_name = "reoptimized-p2mp-lsp"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::~S2l() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<s2l_reverse_lsp_sub_obj.len(); index++) { if(s2l_reverse_lsp_sub_obj[index]->has_data()) return true; } for (std::size_t index=0; index<shared_risk_link_group.len(); index++) { if(shared_risk_link_group[index]->has_data()) return true; } for (std::size_t index=0; index<out_ero.len(); index++) { if(out_ero[index]->has_data()) return true; } for (std::size_t index=0; index<in_ero.len(); index++) { if(in_ero[index]->has_data()) return true; } for (std::size_t index=0; index<path_rro.len(); index++) { if(path_rro[index]->has_data()) return true; } for (std::size_t index=0; index<resv_rro.len(); index++) { if(resv_rro[index]->has_data()) return true; } for (std::size_t index=0; index<path_affinity_array.len(); index++) { if(path_affinity_array[index]->has_data()) return true; } for (std::size_t index=0; index<reverse_ero_in.len(); index++) { if(reverse_ero_in[index]->has_data()) return true; } for (std::size_t index=0; index<s2l_segment_routing_path.len(); index++) { if(s2l_segment_routing_path[index]->has_data()) return true; } return pcalc_area.is_set || is_expanded_ero.is_set || path_reeval_query_mid.is_set || time_since_last_query_received_mid.is_set || time_since_last_preferred_path_exists_send_mid.is_set || time_since_last_preferred_tree_exists_send_mid.is_set || expanded_ero_area_id.is_set || expanded_ero_affinity_bits.is_set || expanded_ero_affinity_mask.is_set || expanded_ero_metric_type.is_set || expanded_ero_metric.is_set || abr_auto_discovered.is_set || is_frr_enabled.is_set || is_node_protected.is_set || is_bandwidth_protect.is_set || path_rro_enabled.is_set || weight.is_set || reverse_weight.is_set || uptime.is_set || egress_interface.is_set || egress_interface_state.is_set || egress_interface_brief.is_set || ingress_interface.is_set || ingress_interface_state.is_set || ingress_interface_brief.is_set || s2l_local_label.is_set || s2l_out_label.is_set || outbound_frr_state.is_set || frr_out_tunnel_interface.is_set || role.is_set || signalling_status.is_set || local_router_id.is_set || upstream_router_id.is_set || downstream_router_id.is_set || next_hop_address.is_set || next_next_hop_address.is_set || previous_hop_address.is_set || incoming_address.is_set || backup_tunnel_interface.is_set || node_hop_count.is_set || is_optical.is_set || s2l_reverse_ero_obj_present.is_set || reverse_lsp_present.is_set || reverse_lsp_connected.is_set || reverse_lsp_name.is_set || s2l_reverse_tspec_obj_present.is_set || path_using_strict_spf.is_set || (s2l_fec != nullptr && s2l_fec->has_data()) || (active_path_option != nullptr && active_path_option->has_data()) || (out_xro != nullptr && out_xro->has_data()) || (in_xro != nullptr && in_xro->has_data()) || (tspec != nullptr && tspec->has_data()) || (generic_tspec != nullptr && generic_tspec->has_data()) || (fspec != nullptr && fspec->has_data()) || (generic_fspec != nullptr && generic_fspec->has_data()) || (next_hop_address_generic != nullptr && next_hop_address_generic->has_data()) || (previous_hop_address_generic != nullptr && previous_hop_address_generic->has_data()) || (incoming_address_generic != nullptr && incoming_address_generic->has_data()) || (s2l_convergence != nullptr && s2l_convergence->has_data()) || (soft_preemption != nullptr && soft_preemption->has_data()) || (gmpls_labels != nullptr && gmpls_labels->has_data()) || (otn_s2l != nullptr && otn_s2l->has_data()) || (head_end_bfd_info != nullptr && head_end_bfd_info->has_data()) || (tail_end_bfd_info != nullptr && tail_end_bfd_info->has_data()) || (srlg_collection != nullptr && srlg_collection->has_data()) || (association != nullptr && association->has_data()) || (protection != nullptr && protection->has_data()) || (reverse_lsp_fec != nullptr && reverse_lsp_fec->has_data()) || (reverse_tspec != nullptr && reverse_tspec->has_data()) || (flex_info != nullptr && flex_info->has_data()) || (lsp_wrap_info != nullptr && lsp_wrap_info->has_data()) || (diversity_info != nullptr && diversity_info->has_data()) || (accumulated_path_metrics != nullptr && accumulated_path_metrics->has_data()) || (accumulated_reverse_path_metrics != nullptr && accumulated_reverse_path_metrics->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::has_operation() const { for (std::size_t index=0; index<s2l_reverse_lsp_sub_obj.len(); index++) { if(s2l_reverse_lsp_sub_obj[index]->has_operation()) return true; } for (std::size_t index=0; index<shared_risk_link_group.len(); index++) { if(shared_risk_link_group[index]->has_operation()) return true; } for (std::size_t index=0; index<out_ero.len(); index++) { if(out_ero[index]->has_operation()) return true; } for (std::size_t index=0; index<in_ero.len(); index++) { if(in_ero[index]->has_operation()) return true; } for (std::size_t index=0; index<path_rro.len(); index++) { if(path_rro[index]->has_operation()) return true; } for (std::size_t index=0; index<resv_rro.len(); index++) { if(resv_rro[index]->has_operation()) return true; } for (std::size_t index=0; index<path_affinity_array.len(); index++) { if(path_affinity_array[index]->has_operation()) return true; } for (std::size_t index=0; index<reverse_ero_in.len(); index++) { if(reverse_ero_in[index]->has_operation()) return true; } for (std::size_t index=0; index<s2l_segment_routing_path.len(); index++) { if(s2l_segment_routing_path[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(pcalc_area.yfilter) || ydk::is_set(is_expanded_ero.yfilter) || ydk::is_set(path_reeval_query_mid.yfilter) || ydk::is_set(time_since_last_query_received_mid.yfilter) || ydk::is_set(time_since_last_preferred_path_exists_send_mid.yfilter) || ydk::is_set(time_since_last_preferred_tree_exists_send_mid.yfilter) || ydk::is_set(expanded_ero_area_id.yfilter) || ydk::is_set(expanded_ero_affinity_bits.yfilter) || ydk::is_set(expanded_ero_affinity_mask.yfilter) || ydk::is_set(expanded_ero_metric_type.yfilter) || ydk::is_set(expanded_ero_metric.yfilter) || ydk::is_set(abr_auto_discovered.yfilter) || ydk::is_set(is_frr_enabled.yfilter) || ydk::is_set(is_node_protected.yfilter) || ydk::is_set(is_bandwidth_protect.yfilter) || ydk::is_set(path_rro_enabled.yfilter) || ydk::is_set(weight.yfilter) || ydk::is_set(reverse_weight.yfilter) || ydk::is_set(uptime.yfilter) || ydk::is_set(egress_interface.yfilter) || ydk::is_set(egress_interface_state.yfilter) || ydk::is_set(egress_interface_brief.yfilter) || ydk::is_set(ingress_interface.yfilter) || ydk::is_set(ingress_interface_state.yfilter) || ydk::is_set(ingress_interface_brief.yfilter) || ydk::is_set(s2l_local_label.yfilter) || ydk::is_set(s2l_out_label.yfilter) || ydk::is_set(outbound_frr_state.yfilter) || ydk::is_set(frr_out_tunnel_interface.yfilter) || ydk::is_set(role.yfilter) || ydk::is_set(signalling_status.yfilter) || ydk::is_set(local_router_id.yfilter) || ydk::is_set(upstream_router_id.yfilter) || ydk::is_set(downstream_router_id.yfilter) || ydk::is_set(next_hop_address.yfilter) || ydk::is_set(next_next_hop_address.yfilter) || ydk::is_set(previous_hop_address.yfilter) || ydk::is_set(incoming_address.yfilter) || ydk::is_set(backup_tunnel_interface.yfilter) || ydk::is_set(node_hop_count.yfilter) || ydk::is_set(is_optical.yfilter) || ydk::is_set(s2l_reverse_ero_obj_present.yfilter) || ydk::is_set(reverse_lsp_present.yfilter) || ydk::is_set(reverse_lsp_connected.yfilter) || ydk::is_set(reverse_lsp_name.yfilter) || ydk::is_set(s2l_reverse_tspec_obj_present.yfilter) || ydk::is_set(path_using_strict_spf.yfilter) || (s2l_fec != nullptr && s2l_fec->has_operation()) || (active_path_option != nullptr && active_path_option->has_operation()) || (out_xro != nullptr && out_xro->has_operation()) || (in_xro != nullptr && in_xro->has_operation()) || (tspec != nullptr && tspec->has_operation()) || (generic_tspec != nullptr && generic_tspec->has_operation()) || (fspec != nullptr && fspec->has_operation()) || (generic_fspec != nullptr && generic_fspec->has_operation()) || (next_hop_address_generic != nullptr && next_hop_address_generic->has_operation()) || (previous_hop_address_generic != nullptr && previous_hop_address_generic->has_operation()) || (incoming_address_generic != nullptr && incoming_address_generic->has_operation()) || (s2l_convergence != nullptr && s2l_convergence->has_operation()) || (soft_preemption != nullptr && soft_preemption->has_operation()) || (gmpls_labels != nullptr && gmpls_labels->has_operation()) || (otn_s2l != nullptr && otn_s2l->has_operation()) || (head_end_bfd_info != nullptr && head_end_bfd_info->has_operation()) || (tail_end_bfd_info != nullptr && tail_end_bfd_info->has_operation()) || (srlg_collection != nullptr && srlg_collection->has_operation()) || (association != nullptr && association->has_operation()) || (protection != nullptr && protection->has_operation()) || (reverse_lsp_fec != nullptr && reverse_lsp_fec->has_operation()) || (reverse_tspec != nullptr && reverse_tspec->has_operation()) || (flex_info != nullptr && flex_info->has_operation()) || (lsp_wrap_info != nullptr && lsp_wrap_info->has_operation()) || (diversity_info != nullptr && diversity_info->has_operation()) || (accumulated_path_metrics != nullptr && accumulated_path_metrics->has_operation()) || (accumulated_reverse_path_metrics != nullptr && accumulated_reverse_path_metrics->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "s2l"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (pcalc_area.is_set || is_set(pcalc_area.yfilter)) leaf_name_data.push_back(pcalc_area.get_name_leafdata()); if (is_expanded_ero.is_set || is_set(is_expanded_ero.yfilter)) leaf_name_data.push_back(is_expanded_ero.get_name_leafdata()); if (path_reeval_query_mid.is_set || is_set(path_reeval_query_mid.yfilter)) leaf_name_data.push_back(path_reeval_query_mid.get_name_leafdata()); if (time_since_last_query_received_mid.is_set || is_set(time_since_last_query_received_mid.yfilter)) leaf_name_data.push_back(time_since_last_query_received_mid.get_name_leafdata()); if (time_since_last_preferred_path_exists_send_mid.is_set || is_set(time_since_last_preferred_path_exists_send_mid.yfilter)) leaf_name_data.push_back(time_since_last_preferred_path_exists_send_mid.get_name_leafdata()); if (time_since_last_preferred_tree_exists_send_mid.is_set || is_set(time_since_last_preferred_tree_exists_send_mid.yfilter)) leaf_name_data.push_back(time_since_last_preferred_tree_exists_send_mid.get_name_leafdata()); if (expanded_ero_area_id.is_set || is_set(expanded_ero_area_id.yfilter)) leaf_name_data.push_back(expanded_ero_area_id.get_name_leafdata()); if (expanded_ero_affinity_bits.is_set || is_set(expanded_ero_affinity_bits.yfilter)) leaf_name_data.push_back(expanded_ero_affinity_bits.get_name_leafdata()); if (expanded_ero_affinity_mask.is_set || is_set(expanded_ero_affinity_mask.yfilter)) leaf_name_data.push_back(expanded_ero_affinity_mask.get_name_leafdata()); if (expanded_ero_metric_type.is_set || is_set(expanded_ero_metric_type.yfilter)) leaf_name_data.push_back(expanded_ero_metric_type.get_name_leafdata()); if (expanded_ero_metric.is_set || is_set(expanded_ero_metric.yfilter)) leaf_name_data.push_back(expanded_ero_metric.get_name_leafdata()); if (abr_auto_discovered.is_set || is_set(abr_auto_discovered.yfilter)) leaf_name_data.push_back(abr_auto_discovered.get_name_leafdata()); if (is_frr_enabled.is_set || is_set(is_frr_enabled.yfilter)) leaf_name_data.push_back(is_frr_enabled.get_name_leafdata()); if (is_node_protected.is_set || is_set(is_node_protected.yfilter)) leaf_name_data.push_back(is_node_protected.get_name_leafdata()); if (is_bandwidth_protect.is_set || is_set(is_bandwidth_protect.yfilter)) leaf_name_data.push_back(is_bandwidth_protect.get_name_leafdata()); if (path_rro_enabled.is_set || is_set(path_rro_enabled.yfilter)) leaf_name_data.push_back(path_rro_enabled.get_name_leafdata()); if (weight.is_set || is_set(weight.yfilter)) leaf_name_data.push_back(weight.get_name_leafdata()); if (reverse_weight.is_set || is_set(reverse_weight.yfilter)) leaf_name_data.push_back(reverse_weight.get_name_leafdata()); if (uptime.is_set || is_set(uptime.yfilter)) leaf_name_data.push_back(uptime.get_name_leafdata()); if (egress_interface.is_set || is_set(egress_interface.yfilter)) leaf_name_data.push_back(egress_interface.get_name_leafdata()); if (egress_interface_state.is_set || is_set(egress_interface_state.yfilter)) leaf_name_data.push_back(egress_interface_state.get_name_leafdata()); if (egress_interface_brief.is_set || is_set(egress_interface_brief.yfilter)) leaf_name_data.push_back(egress_interface_brief.get_name_leafdata()); if (ingress_interface.is_set || is_set(ingress_interface.yfilter)) leaf_name_data.push_back(ingress_interface.get_name_leafdata()); if (ingress_interface_state.is_set || is_set(ingress_interface_state.yfilter)) leaf_name_data.push_back(ingress_interface_state.get_name_leafdata()); if (ingress_interface_brief.is_set || is_set(ingress_interface_brief.yfilter)) leaf_name_data.push_back(ingress_interface_brief.get_name_leafdata()); if (s2l_local_label.is_set || is_set(s2l_local_label.yfilter)) leaf_name_data.push_back(s2l_local_label.get_name_leafdata()); if (s2l_out_label.is_set || is_set(s2l_out_label.yfilter)) leaf_name_data.push_back(s2l_out_label.get_name_leafdata()); if (outbound_frr_state.is_set || is_set(outbound_frr_state.yfilter)) leaf_name_data.push_back(outbound_frr_state.get_name_leafdata()); if (frr_out_tunnel_interface.is_set || is_set(frr_out_tunnel_interface.yfilter)) leaf_name_data.push_back(frr_out_tunnel_interface.get_name_leafdata()); if (role.is_set || is_set(role.yfilter)) leaf_name_data.push_back(role.get_name_leafdata()); if (signalling_status.is_set || is_set(signalling_status.yfilter)) leaf_name_data.push_back(signalling_status.get_name_leafdata()); if (local_router_id.is_set || is_set(local_router_id.yfilter)) leaf_name_data.push_back(local_router_id.get_name_leafdata()); if (upstream_router_id.is_set || is_set(upstream_router_id.yfilter)) leaf_name_data.push_back(upstream_router_id.get_name_leafdata()); if (downstream_router_id.is_set || is_set(downstream_router_id.yfilter)) leaf_name_data.push_back(downstream_router_id.get_name_leafdata()); if (next_hop_address.is_set || is_set(next_hop_address.yfilter)) leaf_name_data.push_back(next_hop_address.get_name_leafdata()); if (next_next_hop_address.is_set || is_set(next_next_hop_address.yfilter)) leaf_name_data.push_back(next_next_hop_address.get_name_leafdata()); if (previous_hop_address.is_set || is_set(previous_hop_address.yfilter)) leaf_name_data.push_back(previous_hop_address.get_name_leafdata()); if (incoming_address.is_set || is_set(incoming_address.yfilter)) leaf_name_data.push_back(incoming_address.get_name_leafdata()); if (backup_tunnel_interface.is_set || is_set(backup_tunnel_interface.yfilter)) leaf_name_data.push_back(backup_tunnel_interface.get_name_leafdata()); if (node_hop_count.is_set || is_set(node_hop_count.yfilter)) leaf_name_data.push_back(node_hop_count.get_name_leafdata()); if (is_optical.is_set || is_set(is_optical.yfilter)) leaf_name_data.push_back(is_optical.get_name_leafdata()); if (s2l_reverse_ero_obj_present.is_set || is_set(s2l_reverse_ero_obj_present.yfilter)) leaf_name_data.push_back(s2l_reverse_ero_obj_present.get_name_leafdata()); if (reverse_lsp_present.is_set || is_set(reverse_lsp_present.yfilter)) leaf_name_data.push_back(reverse_lsp_present.get_name_leafdata()); if (reverse_lsp_connected.is_set || is_set(reverse_lsp_connected.yfilter)) leaf_name_data.push_back(reverse_lsp_connected.get_name_leafdata()); if (reverse_lsp_name.is_set || is_set(reverse_lsp_name.yfilter)) leaf_name_data.push_back(reverse_lsp_name.get_name_leafdata()); if (s2l_reverse_tspec_obj_present.is_set || is_set(s2l_reverse_tspec_obj_present.yfilter)) leaf_name_data.push_back(s2l_reverse_tspec_obj_present.get_name_leafdata()); if (path_using_strict_spf.is_set || is_set(path_using_strict_spf.yfilter)) leaf_name_data.push_back(path_using_strict_spf.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "s2l-fec") { if(s2l_fec == nullptr) { s2l_fec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec>(); } return s2l_fec; } if(child_yang_name == "active-path-option") { if(active_path_option == nullptr) { active_path_option = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption>(); } return active_path_option; } if(child_yang_name == "out-xro") { if(out_xro == nullptr) { out_xro = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro>(); } return out_xro; } if(child_yang_name == "in-xro") { if(in_xro == nullptr) { in_xro = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro>(); } return in_xro; } if(child_yang_name == "tspec") { if(tspec == nullptr) { tspec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Tspec>(); } return tspec; } if(child_yang_name == "generic-tspec") { if(generic_tspec == nullptr) { generic_tspec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::GenericTspec>(); } return generic_tspec; } if(child_yang_name == "fspec") { if(fspec == nullptr) { fspec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Fspec>(); } return fspec; } if(child_yang_name == "generic-fspec") { if(generic_fspec == nullptr) { generic_fspec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::GenericFspec>(); } return generic_fspec; } if(child_yang_name == "next-hop-address-generic") { if(next_hop_address_generic == nullptr) { next_hop_address_generic = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::NextHopAddressGeneric>(); } return next_hop_address_generic; } if(child_yang_name == "previous-hop-address-generic") { if(previous_hop_address_generic == nullptr) { previous_hop_address_generic = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::PreviousHopAddressGeneric>(); } return previous_hop_address_generic; } if(child_yang_name == "incoming-address-generic") { if(incoming_address_generic == nullptr) { incoming_address_generic = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::IncomingAddressGeneric>(); } return incoming_address_generic; } if(child_yang_name == "s2l-convergence") { if(s2l_convergence == nullptr) { s2l_convergence = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lConvergence>(); } return s2l_convergence; } if(child_yang_name == "soft-preemption") { if(soft_preemption == nullptr) { soft_preemption = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::SoftPreemption>(); } return soft_preemption; } if(child_yang_name == "gmpls-labels") { if(gmpls_labels == nullptr) { gmpls_labels = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::GmplsLabels>(); } return gmpls_labels; } if(child_yang_name == "otn-s2l") { if(otn_s2l == nullptr) { otn_s2l = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OtnS2l>(); } return otn_s2l; } if(child_yang_name == "head-end-bfd-info") { if(head_end_bfd_info == nullptr) { head_end_bfd_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::HeadEndBfdInfo>(); } return head_end_bfd_info; } if(child_yang_name == "tail-end-bfd-info") { if(tail_end_bfd_info == nullptr) { tail_end_bfd_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::TailEndBfdInfo>(); } return tail_end_bfd_info; } if(child_yang_name == "srlg-collection") { if(srlg_collection == nullptr) { srlg_collection = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::SrlgCollection>(); } return srlg_collection; } if(child_yang_name == "association") { if(association == nullptr) { association = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Association>(); } return association; } if(child_yang_name == "protection") { if(protection == nullptr) { protection = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::Protection>(); } return protection; } if(child_yang_name == "reverse-lsp-fec") { if(reverse_lsp_fec == nullptr) { reverse_lsp_fec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ReverseLspFec>(); } return reverse_lsp_fec; } if(child_yang_name == "reverse-tspec") { if(reverse_tspec == nullptr) { reverse_tspec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ReverseTspec>(); } return reverse_tspec; } if(child_yang_name == "flex-info") { if(flex_info == nullptr) { flex_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::FlexInfo>(); } return flex_info; } if(child_yang_name == "lsp-wrap-info") { if(lsp_wrap_info == nullptr) { lsp_wrap_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::LspWrapInfo>(); } return lsp_wrap_info; } if(child_yang_name == "diversity-info") { if(diversity_info == nullptr) { diversity_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::DiversityInfo>(); } return diversity_info; } if(child_yang_name == "accumulated-path-metrics") { if(accumulated_path_metrics == nullptr) { accumulated_path_metrics = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::AccumulatedPathMetrics>(); } return accumulated_path_metrics; } if(child_yang_name == "accumulated-reverse-path-metrics") { if(accumulated_reverse_path_metrics == nullptr) { accumulated_reverse_path_metrics = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::AccumulatedReversePathMetrics>(); } return accumulated_reverse_path_metrics; } if(child_yang_name == "s2l-reverse-lsp-sub-obj") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lReverseLspSubObj>(); ent_->parent = this; s2l_reverse_lsp_sub_obj.append(ent_); return ent_; } if(child_yang_name == "shared-risk-link-group") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::SharedRiskLinkGroup>(); ent_->parent = this; shared_risk_link_group.append(ent_); return ent_; } if(child_yang_name == "out-ero") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutEro>(); ent_->parent = this; out_ero.append(ent_); return ent_; } if(child_yang_name == "in-ero") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InEro>(); ent_->parent = this; in_ero.append(ent_); return ent_; } if(child_yang_name == "path-rro") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::PathRro>(); ent_->parent = this; path_rro.append(ent_); return ent_; } if(child_yang_name == "resv-rro") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ResvRro>(); ent_->parent = this; resv_rro.append(ent_); return ent_; } if(child_yang_name == "path-affinity-array") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::PathAffinityArray>(); ent_->parent = this; path_affinity_array.append(ent_); return ent_; } if(child_yang_name == "reverse-ero-in") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ReverseEroIn>(); ent_->parent = this; reverse_ero_in.append(ent_); return ent_; } if(child_yang_name == "s2l-segment-routing-path") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lSegmentRoutingPath>(); ent_->parent = this; s2l_segment_routing_path.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(s2l_fec != nullptr) { _children["s2l-fec"] = s2l_fec; } if(active_path_option != nullptr) { _children["active-path-option"] = active_path_option; } if(out_xro != nullptr) { _children["out-xro"] = out_xro; } if(in_xro != nullptr) { _children["in-xro"] = in_xro; } if(tspec != nullptr) { _children["tspec"] = tspec; } if(generic_tspec != nullptr) { _children["generic-tspec"] = generic_tspec; } if(fspec != nullptr) { _children["fspec"] = fspec; } if(generic_fspec != nullptr) { _children["generic-fspec"] = generic_fspec; } if(next_hop_address_generic != nullptr) { _children["next-hop-address-generic"] = next_hop_address_generic; } if(previous_hop_address_generic != nullptr) { _children["previous-hop-address-generic"] = previous_hop_address_generic; } if(incoming_address_generic != nullptr) { _children["incoming-address-generic"] = incoming_address_generic; } if(s2l_convergence != nullptr) { _children["s2l-convergence"] = s2l_convergence; } if(soft_preemption != nullptr) { _children["soft-preemption"] = soft_preemption; } if(gmpls_labels != nullptr) { _children["gmpls-labels"] = gmpls_labels; } if(otn_s2l != nullptr) { _children["otn-s2l"] = otn_s2l; } if(head_end_bfd_info != nullptr) { _children["head-end-bfd-info"] = head_end_bfd_info; } if(tail_end_bfd_info != nullptr) { _children["tail-end-bfd-info"] = tail_end_bfd_info; } if(srlg_collection != nullptr) { _children["srlg-collection"] = srlg_collection; } if(association != nullptr) { _children["association"] = association; } if(protection != nullptr) { _children["protection"] = protection; } if(reverse_lsp_fec != nullptr) { _children["reverse-lsp-fec"] = reverse_lsp_fec; } if(reverse_tspec != nullptr) { _children["reverse-tspec"] = reverse_tspec; } if(flex_info != nullptr) { _children["flex-info"] = flex_info; } if(lsp_wrap_info != nullptr) { _children["lsp-wrap-info"] = lsp_wrap_info; } if(diversity_info != nullptr) { _children["diversity-info"] = diversity_info; } if(accumulated_path_metrics != nullptr) { _children["accumulated-path-metrics"] = accumulated_path_metrics; } if(accumulated_reverse_path_metrics != nullptr) { _children["accumulated-reverse-path-metrics"] = accumulated_reverse_path_metrics; } count_ = 0; for (auto ent_ : s2l_reverse_lsp_sub_obj.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_ : shared_risk_link_group.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_ : out_ero.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_ : in_ero.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_ : path_rro.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_ : resv_rro.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_ : path_affinity_array.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_ : reverse_ero_in.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_ : s2l_segment_routing_path.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::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 == "pcalc-area") { pcalc_area = value; pcalc_area.value_namespace = name_space; pcalc_area.value_namespace_prefix = name_space_prefix; } if(value_path == "is-expanded-ero") { is_expanded_ero = value; is_expanded_ero.value_namespace = name_space; is_expanded_ero.value_namespace_prefix = name_space_prefix; } if(value_path == "path-reeval-query-mid") { path_reeval_query_mid = value; path_reeval_query_mid.value_namespace = name_space; path_reeval_query_mid.value_namespace_prefix = name_space_prefix; } if(value_path == "time-since-last-query-received-mid") { time_since_last_query_received_mid = value; time_since_last_query_received_mid.value_namespace = name_space; time_since_last_query_received_mid.value_namespace_prefix = name_space_prefix; } if(value_path == "time-since-last-preferred-path-exists-send-mid") { time_since_last_preferred_path_exists_send_mid = value; time_since_last_preferred_path_exists_send_mid.value_namespace = name_space; time_since_last_preferred_path_exists_send_mid.value_namespace_prefix = name_space_prefix; } if(value_path == "time-since-last-preferred-tree-exists-send-mid") { time_since_last_preferred_tree_exists_send_mid = value; time_since_last_preferred_tree_exists_send_mid.value_namespace = name_space; time_since_last_preferred_tree_exists_send_mid.value_namespace_prefix = name_space_prefix; } if(value_path == "expanded-ero-area-id") { expanded_ero_area_id = value; expanded_ero_area_id.value_namespace = name_space; expanded_ero_area_id.value_namespace_prefix = name_space_prefix; } if(value_path == "expanded-ero-affinity-bits") { expanded_ero_affinity_bits = value; expanded_ero_affinity_bits.value_namespace = name_space; expanded_ero_affinity_bits.value_namespace_prefix = name_space_prefix; } if(value_path == "expanded-ero-affinity-mask") { expanded_ero_affinity_mask = value; expanded_ero_affinity_mask.value_namespace = name_space; expanded_ero_affinity_mask.value_namespace_prefix = name_space_prefix; } if(value_path == "expanded-ero-metric-type") { expanded_ero_metric_type = value; expanded_ero_metric_type.value_namespace = name_space; expanded_ero_metric_type.value_namespace_prefix = name_space_prefix; } if(value_path == "expanded-ero-metric") { expanded_ero_metric = value; expanded_ero_metric.value_namespace = name_space; expanded_ero_metric.value_namespace_prefix = name_space_prefix; } if(value_path == "abr-auto-discovered") { abr_auto_discovered = value; abr_auto_discovered.value_namespace = name_space; abr_auto_discovered.value_namespace_prefix = name_space_prefix; } if(value_path == "is-frr-enabled") { is_frr_enabled = value; is_frr_enabled.value_namespace = name_space; is_frr_enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "is-node-protected") { is_node_protected = value; is_node_protected.value_namespace = name_space; is_node_protected.value_namespace_prefix = name_space_prefix; } if(value_path == "is-bandwidth-protect") { is_bandwidth_protect = value; is_bandwidth_protect.value_namespace = name_space; is_bandwidth_protect.value_namespace_prefix = name_space_prefix; } if(value_path == "path-rro-enabled") { path_rro_enabled = value; path_rro_enabled.value_namespace = name_space; path_rro_enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "weight") { weight = value; weight.value_namespace = name_space; weight.value_namespace_prefix = name_space_prefix; } if(value_path == "reverse-weight") { reverse_weight = value; reverse_weight.value_namespace = name_space; reverse_weight.value_namespace_prefix = name_space_prefix; } if(value_path == "uptime") { uptime = value; uptime.value_namespace = name_space; uptime.value_namespace_prefix = name_space_prefix; } if(value_path == "egress-interface") { egress_interface = value; egress_interface.value_namespace = name_space; egress_interface.value_namespace_prefix = name_space_prefix; } if(value_path == "egress-interface-state") { egress_interface_state = value; egress_interface_state.value_namespace = name_space; egress_interface_state.value_namespace_prefix = name_space_prefix; } if(value_path == "egress-interface-brief") { egress_interface_brief = value; egress_interface_brief.value_namespace = name_space; egress_interface_brief.value_namespace_prefix = name_space_prefix; } if(value_path == "ingress-interface") { ingress_interface = value; ingress_interface.value_namespace = name_space; ingress_interface.value_namespace_prefix = name_space_prefix; } if(value_path == "ingress-interface-state") { ingress_interface_state = value; ingress_interface_state.value_namespace = name_space; ingress_interface_state.value_namespace_prefix = name_space_prefix; } if(value_path == "ingress-interface-brief") { ingress_interface_brief = value; ingress_interface_brief.value_namespace = name_space; ingress_interface_brief.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-local-label") { s2l_local_label = value; s2l_local_label.value_namespace = name_space; s2l_local_label.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-out-label") { s2l_out_label = value; s2l_out_label.value_namespace = name_space; s2l_out_label.value_namespace_prefix = name_space_prefix; } if(value_path == "outbound-frr-state") { outbound_frr_state = value; outbound_frr_state.value_namespace = name_space; outbound_frr_state.value_namespace_prefix = name_space_prefix; } if(value_path == "frr-out-tunnel-interface") { frr_out_tunnel_interface = value; frr_out_tunnel_interface.value_namespace = name_space; frr_out_tunnel_interface.value_namespace_prefix = name_space_prefix; } if(value_path == "role") { role = value; role.value_namespace = name_space; role.value_namespace_prefix = name_space_prefix; } if(value_path == "signalling-status") { signalling_status = value; signalling_status.value_namespace = name_space; signalling_status.value_namespace_prefix = name_space_prefix; } if(value_path == "local-router-id") { local_router_id = value; local_router_id.value_namespace = name_space; local_router_id.value_namespace_prefix = name_space_prefix; } if(value_path == "upstream-router-id") { upstream_router_id = value; upstream_router_id.value_namespace = name_space; upstream_router_id.value_namespace_prefix = name_space_prefix; } if(value_path == "downstream-router-id") { downstream_router_id = value; downstream_router_id.value_namespace = name_space; downstream_router_id.value_namespace_prefix = name_space_prefix; } if(value_path == "next-hop-address") { next_hop_address = value; next_hop_address.value_namespace = name_space; next_hop_address.value_namespace_prefix = name_space_prefix; } if(value_path == "next-next-hop-address") { next_next_hop_address = value; next_next_hop_address.value_namespace = name_space; next_next_hop_address.value_namespace_prefix = name_space_prefix; } if(value_path == "previous-hop-address") { previous_hop_address = value; previous_hop_address.value_namespace = name_space; previous_hop_address.value_namespace_prefix = name_space_prefix; } if(value_path == "incoming-address") { incoming_address = value; incoming_address.value_namespace = name_space; incoming_address.value_namespace_prefix = name_space_prefix; } if(value_path == "backup-tunnel-interface") { backup_tunnel_interface = value; backup_tunnel_interface.value_namespace = name_space; backup_tunnel_interface.value_namespace_prefix = name_space_prefix; } if(value_path == "node-hop-count") { node_hop_count = value; node_hop_count.value_namespace = name_space; node_hop_count.value_namespace_prefix = name_space_prefix; } if(value_path == "is-optical") { is_optical = value; is_optical.value_namespace = name_space; is_optical.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-reverse-ero-obj-present") { s2l_reverse_ero_obj_present = value; s2l_reverse_ero_obj_present.value_namespace = name_space; s2l_reverse_ero_obj_present.value_namespace_prefix = name_space_prefix; } if(value_path == "reverse-lsp-present") { reverse_lsp_present = value; reverse_lsp_present.value_namespace = name_space; reverse_lsp_present.value_namespace_prefix = name_space_prefix; } if(value_path == "reverse-lsp-connected") { reverse_lsp_connected = value; reverse_lsp_connected.value_namespace = name_space; reverse_lsp_connected.value_namespace_prefix = name_space_prefix; } if(value_path == "reverse-lsp-name") { reverse_lsp_name = value; reverse_lsp_name.value_namespace = name_space; reverse_lsp_name.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-reverse-tspec-obj-present") { s2l_reverse_tspec_obj_present = value; s2l_reverse_tspec_obj_present.value_namespace = name_space; s2l_reverse_tspec_obj_present.value_namespace_prefix = name_space_prefix; } if(value_path == "path-using-strict-spf") { path_using_strict_spf = value; path_using_strict_spf.value_namespace = name_space; path_using_strict_spf.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "pcalc-area") { pcalc_area.yfilter = yfilter; } if(value_path == "is-expanded-ero") { is_expanded_ero.yfilter = yfilter; } if(value_path == "path-reeval-query-mid") { path_reeval_query_mid.yfilter = yfilter; } if(value_path == "time-since-last-query-received-mid") { time_since_last_query_received_mid.yfilter = yfilter; } if(value_path == "time-since-last-preferred-path-exists-send-mid") { time_since_last_preferred_path_exists_send_mid.yfilter = yfilter; } if(value_path == "time-since-last-preferred-tree-exists-send-mid") { time_since_last_preferred_tree_exists_send_mid.yfilter = yfilter; } if(value_path == "expanded-ero-area-id") { expanded_ero_area_id.yfilter = yfilter; } if(value_path == "expanded-ero-affinity-bits") { expanded_ero_affinity_bits.yfilter = yfilter; } if(value_path == "expanded-ero-affinity-mask") { expanded_ero_affinity_mask.yfilter = yfilter; } if(value_path == "expanded-ero-metric-type") { expanded_ero_metric_type.yfilter = yfilter; } if(value_path == "expanded-ero-metric") { expanded_ero_metric.yfilter = yfilter; } if(value_path == "abr-auto-discovered") { abr_auto_discovered.yfilter = yfilter; } if(value_path == "is-frr-enabled") { is_frr_enabled.yfilter = yfilter; } if(value_path == "is-node-protected") { is_node_protected.yfilter = yfilter; } if(value_path == "is-bandwidth-protect") { is_bandwidth_protect.yfilter = yfilter; } if(value_path == "path-rro-enabled") { path_rro_enabled.yfilter = yfilter; } if(value_path == "weight") { weight.yfilter = yfilter; } if(value_path == "reverse-weight") { reverse_weight.yfilter = yfilter; } if(value_path == "uptime") { uptime.yfilter = yfilter; } if(value_path == "egress-interface") { egress_interface.yfilter = yfilter; } if(value_path == "egress-interface-state") { egress_interface_state.yfilter = yfilter; } if(value_path == "egress-interface-brief") { egress_interface_brief.yfilter = yfilter; } if(value_path == "ingress-interface") { ingress_interface.yfilter = yfilter; } if(value_path == "ingress-interface-state") { ingress_interface_state.yfilter = yfilter; } if(value_path == "ingress-interface-brief") { ingress_interface_brief.yfilter = yfilter; } if(value_path == "s2l-local-label") { s2l_local_label.yfilter = yfilter; } if(value_path == "s2l-out-label") { s2l_out_label.yfilter = yfilter; } if(value_path == "outbound-frr-state") { outbound_frr_state.yfilter = yfilter; } if(value_path == "frr-out-tunnel-interface") { frr_out_tunnel_interface.yfilter = yfilter; } if(value_path == "role") { role.yfilter = yfilter; } if(value_path == "signalling-status") { signalling_status.yfilter = yfilter; } if(value_path == "local-router-id") { local_router_id.yfilter = yfilter; } if(value_path == "upstream-router-id") { upstream_router_id.yfilter = yfilter; } if(value_path == "downstream-router-id") { downstream_router_id.yfilter = yfilter; } if(value_path == "next-hop-address") { next_hop_address.yfilter = yfilter; } if(value_path == "next-next-hop-address") { next_next_hop_address.yfilter = yfilter; } if(value_path == "previous-hop-address") { previous_hop_address.yfilter = yfilter; } if(value_path == "incoming-address") { incoming_address.yfilter = yfilter; } if(value_path == "backup-tunnel-interface") { backup_tunnel_interface.yfilter = yfilter; } if(value_path == "node-hop-count") { node_hop_count.yfilter = yfilter; } if(value_path == "is-optical") { is_optical.yfilter = yfilter; } if(value_path == "s2l-reverse-ero-obj-present") { s2l_reverse_ero_obj_present.yfilter = yfilter; } if(value_path == "reverse-lsp-present") { reverse_lsp_present.yfilter = yfilter; } if(value_path == "reverse-lsp-connected") { reverse_lsp_connected.yfilter = yfilter; } if(value_path == "reverse-lsp-name") { reverse_lsp_name.yfilter = yfilter; } if(value_path == "s2l-reverse-tspec-obj-present") { s2l_reverse_tspec_obj_present.yfilter = yfilter; } if(value_path == "path-using-strict-spf") { path_using_strict_spf.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::has_leaf_or_child_of_name(const std::string & name) const { if(name == "s2l-fec" || name == "active-path-option" || name == "out-xro" || name == "in-xro" || name == "tspec" || name == "generic-tspec" || name == "fspec" || name == "generic-fspec" || name == "next-hop-address-generic" || name == "previous-hop-address-generic" || name == "incoming-address-generic" || name == "s2l-convergence" || name == "soft-preemption" || name == "gmpls-labels" || name == "otn-s2l" || name == "head-end-bfd-info" || name == "tail-end-bfd-info" || name == "srlg-collection" || name == "association" || name == "protection" || name == "reverse-lsp-fec" || name == "reverse-tspec" || name == "flex-info" || name == "lsp-wrap-info" || name == "diversity-info" || name == "accumulated-path-metrics" || name == "accumulated-reverse-path-metrics" || name == "s2l-reverse-lsp-sub-obj" || name == "shared-risk-link-group" || name == "out-ero" || name == "in-ero" || name == "path-rro" || name == "resv-rro" || name == "path-affinity-array" || name == "reverse-ero-in" || name == "s2l-segment-routing-path" || name == "pcalc-area" || name == "is-expanded-ero" || name == "path-reeval-query-mid" || name == "time-since-last-query-received-mid" || name == "time-since-last-preferred-path-exists-send-mid" || name == "time-since-last-preferred-tree-exists-send-mid" || name == "expanded-ero-area-id" || name == "expanded-ero-affinity-bits" || name == "expanded-ero-affinity-mask" || name == "expanded-ero-metric-type" || name == "expanded-ero-metric" || name == "abr-auto-discovered" || name == "is-frr-enabled" || name == "is-node-protected" || name == "is-bandwidth-protect" || name == "path-rro-enabled" || name == "weight" || name == "reverse-weight" || name == "uptime" || name == "egress-interface" || name == "egress-interface-state" || name == "egress-interface-brief" || name == "ingress-interface" || name == "ingress-interface-state" || name == "ingress-interface-brief" || name == "s2l-local-label" || name == "s2l-out-label" || name == "outbound-frr-state" || name == "frr-out-tunnel-interface" || name == "role" || name == "signalling-status" || name == "local-router-id" || name == "upstream-router-id" || name == "downstream-router-id" || name == "next-hop-address" || name == "next-next-hop-address" || name == "previous-hop-address" || name == "incoming-address" || name == "backup-tunnel-interface" || name == "node-hop-count" || name == "is-optical" || name == "s2l-reverse-ero-obj-present" || name == "reverse-lsp-present" || name == "reverse-lsp-connected" || name == "reverse-lsp-name" || name == "s2l-reverse-tspec-obj-present" || name == "path-using-strict-spf") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::S2lFec() : s2l_fec_subgroup_id{YType::uint16, "s2l-fec-subgroup-id"}, s2l_fec_lsp_id{YType::uint16, "s2l-fec-lsp-id"}, s2l_fec_tunnel_id{YType::uint16, "s2l-fec-tunnel-id"}, s2l_fec_extended_tunnel_id{YType::str, "s2l-fec-extended-tunnel-id"}, s2l_fec_source{YType::str, "s2l-fec-source"}, s2l_fec_dest{YType::str, "s2l-fec-dest"}, s2l_fec_p2mp_id{YType::uint32, "s2l-fec-p2mp-id"}, s2l_fec_subgroup_originator{YType::str, "s2l-fec-subgroup-originator"}, s2l_fec_ctype{YType::enumeration, "s2l-fec-ctype"}, s2l_fec_vrf{YType::str, "s2l-fec-vrf"} { yang_name = "s2l-fec"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::~S2lFec() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::has_data() const { if (is_presence_container) return true; return s2l_fec_subgroup_id.is_set || s2l_fec_lsp_id.is_set || s2l_fec_tunnel_id.is_set || s2l_fec_extended_tunnel_id.is_set || s2l_fec_source.is_set || s2l_fec_dest.is_set || s2l_fec_p2mp_id.is_set || s2l_fec_subgroup_originator.is_set || s2l_fec_ctype.is_set || s2l_fec_vrf.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::has_operation() const { return is_set(yfilter) || ydk::is_set(s2l_fec_subgroup_id.yfilter) || ydk::is_set(s2l_fec_lsp_id.yfilter) || ydk::is_set(s2l_fec_tunnel_id.yfilter) || ydk::is_set(s2l_fec_extended_tunnel_id.yfilter) || ydk::is_set(s2l_fec_source.yfilter) || ydk::is_set(s2l_fec_dest.yfilter) || ydk::is_set(s2l_fec_p2mp_id.yfilter) || ydk::is_set(s2l_fec_subgroup_originator.yfilter) || ydk::is_set(s2l_fec_ctype.yfilter) || ydk::is_set(s2l_fec_vrf.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "s2l-fec"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (s2l_fec_subgroup_id.is_set || is_set(s2l_fec_subgroup_id.yfilter)) leaf_name_data.push_back(s2l_fec_subgroup_id.get_name_leafdata()); if (s2l_fec_lsp_id.is_set || is_set(s2l_fec_lsp_id.yfilter)) leaf_name_data.push_back(s2l_fec_lsp_id.get_name_leafdata()); if (s2l_fec_tunnel_id.is_set || is_set(s2l_fec_tunnel_id.yfilter)) leaf_name_data.push_back(s2l_fec_tunnel_id.get_name_leafdata()); if (s2l_fec_extended_tunnel_id.is_set || is_set(s2l_fec_extended_tunnel_id.yfilter)) leaf_name_data.push_back(s2l_fec_extended_tunnel_id.get_name_leafdata()); if (s2l_fec_source.is_set || is_set(s2l_fec_source.yfilter)) leaf_name_data.push_back(s2l_fec_source.get_name_leafdata()); if (s2l_fec_dest.is_set || is_set(s2l_fec_dest.yfilter)) leaf_name_data.push_back(s2l_fec_dest.get_name_leafdata()); if (s2l_fec_p2mp_id.is_set || is_set(s2l_fec_p2mp_id.yfilter)) leaf_name_data.push_back(s2l_fec_p2mp_id.get_name_leafdata()); if (s2l_fec_subgroup_originator.is_set || is_set(s2l_fec_subgroup_originator.yfilter)) leaf_name_data.push_back(s2l_fec_subgroup_originator.get_name_leafdata()); if (s2l_fec_ctype.is_set || is_set(s2l_fec_ctype.yfilter)) leaf_name_data.push_back(s2l_fec_ctype.get_name_leafdata()); if (s2l_fec_vrf.is_set || is_set(s2l_fec_vrf.yfilter)) leaf_name_data.push_back(s2l_fec_vrf.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::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 == "s2l-fec-subgroup-id") { s2l_fec_subgroup_id = value; s2l_fec_subgroup_id.value_namespace = name_space; s2l_fec_subgroup_id.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-fec-lsp-id") { s2l_fec_lsp_id = value; s2l_fec_lsp_id.value_namespace = name_space; s2l_fec_lsp_id.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-fec-tunnel-id") { s2l_fec_tunnel_id = value; s2l_fec_tunnel_id.value_namespace = name_space; s2l_fec_tunnel_id.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-fec-extended-tunnel-id") { s2l_fec_extended_tunnel_id = value; s2l_fec_extended_tunnel_id.value_namespace = name_space; s2l_fec_extended_tunnel_id.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-fec-source") { s2l_fec_source = value; s2l_fec_source.value_namespace = name_space; s2l_fec_source.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-fec-dest") { s2l_fec_dest = value; s2l_fec_dest.value_namespace = name_space; s2l_fec_dest.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-fec-p2mp-id") { s2l_fec_p2mp_id = value; s2l_fec_p2mp_id.value_namespace = name_space; s2l_fec_p2mp_id.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-fec-subgroup-originator") { s2l_fec_subgroup_originator = value; s2l_fec_subgroup_originator.value_namespace = name_space; s2l_fec_subgroup_originator.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-fec-ctype") { s2l_fec_ctype = value; s2l_fec_ctype.value_namespace = name_space; s2l_fec_ctype.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-fec-vrf") { s2l_fec_vrf = value; s2l_fec_vrf.value_namespace = name_space; s2l_fec_vrf.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "s2l-fec-subgroup-id") { s2l_fec_subgroup_id.yfilter = yfilter; } if(value_path == "s2l-fec-lsp-id") { s2l_fec_lsp_id.yfilter = yfilter; } if(value_path == "s2l-fec-tunnel-id") { s2l_fec_tunnel_id.yfilter = yfilter; } if(value_path == "s2l-fec-extended-tunnel-id") { s2l_fec_extended_tunnel_id.yfilter = yfilter; } if(value_path == "s2l-fec-source") { s2l_fec_source.yfilter = yfilter; } if(value_path == "s2l-fec-dest") { s2l_fec_dest.yfilter = yfilter; } if(value_path == "s2l-fec-p2mp-id") { s2l_fec_p2mp_id.yfilter = yfilter; } if(value_path == "s2l-fec-subgroup-originator") { s2l_fec_subgroup_originator.yfilter = yfilter; } if(value_path == "s2l-fec-ctype") { s2l_fec_ctype.yfilter = yfilter; } if(value_path == "s2l-fec-vrf") { s2l_fec_vrf.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::S2lFec::has_leaf_or_child_of_name(const std::string & name) const { if(name == "s2l-fec-subgroup-id" || name == "s2l-fec-lsp-id" || name == "s2l-fec-tunnel-id" || name == "s2l-fec-extended-tunnel-id" || name == "s2l-fec-source" || name == "s2l-fec-dest" || name == "s2l-fec-p2mp-id" || name == "s2l-fec-subgroup-originator" || name == "s2l-fec-ctype" || name == "s2l-fec-vrf") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::ActivePathOption() : option_index_is_valid{YType::boolean, "option-index-is-valid"}, option_index{YType::uint32, "option-index"}, path_option_name{YType::str, "path-option-name"}, path_option_type{YType::enumeration, "path-option-type"}, explicit_path_name{YType::str, "explicit-path-name"}, explicit_path_id{YType::uint16, "explicit-path-id"}, holddown_duration{YType::uint16, "holddown-duration"}, pce_address{YType::str, "pce-address"}, path_option_area_id{YType::str, "path-option-area-id"}, is_strict_explicit_path{YType::boolean, "is-strict-explicit-path"}, is_helddown{YType::boolean, "is-helddown"}, is_lockdown{YType::boolean, "is-lockdown"}, is_verbatim{YType::boolean, "is-verbatim"}, is_disabled{YType::boolean, "is-disabled"}, has_attribute_set{YType::boolean, "has-attribute-set"}, attribute_set_found{YType::boolean, "attribute-set-found"}, has_xro_attribute_set{YType::boolean, "has-xro-attribute-set"}, xro_attribute_set_found{YType::boolean, "xro-attribute-set-found"}, is_segment_routing{YType::boolean, "is-segment-routing"}, protected_by_path_option_index{YType::uint32, "protected-by-path-option-index"}, restored_from_path_option_index{YType::uint32, "restored-from-path-option-index"} , attribute_set(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet>()) , xro_attribute_set(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet>()) , path_calculation_error(this, {}) , remerge_error(this, {}) , signalling_error(this, {}) { attribute_set->parent = this; xro_attribute_set->parent = this; yang_name = "active-path-option"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::~ActivePathOption() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<path_calculation_error.len(); index++) { if(path_calculation_error[index]->has_data()) return true; } for (std::size_t index=0; index<remerge_error.len(); index++) { if(remerge_error[index]->has_data()) return true; } for (std::size_t index=0; index<signalling_error.len(); index++) { if(signalling_error[index]->has_data()) return true; } return option_index_is_valid.is_set || option_index.is_set || path_option_name.is_set || path_option_type.is_set || explicit_path_name.is_set || explicit_path_id.is_set || holddown_duration.is_set || pce_address.is_set || path_option_area_id.is_set || is_strict_explicit_path.is_set || is_helddown.is_set || is_lockdown.is_set || is_verbatim.is_set || is_disabled.is_set || has_attribute_set.is_set || attribute_set_found.is_set || has_xro_attribute_set.is_set || xro_attribute_set_found.is_set || is_segment_routing.is_set || protected_by_path_option_index.is_set || restored_from_path_option_index.is_set || (attribute_set != nullptr && attribute_set->has_data()) || (xro_attribute_set != nullptr && xro_attribute_set->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::has_operation() const { for (std::size_t index=0; index<path_calculation_error.len(); index++) { if(path_calculation_error[index]->has_operation()) return true; } for (std::size_t index=0; index<remerge_error.len(); index++) { if(remerge_error[index]->has_operation()) return true; } for (std::size_t index=0; index<signalling_error.len(); index++) { if(signalling_error[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(option_index_is_valid.yfilter) || ydk::is_set(option_index.yfilter) || ydk::is_set(path_option_name.yfilter) || ydk::is_set(path_option_type.yfilter) || ydk::is_set(explicit_path_name.yfilter) || ydk::is_set(explicit_path_id.yfilter) || ydk::is_set(holddown_duration.yfilter) || ydk::is_set(pce_address.yfilter) || ydk::is_set(path_option_area_id.yfilter) || ydk::is_set(is_strict_explicit_path.yfilter) || ydk::is_set(is_helddown.yfilter) || ydk::is_set(is_lockdown.yfilter) || ydk::is_set(is_verbatim.yfilter) || ydk::is_set(is_disabled.yfilter) || ydk::is_set(has_attribute_set.yfilter) || ydk::is_set(attribute_set_found.yfilter) || ydk::is_set(has_xro_attribute_set.yfilter) || ydk::is_set(xro_attribute_set_found.yfilter) || ydk::is_set(is_segment_routing.yfilter) || ydk::is_set(protected_by_path_option_index.yfilter) || ydk::is_set(restored_from_path_option_index.yfilter) || (attribute_set != nullptr && attribute_set->has_operation()) || (xro_attribute_set != nullptr && xro_attribute_set->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "active-path-option"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (option_index_is_valid.is_set || is_set(option_index_is_valid.yfilter)) leaf_name_data.push_back(option_index_is_valid.get_name_leafdata()); if (option_index.is_set || is_set(option_index.yfilter)) leaf_name_data.push_back(option_index.get_name_leafdata()); if (path_option_name.is_set || is_set(path_option_name.yfilter)) leaf_name_data.push_back(path_option_name.get_name_leafdata()); if (path_option_type.is_set || is_set(path_option_type.yfilter)) leaf_name_data.push_back(path_option_type.get_name_leafdata()); if (explicit_path_name.is_set || is_set(explicit_path_name.yfilter)) leaf_name_data.push_back(explicit_path_name.get_name_leafdata()); if (explicit_path_id.is_set || is_set(explicit_path_id.yfilter)) leaf_name_data.push_back(explicit_path_id.get_name_leafdata()); if (holddown_duration.is_set || is_set(holddown_duration.yfilter)) leaf_name_data.push_back(holddown_duration.get_name_leafdata()); if (pce_address.is_set || is_set(pce_address.yfilter)) leaf_name_data.push_back(pce_address.get_name_leafdata()); if (path_option_area_id.is_set || is_set(path_option_area_id.yfilter)) leaf_name_data.push_back(path_option_area_id.get_name_leafdata()); if (is_strict_explicit_path.is_set || is_set(is_strict_explicit_path.yfilter)) leaf_name_data.push_back(is_strict_explicit_path.get_name_leafdata()); if (is_helddown.is_set || is_set(is_helddown.yfilter)) leaf_name_data.push_back(is_helddown.get_name_leafdata()); if (is_lockdown.is_set || is_set(is_lockdown.yfilter)) leaf_name_data.push_back(is_lockdown.get_name_leafdata()); if (is_verbatim.is_set || is_set(is_verbatim.yfilter)) leaf_name_data.push_back(is_verbatim.get_name_leafdata()); if (is_disabled.is_set || is_set(is_disabled.yfilter)) leaf_name_data.push_back(is_disabled.get_name_leafdata()); if (has_attribute_set.is_set || is_set(has_attribute_set.yfilter)) leaf_name_data.push_back(has_attribute_set.get_name_leafdata()); if (attribute_set_found.is_set || is_set(attribute_set_found.yfilter)) leaf_name_data.push_back(attribute_set_found.get_name_leafdata()); if (has_xro_attribute_set.is_set || is_set(has_xro_attribute_set.yfilter)) leaf_name_data.push_back(has_xro_attribute_set.get_name_leafdata()); if (xro_attribute_set_found.is_set || is_set(xro_attribute_set_found.yfilter)) leaf_name_data.push_back(xro_attribute_set_found.get_name_leafdata()); if (is_segment_routing.is_set || is_set(is_segment_routing.yfilter)) leaf_name_data.push_back(is_segment_routing.get_name_leafdata()); if (protected_by_path_option_index.is_set || is_set(protected_by_path_option_index.yfilter)) leaf_name_data.push_back(protected_by_path_option_index.get_name_leafdata()); if (restored_from_path_option_index.is_set || is_set(restored_from_path_option_index.yfilter)) leaf_name_data.push_back(restored_from_path_option_index.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "attribute-set") { if(attribute_set == nullptr) { attribute_set = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet>(); } return attribute_set; } if(child_yang_name == "xro-attribute-set") { if(xro_attribute_set == nullptr) { xro_attribute_set = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet>(); } return xro_attribute_set; } if(child_yang_name == "path-calculation-error") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError>(); ent_->parent = this; path_calculation_error.append(ent_); return ent_; } if(child_yang_name == "remerge-error") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError>(); ent_->parent = this; remerge_error.append(ent_); return ent_; } if(child_yang_name == "signalling-error") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError>(); ent_->parent = this; signalling_error.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(attribute_set != nullptr) { _children["attribute-set"] = attribute_set; } if(xro_attribute_set != nullptr) { _children["xro-attribute-set"] = xro_attribute_set; } count_ = 0; for (auto ent_ : path_calculation_error.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_ : remerge_error.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_ : signalling_error.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::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 == "option-index-is-valid") { option_index_is_valid = value; option_index_is_valid.value_namespace = name_space; option_index_is_valid.value_namespace_prefix = name_space_prefix; } if(value_path == "option-index") { option_index = value; option_index.value_namespace = name_space; option_index.value_namespace_prefix = name_space_prefix; } if(value_path == "path-option-name") { path_option_name = value; path_option_name.value_namespace = name_space; path_option_name.value_namespace_prefix = name_space_prefix; } if(value_path == "path-option-type") { path_option_type = value; path_option_type.value_namespace = name_space; path_option_type.value_namespace_prefix = name_space_prefix; } if(value_path == "explicit-path-name") { explicit_path_name = value; explicit_path_name.value_namespace = name_space; explicit_path_name.value_namespace_prefix = name_space_prefix; } if(value_path == "explicit-path-id") { explicit_path_id = value; explicit_path_id.value_namespace = name_space; explicit_path_id.value_namespace_prefix = name_space_prefix; } if(value_path == "holddown-duration") { holddown_duration = value; holddown_duration.value_namespace = name_space; holddown_duration.value_namespace_prefix = name_space_prefix; } if(value_path == "pce-address") { pce_address = value; pce_address.value_namespace = name_space; pce_address.value_namespace_prefix = name_space_prefix; } if(value_path == "path-option-area-id") { path_option_area_id = value; path_option_area_id.value_namespace = name_space; path_option_area_id.value_namespace_prefix = name_space_prefix; } if(value_path == "is-strict-explicit-path") { is_strict_explicit_path = value; is_strict_explicit_path.value_namespace = name_space; is_strict_explicit_path.value_namespace_prefix = name_space_prefix; } if(value_path == "is-helddown") { is_helddown = value; is_helddown.value_namespace = name_space; is_helddown.value_namespace_prefix = name_space_prefix; } if(value_path == "is-lockdown") { is_lockdown = value; is_lockdown.value_namespace = name_space; is_lockdown.value_namespace_prefix = name_space_prefix; } if(value_path == "is-verbatim") { is_verbatim = value; is_verbatim.value_namespace = name_space; is_verbatim.value_namespace_prefix = name_space_prefix; } if(value_path == "is-disabled") { is_disabled = value; is_disabled.value_namespace = name_space; is_disabled.value_namespace_prefix = name_space_prefix; } if(value_path == "has-attribute-set") { has_attribute_set = value; has_attribute_set.value_namespace = name_space; has_attribute_set.value_namespace_prefix = name_space_prefix; } if(value_path == "attribute-set-found") { attribute_set_found = value; attribute_set_found.value_namespace = name_space; attribute_set_found.value_namespace_prefix = name_space_prefix; } if(value_path == "has-xro-attribute-set") { has_xro_attribute_set = value; has_xro_attribute_set.value_namespace = name_space; has_xro_attribute_set.value_namespace_prefix = name_space_prefix; } if(value_path == "xro-attribute-set-found") { xro_attribute_set_found = value; xro_attribute_set_found.value_namespace = name_space; xro_attribute_set_found.value_namespace_prefix = name_space_prefix; } if(value_path == "is-segment-routing") { is_segment_routing = value; is_segment_routing.value_namespace = name_space; is_segment_routing.value_namespace_prefix = name_space_prefix; } if(value_path == "protected-by-path-option-index") { protected_by_path_option_index = value; protected_by_path_option_index.value_namespace = name_space; protected_by_path_option_index.value_namespace_prefix = name_space_prefix; } if(value_path == "restored-from-path-option-index") { restored_from_path_option_index = value; restored_from_path_option_index.value_namespace = name_space; restored_from_path_option_index.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "option-index-is-valid") { option_index_is_valid.yfilter = yfilter; } if(value_path == "option-index") { option_index.yfilter = yfilter; } if(value_path == "path-option-name") { path_option_name.yfilter = yfilter; } if(value_path == "path-option-type") { path_option_type.yfilter = yfilter; } if(value_path == "explicit-path-name") { explicit_path_name.yfilter = yfilter; } if(value_path == "explicit-path-id") { explicit_path_id.yfilter = yfilter; } if(value_path == "holddown-duration") { holddown_duration.yfilter = yfilter; } if(value_path == "pce-address") { pce_address.yfilter = yfilter; } if(value_path == "path-option-area-id") { path_option_area_id.yfilter = yfilter; } if(value_path == "is-strict-explicit-path") { is_strict_explicit_path.yfilter = yfilter; } if(value_path == "is-helddown") { is_helddown.yfilter = yfilter; } if(value_path == "is-lockdown") { is_lockdown.yfilter = yfilter; } if(value_path == "is-verbatim") { is_verbatim.yfilter = yfilter; } if(value_path == "is-disabled") { is_disabled.yfilter = yfilter; } if(value_path == "has-attribute-set") { has_attribute_set.yfilter = yfilter; } if(value_path == "attribute-set-found") { attribute_set_found.yfilter = yfilter; } if(value_path == "has-xro-attribute-set") { has_xro_attribute_set.yfilter = yfilter; } if(value_path == "xro-attribute-set-found") { xro_attribute_set_found.yfilter = yfilter; } if(value_path == "is-segment-routing") { is_segment_routing.yfilter = yfilter; } if(value_path == "protected-by-path-option-index") { protected_by_path_option_index.yfilter = yfilter; } if(value_path == "restored-from-path-option-index") { restored_from_path_option_index.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::has_leaf_or_child_of_name(const std::string & name) const { if(name == "attribute-set" || name == "xro-attribute-set" || name == "path-calculation-error" || name == "remerge-error" || name == "signalling-error" || name == "option-index-is-valid" || name == "option-index" || name == "path-option-name" || name == "path-option-type" || name == "explicit-path-name" || name == "explicit-path-id" || name == "holddown-duration" || name == "pce-address" || name == "path-option-area-id" || name == "is-strict-explicit-path" || name == "is-helddown" || name == "is-lockdown" || name == "is-verbatim" || name == "is-disabled" || name == "has-attribute-set" || name == "attribute-set-found" || name == "has-xro-attribute-set" || name == "xro-attribute-set-found" || name == "is-segment-routing" || name == "protected-by-path-option-index" || name == "restored-from-path-option-index") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSet() : tunnel_attribute_set_name{YType::str, "tunnel-attribute-set-name"}, tunnel_attribute_set_name_crc32{YType::uint32, "tunnel-attribute-set-name-crc32"} , attribute_set_union(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion>()) { attribute_set_union->parent = this; yang_name = "attribute-set"; yang_parent_name = "active-path-option"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::~AttributeSet() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::has_data() const { if (is_presence_container) return true; return tunnel_attribute_set_name.is_set || tunnel_attribute_set_name_crc32.is_set || (attribute_set_union != nullptr && attribute_set_union->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::has_operation() const { return is_set(yfilter) || ydk::is_set(tunnel_attribute_set_name.yfilter) || ydk::is_set(tunnel_attribute_set_name_crc32.yfilter) || (attribute_set_union != nullptr && attribute_set_union->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (tunnel_attribute_set_name.is_set || is_set(tunnel_attribute_set_name.yfilter)) leaf_name_data.push_back(tunnel_attribute_set_name.get_name_leafdata()); if (tunnel_attribute_set_name_crc32.is_set || is_set(tunnel_attribute_set_name_crc32.yfilter)) leaf_name_data.push_back(tunnel_attribute_set_name_crc32.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "attribute-set-union") { if(attribute_set_union == nullptr) { attribute_set_union = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion>(); } return attribute_set_union; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(attribute_set_union != nullptr) { _children["attribute-set-union"] = attribute_set_union; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::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 == "tunnel-attribute-set-name") { tunnel_attribute_set_name = value; tunnel_attribute_set_name.value_namespace = name_space; tunnel_attribute_set_name.value_namespace_prefix = name_space_prefix; } if(value_path == "tunnel-attribute-set-name-crc32") { tunnel_attribute_set_name_crc32 = value; tunnel_attribute_set_name_crc32.value_namespace = name_space; tunnel_attribute_set_name_crc32.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "tunnel-attribute-set-name") { tunnel_attribute_set_name.yfilter = yfilter; } if(value_path == "tunnel-attribute-set-name-crc32") { tunnel_attribute_set_name_crc32.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::has_leaf_or_child_of_name(const std::string & name) const { if(name == "attribute-set-union" || name == "tunnel-attribute-set-name" || name == "tunnel-attribute-set-name-crc32") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetUnion() : tunnel_attribute_set_type{YType::enumeration, "tunnel-attribute-set-type"} , attribute_set_path_option(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption>()) , attribute_set_autobackup(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup>()) , attribute_set_automesh(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh>()) , attribute_set_xro(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro>()) , attribute_set_p2mpte(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte>()) , attribute_set_aps_pp(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp>()) , attribute_set_p2p_te(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe>()) { attribute_set_path_option->parent = this; attribute_set_autobackup->parent = this; attribute_set_automesh->parent = this; attribute_set_xro->parent = this; attribute_set_p2mpte->parent = this; attribute_set_aps_pp->parent = this; attribute_set_p2p_te->parent = this; yang_name = "attribute-set-union"; yang_parent_name = "attribute-set"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::~AttributeSetUnion() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::has_data() const { if (is_presence_container) return true; return tunnel_attribute_set_type.is_set || (attribute_set_path_option != nullptr && attribute_set_path_option->has_data()) || (attribute_set_autobackup != nullptr && attribute_set_autobackup->has_data()) || (attribute_set_automesh != nullptr && attribute_set_automesh->has_data()) || (attribute_set_xro != nullptr && attribute_set_xro->has_data()) || (attribute_set_p2mpte != nullptr && attribute_set_p2mpte->has_data()) || (attribute_set_aps_pp != nullptr && attribute_set_aps_pp->has_data()) || (attribute_set_p2p_te != nullptr && attribute_set_p2p_te->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::has_operation() const { return is_set(yfilter) || ydk::is_set(tunnel_attribute_set_type.yfilter) || (attribute_set_path_option != nullptr && attribute_set_path_option->has_operation()) || (attribute_set_autobackup != nullptr && attribute_set_autobackup->has_operation()) || (attribute_set_automesh != nullptr && attribute_set_automesh->has_operation()) || (attribute_set_xro != nullptr && attribute_set_xro->has_operation()) || (attribute_set_p2mpte != nullptr && attribute_set_p2mpte->has_operation()) || (attribute_set_aps_pp != nullptr && attribute_set_aps_pp->has_operation()) || (attribute_set_p2p_te != nullptr && attribute_set_p2p_te->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-union"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (tunnel_attribute_set_type.is_set || is_set(tunnel_attribute_set_type.yfilter)) leaf_name_data.push_back(tunnel_attribute_set_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "attribute-set-path-option") { if(attribute_set_path_option == nullptr) { attribute_set_path_option = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption>(); } return attribute_set_path_option; } if(child_yang_name == "attribute-set-autobackup") { if(attribute_set_autobackup == nullptr) { attribute_set_autobackup = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup>(); } return attribute_set_autobackup; } if(child_yang_name == "attribute-set-automesh") { if(attribute_set_automesh == nullptr) { attribute_set_automesh = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh>(); } return attribute_set_automesh; } if(child_yang_name == "attribute-set-xro") { if(attribute_set_xro == nullptr) { attribute_set_xro = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro>(); } return attribute_set_xro; } if(child_yang_name == "attribute-set-p2mpte") { if(attribute_set_p2mpte == nullptr) { attribute_set_p2mpte = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte>(); } return attribute_set_p2mpte; } if(child_yang_name == "attribute-set-aps-pp") { if(attribute_set_aps_pp == nullptr) { attribute_set_aps_pp = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp>(); } return attribute_set_aps_pp; } if(child_yang_name == "attribute-set-p2p-te") { if(attribute_set_p2p_te == nullptr) { attribute_set_p2p_te = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe>(); } return attribute_set_p2p_te; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(attribute_set_path_option != nullptr) { _children["attribute-set-path-option"] = attribute_set_path_option; } if(attribute_set_autobackup != nullptr) { _children["attribute-set-autobackup"] = attribute_set_autobackup; } if(attribute_set_automesh != nullptr) { _children["attribute-set-automesh"] = attribute_set_automesh; } if(attribute_set_xro != nullptr) { _children["attribute-set-xro"] = attribute_set_xro; } if(attribute_set_p2mpte != nullptr) { _children["attribute-set-p2mpte"] = attribute_set_p2mpte; } if(attribute_set_aps_pp != nullptr) { _children["attribute-set-aps-pp"] = attribute_set_aps_pp; } if(attribute_set_p2p_te != nullptr) { _children["attribute-set-p2p-te"] = attribute_set_p2p_te; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::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 == "tunnel-attribute-set-type") { tunnel_attribute_set_type = value; tunnel_attribute_set_type.value_namespace = name_space; tunnel_attribute_set_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "tunnel-attribute-set-type") { tunnel_attribute_set_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::has_leaf_or_child_of_name(const std::string & name) const { if(name == "attribute-set-path-option" || name == "attribute-set-autobackup" || name == "attribute-set-automesh" || name == "attribute-set-xro" || name == "attribute-set-p2mpte" || name == "attribute-set-aps-pp" || name == "attribute-set-p2p-te" || name == "tunnel-attribute-set-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::AttributeSetPathOption() : configured_bandwidth{YType::uint32, "configured-bandwidth"}, cost_limit{YType::uint32, "cost-limit"}, dste_class_type{YType::uint8, "dste-class-type"}, bandwidth_type{YType::enumeration, "bandwidth-type"}, is_bandwidth_configured{YType::boolean, "is-bandwidth-configured"}, is_cost_limit_configured{YType::boolean, "is-cost-limit-configured"}, is_affinity_configured{YType::boolean, "is-affinity-configured"}, generation{YType::uint32, "generation"}, path_invalidation_timeout{YType::uint32, "path-invalidation-timeout"}, path_invalidation_action{YType::uint32, "path-invalidation-action"}, is_path_invalidation_timeout_configured{YType::boolean, "is-path-invalidation-timeout-configured"}, is_path_invalidation_action_configured{YType::boolean, "is-path-invalidation-action-configured"}, exclude_list_name{YType::str, "exclude-list-name"}, is_exclude_list_name_configured{YType::boolean, "is-exclude-list-name-configured"}, is_pce_configured{YType::boolean, "is-pce-configured"}, is_pce_disj_source_configured{YType::boolean, "is-pce-disj-source-configured"}, is_pce_disj_type_configured{YType::boolean, "is-pce-disj-type-configured"}, is_pce_disj_group_id_configured{YType::boolean, "is-pce-disj-group-id-configured"}, pcedp_source_address{YType::uint32, "pcedp-source-address"}, pcedp_type{YType::enumeration, "pcedp-type"}, pcedp_group_id{YType::uint32, "pcedp-group-id"}, is_pceb_dj_source_configured{YType::boolean, "is-pceb-dj-source-configured"}, is_pcebd_group_id_configured{YType::boolean, "is-pcebd-group-id-configured"}, pcebd_source_address{YType::uint32, "pcebd-source-address"}, pcebd_group_id{YType::uint32, "pcebd-group-id"}, is_bfd_reverse_pat_configured{YType::boolean, "is-bfd-reverse-pat-configured"}, is_delay_limit_configured{YType::boolean, "is-delay-limit-configured"}, delay_limit{YType::uint32, "delay-limit"} , affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity>()) , bfd_reverse_path(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath>()) , tunnel_id(this, {}) , version_info(this, {}) { affinity->parent = this; bfd_reverse_path->parent = this; yang_name = "attribute-set-path-option"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::~AttributeSetPathOption() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_data()) return true; } for (std::size_t index=0; index<version_info.len(); index++) { if(version_info[index]->has_data()) return true; } return configured_bandwidth.is_set || cost_limit.is_set || dste_class_type.is_set || bandwidth_type.is_set || is_bandwidth_configured.is_set || is_cost_limit_configured.is_set || is_affinity_configured.is_set || generation.is_set || path_invalidation_timeout.is_set || path_invalidation_action.is_set || is_path_invalidation_timeout_configured.is_set || is_path_invalidation_action_configured.is_set || exclude_list_name.is_set || is_exclude_list_name_configured.is_set || is_pce_configured.is_set || is_pce_disj_source_configured.is_set || is_pce_disj_type_configured.is_set || is_pce_disj_group_id_configured.is_set || pcedp_source_address.is_set || pcedp_type.is_set || pcedp_group_id.is_set || is_pceb_dj_source_configured.is_set || is_pcebd_group_id_configured.is_set || pcebd_source_address.is_set || pcebd_group_id.is_set || is_bfd_reverse_pat_configured.is_set || is_delay_limit_configured.is_set || delay_limit.is_set || (affinity != nullptr && affinity->has_data()) || (bfd_reverse_path != nullptr && bfd_reverse_path->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::has_operation() const { for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_operation()) return true; } for (std::size_t index=0; index<version_info.len(); index++) { if(version_info[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(configured_bandwidth.yfilter) || ydk::is_set(cost_limit.yfilter) || ydk::is_set(dste_class_type.yfilter) || ydk::is_set(bandwidth_type.yfilter) || ydk::is_set(is_bandwidth_configured.yfilter) || ydk::is_set(is_cost_limit_configured.yfilter) || ydk::is_set(is_affinity_configured.yfilter) || ydk::is_set(generation.yfilter) || ydk::is_set(path_invalidation_timeout.yfilter) || ydk::is_set(path_invalidation_action.yfilter) || ydk::is_set(is_path_invalidation_timeout_configured.yfilter) || ydk::is_set(is_path_invalidation_action_configured.yfilter) || ydk::is_set(exclude_list_name.yfilter) || ydk::is_set(is_exclude_list_name_configured.yfilter) || ydk::is_set(is_pce_configured.yfilter) || ydk::is_set(is_pce_disj_source_configured.yfilter) || ydk::is_set(is_pce_disj_type_configured.yfilter) || ydk::is_set(is_pce_disj_group_id_configured.yfilter) || ydk::is_set(pcedp_source_address.yfilter) || ydk::is_set(pcedp_type.yfilter) || ydk::is_set(pcedp_group_id.yfilter) || ydk::is_set(is_pceb_dj_source_configured.yfilter) || ydk::is_set(is_pcebd_group_id_configured.yfilter) || ydk::is_set(pcebd_source_address.yfilter) || ydk::is_set(pcebd_group_id.yfilter) || ydk::is_set(is_bfd_reverse_pat_configured.yfilter) || ydk::is_set(is_delay_limit_configured.yfilter) || ydk::is_set(delay_limit.yfilter) || (affinity != nullptr && affinity->has_operation()) || (bfd_reverse_path != nullptr && bfd_reverse_path->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-path-option"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (configured_bandwidth.is_set || is_set(configured_bandwidth.yfilter)) leaf_name_data.push_back(configured_bandwidth.get_name_leafdata()); if (cost_limit.is_set || is_set(cost_limit.yfilter)) leaf_name_data.push_back(cost_limit.get_name_leafdata()); if (dste_class_type.is_set || is_set(dste_class_type.yfilter)) leaf_name_data.push_back(dste_class_type.get_name_leafdata()); if (bandwidth_type.is_set || is_set(bandwidth_type.yfilter)) leaf_name_data.push_back(bandwidth_type.get_name_leafdata()); if (is_bandwidth_configured.is_set || is_set(is_bandwidth_configured.yfilter)) leaf_name_data.push_back(is_bandwidth_configured.get_name_leafdata()); if (is_cost_limit_configured.is_set || is_set(is_cost_limit_configured.yfilter)) leaf_name_data.push_back(is_cost_limit_configured.get_name_leafdata()); if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata()); if (generation.is_set || is_set(generation.yfilter)) leaf_name_data.push_back(generation.get_name_leafdata()); if (path_invalidation_timeout.is_set || is_set(path_invalidation_timeout.yfilter)) leaf_name_data.push_back(path_invalidation_timeout.get_name_leafdata()); if (path_invalidation_action.is_set || is_set(path_invalidation_action.yfilter)) leaf_name_data.push_back(path_invalidation_action.get_name_leafdata()); if (is_path_invalidation_timeout_configured.is_set || is_set(is_path_invalidation_timeout_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_timeout_configured.get_name_leafdata()); if (is_path_invalidation_action_configured.is_set || is_set(is_path_invalidation_action_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_action_configured.get_name_leafdata()); if (exclude_list_name.is_set || is_set(exclude_list_name.yfilter)) leaf_name_data.push_back(exclude_list_name.get_name_leafdata()); if (is_exclude_list_name_configured.is_set || is_set(is_exclude_list_name_configured.yfilter)) leaf_name_data.push_back(is_exclude_list_name_configured.get_name_leafdata()); if (is_pce_configured.is_set || is_set(is_pce_configured.yfilter)) leaf_name_data.push_back(is_pce_configured.get_name_leafdata()); if (is_pce_disj_source_configured.is_set || is_set(is_pce_disj_source_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_source_configured.get_name_leafdata()); if (is_pce_disj_type_configured.is_set || is_set(is_pce_disj_type_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_type_configured.get_name_leafdata()); if (is_pce_disj_group_id_configured.is_set || is_set(is_pce_disj_group_id_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_group_id_configured.get_name_leafdata()); if (pcedp_source_address.is_set || is_set(pcedp_source_address.yfilter)) leaf_name_data.push_back(pcedp_source_address.get_name_leafdata()); if (pcedp_type.is_set || is_set(pcedp_type.yfilter)) leaf_name_data.push_back(pcedp_type.get_name_leafdata()); if (pcedp_group_id.is_set || is_set(pcedp_group_id.yfilter)) leaf_name_data.push_back(pcedp_group_id.get_name_leafdata()); if (is_pceb_dj_source_configured.is_set || is_set(is_pceb_dj_source_configured.yfilter)) leaf_name_data.push_back(is_pceb_dj_source_configured.get_name_leafdata()); if (is_pcebd_group_id_configured.is_set || is_set(is_pcebd_group_id_configured.yfilter)) leaf_name_data.push_back(is_pcebd_group_id_configured.get_name_leafdata()); if (pcebd_source_address.is_set || is_set(pcebd_source_address.yfilter)) leaf_name_data.push_back(pcebd_source_address.get_name_leafdata()); if (pcebd_group_id.is_set || is_set(pcebd_group_id.yfilter)) leaf_name_data.push_back(pcebd_group_id.get_name_leafdata()); if (is_bfd_reverse_pat_configured.is_set || is_set(is_bfd_reverse_pat_configured.yfilter)) leaf_name_data.push_back(is_bfd_reverse_pat_configured.get_name_leafdata()); if (is_delay_limit_configured.is_set || is_set(is_delay_limit_configured.yfilter)) leaf_name_data.push_back(is_delay_limit_configured.get_name_leafdata()); if (delay_limit.is_set || is_set(delay_limit.yfilter)) leaf_name_data.push_back(delay_limit.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "affinity") { if(affinity == nullptr) { affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity>(); } return affinity; } if(child_yang_name == "bfd-reverse-path") { if(bfd_reverse_path == nullptr) { bfd_reverse_path = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath>(); } return bfd_reverse_path; } if(child_yang_name == "tunnel-id") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId>(); ent_->parent = this; tunnel_id.append(ent_); return ent_; } if(child_yang_name == "version-info") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo>(); ent_->parent = this; version_info.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(affinity != nullptr) { _children["affinity"] = affinity; } if(bfd_reverse_path != nullptr) { _children["bfd-reverse-path"] = bfd_reverse_path; } count_ = 0; for (auto ent_ : tunnel_id.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_ : version_info.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::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 == "configured-bandwidth") { configured_bandwidth = value; configured_bandwidth.value_namespace = name_space; configured_bandwidth.value_namespace_prefix = name_space_prefix; } if(value_path == "cost-limit") { cost_limit = value; cost_limit.value_namespace = name_space; cost_limit.value_namespace_prefix = name_space_prefix; } if(value_path == "dste-class-type") { dste_class_type = value; dste_class_type.value_namespace = name_space; dste_class_type.value_namespace_prefix = name_space_prefix; } if(value_path == "bandwidth-type") { bandwidth_type = value; bandwidth_type.value_namespace = name_space; bandwidth_type.value_namespace_prefix = name_space_prefix; } if(value_path == "is-bandwidth-configured") { is_bandwidth_configured = value; is_bandwidth_configured.value_namespace = name_space; is_bandwidth_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-cost-limit-configured") { is_cost_limit_configured = value; is_cost_limit_configured.value_namespace = name_space; is_cost_limit_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-affinity-configured") { is_affinity_configured = value; is_affinity_configured.value_namespace = name_space; is_affinity_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "generation") { generation = value; generation.value_namespace = name_space; generation.value_namespace_prefix = name_space_prefix; } if(value_path == "path-invalidation-timeout") { path_invalidation_timeout = value; path_invalidation_timeout.value_namespace = name_space; path_invalidation_timeout.value_namespace_prefix = name_space_prefix; } if(value_path == "path-invalidation-action") { path_invalidation_action = value; path_invalidation_action.value_namespace = name_space; path_invalidation_action.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-invalidation-timeout-configured") { is_path_invalidation_timeout_configured = value; is_path_invalidation_timeout_configured.value_namespace = name_space; is_path_invalidation_timeout_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-invalidation-action-configured") { is_path_invalidation_action_configured = value; is_path_invalidation_action_configured.value_namespace = name_space; is_path_invalidation_action_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "exclude-list-name") { exclude_list_name = value; exclude_list_name.value_namespace = name_space; exclude_list_name.value_namespace_prefix = name_space_prefix; } if(value_path == "is-exclude-list-name-configured") { is_exclude_list_name_configured = value; is_exclude_list_name_configured.value_namespace = name_space; is_exclude_list_name_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-configured") { is_pce_configured = value; is_pce_configured.value_namespace = name_space; is_pce_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-disj-source-configured") { is_pce_disj_source_configured = value; is_pce_disj_source_configured.value_namespace = name_space; is_pce_disj_source_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-disj-type-configured") { is_pce_disj_type_configured = value; is_pce_disj_type_configured.value_namespace = name_space; is_pce_disj_type_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-disj-group-id-configured") { is_pce_disj_group_id_configured = value; is_pce_disj_group_id_configured.value_namespace = name_space; is_pce_disj_group_id_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "pcedp-source-address") { pcedp_source_address = value; pcedp_source_address.value_namespace = name_space; pcedp_source_address.value_namespace_prefix = name_space_prefix; } if(value_path == "pcedp-type") { pcedp_type = value; pcedp_type.value_namespace = name_space; pcedp_type.value_namespace_prefix = name_space_prefix; } if(value_path == "pcedp-group-id") { pcedp_group_id = value; pcedp_group_id.value_namespace = name_space; pcedp_group_id.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pceb-dj-source-configured") { is_pceb_dj_source_configured = value; is_pceb_dj_source_configured.value_namespace = name_space; is_pceb_dj_source_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pcebd-group-id-configured") { is_pcebd_group_id_configured = value; is_pcebd_group_id_configured.value_namespace = name_space; is_pcebd_group_id_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "pcebd-source-address") { pcebd_source_address = value; pcebd_source_address.value_namespace = name_space; pcebd_source_address.value_namespace_prefix = name_space_prefix; } if(value_path == "pcebd-group-id") { pcebd_group_id = value; pcebd_group_id.value_namespace = name_space; pcebd_group_id.value_namespace_prefix = name_space_prefix; } if(value_path == "is-bfd-reverse-pat-configured") { is_bfd_reverse_pat_configured = value; is_bfd_reverse_pat_configured.value_namespace = name_space; is_bfd_reverse_pat_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-delay-limit-configured") { is_delay_limit_configured = value; is_delay_limit_configured.value_namespace = name_space; is_delay_limit_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "delay-limit") { delay_limit = value; delay_limit.value_namespace = name_space; delay_limit.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "configured-bandwidth") { configured_bandwidth.yfilter = yfilter; } if(value_path == "cost-limit") { cost_limit.yfilter = yfilter; } if(value_path == "dste-class-type") { dste_class_type.yfilter = yfilter; } if(value_path == "bandwidth-type") { bandwidth_type.yfilter = yfilter; } if(value_path == "is-bandwidth-configured") { is_bandwidth_configured.yfilter = yfilter; } if(value_path == "is-cost-limit-configured") { is_cost_limit_configured.yfilter = yfilter; } if(value_path == "is-affinity-configured") { is_affinity_configured.yfilter = yfilter; } if(value_path == "generation") { generation.yfilter = yfilter; } if(value_path == "path-invalidation-timeout") { path_invalidation_timeout.yfilter = yfilter; } if(value_path == "path-invalidation-action") { path_invalidation_action.yfilter = yfilter; } if(value_path == "is-path-invalidation-timeout-configured") { is_path_invalidation_timeout_configured.yfilter = yfilter; } if(value_path == "is-path-invalidation-action-configured") { is_path_invalidation_action_configured.yfilter = yfilter; } if(value_path == "exclude-list-name") { exclude_list_name.yfilter = yfilter; } if(value_path == "is-exclude-list-name-configured") { is_exclude_list_name_configured.yfilter = yfilter; } if(value_path == "is-pce-configured") { is_pce_configured.yfilter = yfilter; } if(value_path == "is-pce-disj-source-configured") { is_pce_disj_source_configured.yfilter = yfilter; } if(value_path == "is-pce-disj-type-configured") { is_pce_disj_type_configured.yfilter = yfilter; } if(value_path == "is-pce-disj-group-id-configured") { is_pce_disj_group_id_configured.yfilter = yfilter; } if(value_path == "pcedp-source-address") { pcedp_source_address.yfilter = yfilter; } if(value_path == "pcedp-type") { pcedp_type.yfilter = yfilter; } if(value_path == "pcedp-group-id") { pcedp_group_id.yfilter = yfilter; } if(value_path == "is-pceb-dj-source-configured") { is_pceb_dj_source_configured.yfilter = yfilter; } if(value_path == "is-pcebd-group-id-configured") { is_pcebd_group_id_configured.yfilter = yfilter; } if(value_path == "pcebd-source-address") { pcebd_source_address.yfilter = yfilter; } if(value_path == "pcebd-group-id") { pcebd_group_id.yfilter = yfilter; } if(value_path == "is-bfd-reverse-pat-configured") { is_bfd_reverse_pat_configured.yfilter = yfilter; } if(value_path == "is-delay-limit-configured") { is_delay_limit_configured.yfilter = yfilter; } if(value_path == "delay-limit") { delay_limit.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::has_leaf_or_child_of_name(const std::string & name) const { if(name == "affinity" || name == "bfd-reverse-path" || name == "tunnel-id" || name == "version-info" || name == "configured-bandwidth" || name == "cost-limit" || name == "dste-class-type" || name == "bandwidth-type" || name == "is-bandwidth-configured" || name == "is-cost-limit-configured" || name == "is-affinity-configured" || name == "generation" || name == "path-invalidation-timeout" || name == "path-invalidation-action" || name == "is-path-invalidation-timeout-configured" || name == "is-path-invalidation-action-configured" || name == "exclude-list-name" || name == "is-exclude-list-name-configured" || name == "is-pce-configured" || name == "is-pce-disj-source-configured" || name == "is-pce-disj-type-configured" || name == "is-pce-disj-group-id-configured" || name == "pcedp-source-address" || name == "pcedp-type" || name == "pcedp-group-id" || name == "is-pceb-dj-source-configured" || name == "is-pcebd-group-id-configured" || name == "pcebd-source-address" || name == "pcebd-group-id" || name == "is-bfd-reverse-pat-configured" || name == "is-delay-limit-configured" || name == "delay-limit") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::Affinity() : affinity_bits{YType::uint32, "affinity-bits"}, affinity_mask{YType::uint32, "affinity-mask"} , named_affinity(this, {}) { yang_name = "affinity"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::~Affinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_data()) return true; } return affinity_bits.is_set || affinity_mask.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::has_operation() const { for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(affinity_bits.yfilter) || ydk::is_set(affinity_mask.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "affinity"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata()); if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "named-affinity") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity>(); ent_->parent = this; named_affinity.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : named_affinity.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::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 == "affinity-bits") { affinity_bits = value; affinity_bits.value_namespace = name_space; affinity_bits.value_namespace_prefix = name_space_prefix; } if(value_path == "affinity-mask") { affinity_mask = value; affinity_mask.value_namespace = name_space; affinity_mask.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "affinity-bits") { affinity_bits.yfilter = yfilter; } if(value_path == "affinity-mask") { affinity_mask.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::NamedAffinity() : constraint_type{YType::uint8, "constraint-type"}, constraint_value{YType::uint32, "constraint-value"}, forward_ref_value{YType::uint32, "forward-ref-value"} , constraint_extended_value(this, {}) , extended_forward_ref_value(this, {}) { yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::~NamedAffinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_data()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_data()) return true; } return constraint_type.is_set || constraint_value.is_set || forward_ref_value.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::has_operation() const { for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_operation()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(constraint_type.yfilter) || ydk::is_set(constraint_value.yfilter) || ydk::is_set(forward_ref_value.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "named-affinity"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata()); if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata()); if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "constraint-extended-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue>(); ent_->parent = this; constraint_extended_value.append(ent_); return ent_; } if(child_yang_name == "extended-forward-ref-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue>(); ent_->parent = this; extended_forward_ref_value.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : constraint_extended_value.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_ : extended_forward_ref_value.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::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 == "constraint-type") { constraint_type = value; constraint_type.value_namespace = name_space; constraint_type.value_namespace_prefix = name_space_prefix; } if(value_path == "constraint-value") { constraint_value = value; constraint_value.value_namespace = name_space; constraint_value.value_namespace_prefix = name_space_prefix; } if(value_path == "forward-ref-value") { forward_ref_value = value; forward_ref_value.value_namespace = name_space; forward_ref_value.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "constraint-type") { constraint_type.yfilter = yfilter; } if(value_path == "constraint-value") { constraint_value.yfilter = yfilter; } if(value_path == "forward-ref-value") { forward_ref_value.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue() : entry{YType::uint32, "entry"} { yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "constraint-extended-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue() : entry{YType::uint32, "entry"} { yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "extended-forward-ref-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::BfdReversePath() : path_type{YType::enumeration, "path-type"}, binding_label{YType::uint32, "binding-label"} { yang_name = "bfd-reverse-path"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::~BfdReversePath() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::has_data() const { if (is_presence_container) return true; return path_type.is_set || binding_label.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::has_operation() const { return is_set(yfilter) || ydk::is_set(path_type.yfilter) || ydk::is_set(binding_label.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "bfd-reverse-path"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (path_type.is_set || is_set(path_type.yfilter)) leaf_name_data.push_back(path_type.get_name_leafdata()); if (binding_label.is_set || is_set(binding_label.yfilter)) leaf_name_data.push_back(binding_label.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::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 == "path-type") { path_type = value; path_type.value_namespace = name_space; path_type.value_namespace_prefix = name_space_prefix; } if(value_path == "binding-label") { binding_label = value; binding_label.value_namespace = name_space; binding_label.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "path-type") { path_type.yfilter = yfilter; } if(value_path == "binding-label") { binding_label.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::has_leaf_or_child_of_name(const std::string & name) const { if(name == "path-type" || name == "binding-label") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::TunnelId() : entry{YType::uint16, "entry"} { yang_name = "tunnel-id"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::~TunnelId() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "tunnel-id"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::VersionInfo() : attribute_type{YType::str, "attribute-type"}, generation{YType::uint32, "generation"}, is_default{YType::boolean, "is-default"} { yang_name = "version-info"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::~VersionInfo() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::has_data() const { if (is_presence_container) return true; return attribute_type.is_set || generation.is_set || is_default.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::has_operation() const { return is_set(yfilter) || ydk::is_set(attribute_type.yfilter) || ydk::is_set(generation.yfilter) || ydk::is_set(is_default.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "version-info"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (attribute_type.is_set || is_set(attribute_type.yfilter)) leaf_name_data.push_back(attribute_type.get_name_leafdata()); if (generation.is_set || is_set(generation.yfilter)) leaf_name_data.push_back(generation.get_name_leafdata()); if (is_default.is_set || is_set(is_default.yfilter)) leaf_name_data.push_back(is_default.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::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 == "attribute-type") { attribute_type = value; attribute_type.value_namespace = name_space; attribute_type.value_namespace_prefix = name_space_prefix; } if(value_path == "generation") { generation = value; generation.value_namespace = name_space; generation.value_namespace_prefix = name_space_prefix; } if(value_path == "is-default") { is_default = value; is_default.value_namespace = name_space; is_default.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "attribute-type") { attribute_type.yfilter = yfilter; } if(value_path == "generation") { generation.yfilter = yfilter; } if(value_path == "is-default") { is_default.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::has_leaf_or_child_of_name(const std::string & name) const { if(name == "attribute-type" || name == "generation" || name == "is-default") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::AttributeSetAutobackup() : is_signalled_name_configured{YType::boolean, "is-signalled-name-configured"}, setup_priority{YType::uint8, "setup-priority"}, hold_priority{YType::uint8, "hold-priority"}, is_priority_configured{YType::boolean, "is-priority-configured"}, policy_class{YType::uint8, "policy-class"}, is_policyclass_configured{YType::boolean, "is-policyclass-configured"}, is_affinity_configured{YType::boolean, "is-affinity-configured"}, record_route{YType::boolean, "record-route"} , signalled_name(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName>()) , affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity>()) , logging(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging>()) , policy_class_entry(this, {}) , tunnel_id(this, {}) , protected_interface(this, {}) { signalled_name->parent = this; affinity->parent = this; logging->parent = this; yang_name = "attribute-set-autobackup"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::~AttributeSetAutobackup() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<policy_class_entry.len(); index++) { if(policy_class_entry[index]->has_data()) return true; } for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_data()) return true; } for (std::size_t index=0; index<protected_interface.len(); index++) { if(protected_interface[index]->has_data()) return true; } return is_signalled_name_configured.is_set || setup_priority.is_set || hold_priority.is_set || is_priority_configured.is_set || policy_class.is_set || is_policyclass_configured.is_set || is_affinity_configured.is_set || record_route.is_set || (signalled_name != nullptr && signalled_name->has_data()) || (affinity != nullptr && affinity->has_data()) || (logging != nullptr && logging->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::has_operation() const { for (std::size_t index=0; index<policy_class_entry.len(); index++) { if(policy_class_entry[index]->has_operation()) return true; } for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_operation()) return true; } for (std::size_t index=0; index<protected_interface.len(); index++) { if(protected_interface[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(is_signalled_name_configured.yfilter) || ydk::is_set(setup_priority.yfilter) || ydk::is_set(hold_priority.yfilter) || ydk::is_set(is_priority_configured.yfilter) || ydk::is_set(policy_class.yfilter) || ydk::is_set(is_policyclass_configured.yfilter) || ydk::is_set(is_affinity_configured.yfilter) || ydk::is_set(record_route.yfilter) || (signalled_name != nullptr && signalled_name->has_operation()) || (affinity != nullptr && affinity->has_operation()) || (logging != nullptr && logging->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-autobackup"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (is_signalled_name_configured.is_set || is_set(is_signalled_name_configured.yfilter)) leaf_name_data.push_back(is_signalled_name_configured.get_name_leafdata()); if (setup_priority.is_set || is_set(setup_priority.yfilter)) leaf_name_data.push_back(setup_priority.get_name_leafdata()); if (hold_priority.is_set || is_set(hold_priority.yfilter)) leaf_name_data.push_back(hold_priority.get_name_leafdata()); if (is_priority_configured.is_set || is_set(is_priority_configured.yfilter)) leaf_name_data.push_back(is_priority_configured.get_name_leafdata()); if (policy_class.is_set || is_set(policy_class.yfilter)) leaf_name_data.push_back(policy_class.get_name_leafdata()); if (is_policyclass_configured.is_set || is_set(is_policyclass_configured.yfilter)) leaf_name_data.push_back(is_policyclass_configured.get_name_leafdata()); if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata()); if (record_route.is_set || is_set(record_route.yfilter)) leaf_name_data.push_back(record_route.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "signalled-name") { if(signalled_name == nullptr) { signalled_name = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName>(); } return signalled_name; } if(child_yang_name == "affinity") { if(affinity == nullptr) { affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity>(); } return affinity; } if(child_yang_name == "logging") { if(logging == nullptr) { logging = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging>(); } return logging; } if(child_yang_name == "policy-class-entry") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry>(); ent_->parent = this; policy_class_entry.append(ent_); return ent_; } if(child_yang_name == "tunnel-id") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId>(); ent_->parent = this; tunnel_id.append(ent_); return ent_; } if(child_yang_name == "protected-interface") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface>(); ent_->parent = this; protected_interface.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(signalled_name != nullptr) { _children["signalled-name"] = signalled_name; } if(affinity != nullptr) { _children["affinity"] = affinity; } if(logging != nullptr) { _children["logging"] = logging; } count_ = 0; for (auto ent_ : policy_class_entry.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_ : tunnel_id.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_ : protected_interface.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::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 == "is-signalled-name-configured") { is_signalled_name_configured = value; is_signalled_name_configured.value_namespace = name_space; is_signalled_name_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "setup-priority") { setup_priority = value; setup_priority.value_namespace = name_space; setup_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "hold-priority") { hold_priority = value; hold_priority.value_namespace = name_space; hold_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "is-priority-configured") { is_priority_configured = value; is_priority_configured.value_namespace = name_space; is_priority_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "policy-class") { policy_class = value; policy_class.value_namespace = name_space; policy_class.value_namespace_prefix = name_space_prefix; } if(value_path == "is-policyclass-configured") { is_policyclass_configured = value; is_policyclass_configured.value_namespace = name_space; is_policyclass_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-affinity-configured") { is_affinity_configured = value; is_affinity_configured.value_namespace = name_space; is_affinity_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "record-route") { record_route = value; record_route.value_namespace = name_space; record_route.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "is-signalled-name-configured") { is_signalled_name_configured.yfilter = yfilter; } if(value_path == "setup-priority") { setup_priority.yfilter = yfilter; } if(value_path == "hold-priority") { hold_priority.yfilter = yfilter; } if(value_path == "is-priority-configured") { is_priority_configured.yfilter = yfilter; } if(value_path == "policy-class") { policy_class.yfilter = yfilter; } if(value_path == "is-policyclass-configured") { is_policyclass_configured.yfilter = yfilter; } if(value_path == "is-affinity-configured") { is_affinity_configured.yfilter = yfilter; } if(value_path == "record-route") { record_route.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "signalled-name" || name == "affinity" || name == "logging" || name == "policy-class-entry" || name == "tunnel-id" || name == "protected-interface" || name == "is-signalled-name-configured" || name == "setup-priority" || name == "hold-priority" || name == "is-priority-configured" || name == "policy-class" || name == "is-policyclass-configured" || name == "is-affinity-configured" || name == "record-route") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::SignalledName() : name{YType::str, "name"}, source_type{YType::enumeration, "source-type"}, protected_interface_type{YType::enumeration, "protected-interface-type"}, is_mp_addresses{YType::boolean, "is-mp-addresses"} { yang_name = "signalled-name"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::~SignalledName() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::has_data() const { if (is_presence_container) return true; return name.is_set || source_type.is_set || protected_interface_type.is_set || is_mp_addresses.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::has_operation() const { return is_set(yfilter) || ydk::is_set(name.yfilter) || ydk::is_set(source_type.yfilter) || ydk::is_set(protected_interface_type.yfilter) || ydk::is_set(is_mp_addresses.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "signalled-name"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (name.is_set || is_set(name.yfilter)) leaf_name_data.push_back(name.get_name_leafdata()); if (source_type.is_set || is_set(source_type.yfilter)) leaf_name_data.push_back(source_type.get_name_leafdata()); if (protected_interface_type.is_set || is_set(protected_interface_type.yfilter)) leaf_name_data.push_back(protected_interface_type.get_name_leafdata()); if (is_mp_addresses.is_set || is_set(is_mp_addresses.yfilter)) leaf_name_data.push_back(is_mp_addresses.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::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 == "name") { name = value; name.value_namespace = name_space; name.value_namespace_prefix = name_space_prefix; } if(value_path == "source-type") { source_type = value; source_type.value_namespace = name_space; source_type.value_namespace_prefix = name_space_prefix; } if(value_path == "protected-interface-type") { protected_interface_type = value; protected_interface_type.value_namespace = name_space; protected_interface_type.value_namespace_prefix = name_space_prefix; } if(value_path == "is-mp-addresses") { is_mp_addresses = value; is_mp_addresses.value_namespace = name_space; is_mp_addresses.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "name") { name.yfilter = yfilter; } if(value_path == "source-type") { source_type.yfilter = yfilter; } if(value_path == "protected-interface-type") { protected_interface_type.yfilter = yfilter; } if(value_path == "is-mp-addresses") { is_mp_addresses.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::has_leaf_or_child_of_name(const std::string & name) const { if(name == "name" || name == "source-type" || name == "protected-interface-type" || name == "is-mp-addresses") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::Affinity() : affinity_bits{YType::uint32, "affinity-bits"}, affinity_mask{YType::uint32, "affinity-mask"} , named_affinity(this, {}) { yang_name = "affinity"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::~Affinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_data()) return true; } return affinity_bits.is_set || affinity_mask.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::has_operation() const { for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(affinity_bits.yfilter) || ydk::is_set(affinity_mask.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "affinity"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata()); if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "named-affinity") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity>(); ent_->parent = this; named_affinity.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : named_affinity.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::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 == "affinity-bits") { affinity_bits = value; affinity_bits.value_namespace = name_space; affinity_bits.value_namespace_prefix = name_space_prefix; } if(value_path == "affinity-mask") { affinity_mask = value; affinity_mask.value_namespace = name_space; affinity_mask.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "affinity-bits") { affinity_bits.yfilter = yfilter; } if(value_path == "affinity-mask") { affinity_mask.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::NamedAffinity() : constraint_type{YType::uint8, "constraint-type"}, constraint_value{YType::uint32, "constraint-value"}, forward_ref_value{YType::uint32, "forward-ref-value"} , constraint_extended_value(this, {}) , extended_forward_ref_value(this, {}) { yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::~NamedAffinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_data()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_data()) return true; } return constraint_type.is_set || constraint_value.is_set || forward_ref_value.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::has_operation() const { for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_operation()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(constraint_type.yfilter) || ydk::is_set(constraint_value.yfilter) || ydk::is_set(forward_ref_value.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "named-affinity"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata()); if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata()); if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "constraint-extended-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue>(); ent_->parent = this; constraint_extended_value.append(ent_); return ent_; } if(child_yang_name == "extended-forward-ref-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue>(); ent_->parent = this; extended_forward_ref_value.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : constraint_extended_value.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_ : extended_forward_ref_value.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::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 == "constraint-type") { constraint_type = value; constraint_type.value_namespace = name_space; constraint_type.value_namespace_prefix = name_space_prefix; } if(value_path == "constraint-value") { constraint_value = value; constraint_value.value_namespace = name_space; constraint_value.value_namespace_prefix = name_space_prefix; } if(value_path == "forward-ref-value") { forward_ref_value = value; forward_ref_value.value_namespace = name_space; forward_ref_value.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "constraint-type") { constraint_type.yfilter = yfilter; } if(value_path == "constraint-value") { constraint_value.yfilter = yfilter; } if(value_path == "forward-ref-value") { forward_ref_value.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue() : entry{YType::uint32, "entry"} { yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "constraint-extended-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue() : entry{YType::uint32, "entry"} { yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "extended-forward-ref-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::Logging() : lsp_state{YType::boolean, "lsp-state"}, s2l_state{YType::boolean, "s2l-state"}, lsp_re_route{YType::boolean, "lsp-re-route"}, lsp_re_opt{YType::boolean, "lsp-re-opt"}, lsp_insufficient_bw{YType::boolean, "lsp-insufficient-bw"}, lsp_bandwidth_change{YType::boolean, "lsp-bandwidth-change"}, lsp_pcalc_failure_logging_enabled{YType::boolean, "lsp-pcalc-failure-logging-enabled"}, all_logging_enabled{YType::boolean, "all-logging-enabled"} { yang_name = "logging"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::~Logging() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::has_data() const { if (is_presence_container) return true; return lsp_state.is_set || s2l_state.is_set || lsp_re_route.is_set || lsp_re_opt.is_set || lsp_insufficient_bw.is_set || lsp_bandwidth_change.is_set || lsp_pcalc_failure_logging_enabled.is_set || all_logging_enabled.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::has_operation() const { return is_set(yfilter) || ydk::is_set(lsp_state.yfilter) || ydk::is_set(s2l_state.yfilter) || ydk::is_set(lsp_re_route.yfilter) || ydk::is_set(lsp_re_opt.yfilter) || ydk::is_set(lsp_insufficient_bw.yfilter) || ydk::is_set(lsp_bandwidth_change.yfilter) || ydk::is_set(lsp_pcalc_failure_logging_enabled.yfilter) || ydk::is_set(all_logging_enabled.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "logging"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (lsp_state.is_set || is_set(lsp_state.yfilter)) leaf_name_data.push_back(lsp_state.get_name_leafdata()); if (s2l_state.is_set || is_set(s2l_state.yfilter)) leaf_name_data.push_back(s2l_state.get_name_leafdata()); if (lsp_re_route.is_set || is_set(lsp_re_route.yfilter)) leaf_name_data.push_back(lsp_re_route.get_name_leafdata()); if (lsp_re_opt.is_set || is_set(lsp_re_opt.yfilter)) leaf_name_data.push_back(lsp_re_opt.get_name_leafdata()); if (lsp_insufficient_bw.is_set || is_set(lsp_insufficient_bw.yfilter)) leaf_name_data.push_back(lsp_insufficient_bw.get_name_leafdata()); if (lsp_bandwidth_change.is_set || is_set(lsp_bandwidth_change.yfilter)) leaf_name_data.push_back(lsp_bandwidth_change.get_name_leafdata()); if (lsp_pcalc_failure_logging_enabled.is_set || is_set(lsp_pcalc_failure_logging_enabled.yfilter)) leaf_name_data.push_back(lsp_pcalc_failure_logging_enabled.get_name_leafdata()); if (all_logging_enabled.is_set || is_set(all_logging_enabled.yfilter)) leaf_name_data.push_back(all_logging_enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::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 == "lsp-state") { lsp_state = value; lsp_state.value_namespace = name_space; lsp_state.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-state") { s2l_state = value; s2l_state.value_namespace = name_space; s2l_state.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-re-route") { lsp_re_route = value; lsp_re_route.value_namespace = name_space; lsp_re_route.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-re-opt") { lsp_re_opt = value; lsp_re_opt.value_namespace = name_space; lsp_re_opt.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-insufficient-bw") { lsp_insufficient_bw = value; lsp_insufficient_bw.value_namespace = name_space; lsp_insufficient_bw.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-bandwidth-change") { lsp_bandwidth_change = value; lsp_bandwidth_change.value_namespace = name_space; lsp_bandwidth_change.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-pcalc-failure-logging-enabled") { lsp_pcalc_failure_logging_enabled = value; lsp_pcalc_failure_logging_enabled.value_namespace = name_space; lsp_pcalc_failure_logging_enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "all-logging-enabled") { all_logging_enabled = value; all_logging_enabled.value_namespace = name_space; all_logging_enabled.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "lsp-state") { lsp_state.yfilter = yfilter; } if(value_path == "s2l-state") { s2l_state.yfilter = yfilter; } if(value_path == "lsp-re-route") { lsp_re_route.yfilter = yfilter; } if(value_path == "lsp-re-opt") { lsp_re_opt.yfilter = yfilter; } if(value_path == "lsp-insufficient-bw") { lsp_insufficient_bw.yfilter = yfilter; } if(value_path == "lsp-bandwidth-change") { lsp_bandwidth_change.yfilter = yfilter; } if(value_path == "lsp-pcalc-failure-logging-enabled") { lsp_pcalc_failure_logging_enabled.yfilter = yfilter; } if(value_path == "all-logging-enabled") { all_logging_enabled.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::has_leaf_or_child_of_name(const std::string & name) const { if(name == "lsp-state" || name == "s2l-state" || name == "lsp-re-route" || name == "lsp-re-opt" || name == "lsp-insufficient-bw" || name == "lsp-bandwidth-change" || name == "lsp-pcalc-failure-logging-enabled" || name == "all-logging-enabled") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::PolicyClassEntry() : entry{YType::uint8, "entry"} { yang_name = "policy-class-entry"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::~PolicyClassEntry() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "policy-class-entry"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::TunnelId() : entry{YType::uint16, "entry"} { yang_name = "tunnel-id"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::~TunnelId() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "tunnel-id"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::ProtectedInterface() : protected_interface{YType::str, "protected-interface"} { yang_name = "protected-interface"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::~ProtectedInterface() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::has_data() const { if (is_presence_container) return true; return protected_interface.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::has_operation() const { return is_set(yfilter) || ydk::is_set(protected_interface.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "protected-interface"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (protected_interface.is_set || is_set(protected_interface.yfilter)) leaf_name_data.push_back(protected_interface.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::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 == "protected-interface") { protected_interface = value; protected_interface.value_namespace = name_space; protected_interface.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "protected-interface") { protected_interface.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::has_leaf_or_child_of_name(const std::string & name) const { if(name == "protected-interface") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::AttributeSetAutomesh() : configured_bandwidth{YType::uint32, "configured-bandwidth"}, dste_class_type{YType::uint8, "dste-class-type"}, is_bandwidth_configured{YType::boolean, "is-bandwidth-configured"}, setup_priority{YType::uint8, "setup-priority"}, hold_priority{YType::uint8, "hold-priority"}, is_priority_configured{YType::boolean, "is-priority-configured"}, policy_class{YType::uint8, "policy-class"}, is_policyclass_configured{YType::boolean, "is-policyclass-configured"}, forward_class{YType::uint32, "forward-class"}, is_forward_class_configured{YType::boolean, "is-forward-class-configured"}, is_affinity_configured{YType::boolean, "is-affinity-configured"}, fast_reroute{YType::boolean, "fast-reroute"}, frr_node_protection{YType::boolean, "frr-node-protection"}, frr_bandwidth_protection{YType::boolean, "frr-bandwidth-protection"}, record_route{YType::boolean, "record-route"}, auto_bandwidth_collect{YType::boolean, "auto-bandwidth-collect"}, auto_route_announce{YType::boolean, "auto-route-announce"}, soft_preemption_configured{YType::boolean, "soft-preemption-configured"}, bandwidth{YType::uint32, "bandwidth"}, load_share{YType::uint32, "load-share"}, is_interface_bw_configured{YType::boolean, "is-interface-bw-configured"} , affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity>()) , logging(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging>()) , policy_class_entry(this, {}) , mesh_group_id(this, {}) , tunnel_id(this, {}) { affinity->parent = this; logging->parent = this; yang_name = "attribute-set-automesh"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::~AttributeSetAutomesh() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<policy_class_entry.len(); index++) { if(policy_class_entry[index]->has_data()) return true; } for (std::size_t index=0; index<mesh_group_id.len(); index++) { if(mesh_group_id[index]->has_data()) return true; } for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_data()) return true; } return configured_bandwidth.is_set || dste_class_type.is_set || is_bandwidth_configured.is_set || setup_priority.is_set || hold_priority.is_set || is_priority_configured.is_set || policy_class.is_set || is_policyclass_configured.is_set || forward_class.is_set || is_forward_class_configured.is_set || is_affinity_configured.is_set || fast_reroute.is_set || frr_node_protection.is_set || frr_bandwidth_protection.is_set || record_route.is_set || auto_bandwidth_collect.is_set || auto_route_announce.is_set || soft_preemption_configured.is_set || bandwidth.is_set || load_share.is_set || is_interface_bw_configured.is_set || (affinity != nullptr && affinity->has_data()) || (logging != nullptr && logging->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::has_operation() const { for (std::size_t index=0; index<policy_class_entry.len(); index++) { if(policy_class_entry[index]->has_operation()) return true; } for (std::size_t index=0; index<mesh_group_id.len(); index++) { if(mesh_group_id[index]->has_operation()) return true; } for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(configured_bandwidth.yfilter) || ydk::is_set(dste_class_type.yfilter) || ydk::is_set(is_bandwidth_configured.yfilter) || ydk::is_set(setup_priority.yfilter) || ydk::is_set(hold_priority.yfilter) || ydk::is_set(is_priority_configured.yfilter) || ydk::is_set(policy_class.yfilter) || ydk::is_set(is_policyclass_configured.yfilter) || ydk::is_set(forward_class.yfilter) || ydk::is_set(is_forward_class_configured.yfilter) || ydk::is_set(is_affinity_configured.yfilter) || ydk::is_set(fast_reroute.yfilter) || ydk::is_set(frr_node_protection.yfilter) || ydk::is_set(frr_bandwidth_protection.yfilter) || ydk::is_set(record_route.yfilter) || ydk::is_set(auto_bandwidth_collect.yfilter) || ydk::is_set(auto_route_announce.yfilter) || ydk::is_set(soft_preemption_configured.yfilter) || ydk::is_set(bandwidth.yfilter) || ydk::is_set(load_share.yfilter) || ydk::is_set(is_interface_bw_configured.yfilter) || (affinity != nullptr && affinity->has_operation()) || (logging != nullptr && logging->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-automesh"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (configured_bandwidth.is_set || is_set(configured_bandwidth.yfilter)) leaf_name_data.push_back(configured_bandwidth.get_name_leafdata()); if (dste_class_type.is_set || is_set(dste_class_type.yfilter)) leaf_name_data.push_back(dste_class_type.get_name_leafdata()); if (is_bandwidth_configured.is_set || is_set(is_bandwidth_configured.yfilter)) leaf_name_data.push_back(is_bandwidth_configured.get_name_leafdata()); if (setup_priority.is_set || is_set(setup_priority.yfilter)) leaf_name_data.push_back(setup_priority.get_name_leafdata()); if (hold_priority.is_set || is_set(hold_priority.yfilter)) leaf_name_data.push_back(hold_priority.get_name_leafdata()); if (is_priority_configured.is_set || is_set(is_priority_configured.yfilter)) leaf_name_data.push_back(is_priority_configured.get_name_leafdata()); if (policy_class.is_set || is_set(policy_class.yfilter)) leaf_name_data.push_back(policy_class.get_name_leafdata()); if (is_policyclass_configured.is_set || is_set(is_policyclass_configured.yfilter)) leaf_name_data.push_back(is_policyclass_configured.get_name_leafdata()); if (forward_class.is_set || is_set(forward_class.yfilter)) leaf_name_data.push_back(forward_class.get_name_leafdata()); if (is_forward_class_configured.is_set || is_set(is_forward_class_configured.yfilter)) leaf_name_data.push_back(is_forward_class_configured.get_name_leafdata()); if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata()); if (fast_reroute.is_set || is_set(fast_reroute.yfilter)) leaf_name_data.push_back(fast_reroute.get_name_leafdata()); if (frr_node_protection.is_set || is_set(frr_node_protection.yfilter)) leaf_name_data.push_back(frr_node_protection.get_name_leafdata()); if (frr_bandwidth_protection.is_set || is_set(frr_bandwidth_protection.yfilter)) leaf_name_data.push_back(frr_bandwidth_protection.get_name_leafdata()); if (record_route.is_set || is_set(record_route.yfilter)) leaf_name_data.push_back(record_route.get_name_leafdata()); if (auto_bandwidth_collect.is_set || is_set(auto_bandwidth_collect.yfilter)) leaf_name_data.push_back(auto_bandwidth_collect.get_name_leafdata()); if (auto_route_announce.is_set || is_set(auto_route_announce.yfilter)) leaf_name_data.push_back(auto_route_announce.get_name_leafdata()); if (soft_preemption_configured.is_set || is_set(soft_preemption_configured.yfilter)) leaf_name_data.push_back(soft_preemption_configured.get_name_leafdata()); if (bandwidth.is_set || is_set(bandwidth.yfilter)) leaf_name_data.push_back(bandwidth.get_name_leafdata()); if (load_share.is_set || is_set(load_share.yfilter)) leaf_name_data.push_back(load_share.get_name_leafdata()); if (is_interface_bw_configured.is_set || is_set(is_interface_bw_configured.yfilter)) leaf_name_data.push_back(is_interface_bw_configured.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "affinity") { if(affinity == nullptr) { affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity>(); } return affinity; } if(child_yang_name == "logging") { if(logging == nullptr) { logging = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging>(); } return logging; } if(child_yang_name == "policy-class-entry") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry>(); ent_->parent = this; policy_class_entry.append(ent_); return ent_; } if(child_yang_name == "mesh-group-id") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId>(); ent_->parent = this; mesh_group_id.append(ent_); return ent_; } if(child_yang_name == "tunnel-id") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId>(); ent_->parent = this; tunnel_id.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(affinity != nullptr) { _children["affinity"] = affinity; } if(logging != nullptr) { _children["logging"] = logging; } count_ = 0; for (auto ent_ : policy_class_entry.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_ : mesh_group_id.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_ : tunnel_id.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::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 == "configured-bandwidth") { configured_bandwidth = value; configured_bandwidth.value_namespace = name_space; configured_bandwidth.value_namespace_prefix = name_space_prefix; } if(value_path == "dste-class-type") { dste_class_type = value; dste_class_type.value_namespace = name_space; dste_class_type.value_namespace_prefix = name_space_prefix; } if(value_path == "is-bandwidth-configured") { is_bandwidth_configured = value; is_bandwidth_configured.value_namespace = name_space; is_bandwidth_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "setup-priority") { setup_priority = value; setup_priority.value_namespace = name_space; setup_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "hold-priority") { hold_priority = value; hold_priority.value_namespace = name_space; hold_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "is-priority-configured") { is_priority_configured = value; is_priority_configured.value_namespace = name_space; is_priority_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "policy-class") { policy_class = value; policy_class.value_namespace = name_space; policy_class.value_namespace_prefix = name_space_prefix; } if(value_path == "is-policyclass-configured") { is_policyclass_configured = value; is_policyclass_configured.value_namespace = name_space; is_policyclass_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "forward-class") { forward_class = value; forward_class.value_namespace = name_space; forward_class.value_namespace_prefix = name_space_prefix; } if(value_path == "is-forward-class-configured") { is_forward_class_configured = value; is_forward_class_configured.value_namespace = name_space; is_forward_class_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-affinity-configured") { is_affinity_configured = value; is_affinity_configured.value_namespace = name_space; is_affinity_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "fast-reroute") { fast_reroute = value; fast_reroute.value_namespace = name_space; fast_reroute.value_namespace_prefix = name_space_prefix; } if(value_path == "frr-node-protection") { frr_node_protection = value; frr_node_protection.value_namespace = name_space; frr_node_protection.value_namespace_prefix = name_space_prefix; } if(value_path == "frr-bandwidth-protection") { frr_bandwidth_protection = value; frr_bandwidth_protection.value_namespace = name_space; frr_bandwidth_protection.value_namespace_prefix = name_space_prefix; } if(value_path == "record-route") { record_route = value; record_route.value_namespace = name_space; record_route.value_namespace_prefix = name_space_prefix; } if(value_path == "auto-bandwidth-collect") { auto_bandwidth_collect = value; auto_bandwidth_collect.value_namespace = name_space; auto_bandwidth_collect.value_namespace_prefix = name_space_prefix; } if(value_path == "auto-route-announce") { auto_route_announce = value; auto_route_announce.value_namespace = name_space; auto_route_announce.value_namespace_prefix = name_space_prefix; } if(value_path == "soft-preemption-configured") { soft_preemption_configured = value; soft_preemption_configured.value_namespace = name_space; soft_preemption_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "bandwidth") { bandwidth = value; bandwidth.value_namespace = name_space; bandwidth.value_namespace_prefix = name_space_prefix; } if(value_path == "load-share") { load_share = value; load_share.value_namespace = name_space; load_share.value_namespace_prefix = name_space_prefix; } if(value_path == "is-interface-bw-configured") { is_interface_bw_configured = value; is_interface_bw_configured.value_namespace = name_space; is_interface_bw_configured.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "configured-bandwidth") { configured_bandwidth.yfilter = yfilter; } if(value_path == "dste-class-type") { dste_class_type.yfilter = yfilter; } if(value_path == "is-bandwidth-configured") { is_bandwidth_configured.yfilter = yfilter; } if(value_path == "setup-priority") { setup_priority.yfilter = yfilter; } if(value_path == "hold-priority") { hold_priority.yfilter = yfilter; } if(value_path == "is-priority-configured") { is_priority_configured.yfilter = yfilter; } if(value_path == "policy-class") { policy_class.yfilter = yfilter; } if(value_path == "is-policyclass-configured") { is_policyclass_configured.yfilter = yfilter; } if(value_path == "forward-class") { forward_class.yfilter = yfilter; } if(value_path == "is-forward-class-configured") { is_forward_class_configured.yfilter = yfilter; } if(value_path == "is-affinity-configured") { is_affinity_configured.yfilter = yfilter; } if(value_path == "fast-reroute") { fast_reroute.yfilter = yfilter; } if(value_path == "frr-node-protection") { frr_node_protection.yfilter = yfilter; } if(value_path == "frr-bandwidth-protection") { frr_bandwidth_protection.yfilter = yfilter; } if(value_path == "record-route") { record_route.yfilter = yfilter; } if(value_path == "auto-bandwidth-collect") { auto_bandwidth_collect.yfilter = yfilter; } if(value_path == "auto-route-announce") { auto_route_announce.yfilter = yfilter; } if(value_path == "soft-preemption-configured") { soft_preemption_configured.yfilter = yfilter; } if(value_path == "bandwidth") { bandwidth.yfilter = yfilter; } if(value_path == "load-share") { load_share.yfilter = yfilter; } if(value_path == "is-interface-bw-configured") { is_interface_bw_configured.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::has_leaf_or_child_of_name(const std::string & name) const { if(name == "affinity" || name == "logging" || name == "policy-class-entry" || name == "mesh-group-id" || name == "tunnel-id" || name == "configured-bandwidth" || name == "dste-class-type" || name == "is-bandwidth-configured" || name == "setup-priority" || name == "hold-priority" || name == "is-priority-configured" || name == "policy-class" || name == "is-policyclass-configured" || name == "forward-class" || name == "is-forward-class-configured" || name == "is-affinity-configured" || name == "fast-reroute" || name == "frr-node-protection" || name == "frr-bandwidth-protection" || name == "record-route" || name == "auto-bandwidth-collect" || name == "auto-route-announce" || name == "soft-preemption-configured" || name == "bandwidth" || name == "load-share" || name == "is-interface-bw-configured") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::Affinity() : affinity_bits{YType::uint32, "affinity-bits"}, affinity_mask{YType::uint32, "affinity-mask"} , named_affinity(this, {}) { yang_name = "affinity"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::~Affinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_data()) return true; } return affinity_bits.is_set || affinity_mask.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::has_operation() const { for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(affinity_bits.yfilter) || ydk::is_set(affinity_mask.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "affinity"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata()); if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "named-affinity") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity>(); ent_->parent = this; named_affinity.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : named_affinity.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::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 == "affinity-bits") { affinity_bits = value; affinity_bits.value_namespace = name_space; affinity_bits.value_namespace_prefix = name_space_prefix; } if(value_path == "affinity-mask") { affinity_mask = value; affinity_mask.value_namespace = name_space; affinity_mask.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "affinity-bits") { affinity_bits.yfilter = yfilter; } if(value_path == "affinity-mask") { affinity_mask.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::NamedAffinity() : constraint_type{YType::uint8, "constraint-type"}, constraint_value{YType::uint32, "constraint-value"}, forward_ref_value{YType::uint32, "forward-ref-value"} , constraint_extended_value(this, {}) , extended_forward_ref_value(this, {}) { yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::~NamedAffinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_data()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_data()) return true; } return constraint_type.is_set || constraint_value.is_set || forward_ref_value.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::has_operation() const { for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_operation()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(constraint_type.yfilter) || ydk::is_set(constraint_value.yfilter) || ydk::is_set(forward_ref_value.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "named-affinity"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata()); if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata()); if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "constraint-extended-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue>(); ent_->parent = this; constraint_extended_value.append(ent_); return ent_; } if(child_yang_name == "extended-forward-ref-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue>(); ent_->parent = this; extended_forward_ref_value.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : constraint_extended_value.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_ : extended_forward_ref_value.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::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 == "constraint-type") { constraint_type = value; constraint_type.value_namespace = name_space; constraint_type.value_namespace_prefix = name_space_prefix; } if(value_path == "constraint-value") { constraint_value = value; constraint_value.value_namespace = name_space; constraint_value.value_namespace_prefix = name_space_prefix; } if(value_path == "forward-ref-value") { forward_ref_value = value; forward_ref_value.value_namespace = name_space; forward_ref_value.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "constraint-type") { constraint_type.yfilter = yfilter; } if(value_path == "constraint-value") { constraint_value.yfilter = yfilter; } if(value_path == "forward-ref-value") { forward_ref_value.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue() : entry{YType::uint32, "entry"} { yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "constraint-extended-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue() : entry{YType::uint32, "entry"} { yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "extended-forward-ref-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::Logging() : lsp_state{YType::boolean, "lsp-state"}, s2l_state{YType::boolean, "s2l-state"}, lsp_re_route{YType::boolean, "lsp-re-route"}, lsp_re_opt{YType::boolean, "lsp-re-opt"}, lsp_insufficient_bw{YType::boolean, "lsp-insufficient-bw"}, lsp_bandwidth_change{YType::boolean, "lsp-bandwidth-change"}, lsp_pcalc_failure_logging_enabled{YType::boolean, "lsp-pcalc-failure-logging-enabled"}, all_logging_enabled{YType::boolean, "all-logging-enabled"} { yang_name = "logging"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::~Logging() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::has_data() const { if (is_presence_container) return true; return lsp_state.is_set || s2l_state.is_set || lsp_re_route.is_set || lsp_re_opt.is_set || lsp_insufficient_bw.is_set || lsp_bandwidth_change.is_set || lsp_pcalc_failure_logging_enabled.is_set || all_logging_enabled.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::has_operation() const { return is_set(yfilter) || ydk::is_set(lsp_state.yfilter) || ydk::is_set(s2l_state.yfilter) || ydk::is_set(lsp_re_route.yfilter) || ydk::is_set(lsp_re_opt.yfilter) || ydk::is_set(lsp_insufficient_bw.yfilter) || ydk::is_set(lsp_bandwidth_change.yfilter) || ydk::is_set(lsp_pcalc_failure_logging_enabled.yfilter) || ydk::is_set(all_logging_enabled.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "logging"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (lsp_state.is_set || is_set(lsp_state.yfilter)) leaf_name_data.push_back(lsp_state.get_name_leafdata()); if (s2l_state.is_set || is_set(s2l_state.yfilter)) leaf_name_data.push_back(s2l_state.get_name_leafdata()); if (lsp_re_route.is_set || is_set(lsp_re_route.yfilter)) leaf_name_data.push_back(lsp_re_route.get_name_leafdata()); if (lsp_re_opt.is_set || is_set(lsp_re_opt.yfilter)) leaf_name_data.push_back(lsp_re_opt.get_name_leafdata()); if (lsp_insufficient_bw.is_set || is_set(lsp_insufficient_bw.yfilter)) leaf_name_data.push_back(lsp_insufficient_bw.get_name_leafdata()); if (lsp_bandwidth_change.is_set || is_set(lsp_bandwidth_change.yfilter)) leaf_name_data.push_back(lsp_bandwidth_change.get_name_leafdata()); if (lsp_pcalc_failure_logging_enabled.is_set || is_set(lsp_pcalc_failure_logging_enabled.yfilter)) leaf_name_data.push_back(lsp_pcalc_failure_logging_enabled.get_name_leafdata()); if (all_logging_enabled.is_set || is_set(all_logging_enabled.yfilter)) leaf_name_data.push_back(all_logging_enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::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 == "lsp-state") { lsp_state = value; lsp_state.value_namespace = name_space; lsp_state.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-state") { s2l_state = value; s2l_state.value_namespace = name_space; s2l_state.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-re-route") { lsp_re_route = value; lsp_re_route.value_namespace = name_space; lsp_re_route.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-re-opt") { lsp_re_opt = value; lsp_re_opt.value_namespace = name_space; lsp_re_opt.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-insufficient-bw") { lsp_insufficient_bw = value; lsp_insufficient_bw.value_namespace = name_space; lsp_insufficient_bw.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-bandwidth-change") { lsp_bandwidth_change = value; lsp_bandwidth_change.value_namespace = name_space; lsp_bandwidth_change.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-pcalc-failure-logging-enabled") { lsp_pcalc_failure_logging_enabled = value; lsp_pcalc_failure_logging_enabled.value_namespace = name_space; lsp_pcalc_failure_logging_enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "all-logging-enabled") { all_logging_enabled = value; all_logging_enabled.value_namespace = name_space; all_logging_enabled.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "lsp-state") { lsp_state.yfilter = yfilter; } if(value_path == "s2l-state") { s2l_state.yfilter = yfilter; } if(value_path == "lsp-re-route") { lsp_re_route.yfilter = yfilter; } if(value_path == "lsp-re-opt") { lsp_re_opt.yfilter = yfilter; } if(value_path == "lsp-insufficient-bw") { lsp_insufficient_bw.yfilter = yfilter; } if(value_path == "lsp-bandwidth-change") { lsp_bandwidth_change.yfilter = yfilter; } if(value_path == "lsp-pcalc-failure-logging-enabled") { lsp_pcalc_failure_logging_enabled.yfilter = yfilter; } if(value_path == "all-logging-enabled") { all_logging_enabled.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::has_leaf_or_child_of_name(const std::string & name) const { if(name == "lsp-state" || name == "s2l-state" || name == "lsp-re-route" || name == "lsp-re-opt" || name == "lsp-insufficient-bw" || name == "lsp-bandwidth-change" || name == "lsp-pcalc-failure-logging-enabled" || name == "all-logging-enabled") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::PolicyClassEntry() : entry{YType::uint8, "entry"} { yang_name = "policy-class-entry"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::~PolicyClassEntry() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "policy-class-entry"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::MeshGroupId() : entry{YType::uint32, "entry"} { yang_name = "mesh-group-id"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::~MeshGroupId() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "mesh-group-id"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::TunnelId() : entry{YType::uint16, "entry"} { yang_name = "tunnel-id"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::~TunnelId() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "tunnel-id"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::AttributeSetXro() : xro(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro>()) { xro->parent = this; yang_name = "attribute-set-xro"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::~AttributeSetXro() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::has_data() const { if (is_presence_container) return true; return (xro != nullptr && xro->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::has_operation() const { return is_set(yfilter) || (xro != nullptr && xro->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-xro"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "xro") { if(xro == nullptr) { xro = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro>(); } return xro; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(xro != nullptr) { _children["xro"] = xro; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::set_filter(const std::string & value_path, YFilter yfilter) { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::has_leaf_or_child_of_name(const std::string & name) const { if(name == "xro") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::Xro() : mutual_diversity_flag{YType::boolean, "mutual-diversity-flag"} , xro_subobject(this, {}) { yang_name = "xro"; yang_parent_name = "attribute-set-xro"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::~Xro() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<xro_subobject.len(); index++) { if(xro_subobject[index]->has_data()) return true; } return mutual_diversity_flag.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::has_operation() const { for (std::size_t index=0; index<xro_subobject.len(); index++) { if(xro_subobject[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(mutual_diversity_flag.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "xro"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (mutual_diversity_flag.is_set || is_set(mutual_diversity_flag.yfilter)) leaf_name_data.push_back(mutual_diversity_flag.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "xro-subobject") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject>(); ent_->parent = this; xro_subobject.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : xro_subobject.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::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 == "mutual-diversity-flag") { mutual_diversity_flag = value; mutual_diversity_flag.value_namespace = name_space; mutual_diversity_flag.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "mutual-diversity-flag") { mutual_diversity_flag.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::has_leaf_or_child_of_name(const std::string & name) const { if(name == "xro-subobject" || name == "mutual-diversity-flag") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::XroSubobject() : type{YType::enumeration, "type"} , ipv4_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject>()) , ipv6_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject>()) , unnumbered_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject>()) , as_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject>()) , srlg_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject>()) , lsp_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject>()) { ipv4_subobject->parent = this; ipv6_subobject->parent = this; unnumbered_subobject->parent = this; as_subobject->parent = this; srlg_subobject->parent = this; lsp_subobject->parent = this; yang_name = "xro-subobject"; yang_parent_name = "xro"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::~XroSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::has_data() const { if (is_presence_container) return true; return type.is_set || (ipv4_subobject != nullptr && ipv4_subobject->has_data()) || (ipv6_subobject != nullptr && ipv6_subobject->has_data()) || (unnumbered_subobject != nullptr && unnumbered_subobject->has_data()) || (as_subobject != nullptr && as_subobject->has_data()) || (srlg_subobject != nullptr && srlg_subobject->has_data()) || (lsp_subobject != nullptr && lsp_subobject->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(type.yfilter) || (ipv4_subobject != nullptr && ipv4_subobject->has_operation()) || (ipv6_subobject != nullptr && ipv6_subobject->has_operation()) || (unnumbered_subobject != nullptr && unnumbered_subobject->has_operation()) || (as_subobject != nullptr && as_subobject->has_operation()) || (srlg_subobject != nullptr && srlg_subobject->has_operation()) || (lsp_subobject != nullptr && lsp_subobject->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "xro-subobject"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "ipv4-subobject") { if(ipv4_subobject == nullptr) { ipv4_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject>(); } return ipv4_subobject; } if(child_yang_name == "ipv6-subobject") { if(ipv6_subobject == nullptr) { ipv6_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject>(); } return ipv6_subobject; } if(child_yang_name == "unnumbered-subobject") { if(unnumbered_subobject == nullptr) { unnumbered_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject>(); } return unnumbered_subobject; } if(child_yang_name == "as-subobject") { if(as_subobject == nullptr) { as_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject>(); } return as_subobject; } if(child_yang_name == "srlg-subobject") { if(srlg_subobject == nullptr) { srlg_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject>(); } return srlg_subobject; } if(child_yang_name == "lsp-subobject") { if(lsp_subobject == nullptr) { lsp_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject>(); } return lsp_subobject; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(ipv4_subobject != nullptr) { _children["ipv4-subobject"] = ipv4_subobject; } if(ipv6_subobject != nullptr) { _children["ipv6-subobject"] = ipv6_subobject; } if(unnumbered_subobject != nullptr) { _children["unnumbered-subobject"] = unnumbered_subobject; } if(as_subobject != nullptr) { _children["as-subobject"] = as_subobject; } if(srlg_subobject != nullptr) { _children["srlg-subobject"] = srlg_subobject; } if(lsp_subobject != nullptr) { _children["lsp-subobject"] = lsp_subobject; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::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 == "type") { type = value; type.value_namespace = name_space; type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "type") { type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "ipv4-subobject" || name == "ipv6-subobject" || name == "unnumbered-subobject" || name == "as-subobject" || name == "srlg-subobject" || name == "lsp-subobject" || name == "type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::Ipv4Subobject() : address{YType::str, "address"}, prefix_len{YType::uint8, "prefix-len"}, attribute{YType::enumeration, "attribute"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "ipv4-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::~Ipv4Subobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::has_data() const { if (is_presence_container) return true; return address.is_set || prefix_len.is_set || attribute.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::has_operation() const { return is_set(yfilter) || ydk::is_set(address.yfilter) || ydk::is_set(prefix_len.yfilter) || ydk::is_set(attribute.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv4-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata()); if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata()); if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::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 == "address") { address = value; address.value_namespace = name_space; address.value_namespace_prefix = name_space_prefix; } if(value_path == "prefix-len") { prefix_len = value; prefix_len.value_namespace = name_space; prefix_len.value_namespace_prefix = name_space_prefix; } if(value_path == "attribute") { attribute = value; attribute.value_namespace = name_space; attribute.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "address") { address.yfilter = yfilter; } if(value_path == "prefix-len") { prefix_len.yfilter = yfilter; } if(value_path == "attribute") { attribute.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::Ipv6Subobject() : address{YType::str, "address"}, prefix_len{YType::uint8, "prefix-len"}, attribute{YType::enumeration, "attribute"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "ipv6-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::~Ipv6Subobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::has_data() const { if (is_presence_container) return true; return address.is_set || prefix_len.is_set || attribute.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::has_operation() const { return is_set(yfilter) || ydk::is_set(address.yfilter) || ydk::is_set(prefix_len.yfilter) || ydk::is_set(attribute.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv6-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata()); if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata()); if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::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 == "address") { address = value; address.value_namespace = name_space; address.value_namespace_prefix = name_space_prefix; } if(value_path == "prefix-len") { prefix_len = value; prefix_len.value_namespace = name_space; prefix_len.value_namespace_prefix = name_space_prefix; } if(value_path == "attribute") { attribute = value; attribute.value_namespace = name_space; attribute.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "address") { address.yfilter = yfilter; } if(value_path == "prefix-len") { prefix_len.yfilter = yfilter; } if(value_path == "attribute") { attribute.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::UnnumberedSubobject() : te_router_id{YType::str, "te-router-id"}, interface_id{YType::uint32, "interface-id"}, attribute{YType::enumeration, "attribute"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "unnumbered-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::~UnnumberedSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::has_data() const { if (is_presence_container) return true; return te_router_id.is_set || interface_id.is_set || attribute.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(te_router_id.yfilter) || ydk::is_set(interface_id.yfilter) || ydk::is_set(attribute.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "unnumbered-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (te_router_id.is_set || is_set(te_router_id.yfilter)) leaf_name_data.push_back(te_router_id.get_name_leafdata()); if (interface_id.is_set || is_set(interface_id.yfilter)) leaf_name_data.push_back(interface_id.get_name_leafdata()); if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::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 == "te-router-id") { te_router_id = value; te_router_id.value_namespace = name_space; te_router_id.value_namespace_prefix = name_space_prefix; } if(value_path == "interface-id") { interface_id = value; interface_id.value_namespace = name_space; interface_id.value_namespace_prefix = name_space_prefix; } if(value_path == "attribute") { attribute = value; attribute.value_namespace = name_space; attribute.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "te-router-id") { te_router_id.yfilter = yfilter; } if(value_path == "interface-id") { interface_id.yfilter = yfilter; } if(value_path == "attribute") { attribute.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "te-router-id" || name == "interface-id" || name == "attribute" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::AsSubobject() : as_number{YType::uint16, "as-number"} { yang_name = "as-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::~AsSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::has_data() const { if (is_presence_container) return true; return as_number.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(as_number.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "as-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::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> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "as-number") { as_number.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "as-number") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::SrlgSubobject() : srlg_id{YType::uint32, "srlg-id"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "srlg-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::~SrlgSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::has_data() const { if (is_presence_container) return true; return srlg_id.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(srlg_id.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "srlg-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (srlg_id.is_set || is_set(srlg_id.yfilter)) leaf_name_data.push_back(srlg_id.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::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 == "srlg-id") { srlg_id = value; srlg_id.value_namespace = name_space; srlg_id.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "srlg-id") { srlg_id.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "srlg-id" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::LspSubobject() : ignore_lsp_id{YType::boolean, "ignore-lsp-id"}, processing_node_exception{YType::boolean, "processing-node-exception"}, penultimate_node_exception{YType::boolean, "penultimate-node-exception"}, destination_node_exception{YType::boolean, "destination-node-exception"}, exclusion_type{YType::enumeration, "exclusion-type"} , fec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec>()) { fec->parent = this; yang_name = "lsp-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::~LspSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::has_data() const { if (is_presence_container) return true; return ignore_lsp_id.is_set || processing_node_exception.is_set || penultimate_node_exception.is_set || destination_node_exception.is_set || exclusion_type.is_set || (fec != nullptr && fec->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(ignore_lsp_id.yfilter) || ydk::is_set(processing_node_exception.yfilter) || ydk::is_set(penultimate_node_exception.yfilter) || ydk::is_set(destination_node_exception.yfilter) || ydk::is_set(exclusion_type.yfilter) || (fec != nullptr && fec->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "lsp-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (ignore_lsp_id.is_set || is_set(ignore_lsp_id.yfilter)) leaf_name_data.push_back(ignore_lsp_id.get_name_leafdata()); if (processing_node_exception.is_set || is_set(processing_node_exception.yfilter)) leaf_name_data.push_back(processing_node_exception.get_name_leafdata()); if (penultimate_node_exception.is_set || is_set(penultimate_node_exception.yfilter)) leaf_name_data.push_back(penultimate_node_exception.get_name_leafdata()); if (destination_node_exception.is_set || is_set(destination_node_exception.yfilter)) leaf_name_data.push_back(destination_node_exception.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "fec") { if(fec == nullptr) { fec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec>(); } return fec; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(fec != nullptr) { _children["fec"] = fec; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::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 == "ignore-lsp-id") { ignore_lsp_id = value; ignore_lsp_id.value_namespace = name_space; ignore_lsp_id.value_namespace_prefix = name_space_prefix; } if(value_path == "processing-node-exception") { processing_node_exception = value; processing_node_exception.value_namespace = name_space; processing_node_exception.value_namespace_prefix = name_space_prefix; } if(value_path == "penultimate-node-exception") { penultimate_node_exception = value; penultimate_node_exception.value_namespace = name_space; penultimate_node_exception.value_namespace_prefix = name_space_prefix; } if(value_path == "destination-node-exception") { destination_node_exception = value; destination_node_exception.value_namespace = name_space; destination_node_exception.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "ignore-lsp-id") { ignore_lsp_id.yfilter = yfilter; } if(value_path == "processing-node-exception") { processing_node_exception.yfilter = yfilter; } if(value_path == "penultimate-node-exception") { penultimate_node_exception.yfilter = yfilter; } if(value_path == "destination-node-exception") { destination_node_exception.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "fec" || name == "ignore-lsp-id" || name == "processing-node-exception" || name == "penultimate-node-exception" || name == "destination-node-exception" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::Fec() : fec_lsp_id{YType::uint16, "fec-lsp-id"}, fec_tunnel_id{YType::uint16, "fec-tunnel-id"}, fec_extended_tunnel_id{YType::str, "fec-extended-tunnel-id"}, fec_source{YType::str, "fec-source"}, fec_vrf{YType::str, "fec-vrf"} , fec_destination_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo>()) { fec_destination_info->parent = this; yang_name = "fec"; yang_parent_name = "lsp-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::~Fec() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::has_data() const { if (is_presence_container) return true; return fec_lsp_id.is_set || fec_tunnel_id.is_set || fec_extended_tunnel_id.is_set || fec_source.is_set || fec_vrf.is_set || (fec_destination_info != nullptr && fec_destination_info->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::has_operation() const { return is_set(yfilter) || ydk::is_set(fec_lsp_id.yfilter) || ydk::is_set(fec_tunnel_id.yfilter) || ydk::is_set(fec_extended_tunnel_id.yfilter) || ydk::is_set(fec_source.yfilter) || ydk::is_set(fec_vrf.yfilter) || (fec_destination_info != nullptr && fec_destination_info->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "fec"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (fec_lsp_id.is_set || is_set(fec_lsp_id.yfilter)) leaf_name_data.push_back(fec_lsp_id.get_name_leafdata()); if (fec_tunnel_id.is_set || is_set(fec_tunnel_id.yfilter)) leaf_name_data.push_back(fec_tunnel_id.get_name_leafdata()); if (fec_extended_tunnel_id.is_set || is_set(fec_extended_tunnel_id.yfilter)) leaf_name_data.push_back(fec_extended_tunnel_id.get_name_leafdata()); if (fec_source.is_set || is_set(fec_source.yfilter)) leaf_name_data.push_back(fec_source.get_name_leafdata()); if (fec_vrf.is_set || is_set(fec_vrf.yfilter)) leaf_name_data.push_back(fec_vrf.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "fec-destination-info") { if(fec_destination_info == nullptr) { fec_destination_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo>(); } return fec_destination_info; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(fec_destination_info != nullptr) { _children["fec-destination-info"] = fec_destination_info; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::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 == "fec-lsp-id") { fec_lsp_id = value; fec_lsp_id.value_namespace = name_space; fec_lsp_id.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-tunnel-id") { fec_tunnel_id = value; fec_tunnel_id.value_namespace = name_space; fec_tunnel_id.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-extended-tunnel-id") { fec_extended_tunnel_id = value; fec_extended_tunnel_id.value_namespace = name_space; fec_extended_tunnel_id.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-source") { fec_source = value; fec_source.value_namespace = name_space; fec_source.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-vrf") { fec_vrf = value; fec_vrf.value_namespace = name_space; fec_vrf.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "fec-lsp-id") { fec_lsp_id.yfilter = yfilter; } if(value_path == "fec-tunnel-id") { fec_tunnel_id.yfilter = yfilter; } if(value_path == "fec-extended-tunnel-id") { fec_extended_tunnel_id.yfilter = yfilter; } if(value_path == "fec-source") { fec_source.yfilter = yfilter; } if(value_path == "fec-vrf") { fec_vrf.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::has_leaf_or_child_of_name(const std::string & name) const { if(name == "fec-destination-info" || name == "fec-lsp-id" || name == "fec-tunnel-id" || name == "fec-extended-tunnel-id" || name == "fec-source" || name == "fec-vrf") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::FecDestinationInfo() : fec_ctype{YType::enumeration, "fec-ctype"}, p2p_lsp_destination{YType::str, "p2p-lsp-destination"}, fec_destination_p2mp_id{YType::uint32, "fec-destination-p2mp-id"} { yang_name = "fec-destination-info"; yang_parent_name = "fec"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::~FecDestinationInfo() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_data() const { if (is_presence_container) return true; return fec_ctype.is_set || p2p_lsp_destination.is_set || fec_destination_p2mp_id.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_operation() const { return is_set(yfilter) || ydk::is_set(fec_ctype.yfilter) || ydk::is_set(p2p_lsp_destination.yfilter) || ydk::is_set(fec_destination_p2mp_id.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "fec-destination-info"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (fec_ctype.is_set || is_set(fec_ctype.yfilter)) leaf_name_data.push_back(fec_ctype.get_name_leafdata()); if (p2p_lsp_destination.is_set || is_set(p2p_lsp_destination.yfilter)) leaf_name_data.push_back(p2p_lsp_destination.get_name_leafdata()); if (fec_destination_p2mp_id.is_set || is_set(fec_destination_p2mp_id.yfilter)) leaf_name_data.push_back(fec_destination_p2mp_id.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::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 == "fec-ctype") { fec_ctype = value; fec_ctype.value_namespace = name_space; fec_ctype.value_namespace_prefix = name_space_prefix; } if(value_path == "p2p-lsp-destination") { p2p_lsp_destination = value; p2p_lsp_destination.value_namespace = name_space; p2p_lsp_destination.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-destination-p2mp-id") { fec_destination_p2mp_id = value; fec_destination_p2mp_id.value_namespace = name_space; fec_destination_p2mp_id.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "fec-ctype") { fec_ctype.yfilter = yfilter; } if(value_path == "p2p-lsp-destination") { p2p_lsp_destination.yfilter = yfilter; } if(value_path == "fec-destination-p2mp-id") { fec_destination_p2mp_id.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_leaf_or_child_of_name(const std::string & name) const { if(name == "fec-ctype" || name == "p2p-lsp-destination" || name == "fec-destination-p2mp-id") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::AttributeSetP2mpte() : fast_reroute{YType::boolean, "fast-reroute"}, frr_bandwidth_protection{YType::boolean, "frr-bandwidth-protection"}, setup_priority{YType::uint8, "setup-priority"}, hold_priority{YType::uint8, "hold-priority"}, is_priority_configured{YType::boolean, "is-priority-configured"}, configured_bandwidth{YType::uint32, "configured-bandwidth"}, dste_class_type{YType::uint8, "dste-class-type"}, is_bandwidth_configured{YType::boolean, "is-bandwidth-configured"}, is_affinity_configured{YType::boolean, "is-affinity-configured"} , affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity>()) , tunnel_id(this, {}) { affinity->parent = this; yang_name = "attribute-set-p2mpte"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::~AttributeSetP2mpte() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_data()) return true; } return fast_reroute.is_set || frr_bandwidth_protection.is_set || setup_priority.is_set || hold_priority.is_set || is_priority_configured.is_set || configured_bandwidth.is_set || dste_class_type.is_set || is_bandwidth_configured.is_set || is_affinity_configured.is_set || (affinity != nullptr && affinity->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::has_operation() const { for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(fast_reroute.yfilter) || ydk::is_set(frr_bandwidth_protection.yfilter) || ydk::is_set(setup_priority.yfilter) || ydk::is_set(hold_priority.yfilter) || ydk::is_set(is_priority_configured.yfilter) || ydk::is_set(configured_bandwidth.yfilter) || ydk::is_set(dste_class_type.yfilter) || ydk::is_set(is_bandwidth_configured.yfilter) || ydk::is_set(is_affinity_configured.yfilter) || (affinity != nullptr && affinity->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-p2mpte"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (fast_reroute.is_set || is_set(fast_reroute.yfilter)) leaf_name_data.push_back(fast_reroute.get_name_leafdata()); if (frr_bandwidth_protection.is_set || is_set(frr_bandwidth_protection.yfilter)) leaf_name_data.push_back(frr_bandwidth_protection.get_name_leafdata()); if (setup_priority.is_set || is_set(setup_priority.yfilter)) leaf_name_data.push_back(setup_priority.get_name_leafdata()); if (hold_priority.is_set || is_set(hold_priority.yfilter)) leaf_name_data.push_back(hold_priority.get_name_leafdata()); if (is_priority_configured.is_set || is_set(is_priority_configured.yfilter)) leaf_name_data.push_back(is_priority_configured.get_name_leafdata()); if (configured_bandwidth.is_set || is_set(configured_bandwidth.yfilter)) leaf_name_data.push_back(configured_bandwidth.get_name_leafdata()); if (dste_class_type.is_set || is_set(dste_class_type.yfilter)) leaf_name_data.push_back(dste_class_type.get_name_leafdata()); if (is_bandwidth_configured.is_set || is_set(is_bandwidth_configured.yfilter)) leaf_name_data.push_back(is_bandwidth_configured.get_name_leafdata()); if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "affinity") { if(affinity == nullptr) { affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity>(); } return affinity; } if(child_yang_name == "tunnel-id") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId>(); ent_->parent = this; tunnel_id.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(affinity != nullptr) { _children["affinity"] = affinity; } count_ = 0; for (auto ent_ : tunnel_id.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::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 == "fast-reroute") { fast_reroute = value; fast_reroute.value_namespace = name_space; fast_reroute.value_namespace_prefix = name_space_prefix; } if(value_path == "frr-bandwidth-protection") { frr_bandwidth_protection = value; frr_bandwidth_protection.value_namespace = name_space; frr_bandwidth_protection.value_namespace_prefix = name_space_prefix; } if(value_path == "setup-priority") { setup_priority = value; setup_priority.value_namespace = name_space; setup_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "hold-priority") { hold_priority = value; hold_priority.value_namespace = name_space; hold_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "is-priority-configured") { is_priority_configured = value; is_priority_configured.value_namespace = name_space; is_priority_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "configured-bandwidth") { configured_bandwidth = value; configured_bandwidth.value_namespace = name_space; configured_bandwidth.value_namespace_prefix = name_space_prefix; } if(value_path == "dste-class-type") { dste_class_type = value; dste_class_type.value_namespace = name_space; dste_class_type.value_namespace_prefix = name_space_prefix; } if(value_path == "is-bandwidth-configured") { is_bandwidth_configured = value; is_bandwidth_configured.value_namespace = name_space; is_bandwidth_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-affinity-configured") { is_affinity_configured = value; is_affinity_configured.value_namespace = name_space; is_affinity_configured.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "fast-reroute") { fast_reroute.yfilter = yfilter; } if(value_path == "frr-bandwidth-protection") { frr_bandwidth_protection.yfilter = yfilter; } if(value_path == "setup-priority") { setup_priority.yfilter = yfilter; } if(value_path == "hold-priority") { hold_priority.yfilter = yfilter; } if(value_path == "is-priority-configured") { is_priority_configured.yfilter = yfilter; } if(value_path == "configured-bandwidth") { configured_bandwidth.yfilter = yfilter; } if(value_path == "dste-class-type") { dste_class_type.yfilter = yfilter; } if(value_path == "is-bandwidth-configured") { is_bandwidth_configured.yfilter = yfilter; } if(value_path == "is-affinity-configured") { is_affinity_configured.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::has_leaf_or_child_of_name(const std::string & name) const { if(name == "affinity" || name == "tunnel-id" || name == "fast-reroute" || name == "frr-bandwidth-protection" || name == "setup-priority" || name == "hold-priority" || name == "is-priority-configured" || name == "configured-bandwidth" || name == "dste-class-type" || name == "is-bandwidth-configured" || name == "is-affinity-configured") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::Affinity() : affinity_bits{YType::uint32, "affinity-bits"}, affinity_mask{YType::uint32, "affinity-mask"} , named_affinity(this, {}) { yang_name = "affinity"; yang_parent_name = "attribute-set-p2mpte"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::~Affinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_data()) return true; } return affinity_bits.is_set || affinity_mask.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::has_operation() const { for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(affinity_bits.yfilter) || ydk::is_set(affinity_mask.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "affinity"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata()); if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "named-affinity") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity>(); ent_->parent = this; named_affinity.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : named_affinity.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::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 == "affinity-bits") { affinity_bits = value; affinity_bits.value_namespace = name_space; affinity_bits.value_namespace_prefix = name_space_prefix; } if(value_path == "affinity-mask") { affinity_mask = value; affinity_mask.value_namespace = name_space; affinity_mask.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "affinity-bits") { affinity_bits.yfilter = yfilter; } if(value_path == "affinity-mask") { affinity_mask.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::NamedAffinity() : constraint_type{YType::uint8, "constraint-type"}, constraint_value{YType::uint32, "constraint-value"}, forward_ref_value{YType::uint32, "forward-ref-value"} , constraint_extended_value(this, {}) , extended_forward_ref_value(this, {}) { yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::~NamedAffinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_data()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_data()) return true; } return constraint_type.is_set || constraint_value.is_set || forward_ref_value.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::has_operation() const { for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_operation()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(constraint_type.yfilter) || ydk::is_set(constraint_value.yfilter) || ydk::is_set(forward_ref_value.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "named-affinity"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata()); if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata()); if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "constraint-extended-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue>(); ent_->parent = this; constraint_extended_value.append(ent_); return ent_; } if(child_yang_name == "extended-forward-ref-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue>(); ent_->parent = this; extended_forward_ref_value.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : constraint_extended_value.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_ : extended_forward_ref_value.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::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 == "constraint-type") { constraint_type = value; constraint_type.value_namespace = name_space; constraint_type.value_namespace_prefix = name_space_prefix; } if(value_path == "constraint-value") { constraint_value = value; constraint_value.value_namespace = name_space; constraint_value.value_namespace_prefix = name_space_prefix; } if(value_path == "forward-ref-value") { forward_ref_value = value; forward_ref_value.value_namespace = name_space; forward_ref_value.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "constraint-type") { constraint_type.yfilter = yfilter; } if(value_path == "constraint-value") { constraint_value.yfilter = yfilter; } if(value_path == "forward-ref-value") { forward_ref_value.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue() : entry{YType::uint32, "entry"} { yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "constraint-extended-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue() : entry{YType::uint32, "entry"} { yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "extended-forward-ref-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::TunnelId() : entry{YType::uint16, "entry"} { yang_name = "tunnel-id"; yang_parent_name = "attribute-set-p2mpte"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::~TunnelId() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "tunnel-id"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::AttributeSetApsPp() : snc_mode{YType::enumeration, "snc-mode"}, tcm_id{YType::uint32, "tcm-id"}, protection_type{YType::enumeration, "protection-type"}, protection_mode{YType::enumeration, "protection-mode"}, wait_to_restore_time{YType::uint32, "wait-to-restore-time"}, hold_off_time{YType::uint32, "hold-off-time"}, path_prot_profile_type{YType::enumeration, "path-prot-profile-type"}, restoration_style{YType::enumeration, "restoration-style"} , revert_schedule(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule>()) { revert_schedule->parent = this; yang_name = "attribute-set-aps-pp"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::~AttributeSetApsPp() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::has_data() const { if (is_presence_container) return true; return snc_mode.is_set || tcm_id.is_set || protection_type.is_set || protection_mode.is_set || wait_to_restore_time.is_set || hold_off_time.is_set || path_prot_profile_type.is_set || restoration_style.is_set || (revert_schedule != nullptr && revert_schedule->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::has_operation() const { return is_set(yfilter) || ydk::is_set(snc_mode.yfilter) || ydk::is_set(tcm_id.yfilter) || ydk::is_set(protection_type.yfilter) || ydk::is_set(protection_mode.yfilter) || ydk::is_set(wait_to_restore_time.yfilter) || ydk::is_set(hold_off_time.yfilter) || ydk::is_set(path_prot_profile_type.yfilter) || ydk::is_set(restoration_style.yfilter) || (revert_schedule != nullptr && revert_schedule->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-aps-pp"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (snc_mode.is_set || is_set(snc_mode.yfilter)) leaf_name_data.push_back(snc_mode.get_name_leafdata()); if (tcm_id.is_set || is_set(tcm_id.yfilter)) leaf_name_data.push_back(tcm_id.get_name_leafdata()); if (protection_type.is_set || is_set(protection_type.yfilter)) leaf_name_data.push_back(protection_type.get_name_leafdata()); if (protection_mode.is_set || is_set(protection_mode.yfilter)) leaf_name_data.push_back(protection_mode.get_name_leafdata()); if (wait_to_restore_time.is_set || is_set(wait_to_restore_time.yfilter)) leaf_name_data.push_back(wait_to_restore_time.get_name_leafdata()); if (hold_off_time.is_set || is_set(hold_off_time.yfilter)) leaf_name_data.push_back(hold_off_time.get_name_leafdata()); if (path_prot_profile_type.is_set || is_set(path_prot_profile_type.yfilter)) leaf_name_data.push_back(path_prot_profile_type.get_name_leafdata()); if (restoration_style.is_set || is_set(restoration_style.yfilter)) leaf_name_data.push_back(restoration_style.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "revert-schedule") { if(revert_schedule == nullptr) { revert_schedule = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule>(); } return revert_schedule; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(revert_schedule != nullptr) { _children["revert-schedule"] = revert_schedule; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::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 == "snc-mode") { snc_mode = value; snc_mode.value_namespace = name_space; snc_mode.value_namespace_prefix = name_space_prefix; } if(value_path == "tcm-id") { tcm_id = value; tcm_id.value_namespace = name_space; tcm_id.value_namespace_prefix = name_space_prefix; } if(value_path == "protection-type") { protection_type = value; protection_type.value_namespace = name_space; protection_type.value_namespace_prefix = name_space_prefix; } if(value_path == "protection-mode") { protection_mode = value; protection_mode.value_namespace = name_space; protection_mode.value_namespace_prefix = name_space_prefix; } if(value_path == "wait-to-restore-time") { wait_to_restore_time = value; wait_to_restore_time.value_namespace = name_space; wait_to_restore_time.value_namespace_prefix = name_space_prefix; } if(value_path == "hold-off-time") { hold_off_time = value; hold_off_time.value_namespace = name_space; hold_off_time.value_namespace_prefix = name_space_prefix; } if(value_path == "path-prot-profile-type") { path_prot_profile_type = value; path_prot_profile_type.value_namespace = name_space; path_prot_profile_type.value_namespace_prefix = name_space_prefix; } if(value_path == "restoration-style") { restoration_style = value; restoration_style.value_namespace = name_space; restoration_style.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "snc-mode") { snc_mode.yfilter = yfilter; } if(value_path == "tcm-id") { tcm_id.yfilter = yfilter; } if(value_path == "protection-type") { protection_type.yfilter = yfilter; } if(value_path == "protection-mode") { protection_mode.yfilter = yfilter; } if(value_path == "wait-to-restore-time") { wait_to_restore_time.yfilter = yfilter; } if(value_path == "hold-off-time") { hold_off_time.yfilter = yfilter; } if(value_path == "path-prot-profile-type") { path_prot_profile_type.yfilter = yfilter; } if(value_path == "restoration-style") { restoration_style.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::has_leaf_or_child_of_name(const std::string & name) const { if(name == "revert-schedule" || name == "snc-mode" || name == "tcm-id" || name == "protection-type" || name == "protection-mode" || name == "wait-to-restore-time" || name == "hold-off-time" || name == "path-prot-profile-type" || name == "restoration-style") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::RevertSchedule() : schedulename{YType::str, "schedulename"}, schedule_date{YType::uint32, "schedule-date"}, schedule_frequency{YType::enumeration, "schedule-frequency"}, duration{YType::uint32, "duration"}, max_tries{YType::uint32, "max-tries"} { yang_name = "revert-schedule"; yang_parent_name = "attribute-set-aps-pp"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::~RevertSchedule() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::has_data() const { if (is_presence_container) return true; return schedulename.is_set || schedule_date.is_set || schedule_frequency.is_set || duration.is_set || max_tries.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::has_operation() const { return is_set(yfilter) || ydk::is_set(schedulename.yfilter) || ydk::is_set(schedule_date.yfilter) || ydk::is_set(schedule_frequency.yfilter) || ydk::is_set(duration.yfilter) || ydk::is_set(max_tries.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "revert-schedule"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (schedulename.is_set || is_set(schedulename.yfilter)) leaf_name_data.push_back(schedulename.get_name_leafdata()); if (schedule_date.is_set || is_set(schedule_date.yfilter)) leaf_name_data.push_back(schedule_date.get_name_leafdata()); if (schedule_frequency.is_set || is_set(schedule_frequency.yfilter)) leaf_name_data.push_back(schedule_frequency.get_name_leafdata()); if (duration.is_set || is_set(duration.yfilter)) leaf_name_data.push_back(duration.get_name_leafdata()); if (max_tries.is_set || is_set(max_tries.yfilter)) leaf_name_data.push_back(max_tries.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::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 == "schedulename") { schedulename = value; schedulename.value_namespace = name_space; schedulename.value_namespace_prefix = name_space_prefix; } if(value_path == "schedule-date") { schedule_date = value; schedule_date.value_namespace = name_space; schedule_date.value_namespace_prefix = name_space_prefix; } if(value_path == "schedule-frequency") { schedule_frequency = value; schedule_frequency.value_namespace = name_space; schedule_frequency.value_namespace_prefix = name_space_prefix; } if(value_path == "duration") { duration = value; duration.value_namespace = name_space; duration.value_namespace_prefix = name_space_prefix; } if(value_path == "max-tries") { max_tries = value; max_tries.value_namespace = name_space; max_tries.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "schedulename") { schedulename.yfilter = yfilter; } if(value_path == "schedule-date") { schedule_date.yfilter = yfilter; } if(value_path == "schedule-frequency") { schedule_frequency.yfilter = yfilter; } if(value_path == "duration") { duration.yfilter = yfilter; } if(value_path == "max-tries") { max_tries.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::has_leaf_or_child_of_name(const std::string & name) const { if(name == "schedulename" || name == "schedule-date" || name == "schedule-frequency" || name == "duration" || name == "max-tries") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::AttributeSetP2pTe() : is_affinity_configured{YType::boolean, "is-affinity-configured"}, path_selection_segment_routing_adjacency_protection{YType::enumeration, "path-selection-segment-routing-adjacency-protection"}, is_path_selection_segment_routing_adjacency_protection_configured{YType::boolean, "is-path-selection-segment-routing-adjacency-protection-configured"}, path_invalidation_timeout{YType::uint32, "path-invalidation-timeout"}, path_selection_invalidation_action{YType::enumeration, "path-selection-invalidation-action"}, is_path_invalidation_timeout_configured{YType::boolean, "is-path-invalidation-timeout-configured"}, is_path_invalidation_action_configured{YType::boolean, "is-path-invalidation-action-configured"}, path_selection_metric{YType::enumeration, "path-selection-metric"}, is_path_selection_metric_configured{YType::boolean, "is-path-selection-metric-configured"}, path_selection_segment_routing_margin{YType::uint32, "path-selection-segment-routing-margin"}, is_path_selection_segment_routing_margin_relative{YType::boolean, "is-path-selection-segment-routing-margin-relative"}, is_path_selection_segment_routing_margin_configured{YType::boolean, "is-path-selection-segment-routing-margin-configured"}, path_selection_segment_routing_segment_limit{YType::uint32, "path-selection-segment-routing-segment-limit"}, is_path_selection_segment_routing_segment_limit_configured{YType::boolean, "is-path-selection-segment-routing-segment-limit-configured"}, is_path_select_configured{YType::boolean, "is-path-select-configured"}, is_prepend_list_configured{YType::boolean, "is-prepend-list-configured"}, is_pce_configured{YType::boolean, "is-pce-configured"}, is_pce_disj_source_configured{YType::boolean, "is-pce-disj-source-configured"}, is_pce_disj_type_configured{YType::boolean, "is-pce-disj-type-configured"}, is_pce_disj_group_id_configured{YType::boolean, "is-pce-disj-group-id-configured"}, pcedp_source_address{YType::uint32, "pcedp-source-address"}, pcedp_type{YType::enumeration, "pcedp-type"}, pcedp_group_id{YType::uint32, "pcedp-group-id"}, is_pceb_dj_source_configured{YType::boolean, "is-pceb-dj-source-configured"}, is_pcebd_group_id_configured{YType::boolean, "is-pcebd-group-id-configured"}, pcebd_source_address{YType::uint32, "pcebd-source-address"}, pcebd_group_id{YType::uint32, "pcebd-group-id"} , affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity>()) , logging(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging>()) , prepend_list(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList>()) , tunnel_id(this, {}) { affinity->parent = this; logging->parent = this; prepend_list->parent = this; yang_name = "attribute-set-p2p-te"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::~AttributeSetP2pTe() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_data()) return true; } return is_affinity_configured.is_set || path_selection_segment_routing_adjacency_protection.is_set || is_path_selection_segment_routing_adjacency_protection_configured.is_set || path_invalidation_timeout.is_set || path_selection_invalidation_action.is_set || is_path_invalidation_timeout_configured.is_set || is_path_invalidation_action_configured.is_set || path_selection_metric.is_set || is_path_selection_metric_configured.is_set || path_selection_segment_routing_margin.is_set || is_path_selection_segment_routing_margin_relative.is_set || is_path_selection_segment_routing_margin_configured.is_set || path_selection_segment_routing_segment_limit.is_set || is_path_selection_segment_routing_segment_limit_configured.is_set || is_path_select_configured.is_set || is_prepend_list_configured.is_set || is_pce_configured.is_set || is_pce_disj_source_configured.is_set || is_pce_disj_type_configured.is_set || is_pce_disj_group_id_configured.is_set || pcedp_source_address.is_set || pcedp_type.is_set || pcedp_group_id.is_set || is_pceb_dj_source_configured.is_set || is_pcebd_group_id_configured.is_set || pcebd_source_address.is_set || pcebd_group_id.is_set || (affinity != nullptr && affinity->has_data()) || (logging != nullptr && logging->has_data()) || (prepend_list != nullptr && prepend_list->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::has_operation() const { for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(is_affinity_configured.yfilter) || ydk::is_set(path_selection_segment_routing_adjacency_protection.yfilter) || ydk::is_set(is_path_selection_segment_routing_adjacency_protection_configured.yfilter) || ydk::is_set(path_invalidation_timeout.yfilter) || ydk::is_set(path_selection_invalidation_action.yfilter) || ydk::is_set(is_path_invalidation_timeout_configured.yfilter) || ydk::is_set(is_path_invalidation_action_configured.yfilter) || ydk::is_set(path_selection_metric.yfilter) || ydk::is_set(is_path_selection_metric_configured.yfilter) || ydk::is_set(path_selection_segment_routing_margin.yfilter) || ydk::is_set(is_path_selection_segment_routing_margin_relative.yfilter) || ydk::is_set(is_path_selection_segment_routing_margin_configured.yfilter) || ydk::is_set(path_selection_segment_routing_segment_limit.yfilter) || ydk::is_set(is_path_selection_segment_routing_segment_limit_configured.yfilter) || ydk::is_set(is_path_select_configured.yfilter) || ydk::is_set(is_prepend_list_configured.yfilter) || ydk::is_set(is_pce_configured.yfilter) || ydk::is_set(is_pce_disj_source_configured.yfilter) || ydk::is_set(is_pce_disj_type_configured.yfilter) || ydk::is_set(is_pce_disj_group_id_configured.yfilter) || ydk::is_set(pcedp_source_address.yfilter) || ydk::is_set(pcedp_type.yfilter) || ydk::is_set(pcedp_group_id.yfilter) || ydk::is_set(is_pceb_dj_source_configured.yfilter) || ydk::is_set(is_pcebd_group_id_configured.yfilter) || ydk::is_set(pcebd_source_address.yfilter) || ydk::is_set(pcebd_group_id.yfilter) || (affinity != nullptr && affinity->has_operation()) || (logging != nullptr && logging->has_operation()) || (prepend_list != nullptr && prepend_list->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-p2p-te"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata()); if (path_selection_segment_routing_adjacency_protection.is_set || is_set(path_selection_segment_routing_adjacency_protection.yfilter)) leaf_name_data.push_back(path_selection_segment_routing_adjacency_protection.get_name_leafdata()); if (is_path_selection_segment_routing_adjacency_protection_configured.is_set || is_set(is_path_selection_segment_routing_adjacency_protection_configured.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_adjacency_protection_configured.get_name_leafdata()); if (path_invalidation_timeout.is_set || is_set(path_invalidation_timeout.yfilter)) leaf_name_data.push_back(path_invalidation_timeout.get_name_leafdata()); if (path_selection_invalidation_action.is_set || is_set(path_selection_invalidation_action.yfilter)) leaf_name_data.push_back(path_selection_invalidation_action.get_name_leafdata()); if (is_path_invalidation_timeout_configured.is_set || is_set(is_path_invalidation_timeout_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_timeout_configured.get_name_leafdata()); if (is_path_invalidation_action_configured.is_set || is_set(is_path_invalidation_action_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_action_configured.get_name_leafdata()); if (path_selection_metric.is_set || is_set(path_selection_metric.yfilter)) leaf_name_data.push_back(path_selection_metric.get_name_leafdata()); if (is_path_selection_metric_configured.is_set || is_set(is_path_selection_metric_configured.yfilter)) leaf_name_data.push_back(is_path_selection_metric_configured.get_name_leafdata()); if (path_selection_segment_routing_margin.is_set || is_set(path_selection_segment_routing_margin.yfilter)) leaf_name_data.push_back(path_selection_segment_routing_margin.get_name_leafdata()); if (is_path_selection_segment_routing_margin_relative.is_set || is_set(is_path_selection_segment_routing_margin_relative.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_margin_relative.get_name_leafdata()); if (is_path_selection_segment_routing_margin_configured.is_set || is_set(is_path_selection_segment_routing_margin_configured.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_margin_configured.get_name_leafdata()); if (path_selection_segment_routing_segment_limit.is_set || is_set(path_selection_segment_routing_segment_limit.yfilter)) leaf_name_data.push_back(path_selection_segment_routing_segment_limit.get_name_leafdata()); if (is_path_selection_segment_routing_segment_limit_configured.is_set || is_set(is_path_selection_segment_routing_segment_limit_configured.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_segment_limit_configured.get_name_leafdata()); if (is_path_select_configured.is_set || is_set(is_path_select_configured.yfilter)) leaf_name_data.push_back(is_path_select_configured.get_name_leafdata()); if (is_prepend_list_configured.is_set || is_set(is_prepend_list_configured.yfilter)) leaf_name_data.push_back(is_prepend_list_configured.get_name_leafdata()); if (is_pce_configured.is_set || is_set(is_pce_configured.yfilter)) leaf_name_data.push_back(is_pce_configured.get_name_leafdata()); if (is_pce_disj_source_configured.is_set || is_set(is_pce_disj_source_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_source_configured.get_name_leafdata()); if (is_pce_disj_type_configured.is_set || is_set(is_pce_disj_type_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_type_configured.get_name_leafdata()); if (is_pce_disj_group_id_configured.is_set || is_set(is_pce_disj_group_id_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_group_id_configured.get_name_leafdata()); if (pcedp_source_address.is_set || is_set(pcedp_source_address.yfilter)) leaf_name_data.push_back(pcedp_source_address.get_name_leafdata()); if (pcedp_type.is_set || is_set(pcedp_type.yfilter)) leaf_name_data.push_back(pcedp_type.get_name_leafdata()); if (pcedp_group_id.is_set || is_set(pcedp_group_id.yfilter)) leaf_name_data.push_back(pcedp_group_id.get_name_leafdata()); if (is_pceb_dj_source_configured.is_set || is_set(is_pceb_dj_source_configured.yfilter)) leaf_name_data.push_back(is_pceb_dj_source_configured.get_name_leafdata()); if (is_pcebd_group_id_configured.is_set || is_set(is_pcebd_group_id_configured.yfilter)) leaf_name_data.push_back(is_pcebd_group_id_configured.get_name_leafdata()); if (pcebd_source_address.is_set || is_set(pcebd_source_address.yfilter)) leaf_name_data.push_back(pcebd_source_address.get_name_leafdata()); if (pcebd_group_id.is_set || is_set(pcebd_group_id.yfilter)) leaf_name_data.push_back(pcebd_group_id.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "affinity") { if(affinity == nullptr) { affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity>(); } return affinity; } if(child_yang_name == "logging") { if(logging == nullptr) { logging = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging>(); } return logging; } if(child_yang_name == "prepend-list") { if(prepend_list == nullptr) { prepend_list = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList>(); } return prepend_list; } if(child_yang_name == "tunnel-id") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId>(); ent_->parent = this; tunnel_id.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(affinity != nullptr) { _children["affinity"] = affinity; } if(logging != nullptr) { _children["logging"] = logging; } if(prepend_list != nullptr) { _children["prepend-list"] = prepend_list; } count_ = 0; for (auto ent_ : tunnel_id.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::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 == "is-affinity-configured") { is_affinity_configured = value; is_affinity_configured.value_namespace = name_space; is_affinity_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "path-selection-segment-routing-adjacency-protection") { path_selection_segment_routing_adjacency_protection = value; path_selection_segment_routing_adjacency_protection.value_namespace = name_space; path_selection_segment_routing_adjacency_protection.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-selection-segment-routing-adjacency-protection-configured") { is_path_selection_segment_routing_adjacency_protection_configured = value; is_path_selection_segment_routing_adjacency_protection_configured.value_namespace = name_space; is_path_selection_segment_routing_adjacency_protection_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "path-invalidation-timeout") { path_invalidation_timeout = value; path_invalidation_timeout.value_namespace = name_space; path_invalidation_timeout.value_namespace_prefix = name_space_prefix; } if(value_path == "path-selection-invalidation-action") { path_selection_invalidation_action = value; path_selection_invalidation_action.value_namespace = name_space; path_selection_invalidation_action.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-invalidation-timeout-configured") { is_path_invalidation_timeout_configured = value; is_path_invalidation_timeout_configured.value_namespace = name_space; is_path_invalidation_timeout_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-invalidation-action-configured") { is_path_invalidation_action_configured = value; is_path_invalidation_action_configured.value_namespace = name_space; is_path_invalidation_action_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "path-selection-metric") { path_selection_metric = value; path_selection_metric.value_namespace = name_space; path_selection_metric.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-selection-metric-configured") { is_path_selection_metric_configured = value; is_path_selection_metric_configured.value_namespace = name_space; is_path_selection_metric_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "path-selection-segment-routing-margin") { path_selection_segment_routing_margin = value; path_selection_segment_routing_margin.value_namespace = name_space; path_selection_segment_routing_margin.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-selection-segment-routing-margin-relative") { is_path_selection_segment_routing_margin_relative = value; is_path_selection_segment_routing_margin_relative.value_namespace = name_space; is_path_selection_segment_routing_margin_relative.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-selection-segment-routing-margin-configured") { is_path_selection_segment_routing_margin_configured = value; is_path_selection_segment_routing_margin_configured.value_namespace = name_space; is_path_selection_segment_routing_margin_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "path-selection-segment-routing-segment-limit") { path_selection_segment_routing_segment_limit = value; path_selection_segment_routing_segment_limit.value_namespace = name_space; path_selection_segment_routing_segment_limit.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-selection-segment-routing-segment-limit-configured") { is_path_selection_segment_routing_segment_limit_configured = value; is_path_selection_segment_routing_segment_limit_configured.value_namespace = name_space; is_path_selection_segment_routing_segment_limit_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-select-configured") { is_path_select_configured = value; is_path_select_configured.value_namespace = name_space; is_path_select_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-prepend-list-configured") { is_prepend_list_configured = value; is_prepend_list_configured.value_namespace = name_space; is_prepend_list_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-configured") { is_pce_configured = value; is_pce_configured.value_namespace = name_space; is_pce_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-disj-source-configured") { is_pce_disj_source_configured = value; is_pce_disj_source_configured.value_namespace = name_space; is_pce_disj_source_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-disj-type-configured") { is_pce_disj_type_configured = value; is_pce_disj_type_configured.value_namespace = name_space; is_pce_disj_type_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-disj-group-id-configured") { is_pce_disj_group_id_configured = value; is_pce_disj_group_id_configured.value_namespace = name_space; is_pce_disj_group_id_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "pcedp-source-address") { pcedp_source_address = value; pcedp_source_address.value_namespace = name_space; pcedp_source_address.value_namespace_prefix = name_space_prefix; } if(value_path == "pcedp-type") { pcedp_type = value; pcedp_type.value_namespace = name_space; pcedp_type.value_namespace_prefix = name_space_prefix; } if(value_path == "pcedp-group-id") { pcedp_group_id = value; pcedp_group_id.value_namespace = name_space; pcedp_group_id.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pceb-dj-source-configured") { is_pceb_dj_source_configured = value; is_pceb_dj_source_configured.value_namespace = name_space; is_pceb_dj_source_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pcebd-group-id-configured") { is_pcebd_group_id_configured = value; is_pcebd_group_id_configured.value_namespace = name_space; is_pcebd_group_id_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "pcebd-source-address") { pcebd_source_address = value; pcebd_source_address.value_namespace = name_space; pcebd_source_address.value_namespace_prefix = name_space_prefix; } if(value_path == "pcebd-group-id") { pcebd_group_id = value; pcebd_group_id.value_namespace = name_space; pcebd_group_id.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "is-affinity-configured") { is_affinity_configured.yfilter = yfilter; } if(value_path == "path-selection-segment-routing-adjacency-protection") { path_selection_segment_routing_adjacency_protection.yfilter = yfilter; } if(value_path == "is-path-selection-segment-routing-adjacency-protection-configured") { is_path_selection_segment_routing_adjacency_protection_configured.yfilter = yfilter; } if(value_path == "path-invalidation-timeout") { path_invalidation_timeout.yfilter = yfilter; } if(value_path == "path-selection-invalidation-action") { path_selection_invalidation_action.yfilter = yfilter; } if(value_path == "is-path-invalidation-timeout-configured") { is_path_invalidation_timeout_configured.yfilter = yfilter; } if(value_path == "is-path-invalidation-action-configured") { is_path_invalidation_action_configured.yfilter = yfilter; } if(value_path == "path-selection-metric") { path_selection_metric.yfilter = yfilter; } if(value_path == "is-path-selection-metric-configured") { is_path_selection_metric_configured.yfilter = yfilter; } if(value_path == "path-selection-segment-routing-margin") { path_selection_segment_routing_margin.yfilter = yfilter; } if(value_path == "is-path-selection-segment-routing-margin-relative") { is_path_selection_segment_routing_margin_relative.yfilter = yfilter; } if(value_path == "is-path-selection-segment-routing-margin-configured") { is_path_selection_segment_routing_margin_configured.yfilter = yfilter; } if(value_path == "path-selection-segment-routing-segment-limit") { path_selection_segment_routing_segment_limit.yfilter = yfilter; } if(value_path == "is-path-selection-segment-routing-segment-limit-configured") { is_path_selection_segment_routing_segment_limit_configured.yfilter = yfilter; } if(value_path == "is-path-select-configured") { is_path_select_configured.yfilter = yfilter; } if(value_path == "is-prepend-list-configured") { is_prepend_list_configured.yfilter = yfilter; } if(value_path == "is-pce-configured") { is_pce_configured.yfilter = yfilter; } if(value_path == "is-pce-disj-source-configured") { is_pce_disj_source_configured.yfilter = yfilter; } if(value_path == "is-pce-disj-type-configured") { is_pce_disj_type_configured.yfilter = yfilter; } if(value_path == "is-pce-disj-group-id-configured") { is_pce_disj_group_id_configured.yfilter = yfilter; } if(value_path == "pcedp-source-address") { pcedp_source_address.yfilter = yfilter; } if(value_path == "pcedp-type") { pcedp_type.yfilter = yfilter; } if(value_path == "pcedp-group-id") { pcedp_group_id.yfilter = yfilter; } if(value_path == "is-pceb-dj-source-configured") { is_pceb_dj_source_configured.yfilter = yfilter; } if(value_path == "is-pcebd-group-id-configured") { is_pcebd_group_id_configured.yfilter = yfilter; } if(value_path == "pcebd-source-address") { pcebd_source_address.yfilter = yfilter; } if(value_path == "pcebd-group-id") { pcebd_group_id.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::has_leaf_or_child_of_name(const std::string & name) const { if(name == "affinity" || name == "logging" || name == "prepend-list" || name == "tunnel-id" || name == "is-affinity-configured" || name == "path-selection-segment-routing-adjacency-protection" || name == "is-path-selection-segment-routing-adjacency-protection-configured" || name == "path-invalidation-timeout" || name == "path-selection-invalidation-action" || name == "is-path-invalidation-timeout-configured" || name == "is-path-invalidation-action-configured" || name == "path-selection-metric" || name == "is-path-selection-metric-configured" || name == "path-selection-segment-routing-margin" || name == "is-path-selection-segment-routing-margin-relative" || name == "is-path-selection-segment-routing-margin-configured" || name == "path-selection-segment-routing-segment-limit" || name == "is-path-selection-segment-routing-segment-limit-configured" || name == "is-path-select-configured" || name == "is-prepend-list-configured" || name == "is-pce-configured" || name == "is-pce-disj-source-configured" || name == "is-pce-disj-type-configured" || name == "is-pce-disj-group-id-configured" || name == "pcedp-source-address" || name == "pcedp-type" || name == "pcedp-group-id" || name == "is-pceb-dj-source-configured" || name == "is-pcebd-group-id-configured" || name == "pcebd-source-address" || name == "pcebd-group-id") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::Affinity() : affinity_bits{YType::uint32, "affinity-bits"}, affinity_mask{YType::uint32, "affinity-mask"} , named_affinity(this, {}) { yang_name = "affinity"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::~Affinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_data()) return true; } return affinity_bits.is_set || affinity_mask.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::has_operation() const { for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(affinity_bits.yfilter) || ydk::is_set(affinity_mask.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "affinity"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata()); if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "named-affinity") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity>(); ent_->parent = this; named_affinity.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : named_affinity.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::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 == "affinity-bits") { affinity_bits = value; affinity_bits.value_namespace = name_space; affinity_bits.value_namespace_prefix = name_space_prefix; } if(value_path == "affinity-mask") { affinity_mask = value; affinity_mask.value_namespace = name_space; affinity_mask.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "affinity-bits") { affinity_bits.yfilter = yfilter; } if(value_path == "affinity-mask") { affinity_mask.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::NamedAffinity() : constraint_type{YType::uint8, "constraint-type"}, constraint_value{YType::uint32, "constraint-value"}, forward_ref_value{YType::uint32, "forward-ref-value"} , constraint_extended_value(this, {}) , extended_forward_ref_value(this, {}) { yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::~NamedAffinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_data()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_data()) return true; } return constraint_type.is_set || constraint_value.is_set || forward_ref_value.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::has_operation() const { for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_operation()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(constraint_type.yfilter) || ydk::is_set(constraint_value.yfilter) || ydk::is_set(forward_ref_value.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "named-affinity"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata()); if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata()); if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "constraint-extended-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue>(); ent_->parent = this; constraint_extended_value.append(ent_); return ent_; } if(child_yang_name == "extended-forward-ref-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue>(); ent_->parent = this; extended_forward_ref_value.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : constraint_extended_value.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_ : extended_forward_ref_value.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::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 == "constraint-type") { constraint_type = value; constraint_type.value_namespace = name_space; constraint_type.value_namespace_prefix = name_space_prefix; } if(value_path == "constraint-value") { constraint_value = value; constraint_value.value_namespace = name_space; constraint_value.value_namespace_prefix = name_space_prefix; } if(value_path == "forward-ref-value") { forward_ref_value = value; forward_ref_value.value_namespace = name_space; forward_ref_value.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "constraint-type") { constraint_type.yfilter = yfilter; } if(value_path == "constraint-value") { constraint_value.yfilter = yfilter; } if(value_path == "forward-ref-value") { forward_ref_value.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue() : entry{YType::uint32, "entry"} { yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "constraint-extended-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue() : entry{YType::uint32, "entry"} { yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "extended-forward-ref-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::Logging() : lsp_state{YType::boolean, "lsp-state"}, s2l_state{YType::boolean, "s2l-state"}, lsp_re_route{YType::boolean, "lsp-re-route"}, lsp_re_opt{YType::boolean, "lsp-re-opt"}, lsp_insufficient_bw{YType::boolean, "lsp-insufficient-bw"}, lsp_bandwidth_change{YType::boolean, "lsp-bandwidth-change"}, lsp_pcalc_failure_logging_enabled{YType::boolean, "lsp-pcalc-failure-logging-enabled"}, all_logging_enabled{YType::boolean, "all-logging-enabled"} { yang_name = "logging"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::~Logging() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::has_data() const { if (is_presence_container) return true; return lsp_state.is_set || s2l_state.is_set || lsp_re_route.is_set || lsp_re_opt.is_set || lsp_insufficient_bw.is_set || lsp_bandwidth_change.is_set || lsp_pcalc_failure_logging_enabled.is_set || all_logging_enabled.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::has_operation() const { return is_set(yfilter) || ydk::is_set(lsp_state.yfilter) || ydk::is_set(s2l_state.yfilter) || ydk::is_set(lsp_re_route.yfilter) || ydk::is_set(lsp_re_opt.yfilter) || ydk::is_set(lsp_insufficient_bw.yfilter) || ydk::is_set(lsp_bandwidth_change.yfilter) || ydk::is_set(lsp_pcalc_failure_logging_enabled.yfilter) || ydk::is_set(all_logging_enabled.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "logging"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (lsp_state.is_set || is_set(lsp_state.yfilter)) leaf_name_data.push_back(lsp_state.get_name_leafdata()); if (s2l_state.is_set || is_set(s2l_state.yfilter)) leaf_name_data.push_back(s2l_state.get_name_leafdata()); if (lsp_re_route.is_set || is_set(lsp_re_route.yfilter)) leaf_name_data.push_back(lsp_re_route.get_name_leafdata()); if (lsp_re_opt.is_set || is_set(lsp_re_opt.yfilter)) leaf_name_data.push_back(lsp_re_opt.get_name_leafdata()); if (lsp_insufficient_bw.is_set || is_set(lsp_insufficient_bw.yfilter)) leaf_name_data.push_back(lsp_insufficient_bw.get_name_leafdata()); if (lsp_bandwidth_change.is_set || is_set(lsp_bandwidth_change.yfilter)) leaf_name_data.push_back(lsp_bandwidth_change.get_name_leafdata()); if (lsp_pcalc_failure_logging_enabled.is_set || is_set(lsp_pcalc_failure_logging_enabled.yfilter)) leaf_name_data.push_back(lsp_pcalc_failure_logging_enabled.get_name_leafdata()); if (all_logging_enabled.is_set || is_set(all_logging_enabled.yfilter)) leaf_name_data.push_back(all_logging_enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::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 == "lsp-state") { lsp_state = value; lsp_state.value_namespace = name_space; lsp_state.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-state") { s2l_state = value; s2l_state.value_namespace = name_space; s2l_state.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-re-route") { lsp_re_route = value; lsp_re_route.value_namespace = name_space; lsp_re_route.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-re-opt") { lsp_re_opt = value; lsp_re_opt.value_namespace = name_space; lsp_re_opt.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-insufficient-bw") { lsp_insufficient_bw = value; lsp_insufficient_bw.value_namespace = name_space; lsp_insufficient_bw.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-bandwidth-change") { lsp_bandwidth_change = value; lsp_bandwidth_change.value_namespace = name_space; lsp_bandwidth_change.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-pcalc-failure-logging-enabled") { lsp_pcalc_failure_logging_enabled = value; lsp_pcalc_failure_logging_enabled.value_namespace = name_space; lsp_pcalc_failure_logging_enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "all-logging-enabled") { all_logging_enabled = value; all_logging_enabled.value_namespace = name_space; all_logging_enabled.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "lsp-state") { lsp_state.yfilter = yfilter; } if(value_path == "s2l-state") { s2l_state.yfilter = yfilter; } if(value_path == "lsp-re-route") { lsp_re_route.yfilter = yfilter; } if(value_path == "lsp-re-opt") { lsp_re_opt.yfilter = yfilter; } if(value_path == "lsp-insufficient-bw") { lsp_insufficient_bw.yfilter = yfilter; } if(value_path == "lsp-bandwidth-change") { lsp_bandwidth_change.yfilter = yfilter; } if(value_path == "lsp-pcalc-failure-logging-enabled") { lsp_pcalc_failure_logging_enabled.yfilter = yfilter; } if(value_path == "all-logging-enabled") { all_logging_enabled.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::has_leaf_or_child_of_name(const std::string & name) const { if(name == "lsp-state" || name == "s2l-state" || name == "lsp-re-route" || name == "lsp-re-opt" || name == "lsp-insufficient-bw" || name == "lsp-bandwidth-change" || name == "lsp-pcalc-failure-logging-enabled" || name == "all-logging-enabled") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependList() : prepend_entry(this, {}) { yang_name = "prepend-list"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::~PrependList() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<prepend_entry.len(); index++) { if(prepend_entry[index]->has_data()) return true; } return false; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::has_operation() const { for (std::size_t index=0; index<prepend_entry.len(); index++) { if(prepend_entry[index]->has_operation()) return true; } return is_set(yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prepend-list"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prepend-entry") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry>(); ent_->parent = this; prepend_entry.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : prepend_entry.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::set_filter(const std::string & value_path, YFilter yfilter) { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prepend-entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::PrependEntry() : type{YType::enumeration, "type"}, index_{YType::uint32, "index"}, next_label{YType::uint32, "next-label"} { yang_name = "prepend-entry"; yang_parent_name = "prepend-list"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::~PrependEntry() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::has_data() const { if (is_presence_container) return true; return type.is_set || index_.is_set || next_label.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::has_operation() const { return is_set(yfilter) || ydk::is_set(type.yfilter) || ydk::is_set(index_.yfilter) || ydk::is_set(next_label.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prepend-entry"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata()); if (index_.is_set || is_set(index_.yfilter)) leaf_name_data.push_back(index_.get_name_leafdata()); if (next_label.is_set || is_set(next_label.yfilter)) leaf_name_data.push_back(next_label.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::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 == "type") { type = value; type.value_namespace = name_space; type.value_namespace_prefix = name_space_prefix; } if(value_path == "index") { index_ = value; index_.value_namespace = name_space; index_.value_namespace_prefix = name_space_prefix; } if(value_path == "next-label") { next_label = value; next_label.value_namespace = name_space; next_label.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "type") { type.yfilter = yfilter; } if(value_path == "index") { index_.yfilter = yfilter; } if(value_path == "next-label") { next_label.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::has_leaf_or_child_of_name(const std::string & name) const { if(name == "type" || name == "index" || name == "next-label") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::TunnelId() : entry{YType::uint16, "entry"} { yang_name = "tunnel-id"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::~TunnelId() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "tunnel-id"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::AttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::XroAttributeSet() : tunnel_attribute_set_name{YType::str, "tunnel-attribute-set-name"}, tunnel_attribute_set_name_crc32{YType::uint32, "tunnel-attribute-set-name-crc32"} , attribute_set_union(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion>()) { attribute_set_union->parent = this; yang_name = "xro-attribute-set"; yang_parent_name = "active-path-option"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::~XroAttributeSet() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::has_data() const { if (is_presence_container) return true; return tunnel_attribute_set_name.is_set || tunnel_attribute_set_name_crc32.is_set || (attribute_set_union != nullptr && attribute_set_union->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::has_operation() const { return is_set(yfilter) || ydk::is_set(tunnel_attribute_set_name.yfilter) || ydk::is_set(tunnel_attribute_set_name_crc32.yfilter) || (attribute_set_union != nullptr && attribute_set_union->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "xro-attribute-set"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (tunnel_attribute_set_name.is_set || is_set(tunnel_attribute_set_name.yfilter)) leaf_name_data.push_back(tunnel_attribute_set_name.get_name_leafdata()); if (tunnel_attribute_set_name_crc32.is_set || is_set(tunnel_attribute_set_name_crc32.yfilter)) leaf_name_data.push_back(tunnel_attribute_set_name_crc32.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "attribute-set-union") { if(attribute_set_union == nullptr) { attribute_set_union = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion>(); } return attribute_set_union; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(attribute_set_union != nullptr) { _children["attribute-set-union"] = attribute_set_union; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::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 == "tunnel-attribute-set-name") { tunnel_attribute_set_name = value; tunnel_attribute_set_name.value_namespace = name_space; tunnel_attribute_set_name.value_namespace_prefix = name_space_prefix; } if(value_path == "tunnel-attribute-set-name-crc32") { tunnel_attribute_set_name_crc32 = value; tunnel_attribute_set_name_crc32.value_namespace = name_space; tunnel_attribute_set_name_crc32.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "tunnel-attribute-set-name") { tunnel_attribute_set_name.yfilter = yfilter; } if(value_path == "tunnel-attribute-set-name-crc32") { tunnel_attribute_set_name_crc32.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::has_leaf_or_child_of_name(const std::string & name) const { if(name == "attribute-set-union" || name == "tunnel-attribute-set-name" || name == "tunnel-attribute-set-name-crc32") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetUnion() : tunnel_attribute_set_type{YType::enumeration, "tunnel-attribute-set-type"} , attribute_set_path_option(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption>()) , attribute_set_autobackup(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup>()) , attribute_set_automesh(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh>()) , attribute_set_xro(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro>()) , attribute_set_p2mpte(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte>()) , attribute_set_aps_pp(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp>()) , attribute_set_p2p_te(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe>()) { attribute_set_path_option->parent = this; attribute_set_autobackup->parent = this; attribute_set_automesh->parent = this; attribute_set_xro->parent = this; attribute_set_p2mpte->parent = this; attribute_set_aps_pp->parent = this; attribute_set_p2p_te->parent = this; yang_name = "attribute-set-union"; yang_parent_name = "xro-attribute-set"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::~AttributeSetUnion() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::has_data() const { if (is_presence_container) return true; return tunnel_attribute_set_type.is_set || (attribute_set_path_option != nullptr && attribute_set_path_option->has_data()) || (attribute_set_autobackup != nullptr && attribute_set_autobackup->has_data()) || (attribute_set_automesh != nullptr && attribute_set_automesh->has_data()) || (attribute_set_xro != nullptr && attribute_set_xro->has_data()) || (attribute_set_p2mpte != nullptr && attribute_set_p2mpte->has_data()) || (attribute_set_aps_pp != nullptr && attribute_set_aps_pp->has_data()) || (attribute_set_p2p_te != nullptr && attribute_set_p2p_te->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::has_operation() const { return is_set(yfilter) || ydk::is_set(tunnel_attribute_set_type.yfilter) || (attribute_set_path_option != nullptr && attribute_set_path_option->has_operation()) || (attribute_set_autobackup != nullptr && attribute_set_autobackup->has_operation()) || (attribute_set_automesh != nullptr && attribute_set_automesh->has_operation()) || (attribute_set_xro != nullptr && attribute_set_xro->has_operation()) || (attribute_set_p2mpte != nullptr && attribute_set_p2mpte->has_operation()) || (attribute_set_aps_pp != nullptr && attribute_set_aps_pp->has_operation()) || (attribute_set_p2p_te != nullptr && attribute_set_p2p_te->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-union"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (tunnel_attribute_set_type.is_set || is_set(tunnel_attribute_set_type.yfilter)) leaf_name_data.push_back(tunnel_attribute_set_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "attribute-set-path-option") { if(attribute_set_path_option == nullptr) { attribute_set_path_option = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption>(); } return attribute_set_path_option; } if(child_yang_name == "attribute-set-autobackup") { if(attribute_set_autobackup == nullptr) { attribute_set_autobackup = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup>(); } return attribute_set_autobackup; } if(child_yang_name == "attribute-set-automesh") { if(attribute_set_automesh == nullptr) { attribute_set_automesh = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh>(); } return attribute_set_automesh; } if(child_yang_name == "attribute-set-xro") { if(attribute_set_xro == nullptr) { attribute_set_xro = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro>(); } return attribute_set_xro; } if(child_yang_name == "attribute-set-p2mpte") { if(attribute_set_p2mpte == nullptr) { attribute_set_p2mpte = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte>(); } return attribute_set_p2mpte; } if(child_yang_name == "attribute-set-aps-pp") { if(attribute_set_aps_pp == nullptr) { attribute_set_aps_pp = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp>(); } return attribute_set_aps_pp; } if(child_yang_name == "attribute-set-p2p-te") { if(attribute_set_p2p_te == nullptr) { attribute_set_p2p_te = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe>(); } return attribute_set_p2p_te; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(attribute_set_path_option != nullptr) { _children["attribute-set-path-option"] = attribute_set_path_option; } if(attribute_set_autobackup != nullptr) { _children["attribute-set-autobackup"] = attribute_set_autobackup; } if(attribute_set_automesh != nullptr) { _children["attribute-set-automesh"] = attribute_set_automesh; } if(attribute_set_xro != nullptr) { _children["attribute-set-xro"] = attribute_set_xro; } if(attribute_set_p2mpte != nullptr) { _children["attribute-set-p2mpte"] = attribute_set_p2mpte; } if(attribute_set_aps_pp != nullptr) { _children["attribute-set-aps-pp"] = attribute_set_aps_pp; } if(attribute_set_p2p_te != nullptr) { _children["attribute-set-p2p-te"] = attribute_set_p2p_te; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::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 == "tunnel-attribute-set-type") { tunnel_attribute_set_type = value; tunnel_attribute_set_type.value_namespace = name_space; tunnel_attribute_set_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "tunnel-attribute-set-type") { tunnel_attribute_set_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::has_leaf_or_child_of_name(const std::string & name) const { if(name == "attribute-set-path-option" || name == "attribute-set-autobackup" || name == "attribute-set-automesh" || name == "attribute-set-xro" || name == "attribute-set-p2mpte" || name == "attribute-set-aps-pp" || name == "attribute-set-p2p-te" || name == "tunnel-attribute-set-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::AttributeSetPathOption() : configured_bandwidth{YType::uint32, "configured-bandwidth"}, cost_limit{YType::uint32, "cost-limit"}, dste_class_type{YType::uint8, "dste-class-type"}, bandwidth_type{YType::enumeration, "bandwidth-type"}, is_bandwidth_configured{YType::boolean, "is-bandwidth-configured"}, is_cost_limit_configured{YType::boolean, "is-cost-limit-configured"}, is_affinity_configured{YType::boolean, "is-affinity-configured"}, generation{YType::uint32, "generation"}, path_invalidation_timeout{YType::uint32, "path-invalidation-timeout"}, path_invalidation_action{YType::uint32, "path-invalidation-action"}, is_path_invalidation_timeout_configured{YType::boolean, "is-path-invalidation-timeout-configured"}, is_path_invalidation_action_configured{YType::boolean, "is-path-invalidation-action-configured"}, exclude_list_name{YType::str, "exclude-list-name"}, is_exclude_list_name_configured{YType::boolean, "is-exclude-list-name-configured"}, is_pce_configured{YType::boolean, "is-pce-configured"}, is_pce_disj_source_configured{YType::boolean, "is-pce-disj-source-configured"}, is_pce_disj_type_configured{YType::boolean, "is-pce-disj-type-configured"}, is_pce_disj_group_id_configured{YType::boolean, "is-pce-disj-group-id-configured"}, pcedp_source_address{YType::uint32, "pcedp-source-address"}, pcedp_type{YType::enumeration, "pcedp-type"}, pcedp_group_id{YType::uint32, "pcedp-group-id"}, is_pceb_dj_source_configured{YType::boolean, "is-pceb-dj-source-configured"}, is_pcebd_group_id_configured{YType::boolean, "is-pcebd-group-id-configured"}, pcebd_source_address{YType::uint32, "pcebd-source-address"}, pcebd_group_id{YType::uint32, "pcebd-group-id"}, is_bfd_reverse_pat_configured{YType::boolean, "is-bfd-reverse-pat-configured"}, is_delay_limit_configured{YType::boolean, "is-delay-limit-configured"}, delay_limit{YType::uint32, "delay-limit"} , affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity>()) , bfd_reverse_path(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath>()) , tunnel_id(this, {}) , version_info(this, {}) { affinity->parent = this; bfd_reverse_path->parent = this; yang_name = "attribute-set-path-option"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::~AttributeSetPathOption() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_data()) return true; } for (std::size_t index=0; index<version_info.len(); index++) { if(version_info[index]->has_data()) return true; } return configured_bandwidth.is_set || cost_limit.is_set || dste_class_type.is_set || bandwidth_type.is_set || is_bandwidth_configured.is_set || is_cost_limit_configured.is_set || is_affinity_configured.is_set || generation.is_set || path_invalidation_timeout.is_set || path_invalidation_action.is_set || is_path_invalidation_timeout_configured.is_set || is_path_invalidation_action_configured.is_set || exclude_list_name.is_set || is_exclude_list_name_configured.is_set || is_pce_configured.is_set || is_pce_disj_source_configured.is_set || is_pce_disj_type_configured.is_set || is_pce_disj_group_id_configured.is_set || pcedp_source_address.is_set || pcedp_type.is_set || pcedp_group_id.is_set || is_pceb_dj_source_configured.is_set || is_pcebd_group_id_configured.is_set || pcebd_source_address.is_set || pcebd_group_id.is_set || is_bfd_reverse_pat_configured.is_set || is_delay_limit_configured.is_set || delay_limit.is_set || (affinity != nullptr && affinity->has_data()) || (bfd_reverse_path != nullptr && bfd_reverse_path->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::has_operation() const { for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_operation()) return true; } for (std::size_t index=0; index<version_info.len(); index++) { if(version_info[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(configured_bandwidth.yfilter) || ydk::is_set(cost_limit.yfilter) || ydk::is_set(dste_class_type.yfilter) || ydk::is_set(bandwidth_type.yfilter) || ydk::is_set(is_bandwidth_configured.yfilter) || ydk::is_set(is_cost_limit_configured.yfilter) || ydk::is_set(is_affinity_configured.yfilter) || ydk::is_set(generation.yfilter) || ydk::is_set(path_invalidation_timeout.yfilter) || ydk::is_set(path_invalidation_action.yfilter) || ydk::is_set(is_path_invalidation_timeout_configured.yfilter) || ydk::is_set(is_path_invalidation_action_configured.yfilter) || ydk::is_set(exclude_list_name.yfilter) || ydk::is_set(is_exclude_list_name_configured.yfilter) || ydk::is_set(is_pce_configured.yfilter) || ydk::is_set(is_pce_disj_source_configured.yfilter) || ydk::is_set(is_pce_disj_type_configured.yfilter) || ydk::is_set(is_pce_disj_group_id_configured.yfilter) || ydk::is_set(pcedp_source_address.yfilter) || ydk::is_set(pcedp_type.yfilter) || ydk::is_set(pcedp_group_id.yfilter) || ydk::is_set(is_pceb_dj_source_configured.yfilter) || ydk::is_set(is_pcebd_group_id_configured.yfilter) || ydk::is_set(pcebd_source_address.yfilter) || ydk::is_set(pcebd_group_id.yfilter) || ydk::is_set(is_bfd_reverse_pat_configured.yfilter) || ydk::is_set(is_delay_limit_configured.yfilter) || ydk::is_set(delay_limit.yfilter) || (affinity != nullptr && affinity->has_operation()) || (bfd_reverse_path != nullptr && bfd_reverse_path->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-path-option"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (configured_bandwidth.is_set || is_set(configured_bandwidth.yfilter)) leaf_name_data.push_back(configured_bandwidth.get_name_leafdata()); if (cost_limit.is_set || is_set(cost_limit.yfilter)) leaf_name_data.push_back(cost_limit.get_name_leafdata()); if (dste_class_type.is_set || is_set(dste_class_type.yfilter)) leaf_name_data.push_back(dste_class_type.get_name_leafdata()); if (bandwidth_type.is_set || is_set(bandwidth_type.yfilter)) leaf_name_data.push_back(bandwidth_type.get_name_leafdata()); if (is_bandwidth_configured.is_set || is_set(is_bandwidth_configured.yfilter)) leaf_name_data.push_back(is_bandwidth_configured.get_name_leafdata()); if (is_cost_limit_configured.is_set || is_set(is_cost_limit_configured.yfilter)) leaf_name_data.push_back(is_cost_limit_configured.get_name_leafdata()); if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata()); if (generation.is_set || is_set(generation.yfilter)) leaf_name_data.push_back(generation.get_name_leafdata()); if (path_invalidation_timeout.is_set || is_set(path_invalidation_timeout.yfilter)) leaf_name_data.push_back(path_invalidation_timeout.get_name_leafdata()); if (path_invalidation_action.is_set || is_set(path_invalidation_action.yfilter)) leaf_name_data.push_back(path_invalidation_action.get_name_leafdata()); if (is_path_invalidation_timeout_configured.is_set || is_set(is_path_invalidation_timeout_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_timeout_configured.get_name_leafdata()); if (is_path_invalidation_action_configured.is_set || is_set(is_path_invalidation_action_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_action_configured.get_name_leafdata()); if (exclude_list_name.is_set || is_set(exclude_list_name.yfilter)) leaf_name_data.push_back(exclude_list_name.get_name_leafdata()); if (is_exclude_list_name_configured.is_set || is_set(is_exclude_list_name_configured.yfilter)) leaf_name_data.push_back(is_exclude_list_name_configured.get_name_leafdata()); if (is_pce_configured.is_set || is_set(is_pce_configured.yfilter)) leaf_name_data.push_back(is_pce_configured.get_name_leafdata()); if (is_pce_disj_source_configured.is_set || is_set(is_pce_disj_source_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_source_configured.get_name_leafdata()); if (is_pce_disj_type_configured.is_set || is_set(is_pce_disj_type_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_type_configured.get_name_leafdata()); if (is_pce_disj_group_id_configured.is_set || is_set(is_pce_disj_group_id_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_group_id_configured.get_name_leafdata()); if (pcedp_source_address.is_set || is_set(pcedp_source_address.yfilter)) leaf_name_data.push_back(pcedp_source_address.get_name_leafdata()); if (pcedp_type.is_set || is_set(pcedp_type.yfilter)) leaf_name_data.push_back(pcedp_type.get_name_leafdata()); if (pcedp_group_id.is_set || is_set(pcedp_group_id.yfilter)) leaf_name_data.push_back(pcedp_group_id.get_name_leafdata()); if (is_pceb_dj_source_configured.is_set || is_set(is_pceb_dj_source_configured.yfilter)) leaf_name_data.push_back(is_pceb_dj_source_configured.get_name_leafdata()); if (is_pcebd_group_id_configured.is_set || is_set(is_pcebd_group_id_configured.yfilter)) leaf_name_data.push_back(is_pcebd_group_id_configured.get_name_leafdata()); if (pcebd_source_address.is_set || is_set(pcebd_source_address.yfilter)) leaf_name_data.push_back(pcebd_source_address.get_name_leafdata()); if (pcebd_group_id.is_set || is_set(pcebd_group_id.yfilter)) leaf_name_data.push_back(pcebd_group_id.get_name_leafdata()); if (is_bfd_reverse_pat_configured.is_set || is_set(is_bfd_reverse_pat_configured.yfilter)) leaf_name_data.push_back(is_bfd_reverse_pat_configured.get_name_leafdata()); if (is_delay_limit_configured.is_set || is_set(is_delay_limit_configured.yfilter)) leaf_name_data.push_back(is_delay_limit_configured.get_name_leafdata()); if (delay_limit.is_set || is_set(delay_limit.yfilter)) leaf_name_data.push_back(delay_limit.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "affinity") { if(affinity == nullptr) { affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity>(); } return affinity; } if(child_yang_name == "bfd-reverse-path") { if(bfd_reverse_path == nullptr) { bfd_reverse_path = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath>(); } return bfd_reverse_path; } if(child_yang_name == "tunnel-id") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId>(); ent_->parent = this; tunnel_id.append(ent_); return ent_; } if(child_yang_name == "version-info") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo>(); ent_->parent = this; version_info.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(affinity != nullptr) { _children["affinity"] = affinity; } if(bfd_reverse_path != nullptr) { _children["bfd-reverse-path"] = bfd_reverse_path; } count_ = 0; for (auto ent_ : tunnel_id.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_ : version_info.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::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 == "configured-bandwidth") { configured_bandwidth = value; configured_bandwidth.value_namespace = name_space; configured_bandwidth.value_namespace_prefix = name_space_prefix; } if(value_path == "cost-limit") { cost_limit = value; cost_limit.value_namespace = name_space; cost_limit.value_namespace_prefix = name_space_prefix; } if(value_path == "dste-class-type") { dste_class_type = value; dste_class_type.value_namespace = name_space; dste_class_type.value_namespace_prefix = name_space_prefix; } if(value_path == "bandwidth-type") { bandwidth_type = value; bandwidth_type.value_namespace = name_space; bandwidth_type.value_namespace_prefix = name_space_prefix; } if(value_path == "is-bandwidth-configured") { is_bandwidth_configured = value; is_bandwidth_configured.value_namespace = name_space; is_bandwidth_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-cost-limit-configured") { is_cost_limit_configured = value; is_cost_limit_configured.value_namespace = name_space; is_cost_limit_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-affinity-configured") { is_affinity_configured = value; is_affinity_configured.value_namespace = name_space; is_affinity_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "generation") { generation = value; generation.value_namespace = name_space; generation.value_namespace_prefix = name_space_prefix; } if(value_path == "path-invalidation-timeout") { path_invalidation_timeout = value; path_invalidation_timeout.value_namespace = name_space; path_invalidation_timeout.value_namespace_prefix = name_space_prefix; } if(value_path == "path-invalidation-action") { path_invalidation_action = value; path_invalidation_action.value_namespace = name_space; path_invalidation_action.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-invalidation-timeout-configured") { is_path_invalidation_timeout_configured = value; is_path_invalidation_timeout_configured.value_namespace = name_space; is_path_invalidation_timeout_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-invalidation-action-configured") { is_path_invalidation_action_configured = value; is_path_invalidation_action_configured.value_namespace = name_space; is_path_invalidation_action_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "exclude-list-name") { exclude_list_name = value; exclude_list_name.value_namespace = name_space; exclude_list_name.value_namespace_prefix = name_space_prefix; } if(value_path == "is-exclude-list-name-configured") { is_exclude_list_name_configured = value; is_exclude_list_name_configured.value_namespace = name_space; is_exclude_list_name_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-configured") { is_pce_configured = value; is_pce_configured.value_namespace = name_space; is_pce_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-disj-source-configured") { is_pce_disj_source_configured = value; is_pce_disj_source_configured.value_namespace = name_space; is_pce_disj_source_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-disj-type-configured") { is_pce_disj_type_configured = value; is_pce_disj_type_configured.value_namespace = name_space; is_pce_disj_type_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-disj-group-id-configured") { is_pce_disj_group_id_configured = value; is_pce_disj_group_id_configured.value_namespace = name_space; is_pce_disj_group_id_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "pcedp-source-address") { pcedp_source_address = value; pcedp_source_address.value_namespace = name_space; pcedp_source_address.value_namespace_prefix = name_space_prefix; } if(value_path == "pcedp-type") { pcedp_type = value; pcedp_type.value_namespace = name_space; pcedp_type.value_namespace_prefix = name_space_prefix; } if(value_path == "pcedp-group-id") { pcedp_group_id = value; pcedp_group_id.value_namespace = name_space; pcedp_group_id.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pceb-dj-source-configured") { is_pceb_dj_source_configured = value; is_pceb_dj_source_configured.value_namespace = name_space; is_pceb_dj_source_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pcebd-group-id-configured") { is_pcebd_group_id_configured = value; is_pcebd_group_id_configured.value_namespace = name_space; is_pcebd_group_id_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "pcebd-source-address") { pcebd_source_address = value; pcebd_source_address.value_namespace = name_space; pcebd_source_address.value_namespace_prefix = name_space_prefix; } if(value_path == "pcebd-group-id") { pcebd_group_id = value; pcebd_group_id.value_namespace = name_space; pcebd_group_id.value_namespace_prefix = name_space_prefix; } if(value_path == "is-bfd-reverse-pat-configured") { is_bfd_reverse_pat_configured = value; is_bfd_reverse_pat_configured.value_namespace = name_space; is_bfd_reverse_pat_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-delay-limit-configured") { is_delay_limit_configured = value; is_delay_limit_configured.value_namespace = name_space; is_delay_limit_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "delay-limit") { delay_limit = value; delay_limit.value_namespace = name_space; delay_limit.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "configured-bandwidth") { configured_bandwidth.yfilter = yfilter; } if(value_path == "cost-limit") { cost_limit.yfilter = yfilter; } if(value_path == "dste-class-type") { dste_class_type.yfilter = yfilter; } if(value_path == "bandwidth-type") { bandwidth_type.yfilter = yfilter; } if(value_path == "is-bandwidth-configured") { is_bandwidth_configured.yfilter = yfilter; } if(value_path == "is-cost-limit-configured") { is_cost_limit_configured.yfilter = yfilter; } if(value_path == "is-affinity-configured") { is_affinity_configured.yfilter = yfilter; } if(value_path == "generation") { generation.yfilter = yfilter; } if(value_path == "path-invalidation-timeout") { path_invalidation_timeout.yfilter = yfilter; } if(value_path == "path-invalidation-action") { path_invalidation_action.yfilter = yfilter; } if(value_path == "is-path-invalidation-timeout-configured") { is_path_invalidation_timeout_configured.yfilter = yfilter; } if(value_path == "is-path-invalidation-action-configured") { is_path_invalidation_action_configured.yfilter = yfilter; } if(value_path == "exclude-list-name") { exclude_list_name.yfilter = yfilter; } if(value_path == "is-exclude-list-name-configured") { is_exclude_list_name_configured.yfilter = yfilter; } if(value_path == "is-pce-configured") { is_pce_configured.yfilter = yfilter; } if(value_path == "is-pce-disj-source-configured") { is_pce_disj_source_configured.yfilter = yfilter; } if(value_path == "is-pce-disj-type-configured") { is_pce_disj_type_configured.yfilter = yfilter; } if(value_path == "is-pce-disj-group-id-configured") { is_pce_disj_group_id_configured.yfilter = yfilter; } if(value_path == "pcedp-source-address") { pcedp_source_address.yfilter = yfilter; } if(value_path == "pcedp-type") { pcedp_type.yfilter = yfilter; } if(value_path == "pcedp-group-id") { pcedp_group_id.yfilter = yfilter; } if(value_path == "is-pceb-dj-source-configured") { is_pceb_dj_source_configured.yfilter = yfilter; } if(value_path == "is-pcebd-group-id-configured") { is_pcebd_group_id_configured.yfilter = yfilter; } if(value_path == "pcebd-source-address") { pcebd_source_address.yfilter = yfilter; } if(value_path == "pcebd-group-id") { pcebd_group_id.yfilter = yfilter; } if(value_path == "is-bfd-reverse-pat-configured") { is_bfd_reverse_pat_configured.yfilter = yfilter; } if(value_path == "is-delay-limit-configured") { is_delay_limit_configured.yfilter = yfilter; } if(value_path == "delay-limit") { delay_limit.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::has_leaf_or_child_of_name(const std::string & name) const { if(name == "affinity" || name == "bfd-reverse-path" || name == "tunnel-id" || name == "version-info" || name == "configured-bandwidth" || name == "cost-limit" || name == "dste-class-type" || name == "bandwidth-type" || name == "is-bandwidth-configured" || name == "is-cost-limit-configured" || name == "is-affinity-configured" || name == "generation" || name == "path-invalidation-timeout" || name == "path-invalidation-action" || name == "is-path-invalidation-timeout-configured" || name == "is-path-invalidation-action-configured" || name == "exclude-list-name" || name == "is-exclude-list-name-configured" || name == "is-pce-configured" || name == "is-pce-disj-source-configured" || name == "is-pce-disj-type-configured" || name == "is-pce-disj-group-id-configured" || name == "pcedp-source-address" || name == "pcedp-type" || name == "pcedp-group-id" || name == "is-pceb-dj-source-configured" || name == "is-pcebd-group-id-configured" || name == "pcebd-source-address" || name == "pcebd-group-id" || name == "is-bfd-reverse-pat-configured" || name == "is-delay-limit-configured" || name == "delay-limit") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::Affinity() : affinity_bits{YType::uint32, "affinity-bits"}, affinity_mask{YType::uint32, "affinity-mask"} , named_affinity(this, {}) { yang_name = "affinity"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::~Affinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_data()) return true; } return affinity_bits.is_set || affinity_mask.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::has_operation() const { for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(affinity_bits.yfilter) || ydk::is_set(affinity_mask.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "affinity"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata()); if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "named-affinity") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity>(); ent_->parent = this; named_affinity.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : named_affinity.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::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 == "affinity-bits") { affinity_bits = value; affinity_bits.value_namespace = name_space; affinity_bits.value_namespace_prefix = name_space_prefix; } if(value_path == "affinity-mask") { affinity_mask = value; affinity_mask.value_namespace = name_space; affinity_mask.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "affinity-bits") { affinity_bits.yfilter = yfilter; } if(value_path == "affinity-mask") { affinity_mask.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::NamedAffinity() : constraint_type{YType::uint8, "constraint-type"}, constraint_value{YType::uint32, "constraint-value"}, forward_ref_value{YType::uint32, "forward-ref-value"} , constraint_extended_value(this, {}) , extended_forward_ref_value(this, {}) { yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::~NamedAffinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_data()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_data()) return true; } return constraint_type.is_set || constraint_value.is_set || forward_ref_value.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::has_operation() const { for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_operation()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(constraint_type.yfilter) || ydk::is_set(constraint_value.yfilter) || ydk::is_set(forward_ref_value.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "named-affinity"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata()); if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata()); if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "constraint-extended-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue>(); ent_->parent = this; constraint_extended_value.append(ent_); return ent_; } if(child_yang_name == "extended-forward-ref-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue>(); ent_->parent = this; extended_forward_ref_value.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : constraint_extended_value.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_ : extended_forward_ref_value.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::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 == "constraint-type") { constraint_type = value; constraint_type.value_namespace = name_space; constraint_type.value_namespace_prefix = name_space_prefix; } if(value_path == "constraint-value") { constraint_value = value; constraint_value.value_namespace = name_space; constraint_value.value_namespace_prefix = name_space_prefix; } if(value_path == "forward-ref-value") { forward_ref_value = value; forward_ref_value.value_namespace = name_space; forward_ref_value.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "constraint-type") { constraint_type.yfilter = yfilter; } if(value_path == "constraint-value") { constraint_value.yfilter = yfilter; } if(value_path == "forward-ref-value") { forward_ref_value.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue() : entry{YType::uint32, "entry"} { yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "constraint-extended-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue() : entry{YType::uint32, "entry"} { yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "extended-forward-ref-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::BfdReversePath() : path_type{YType::enumeration, "path-type"}, binding_label{YType::uint32, "binding-label"} { yang_name = "bfd-reverse-path"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::~BfdReversePath() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::has_data() const { if (is_presence_container) return true; return path_type.is_set || binding_label.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::has_operation() const { return is_set(yfilter) || ydk::is_set(path_type.yfilter) || ydk::is_set(binding_label.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "bfd-reverse-path"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (path_type.is_set || is_set(path_type.yfilter)) leaf_name_data.push_back(path_type.get_name_leafdata()); if (binding_label.is_set || is_set(binding_label.yfilter)) leaf_name_data.push_back(binding_label.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::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 == "path-type") { path_type = value; path_type.value_namespace = name_space; path_type.value_namespace_prefix = name_space_prefix; } if(value_path == "binding-label") { binding_label = value; binding_label.value_namespace = name_space; binding_label.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "path-type") { path_type.yfilter = yfilter; } if(value_path == "binding-label") { binding_label.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::BfdReversePath::has_leaf_or_child_of_name(const std::string & name) const { if(name == "path-type" || name == "binding-label") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::TunnelId() : entry{YType::uint16, "entry"} { yang_name = "tunnel-id"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::~TunnelId() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "tunnel-id"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::TunnelId::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::VersionInfo() : attribute_type{YType::str, "attribute-type"}, generation{YType::uint32, "generation"}, is_default{YType::boolean, "is-default"} { yang_name = "version-info"; yang_parent_name = "attribute-set-path-option"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::~VersionInfo() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::has_data() const { if (is_presence_container) return true; return attribute_type.is_set || generation.is_set || is_default.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::has_operation() const { return is_set(yfilter) || ydk::is_set(attribute_type.yfilter) || ydk::is_set(generation.yfilter) || ydk::is_set(is_default.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "version-info"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (attribute_type.is_set || is_set(attribute_type.yfilter)) leaf_name_data.push_back(attribute_type.get_name_leafdata()); if (generation.is_set || is_set(generation.yfilter)) leaf_name_data.push_back(generation.get_name_leafdata()); if (is_default.is_set || is_set(is_default.yfilter)) leaf_name_data.push_back(is_default.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::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 == "attribute-type") { attribute_type = value; attribute_type.value_namespace = name_space; attribute_type.value_namespace_prefix = name_space_prefix; } if(value_path == "generation") { generation = value; generation.value_namespace = name_space; generation.value_namespace_prefix = name_space_prefix; } if(value_path == "is-default") { is_default = value; is_default.value_namespace = name_space; is_default.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "attribute-type") { attribute_type.yfilter = yfilter; } if(value_path == "generation") { generation.yfilter = yfilter; } if(value_path == "is-default") { is_default.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetPathOption::VersionInfo::has_leaf_or_child_of_name(const std::string & name) const { if(name == "attribute-type" || name == "generation" || name == "is-default") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::AttributeSetAutobackup() : is_signalled_name_configured{YType::boolean, "is-signalled-name-configured"}, setup_priority{YType::uint8, "setup-priority"}, hold_priority{YType::uint8, "hold-priority"}, is_priority_configured{YType::boolean, "is-priority-configured"}, policy_class{YType::uint8, "policy-class"}, is_policyclass_configured{YType::boolean, "is-policyclass-configured"}, is_affinity_configured{YType::boolean, "is-affinity-configured"}, record_route{YType::boolean, "record-route"} , signalled_name(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName>()) , affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity>()) , logging(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging>()) , policy_class_entry(this, {}) , tunnel_id(this, {}) , protected_interface(this, {}) { signalled_name->parent = this; affinity->parent = this; logging->parent = this; yang_name = "attribute-set-autobackup"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::~AttributeSetAutobackup() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<policy_class_entry.len(); index++) { if(policy_class_entry[index]->has_data()) return true; } for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_data()) return true; } for (std::size_t index=0; index<protected_interface.len(); index++) { if(protected_interface[index]->has_data()) return true; } return is_signalled_name_configured.is_set || setup_priority.is_set || hold_priority.is_set || is_priority_configured.is_set || policy_class.is_set || is_policyclass_configured.is_set || is_affinity_configured.is_set || record_route.is_set || (signalled_name != nullptr && signalled_name->has_data()) || (affinity != nullptr && affinity->has_data()) || (logging != nullptr && logging->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::has_operation() const { for (std::size_t index=0; index<policy_class_entry.len(); index++) { if(policy_class_entry[index]->has_operation()) return true; } for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_operation()) return true; } for (std::size_t index=0; index<protected_interface.len(); index++) { if(protected_interface[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(is_signalled_name_configured.yfilter) || ydk::is_set(setup_priority.yfilter) || ydk::is_set(hold_priority.yfilter) || ydk::is_set(is_priority_configured.yfilter) || ydk::is_set(policy_class.yfilter) || ydk::is_set(is_policyclass_configured.yfilter) || ydk::is_set(is_affinity_configured.yfilter) || ydk::is_set(record_route.yfilter) || (signalled_name != nullptr && signalled_name->has_operation()) || (affinity != nullptr && affinity->has_operation()) || (logging != nullptr && logging->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-autobackup"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (is_signalled_name_configured.is_set || is_set(is_signalled_name_configured.yfilter)) leaf_name_data.push_back(is_signalled_name_configured.get_name_leafdata()); if (setup_priority.is_set || is_set(setup_priority.yfilter)) leaf_name_data.push_back(setup_priority.get_name_leafdata()); if (hold_priority.is_set || is_set(hold_priority.yfilter)) leaf_name_data.push_back(hold_priority.get_name_leafdata()); if (is_priority_configured.is_set || is_set(is_priority_configured.yfilter)) leaf_name_data.push_back(is_priority_configured.get_name_leafdata()); if (policy_class.is_set || is_set(policy_class.yfilter)) leaf_name_data.push_back(policy_class.get_name_leafdata()); if (is_policyclass_configured.is_set || is_set(is_policyclass_configured.yfilter)) leaf_name_data.push_back(is_policyclass_configured.get_name_leafdata()); if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata()); if (record_route.is_set || is_set(record_route.yfilter)) leaf_name_data.push_back(record_route.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "signalled-name") { if(signalled_name == nullptr) { signalled_name = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName>(); } return signalled_name; } if(child_yang_name == "affinity") { if(affinity == nullptr) { affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity>(); } return affinity; } if(child_yang_name == "logging") { if(logging == nullptr) { logging = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging>(); } return logging; } if(child_yang_name == "policy-class-entry") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry>(); ent_->parent = this; policy_class_entry.append(ent_); return ent_; } if(child_yang_name == "tunnel-id") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId>(); ent_->parent = this; tunnel_id.append(ent_); return ent_; } if(child_yang_name == "protected-interface") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface>(); ent_->parent = this; protected_interface.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(signalled_name != nullptr) { _children["signalled-name"] = signalled_name; } if(affinity != nullptr) { _children["affinity"] = affinity; } if(logging != nullptr) { _children["logging"] = logging; } count_ = 0; for (auto ent_ : policy_class_entry.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_ : tunnel_id.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_ : protected_interface.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::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 == "is-signalled-name-configured") { is_signalled_name_configured = value; is_signalled_name_configured.value_namespace = name_space; is_signalled_name_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "setup-priority") { setup_priority = value; setup_priority.value_namespace = name_space; setup_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "hold-priority") { hold_priority = value; hold_priority.value_namespace = name_space; hold_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "is-priority-configured") { is_priority_configured = value; is_priority_configured.value_namespace = name_space; is_priority_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "policy-class") { policy_class = value; policy_class.value_namespace = name_space; policy_class.value_namespace_prefix = name_space_prefix; } if(value_path == "is-policyclass-configured") { is_policyclass_configured = value; is_policyclass_configured.value_namespace = name_space; is_policyclass_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-affinity-configured") { is_affinity_configured = value; is_affinity_configured.value_namespace = name_space; is_affinity_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "record-route") { record_route = value; record_route.value_namespace = name_space; record_route.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "is-signalled-name-configured") { is_signalled_name_configured.yfilter = yfilter; } if(value_path == "setup-priority") { setup_priority.yfilter = yfilter; } if(value_path == "hold-priority") { hold_priority.yfilter = yfilter; } if(value_path == "is-priority-configured") { is_priority_configured.yfilter = yfilter; } if(value_path == "policy-class") { policy_class.yfilter = yfilter; } if(value_path == "is-policyclass-configured") { is_policyclass_configured.yfilter = yfilter; } if(value_path == "is-affinity-configured") { is_affinity_configured.yfilter = yfilter; } if(value_path == "record-route") { record_route.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::has_leaf_or_child_of_name(const std::string & name) const { if(name == "signalled-name" || name == "affinity" || name == "logging" || name == "policy-class-entry" || name == "tunnel-id" || name == "protected-interface" || name == "is-signalled-name-configured" || name == "setup-priority" || name == "hold-priority" || name == "is-priority-configured" || name == "policy-class" || name == "is-policyclass-configured" || name == "is-affinity-configured" || name == "record-route") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::SignalledName() : name{YType::str, "name"}, source_type{YType::enumeration, "source-type"}, protected_interface_type{YType::enumeration, "protected-interface-type"}, is_mp_addresses{YType::boolean, "is-mp-addresses"} { yang_name = "signalled-name"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::~SignalledName() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::has_data() const { if (is_presence_container) return true; return name.is_set || source_type.is_set || protected_interface_type.is_set || is_mp_addresses.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::has_operation() const { return is_set(yfilter) || ydk::is_set(name.yfilter) || ydk::is_set(source_type.yfilter) || ydk::is_set(protected_interface_type.yfilter) || ydk::is_set(is_mp_addresses.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "signalled-name"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (name.is_set || is_set(name.yfilter)) leaf_name_data.push_back(name.get_name_leafdata()); if (source_type.is_set || is_set(source_type.yfilter)) leaf_name_data.push_back(source_type.get_name_leafdata()); if (protected_interface_type.is_set || is_set(protected_interface_type.yfilter)) leaf_name_data.push_back(protected_interface_type.get_name_leafdata()); if (is_mp_addresses.is_set || is_set(is_mp_addresses.yfilter)) leaf_name_data.push_back(is_mp_addresses.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::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 == "name") { name = value; name.value_namespace = name_space; name.value_namespace_prefix = name_space_prefix; } if(value_path == "source-type") { source_type = value; source_type.value_namespace = name_space; source_type.value_namespace_prefix = name_space_prefix; } if(value_path == "protected-interface-type") { protected_interface_type = value; protected_interface_type.value_namespace = name_space; protected_interface_type.value_namespace_prefix = name_space_prefix; } if(value_path == "is-mp-addresses") { is_mp_addresses = value; is_mp_addresses.value_namespace = name_space; is_mp_addresses.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "name") { name.yfilter = yfilter; } if(value_path == "source-type") { source_type.yfilter = yfilter; } if(value_path == "protected-interface-type") { protected_interface_type.yfilter = yfilter; } if(value_path == "is-mp-addresses") { is_mp_addresses.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::SignalledName::has_leaf_or_child_of_name(const std::string & name) const { if(name == "name" || name == "source-type" || name == "protected-interface-type" || name == "is-mp-addresses") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::Affinity() : affinity_bits{YType::uint32, "affinity-bits"}, affinity_mask{YType::uint32, "affinity-mask"} , named_affinity(this, {}) { yang_name = "affinity"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::~Affinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_data()) return true; } return affinity_bits.is_set || affinity_mask.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::has_operation() const { for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(affinity_bits.yfilter) || ydk::is_set(affinity_mask.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "affinity"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata()); if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "named-affinity") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity>(); ent_->parent = this; named_affinity.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : named_affinity.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::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 == "affinity-bits") { affinity_bits = value; affinity_bits.value_namespace = name_space; affinity_bits.value_namespace_prefix = name_space_prefix; } if(value_path == "affinity-mask") { affinity_mask = value; affinity_mask.value_namespace = name_space; affinity_mask.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "affinity-bits") { affinity_bits.yfilter = yfilter; } if(value_path == "affinity-mask") { affinity_mask.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::NamedAffinity() : constraint_type{YType::uint8, "constraint-type"}, constraint_value{YType::uint32, "constraint-value"}, forward_ref_value{YType::uint32, "forward-ref-value"} , constraint_extended_value(this, {}) , extended_forward_ref_value(this, {}) { yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::~NamedAffinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_data()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_data()) return true; } return constraint_type.is_set || constraint_value.is_set || forward_ref_value.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::has_operation() const { for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_operation()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(constraint_type.yfilter) || ydk::is_set(constraint_value.yfilter) || ydk::is_set(forward_ref_value.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "named-affinity"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata()); if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata()); if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "constraint-extended-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue>(); ent_->parent = this; constraint_extended_value.append(ent_); return ent_; } if(child_yang_name == "extended-forward-ref-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue>(); ent_->parent = this; extended_forward_ref_value.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : constraint_extended_value.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_ : extended_forward_ref_value.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::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 == "constraint-type") { constraint_type = value; constraint_type.value_namespace = name_space; constraint_type.value_namespace_prefix = name_space_prefix; } if(value_path == "constraint-value") { constraint_value = value; constraint_value.value_namespace = name_space; constraint_value.value_namespace_prefix = name_space_prefix; } if(value_path == "forward-ref-value") { forward_ref_value = value; forward_ref_value.value_namespace = name_space; forward_ref_value.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "constraint-type") { constraint_type.yfilter = yfilter; } if(value_path == "constraint-value") { constraint_value.yfilter = yfilter; } if(value_path == "forward-ref-value") { forward_ref_value.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue() : entry{YType::uint32, "entry"} { yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "constraint-extended-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue() : entry{YType::uint32, "entry"} { yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "extended-forward-ref-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::Logging() : lsp_state{YType::boolean, "lsp-state"}, s2l_state{YType::boolean, "s2l-state"}, lsp_re_route{YType::boolean, "lsp-re-route"}, lsp_re_opt{YType::boolean, "lsp-re-opt"}, lsp_insufficient_bw{YType::boolean, "lsp-insufficient-bw"}, lsp_bandwidth_change{YType::boolean, "lsp-bandwidth-change"}, lsp_pcalc_failure_logging_enabled{YType::boolean, "lsp-pcalc-failure-logging-enabled"}, all_logging_enabled{YType::boolean, "all-logging-enabled"} { yang_name = "logging"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::~Logging() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::has_data() const { if (is_presence_container) return true; return lsp_state.is_set || s2l_state.is_set || lsp_re_route.is_set || lsp_re_opt.is_set || lsp_insufficient_bw.is_set || lsp_bandwidth_change.is_set || lsp_pcalc_failure_logging_enabled.is_set || all_logging_enabled.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::has_operation() const { return is_set(yfilter) || ydk::is_set(lsp_state.yfilter) || ydk::is_set(s2l_state.yfilter) || ydk::is_set(lsp_re_route.yfilter) || ydk::is_set(lsp_re_opt.yfilter) || ydk::is_set(lsp_insufficient_bw.yfilter) || ydk::is_set(lsp_bandwidth_change.yfilter) || ydk::is_set(lsp_pcalc_failure_logging_enabled.yfilter) || ydk::is_set(all_logging_enabled.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "logging"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (lsp_state.is_set || is_set(lsp_state.yfilter)) leaf_name_data.push_back(lsp_state.get_name_leafdata()); if (s2l_state.is_set || is_set(s2l_state.yfilter)) leaf_name_data.push_back(s2l_state.get_name_leafdata()); if (lsp_re_route.is_set || is_set(lsp_re_route.yfilter)) leaf_name_data.push_back(lsp_re_route.get_name_leafdata()); if (lsp_re_opt.is_set || is_set(lsp_re_opt.yfilter)) leaf_name_data.push_back(lsp_re_opt.get_name_leafdata()); if (lsp_insufficient_bw.is_set || is_set(lsp_insufficient_bw.yfilter)) leaf_name_data.push_back(lsp_insufficient_bw.get_name_leafdata()); if (lsp_bandwidth_change.is_set || is_set(lsp_bandwidth_change.yfilter)) leaf_name_data.push_back(lsp_bandwidth_change.get_name_leafdata()); if (lsp_pcalc_failure_logging_enabled.is_set || is_set(lsp_pcalc_failure_logging_enabled.yfilter)) leaf_name_data.push_back(lsp_pcalc_failure_logging_enabled.get_name_leafdata()); if (all_logging_enabled.is_set || is_set(all_logging_enabled.yfilter)) leaf_name_data.push_back(all_logging_enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::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 == "lsp-state") { lsp_state = value; lsp_state.value_namespace = name_space; lsp_state.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-state") { s2l_state = value; s2l_state.value_namespace = name_space; s2l_state.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-re-route") { lsp_re_route = value; lsp_re_route.value_namespace = name_space; lsp_re_route.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-re-opt") { lsp_re_opt = value; lsp_re_opt.value_namespace = name_space; lsp_re_opt.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-insufficient-bw") { lsp_insufficient_bw = value; lsp_insufficient_bw.value_namespace = name_space; lsp_insufficient_bw.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-bandwidth-change") { lsp_bandwidth_change = value; lsp_bandwidth_change.value_namespace = name_space; lsp_bandwidth_change.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-pcalc-failure-logging-enabled") { lsp_pcalc_failure_logging_enabled = value; lsp_pcalc_failure_logging_enabled.value_namespace = name_space; lsp_pcalc_failure_logging_enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "all-logging-enabled") { all_logging_enabled = value; all_logging_enabled.value_namespace = name_space; all_logging_enabled.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "lsp-state") { lsp_state.yfilter = yfilter; } if(value_path == "s2l-state") { s2l_state.yfilter = yfilter; } if(value_path == "lsp-re-route") { lsp_re_route.yfilter = yfilter; } if(value_path == "lsp-re-opt") { lsp_re_opt.yfilter = yfilter; } if(value_path == "lsp-insufficient-bw") { lsp_insufficient_bw.yfilter = yfilter; } if(value_path == "lsp-bandwidth-change") { lsp_bandwidth_change.yfilter = yfilter; } if(value_path == "lsp-pcalc-failure-logging-enabled") { lsp_pcalc_failure_logging_enabled.yfilter = yfilter; } if(value_path == "all-logging-enabled") { all_logging_enabled.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::Logging::has_leaf_or_child_of_name(const std::string & name) const { if(name == "lsp-state" || name == "s2l-state" || name == "lsp-re-route" || name == "lsp-re-opt" || name == "lsp-insufficient-bw" || name == "lsp-bandwidth-change" || name == "lsp-pcalc-failure-logging-enabled" || name == "all-logging-enabled") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::PolicyClassEntry() : entry{YType::uint8, "entry"} { yang_name = "policy-class-entry"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::~PolicyClassEntry() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "policy-class-entry"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::PolicyClassEntry::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::TunnelId() : entry{YType::uint16, "entry"} { yang_name = "tunnel-id"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::~TunnelId() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "tunnel-id"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::TunnelId::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::ProtectedInterface() : protected_interface{YType::str, "protected-interface"} { yang_name = "protected-interface"; yang_parent_name = "attribute-set-autobackup"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::~ProtectedInterface() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::has_data() const { if (is_presence_container) return true; return protected_interface.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::has_operation() const { return is_set(yfilter) || ydk::is_set(protected_interface.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "protected-interface"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (protected_interface.is_set || is_set(protected_interface.yfilter)) leaf_name_data.push_back(protected_interface.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::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 == "protected-interface") { protected_interface = value; protected_interface.value_namespace = name_space; protected_interface.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "protected-interface") { protected_interface.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutobackup::ProtectedInterface::has_leaf_or_child_of_name(const std::string & name) const { if(name == "protected-interface") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::AttributeSetAutomesh() : configured_bandwidth{YType::uint32, "configured-bandwidth"}, dste_class_type{YType::uint8, "dste-class-type"}, is_bandwidth_configured{YType::boolean, "is-bandwidth-configured"}, setup_priority{YType::uint8, "setup-priority"}, hold_priority{YType::uint8, "hold-priority"}, is_priority_configured{YType::boolean, "is-priority-configured"}, policy_class{YType::uint8, "policy-class"}, is_policyclass_configured{YType::boolean, "is-policyclass-configured"}, forward_class{YType::uint32, "forward-class"}, is_forward_class_configured{YType::boolean, "is-forward-class-configured"}, is_affinity_configured{YType::boolean, "is-affinity-configured"}, fast_reroute{YType::boolean, "fast-reroute"}, frr_node_protection{YType::boolean, "frr-node-protection"}, frr_bandwidth_protection{YType::boolean, "frr-bandwidth-protection"}, record_route{YType::boolean, "record-route"}, auto_bandwidth_collect{YType::boolean, "auto-bandwidth-collect"}, auto_route_announce{YType::boolean, "auto-route-announce"}, soft_preemption_configured{YType::boolean, "soft-preemption-configured"}, bandwidth{YType::uint32, "bandwidth"}, load_share{YType::uint32, "load-share"}, is_interface_bw_configured{YType::boolean, "is-interface-bw-configured"} , affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity>()) , logging(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging>()) , policy_class_entry(this, {}) , mesh_group_id(this, {}) , tunnel_id(this, {}) { affinity->parent = this; logging->parent = this; yang_name = "attribute-set-automesh"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::~AttributeSetAutomesh() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<policy_class_entry.len(); index++) { if(policy_class_entry[index]->has_data()) return true; } for (std::size_t index=0; index<mesh_group_id.len(); index++) { if(mesh_group_id[index]->has_data()) return true; } for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_data()) return true; } return configured_bandwidth.is_set || dste_class_type.is_set || is_bandwidth_configured.is_set || setup_priority.is_set || hold_priority.is_set || is_priority_configured.is_set || policy_class.is_set || is_policyclass_configured.is_set || forward_class.is_set || is_forward_class_configured.is_set || is_affinity_configured.is_set || fast_reroute.is_set || frr_node_protection.is_set || frr_bandwidth_protection.is_set || record_route.is_set || auto_bandwidth_collect.is_set || auto_route_announce.is_set || soft_preemption_configured.is_set || bandwidth.is_set || load_share.is_set || is_interface_bw_configured.is_set || (affinity != nullptr && affinity->has_data()) || (logging != nullptr && logging->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::has_operation() const { for (std::size_t index=0; index<policy_class_entry.len(); index++) { if(policy_class_entry[index]->has_operation()) return true; } for (std::size_t index=0; index<mesh_group_id.len(); index++) { if(mesh_group_id[index]->has_operation()) return true; } for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(configured_bandwidth.yfilter) || ydk::is_set(dste_class_type.yfilter) || ydk::is_set(is_bandwidth_configured.yfilter) || ydk::is_set(setup_priority.yfilter) || ydk::is_set(hold_priority.yfilter) || ydk::is_set(is_priority_configured.yfilter) || ydk::is_set(policy_class.yfilter) || ydk::is_set(is_policyclass_configured.yfilter) || ydk::is_set(forward_class.yfilter) || ydk::is_set(is_forward_class_configured.yfilter) || ydk::is_set(is_affinity_configured.yfilter) || ydk::is_set(fast_reroute.yfilter) || ydk::is_set(frr_node_protection.yfilter) || ydk::is_set(frr_bandwidth_protection.yfilter) || ydk::is_set(record_route.yfilter) || ydk::is_set(auto_bandwidth_collect.yfilter) || ydk::is_set(auto_route_announce.yfilter) || ydk::is_set(soft_preemption_configured.yfilter) || ydk::is_set(bandwidth.yfilter) || ydk::is_set(load_share.yfilter) || ydk::is_set(is_interface_bw_configured.yfilter) || (affinity != nullptr && affinity->has_operation()) || (logging != nullptr && logging->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-automesh"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (configured_bandwidth.is_set || is_set(configured_bandwidth.yfilter)) leaf_name_data.push_back(configured_bandwidth.get_name_leafdata()); if (dste_class_type.is_set || is_set(dste_class_type.yfilter)) leaf_name_data.push_back(dste_class_type.get_name_leafdata()); if (is_bandwidth_configured.is_set || is_set(is_bandwidth_configured.yfilter)) leaf_name_data.push_back(is_bandwidth_configured.get_name_leafdata()); if (setup_priority.is_set || is_set(setup_priority.yfilter)) leaf_name_data.push_back(setup_priority.get_name_leafdata()); if (hold_priority.is_set || is_set(hold_priority.yfilter)) leaf_name_data.push_back(hold_priority.get_name_leafdata()); if (is_priority_configured.is_set || is_set(is_priority_configured.yfilter)) leaf_name_data.push_back(is_priority_configured.get_name_leafdata()); if (policy_class.is_set || is_set(policy_class.yfilter)) leaf_name_data.push_back(policy_class.get_name_leafdata()); if (is_policyclass_configured.is_set || is_set(is_policyclass_configured.yfilter)) leaf_name_data.push_back(is_policyclass_configured.get_name_leafdata()); if (forward_class.is_set || is_set(forward_class.yfilter)) leaf_name_data.push_back(forward_class.get_name_leafdata()); if (is_forward_class_configured.is_set || is_set(is_forward_class_configured.yfilter)) leaf_name_data.push_back(is_forward_class_configured.get_name_leafdata()); if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata()); if (fast_reroute.is_set || is_set(fast_reroute.yfilter)) leaf_name_data.push_back(fast_reroute.get_name_leafdata()); if (frr_node_protection.is_set || is_set(frr_node_protection.yfilter)) leaf_name_data.push_back(frr_node_protection.get_name_leafdata()); if (frr_bandwidth_protection.is_set || is_set(frr_bandwidth_protection.yfilter)) leaf_name_data.push_back(frr_bandwidth_protection.get_name_leafdata()); if (record_route.is_set || is_set(record_route.yfilter)) leaf_name_data.push_back(record_route.get_name_leafdata()); if (auto_bandwidth_collect.is_set || is_set(auto_bandwidth_collect.yfilter)) leaf_name_data.push_back(auto_bandwidth_collect.get_name_leafdata()); if (auto_route_announce.is_set || is_set(auto_route_announce.yfilter)) leaf_name_data.push_back(auto_route_announce.get_name_leafdata()); if (soft_preemption_configured.is_set || is_set(soft_preemption_configured.yfilter)) leaf_name_data.push_back(soft_preemption_configured.get_name_leafdata()); if (bandwidth.is_set || is_set(bandwidth.yfilter)) leaf_name_data.push_back(bandwidth.get_name_leafdata()); if (load_share.is_set || is_set(load_share.yfilter)) leaf_name_data.push_back(load_share.get_name_leafdata()); if (is_interface_bw_configured.is_set || is_set(is_interface_bw_configured.yfilter)) leaf_name_data.push_back(is_interface_bw_configured.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "affinity") { if(affinity == nullptr) { affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity>(); } return affinity; } if(child_yang_name == "logging") { if(logging == nullptr) { logging = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging>(); } return logging; } if(child_yang_name == "policy-class-entry") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry>(); ent_->parent = this; policy_class_entry.append(ent_); return ent_; } if(child_yang_name == "mesh-group-id") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId>(); ent_->parent = this; mesh_group_id.append(ent_); return ent_; } if(child_yang_name == "tunnel-id") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId>(); ent_->parent = this; tunnel_id.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(affinity != nullptr) { _children["affinity"] = affinity; } if(logging != nullptr) { _children["logging"] = logging; } count_ = 0; for (auto ent_ : policy_class_entry.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_ : mesh_group_id.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_ : tunnel_id.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::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 == "configured-bandwidth") { configured_bandwidth = value; configured_bandwidth.value_namespace = name_space; configured_bandwidth.value_namespace_prefix = name_space_prefix; } if(value_path == "dste-class-type") { dste_class_type = value; dste_class_type.value_namespace = name_space; dste_class_type.value_namespace_prefix = name_space_prefix; } if(value_path == "is-bandwidth-configured") { is_bandwidth_configured = value; is_bandwidth_configured.value_namespace = name_space; is_bandwidth_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "setup-priority") { setup_priority = value; setup_priority.value_namespace = name_space; setup_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "hold-priority") { hold_priority = value; hold_priority.value_namespace = name_space; hold_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "is-priority-configured") { is_priority_configured = value; is_priority_configured.value_namespace = name_space; is_priority_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "policy-class") { policy_class = value; policy_class.value_namespace = name_space; policy_class.value_namespace_prefix = name_space_prefix; } if(value_path == "is-policyclass-configured") { is_policyclass_configured = value; is_policyclass_configured.value_namespace = name_space; is_policyclass_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "forward-class") { forward_class = value; forward_class.value_namespace = name_space; forward_class.value_namespace_prefix = name_space_prefix; } if(value_path == "is-forward-class-configured") { is_forward_class_configured = value; is_forward_class_configured.value_namespace = name_space; is_forward_class_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-affinity-configured") { is_affinity_configured = value; is_affinity_configured.value_namespace = name_space; is_affinity_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "fast-reroute") { fast_reroute = value; fast_reroute.value_namespace = name_space; fast_reroute.value_namespace_prefix = name_space_prefix; } if(value_path == "frr-node-protection") { frr_node_protection = value; frr_node_protection.value_namespace = name_space; frr_node_protection.value_namespace_prefix = name_space_prefix; } if(value_path == "frr-bandwidth-protection") { frr_bandwidth_protection = value; frr_bandwidth_protection.value_namespace = name_space; frr_bandwidth_protection.value_namespace_prefix = name_space_prefix; } if(value_path == "record-route") { record_route = value; record_route.value_namespace = name_space; record_route.value_namespace_prefix = name_space_prefix; } if(value_path == "auto-bandwidth-collect") { auto_bandwidth_collect = value; auto_bandwidth_collect.value_namespace = name_space; auto_bandwidth_collect.value_namespace_prefix = name_space_prefix; } if(value_path == "auto-route-announce") { auto_route_announce = value; auto_route_announce.value_namespace = name_space; auto_route_announce.value_namespace_prefix = name_space_prefix; } if(value_path == "soft-preemption-configured") { soft_preemption_configured = value; soft_preemption_configured.value_namespace = name_space; soft_preemption_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "bandwidth") { bandwidth = value; bandwidth.value_namespace = name_space; bandwidth.value_namespace_prefix = name_space_prefix; } if(value_path == "load-share") { load_share = value; load_share.value_namespace = name_space; load_share.value_namespace_prefix = name_space_prefix; } if(value_path == "is-interface-bw-configured") { is_interface_bw_configured = value; is_interface_bw_configured.value_namespace = name_space; is_interface_bw_configured.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "configured-bandwidth") { configured_bandwidth.yfilter = yfilter; } if(value_path == "dste-class-type") { dste_class_type.yfilter = yfilter; } if(value_path == "is-bandwidth-configured") { is_bandwidth_configured.yfilter = yfilter; } if(value_path == "setup-priority") { setup_priority.yfilter = yfilter; } if(value_path == "hold-priority") { hold_priority.yfilter = yfilter; } if(value_path == "is-priority-configured") { is_priority_configured.yfilter = yfilter; } if(value_path == "policy-class") { policy_class.yfilter = yfilter; } if(value_path == "is-policyclass-configured") { is_policyclass_configured.yfilter = yfilter; } if(value_path == "forward-class") { forward_class.yfilter = yfilter; } if(value_path == "is-forward-class-configured") { is_forward_class_configured.yfilter = yfilter; } if(value_path == "is-affinity-configured") { is_affinity_configured.yfilter = yfilter; } if(value_path == "fast-reroute") { fast_reroute.yfilter = yfilter; } if(value_path == "frr-node-protection") { frr_node_protection.yfilter = yfilter; } if(value_path == "frr-bandwidth-protection") { frr_bandwidth_protection.yfilter = yfilter; } if(value_path == "record-route") { record_route.yfilter = yfilter; } if(value_path == "auto-bandwidth-collect") { auto_bandwidth_collect.yfilter = yfilter; } if(value_path == "auto-route-announce") { auto_route_announce.yfilter = yfilter; } if(value_path == "soft-preemption-configured") { soft_preemption_configured.yfilter = yfilter; } if(value_path == "bandwidth") { bandwidth.yfilter = yfilter; } if(value_path == "load-share") { load_share.yfilter = yfilter; } if(value_path == "is-interface-bw-configured") { is_interface_bw_configured.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::has_leaf_or_child_of_name(const std::string & name) const { if(name == "affinity" || name == "logging" || name == "policy-class-entry" || name == "mesh-group-id" || name == "tunnel-id" || name == "configured-bandwidth" || name == "dste-class-type" || name == "is-bandwidth-configured" || name == "setup-priority" || name == "hold-priority" || name == "is-priority-configured" || name == "policy-class" || name == "is-policyclass-configured" || name == "forward-class" || name == "is-forward-class-configured" || name == "is-affinity-configured" || name == "fast-reroute" || name == "frr-node-protection" || name == "frr-bandwidth-protection" || name == "record-route" || name == "auto-bandwidth-collect" || name == "auto-route-announce" || name == "soft-preemption-configured" || name == "bandwidth" || name == "load-share" || name == "is-interface-bw-configured") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::Affinity() : affinity_bits{YType::uint32, "affinity-bits"}, affinity_mask{YType::uint32, "affinity-mask"} , named_affinity(this, {}) { yang_name = "affinity"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::~Affinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_data()) return true; } return affinity_bits.is_set || affinity_mask.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::has_operation() const { for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(affinity_bits.yfilter) || ydk::is_set(affinity_mask.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "affinity"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata()); if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "named-affinity") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity>(); ent_->parent = this; named_affinity.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : named_affinity.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::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 == "affinity-bits") { affinity_bits = value; affinity_bits.value_namespace = name_space; affinity_bits.value_namespace_prefix = name_space_prefix; } if(value_path == "affinity-mask") { affinity_mask = value; affinity_mask.value_namespace = name_space; affinity_mask.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "affinity-bits") { affinity_bits.yfilter = yfilter; } if(value_path == "affinity-mask") { affinity_mask.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::NamedAffinity() : constraint_type{YType::uint8, "constraint-type"}, constraint_value{YType::uint32, "constraint-value"}, forward_ref_value{YType::uint32, "forward-ref-value"} , constraint_extended_value(this, {}) , extended_forward_ref_value(this, {}) { yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::~NamedAffinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_data()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_data()) return true; } return constraint_type.is_set || constraint_value.is_set || forward_ref_value.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::has_operation() const { for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_operation()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(constraint_type.yfilter) || ydk::is_set(constraint_value.yfilter) || ydk::is_set(forward_ref_value.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "named-affinity"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata()); if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata()); if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "constraint-extended-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue>(); ent_->parent = this; constraint_extended_value.append(ent_); return ent_; } if(child_yang_name == "extended-forward-ref-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue>(); ent_->parent = this; extended_forward_ref_value.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : constraint_extended_value.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_ : extended_forward_ref_value.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::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 == "constraint-type") { constraint_type = value; constraint_type.value_namespace = name_space; constraint_type.value_namespace_prefix = name_space_prefix; } if(value_path == "constraint-value") { constraint_value = value; constraint_value.value_namespace = name_space; constraint_value.value_namespace_prefix = name_space_prefix; } if(value_path == "forward-ref-value") { forward_ref_value = value; forward_ref_value.value_namespace = name_space; forward_ref_value.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "constraint-type") { constraint_type.yfilter = yfilter; } if(value_path == "constraint-value") { constraint_value.yfilter = yfilter; } if(value_path == "forward-ref-value") { forward_ref_value.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue() : entry{YType::uint32, "entry"} { yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "constraint-extended-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue() : entry{YType::uint32, "entry"} { yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "extended-forward-ref-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::Logging() : lsp_state{YType::boolean, "lsp-state"}, s2l_state{YType::boolean, "s2l-state"}, lsp_re_route{YType::boolean, "lsp-re-route"}, lsp_re_opt{YType::boolean, "lsp-re-opt"}, lsp_insufficient_bw{YType::boolean, "lsp-insufficient-bw"}, lsp_bandwidth_change{YType::boolean, "lsp-bandwidth-change"}, lsp_pcalc_failure_logging_enabled{YType::boolean, "lsp-pcalc-failure-logging-enabled"}, all_logging_enabled{YType::boolean, "all-logging-enabled"} { yang_name = "logging"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::~Logging() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::has_data() const { if (is_presence_container) return true; return lsp_state.is_set || s2l_state.is_set || lsp_re_route.is_set || lsp_re_opt.is_set || lsp_insufficient_bw.is_set || lsp_bandwidth_change.is_set || lsp_pcalc_failure_logging_enabled.is_set || all_logging_enabled.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::has_operation() const { return is_set(yfilter) || ydk::is_set(lsp_state.yfilter) || ydk::is_set(s2l_state.yfilter) || ydk::is_set(lsp_re_route.yfilter) || ydk::is_set(lsp_re_opt.yfilter) || ydk::is_set(lsp_insufficient_bw.yfilter) || ydk::is_set(lsp_bandwidth_change.yfilter) || ydk::is_set(lsp_pcalc_failure_logging_enabled.yfilter) || ydk::is_set(all_logging_enabled.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "logging"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (lsp_state.is_set || is_set(lsp_state.yfilter)) leaf_name_data.push_back(lsp_state.get_name_leafdata()); if (s2l_state.is_set || is_set(s2l_state.yfilter)) leaf_name_data.push_back(s2l_state.get_name_leafdata()); if (lsp_re_route.is_set || is_set(lsp_re_route.yfilter)) leaf_name_data.push_back(lsp_re_route.get_name_leafdata()); if (lsp_re_opt.is_set || is_set(lsp_re_opt.yfilter)) leaf_name_data.push_back(lsp_re_opt.get_name_leafdata()); if (lsp_insufficient_bw.is_set || is_set(lsp_insufficient_bw.yfilter)) leaf_name_data.push_back(lsp_insufficient_bw.get_name_leafdata()); if (lsp_bandwidth_change.is_set || is_set(lsp_bandwidth_change.yfilter)) leaf_name_data.push_back(lsp_bandwidth_change.get_name_leafdata()); if (lsp_pcalc_failure_logging_enabled.is_set || is_set(lsp_pcalc_failure_logging_enabled.yfilter)) leaf_name_data.push_back(lsp_pcalc_failure_logging_enabled.get_name_leafdata()); if (all_logging_enabled.is_set || is_set(all_logging_enabled.yfilter)) leaf_name_data.push_back(all_logging_enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::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 == "lsp-state") { lsp_state = value; lsp_state.value_namespace = name_space; lsp_state.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-state") { s2l_state = value; s2l_state.value_namespace = name_space; s2l_state.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-re-route") { lsp_re_route = value; lsp_re_route.value_namespace = name_space; lsp_re_route.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-re-opt") { lsp_re_opt = value; lsp_re_opt.value_namespace = name_space; lsp_re_opt.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-insufficient-bw") { lsp_insufficient_bw = value; lsp_insufficient_bw.value_namespace = name_space; lsp_insufficient_bw.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-bandwidth-change") { lsp_bandwidth_change = value; lsp_bandwidth_change.value_namespace = name_space; lsp_bandwidth_change.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-pcalc-failure-logging-enabled") { lsp_pcalc_failure_logging_enabled = value; lsp_pcalc_failure_logging_enabled.value_namespace = name_space; lsp_pcalc_failure_logging_enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "all-logging-enabled") { all_logging_enabled = value; all_logging_enabled.value_namespace = name_space; all_logging_enabled.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "lsp-state") { lsp_state.yfilter = yfilter; } if(value_path == "s2l-state") { s2l_state.yfilter = yfilter; } if(value_path == "lsp-re-route") { lsp_re_route.yfilter = yfilter; } if(value_path == "lsp-re-opt") { lsp_re_opt.yfilter = yfilter; } if(value_path == "lsp-insufficient-bw") { lsp_insufficient_bw.yfilter = yfilter; } if(value_path == "lsp-bandwidth-change") { lsp_bandwidth_change.yfilter = yfilter; } if(value_path == "lsp-pcalc-failure-logging-enabled") { lsp_pcalc_failure_logging_enabled.yfilter = yfilter; } if(value_path == "all-logging-enabled") { all_logging_enabled.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::Logging::has_leaf_or_child_of_name(const std::string & name) const { if(name == "lsp-state" || name == "s2l-state" || name == "lsp-re-route" || name == "lsp-re-opt" || name == "lsp-insufficient-bw" || name == "lsp-bandwidth-change" || name == "lsp-pcalc-failure-logging-enabled" || name == "all-logging-enabled") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::PolicyClassEntry() : entry{YType::uint8, "entry"} { yang_name = "policy-class-entry"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::~PolicyClassEntry() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "policy-class-entry"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::PolicyClassEntry::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::MeshGroupId() : entry{YType::uint32, "entry"} { yang_name = "mesh-group-id"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::~MeshGroupId() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "mesh-group-id"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::MeshGroupId::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::TunnelId() : entry{YType::uint16, "entry"} { yang_name = "tunnel-id"; yang_parent_name = "attribute-set-automesh"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::~TunnelId() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "tunnel-id"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetAutomesh::TunnelId::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::AttributeSetXro() : xro(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro>()) { xro->parent = this; yang_name = "attribute-set-xro"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::~AttributeSetXro() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::has_data() const { if (is_presence_container) return true; return (xro != nullptr && xro->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::has_operation() const { return is_set(yfilter) || (xro != nullptr && xro->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-xro"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "xro") { if(xro == nullptr) { xro = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro>(); } return xro; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(xro != nullptr) { _children["xro"] = xro; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::set_filter(const std::string & value_path, YFilter yfilter) { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::has_leaf_or_child_of_name(const std::string & name) const { if(name == "xro") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::Xro() : mutual_diversity_flag{YType::boolean, "mutual-diversity-flag"} , xro_subobject(this, {}) { yang_name = "xro"; yang_parent_name = "attribute-set-xro"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::~Xro() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<xro_subobject.len(); index++) { if(xro_subobject[index]->has_data()) return true; } return mutual_diversity_flag.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::has_operation() const { for (std::size_t index=0; index<xro_subobject.len(); index++) { if(xro_subobject[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(mutual_diversity_flag.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "xro"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (mutual_diversity_flag.is_set || is_set(mutual_diversity_flag.yfilter)) leaf_name_data.push_back(mutual_diversity_flag.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "xro-subobject") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject>(); ent_->parent = this; xro_subobject.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : xro_subobject.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::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 == "mutual-diversity-flag") { mutual_diversity_flag = value; mutual_diversity_flag.value_namespace = name_space; mutual_diversity_flag.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "mutual-diversity-flag") { mutual_diversity_flag.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::has_leaf_or_child_of_name(const std::string & name) const { if(name == "xro-subobject" || name == "mutual-diversity-flag") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::XroSubobject() : type{YType::enumeration, "type"} , ipv4_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject>()) , ipv6_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject>()) , unnumbered_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject>()) , as_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject>()) , srlg_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject>()) , lsp_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject>()) { ipv4_subobject->parent = this; ipv6_subobject->parent = this; unnumbered_subobject->parent = this; as_subobject->parent = this; srlg_subobject->parent = this; lsp_subobject->parent = this; yang_name = "xro-subobject"; yang_parent_name = "xro"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::~XroSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::has_data() const { if (is_presence_container) return true; return type.is_set || (ipv4_subobject != nullptr && ipv4_subobject->has_data()) || (ipv6_subobject != nullptr && ipv6_subobject->has_data()) || (unnumbered_subobject != nullptr && unnumbered_subobject->has_data()) || (as_subobject != nullptr && as_subobject->has_data()) || (srlg_subobject != nullptr && srlg_subobject->has_data()) || (lsp_subobject != nullptr && lsp_subobject->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(type.yfilter) || (ipv4_subobject != nullptr && ipv4_subobject->has_operation()) || (ipv6_subobject != nullptr && ipv6_subobject->has_operation()) || (unnumbered_subobject != nullptr && unnumbered_subobject->has_operation()) || (as_subobject != nullptr && as_subobject->has_operation()) || (srlg_subobject != nullptr && srlg_subobject->has_operation()) || (lsp_subobject != nullptr && lsp_subobject->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "xro-subobject"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "ipv4-subobject") { if(ipv4_subobject == nullptr) { ipv4_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject>(); } return ipv4_subobject; } if(child_yang_name == "ipv6-subobject") { if(ipv6_subobject == nullptr) { ipv6_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject>(); } return ipv6_subobject; } if(child_yang_name == "unnumbered-subobject") { if(unnumbered_subobject == nullptr) { unnumbered_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject>(); } return unnumbered_subobject; } if(child_yang_name == "as-subobject") { if(as_subobject == nullptr) { as_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject>(); } return as_subobject; } if(child_yang_name == "srlg-subobject") { if(srlg_subobject == nullptr) { srlg_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject>(); } return srlg_subobject; } if(child_yang_name == "lsp-subobject") { if(lsp_subobject == nullptr) { lsp_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject>(); } return lsp_subobject; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(ipv4_subobject != nullptr) { _children["ipv4-subobject"] = ipv4_subobject; } if(ipv6_subobject != nullptr) { _children["ipv6-subobject"] = ipv6_subobject; } if(unnumbered_subobject != nullptr) { _children["unnumbered-subobject"] = unnumbered_subobject; } if(as_subobject != nullptr) { _children["as-subobject"] = as_subobject; } if(srlg_subobject != nullptr) { _children["srlg-subobject"] = srlg_subobject; } if(lsp_subobject != nullptr) { _children["lsp-subobject"] = lsp_subobject; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::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 == "type") { type = value; type.value_namespace = name_space; type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "type") { type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "ipv4-subobject" || name == "ipv6-subobject" || name == "unnumbered-subobject" || name == "as-subobject" || name == "srlg-subobject" || name == "lsp-subobject" || name == "type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::Ipv4Subobject() : address{YType::str, "address"}, prefix_len{YType::uint8, "prefix-len"}, attribute{YType::enumeration, "attribute"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "ipv4-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::~Ipv4Subobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::has_data() const { if (is_presence_container) return true; return address.is_set || prefix_len.is_set || attribute.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::has_operation() const { return is_set(yfilter) || ydk::is_set(address.yfilter) || ydk::is_set(prefix_len.yfilter) || ydk::is_set(attribute.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv4-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata()); if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata()); if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::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 == "address") { address = value; address.value_namespace = name_space; address.value_namespace_prefix = name_space_prefix; } if(value_path == "prefix-len") { prefix_len = value; prefix_len.value_namespace = name_space; prefix_len.value_namespace_prefix = name_space_prefix; } if(value_path == "attribute") { attribute = value; attribute.value_namespace = name_space; attribute.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "address") { address.yfilter = yfilter; } if(value_path == "prefix-len") { prefix_len.yfilter = yfilter; } if(value_path == "attribute") { attribute.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv4Subobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::Ipv6Subobject() : address{YType::str, "address"}, prefix_len{YType::uint8, "prefix-len"}, attribute{YType::enumeration, "attribute"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "ipv6-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::~Ipv6Subobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::has_data() const { if (is_presence_container) return true; return address.is_set || prefix_len.is_set || attribute.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::has_operation() const { return is_set(yfilter) || ydk::is_set(address.yfilter) || ydk::is_set(prefix_len.yfilter) || ydk::is_set(attribute.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv6-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata()); if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata()); if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::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 == "address") { address = value; address.value_namespace = name_space; address.value_namespace_prefix = name_space_prefix; } if(value_path == "prefix-len") { prefix_len = value; prefix_len.value_namespace = name_space; prefix_len.value_namespace_prefix = name_space_prefix; } if(value_path == "attribute") { attribute = value; attribute.value_namespace = name_space; attribute.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "address") { address.yfilter = yfilter; } if(value_path == "prefix-len") { prefix_len.yfilter = yfilter; } if(value_path == "attribute") { attribute.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::Ipv6Subobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::UnnumberedSubobject() : te_router_id{YType::str, "te-router-id"}, interface_id{YType::uint32, "interface-id"}, attribute{YType::enumeration, "attribute"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "unnumbered-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::~UnnumberedSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::has_data() const { if (is_presence_container) return true; return te_router_id.is_set || interface_id.is_set || attribute.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(te_router_id.yfilter) || ydk::is_set(interface_id.yfilter) || ydk::is_set(attribute.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "unnumbered-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (te_router_id.is_set || is_set(te_router_id.yfilter)) leaf_name_data.push_back(te_router_id.get_name_leafdata()); if (interface_id.is_set || is_set(interface_id.yfilter)) leaf_name_data.push_back(interface_id.get_name_leafdata()); if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::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 == "te-router-id") { te_router_id = value; te_router_id.value_namespace = name_space; te_router_id.value_namespace_prefix = name_space_prefix; } if(value_path == "interface-id") { interface_id = value; interface_id.value_namespace = name_space; interface_id.value_namespace_prefix = name_space_prefix; } if(value_path == "attribute") { attribute = value; attribute.value_namespace = name_space; attribute.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "te-router-id") { te_router_id.yfilter = yfilter; } if(value_path == "interface-id") { interface_id.yfilter = yfilter; } if(value_path == "attribute") { attribute.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::UnnumberedSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "te-router-id" || name == "interface-id" || name == "attribute" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::AsSubobject() : as_number{YType::uint16, "as-number"} { yang_name = "as-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::~AsSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::has_data() const { if (is_presence_container) return true; return as_number.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(as_number.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "as-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::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> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "as-number") { as_number.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::AsSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "as-number") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::SrlgSubobject() : srlg_id{YType::uint32, "srlg-id"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "srlg-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::~SrlgSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::has_data() const { if (is_presence_container) return true; return srlg_id.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(srlg_id.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "srlg-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (srlg_id.is_set || is_set(srlg_id.yfilter)) leaf_name_data.push_back(srlg_id.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::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 == "srlg-id") { srlg_id = value; srlg_id.value_namespace = name_space; srlg_id.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "srlg-id") { srlg_id.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::SrlgSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "srlg-id" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::LspSubobject() : ignore_lsp_id{YType::boolean, "ignore-lsp-id"}, processing_node_exception{YType::boolean, "processing-node-exception"}, penultimate_node_exception{YType::boolean, "penultimate-node-exception"}, destination_node_exception{YType::boolean, "destination-node-exception"}, exclusion_type{YType::enumeration, "exclusion-type"} , fec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec>()) { fec->parent = this; yang_name = "lsp-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::~LspSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::has_data() const { if (is_presence_container) return true; return ignore_lsp_id.is_set || processing_node_exception.is_set || penultimate_node_exception.is_set || destination_node_exception.is_set || exclusion_type.is_set || (fec != nullptr && fec->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(ignore_lsp_id.yfilter) || ydk::is_set(processing_node_exception.yfilter) || ydk::is_set(penultimate_node_exception.yfilter) || ydk::is_set(destination_node_exception.yfilter) || ydk::is_set(exclusion_type.yfilter) || (fec != nullptr && fec->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "lsp-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (ignore_lsp_id.is_set || is_set(ignore_lsp_id.yfilter)) leaf_name_data.push_back(ignore_lsp_id.get_name_leafdata()); if (processing_node_exception.is_set || is_set(processing_node_exception.yfilter)) leaf_name_data.push_back(processing_node_exception.get_name_leafdata()); if (penultimate_node_exception.is_set || is_set(penultimate_node_exception.yfilter)) leaf_name_data.push_back(penultimate_node_exception.get_name_leafdata()); if (destination_node_exception.is_set || is_set(destination_node_exception.yfilter)) leaf_name_data.push_back(destination_node_exception.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "fec") { if(fec == nullptr) { fec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec>(); } return fec; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(fec != nullptr) { _children["fec"] = fec; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::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 == "ignore-lsp-id") { ignore_lsp_id = value; ignore_lsp_id.value_namespace = name_space; ignore_lsp_id.value_namespace_prefix = name_space_prefix; } if(value_path == "processing-node-exception") { processing_node_exception = value; processing_node_exception.value_namespace = name_space; processing_node_exception.value_namespace_prefix = name_space_prefix; } if(value_path == "penultimate-node-exception") { penultimate_node_exception = value; penultimate_node_exception.value_namespace = name_space; penultimate_node_exception.value_namespace_prefix = name_space_prefix; } if(value_path == "destination-node-exception") { destination_node_exception = value; destination_node_exception.value_namespace = name_space; destination_node_exception.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "ignore-lsp-id") { ignore_lsp_id.yfilter = yfilter; } if(value_path == "processing-node-exception") { processing_node_exception.yfilter = yfilter; } if(value_path == "penultimate-node-exception") { penultimate_node_exception.yfilter = yfilter; } if(value_path == "destination-node-exception") { destination_node_exception.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "fec" || name == "ignore-lsp-id" || name == "processing-node-exception" || name == "penultimate-node-exception" || name == "destination-node-exception" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::Fec() : fec_lsp_id{YType::uint16, "fec-lsp-id"}, fec_tunnel_id{YType::uint16, "fec-tunnel-id"}, fec_extended_tunnel_id{YType::str, "fec-extended-tunnel-id"}, fec_source{YType::str, "fec-source"}, fec_vrf{YType::str, "fec-vrf"} , fec_destination_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo>()) { fec_destination_info->parent = this; yang_name = "fec"; yang_parent_name = "lsp-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::~Fec() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::has_data() const { if (is_presence_container) return true; return fec_lsp_id.is_set || fec_tunnel_id.is_set || fec_extended_tunnel_id.is_set || fec_source.is_set || fec_vrf.is_set || (fec_destination_info != nullptr && fec_destination_info->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::has_operation() const { return is_set(yfilter) || ydk::is_set(fec_lsp_id.yfilter) || ydk::is_set(fec_tunnel_id.yfilter) || ydk::is_set(fec_extended_tunnel_id.yfilter) || ydk::is_set(fec_source.yfilter) || ydk::is_set(fec_vrf.yfilter) || (fec_destination_info != nullptr && fec_destination_info->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "fec"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (fec_lsp_id.is_set || is_set(fec_lsp_id.yfilter)) leaf_name_data.push_back(fec_lsp_id.get_name_leafdata()); if (fec_tunnel_id.is_set || is_set(fec_tunnel_id.yfilter)) leaf_name_data.push_back(fec_tunnel_id.get_name_leafdata()); if (fec_extended_tunnel_id.is_set || is_set(fec_extended_tunnel_id.yfilter)) leaf_name_data.push_back(fec_extended_tunnel_id.get_name_leafdata()); if (fec_source.is_set || is_set(fec_source.yfilter)) leaf_name_data.push_back(fec_source.get_name_leafdata()); if (fec_vrf.is_set || is_set(fec_vrf.yfilter)) leaf_name_data.push_back(fec_vrf.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "fec-destination-info") { if(fec_destination_info == nullptr) { fec_destination_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo>(); } return fec_destination_info; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(fec_destination_info != nullptr) { _children["fec-destination-info"] = fec_destination_info; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::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 == "fec-lsp-id") { fec_lsp_id = value; fec_lsp_id.value_namespace = name_space; fec_lsp_id.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-tunnel-id") { fec_tunnel_id = value; fec_tunnel_id.value_namespace = name_space; fec_tunnel_id.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-extended-tunnel-id") { fec_extended_tunnel_id = value; fec_extended_tunnel_id.value_namespace = name_space; fec_extended_tunnel_id.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-source") { fec_source = value; fec_source.value_namespace = name_space; fec_source.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-vrf") { fec_vrf = value; fec_vrf.value_namespace = name_space; fec_vrf.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "fec-lsp-id") { fec_lsp_id.yfilter = yfilter; } if(value_path == "fec-tunnel-id") { fec_tunnel_id.yfilter = yfilter; } if(value_path == "fec-extended-tunnel-id") { fec_extended_tunnel_id.yfilter = yfilter; } if(value_path == "fec-source") { fec_source.yfilter = yfilter; } if(value_path == "fec-vrf") { fec_vrf.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::has_leaf_or_child_of_name(const std::string & name) const { if(name == "fec-destination-info" || name == "fec-lsp-id" || name == "fec-tunnel-id" || name == "fec-extended-tunnel-id" || name == "fec-source" || name == "fec-vrf") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::FecDestinationInfo() : fec_ctype{YType::enumeration, "fec-ctype"}, p2p_lsp_destination{YType::str, "p2p-lsp-destination"}, fec_destination_p2mp_id{YType::uint32, "fec-destination-p2mp-id"} { yang_name = "fec-destination-info"; yang_parent_name = "fec"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::~FecDestinationInfo() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_data() const { if (is_presence_container) return true; return fec_ctype.is_set || p2p_lsp_destination.is_set || fec_destination_p2mp_id.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_operation() const { return is_set(yfilter) || ydk::is_set(fec_ctype.yfilter) || ydk::is_set(p2p_lsp_destination.yfilter) || ydk::is_set(fec_destination_p2mp_id.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "fec-destination-info"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (fec_ctype.is_set || is_set(fec_ctype.yfilter)) leaf_name_data.push_back(fec_ctype.get_name_leafdata()); if (p2p_lsp_destination.is_set || is_set(p2p_lsp_destination.yfilter)) leaf_name_data.push_back(p2p_lsp_destination.get_name_leafdata()); if (fec_destination_p2mp_id.is_set || is_set(fec_destination_p2mp_id.yfilter)) leaf_name_data.push_back(fec_destination_p2mp_id.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::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 == "fec-ctype") { fec_ctype = value; fec_ctype.value_namespace = name_space; fec_ctype.value_namespace_prefix = name_space_prefix; } if(value_path == "p2p-lsp-destination") { p2p_lsp_destination = value; p2p_lsp_destination.value_namespace = name_space; p2p_lsp_destination.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-destination-p2mp-id") { fec_destination_p2mp_id = value; fec_destination_p2mp_id.value_namespace = name_space; fec_destination_p2mp_id.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "fec-ctype") { fec_ctype.yfilter = yfilter; } if(value_path == "p2p-lsp-destination") { p2p_lsp_destination.yfilter = yfilter; } if(value_path == "fec-destination-p2mp-id") { fec_destination_p2mp_id.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetXro::Xro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_leaf_or_child_of_name(const std::string & name) const { if(name == "fec-ctype" || name == "p2p-lsp-destination" || name == "fec-destination-p2mp-id") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::AttributeSetP2mpte() : fast_reroute{YType::boolean, "fast-reroute"}, frr_bandwidth_protection{YType::boolean, "frr-bandwidth-protection"}, setup_priority{YType::uint8, "setup-priority"}, hold_priority{YType::uint8, "hold-priority"}, is_priority_configured{YType::boolean, "is-priority-configured"}, configured_bandwidth{YType::uint32, "configured-bandwidth"}, dste_class_type{YType::uint8, "dste-class-type"}, is_bandwidth_configured{YType::boolean, "is-bandwidth-configured"}, is_affinity_configured{YType::boolean, "is-affinity-configured"} , affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity>()) , tunnel_id(this, {}) { affinity->parent = this; yang_name = "attribute-set-p2mpte"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::~AttributeSetP2mpte() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_data()) return true; } return fast_reroute.is_set || frr_bandwidth_protection.is_set || setup_priority.is_set || hold_priority.is_set || is_priority_configured.is_set || configured_bandwidth.is_set || dste_class_type.is_set || is_bandwidth_configured.is_set || is_affinity_configured.is_set || (affinity != nullptr && affinity->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::has_operation() const { for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(fast_reroute.yfilter) || ydk::is_set(frr_bandwidth_protection.yfilter) || ydk::is_set(setup_priority.yfilter) || ydk::is_set(hold_priority.yfilter) || ydk::is_set(is_priority_configured.yfilter) || ydk::is_set(configured_bandwidth.yfilter) || ydk::is_set(dste_class_type.yfilter) || ydk::is_set(is_bandwidth_configured.yfilter) || ydk::is_set(is_affinity_configured.yfilter) || (affinity != nullptr && affinity->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-p2mpte"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (fast_reroute.is_set || is_set(fast_reroute.yfilter)) leaf_name_data.push_back(fast_reroute.get_name_leafdata()); if (frr_bandwidth_protection.is_set || is_set(frr_bandwidth_protection.yfilter)) leaf_name_data.push_back(frr_bandwidth_protection.get_name_leafdata()); if (setup_priority.is_set || is_set(setup_priority.yfilter)) leaf_name_data.push_back(setup_priority.get_name_leafdata()); if (hold_priority.is_set || is_set(hold_priority.yfilter)) leaf_name_data.push_back(hold_priority.get_name_leafdata()); if (is_priority_configured.is_set || is_set(is_priority_configured.yfilter)) leaf_name_data.push_back(is_priority_configured.get_name_leafdata()); if (configured_bandwidth.is_set || is_set(configured_bandwidth.yfilter)) leaf_name_data.push_back(configured_bandwidth.get_name_leafdata()); if (dste_class_type.is_set || is_set(dste_class_type.yfilter)) leaf_name_data.push_back(dste_class_type.get_name_leafdata()); if (is_bandwidth_configured.is_set || is_set(is_bandwidth_configured.yfilter)) leaf_name_data.push_back(is_bandwidth_configured.get_name_leafdata()); if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "affinity") { if(affinity == nullptr) { affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity>(); } return affinity; } if(child_yang_name == "tunnel-id") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId>(); ent_->parent = this; tunnel_id.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(affinity != nullptr) { _children["affinity"] = affinity; } count_ = 0; for (auto ent_ : tunnel_id.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::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 == "fast-reroute") { fast_reroute = value; fast_reroute.value_namespace = name_space; fast_reroute.value_namespace_prefix = name_space_prefix; } if(value_path == "frr-bandwidth-protection") { frr_bandwidth_protection = value; frr_bandwidth_protection.value_namespace = name_space; frr_bandwidth_protection.value_namespace_prefix = name_space_prefix; } if(value_path == "setup-priority") { setup_priority = value; setup_priority.value_namespace = name_space; setup_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "hold-priority") { hold_priority = value; hold_priority.value_namespace = name_space; hold_priority.value_namespace_prefix = name_space_prefix; } if(value_path == "is-priority-configured") { is_priority_configured = value; is_priority_configured.value_namespace = name_space; is_priority_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "configured-bandwidth") { configured_bandwidth = value; configured_bandwidth.value_namespace = name_space; configured_bandwidth.value_namespace_prefix = name_space_prefix; } if(value_path == "dste-class-type") { dste_class_type = value; dste_class_type.value_namespace = name_space; dste_class_type.value_namespace_prefix = name_space_prefix; } if(value_path == "is-bandwidth-configured") { is_bandwidth_configured = value; is_bandwidth_configured.value_namespace = name_space; is_bandwidth_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-affinity-configured") { is_affinity_configured = value; is_affinity_configured.value_namespace = name_space; is_affinity_configured.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "fast-reroute") { fast_reroute.yfilter = yfilter; } if(value_path == "frr-bandwidth-protection") { frr_bandwidth_protection.yfilter = yfilter; } if(value_path == "setup-priority") { setup_priority.yfilter = yfilter; } if(value_path == "hold-priority") { hold_priority.yfilter = yfilter; } if(value_path == "is-priority-configured") { is_priority_configured.yfilter = yfilter; } if(value_path == "configured-bandwidth") { configured_bandwidth.yfilter = yfilter; } if(value_path == "dste-class-type") { dste_class_type.yfilter = yfilter; } if(value_path == "is-bandwidth-configured") { is_bandwidth_configured.yfilter = yfilter; } if(value_path == "is-affinity-configured") { is_affinity_configured.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::has_leaf_or_child_of_name(const std::string & name) const { if(name == "affinity" || name == "tunnel-id" || name == "fast-reroute" || name == "frr-bandwidth-protection" || name == "setup-priority" || name == "hold-priority" || name == "is-priority-configured" || name == "configured-bandwidth" || name == "dste-class-type" || name == "is-bandwidth-configured" || name == "is-affinity-configured") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::Affinity() : affinity_bits{YType::uint32, "affinity-bits"}, affinity_mask{YType::uint32, "affinity-mask"} , named_affinity(this, {}) { yang_name = "affinity"; yang_parent_name = "attribute-set-p2mpte"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::~Affinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_data()) return true; } return affinity_bits.is_set || affinity_mask.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::has_operation() const { for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(affinity_bits.yfilter) || ydk::is_set(affinity_mask.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "affinity"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata()); if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "named-affinity") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity>(); ent_->parent = this; named_affinity.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : named_affinity.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::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 == "affinity-bits") { affinity_bits = value; affinity_bits.value_namespace = name_space; affinity_bits.value_namespace_prefix = name_space_prefix; } if(value_path == "affinity-mask") { affinity_mask = value; affinity_mask.value_namespace = name_space; affinity_mask.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "affinity-bits") { affinity_bits.yfilter = yfilter; } if(value_path == "affinity-mask") { affinity_mask.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::NamedAffinity() : constraint_type{YType::uint8, "constraint-type"}, constraint_value{YType::uint32, "constraint-value"}, forward_ref_value{YType::uint32, "forward-ref-value"} , constraint_extended_value(this, {}) , extended_forward_ref_value(this, {}) { yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::~NamedAffinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_data()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_data()) return true; } return constraint_type.is_set || constraint_value.is_set || forward_ref_value.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::has_operation() const { for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_operation()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(constraint_type.yfilter) || ydk::is_set(constraint_value.yfilter) || ydk::is_set(forward_ref_value.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "named-affinity"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata()); if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata()); if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "constraint-extended-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue>(); ent_->parent = this; constraint_extended_value.append(ent_); return ent_; } if(child_yang_name == "extended-forward-ref-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue>(); ent_->parent = this; extended_forward_ref_value.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : constraint_extended_value.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_ : extended_forward_ref_value.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::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 == "constraint-type") { constraint_type = value; constraint_type.value_namespace = name_space; constraint_type.value_namespace_prefix = name_space_prefix; } if(value_path == "constraint-value") { constraint_value = value; constraint_value.value_namespace = name_space; constraint_value.value_namespace_prefix = name_space_prefix; } if(value_path == "forward-ref-value") { forward_ref_value = value; forward_ref_value.value_namespace = name_space; forward_ref_value.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "constraint-type") { constraint_type.yfilter = yfilter; } if(value_path == "constraint-value") { constraint_value.yfilter = yfilter; } if(value_path == "forward-ref-value") { forward_ref_value.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue() : entry{YType::uint32, "entry"} { yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "constraint-extended-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue() : entry{YType::uint32, "entry"} { yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "extended-forward-ref-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::TunnelId() : entry{YType::uint16, "entry"} { yang_name = "tunnel-id"; yang_parent_name = "attribute-set-p2mpte"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::~TunnelId() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "tunnel-id"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2mpte::TunnelId::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::AttributeSetApsPp() : snc_mode{YType::enumeration, "snc-mode"}, tcm_id{YType::uint32, "tcm-id"}, protection_type{YType::enumeration, "protection-type"}, protection_mode{YType::enumeration, "protection-mode"}, wait_to_restore_time{YType::uint32, "wait-to-restore-time"}, hold_off_time{YType::uint32, "hold-off-time"}, path_prot_profile_type{YType::enumeration, "path-prot-profile-type"}, restoration_style{YType::enumeration, "restoration-style"} , revert_schedule(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule>()) { revert_schedule->parent = this; yang_name = "attribute-set-aps-pp"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::~AttributeSetApsPp() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::has_data() const { if (is_presence_container) return true; return snc_mode.is_set || tcm_id.is_set || protection_type.is_set || protection_mode.is_set || wait_to_restore_time.is_set || hold_off_time.is_set || path_prot_profile_type.is_set || restoration_style.is_set || (revert_schedule != nullptr && revert_schedule->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::has_operation() const { return is_set(yfilter) || ydk::is_set(snc_mode.yfilter) || ydk::is_set(tcm_id.yfilter) || ydk::is_set(protection_type.yfilter) || ydk::is_set(protection_mode.yfilter) || ydk::is_set(wait_to_restore_time.yfilter) || ydk::is_set(hold_off_time.yfilter) || ydk::is_set(path_prot_profile_type.yfilter) || ydk::is_set(restoration_style.yfilter) || (revert_schedule != nullptr && revert_schedule->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-aps-pp"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (snc_mode.is_set || is_set(snc_mode.yfilter)) leaf_name_data.push_back(snc_mode.get_name_leafdata()); if (tcm_id.is_set || is_set(tcm_id.yfilter)) leaf_name_data.push_back(tcm_id.get_name_leafdata()); if (protection_type.is_set || is_set(protection_type.yfilter)) leaf_name_data.push_back(protection_type.get_name_leafdata()); if (protection_mode.is_set || is_set(protection_mode.yfilter)) leaf_name_data.push_back(protection_mode.get_name_leafdata()); if (wait_to_restore_time.is_set || is_set(wait_to_restore_time.yfilter)) leaf_name_data.push_back(wait_to_restore_time.get_name_leafdata()); if (hold_off_time.is_set || is_set(hold_off_time.yfilter)) leaf_name_data.push_back(hold_off_time.get_name_leafdata()); if (path_prot_profile_type.is_set || is_set(path_prot_profile_type.yfilter)) leaf_name_data.push_back(path_prot_profile_type.get_name_leafdata()); if (restoration_style.is_set || is_set(restoration_style.yfilter)) leaf_name_data.push_back(restoration_style.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "revert-schedule") { if(revert_schedule == nullptr) { revert_schedule = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule>(); } return revert_schedule; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(revert_schedule != nullptr) { _children["revert-schedule"] = revert_schedule; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::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 == "snc-mode") { snc_mode = value; snc_mode.value_namespace = name_space; snc_mode.value_namespace_prefix = name_space_prefix; } if(value_path == "tcm-id") { tcm_id = value; tcm_id.value_namespace = name_space; tcm_id.value_namespace_prefix = name_space_prefix; } if(value_path == "protection-type") { protection_type = value; protection_type.value_namespace = name_space; protection_type.value_namespace_prefix = name_space_prefix; } if(value_path == "protection-mode") { protection_mode = value; protection_mode.value_namespace = name_space; protection_mode.value_namespace_prefix = name_space_prefix; } if(value_path == "wait-to-restore-time") { wait_to_restore_time = value; wait_to_restore_time.value_namespace = name_space; wait_to_restore_time.value_namespace_prefix = name_space_prefix; } if(value_path == "hold-off-time") { hold_off_time = value; hold_off_time.value_namespace = name_space; hold_off_time.value_namespace_prefix = name_space_prefix; } if(value_path == "path-prot-profile-type") { path_prot_profile_type = value; path_prot_profile_type.value_namespace = name_space; path_prot_profile_type.value_namespace_prefix = name_space_prefix; } if(value_path == "restoration-style") { restoration_style = value; restoration_style.value_namespace = name_space; restoration_style.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "snc-mode") { snc_mode.yfilter = yfilter; } if(value_path == "tcm-id") { tcm_id.yfilter = yfilter; } if(value_path == "protection-type") { protection_type.yfilter = yfilter; } if(value_path == "protection-mode") { protection_mode.yfilter = yfilter; } if(value_path == "wait-to-restore-time") { wait_to_restore_time.yfilter = yfilter; } if(value_path == "hold-off-time") { hold_off_time.yfilter = yfilter; } if(value_path == "path-prot-profile-type") { path_prot_profile_type.yfilter = yfilter; } if(value_path == "restoration-style") { restoration_style.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::has_leaf_or_child_of_name(const std::string & name) const { if(name == "revert-schedule" || name == "snc-mode" || name == "tcm-id" || name == "protection-type" || name == "protection-mode" || name == "wait-to-restore-time" || name == "hold-off-time" || name == "path-prot-profile-type" || name == "restoration-style") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::RevertSchedule() : schedulename{YType::str, "schedulename"}, schedule_date{YType::uint32, "schedule-date"}, schedule_frequency{YType::enumeration, "schedule-frequency"}, duration{YType::uint32, "duration"}, max_tries{YType::uint32, "max-tries"} { yang_name = "revert-schedule"; yang_parent_name = "attribute-set-aps-pp"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::~RevertSchedule() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::has_data() const { if (is_presence_container) return true; return schedulename.is_set || schedule_date.is_set || schedule_frequency.is_set || duration.is_set || max_tries.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::has_operation() const { return is_set(yfilter) || ydk::is_set(schedulename.yfilter) || ydk::is_set(schedule_date.yfilter) || ydk::is_set(schedule_frequency.yfilter) || ydk::is_set(duration.yfilter) || ydk::is_set(max_tries.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "revert-schedule"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (schedulename.is_set || is_set(schedulename.yfilter)) leaf_name_data.push_back(schedulename.get_name_leafdata()); if (schedule_date.is_set || is_set(schedule_date.yfilter)) leaf_name_data.push_back(schedule_date.get_name_leafdata()); if (schedule_frequency.is_set || is_set(schedule_frequency.yfilter)) leaf_name_data.push_back(schedule_frequency.get_name_leafdata()); if (duration.is_set || is_set(duration.yfilter)) leaf_name_data.push_back(duration.get_name_leafdata()); if (max_tries.is_set || is_set(max_tries.yfilter)) leaf_name_data.push_back(max_tries.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::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 == "schedulename") { schedulename = value; schedulename.value_namespace = name_space; schedulename.value_namespace_prefix = name_space_prefix; } if(value_path == "schedule-date") { schedule_date = value; schedule_date.value_namespace = name_space; schedule_date.value_namespace_prefix = name_space_prefix; } if(value_path == "schedule-frequency") { schedule_frequency = value; schedule_frequency.value_namespace = name_space; schedule_frequency.value_namespace_prefix = name_space_prefix; } if(value_path == "duration") { duration = value; duration.value_namespace = name_space; duration.value_namespace_prefix = name_space_prefix; } if(value_path == "max-tries") { max_tries = value; max_tries.value_namespace = name_space; max_tries.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "schedulename") { schedulename.yfilter = yfilter; } if(value_path == "schedule-date") { schedule_date.yfilter = yfilter; } if(value_path == "schedule-frequency") { schedule_frequency.yfilter = yfilter; } if(value_path == "duration") { duration.yfilter = yfilter; } if(value_path == "max-tries") { max_tries.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetApsPp::RevertSchedule::has_leaf_or_child_of_name(const std::string & name) const { if(name == "schedulename" || name == "schedule-date" || name == "schedule-frequency" || name == "duration" || name == "max-tries") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::AttributeSetP2pTe() : is_affinity_configured{YType::boolean, "is-affinity-configured"}, path_selection_segment_routing_adjacency_protection{YType::enumeration, "path-selection-segment-routing-adjacency-protection"}, is_path_selection_segment_routing_adjacency_protection_configured{YType::boolean, "is-path-selection-segment-routing-adjacency-protection-configured"}, path_invalidation_timeout{YType::uint32, "path-invalidation-timeout"}, path_selection_invalidation_action{YType::enumeration, "path-selection-invalidation-action"}, is_path_invalidation_timeout_configured{YType::boolean, "is-path-invalidation-timeout-configured"}, is_path_invalidation_action_configured{YType::boolean, "is-path-invalidation-action-configured"}, path_selection_metric{YType::enumeration, "path-selection-metric"}, is_path_selection_metric_configured{YType::boolean, "is-path-selection-metric-configured"}, path_selection_segment_routing_margin{YType::uint32, "path-selection-segment-routing-margin"}, is_path_selection_segment_routing_margin_relative{YType::boolean, "is-path-selection-segment-routing-margin-relative"}, is_path_selection_segment_routing_margin_configured{YType::boolean, "is-path-selection-segment-routing-margin-configured"}, path_selection_segment_routing_segment_limit{YType::uint32, "path-selection-segment-routing-segment-limit"}, is_path_selection_segment_routing_segment_limit_configured{YType::boolean, "is-path-selection-segment-routing-segment-limit-configured"}, is_path_select_configured{YType::boolean, "is-path-select-configured"}, is_prepend_list_configured{YType::boolean, "is-prepend-list-configured"}, is_pce_configured{YType::boolean, "is-pce-configured"}, is_pce_disj_source_configured{YType::boolean, "is-pce-disj-source-configured"}, is_pce_disj_type_configured{YType::boolean, "is-pce-disj-type-configured"}, is_pce_disj_group_id_configured{YType::boolean, "is-pce-disj-group-id-configured"}, pcedp_source_address{YType::uint32, "pcedp-source-address"}, pcedp_type{YType::enumeration, "pcedp-type"}, pcedp_group_id{YType::uint32, "pcedp-group-id"}, is_pceb_dj_source_configured{YType::boolean, "is-pceb-dj-source-configured"}, is_pcebd_group_id_configured{YType::boolean, "is-pcebd-group-id-configured"}, pcebd_source_address{YType::uint32, "pcebd-source-address"}, pcebd_group_id{YType::uint32, "pcebd-group-id"} , affinity(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity>()) , logging(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging>()) , prepend_list(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList>()) , tunnel_id(this, {}) { affinity->parent = this; logging->parent = this; prepend_list->parent = this; yang_name = "attribute-set-p2p-te"; yang_parent_name = "attribute-set-union"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::~AttributeSetP2pTe() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_data()) return true; } return is_affinity_configured.is_set || path_selection_segment_routing_adjacency_protection.is_set || is_path_selection_segment_routing_adjacency_protection_configured.is_set || path_invalidation_timeout.is_set || path_selection_invalidation_action.is_set || is_path_invalidation_timeout_configured.is_set || is_path_invalidation_action_configured.is_set || path_selection_metric.is_set || is_path_selection_metric_configured.is_set || path_selection_segment_routing_margin.is_set || is_path_selection_segment_routing_margin_relative.is_set || is_path_selection_segment_routing_margin_configured.is_set || path_selection_segment_routing_segment_limit.is_set || is_path_selection_segment_routing_segment_limit_configured.is_set || is_path_select_configured.is_set || is_prepend_list_configured.is_set || is_pce_configured.is_set || is_pce_disj_source_configured.is_set || is_pce_disj_type_configured.is_set || is_pce_disj_group_id_configured.is_set || pcedp_source_address.is_set || pcedp_type.is_set || pcedp_group_id.is_set || is_pceb_dj_source_configured.is_set || is_pcebd_group_id_configured.is_set || pcebd_source_address.is_set || pcebd_group_id.is_set || (affinity != nullptr && affinity->has_data()) || (logging != nullptr && logging->has_data()) || (prepend_list != nullptr && prepend_list->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::has_operation() const { for (std::size_t index=0; index<tunnel_id.len(); index++) { if(tunnel_id[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(is_affinity_configured.yfilter) || ydk::is_set(path_selection_segment_routing_adjacency_protection.yfilter) || ydk::is_set(is_path_selection_segment_routing_adjacency_protection_configured.yfilter) || ydk::is_set(path_invalidation_timeout.yfilter) || ydk::is_set(path_selection_invalidation_action.yfilter) || ydk::is_set(is_path_invalidation_timeout_configured.yfilter) || ydk::is_set(is_path_invalidation_action_configured.yfilter) || ydk::is_set(path_selection_metric.yfilter) || ydk::is_set(is_path_selection_metric_configured.yfilter) || ydk::is_set(path_selection_segment_routing_margin.yfilter) || ydk::is_set(is_path_selection_segment_routing_margin_relative.yfilter) || ydk::is_set(is_path_selection_segment_routing_margin_configured.yfilter) || ydk::is_set(path_selection_segment_routing_segment_limit.yfilter) || ydk::is_set(is_path_selection_segment_routing_segment_limit_configured.yfilter) || ydk::is_set(is_path_select_configured.yfilter) || ydk::is_set(is_prepend_list_configured.yfilter) || ydk::is_set(is_pce_configured.yfilter) || ydk::is_set(is_pce_disj_source_configured.yfilter) || ydk::is_set(is_pce_disj_type_configured.yfilter) || ydk::is_set(is_pce_disj_group_id_configured.yfilter) || ydk::is_set(pcedp_source_address.yfilter) || ydk::is_set(pcedp_type.yfilter) || ydk::is_set(pcedp_group_id.yfilter) || ydk::is_set(is_pceb_dj_source_configured.yfilter) || ydk::is_set(is_pcebd_group_id_configured.yfilter) || ydk::is_set(pcebd_source_address.yfilter) || ydk::is_set(pcebd_group_id.yfilter) || (affinity != nullptr && affinity->has_operation()) || (logging != nullptr && logging->has_operation()) || (prepend_list != nullptr && prepend_list->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "attribute-set-p2p-te"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (is_affinity_configured.is_set || is_set(is_affinity_configured.yfilter)) leaf_name_data.push_back(is_affinity_configured.get_name_leafdata()); if (path_selection_segment_routing_adjacency_protection.is_set || is_set(path_selection_segment_routing_adjacency_protection.yfilter)) leaf_name_data.push_back(path_selection_segment_routing_adjacency_protection.get_name_leafdata()); if (is_path_selection_segment_routing_adjacency_protection_configured.is_set || is_set(is_path_selection_segment_routing_adjacency_protection_configured.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_adjacency_protection_configured.get_name_leafdata()); if (path_invalidation_timeout.is_set || is_set(path_invalidation_timeout.yfilter)) leaf_name_data.push_back(path_invalidation_timeout.get_name_leafdata()); if (path_selection_invalidation_action.is_set || is_set(path_selection_invalidation_action.yfilter)) leaf_name_data.push_back(path_selection_invalidation_action.get_name_leafdata()); if (is_path_invalidation_timeout_configured.is_set || is_set(is_path_invalidation_timeout_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_timeout_configured.get_name_leafdata()); if (is_path_invalidation_action_configured.is_set || is_set(is_path_invalidation_action_configured.yfilter)) leaf_name_data.push_back(is_path_invalidation_action_configured.get_name_leafdata()); if (path_selection_metric.is_set || is_set(path_selection_metric.yfilter)) leaf_name_data.push_back(path_selection_metric.get_name_leafdata()); if (is_path_selection_metric_configured.is_set || is_set(is_path_selection_metric_configured.yfilter)) leaf_name_data.push_back(is_path_selection_metric_configured.get_name_leafdata()); if (path_selection_segment_routing_margin.is_set || is_set(path_selection_segment_routing_margin.yfilter)) leaf_name_data.push_back(path_selection_segment_routing_margin.get_name_leafdata()); if (is_path_selection_segment_routing_margin_relative.is_set || is_set(is_path_selection_segment_routing_margin_relative.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_margin_relative.get_name_leafdata()); if (is_path_selection_segment_routing_margin_configured.is_set || is_set(is_path_selection_segment_routing_margin_configured.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_margin_configured.get_name_leafdata()); if (path_selection_segment_routing_segment_limit.is_set || is_set(path_selection_segment_routing_segment_limit.yfilter)) leaf_name_data.push_back(path_selection_segment_routing_segment_limit.get_name_leafdata()); if (is_path_selection_segment_routing_segment_limit_configured.is_set || is_set(is_path_selection_segment_routing_segment_limit_configured.yfilter)) leaf_name_data.push_back(is_path_selection_segment_routing_segment_limit_configured.get_name_leafdata()); if (is_path_select_configured.is_set || is_set(is_path_select_configured.yfilter)) leaf_name_data.push_back(is_path_select_configured.get_name_leafdata()); if (is_prepend_list_configured.is_set || is_set(is_prepend_list_configured.yfilter)) leaf_name_data.push_back(is_prepend_list_configured.get_name_leafdata()); if (is_pce_configured.is_set || is_set(is_pce_configured.yfilter)) leaf_name_data.push_back(is_pce_configured.get_name_leafdata()); if (is_pce_disj_source_configured.is_set || is_set(is_pce_disj_source_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_source_configured.get_name_leafdata()); if (is_pce_disj_type_configured.is_set || is_set(is_pce_disj_type_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_type_configured.get_name_leafdata()); if (is_pce_disj_group_id_configured.is_set || is_set(is_pce_disj_group_id_configured.yfilter)) leaf_name_data.push_back(is_pce_disj_group_id_configured.get_name_leafdata()); if (pcedp_source_address.is_set || is_set(pcedp_source_address.yfilter)) leaf_name_data.push_back(pcedp_source_address.get_name_leafdata()); if (pcedp_type.is_set || is_set(pcedp_type.yfilter)) leaf_name_data.push_back(pcedp_type.get_name_leafdata()); if (pcedp_group_id.is_set || is_set(pcedp_group_id.yfilter)) leaf_name_data.push_back(pcedp_group_id.get_name_leafdata()); if (is_pceb_dj_source_configured.is_set || is_set(is_pceb_dj_source_configured.yfilter)) leaf_name_data.push_back(is_pceb_dj_source_configured.get_name_leafdata()); if (is_pcebd_group_id_configured.is_set || is_set(is_pcebd_group_id_configured.yfilter)) leaf_name_data.push_back(is_pcebd_group_id_configured.get_name_leafdata()); if (pcebd_source_address.is_set || is_set(pcebd_source_address.yfilter)) leaf_name_data.push_back(pcebd_source_address.get_name_leafdata()); if (pcebd_group_id.is_set || is_set(pcebd_group_id.yfilter)) leaf_name_data.push_back(pcebd_group_id.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "affinity") { if(affinity == nullptr) { affinity = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity>(); } return affinity; } if(child_yang_name == "logging") { if(logging == nullptr) { logging = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging>(); } return logging; } if(child_yang_name == "prepend-list") { if(prepend_list == nullptr) { prepend_list = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList>(); } return prepend_list; } if(child_yang_name == "tunnel-id") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId>(); ent_->parent = this; tunnel_id.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(affinity != nullptr) { _children["affinity"] = affinity; } if(logging != nullptr) { _children["logging"] = logging; } if(prepend_list != nullptr) { _children["prepend-list"] = prepend_list; } count_ = 0; for (auto ent_ : tunnel_id.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::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 == "is-affinity-configured") { is_affinity_configured = value; is_affinity_configured.value_namespace = name_space; is_affinity_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "path-selection-segment-routing-adjacency-protection") { path_selection_segment_routing_adjacency_protection = value; path_selection_segment_routing_adjacency_protection.value_namespace = name_space; path_selection_segment_routing_adjacency_protection.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-selection-segment-routing-adjacency-protection-configured") { is_path_selection_segment_routing_adjacency_protection_configured = value; is_path_selection_segment_routing_adjacency_protection_configured.value_namespace = name_space; is_path_selection_segment_routing_adjacency_protection_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "path-invalidation-timeout") { path_invalidation_timeout = value; path_invalidation_timeout.value_namespace = name_space; path_invalidation_timeout.value_namespace_prefix = name_space_prefix; } if(value_path == "path-selection-invalidation-action") { path_selection_invalidation_action = value; path_selection_invalidation_action.value_namespace = name_space; path_selection_invalidation_action.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-invalidation-timeout-configured") { is_path_invalidation_timeout_configured = value; is_path_invalidation_timeout_configured.value_namespace = name_space; is_path_invalidation_timeout_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-invalidation-action-configured") { is_path_invalidation_action_configured = value; is_path_invalidation_action_configured.value_namespace = name_space; is_path_invalidation_action_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "path-selection-metric") { path_selection_metric = value; path_selection_metric.value_namespace = name_space; path_selection_metric.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-selection-metric-configured") { is_path_selection_metric_configured = value; is_path_selection_metric_configured.value_namespace = name_space; is_path_selection_metric_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "path-selection-segment-routing-margin") { path_selection_segment_routing_margin = value; path_selection_segment_routing_margin.value_namespace = name_space; path_selection_segment_routing_margin.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-selection-segment-routing-margin-relative") { is_path_selection_segment_routing_margin_relative = value; is_path_selection_segment_routing_margin_relative.value_namespace = name_space; is_path_selection_segment_routing_margin_relative.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-selection-segment-routing-margin-configured") { is_path_selection_segment_routing_margin_configured = value; is_path_selection_segment_routing_margin_configured.value_namespace = name_space; is_path_selection_segment_routing_margin_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "path-selection-segment-routing-segment-limit") { path_selection_segment_routing_segment_limit = value; path_selection_segment_routing_segment_limit.value_namespace = name_space; path_selection_segment_routing_segment_limit.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-selection-segment-routing-segment-limit-configured") { is_path_selection_segment_routing_segment_limit_configured = value; is_path_selection_segment_routing_segment_limit_configured.value_namespace = name_space; is_path_selection_segment_routing_segment_limit_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-path-select-configured") { is_path_select_configured = value; is_path_select_configured.value_namespace = name_space; is_path_select_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-prepend-list-configured") { is_prepend_list_configured = value; is_prepend_list_configured.value_namespace = name_space; is_prepend_list_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-configured") { is_pce_configured = value; is_pce_configured.value_namespace = name_space; is_pce_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-disj-source-configured") { is_pce_disj_source_configured = value; is_pce_disj_source_configured.value_namespace = name_space; is_pce_disj_source_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-disj-type-configured") { is_pce_disj_type_configured = value; is_pce_disj_type_configured.value_namespace = name_space; is_pce_disj_type_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pce-disj-group-id-configured") { is_pce_disj_group_id_configured = value; is_pce_disj_group_id_configured.value_namespace = name_space; is_pce_disj_group_id_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "pcedp-source-address") { pcedp_source_address = value; pcedp_source_address.value_namespace = name_space; pcedp_source_address.value_namespace_prefix = name_space_prefix; } if(value_path == "pcedp-type") { pcedp_type = value; pcedp_type.value_namespace = name_space; pcedp_type.value_namespace_prefix = name_space_prefix; } if(value_path == "pcedp-group-id") { pcedp_group_id = value; pcedp_group_id.value_namespace = name_space; pcedp_group_id.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pceb-dj-source-configured") { is_pceb_dj_source_configured = value; is_pceb_dj_source_configured.value_namespace = name_space; is_pceb_dj_source_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "is-pcebd-group-id-configured") { is_pcebd_group_id_configured = value; is_pcebd_group_id_configured.value_namespace = name_space; is_pcebd_group_id_configured.value_namespace_prefix = name_space_prefix; } if(value_path == "pcebd-source-address") { pcebd_source_address = value; pcebd_source_address.value_namespace = name_space; pcebd_source_address.value_namespace_prefix = name_space_prefix; } if(value_path == "pcebd-group-id") { pcebd_group_id = value; pcebd_group_id.value_namespace = name_space; pcebd_group_id.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "is-affinity-configured") { is_affinity_configured.yfilter = yfilter; } if(value_path == "path-selection-segment-routing-adjacency-protection") { path_selection_segment_routing_adjacency_protection.yfilter = yfilter; } if(value_path == "is-path-selection-segment-routing-adjacency-protection-configured") { is_path_selection_segment_routing_adjacency_protection_configured.yfilter = yfilter; } if(value_path == "path-invalidation-timeout") { path_invalidation_timeout.yfilter = yfilter; } if(value_path == "path-selection-invalidation-action") { path_selection_invalidation_action.yfilter = yfilter; } if(value_path == "is-path-invalidation-timeout-configured") { is_path_invalidation_timeout_configured.yfilter = yfilter; } if(value_path == "is-path-invalidation-action-configured") { is_path_invalidation_action_configured.yfilter = yfilter; } if(value_path == "path-selection-metric") { path_selection_metric.yfilter = yfilter; } if(value_path == "is-path-selection-metric-configured") { is_path_selection_metric_configured.yfilter = yfilter; } if(value_path == "path-selection-segment-routing-margin") { path_selection_segment_routing_margin.yfilter = yfilter; } if(value_path == "is-path-selection-segment-routing-margin-relative") { is_path_selection_segment_routing_margin_relative.yfilter = yfilter; } if(value_path == "is-path-selection-segment-routing-margin-configured") { is_path_selection_segment_routing_margin_configured.yfilter = yfilter; } if(value_path == "path-selection-segment-routing-segment-limit") { path_selection_segment_routing_segment_limit.yfilter = yfilter; } if(value_path == "is-path-selection-segment-routing-segment-limit-configured") { is_path_selection_segment_routing_segment_limit_configured.yfilter = yfilter; } if(value_path == "is-path-select-configured") { is_path_select_configured.yfilter = yfilter; } if(value_path == "is-prepend-list-configured") { is_prepend_list_configured.yfilter = yfilter; } if(value_path == "is-pce-configured") { is_pce_configured.yfilter = yfilter; } if(value_path == "is-pce-disj-source-configured") { is_pce_disj_source_configured.yfilter = yfilter; } if(value_path == "is-pce-disj-type-configured") { is_pce_disj_type_configured.yfilter = yfilter; } if(value_path == "is-pce-disj-group-id-configured") { is_pce_disj_group_id_configured.yfilter = yfilter; } if(value_path == "pcedp-source-address") { pcedp_source_address.yfilter = yfilter; } if(value_path == "pcedp-type") { pcedp_type.yfilter = yfilter; } if(value_path == "pcedp-group-id") { pcedp_group_id.yfilter = yfilter; } if(value_path == "is-pceb-dj-source-configured") { is_pceb_dj_source_configured.yfilter = yfilter; } if(value_path == "is-pcebd-group-id-configured") { is_pcebd_group_id_configured.yfilter = yfilter; } if(value_path == "pcebd-source-address") { pcebd_source_address.yfilter = yfilter; } if(value_path == "pcebd-group-id") { pcebd_group_id.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::has_leaf_or_child_of_name(const std::string & name) const { if(name == "affinity" || name == "logging" || name == "prepend-list" || name == "tunnel-id" || name == "is-affinity-configured" || name == "path-selection-segment-routing-adjacency-protection" || name == "is-path-selection-segment-routing-adjacency-protection-configured" || name == "path-invalidation-timeout" || name == "path-selection-invalidation-action" || name == "is-path-invalidation-timeout-configured" || name == "is-path-invalidation-action-configured" || name == "path-selection-metric" || name == "is-path-selection-metric-configured" || name == "path-selection-segment-routing-margin" || name == "is-path-selection-segment-routing-margin-relative" || name == "is-path-selection-segment-routing-margin-configured" || name == "path-selection-segment-routing-segment-limit" || name == "is-path-selection-segment-routing-segment-limit-configured" || name == "is-path-select-configured" || name == "is-prepend-list-configured" || name == "is-pce-configured" || name == "is-pce-disj-source-configured" || name == "is-pce-disj-type-configured" || name == "is-pce-disj-group-id-configured" || name == "pcedp-source-address" || name == "pcedp-type" || name == "pcedp-group-id" || name == "is-pceb-dj-source-configured" || name == "is-pcebd-group-id-configured" || name == "pcebd-source-address" || name == "pcebd-group-id") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::Affinity() : affinity_bits{YType::uint32, "affinity-bits"}, affinity_mask{YType::uint32, "affinity-mask"} , named_affinity(this, {}) { yang_name = "affinity"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::~Affinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_data()) return true; } return affinity_bits.is_set || affinity_mask.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::has_operation() const { for (std::size_t index=0; index<named_affinity.len(); index++) { if(named_affinity[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(affinity_bits.yfilter) || ydk::is_set(affinity_mask.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "affinity"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (affinity_bits.is_set || is_set(affinity_bits.yfilter)) leaf_name_data.push_back(affinity_bits.get_name_leafdata()); if (affinity_mask.is_set || is_set(affinity_mask.yfilter)) leaf_name_data.push_back(affinity_mask.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "named-affinity") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity>(); ent_->parent = this; named_affinity.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : named_affinity.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::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 == "affinity-bits") { affinity_bits = value; affinity_bits.value_namespace = name_space; affinity_bits.value_namespace_prefix = name_space_prefix; } if(value_path == "affinity-mask") { affinity_mask = value; affinity_mask.value_namespace = name_space; affinity_mask.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "affinity-bits") { affinity_bits.yfilter = yfilter; } if(value_path == "affinity-mask") { affinity_mask.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "named-affinity" || name == "affinity-bits" || name == "affinity-mask") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::NamedAffinity() : constraint_type{YType::uint8, "constraint-type"}, constraint_value{YType::uint32, "constraint-value"}, forward_ref_value{YType::uint32, "forward-ref-value"} , constraint_extended_value(this, {}) , extended_forward_ref_value(this, {}) { yang_name = "named-affinity"; yang_parent_name = "affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::~NamedAffinity() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_data()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_data()) return true; } return constraint_type.is_set || constraint_value.is_set || forward_ref_value.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::has_operation() const { for (std::size_t index=0; index<constraint_extended_value.len(); index++) { if(constraint_extended_value[index]->has_operation()) return true; } for (std::size_t index=0; index<extended_forward_ref_value.len(); index++) { if(extended_forward_ref_value[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(constraint_type.yfilter) || ydk::is_set(constraint_value.yfilter) || ydk::is_set(forward_ref_value.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "named-affinity"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (constraint_type.is_set || is_set(constraint_type.yfilter)) leaf_name_data.push_back(constraint_type.get_name_leafdata()); if (constraint_value.is_set || is_set(constraint_value.yfilter)) leaf_name_data.push_back(constraint_value.get_name_leafdata()); if (forward_ref_value.is_set || is_set(forward_ref_value.yfilter)) leaf_name_data.push_back(forward_ref_value.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "constraint-extended-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue>(); ent_->parent = this; constraint_extended_value.append(ent_); return ent_; } if(child_yang_name == "extended-forward-ref-value") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue>(); ent_->parent = this; extended_forward_ref_value.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : constraint_extended_value.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_ : extended_forward_ref_value.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::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 == "constraint-type") { constraint_type = value; constraint_type.value_namespace = name_space; constraint_type.value_namespace_prefix = name_space_prefix; } if(value_path == "constraint-value") { constraint_value = value; constraint_value.value_namespace = name_space; constraint_value.value_namespace_prefix = name_space_prefix; } if(value_path == "forward-ref-value") { forward_ref_value = value; forward_ref_value.value_namespace = name_space; forward_ref_value.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "constraint-type") { constraint_type.yfilter = yfilter; } if(value_path == "constraint-value") { constraint_value.yfilter = yfilter; } if(value_path == "forward-ref-value") { forward_ref_value.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::has_leaf_or_child_of_name(const std::string & name) const { if(name == "constraint-extended-value" || name == "extended-forward-ref-value" || name == "constraint-type" || name == "constraint-value" || name == "forward-ref-value") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::ConstraintExtendedValue() : entry{YType::uint32, "entry"} { yang_name = "constraint-extended-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::~ConstraintExtendedValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "constraint-extended-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ConstraintExtendedValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::ExtendedForwardRefValue() : entry{YType::uint32, "entry"} { yang_name = "extended-forward-ref-value"; yang_parent_name = "named-affinity"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::~ExtendedForwardRefValue() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "extended-forward-ref-value"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Affinity::NamedAffinity::ExtendedForwardRefValue::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::Logging() : lsp_state{YType::boolean, "lsp-state"}, s2l_state{YType::boolean, "s2l-state"}, lsp_re_route{YType::boolean, "lsp-re-route"}, lsp_re_opt{YType::boolean, "lsp-re-opt"}, lsp_insufficient_bw{YType::boolean, "lsp-insufficient-bw"}, lsp_bandwidth_change{YType::boolean, "lsp-bandwidth-change"}, lsp_pcalc_failure_logging_enabled{YType::boolean, "lsp-pcalc-failure-logging-enabled"}, all_logging_enabled{YType::boolean, "all-logging-enabled"} { yang_name = "logging"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::~Logging() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::has_data() const { if (is_presence_container) return true; return lsp_state.is_set || s2l_state.is_set || lsp_re_route.is_set || lsp_re_opt.is_set || lsp_insufficient_bw.is_set || lsp_bandwidth_change.is_set || lsp_pcalc_failure_logging_enabled.is_set || all_logging_enabled.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::has_operation() const { return is_set(yfilter) || ydk::is_set(lsp_state.yfilter) || ydk::is_set(s2l_state.yfilter) || ydk::is_set(lsp_re_route.yfilter) || ydk::is_set(lsp_re_opt.yfilter) || ydk::is_set(lsp_insufficient_bw.yfilter) || ydk::is_set(lsp_bandwidth_change.yfilter) || ydk::is_set(lsp_pcalc_failure_logging_enabled.yfilter) || ydk::is_set(all_logging_enabled.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "logging"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (lsp_state.is_set || is_set(lsp_state.yfilter)) leaf_name_data.push_back(lsp_state.get_name_leafdata()); if (s2l_state.is_set || is_set(s2l_state.yfilter)) leaf_name_data.push_back(s2l_state.get_name_leafdata()); if (lsp_re_route.is_set || is_set(lsp_re_route.yfilter)) leaf_name_data.push_back(lsp_re_route.get_name_leafdata()); if (lsp_re_opt.is_set || is_set(lsp_re_opt.yfilter)) leaf_name_data.push_back(lsp_re_opt.get_name_leafdata()); if (lsp_insufficient_bw.is_set || is_set(lsp_insufficient_bw.yfilter)) leaf_name_data.push_back(lsp_insufficient_bw.get_name_leafdata()); if (lsp_bandwidth_change.is_set || is_set(lsp_bandwidth_change.yfilter)) leaf_name_data.push_back(lsp_bandwidth_change.get_name_leafdata()); if (lsp_pcalc_failure_logging_enabled.is_set || is_set(lsp_pcalc_failure_logging_enabled.yfilter)) leaf_name_data.push_back(lsp_pcalc_failure_logging_enabled.get_name_leafdata()); if (all_logging_enabled.is_set || is_set(all_logging_enabled.yfilter)) leaf_name_data.push_back(all_logging_enabled.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::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 == "lsp-state") { lsp_state = value; lsp_state.value_namespace = name_space; lsp_state.value_namespace_prefix = name_space_prefix; } if(value_path == "s2l-state") { s2l_state = value; s2l_state.value_namespace = name_space; s2l_state.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-re-route") { lsp_re_route = value; lsp_re_route.value_namespace = name_space; lsp_re_route.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-re-opt") { lsp_re_opt = value; lsp_re_opt.value_namespace = name_space; lsp_re_opt.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-insufficient-bw") { lsp_insufficient_bw = value; lsp_insufficient_bw.value_namespace = name_space; lsp_insufficient_bw.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-bandwidth-change") { lsp_bandwidth_change = value; lsp_bandwidth_change.value_namespace = name_space; lsp_bandwidth_change.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-pcalc-failure-logging-enabled") { lsp_pcalc_failure_logging_enabled = value; lsp_pcalc_failure_logging_enabled.value_namespace = name_space; lsp_pcalc_failure_logging_enabled.value_namespace_prefix = name_space_prefix; } if(value_path == "all-logging-enabled") { all_logging_enabled = value; all_logging_enabled.value_namespace = name_space; all_logging_enabled.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "lsp-state") { lsp_state.yfilter = yfilter; } if(value_path == "s2l-state") { s2l_state.yfilter = yfilter; } if(value_path == "lsp-re-route") { lsp_re_route.yfilter = yfilter; } if(value_path == "lsp-re-opt") { lsp_re_opt.yfilter = yfilter; } if(value_path == "lsp-insufficient-bw") { lsp_insufficient_bw.yfilter = yfilter; } if(value_path == "lsp-bandwidth-change") { lsp_bandwidth_change.yfilter = yfilter; } if(value_path == "lsp-pcalc-failure-logging-enabled") { lsp_pcalc_failure_logging_enabled.yfilter = yfilter; } if(value_path == "all-logging-enabled") { all_logging_enabled.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::Logging::has_leaf_or_child_of_name(const std::string & name) const { if(name == "lsp-state" || name == "s2l-state" || name == "lsp-re-route" || name == "lsp-re-opt" || name == "lsp-insufficient-bw" || name == "lsp-bandwidth-change" || name == "lsp-pcalc-failure-logging-enabled" || name == "all-logging-enabled") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependList() : prepend_entry(this, {}) { yang_name = "prepend-list"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::~PrependList() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<prepend_entry.len(); index++) { if(prepend_entry[index]->has_data()) return true; } return false; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::has_operation() const { for (std::size_t index=0; index<prepend_entry.len(); index++) { if(prepend_entry[index]->has_operation()) return true; } return is_set(yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prepend-list"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "prepend-entry") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry>(); ent_->parent = this; prepend_entry.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : prepend_entry.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::set_value(const std::string & value_path, const std::string & value, const std::string & name_space, const std::string & name_space_prefix) { } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::set_filter(const std::string & value_path, YFilter yfilter) { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::has_leaf_or_child_of_name(const std::string & name) const { if(name == "prepend-entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::PrependEntry() : type{YType::enumeration, "type"}, index_{YType::uint32, "index"}, next_label{YType::uint32, "next-label"} { yang_name = "prepend-entry"; yang_parent_name = "prepend-list"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::~PrependEntry() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::has_data() const { if (is_presence_container) return true; return type.is_set || index_.is_set || next_label.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::has_operation() const { return is_set(yfilter) || ydk::is_set(type.yfilter) || ydk::is_set(index_.yfilter) || ydk::is_set(next_label.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "prepend-entry"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata()); if (index_.is_set || is_set(index_.yfilter)) leaf_name_data.push_back(index_.get_name_leafdata()); if (next_label.is_set || is_set(next_label.yfilter)) leaf_name_data.push_back(next_label.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::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 == "type") { type = value; type.value_namespace = name_space; type.value_namespace_prefix = name_space_prefix; } if(value_path == "index") { index_ = value; index_.value_namespace = name_space; index_.value_namespace_prefix = name_space_prefix; } if(value_path == "next-label") { next_label = value; next_label.value_namespace = name_space; next_label.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "type") { type.yfilter = yfilter; } if(value_path == "index") { index_.yfilter = yfilter; } if(value_path == "next-label") { next_label.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::PrependList::PrependEntry::has_leaf_or_child_of_name(const std::string & name) const { if(name == "type" || name == "index" || name == "next-label") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::TunnelId() : entry{YType::uint16, "entry"} { yang_name = "tunnel-id"; yang_parent_name = "attribute-set-p2p-te"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::~TunnelId() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::has_data() const { if (is_presence_container) return true; return entry.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::has_operation() const { return is_set(yfilter) || ydk::is_set(entry.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "tunnel-id"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (entry.is_set || is_set(entry.yfilter)) leaf_name_data.push_back(entry.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::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 == "entry") { entry = value; entry.value_namespace = name_space; entry.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "entry") { entry.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::XroAttributeSet::AttributeSetUnion::AttributeSetP2pTe::TunnelId::has_leaf_or_child_of_name(const std::string & name) const { if(name == "entry") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::PathCalculationError() : error_message{YType::str, "error-message"}, lsp_mode{YType::enumeration, "lsp-mode"}, log_time{YType::uint32, "log-time"} { yang_name = "path-calculation-error"; yang_parent_name = "active-path-option"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::~PathCalculationError() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::has_data() const { if (is_presence_container) return true; return error_message.is_set || lsp_mode.is_set || log_time.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::has_operation() const { return is_set(yfilter) || ydk::is_set(error_message.yfilter) || ydk::is_set(lsp_mode.yfilter) || ydk::is_set(log_time.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "path-calculation-error"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (error_message.is_set || is_set(error_message.yfilter)) leaf_name_data.push_back(error_message.get_name_leafdata()); if (lsp_mode.is_set || is_set(lsp_mode.yfilter)) leaf_name_data.push_back(lsp_mode.get_name_leafdata()); if (log_time.is_set || is_set(log_time.yfilter)) leaf_name_data.push_back(log_time.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::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 == "error-message") { error_message = value; error_message.value_namespace = name_space; error_message.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-mode") { lsp_mode = value; lsp_mode.value_namespace = name_space; lsp_mode.value_namespace_prefix = name_space_prefix; } if(value_path == "log-time") { log_time = value; log_time.value_namespace = name_space; log_time.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "error-message") { error_message.yfilter = yfilter; } if(value_path == "lsp-mode") { lsp_mode.yfilter = yfilter; } if(value_path == "log-time") { log_time.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::PathCalculationError::has_leaf_or_child_of_name(const std::string & name) const { if(name == "error-message" || name == "lsp-mode" || name == "log-time") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::RemergeError() : error_message{YType::str, "error-message"}, lsp_mode{YType::enumeration, "lsp-mode"}, log_time{YType::uint32, "log-time"} { yang_name = "remerge-error"; yang_parent_name = "active-path-option"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::~RemergeError() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::has_data() const { if (is_presence_container) return true; return error_message.is_set || lsp_mode.is_set || log_time.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::has_operation() const { return is_set(yfilter) || ydk::is_set(error_message.yfilter) || ydk::is_set(lsp_mode.yfilter) || ydk::is_set(log_time.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "remerge-error"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (error_message.is_set || is_set(error_message.yfilter)) leaf_name_data.push_back(error_message.get_name_leafdata()); if (lsp_mode.is_set || is_set(lsp_mode.yfilter)) leaf_name_data.push_back(lsp_mode.get_name_leafdata()); if (log_time.is_set || is_set(log_time.yfilter)) leaf_name_data.push_back(log_time.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::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 == "error-message") { error_message = value; error_message.value_namespace = name_space; error_message.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-mode") { lsp_mode = value; lsp_mode.value_namespace = name_space; lsp_mode.value_namespace_prefix = name_space_prefix; } if(value_path == "log-time") { log_time = value; log_time.value_namespace = name_space; log_time.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "error-message") { error_message.yfilter = yfilter; } if(value_path == "lsp-mode") { lsp_mode.yfilter = yfilter; } if(value_path == "log-time") { log_time.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::RemergeError::has_leaf_or_child_of_name(const std::string & name) const { if(name == "error-message" || name == "lsp-mode" || name == "log-time") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::SignallingError() : error_node{YType::uint32, "error-node"}, error{YType::uint8, "error"}, sub_code{YType::uint16, "sub-code"}, lsp_mode{YType::enumeration, "lsp-mode"}, log_time{YType::uint32, "log-time"}, signalling_lsp_id{YType::uint16, "signalling-lsp-id"}, error_message{YType::str, "error-message"}, reverse_lsp{YType::boolean, "reverse-lsp"} { yang_name = "signalling-error"; yang_parent_name = "active-path-option"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::~SignallingError() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::has_data() const { if (is_presence_container) return true; return error_node.is_set || error.is_set || sub_code.is_set || lsp_mode.is_set || log_time.is_set || signalling_lsp_id.is_set || error_message.is_set || reverse_lsp.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::has_operation() const { return is_set(yfilter) || ydk::is_set(error_node.yfilter) || ydk::is_set(error.yfilter) || ydk::is_set(sub_code.yfilter) || ydk::is_set(lsp_mode.yfilter) || ydk::is_set(log_time.yfilter) || ydk::is_set(signalling_lsp_id.yfilter) || ydk::is_set(error_message.yfilter) || ydk::is_set(reverse_lsp.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "signalling-error"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (error_node.is_set || is_set(error_node.yfilter)) leaf_name_data.push_back(error_node.get_name_leafdata()); if (error.is_set || is_set(error.yfilter)) leaf_name_data.push_back(error.get_name_leafdata()); if (sub_code.is_set || is_set(sub_code.yfilter)) leaf_name_data.push_back(sub_code.get_name_leafdata()); if (lsp_mode.is_set || is_set(lsp_mode.yfilter)) leaf_name_data.push_back(lsp_mode.get_name_leafdata()); if (log_time.is_set || is_set(log_time.yfilter)) leaf_name_data.push_back(log_time.get_name_leafdata()); if (signalling_lsp_id.is_set || is_set(signalling_lsp_id.yfilter)) leaf_name_data.push_back(signalling_lsp_id.get_name_leafdata()); if (error_message.is_set || is_set(error_message.yfilter)) leaf_name_data.push_back(error_message.get_name_leafdata()); if (reverse_lsp.is_set || is_set(reverse_lsp.yfilter)) leaf_name_data.push_back(reverse_lsp.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::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 == "error-node") { error_node = value; error_node.value_namespace = name_space; error_node.value_namespace_prefix = name_space_prefix; } if(value_path == "error") { error = value; error.value_namespace = name_space; error.value_namespace_prefix = name_space_prefix; } if(value_path == "sub-code") { sub_code = value; sub_code.value_namespace = name_space; sub_code.value_namespace_prefix = name_space_prefix; } if(value_path == "lsp-mode") { lsp_mode = value; lsp_mode.value_namespace = name_space; lsp_mode.value_namespace_prefix = name_space_prefix; } if(value_path == "log-time") { log_time = value; log_time.value_namespace = name_space; log_time.value_namespace_prefix = name_space_prefix; } if(value_path == "signalling-lsp-id") { signalling_lsp_id = value; signalling_lsp_id.value_namespace = name_space; signalling_lsp_id.value_namespace_prefix = name_space_prefix; } if(value_path == "error-message") { error_message = value; error_message.value_namespace = name_space; error_message.value_namespace_prefix = name_space_prefix; } if(value_path == "reverse-lsp") { reverse_lsp = value; reverse_lsp.value_namespace = name_space; reverse_lsp.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "error-node") { error_node.yfilter = yfilter; } if(value_path == "error") { error.yfilter = yfilter; } if(value_path == "sub-code") { sub_code.yfilter = yfilter; } if(value_path == "lsp-mode") { lsp_mode.yfilter = yfilter; } if(value_path == "log-time") { log_time.yfilter = yfilter; } if(value_path == "signalling-lsp-id") { signalling_lsp_id.yfilter = yfilter; } if(value_path == "error-message") { error_message.yfilter = yfilter; } if(value_path == "reverse-lsp") { reverse_lsp.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::ActivePathOption::SignallingError::has_leaf_or_child_of_name(const std::string & name) const { if(name == "error-node" || name == "error" || name == "sub-code" || name == "lsp-mode" || name == "log-time" || name == "signalling-lsp-id" || name == "error-message" || name == "reverse-lsp") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::OutXro() : mutual_diversity_flag{YType::boolean, "mutual-diversity-flag"} , xro_subobject(this, {}) { yang_name = "out-xro"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::~OutXro() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<xro_subobject.len(); index++) { if(xro_subobject[index]->has_data()) return true; } return mutual_diversity_flag.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::has_operation() const { for (std::size_t index=0; index<xro_subobject.len(); index++) { if(xro_subobject[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(mutual_diversity_flag.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "out-xro"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (mutual_diversity_flag.is_set || is_set(mutual_diversity_flag.yfilter)) leaf_name_data.push_back(mutual_diversity_flag.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "xro-subobject") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject>(); ent_->parent = this; xro_subobject.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : xro_subobject.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::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 == "mutual-diversity-flag") { mutual_diversity_flag = value; mutual_diversity_flag.value_namespace = name_space; mutual_diversity_flag.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "mutual-diversity-flag") { mutual_diversity_flag.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::has_leaf_or_child_of_name(const std::string & name) const { if(name == "xro-subobject" || name == "mutual-diversity-flag") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::XroSubobject() : type{YType::enumeration, "type"} , ipv4_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject>()) , ipv6_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject>()) , unnumbered_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject>()) , as_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject>()) , srlg_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject>()) , lsp_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject>()) { ipv4_subobject->parent = this; ipv6_subobject->parent = this; unnumbered_subobject->parent = this; as_subobject->parent = this; srlg_subobject->parent = this; lsp_subobject->parent = this; yang_name = "xro-subobject"; yang_parent_name = "out-xro"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::~XroSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::has_data() const { if (is_presence_container) return true; return type.is_set || (ipv4_subobject != nullptr && ipv4_subobject->has_data()) || (ipv6_subobject != nullptr && ipv6_subobject->has_data()) || (unnumbered_subobject != nullptr && unnumbered_subobject->has_data()) || (as_subobject != nullptr && as_subobject->has_data()) || (srlg_subobject != nullptr && srlg_subobject->has_data()) || (lsp_subobject != nullptr && lsp_subobject->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(type.yfilter) || (ipv4_subobject != nullptr && ipv4_subobject->has_operation()) || (ipv6_subobject != nullptr && ipv6_subobject->has_operation()) || (unnumbered_subobject != nullptr && unnumbered_subobject->has_operation()) || (as_subobject != nullptr && as_subobject->has_operation()) || (srlg_subobject != nullptr && srlg_subobject->has_operation()) || (lsp_subobject != nullptr && lsp_subobject->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "xro-subobject"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "ipv4-subobject") { if(ipv4_subobject == nullptr) { ipv4_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject>(); } return ipv4_subobject; } if(child_yang_name == "ipv6-subobject") { if(ipv6_subobject == nullptr) { ipv6_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject>(); } return ipv6_subobject; } if(child_yang_name == "unnumbered-subobject") { if(unnumbered_subobject == nullptr) { unnumbered_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject>(); } return unnumbered_subobject; } if(child_yang_name == "as-subobject") { if(as_subobject == nullptr) { as_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject>(); } return as_subobject; } if(child_yang_name == "srlg-subobject") { if(srlg_subobject == nullptr) { srlg_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject>(); } return srlg_subobject; } if(child_yang_name == "lsp-subobject") { if(lsp_subobject == nullptr) { lsp_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject>(); } return lsp_subobject; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(ipv4_subobject != nullptr) { _children["ipv4-subobject"] = ipv4_subobject; } if(ipv6_subobject != nullptr) { _children["ipv6-subobject"] = ipv6_subobject; } if(unnumbered_subobject != nullptr) { _children["unnumbered-subobject"] = unnumbered_subobject; } if(as_subobject != nullptr) { _children["as-subobject"] = as_subobject; } if(srlg_subobject != nullptr) { _children["srlg-subobject"] = srlg_subobject; } if(lsp_subobject != nullptr) { _children["lsp-subobject"] = lsp_subobject; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::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 == "type") { type = value; type.value_namespace = name_space; type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "type") { type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "ipv4-subobject" || name == "ipv6-subobject" || name == "unnumbered-subobject" || name == "as-subobject" || name == "srlg-subobject" || name == "lsp-subobject" || name == "type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::Ipv4Subobject() : address{YType::str, "address"}, prefix_len{YType::uint8, "prefix-len"}, attribute{YType::enumeration, "attribute"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "ipv4-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::~Ipv4Subobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::has_data() const { if (is_presence_container) return true; return address.is_set || prefix_len.is_set || attribute.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::has_operation() const { return is_set(yfilter) || ydk::is_set(address.yfilter) || ydk::is_set(prefix_len.yfilter) || ydk::is_set(attribute.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv4-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata()); if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata()); if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::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 == "address") { address = value; address.value_namespace = name_space; address.value_namespace_prefix = name_space_prefix; } if(value_path == "prefix-len") { prefix_len = value; prefix_len.value_namespace = name_space; prefix_len.value_namespace_prefix = name_space_prefix; } if(value_path == "attribute") { attribute = value; attribute.value_namespace = name_space; attribute.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "address") { address.yfilter = yfilter; } if(value_path == "prefix-len") { prefix_len.yfilter = yfilter; } if(value_path == "attribute") { attribute.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv4Subobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::Ipv6Subobject() : address{YType::str, "address"}, prefix_len{YType::uint8, "prefix-len"}, attribute{YType::enumeration, "attribute"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "ipv6-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::~Ipv6Subobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::has_data() const { if (is_presence_container) return true; return address.is_set || prefix_len.is_set || attribute.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::has_operation() const { return is_set(yfilter) || ydk::is_set(address.yfilter) || ydk::is_set(prefix_len.yfilter) || ydk::is_set(attribute.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv6-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata()); if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata()); if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::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 == "address") { address = value; address.value_namespace = name_space; address.value_namespace_prefix = name_space_prefix; } if(value_path == "prefix-len") { prefix_len = value; prefix_len.value_namespace = name_space; prefix_len.value_namespace_prefix = name_space_prefix; } if(value_path == "attribute") { attribute = value; attribute.value_namespace = name_space; attribute.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "address") { address.yfilter = yfilter; } if(value_path == "prefix-len") { prefix_len.yfilter = yfilter; } if(value_path == "attribute") { attribute.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::Ipv6Subobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::UnnumberedSubobject() : te_router_id{YType::str, "te-router-id"}, interface_id{YType::uint32, "interface-id"}, attribute{YType::enumeration, "attribute"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "unnumbered-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::~UnnumberedSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::has_data() const { if (is_presence_container) return true; return te_router_id.is_set || interface_id.is_set || attribute.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(te_router_id.yfilter) || ydk::is_set(interface_id.yfilter) || ydk::is_set(attribute.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "unnumbered-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (te_router_id.is_set || is_set(te_router_id.yfilter)) leaf_name_data.push_back(te_router_id.get_name_leafdata()); if (interface_id.is_set || is_set(interface_id.yfilter)) leaf_name_data.push_back(interface_id.get_name_leafdata()); if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::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 == "te-router-id") { te_router_id = value; te_router_id.value_namespace = name_space; te_router_id.value_namespace_prefix = name_space_prefix; } if(value_path == "interface-id") { interface_id = value; interface_id.value_namespace = name_space; interface_id.value_namespace_prefix = name_space_prefix; } if(value_path == "attribute") { attribute = value; attribute.value_namespace = name_space; attribute.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "te-router-id") { te_router_id.yfilter = yfilter; } if(value_path == "interface-id") { interface_id.yfilter = yfilter; } if(value_path == "attribute") { attribute.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::UnnumberedSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "te-router-id" || name == "interface-id" || name == "attribute" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::AsSubobject() : as_number{YType::uint16, "as-number"} { yang_name = "as-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::~AsSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::has_data() const { if (is_presence_container) return true; return as_number.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(as_number.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "as-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::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> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "as-number") { as_number.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::AsSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "as-number") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::SrlgSubobject() : srlg_id{YType::uint32, "srlg-id"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "srlg-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::~SrlgSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::has_data() const { if (is_presence_container) return true; return srlg_id.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(srlg_id.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "srlg-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (srlg_id.is_set || is_set(srlg_id.yfilter)) leaf_name_data.push_back(srlg_id.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::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 == "srlg-id") { srlg_id = value; srlg_id.value_namespace = name_space; srlg_id.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "srlg-id") { srlg_id.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::SrlgSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "srlg-id" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::LspSubobject() : ignore_lsp_id{YType::boolean, "ignore-lsp-id"}, processing_node_exception{YType::boolean, "processing-node-exception"}, penultimate_node_exception{YType::boolean, "penultimate-node-exception"}, destination_node_exception{YType::boolean, "destination-node-exception"}, exclusion_type{YType::enumeration, "exclusion-type"} , fec(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec>()) { fec->parent = this; yang_name = "lsp-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::~LspSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::has_data() const { if (is_presence_container) return true; return ignore_lsp_id.is_set || processing_node_exception.is_set || penultimate_node_exception.is_set || destination_node_exception.is_set || exclusion_type.is_set || (fec != nullptr && fec->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(ignore_lsp_id.yfilter) || ydk::is_set(processing_node_exception.yfilter) || ydk::is_set(penultimate_node_exception.yfilter) || ydk::is_set(destination_node_exception.yfilter) || ydk::is_set(exclusion_type.yfilter) || (fec != nullptr && fec->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "lsp-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (ignore_lsp_id.is_set || is_set(ignore_lsp_id.yfilter)) leaf_name_data.push_back(ignore_lsp_id.get_name_leafdata()); if (processing_node_exception.is_set || is_set(processing_node_exception.yfilter)) leaf_name_data.push_back(processing_node_exception.get_name_leafdata()); if (penultimate_node_exception.is_set || is_set(penultimate_node_exception.yfilter)) leaf_name_data.push_back(penultimate_node_exception.get_name_leafdata()); if (destination_node_exception.is_set || is_set(destination_node_exception.yfilter)) leaf_name_data.push_back(destination_node_exception.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "fec") { if(fec == nullptr) { fec = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec>(); } return fec; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(fec != nullptr) { _children["fec"] = fec; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::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 == "ignore-lsp-id") { ignore_lsp_id = value; ignore_lsp_id.value_namespace = name_space; ignore_lsp_id.value_namespace_prefix = name_space_prefix; } if(value_path == "processing-node-exception") { processing_node_exception = value; processing_node_exception.value_namespace = name_space; processing_node_exception.value_namespace_prefix = name_space_prefix; } if(value_path == "penultimate-node-exception") { penultimate_node_exception = value; penultimate_node_exception.value_namespace = name_space; penultimate_node_exception.value_namespace_prefix = name_space_prefix; } if(value_path == "destination-node-exception") { destination_node_exception = value; destination_node_exception.value_namespace = name_space; destination_node_exception.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "ignore-lsp-id") { ignore_lsp_id.yfilter = yfilter; } if(value_path == "processing-node-exception") { processing_node_exception.yfilter = yfilter; } if(value_path == "penultimate-node-exception") { penultimate_node_exception.yfilter = yfilter; } if(value_path == "destination-node-exception") { destination_node_exception.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "fec" || name == "ignore-lsp-id" || name == "processing-node-exception" || name == "penultimate-node-exception" || name == "destination-node-exception" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::Fec() : fec_lsp_id{YType::uint16, "fec-lsp-id"}, fec_tunnel_id{YType::uint16, "fec-tunnel-id"}, fec_extended_tunnel_id{YType::str, "fec-extended-tunnel-id"}, fec_source{YType::str, "fec-source"}, fec_vrf{YType::str, "fec-vrf"} , fec_destination_info(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo>()) { fec_destination_info->parent = this; yang_name = "fec"; yang_parent_name = "lsp-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::~Fec() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::has_data() const { if (is_presence_container) return true; return fec_lsp_id.is_set || fec_tunnel_id.is_set || fec_extended_tunnel_id.is_set || fec_source.is_set || fec_vrf.is_set || (fec_destination_info != nullptr && fec_destination_info->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::has_operation() const { return is_set(yfilter) || ydk::is_set(fec_lsp_id.yfilter) || ydk::is_set(fec_tunnel_id.yfilter) || ydk::is_set(fec_extended_tunnel_id.yfilter) || ydk::is_set(fec_source.yfilter) || ydk::is_set(fec_vrf.yfilter) || (fec_destination_info != nullptr && fec_destination_info->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "fec"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (fec_lsp_id.is_set || is_set(fec_lsp_id.yfilter)) leaf_name_data.push_back(fec_lsp_id.get_name_leafdata()); if (fec_tunnel_id.is_set || is_set(fec_tunnel_id.yfilter)) leaf_name_data.push_back(fec_tunnel_id.get_name_leafdata()); if (fec_extended_tunnel_id.is_set || is_set(fec_extended_tunnel_id.yfilter)) leaf_name_data.push_back(fec_extended_tunnel_id.get_name_leafdata()); if (fec_source.is_set || is_set(fec_source.yfilter)) leaf_name_data.push_back(fec_source.get_name_leafdata()); if (fec_vrf.is_set || is_set(fec_vrf.yfilter)) leaf_name_data.push_back(fec_vrf.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "fec-destination-info") { if(fec_destination_info == nullptr) { fec_destination_info = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo>(); } return fec_destination_info; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(fec_destination_info != nullptr) { _children["fec-destination-info"] = fec_destination_info; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::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 == "fec-lsp-id") { fec_lsp_id = value; fec_lsp_id.value_namespace = name_space; fec_lsp_id.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-tunnel-id") { fec_tunnel_id = value; fec_tunnel_id.value_namespace = name_space; fec_tunnel_id.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-extended-tunnel-id") { fec_extended_tunnel_id = value; fec_extended_tunnel_id.value_namespace = name_space; fec_extended_tunnel_id.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-source") { fec_source = value; fec_source.value_namespace = name_space; fec_source.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-vrf") { fec_vrf = value; fec_vrf.value_namespace = name_space; fec_vrf.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "fec-lsp-id") { fec_lsp_id.yfilter = yfilter; } if(value_path == "fec-tunnel-id") { fec_tunnel_id.yfilter = yfilter; } if(value_path == "fec-extended-tunnel-id") { fec_extended_tunnel_id.yfilter = yfilter; } if(value_path == "fec-source") { fec_source.yfilter = yfilter; } if(value_path == "fec-vrf") { fec_vrf.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::has_leaf_or_child_of_name(const std::string & name) const { if(name == "fec-destination-info" || name == "fec-lsp-id" || name == "fec-tunnel-id" || name == "fec-extended-tunnel-id" || name == "fec-source" || name == "fec-vrf") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::FecDestinationInfo() : fec_ctype{YType::enumeration, "fec-ctype"}, p2p_lsp_destination{YType::str, "p2p-lsp-destination"}, fec_destination_p2mp_id{YType::uint32, "fec-destination-p2mp-id"} { yang_name = "fec-destination-info"; yang_parent_name = "fec"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::~FecDestinationInfo() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_data() const { if (is_presence_container) return true; return fec_ctype.is_set || p2p_lsp_destination.is_set || fec_destination_p2mp_id.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_operation() const { return is_set(yfilter) || ydk::is_set(fec_ctype.yfilter) || ydk::is_set(p2p_lsp_destination.yfilter) || ydk::is_set(fec_destination_p2mp_id.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "fec-destination-info"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (fec_ctype.is_set || is_set(fec_ctype.yfilter)) leaf_name_data.push_back(fec_ctype.get_name_leafdata()); if (p2p_lsp_destination.is_set || is_set(p2p_lsp_destination.yfilter)) leaf_name_data.push_back(p2p_lsp_destination.get_name_leafdata()); if (fec_destination_p2mp_id.is_set || is_set(fec_destination_p2mp_id.yfilter)) leaf_name_data.push_back(fec_destination_p2mp_id.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::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 == "fec-ctype") { fec_ctype = value; fec_ctype.value_namespace = name_space; fec_ctype.value_namespace_prefix = name_space_prefix; } if(value_path == "p2p-lsp-destination") { p2p_lsp_destination = value; p2p_lsp_destination.value_namespace = name_space; p2p_lsp_destination.value_namespace_prefix = name_space_prefix; } if(value_path == "fec-destination-p2mp-id") { fec_destination_p2mp_id = value; fec_destination_p2mp_id.value_namespace = name_space; fec_destination_p2mp_id.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "fec-ctype") { fec_ctype.yfilter = yfilter; } if(value_path == "p2p-lsp-destination") { p2p_lsp_destination.yfilter = yfilter; } if(value_path == "fec-destination-p2mp-id") { fec_destination_p2mp_id.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::OutXro::XroSubobject::LspSubobject::Fec::FecDestinationInfo::has_leaf_or_child_of_name(const std::string & name) const { if(name == "fec-ctype" || name == "p2p-lsp-destination" || name == "fec-destination-p2mp-id") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::InXro() : mutual_diversity_flag{YType::boolean, "mutual-diversity-flag"} , xro_subobject(this, {}) { yang_name = "in-xro"; yang_parent_name = "s2l"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::~InXro() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::has_data() const { if (is_presence_container) return true; for (std::size_t index=0; index<xro_subobject.len(); index++) { if(xro_subobject[index]->has_data()) return true; } return mutual_diversity_flag.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::has_operation() const { for (std::size_t index=0; index<xro_subobject.len(); index++) { if(xro_subobject[index]->has_operation()) return true; } return is_set(yfilter) || ydk::is_set(mutual_diversity_flag.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "in-xro"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (mutual_diversity_flag.is_set || is_set(mutual_diversity_flag.yfilter)) leaf_name_data.push_back(mutual_diversity_flag.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "xro-subobject") { auto ent_ = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject>(); ent_->parent = this; xro_subobject.append(ent_); return ent_; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; count_ = 0; for (auto ent_ : xro_subobject.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 MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::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 == "mutual-diversity-flag") { mutual_diversity_flag = value; mutual_diversity_flag.value_namespace = name_space; mutual_diversity_flag.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "mutual-diversity-flag") { mutual_diversity_flag.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::has_leaf_or_child_of_name(const std::string & name) const { if(name == "xro-subobject" || name == "mutual-diversity-flag") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::XroSubobject() : type{YType::enumeration, "type"} , ipv4_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject>()) , ipv6_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject>()) , unnumbered_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::UnnumberedSubobject>()) , as_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::AsSubobject>()) , srlg_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::SrlgSubobject>()) , lsp_subobject(std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::LspSubobject>()) { ipv4_subobject->parent = this; ipv6_subobject->parent = this; unnumbered_subobject->parent = this; as_subobject->parent = this; srlg_subobject->parent = this; lsp_subobject->parent = this; yang_name = "xro-subobject"; yang_parent_name = "in-xro"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::~XroSubobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::has_data() const { if (is_presence_container) return true; return type.is_set || (ipv4_subobject != nullptr && ipv4_subobject->has_data()) || (ipv6_subobject != nullptr && ipv6_subobject->has_data()) || (unnumbered_subobject != nullptr && unnumbered_subobject->has_data()) || (as_subobject != nullptr && as_subobject->has_data()) || (srlg_subobject != nullptr && srlg_subobject->has_data()) || (lsp_subobject != nullptr && lsp_subobject->has_data()); } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::has_operation() const { return is_set(yfilter) || ydk::is_set(type.yfilter) || (ipv4_subobject != nullptr && ipv4_subobject->has_operation()) || (ipv6_subobject != nullptr && ipv6_subobject->has_operation()) || (unnumbered_subobject != nullptr && unnumbered_subobject->has_operation()) || (as_subobject != nullptr && as_subobject->has_operation()) || (srlg_subobject != nullptr && srlg_subobject->has_operation()) || (lsp_subobject != nullptr && lsp_subobject->has_operation()); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "xro-subobject"; path_buffer << "[" << get_ylist_key() << "]"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (type.is_set || is_set(type.yfilter)) leaf_name_data.push_back(type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::get_child_by_name(const std::string & child_yang_name, const std::string & segment_path) { if(child_yang_name == "ipv4-subobject") { if(ipv4_subobject == nullptr) { ipv4_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject>(); } return ipv4_subobject; } if(child_yang_name == "ipv6-subobject") { if(ipv6_subobject == nullptr) { ipv6_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject>(); } return ipv6_subobject; } if(child_yang_name == "unnumbered-subobject") { if(unnumbered_subobject == nullptr) { unnumbered_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::UnnumberedSubobject>(); } return unnumbered_subobject; } if(child_yang_name == "as-subobject") { if(as_subobject == nullptr) { as_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::AsSubobject>(); } return as_subobject; } if(child_yang_name == "srlg-subobject") { if(srlg_subobject == nullptr) { srlg_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::SrlgSubobject>(); } return srlg_subobject; } if(child_yang_name == "lsp-subobject") { if(lsp_subobject == nullptr) { lsp_subobject = std::make_shared<MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::LspSubobject>(); } return lsp_subobject; } return nullptr; } std::map<std::string, std::shared_ptr<ydk::Entity>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; if(ipv4_subobject != nullptr) { _children["ipv4-subobject"] = ipv4_subobject; } if(ipv6_subobject != nullptr) { _children["ipv6-subobject"] = ipv6_subobject; } if(unnumbered_subobject != nullptr) { _children["unnumbered-subobject"] = unnumbered_subobject; } if(as_subobject != nullptr) { _children["as-subobject"] = as_subobject; } if(srlg_subobject != nullptr) { _children["srlg-subobject"] = srlg_subobject; } if(lsp_subobject != nullptr) { _children["lsp-subobject"] = lsp_subobject; } return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::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 == "type") { type = value; type.value_namespace = name_space; type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "type") { type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "ipv4-subobject" || name == "ipv6-subobject" || name == "unnumbered-subobject" || name == "as-subobject" || name == "srlg-subobject" || name == "lsp-subobject" || name == "type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::Ipv4Subobject() : address{YType::str, "address"}, prefix_len{YType::uint8, "prefix-len"}, attribute{YType::enumeration, "attribute"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "ipv4-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::~Ipv4Subobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::has_data() const { if (is_presence_container) return true; return address.is_set || prefix_len.is_set || attribute.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::has_operation() const { return is_set(yfilter) || ydk::is_set(address.yfilter) || ydk::is_set(prefix_len.yfilter) || ydk::is_set(attribute.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv4-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata()); if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata()); if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::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 == "address") { address = value; address.value_namespace = name_space; address.value_namespace_prefix = name_space_prefix; } if(value_path == "prefix-len") { prefix_len = value; prefix_len.value_namespace = name_space; prefix_len.value_namespace_prefix = name_space_prefix; } if(value_path == "attribute") { attribute = value; attribute.value_namespace = name_space; attribute.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "address") { address.yfilter = yfilter; } if(value_path == "prefix-len") { prefix_len.yfilter = yfilter; } if(value_path == "attribute") { attribute.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv4Subobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type") return true; return false; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::Ipv6Subobject() : address{YType::str, "address"}, prefix_len{YType::uint8, "prefix-len"}, attribute{YType::enumeration, "attribute"}, exclusion_type{YType::enumeration, "exclusion-type"} { yang_name = "ipv6-subobject"; yang_parent_name = "xro-subobject"; is_top_level_class = false; has_list_ancestor = true; } MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::~Ipv6Subobject() { } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::has_data() const { if (is_presence_container) return true; return address.is_set || prefix_len.is_set || attribute.is_set || exclusion_type.is_set; } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::has_operation() const { return is_set(yfilter) || ydk::is_set(address.yfilter) || ydk::is_set(prefix_len.yfilter) || ydk::is_set(attribute.yfilter) || ydk::is_set(exclusion_type.yfilter); } std::string MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::get_segment_path() const { std::ostringstream path_buffer; path_buffer << "ipv6-subobject"; return path_buffer.str(); } std::vector<std::pair<std::string, LeafData> > MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::get_name_leaf_data() const { std::vector<std::pair<std::string, LeafData> > leaf_name_data {}; if (address.is_set || is_set(address.yfilter)) leaf_name_data.push_back(address.get_name_leafdata()); if (prefix_len.is_set || is_set(prefix_len.yfilter)) leaf_name_data.push_back(prefix_len.get_name_leafdata()); if (attribute.is_set || is_set(attribute.yfilter)) leaf_name_data.push_back(attribute.get_name_leafdata()); if (exclusion_type.is_set || is_set(exclusion_type.yfilter)) leaf_name_data.push_back(exclusion_type.get_name_leafdata()); return leaf_name_data; } std::shared_ptr<ydk::Entity> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::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>> MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::get_children() const { std::map<std::string, std::shared_ptr<ydk::Entity>> _children{}; char count_=0; return _children; } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::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 == "address") { address = value; address.value_namespace = name_space; address.value_namespace_prefix = name_space_prefix; } if(value_path == "prefix-len") { prefix_len = value; prefix_len.value_namespace = name_space; prefix_len.value_namespace_prefix = name_space_prefix; } if(value_path == "attribute") { attribute = value; attribute.value_namespace = name_space; attribute.value_namespace_prefix = name_space_prefix; } if(value_path == "exclusion-type") { exclusion_type = value; exclusion_type.value_namespace = name_space; exclusion_type.value_namespace_prefix = name_space_prefix; } } void MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::set_filter(const std::string & value_path, YFilter yfilter) { if(value_path == "address") { address.yfilter = yfilter; } if(value_path == "prefix-len") { prefix_len.yfilter = yfilter; } if(value_path == "attribute") { attribute.yfilter = yfilter; } if(value_path == "exclusion-type") { exclusion_type.yfilter = yfilter; } } bool MplsTeStandby::P2pP2mpTunnel::NniTunnels::NniTunnel::ReoptimizedP2mpLsp::S2l::InXro::XroSubobject::Ipv6Subobject::has_leaf_or_child_of_name(const std::string & name) const { if(name == "address" || name == "prefix-len" || name == "attribute" || name == "exclusion-type") return true; return false; } } }
44.482051
2,605
0.739013
CiscoDevNet
33d7db421d47e5b9a09cd1e3ee4fd25153ca24e5
2,092
cpp
C++
src/main.cpp
codingwithjulio/sdl2-create-window
418e3258eda05f63a07c5dc42732adddf6bb3793
[ "MIT" ]
null
null
null
src/main.cpp
codingwithjulio/sdl2-create-window
418e3258eda05f63a07c5dc42732adddf6bb3793
[ "MIT" ]
null
null
null
src/main.cpp
codingwithjulio/sdl2-create-window
418e3258eda05f63a07c5dc42732adddf6bb3793
[ "MIT" ]
null
null
null
#include <iostream> #include <SDL2/SDL.h> // Graphics const int WINDOW_WIDTH = 512; const int WINDOW_HEIGHT = 284; SDL_Window* g_main_window; SDL_Renderer* g_main_renderer; // Colors namespace Colors { const SDL_Color GREEN = { 0, 255, 0, SDL_ALPHA_OPAQUE }; const SDL_Color BLACK = { 0, 0, 0, SDL_ALPHA_OPAQUE }; } static void ClearScreen(SDL_Renderer* renderer) { SDL_SetRenderDrawColor(renderer, Colors::BLACK.r, Colors::BLACK.g, Colors::BLACK.b, Colors::BLACK.a); SDL_RenderClear(renderer); } static bool Init() { if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { std::cout << "SDL_Init failed with error: " << SDL_GetError() << std::endl; return EXIT_FAILURE; } g_main_window = SDL_CreateWindow( "Creating a Window (512x284)", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_OPENGL ); if (g_main_window == nullptr) { std::cout << "Unable to crete the main window. Erro: " << SDL_GetError() << std::endl; SDL_Quit(); return EXIT_FAILURE; } g_main_renderer = SDL_CreateRenderer(g_main_window, -1, SDL_RENDERER_PRESENTVSYNC); return true; } void Shutdown() { if (g_main_window != nullptr) { SDL_DestroyWindow(g_main_window); g_main_window = nullptr; } if (g_main_renderer != nullptr) { SDL_DestroyRenderer(g_main_renderer); g_main_renderer = nullptr; } SDL_Quit(); } int main() { if (Init() == false) { Shutdown(); } // Draw loop SDL_Event event; bool running = true; while(running) { ClearScreen(g_main_renderer); // Check and process I/O events if (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: { running = event.key.keysym.scancode != SDL_SCANCODE_ESCAPE; break; } case SDL_QUIT: { running = false; break; } default: break; } } // Update the screen with the content rendered in the background SDL_RenderPresent(g_main_renderer); } Shutdown(); return EXIT_SUCCESS; }
20.712871
103
0.650096
codingwithjulio
33d8dcd655bf8d4f972500b2a104006dcf45bea2
1,192
cpp
C++
code/src/problem4_type_conversion/main.cpp
dsba2020-z/workshops5-6
5466ef1241208ca93df18c81deb4fbc69957ee7f
[ "BSD-3-Clause" ]
null
null
null
code/src/problem4_type_conversion/main.cpp
dsba2020-z/workshops5-6
5466ef1241208ca93df18c81deb4fbc69957ee7f
[ "BSD-3-Clause" ]
null
null
null
code/src/problem4_type_conversion/main.cpp
dsba2020-z/workshops5-6
5466ef1241208ca93df18c81deb4fbc69957ee7f
[ "BSD-3-Clause" ]
null
null
null
//////////////////////////////////////////////////////////////////////////////// /// \file /// \brief Main module for Problem 4: Type conversion. /// \author Georgii Zhulikov /// \version 0.1.0 /// \date 25.01.2021 /// This code is for educational purposes of the course "Introduction /// to programming" provided by the Faculty of Computer Science /// at the Higher School of Economics. /// /// Create a program that performs the following steps: /// 1. Reads three integer numbers from input. /// 2. Multiplies each number by 2. /// 3. Concatenates the results into a single large number. /// 4. Multiplies the result by 2. /// 5. Outputs the resulting number. /// /// Use stringstream for type converstion between numbers and strings. /// (Additional) Use a debugger to check that at each step the strings and /// numbers hold the correct values. /// //////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <string> #include <sstream> int main() { using std::cout; using std::cin; // TODO: provide your implementation here cout << "\n\n"; return 0; }
30.564103
81
0.564597
dsba2020-z
33d94174eb4f9595b832cb6cce4d90d307c9a89b
17,148
cpp
C++
3rdParty/V8/v5.7.492.77/third_party/icu/source/common/normalizer2.cpp
sita1999/arangodb
6a4f462fa209010cd064f99e63d85ce1d432c500
[ "Apache-2.0" ]
2
2019-12-07T11:29:58.000Z
2021-06-26T12:48:10.000Z
3rdParty/V8/v5.7.492.77/third_party/icu/source/common/normalizer2.cpp
lipper/arangodb
66ea1fd4946668192e3f0d1060f0844f324ad7b8
[ "Apache-2.0" ]
null
null
null
3rdParty/V8/v5.7.492.77/third_party/icu/source/common/normalizer2.cpp
lipper/arangodb
66ea1fd4946668192e3f0d1060f0844f324ad7b8
[ "Apache-2.0" ]
1
2021-07-12T06:29:34.000Z
2021-07-12T06:29:34.000Z
// Copyright (C) 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* * * Copyright (C) 2009-2016, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: normalizer2.cpp * encoding: US-ASCII * tab size: 8 (not used) * indentation:4 * * created on: 2009nov22 * created by: Markus W. Scherer */ #include "unicode/utypes.h" #if !UCONFIG_NO_NORMALIZATION #include "unicode/normalizer2.h" #include "unicode/unistr.h" #include "unicode/unorm.h" #include "cstring.h" #include "mutex.h" #include "norm2allmodes.h" #include "normalizer2impl.h" #include "uassert.h" #include "ucln_cmn.h" using icu::Normalizer2Impl; // NFC/NFD data machine-generated by gennorm2 --csource #define INCLUDED_FROM_NORMALIZER2_CPP #include "norm2_nfc_data.h" U_NAMESPACE_BEGIN // Public API dispatch via Normalizer2 subclasses -------------------------- *** Normalizer2::~Normalizer2() {} UBool Normalizer2::getRawDecomposition(UChar32, UnicodeString &) const { return FALSE; } UChar32 Normalizer2::composePair(UChar32, UChar32) const { return U_SENTINEL; } uint8_t Normalizer2::getCombiningClass(UChar32 /*c*/) const { return 0; } // Normalizer2 implementation for the old UNORM_NONE. class NoopNormalizer2 : public Normalizer2 { virtual ~NoopNormalizer2(); virtual UnicodeString & normalize(const UnicodeString &src, UnicodeString &dest, UErrorCode &errorCode) const { if(U_SUCCESS(errorCode)) { if(&dest!=&src) { dest=src; } else { errorCode=U_ILLEGAL_ARGUMENT_ERROR; } } return dest; } virtual UnicodeString & normalizeSecondAndAppend(UnicodeString &first, const UnicodeString &second, UErrorCode &errorCode) const { if(U_SUCCESS(errorCode)) { if(&first!=&second) { first.append(second); } else { errorCode=U_ILLEGAL_ARGUMENT_ERROR; } } return first; } virtual UnicodeString & append(UnicodeString &first, const UnicodeString &second, UErrorCode &errorCode) const { if(U_SUCCESS(errorCode)) { if(&first!=&second) { first.append(second); } else { errorCode=U_ILLEGAL_ARGUMENT_ERROR; } } return first; } virtual UBool getDecomposition(UChar32, UnicodeString &) const { return FALSE; } // No need to override the default getRawDecomposition(). virtual UBool isNormalized(const UnicodeString &, UErrorCode &) const { return TRUE; } virtual UNormalizationCheckResult quickCheck(const UnicodeString &, UErrorCode &) const { return UNORM_YES; } virtual int32_t spanQuickCheckYes(const UnicodeString &s, UErrorCode &) const { return s.length(); } virtual UBool hasBoundaryBefore(UChar32) const { return TRUE; } virtual UBool hasBoundaryAfter(UChar32) const { return TRUE; } virtual UBool isInert(UChar32) const { return TRUE; } }; NoopNormalizer2::~NoopNormalizer2() {} Normalizer2WithImpl::~Normalizer2WithImpl() {} DecomposeNormalizer2::~DecomposeNormalizer2() {} ComposeNormalizer2::~ComposeNormalizer2() {} FCDNormalizer2::~FCDNormalizer2() {} // instance cache ---------------------------------------------------------- *** Norm2AllModes::~Norm2AllModes() { delete impl; } Norm2AllModes * Norm2AllModes::createInstance(Normalizer2Impl *impl, UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { delete impl; return NULL; } Norm2AllModes *allModes=new Norm2AllModes(impl); if(allModes==NULL) { errorCode=U_MEMORY_ALLOCATION_ERROR; delete impl; return NULL; } return allModes; } Norm2AllModes * Norm2AllModes::createNFCInstance(UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return NULL; } Normalizer2Impl *impl=new Normalizer2Impl; if(impl==NULL) { errorCode=U_MEMORY_ALLOCATION_ERROR; return NULL; } impl->init(norm2_nfc_data_indexes, &norm2_nfc_data_trie, norm2_nfc_data_extraData, norm2_nfc_data_smallFCD); return createInstance(impl, errorCode); } U_CDECL_BEGIN static UBool U_CALLCONV uprv_normalizer2_cleanup(); U_CDECL_END static Norm2AllModes *nfcSingleton; static Normalizer2 *noopSingleton; static icu::UInitOnce nfcInitOnce = U_INITONCE_INITIALIZER; static icu::UInitOnce noopInitOnce = U_INITONCE_INITIALIZER; // UInitOnce singleton initialization functions static void U_CALLCONV initNFCSingleton(UErrorCode &errorCode) { nfcSingleton=Norm2AllModes::createNFCInstance(errorCode); ucln_common_registerCleanup(UCLN_COMMON_NORMALIZER2, uprv_normalizer2_cleanup); } static void U_CALLCONV initNoopSingleton(UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return; } noopSingleton=new NoopNormalizer2; if(noopSingleton==NULL) { errorCode=U_MEMORY_ALLOCATION_ERROR; return; } ucln_common_registerCleanup(UCLN_COMMON_NORMALIZER2, uprv_normalizer2_cleanup); } U_CDECL_BEGIN static UBool U_CALLCONV uprv_normalizer2_cleanup() { delete nfcSingleton; nfcSingleton = NULL; delete noopSingleton; noopSingleton = NULL; nfcInitOnce.reset(); noopInitOnce.reset(); return TRUE; } U_CDECL_END const Norm2AllModes * Norm2AllModes::getNFCInstance(UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return NULL; } umtx_initOnce(nfcInitOnce, &initNFCSingleton, errorCode); return nfcSingleton; } const Normalizer2 * Normalizer2::getNFCInstance(UErrorCode &errorCode) { const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode); return allModes!=NULL ? &allModes->comp : NULL; } const Normalizer2 * Normalizer2::getNFDInstance(UErrorCode &errorCode) { const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode); return allModes!=NULL ? &allModes->decomp : NULL; } const Normalizer2 *Normalizer2Factory::getFCDInstance(UErrorCode &errorCode) { const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode); return allModes!=NULL ? &allModes->fcd : NULL; } const Normalizer2 *Normalizer2Factory::getFCCInstance(UErrorCode &errorCode) { const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode); return allModes!=NULL ? &allModes->fcc : NULL; } const Normalizer2 *Normalizer2Factory::getNoopInstance(UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return NULL; } umtx_initOnce(noopInitOnce, &initNoopSingleton, errorCode); return noopSingleton; } const Normalizer2Impl * Normalizer2Factory::getNFCImpl(UErrorCode &errorCode) { const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode); return allModes!=NULL ? allModes->impl : NULL; } const Normalizer2Impl * Normalizer2Factory::getImpl(const Normalizer2 *norm2) { return &((Normalizer2WithImpl *)norm2)->impl; } U_NAMESPACE_END // C API ------------------------------------------------------------------- *** U_NAMESPACE_USE U_CAPI const UNormalizer2 * U_EXPORT2 unorm2_getNFCInstance(UErrorCode *pErrorCode) { return (const UNormalizer2 *)Normalizer2::getNFCInstance(*pErrorCode); } U_CAPI const UNormalizer2 * U_EXPORT2 unorm2_getNFDInstance(UErrorCode *pErrorCode) { return (const UNormalizer2 *)Normalizer2::getNFDInstance(*pErrorCode); } U_CAPI void U_EXPORT2 unorm2_close(UNormalizer2 *norm2) { delete (Normalizer2 *)norm2; } U_CAPI int32_t U_EXPORT2 unorm2_normalize(const UNormalizer2 *norm2, const UChar *src, int32_t length, UChar *dest, int32_t capacity, UErrorCode *pErrorCode) { if(U_FAILURE(*pErrorCode)) { return 0; } if( (src==NULL ? length!=0 : length<-1) || (dest==NULL ? capacity!=0 : capacity<0) || (src==dest && src!=NULL) ) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } UnicodeString destString(dest, 0, capacity); // length==0: Nothing to do, and n2wi->normalize(NULL, NULL, buffer, ...) would crash. if(length!=0) { const Normalizer2 *n2=(const Normalizer2 *)norm2; const Normalizer2WithImpl *n2wi=dynamic_cast<const Normalizer2WithImpl *>(n2); if(n2wi!=NULL) { // Avoid duplicate argument checking and support NUL-terminated src. ReorderingBuffer buffer(n2wi->impl, destString); if(buffer.init(length, *pErrorCode)) { n2wi->normalize(src, length>=0 ? src+length : NULL, buffer, *pErrorCode); } } else { UnicodeString srcString(length<0, src, length); n2->normalize(srcString, destString, *pErrorCode); } } return destString.extract(dest, capacity, *pErrorCode); } static int32_t normalizeSecondAndAppend(const UNormalizer2 *norm2, UChar *first, int32_t firstLength, int32_t firstCapacity, const UChar *second, int32_t secondLength, UBool doNormalize, UErrorCode *pErrorCode) { if(U_FAILURE(*pErrorCode)) { return 0; } if( (second==NULL ? secondLength!=0 : secondLength<-1) || (first==NULL ? (firstCapacity!=0 || firstLength!=0) : (firstCapacity<0 || firstLength<-1)) || (first==second && first!=NULL) ) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } UnicodeString firstString(first, firstLength, firstCapacity); firstLength=firstString.length(); // In case it was -1. // secondLength==0: Nothing to do, and n2wi->normalizeAndAppend(NULL, NULL, buffer, ...) would crash. if(secondLength!=0) { const Normalizer2 *n2=(const Normalizer2 *)norm2; const Normalizer2WithImpl *n2wi=dynamic_cast<const Normalizer2WithImpl *>(n2); if(n2wi!=NULL) { // Avoid duplicate argument checking and support NUL-terminated src. UnicodeString safeMiddle; { ReorderingBuffer buffer(n2wi->impl, firstString); if(buffer.init(firstLength+secondLength+1, *pErrorCode)) { // destCapacity>=-1 n2wi->normalizeAndAppend(second, secondLength>=0 ? second+secondLength : NULL, doNormalize, safeMiddle, buffer, *pErrorCode); } } // The ReorderingBuffer destructor finalizes firstString. if(U_FAILURE(*pErrorCode) || firstString.length()>firstCapacity) { // Restore the modified suffix of the first string. // This does not restore first[] array contents between firstLength and firstCapacity. // (That might be uninitialized memory, as far as we know.) if(first!=NULL) { /* don't dereference NULL */ safeMiddle.extract(0, 0x7fffffff, first+firstLength-safeMiddle.length()); if(firstLength<firstCapacity) { first[firstLength]=0; // NUL-terminate in case it was originally. } } } } else { UnicodeString secondString(secondLength<0, second, secondLength); if(doNormalize) { n2->normalizeSecondAndAppend(firstString, secondString, *pErrorCode); } else { n2->append(firstString, secondString, *pErrorCode); } } } return firstString.extract(first, firstCapacity, *pErrorCode); } U_CAPI int32_t U_EXPORT2 unorm2_normalizeSecondAndAppend(const UNormalizer2 *norm2, UChar *first, int32_t firstLength, int32_t firstCapacity, const UChar *second, int32_t secondLength, UErrorCode *pErrorCode) { return normalizeSecondAndAppend(norm2, first, firstLength, firstCapacity, second, secondLength, TRUE, pErrorCode); } U_CAPI int32_t U_EXPORT2 unorm2_append(const UNormalizer2 *norm2, UChar *first, int32_t firstLength, int32_t firstCapacity, const UChar *second, int32_t secondLength, UErrorCode *pErrorCode) { return normalizeSecondAndAppend(norm2, first, firstLength, firstCapacity, second, secondLength, FALSE, pErrorCode); } U_CAPI int32_t U_EXPORT2 unorm2_getDecomposition(const UNormalizer2 *norm2, UChar32 c, UChar *decomposition, int32_t capacity, UErrorCode *pErrorCode) { if(U_FAILURE(*pErrorCode)) { return 0; } if(decomposition==NULL ? capacity!=0 : capacity<0) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } UnicodeString destString(decomposition, 0, capacity); if(reinterpret_cast<const Normalizer2 *>(norm2)->getDecomposition(c, destString)) { return destString.extract(decomposition, capacity, *pErrorCode); } else { return -1; } } U_CAPI int32_t U_EXPORT2 unorm2_getRawDecomposition(const UNormalizer2 *norm2, UChar32 c, UChar *decomposition, int32_t capacity, UErrorCode *pErrorCode) { if(U_FAILURE(*pErrorCode)) { return 0; } if(decomposition==NULL ? capacity!=0 : capacity<0) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } UnicodeString destString(decomposition, 0, capacity); if(reinterpret_cast<const Normalizer2 *>(norm2)->getRawDecomposition(c, destString)) { return destString.extract(decomposition, capacity, *pErrorCode); } else { return -1; } } U_CAPI UChar32 U_EXPORT2 unorm2_composePair(const UNormalizer2 *norm2, UChar32 a, UChar32 b) { return reinterpret_cast<const Normalizer2 *>(norm2)->composePair(a, b); } U_CAPI uint8_t U_EXPORT2 unorm2_getCombiningClass(const UNormalizer2 *norm2, UChar32 c) { return reinterpret_cast<const Normalizer2 *>(norm2)->getCombiningClass(c); } U_CAPI UBool U_EXPORT2 unorm2_isNormalized(const UNormalizer2 *norm2, const UChar *s, int32_t length, UErrorCode *pErrorCode) { if(U_FAILURE(*pErrorCode)) { return 0; } if((s==NULL && length!=0) || length<-1) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } UnicodeString sString(length<0, s, length); return ((const Normalizer2 *)norm2)->isNormalized(sString, *pErrorCode); } U_CAPI UNormalizationCheckResult U_EXPORT2 unorm2_quickCheck(const UNormalizer2 *norm2, const UChar *s, int32_t length, UErrorCode *pErrorCode) { if(U_FAILURE(*pErrorCode)) { return UNORM_NO; } if((s==NULL && length!=0) || length<-1) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return UNORM_NO; } UnicodeString sString(length<0, s, length); return ((const Normalizer2 *)norm2)->quickCheck(sString, *pErrorCode); } U_CAPI int32_t U_EXPORT2 unorm2_spanQuickCheckYes(const UNormalizer2 *norm2, const UChar *s, int32_t length, UErrorCode *pErrorCode) { if(U_FAILURE(*pErrorCode)) { return 0; } if((s==NULL && length!=0) || length<-1) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } UnicodeString sString(length<0, s, length); return ((const Normalizer2 *)norm2)->spanQuickCheckYes(sString, *pErrorCode); } U_CAPI UBool U_EXPORT2 unorm2_hasBoundaryBefore(const UNormalizer2 *norm2, UChar32 c) { return ((const Normalizer2 *)norm2)->hasBoundaryBefore(c); } U_CAPI UBool U_EXPORT2 unorm2_hasBoundaryAfter(const UNormalizer2 *norm2, UChar32 c) { return ((const Normalizer2 *)norm2)->hasBoundaryAfter(c); } U_CAPI UBool U_EXPORT2 unorm2_isInert(const UNormalizer2 *norm2, UChar32 c) { return ((const Normalizer2 *)norm2)->isInert(c); } // Some properties APIs ---------------------------------------------------- *** U_CAPI uint8_t U_EXPORT2 u_getCombiningClass(UChar32 c) { UErrorCode errorCode=U_ZERO_ERROR; const Normalizer2 *nfd=Normalizer2::getNFDInstance(errorCode); if(U_SUCCESS(errorCode)) { return nfd->getCombiningClass(c); } else { return 0; } } U_CFUNC uint16_t unorm_getFCD16(UChar32 c) { UErrorCode errorCode=U_ZERO_ERROR; const Normalizer2Impl *impl=Normalizer2Factory::getNFCImpl(errorCode); if(U_SUCCESS(errorCode)) { return impl->getFCD16(c); } else { return 0; } } #endif // !UCONFIG_NO_NORMALIZATION
32.662857
105
0.6385
sita1999
33d9548a71208d39a75f79b2e025e17810e33255
932
cpp
C++
src/ArduinoComponents/Components/TactileButton.cpp
gilmaimon/ArduinoComponents
f676639e1f6eb56ba3752f9ed6749b37eba4b5d6
[ "MIT" ]
17
2018-10-06T16:10:21.000Z
2021-07-08T16:16:21.000Z
src/ArduinoComponents/Components/TactileButton.cpp
aelmendorf/ArduinoComponents
f676639e1f6eb56ba3752f9ed6749b37eba4b5d6
[ "MIT" ]
10
2018-10-06T18:58:50.000Z
2020-08-30T19:57:53.000Z
src/ArduinoComponents/Components/TactileButton.cpp
aelmendorf/ArduinoComponents
f676639e1f6eb56ba3752f9ed6749b37eba4b5d6
[ "MIT" ]
1
2021-04-07T04:39:40.000Z
2021-04-07T04:39:40.000Z
#include "TactileButton.h" namespace components { TactileButton::TactileButton(Ref<Component> parent, DigitalInput input, TriggerOn trigger) : Component(parent), _input(input), _pressed(false), _on_press([](){}), _on_release([](){}), _trigger(trigger) {} TactileButton::TactileButton(Ref<Component> parent, PinNumber pin, TriggerOn trigger, InputPull pull) : TactileButton(parent, DigitalInput(pin, pull), trigger) {} void TactileButton::onPress(VoidCallback cbk) { this->_on_press = cbk; } void TactileButton::onRelease(VoidCallback cbk) { this->_on_release = cbk; } bool TactileButton::isPressed() { return (_trigger == TriggerOn::Low)? _input.isLow(): _input.isHigh(); } void TactileButton::privateLoop() { bool pressedState = this->isPressed(); if(pressedState != _pressed) { if(pressedState == true) _on_press(); else if(pressedState == false) _on_release(); _pressed = pressedState; } } };
34.518519
205
0.718884
gilmaimon
33d9eb33c495b6161cf5069c41f26c0530fec958
6,248
cc
C++
ui/views/layout/flex_layout_view.cc
Ron423c/chromium
2edf7b980065b648f8b2a6e52193d83832fe36b7
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
575
2015-06-18T23:58:20.000Z
2022-03-23T09:32:39.000Z
ui/views/layout/flex_layout_view.cc
Ron423c/chromium
2edf7b980065b648f8b2a6e52193d83832fe36b7
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
113
2015-05-04T09:58:14.000Z
2022-01-31T19:35:03.000Z
ui/views/layout/flex_layout_view.cc
iridium-browser/iridium-browser
907e31cf5ce5ad14d832796e3a7c11e496828959
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
52
2015-07-14T10:40:50.000Z
2022-03-15T01:11:49.000Z
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/views/layout/flex_layout_view.h" #include <memory> #include "ui/views/layout/flex_layout_types.h" #include "ui/views/layout/layout_types.h" #include "ui/views/metadata/metadata_impl_macros.h" #include "ui/views/metadata/type_conversion.h" namespace views { FlexLayoutView::FlexLayoutView() : layout_(SetLayoutManager(std::make_unique<FlexLayout>())), orientation_(layout_->orientation()), main_axis_alignment_(layout_->main_axis_alignment()), cross_axis_alignment_(layout_->cross_axis_alignment()), interior_margin_(layout_->interior_margin()), minimum_cross_axis_size_(layout_->minimum_cross_axis_size()), collapse_margins_(layout_->collapse_margins()), include_host_insets_in_layout_(layout_->include_host_insets_in_layout()), ignore_default_main_axis_margins_( layout_->ignore_default_main_axis_margins()), flex_allocation_order_(layout_->flex_allocation_order()) {} FlexLayoutView::~FlexLayoutView() = default; void FlexLayoutView::SetOrientation(LayoutOrientation orientation) { if (orientation_ == orientation) return; layout_->SetOrientation(orientation); orientation_ = orientation; OnPropertyChanged(&orientation_, kPropertyEffectsLayout); } LayoutOrientation FlexLayoutView::GetOrientation() const { return orientation_; } void FlexLayoutView::SetMainAxisAlignment(LayoutAlignment main_axis_alignment) { if (main_axis_alignment_ == main_axis_alignment) return; layout_->SetMainAxisAlignment(main_axis_alignment); main_axis_alignment_ = main_axis_alignment; OnPropertyChanged(&main_axis_alignment_, kPropertyEffectsLayout); } LayoutAlignment FlexLayoutView::GetMainAxisAlignment() const { return layout_->main_axis_alignment(); } void FlexLayoutView::SetCrossAxisAlignment( LayoutAlignment cross_axis_alignment) { if (cross_axis_alignment_ == cross_axis_alignment) return; layout_->SetCrossAxisAlignment(cross_axis_alignment); cross_axis_alignment_ = cross_axis_alignment; OnPropertyChanged(&cross_axis_alignment_, kPropertyEffectsLayout); } LayoutAlignment FlexLayoutView::GetCrossAxisAlignment() const { return cross_axis_alignment_; } void FlexLayoutView::SetInteriorMargin(const gfx::Insets& interior_margin) { if (interior_margin_ == interior_margin) return; layout_->SetInteriorMargin(interior_margin); interior_margin_ = interior_margin; OnPropertyChanged(&interior_margin_, kPropertyEffectsLayout); } const gfx::Insets& FlexLayoutView::GetInteriorMargin() const { return interior_margin_; } void FlexLayoutView::SetMinimumCrossAxisSize(int size) { if (minimum_cross_axis_size_ == size) return; layout_->SetMinimumCrossAxisSize(size); minimum_cross_axis_size_ = size; OnPropertyChanged(&minimum_cross_axis_size_, kPropertyEffectsLayout); } int FlexLayoutView::GetMinimumCrossAxisSize() const { return minimum_cross_axis_size_; } void FlexLayoutView::SetCollapseMargins(bool collapse_margins) { if (collapse_margins_ == collapse_margins) return; layout_->SetCollapseMargins(collapse_margins); collapse_margins_ = collapse_margins; OnPropertyChanged(&collapse_margins_, kPropertyEffectsLayout); } bool FlexLayoutView::GetCollapseMargins() const { return collapse_margins_; } void FlexLayoutView::SetIncludeHostInsetsInLayout( bool include_host_insets_in_layout) { if (include_host_insets_in_layout_ == include_host_insets_in_layout) return; layout_->SetIncludeHostInsetsInLayout(include_host_insets_in_layout); include_host_insets_in_layout_ = include_host_insets_in_layout; OnPropertyChanged(&include_host_insets_in_layout_, kPropertyEffectsLayout); } bool FlexLayoutView::GetIncludeHostInsetsInLayout() const { return include_host_insets_in_layout_; } void FlexLayoutView::SetIgnoreDefaultMainAxisMargins( bool ignore_default_main_axis_margins) { if (ignore_default_main_axis_margins == ignore_default_main_axis_margins_) { return; } layout_->SetIgnoreDefaultMainAxisMargins(ignore_default_main_axis_margins); ignore_default_main_axis_margins_ = ignore_default_main_axis_margins; OnPropertyChanged(&ignore_default_main_axis_margins_, kPropertyEffectsLayout); } bool FlexLayoutView::GetIgnoreDefaultMainAxisMargins() const { return ignore_default_main_axis_margins_; } void FlexLayoutView::SetFlexAllocationOrder( FlexAllocationOrder flex_allocation_order) { if (flex_allocation_order_ == flex_allocation_order) return; layout_->SetFlexAllocationOrder(flex_allocation_order); flex_allocation_order_ = flex_allocation_order; OnPropertyChanged(&flex_allocation_order_, kPropertyEffectsLayout); } FlexAllocationOrder FlexLayoutView::GetFlexAllocationOrder() const { return flex_allocation_order_; } FlexRule FlexLayoutView::GetDefaultFlexRule() const { return layout_->GetDefaultFlexRule(); } DEFINE_ENUM_CONVERTERS(LayoutOrientation, {LayoutOrientation::kHorizontal, u"kHorizontal"}, {LayoutOrientation::kVertical, u"kVertical"}) DEFINE_ENUM_CONVERTERS(LayoutAlignment, {LayoutAlignment::kStart, u"kStart"}, {LayoutAlignment::kCenter, u"kCenter"}, {LayoutAlignment::kEnd, u"kEnd"}, {LayoutAlignment::kStretch, u"kStretch"}) DEFINE_ENUM_CONVERTERS(FlexAllocationOrder, {FlexAllocationOrder::kNormal, u"kNormal"}, {FlexAllocationOrder::kReverse, u"kReverse"}) BEGIN_METADATA(FlexLayoutView, View) ADD_PROPERTY_METADATA(LayoutOrientation, Orientation) ADD_PROPERTY_METADATA(LayoutAlignment, MainAxisAlignment) ADD_PROPERTY_METADATA(LayoutAlignment, CrossAxisAlignment) ADD_PROPERTY_METADATA(const gfx::Insets, InteriorMargin) ADD_PROPERTY_METADATA(int, MinimumCrossAxisSize) ADD_PROPERTY_METADATA(bool, CollapseMargins) ADD_PROPERTY_METADATA(bool, IncludeHostInsetsInLayout) ADD_PROPERTY_METADATA(bool, IgnoreDefaultMainAxisMargins) ADD_PROPERTY_METADATA(FlexAllocationOrder, FlexAllocationOrder) END_METADATA } // namespace views
35.702857
80
0.793214
Ron423c
33d9f85d13e0f54d4fe7cdcd1f481d7cb4783d0f
6,721
cpp
C++
strategies/src/moving_averages_crossing/moving_average_crossing.cpp
Rapprise/b2s-trader
ac8a3c2221d15c4df8df63842d20dafd6801e535
[ "BSD-2-Clause" ]
21
2020-06-07T20:34:47.000Z
2021-08-10T20:19:59.000Z
strategies/src/moving_averages_crossing/moving_average_crossing.cpp
Rapprise/b2s-trader
ac8a3c2221d15c4df8df63842d20dafd6801e535
[ "BSD-2-Clause" ]
null
null
null
strategies/src/moving_averages_crossing/moving_average_crossing.cpp
Rapprise/b2s-trader
ac8a3c2221d15c4df8df63842d20dafd6801e535
[ "BSD-2-Clause" ]
4
2020-07-13T10:19:44.000Z
2022-03-11T12:15:43.000Z
/* * Copyright (c) 2020, Rapprise. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <set> #include "common/exceptions/strategy_exception/small_analyzed_period_exception.h" #include "common/exceptions/undefined_type_exception.h" #include "common/loggers/file_logger.h" #include "include/exponential_moving_average/exponential_moving_average.h" #include "include/moving_averages_crossing/moving_averages_crossing.h" #include "include/simple_moving_average/simple_moving_average.h" constexpr unsigned int MIN_MOVING_AVERAGES_COUNT = 2; namespace auto_trader { namespace strategies { void MovingAveragesCrossing::createLines(const std::vector<common::MarketData> &marketData, int smallerPeriodSize, int biggerPeriodSize, double lastBuyCrossingPoint, double lastSellCrossingPoint, common::MovingAverageType type) { crossingForSellSignal_.second = false; crossingForBuySignal_.second = false; if (marketData.size() == 0 || marketData.size() < biggerPeriodSize) { common::loggers::FileLogger::getLogger() << "MAC: bad data for creating lines."; throw common::exceptions::StrategyException( "Moving Averages Crossing: not valid data for creating lines"); } lastBuyCrossingPoint_ = lastBuyCrossingPoint; lastSellCrossingPoint_ = lastSellCrossingPoint; auto movingAveragePtr = createMovingAverage(type); movingAveragePtr->createLine(marketData, smallerPeriodSize); smallerPeriodLine_ = movingAveragePtr->getLine(); movingAveragePtr->createLine(marketData, biggerPeriodSize); biggerPeriodLine_ = movingAveragePtr->getLine(); crossingToBuySignal(); crossingToSellSignal(); } std::shared_ptr<MovingAverageBase> MovingAveragesCrossing::createMovingAverage( common::MovingAverageType type) { switch (type) { case common::MovingAverageType::EXPONENTIAL: return std::make_shared<ExponentialMovingAverage>(); case common::MovingAverageType::SIMPLE: return std::make_shared<SimpleMovingAverage>(); default: break; } throw common::exceptions::UndefinedTypeException("Moving Average Type"); } MovingAverageLine MovingAveragesCrossing::getSmallerPeriodLine() const { return smallerPeriodLine_; } MovingAverageLine MovingAveragesCrossing::getBiggerPeriodLine() const { return biggerPeriodLine_; } bool MovingAveragesCrossing::isNeedToBuy() const { return crossingForBuySignal_.second; } bool MovingAveragesCrossing::isNeedToSell() const { return crossingForSellSignal_.second; } double MovingAveragesCrossing::getLastBuyCrossingPoint() const { return lastBuyCrossingPoint_; } double MovingAveragesCrossing::getLastSellCrossingPoint() const { return lastSellCrossingPoint_; } void MovingAveragesCrossing::setCrossingInterval(unsigned int crossingInterval) { crossingInterval_ = crossingInterval; } void MovingAveragesCrossing::crossingToBuySignal() { auto lowerPeriodLineSize = smallerPeriodLine_.getSize(); auto highPeriodLineSize = biggerPeriodLine_.getSize(); auto beforeTheLastPointLowerPeriodLine = smallerPeriodLine_.getPoint(lowerPeriodLineSize - 2); auto beforeTheLastPointHighPeriodLine = biggerPeriodLine_.getPoint(highPeriodLineSize - 2); auto lastLowerLinePoint = smallerPeriodLine_.getLastPoint(); auto lastHighLinePoint = biggerPeriodLine_.getLastPoint(); if (beforeTheLastPointLowerPeriodLine < beforeTheLastPointHighPeriodLine && lastLowerLinePoint > lastHighLinePoint) { auto isDuplicate = isBuyCrossingDuplicatedOnInterval(); if (!isDuplicate) { lastBuyCrossingPoint_ = lastLowerLinePoint; crossingForBuySignal_.second = true; } else { crossingForBuySignal_.second = false; } } else { crossingForBuySignal_.second = false; } } void MovingAveragesCrossing::crossingToSellSignal() { auto lowerPeriodLineSize = smallerPeriodLine_.getSize(); auto highPeriodLineSize = biggerPeriodLine_.getSize(); auto beforeTheLastPointLowerPeriodLine = smallerPeriodLine_.getPoint(lowerPeriodLineSize - 2); auto beforeTheLastPointHighPeriodLine = biggerPeriodLine_.getPoint(highPeriodLineSize - 2); auto lastLowerLinePoint = smallerPeriodLine_.getLastPoint(); auto lastHighLinePoint = biggerPeriodLine_.getLastPoint(); if (beforeTheLastPointLowerPeriodLine > beforeTheLastPointHighPeriodLine && lastLowerLinePoint < lastHighLinePoint) { auto isDuplicate = isSellCrossingDuplicatedOnInterval(); if (!isDuplicate) { lastSellCrossingPoint_ = lastLowerLinePoint; crossingForSellSignal_.second = true; } else { crossingForSellSignal_.second = false; } } else { crossingForSellSignal_.second = false; } } bool MovingAveragesCrossing::isBuyCrossingDuplicatedOnInterval() const { auto lineSize = smallerPeriodLine_.getSize(); for (size_t index = lineSize - 1; index >= lineSize - crossingInterval_ - 1; --index) { if (smallerPeriodLine_.getPoint(index) == lastBuyCrossingPoint_) return true; } return false; } bool MovingAveragesCrossing::isSellCrossingDuplicatedOnInterval() const { auto lineSize = smallerPeriodLine_.getSize(); for (size_t index = lineSize - 1; index >= lineSize - crossingInterval_ - 1; --index) { if (smallerPeriodLine_.getPoint(index) == lastSellCrossingPoint_) return true; } return false; } } // namespace strategies } // namespace auto_trader
39.769231
99
0.767743
Rapprise
33dabeba49d27b05f1ba25ee914e1af5babc18b6
11,616
hpp
C++
external/include/boost/proto/domain.hpp
sbrown-uhd/hazelcast-cpp-client
ce57a508092fa42b9b4b371ae6c2782a21c75515
[ "Apache-2.0" ]
12,278
2015-01-29T17:11:33.000Z
2022-03-31T21:12:00.000Z
external/include/boost/proto/domain.hpp
sbrown-uhd/hazelcast-cpp-client
ce57a508092fa42b9b4b371ae6c2782a21c75515
[ "Apache-2.0" ]
9,469
2015-01-30T05:33:07.000Z
2022-03-31T16:17:21.000Z
external/include/boost/proto/domain.hpp
sbrown-uhd/hazelcast-cpp-client
ce57a508092fa42b9b4b371ae6c2782a21c75515
[ "Apache-2.0" ]
1,343
2017-12-08T19:47:19.000Z
2022-03-26T11:31:36.000Z
/////////////////////////////////////////////////////////////////////////////// /// \file domain.hpp /// Contains definition of domain\<\> class template and helpers for /// defining domains with a generator and a grammar for controlling /// operator overloading. // // Copyright 2008 Eric Niebler. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_PROTO_DOMAIN_HPP_EAN_02_13_2007 #define BOOST_PROTO_DOMAIN_HPP_EAN_02_13_2007 #include <boost/ref.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/proto/proto_fwd.hpp> #include <boost/proto/generate.hpp> #include <boost/proto/detail/as_expr.hpp> #include <boost/proto/detail/deduce_domain.hpp> #if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif namespace boost { namespace proto { namespace detail { struct not_a_generator {}; struct not_a_grammar {}; struct not_a_domain {}; } namespace domainns_ { /// \brief For use in defining domain tags to be used /// with \c proto::extends\<\>. A \e Domain associates /// an expression type with a \e Generator, and optionally /// a \e Grammar. /// /// The Generator determines how new expressions in the /// domain are constructed. Typically, a generator wraps /// all new expressions in a wrapper that imparts /// domain-specific behaviors to expressions within its /// domain. (See \c proto::extends\<\>.) /// /// The Grammar determines whether a given expression is /// valid within the domain, and automatically disables /// any operator overloads which would cause an invalid /// expression to be created. By default, the Grammar /// parameter defaults to the wildcard, \c proto::_, which /// makes all expressions valid within the domain. /// /// The Super declares the domain currently being defined /// to be a sub-domain of Super. Expressions in sub-domains /// can be freely combined with expressions in its super- /// domain (and <I>its</I> super-domain, etc.). /// /// Example: /// \code /// template<typename Expr> /// struct MyExpr; /// /// struct MyGrammar /// : or_< terminal<_>, plus<MyGrammar, MyGrammar> > /// {}; /// /// // Define MyDomain, in which all expressions are /// // wrapped in MyExpr<> and only expressions that /// // conform to MyGrammar are allowed. /// struct MyDomain /// : domain<generator<MyExpr>, MyGrammar> /// {}; /// /// // Use MyDomain to define MyExpr /// template<typename Expr> /// struct MyExpr /// : extends<Expr, MyExpr<Expr>, MyDomain> /// { /// // ... /// }; /// \endcode /// template< typename Generator // = default_generator , typename Grammar // = proto::_ , typename Super // = no_super_domain > struct domain : Generator { typedef Generator proto_generator; typedef Grammar proto_grammar; typedef Super proto_super_domain; typedef domain proto_base_domain; /// INTERNAL ONLY typedef void proto_is_domain_; /// \brief A unary MonomorphicFunctionObject that turns objects into Proto /// expression objects in this domain. /// /// The <tt>as_expr\<\></tt> function object turns objects into Proto expressions, if /// they are not already, by making them Proto terminals held by value if /// possible. Objects that are already Proto expressions are left alone. /// /// If <tt>wants_basic_expr\<Generator\>::value</tt> is true, then let \c E be \c basic_expr; /// otherwise, let \t E be \c expr. Given an lvalue \c t of type \c T: /// /// If \c T is not a Proto expression type the resulting terminal is /// calculated as follows: /// /// If \c T is a function type, an abstract type, or a type derived from /// \c std::ios_base, let \c A be <tt>T &</tt>. /// Otherwise, let \c A be the type \c T stripped of cv-qualifiers. /// Then, the result of applying <tt>as_expr\<T\>()(t)</tt> is /// <tt>Generator()(E\<tag::terminal, term\<A\> \>::make(t))</tt>. /// /// If \c T is a Proto expression type and its generator type is different from /// \c Generator, the result is <tt>Generator()(t)</tt>. /// /// Otherwise, the result is \c t converted to an (un-const) rvalue. /// template<typename T, typename IsExpr = void, typename Callable = proto::callable> struct as_expr : detail::as_expr< T , typename detail::base_generator<Generator>::type , wants_basic_expr<Generator>::value > { BOOST_PROTO_CALLABLE() }; /// INTERNAL ONLY /// template<typename T> struct as_expr<T, typename T::proto_is_expr_, proto::callable> { BOOST_PROTO_CALLABLE() typedef typename remove_const<T>::type result_type; BOOST_FORCEINLINE result_type operator()(T &e) const { return e; } }; /// \brief A unary MonomorphicFunctionObject that turns objects into Proto /// expression objects in this domain. /// /// The <tt>as_child\<\></tt> function object turns objects into Proto expressions, if /// they are not already, by making them Proto terminals held by reference. /// Objects that are already Proto expressions are simply returned by reference. /// /// If <tt>wants_basic_expr\<Generator\>::value</tt> is true, then let \c E be \c basic_expr; /// otherwise, let \t E be \c expr. Given an lvalue \c t of type \c T: /// /// If \c T is not a Proto expression type the resulting terminal is /// <tt>Generator()(E\<tag::terminal, term\<T &\> \>::make(t))</tt>. /// /// If \c T is a Proto expression type and its generator type is different from /// \c Generator, the result is <tt>Generator()(t)</tt>. /// /// Otherwise, the result is the lvalue \c t. /// template<typename T, typename IsExpr = void, typename Callable = proto::callable> struct as_child : detail::as_child< T , typename detail::base_generator<Generator>::type , wants_basic_expr<Generator>::value > { BOOST_PROTO_CALLABLE() }; /// INTERNAL ONLY /// template<typename T> struct as_child<T, typename T::proto_is_expr_, proto::callable> { BOOST_PROTO_CALLABLE() typedef T &result_type; BOOST_FORCEINLINE result_type operator()(T &e) const { return e; } }; }; /// \brief The domain expressions have by default, if /// \c proto::extends\<\> has not been used to associate /// a domain with an expression. /// struct default_domain : domain<> {}; /// \brief A domain to use when you prefer the use of /// \c proto::basic_expr\<\> over \c proto::expr\<\>. /// struct basic_default_domain : domain<basic_default_generator> {}; /// \brief A pseudo-domain for use in functions and /// metafunctions that require a domain parameter. It /// indicates that the domain of the parent node should /// be inferred from the domains of the child nodes. /// /// \attention \c deduce_domain is not itself a valid domain. /// struct deduce_domain : domain<detail::not_a_generator, detail::not_a_grammar, detail::not_a_domain> {}; /// \brief Given a domain, a tag type and an argument list, /// compute the type of the expression to generate. This is /// either an instance of \c proto::expr\<\> or /// \c proto::basic_expr\<\>. /// template<typename Domain, typename Tag, typename Args, bool WantsBasicExpr> struct base_expr { typedef proto::expr<Tag, Args, Args::arity> type; }; /// INTERNAL ONLY /// template<typename Domain, typename Tag, typename Args> struct base_expr<Domain, Tag, Args, true> { typedef proto::basic_expr<Tag, Args, Args::arity> type; }; } /// A metafunction that returns \c mpl::true_ /// if the type \c T is the type of a Proto domain; /// \c mpl::false_ otherwise. If \c T inherits from /// \c proto::domain\<\>, \c is_domain\<T\> is /// \c mpl::true_. template<typename T, typename Void /* = void*/> struct is_domain : mpl::false_ {}; /// INTERNAL ONLY /// template<typename T> struct is_domain<T, typename T::proto_is_domain_> : mpl::true_ {}; /// A metafunction that returns the domain of /// a given type. If \c T is a Proto expression /// type, it returns that expression's associated /// domain. If not, it returns /// \c proto::default_domain. template<typename T, typename Void /* = void*/> struct domain_of { typedef default_domain type; }; /// INTERNAL ONLY /// template<typename T> struct domain_of<T, typename T::proto_is_expr_> { typedef typename T::proto_domain type; }; /// INTERNAL ONLY /// template<typename T> struct domain_of<T &, void> { typedef typename domain_of<T>::type type; }; /// INTERNAL ONLY /// template<typename T> struct domain_of<boost::reference_wrapper<T>, void> { typedef typename domain_of<T>::type type; }; /// INTERNAL ONLY /// template<typename T> struct domain_of<boost::reference_wrapper<T> const, void> { typedef typename domain_of<T>::type type; }; /// A metafunction that returns \c mpl::true_ /// if the type \c SubDomain is a sub-domain of /// \c SuperDomain; \c mpl::false_ otherwise. template<typename SubDomain, typename SuperDomain> struct is_sub_domain_of : is_sub_domain_of<typename SubDomain::proto_super_domain, SuperDomain> {}; /// INTERNAL ONLY /// template<typename SuperDomain> struct is_sub_domain_of<proto::no_super_domain, SuperDomain> : mpl::false_ {}; /// INTERNAL ONLY /// template<typename SuperDomain> struct is_sub_domain_of<SuperDomain, SuperDomain> : mpl::true_ {}; }} #if defined(_MSC_VER) # pragma warning(pop) #endif #endif
34.366864
105
0.557335
sbrown-uhd
33db9d4339f77cde9c993273ea1742252a6cadaa
2,851
hxx
C++
main/xmlsecurity/source/xmlsec/nss/ciphercontext.hxx
Grosskopf/openoffice
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
[ "Apache-2.0" ]
679
2015-01-06T06:34:58.000Z
2022-03-30T01:06:03.000Z
main/xmlsecurity/source/xmlsec/nss/ciphercontext.hxx
Grosskopf/openoffice
93df6e8a695d5e3eac16f3ad5e9ade1b963ab8d7
[ "Apache-2.0" ]
102
2017-11-07T08:51:31.000Z
2022-03-17T12:13:49.000Z
main/xmlsecurity/source/xmlsec/nss/ciphercontext.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 _CIPHERCONTEXT_HXX #define _CIPHERCONTEXT_HXX #include <com/sun/star/xml/crypto/XCipherContext.hpp> #include <cppuhelper/implbase1.hxx> #include <osl/mutex.hxx> #include <pk11pub.h> class OCipherContext : public cppu::WeakImplHelper1< ::com::sun::star::xml::crypto::XCipherContext > { private: ::osl::Mutex m_aMutex; PK11SlotInfo* m_pSlot; PK11SymKey* m_pSymKey; SECItem* m_pSecParam; PK11Context* m_pContext; sal_Int32 m_nBlockSize; ::com::sun::star::uno::Sequence< sal_Int8 > m_aLastBlock; bool m_bEncryption; bool m_bPadding; bool m_bW3CPadding; sal_Int64 m_nConverted; bool m_bDisposed; bool m_bBroken; void Dispose(); OCipherContext() : m_pSlot( NULL ) , m_pSymKey( NULL ) , m_pSecParam( NULL ) , m_pContext( NULL ) , m_nBlockSize( 0 ) , m_bEncryption( false ) , m_bPadding( false ) , m_bW3CPadding( false ) , m_nConverted( 0 ) , m_bDisposed( false ) , m_bBroken( false ) {} public: virtual ~OCipherContext() { Dispose(); } static ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XCipherContext > Create( CK_MECHANISM_TYPE nNSSCipherID, const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aKey, const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aInitializationVector, bool bEncryption, bool bW3CPadding ); // XCipherContext virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL convertWithCipherContext( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::DisposedException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL finalizeCipherContextAndDispose( ) throw (::com::sun::star::lang::DisposedException, ::com::sun::star::uno::RuntimeException); }; #endif
33.151163
305
0.667485
Grosskopf
33dbf0b9e562abcc61549f27d0043b137680e850
4,961
cpp
C++
media/libmedia/AudioParameter.cpp
rubis-lab/NANS_framework_av
fc0e7dfab044f96b33c641d7ddf60d5a8f1ac46e
[ "Apache-2.0" ]
null
null
null
media/libmedia/AudioParameter.cpp
rubis-lab/NANS_framework_av
fc0e7dfab044f96b33c641d7ddf60d5a8f1ac46e
[ "Apache-2.0" ]
null
null
null
media/libmedia/AudioParameter.cpp
rubis-lab/NANS_framework_av
fc0e7dfab044f96b33c641d7ddf60d5a8f1ac46e
[ "Apache-2.0" ]
null
null
null
/* * Copyright (C) 2006-2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_TAG "AudioParameter" //#define LOG_NDEBUG 0 #include <utils/Log.h> #include <hardware/audio.h> #include <media/AudioParameter.h> namespace android { // static const char * const AudioParameter::keyRouting = AUDIO_PARAMETER_STREAM_ROUTING; const char * const AudioParameter::keySamplingRate = AUDIO_PARAMETER_STREAM_SAMPLING_RATE; const char * const AudioParameter::keyFormat = AUDIO_PARAMETER_STREAM_FORMAT; const char * const AudioParameter::keyChannels = AUDIO_PARAMETER_STREAM_CHANNELS; const char * const AudioParameter::keyFrameCount = AUDIO_PARAMETER_STREAM_FRAME_COUNT; const char * const AudioParameter::keyInputSource = AUDIO_PARAMETER_STREAM_INPUT_SOURCE; const char * const AudioParameter::keyScreenState = AUDIO_PARAMETER_KEY_SCREEN_STATE; AudioParameter::AudioParameter(const String8& keyValuePairs) { char *str = new char[keyValuePairs.length()+1]; mKeyValuePairs = keyValuePairs; char *last; strcpy(str, keyValuePairs.string()); char *pair = strtok_r(str, ";", &last); while (pair != NULL) { if (strlen(pair) != 0) { size_t eqIdx = strcspn(pair, "="); String8 key = String8(pair, eqIdx); String8 value; if (eqIdx == strlen(pair)) { value = String8(""); } else { value = String8(pair + eqIdx + 1); } if (mParameters.indexOfKey(key) < 0) { mParameters.add(key, value); } else { mParameters.replaceValueFor(key, value); } } else { ALOGV("AudioParameter() cstor empty key value pair"); } pair = strtok_r(NULL, ";", &last); } delete[] str; } AudioParameter::~AudioParameter() { mParameters.clear(); } String8 AudioParameter::toString() { String8 str = String8(""); size_t size = mParameters.size(); for (size_t i = 0; i < size; i++) { str += mParameters.keyAt(i); str += "="; str += mParameters.valueAt(i); if (i < (size - 1)) str += ";"; } return str; } status_t AudioParameter::add(const String8& key, const String8& value) { if (mParameters.indexOfKey(key) < 0) { mParameters.add(key, value); return NO_ERROR; } else { mParameters.replaceValueFor(key, value); return ALREADY_EXISTS; } } status_t AudioParameter::addInt(const String8& key, const int value) { char str[12]; if (snprintf(str, 12, "%d", value) > 0) { String8 str8 = String8(str); return add(key, str8); } else { return BAD_VALUE; } } status_t AudioParameter::addFloat(const String8& key, const float value) { char str[23]; if (snprintf(str, 23, "%.10f", value) > 0) { String8 str8 = String8(str); return add(key, str8); } else { return BAD_VALUE; } } status_t AudioParameter::remove(const String8& key) { if (mParameters.indexOfKey(key) >= 0) { mParameters.removeItem(key); return NO_ERROR; } else { return BAD_VALUE; } } status_t AudioParameter::get(const String8& key, String8& value) { if (mParameters.indexOfKey(key) >= 0) { value = mParameters.valueFor(key); return NO_ERROR; } else { return BAD_VALUE; } } status_t AudioParameter::getInt(const String8& key, int& value) { String8 str8; status_t result = get(key, str8); value = 0; if (result == NO_ERROR) { int val; if (sscanf(str8.string(), "%d", &val) == 1) { value = val; } else { result = INVALID_OPERATION; } } return result; } status_t AudioParameter::getFloat(const String8& key, float& value) { String8 str8; status_t result = get(key, str8); value = 0; if (result == NO_ERROR) { float val; if (sscanf(str8.string(), "%f", &val) == 1) { value = val; } else { result = INVALID_OPERATION; } } return result; } status_t AudioParameter::getAt(size_t index, String8& key, String8& value) { if (mParameters.size() > index) { key = mParameters.keyAt(index); value = mParameters.valueAt(index); return NO_ERROR; } else { return BAD_VALUE; } } }; // namespace android
26.961957
90
0.617819
rubis-lab
33de8fcb757034f62b7db30f9731b11c57fe5bf1
4,208
cpp
C++
compile/libbcc/lib/Renderscript/RSIsThreadablePass.cpp
Keneral/aframeworks
af1d0010bfb88751837fb1afc355705bd8a9ad8b
[ "Unlicense" ]
null
null
null
compile/libbcc/lib/Renderscript/RSIsThreadablePass.cpp
Keneral/aframeworks
af1d0010bfb88751837fb1afc355705bd8a9ad8b
[ "Unlicense" ]
null
null
null
compile/libbcc/lib/Renderscript/RSIsThreadablePass.cpp
Keneral/aframeworks
af1d0010bfb88751837fb1afc355705bd8a9ad8b
[ "Unlicense" ]
null
null
null
/* * Copyright 2015, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "bcc/Renderscript/RSTransforms.h" #include "bcc/Support/Log.h" #include <cstdlib> #include <llvm/IR/Instructions.h> #include <llvm/IR/Metadata.h> #include <llvm/IR/Module.h> #include <llvm/IR/Function.h> #include <llvm/Pass.h> namespace { // anonymous namespace // Create a Module pass that screens all the global functions in the module and // check if any non-threadable function is callable. If so, we mark the // Module as non-threadable by adding a metadata flag '#rs_is_threadable' class RSIsThreadablePass : public llvm::ModulePass { private: static char ID; std::vector<std::string> nonThreadableFns = { "_Z22rsgBindProgramFragment19rs_program_fragment", "_Z19rsgBindProgramStore16rs_program_store", "_Z20rsgBindProgramVertex17rs_program_vertex", "_Z20rsgBindProgramRaster17rs_program_raster", "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", "_Z15rsgBindConstant19rs_program_fragmentj13rs_allocation", "_Z15rsgBindConstant17rs_program_vertexj13rs_allocation", "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", "_Z33rsgProgramVertexLoadTextureMatrixPK12rs_matrix4x4", "_Z35rsgProgramVertexGetProjectionMatrixP12rs_matrix4x4", "_Z31rsgProgramFragmentConstantColor19rs_program_fragmentffff", "_Z11rsgGetWidthv", "_Z12rsgGetHeightv", "_Z11rsgDrawRectfffff", "_Z11rsgDrawQuadffffffffffff", "_Z20rsgDrawQuadTexCoordsffffffffffffffffffff", "_Z24rsgDrawSpriteScreenspacefffff", "_Z11rsgDrawMesh7rs_mesh", "_Z11rsgDrawMesh7rs_meshj", "_Z11rsgDrawMesh7rs_meshjjj", "_Z25rsgMeshComputeBoundingBox7rs_meshPfS0_S0_S0_S0_S0_", "_Z11rsgDrawPath7rs_path", "_Z13rsgClearColorffff", "_Z13rsgClearDepthf", "_Z11rsgDrawTextPKcii", "_Z11rsgDrawText13rs_allocationii", "_Z14rsgMeasureTextPKcPiS1_S1_S1_", "_Z14rsgMeasureText13rs_allocationPiS0_S0_S0_", "_Z11rsgBindFont7rs_font", "_Z12rsgFontColorffff", "_Z18rsgBindColorTarget13rs_allocationj", "_Z18rsgBindDepthTarget13rs_allocation", "_Z19rsgClearColorTargetj", "_Z19rsgClearDepthTargetv", "_Z24rsgClearAllRenderTargetsv", "_Z7rsGetDtv", "_Z5colorffff", "_Z9rsgFinishv", }; bool isPresent(std::vector<std::string> &list, std::string name) { auto lower = std::lower_bound(list.begin(), list.end(), name); if (lower != list.end() && name.compare(*lower) == 0) return true; return false; } public: RSIsThreadablePass() : ModulePass (ID) { std::sort(nonThreadableFns.begin(), nonThreadableFns.end()); } virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const override { AU.setPreservesAll(); } bool runOnModule(llvm::Module &M) override { bool threadable = true; auto &FunctionList(M.getFunctionList()); for (auto &F: FunctionList) { if (isPresent(nonThreadableFns, F.getName().str())) { threadable = false; break; } } llvm::LLVMContext &context = M.getContext(); llvm::MDString *val = llvm::MDString::get(context, (threadable) ? "yes" : "no"); llvm::NamedMDNode *node = M.getOrInsertNamedMetadata("#rs_is_threadable"); node->addOperand(llvm::MDNode::get(context, val)); return false; } }; } char RSIsThreadablePass::ID = 0; namespace bcc { llvm::ModulePass * createRSIsThreadablePass () { return new RSIsThreadablePass(); } }
30.941176
79
0.726949
Keneral
33dea591772d1b2c41ef7468c9f59744cbd25b4e
1,318
hpp
C++
Engine/Engine.hpp
Patryk404/Tetris-sfml
9bfc01726e7996184c4499addbb1eed02c735a12
[ "MIT" ]
null
null
null
Engine/Engine.hpp
Patryk404/Tetris-sfml
9bfc01726e7996184c4499addbb1eed02c735a12
[ "MIT" ]
null
null
null
Engine/Engine.hpp
Patryk404/Tetris-sfml
9bfc01726e7996184c4499addbb1eed02c735a12
[ "MIT" ]
null
null
null
#include <SFML/Graphics.hpp> #include <SFML/Audio.hpp> #include <iostream> #include <time.h> #pragma once #include "../Blocks/Block.hpp" #include "../Map/Map.hpp" class Engine { public: Engine(); void move(); void rotation(); void tick(Block block[]); void check_lines(); void check_gameover(); void run_timer(); void set_default(); void check_events(sf::Event &event); void render(sf::RenderWindow &window,sf::Text game_over[]); private: const int figures[7][4] = { {1,3,5,7}, // I {2,4,5,7}, // Z {3,5,4,6}, // S {3,5,4,7}, // T {2,3,5,7}, // L {3,5,7,6}, // J {2,3,4,5} // O }; float time; int delay; bool game; int direction; int score; bool rotate; bool first; bool play_once; sf::Music music; sf::SoundBuffer buffer; sf::SoundBuffer game_over_buffer; sf::Sound dissmiss; sf::Sound gameover; sf::RectangleShape s; sf::Clock timer; Block a[4],b[4]; Map Map; bool check(); friend class UI; };
24.867925
67
0.456753
Patryk404
33e030a5735e8e0a59ea50d1306e22d76f02af62
9,170
cpp
C++
scene/gui/box_container.cpp
kingoftheconnors/godot
e93af13959e2840e6fed58fb79ec4f7b9fdfec6a
[ "CC-BY-3.0", "Apache-2.0", "MIT" ]
1
2021-06-04T14:29:54.000Z
2021-06-04T14:29:54.000Z
scene/gui/box_container.cpp
kingoftheconnors/godot
e93af13959e2840e6fed58fb79ec4f7b9fdfec6a
[ "CC-BY-3.0", "Apache-2.0", "MIT" ]
6
2020-10-05T20:00:21.000Z
2021-07-10T19:07:27.000Z
scene/gui/box_container.cpp
kingoftheconnors/godot
e93af13959e2840e6fed58fb79ec4f7b9fdfec6a
[ "CC-BY-3.0", "Apache-2.0", "MIT" ]
2
2020-12-28T13:10:08.000Z
2021-12-31T20:53:18.000Z
/*************************************************************************/ /* box_container.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* 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 "box_container.h" #include "label.h" #include "margin_container.h" struct _MinSizeCache { int min_size; bool will_stretch; int final_size; }; void BoxContainer::_resort() { /** First pass, determine minimum size AND amount of stretchable elements */ Size2i new_size = get_size(); int sep = get_theme_constant("separation"); //,vertical?"VBoxContainer":"HBoxContainer"); bool first = true; int children_count = 0; int stretch_min = 0; int stretch_avail = 0; float stretch_ratio_total = 0; Map<Control *, _MinSizeCache> min_size_cache; for (int i = 0; i < get_child_count(); i++) { Control *c = Object::cast_to<Control>(get_child(i)); if (!c || !c->is_visible_in_tree()) { continue; } if (c->is_set_as_top_level()) { continue; } Size2i size = c->get_combined_minimum_size(); _MinSizeCache msc; if (vertical) { /* VERTICAL */ stretch_min += size.height; msc.min_size = size.height; msc.will_stretch = c->get_v_size_flags() & SIZE_EXPAND; } else { /* HORIZONTAL */ stretch_min += size.width; msc.min_size = size.width; msc.will_stretch = c->get_h_size_flags() & SIZE_EXPAND; } if (msc.will_stretch) { stretch_avail += msc.min_size; stretch_ratio_total += c->get_stretch_ratio(); } msc.final_size = msc.min_size; min_size_cache[c] = msc; children_count++; } if (children_count == 0) { return; } int stretch_max = (vertical ? new_size.height : new_size.width) - (children_count - 1) * sep; int stretch_diff = stretch_max - stretch_min; if (stretch_diff < 0) { //avoid negative stretch space stretch_diff = 0; } stretch_avail += stretch_diff; //available stretch space. /** Second, pass successively to discard elements that can't be stretched, this will run while stretchable elements exist */ bool has_stretched = false; while (stretch_ratio_total > 0) { // first of all, don't even be here if no stretchable objects exist has_stretched = true; bool refit_successful = true; //assume refit-test will go well float error = 0; // Keep track of accumulated error in pixels for (int i = 0; i < get_child_count(); i++) { Control *c = Object::cast_to<Control>(get_child(i)); if (!c || !c->is_visible_in_tree()) { continue; } if (c->is_set_as_top_level()) { continue; } ERR_FAIL_COND(!min_size_cache.has(c)); _MinSizeCache &msc = min_size_cache[c]; if (msc.will_stretch) { //wants to stretch //let's see if it can really stretch float final_pixel_size = stretch_avail * c->get_stretch_ratio() / stretch_ratio_total; // Add leftover fractional pixels to error accumulator error += final_pixel_size - (int)final_pixel_size; if (final_pixel_size < msc.min_size) { //if available stretching area is too small for widget, //then remove it from stretching area msc.will_stretch = false; stretch_ratio_total -= c->get_stretch_ratio(); refit_successful = false; stretch_avail -= msc.min_size; msc.final_size = msc.min_size; break; } else { msc.final_size = final_pixel_size; // Dump accumulated error if one pixel or more if (error >= 1) { msc.final_size += 1; error -= 1; } } } } if (refit_successful) { //uf refit went well, break break; } } /** Final pass, draw and stretch elements **/ int ofs = 0; if (!has_stretched) { switch (align) { case ALIGN_BEGIN: break; case ALIGN_CENTER: ofs = stretch_diff / 2; break; case ALIGN_END: ofs = stretch_diff; break; } } first = true; int idx = 0; for (int i = 0; i < get_child_count(); i++) { Control *c = Object::cast_to<Control>(get_child(i)); if (!c || !c->is_visible_in_tree()) { continue; } if (c->is_set_as_top_level()) { continue; } _MinSizeCache &msc = min_size_cache[c]; if (first) { first = false; } else { ofs += sep; } int from = ofs; int to = ofs + msc.final_size; if (msc.will_stretch && idx == children_count - 1) { //adjust so the last one always fits perfect //compensating for numerical imprecision to = vertical ? new_size.height : new_size.width; } int size = to - from; Rect2 rect; if (vertical) { rect = Rect2(0, from, new_size.width, size); } else { rect = Rect2(from, 0, size, new_size.height); } fit_child_in_rect(c, rect); ofs = to; idx++; } } Size2 BoxContainer::get_minimum_size() const { /* Calculate MINIMUM SIZE */ Size2i minimum; int sep = get_theme_constant("separation"); //,vertical?"VBoxContainer":"HBoxContainer"); bool first = true; for (int i = 0; i < get_child_count(); i++) { Control *c = Object::cast_to<Control>(get_child(i)); if (!c) { continue; } if (c->is_set_as_top_level()) { continue; } if (!c->is_visible()) { continue; } Size2i size = c->get_combined_minimum_size(); if (vertical) { /* VERTICAL */ if (size.width > minimum.width) { minimum.width = size.width; } minimum.height += size.height + (first ? 0 : sep); } else { /* HORIZONTAL */ if (size.height > minimum.height) { minimum.height = size.height; } minimum.width += size.width + (first ? 0 : sep); } first = false; } return minimum; } void BoxContainer::_notification(int p_what) { switch (p_what) { case NOTIFICATION_SORT_CHILDREN: { _resort(); } break; case NOTIFICATION_THEME_CHANGED: { minimum_size_changed(); } break; } } void BoxContainer::set_alignment(AlignMode p_align) { align = p_align; _resort(); } BoxContainer::AlignMode BoxContainer::get_alignment() const { return align; } void BoxContainer::add_spacer(bool p_begin) { Control *c = memnew(Control); c->set_mouse_filter(MOUSE_FILTER_PASS); //allow spacer to pass mouse events if (vertical) { c->set_v_size_flags(SIZE_EXPAND_FILL); } else { c->set_h_size_flags(SIZE_EXPAND_FILL); } add_child(c); if (p_begin) { move_child(c, 0); } } BoxContainer::BoxContainer(bool p_vertical) { vertical = p_vertical; align = ALIGN_BEGIN; } void BoxContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("add_spacer", "begin"), &BoxContainer::add_spacer); ClassDB::bind_method(D_METHOD("get_alignment"), &BoxContainer::get_alignment); ClassDB::bind_method(D_METHOD("set_alignment", "alignment"), &BoxContainer::set_alignment); BIND_ENUM_CONSTANT(ALIGN_BEGIN); BIND_ENUM_CONSTANT(ALIGN_CENTER); BIND_ENUM_CONSTANT(ALIGN_END); ADD_PROPERTY(PropertyInfo(Variant::INT, "alignment", PROPERTY_HINT_ENUM, "Begin,Center,End"), "set_alignment", "get_alignment"); } MarginContainer *VBoxContainer::add_margin_child(const String &p_label, Control *p_control, bool p_expand) { Label *l = memnew(Label); l->set_text(p_label); add_child(l); MarginContainer *mc = memnew(MarginContainer); mc->add_theme_constant_override("margin_left", 0); mc->add_child(p_control); add_child(mc); if (p_expand) { mc->set_v_size_flags(SIZE_EXPAND_FILL); } return mc; }
28.042813
129
0.618757
kingoftheconnors
33e1acfa7698aa8249c191f3e7dc3853b7d523a7
8,635
hpp
C++
include/dca/phys/dca_step/cluster_solver/ctint/structs/interaction_vertices.hpp
NunoEdgarGFlowHub/DCA
51d0085084c9c3eb628893b78596eacfaf2d3ace
[ "BSD-3-Clause" ]
2
2019-12-18T17:13:00.000Z
2021-07-30T01:45:30.000Z
include/dca/phys/dca_step/cluster_solver/ctint/structs/interaction_vertices.hpp
cosdis/DCA
3cfd2a4f4bb876fb69f9c22e7ad06332fb5ebbe5
[ "BSD-3-Clause" ]
1
2021-08-18T07:33:39.000Z
2021-08-18T07:33:39.000Z
include/dca/phys/dca_step/cluster_solver/ctint/structs/interaction_vertices.hpp
cosdis/DCA
3cfd2a4f4bb876fb69f9c22e7ad06332fb5ebbe5
[ "BSD-3-Clause" ]
null
null
null
// Copyright (C) 2018 ETH Zurich // Copyright (C) 2018 UT-Battelle, LLC // All rights reserved. // See LICENSE.txt for terms of usage./ // See CITATION.md for citation guidelines, if DCA++ is used for scientific publications. // // Authors: Giovanni Balduzzi (gbalduzz@itp.phys.ethz.ch) // // This class represent all possible interaction terms of the hamiltonian, and provide // functionalities to randomly sample from them and pair non density-density terms together. #ifndef DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_CTINT_STRUCTS_INTERACTION_VERTICES_HPP #define DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_CTINT_STRUCTS_INTERACTION_VERTICES_HPP #include <algorithm> #include <cmath> #include <stdexcept> #include <vector> #include "dca/function/function.hpp" namespace dca { namespace phys { namespace solver { namespace ctint { // dca::phys::solver::ctint:: // Represent a matrix element W(i,j,k,l) of the interaction hamiltonian. // Each index represent a cluster position and a spin-band index. struct InteractionElement { std::array<ushort, 4> r; std::array<ushort, 4> nu; double w; // TODO: write proper constructor. std::vector<ushort> partners_id = std::vector<ushort>(); // Returns true if r and nu members are equal. bool operator==(const InteractionElement& other) const; }; // Store the interaction terms and allow drawing a random vertex with strength |w|. class InteractionVertices { public: // Initialize vertices with a density-density Hamiltonian. // Precondition: Domain has the shape of dmn_variadic<Nu, Nu, Rdmn> template <class Nu, class Rdmn> void initializeFromHamiltonian(const func::function<double, func::dmn_variadic<Nu, Nu, Rdmn>>& H_int); template <class Nu, class Rdmn> void initializeFromNonDensityHamiltonian( const func::function<double, func::dmn_variadic<Nu, Nu, Nu, Nu, Rdmn>>& H_int); void insertElement(InteractionElement v); void insertElement(const std::vector<double>& vec); template <class Nu, class Rdmn, class TDmn> void checkForInterbandPropagators( const func::function<double, func::dmn_variadic<Nu, Nu, Rdmn, TDmn>>& G_r_t); void reset(); // In: random number generator object. // Returns: first: random vertex sampled with probability proportional to |vertex.w|. // second: first vertex partner's id if it exists, -1 otherwise. template <class Rng> std::pair<short, short> getInsertionIndices(Rng& rng, double double_update_prob) const; // Returns: the sum of the absolute values of the interaction strengths. double integratedInteraction() const { return total_weigth_; } std::size_t size() const { return elements_.size(); } const InteractionElement& operator[](const int idx) const { assert(idx < int(size())); return elements_[idx]; } // Returns the number of possible partners for each non density-density interaction. int possiblePartners() const { const int partners = elements_.back().partners_id.size(); // TODO: generalize if number of possible pairings is not constant or at the back. return partners; } std::vector<InteractionElement> elements_; private: std::vector<double> cumulative_weigths_; double total_weigth_ = 0; bool interband_propagator_ = false; }; template <class Rng> std::pair<short, short> InteractionVertices::getInsertionIndices(Rng& rng, double double_update_prob) const { const double random = rng() * total_weigth_; // search in reverse order. const auto it_to_vertex = std::upper_bound(cumulative_weigths_.rbegin(), cumulative_weigths_.rend(), random); const int index = cumulative_weigths_.rend() - it_to_vertex - 1; assert(index >= 0 && index < size()); assert(double_update_prob >= 0 && double_update_prob <= 1); auto do_double = [&]() -> bool { if (double_update_prob == 0) return 0; else if (double_update_prob == 1) return 1; else return rng() < double_update_prob; }; if (elements_[index].partners_id.size() && do_double()) { // double insertion const auto& partners = elements_[index].partners_id; auto partner_id = partners[rng() * partners.size()]; return std::make_pair(index, partner_id); } else { return std::make_pair(index, -1); } } template <class Nu, class Rdmn> void InteractionVertices::initializeFromHamiltonian( const func::function<double, func::dmn_variadic<Nu, Nu, Rdmn>>& H_int) { // Note: Use this version of the code if double counting in the interaction hamiltonian is removed. // // for (ushort nu1 = 0; nu1 < Nu::dmn_size(); nu1++) { // for (ushort nu2 = 0; nu2 < Nu::dmn_size(); nu2++) // for (ushort delta_r = 0; delta_r < Rdmn::dmn_size(); delta_r++) { // const double value = H_int(nu1, nu2, delta_r); // if (std::abs(value) < 1e-8) // continue; // for (ushort r1 = 0; r1 < Rdmn::dmn_size(); r1++) { // const ushort r2 = Rdmn::parameter_type::subtract(delta_r, r1); // delta_r = r1 - r2 // insertElement(InteractionElement{{r1, r1, r2, r2}, {nu1, nu1, nu2, nu2}, value, short(-1)}); // } // } // } // Assume the density-density interaction Hamiltonian function is double counted, i.e. // H(b1, b2, r1 - r2) == H(b2, b1, r -r2) and both terms describe the same addendum to the // physical Hamiltonian. func::function<bool, func::dmn_variadic<Nu, Nu, Rdmn>> already_inserted; const int r0 = Rdmn::parameter_type::origin_index(); for (ushort nu1 = 0; nu1 < Nu::dmn_size(); nu1++) { for (ushort nu2 = 0; nu2 < Nu::dmn_size(); nu2++) for (ushort delta_r = 0; delta_r < Rdmn::dmn_size(); delta_r++) { const double value = H_int(nu1, nu2, delta_r); if (std::abs(value) < 1e-8) continue; const double minus_delta_r = Rdmn::parameter_type::subtract(delta_r, r0); if (std::abs(H_int(nu1, nu2, delta_r) - H_int(nu2, nu1, minus_delta_r)) > 1e-8) throw(std::logic_error("The interaction double counting is not consistent.")); if (already_inserted(nu2, nu1, minus_delta_r)) // Avoid double counting. continue; // Insert already_inserted(nu1, nu2, delta_r) = true; for (ushort r1 = 0; r1 < Rdmn::dmn_size(); r1++) { const ushort r2 = Rdmn::parameter_type::subtract(delta_r, r1); // delta_r = r1 - r2 insertElement(InteractionElement{{r1, r1, r2, r2}, {nu1, nu1, nu2, nu2}, value}); } } } } template <class Nu, class Rdmn> void InteractionVertices::initializeFromNonDensityHamiltonian( const func::function<double, func::dmn_variadic<Nu, Nu, Nu, Nu, Rdmn>>& H_int) { auto spin = [](ushort nu) { return nu >= Nu::dmn_size() / 2; }; auto check_spins = [&](ushort nu1, ushort nu2, ushort nu3, ushort nu4) -> bool { return spin(nu1) == spin(nu2) && spin(nu3) == spin(nu4); }; for (ushort nu1 = 0; nu1 < Nu::dmn_size(); nu1++) for (ushort nu2 = 0; nu2 < Nu::dmn_size(); nu2++) for (ushort nu3 = 0; nu3 < Nu::dmn_size(); nu3++) for (ushort nu4 = 0; nu4 < Nu::dmn_size(); nu4++) for (ushort delta_r = 0; delta_r < Rdmn::dmn_size(); delta_r++) { const double value = H_int(nu1, nu2, nu3, nu4, delta_r); if (std::abs(value) < 1e-8) continue; if (not check_spins(nu1, nu2, nu3, nu4)) throw(std::logic_error( "Format input hamiltonian s.t. pair of creation and annihilation " "operators have same spin.")); for (ushort r1 = 0; r1 < Rdmn::dmn_size(); r1++) { const ushort r2 = Rdmn::parameter_type::subtract(delta_r, r1); insertElement(InteractionElement{{r1, r1, r2, r2}, {nu1, nu2, nu3, nu4}, value}); } } } template <class Nu, class RDmn, class TDmn> void InteractionVertices::checkForInterbandPropagators( const func::function<double, func::dmn_variadic<Nu, Nu, RDmn, TDmn>>& G_r_t) { interband_propagator_ = false; const int t0 = TDmn::dmn_size() / 2; const int nb = Nu::dmn_size() / 2; const int r0 = RDmn::parameter_type::origin_index(); for (int r = 0; r < RDmn::dmn_size(); ++r) for (int b1 = 0; b1 < nb; ++b1) for (int b2 = 0; b2 < nb; ++b2) { if (r != r0 && b1 != b2 && std::abs(G_r_t(b1, 0, b2, 0, r, t0)) > 1e-8) { interband_propagator_ = true; return; } } } } // namespace ctint } // namespace solver } // namespace phys } // namespace dca #endif // DCA_PHYS_DCA_STEP_CLUSTER_SOLVER_CTINT_STRUCTS_INTERACTION_VERTICES_HPP
39.072398
106
0.652693
NunoEdgarGFlowHub
33e3f4bfa8178f6ca4828664f24947e7ae3471f8
5,460
cpp
C++
sp/src/game/client/view_scene.cpp
tingtom/Fodder
3250572dbc56547709f564ba68e451b21660cdb4
[ "Unlicense" ]
12
2016-09-24T02:47:18.000Z
2020-12-29T16:16:52.000Z
sp/src/game/client/view_scene.cpp
tingtom/Fodder
3250572dbc56547709f564ba68e451b21660cdb4
[ "Unlicense" ]
31
2016-11-27T14:38:02.000Z
2020-06-03T11:11:29.000Z
sp/src/game/client/view_scene.cpp
tingtom/Fodder
3250572dbc56547709f564ba68e451b21660cdb4
[ "Unlicense" ]
6
2015-02-20T06:11:13.000Z
2018-11-15T08:22:01.000Z
//========= Copyright Valve Corporation, All rights reserved. ============// // // Purpose: Responsible for drawing the scene // //===========================================================================// #include "cbase.h" #include "materialsystem/imaterialsystem.h" #include "materialsystem/imaterialvar.h" #include "materialsystem/imaterialsystemhardwareconfig.h" #include "rendertexture.h" #include "view_scene.h" #include "viewrender.h" #include "headtrack/isourcevirtualreality.h" #include "client_virtualreality.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" //----------------------------------------------------------------------------- // Convars related to controlling rendering //----------------------------------------------------------------------------- ConVar r_updaterefracttexture( "r_updaterefracttexture", "1", FCVAR_CHEAT ); ConVar r_depthoverlay( "r_depthoverlay", "0", FCVAR_CHEAT, "Replaces opaque objects with their grayscaled depth values. r_showz_power scales the output." ); int g_viewscene_refractUpdateFrame = 0; bool g_bAllowMultipleRefractUpdatesPerScenePerFrame = false; #if defined( _X360 ) class CAllowMultipleRefractsLogic : public CAutoGameSystem { public: void LevelInitPreEntity() { // EP1 core room needs many refract updates per frame to avoid looking broken (ep1_citadel_03) // Same with Kleiner's lab (d1_trainstation_05) g_bAllowMultipleRefractUpdatesPerScenePerFrame = FStrEq( MapName(), "ep1_citadel_03" ) || FStrEq( MapName(), "d1_trainstation_05" ); } }; static CAllowMultipleRefractsLogic s_AllowMultipleRefractsLogic; #endif void ViewTransform( const Vector &worldSpace, Vector &viewSpace ) { const VMatrix &viewMatrix = engine->WorldToViewMatrix(); Vector3DMultiplyPosition( viewMatrix, worldSpace, viewSpace ); } //----------------------------------------------------------------------------- // Purpose: Transforms a world-space position into a 2D position inside a supplied frustum. //----------------------------------------------------------------------------- int FrustumTransform( const VMatrix &worldToSurface, const Vector& point, Vector& screen ) { // UNDONE: Clean this up some, handle off-screen vertices float w; screen.x = worldToSurface[0][0] * point[0] + worldToSurface[0][1] * point[1] + worldToSurface[0][2] * point[2] + worldToSurface[0][3]; screen.y = worldToSurface[1][0] * point[0] + worldToSurface[1][1] * point[1] + worldToSurface[1][2] * point[2] + worldToSurface[1][3]; // z = worldToSurface[2][0] * point[0] + worldToSurface[2][1] * point[1] + worldToSurface[2][2] * point[2] + worldToSurface[2][3]; w = worldToSurface[3][0] * point[0] + worldToSurface[3][1] * point[1] + worldToSurface[3][2] * point[2] + worldToSurface[3][3]; // Just so we have something valid here screen.z = 0.0f; bool behind; if( w < 0.001f ) { behind = true; screen.x *= 100000; screen.y *= 100000; } else { behind = false; float invw = 1.0f / w; screen.x *= invw; screen.y *= invw; } return behind; } //----------------------------------------------------------------------------- // Purpose: UNDONE: Clean this up some, handle off-screen vertices // Input : *point - // *screen - // Output : int //----------------------------------------------------------------------------- int ScreenTransform( const Vector& point, Vector& screen ) { // UNDONE: Clean this up some, handle off-screen vertices return FrustumTransform ( engine->WorldToScreenMatrix(), point, screen ); } //----------------------------------------------------------------------------- // Purpose: Same as ScreenTransform, but transforms to HUD space. // These are totally different things in VR mode! //----------------------------------------------------------------------------- int HudTransform( const Vector& point, Vector& screen ) { if ( UseVR() ) { return FrustumTransform ( g_ClientVirtualReality.GetHudProjectionFromWorld(), point, screen ); } else { return FrustumTransform ( engine->WorldToScreenMatrix(), point, screen ); } } void UpdateFullScreenDepthTexture( void ) { if( !g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_b() ) return; ITexture *pDepthTex = GetFullFrameDepthTexture(); CMatRenderContextPtr pRenderContext( materials ); if( IsX360() ) { pRenderContext->CopyRenderTargetToTextureEx( pDepthTex, -1, NULL, NULL ); } else { pRenderContext->CopyRenderTargetToTextureEx( pDepthTex, 0, NULL, NULL ); } pRenderContext->SetFullScreenDepthTextureValidityFlag( true ); if( r_depthoverlay.GetBool() ) { IMaterial *pMaterial = materials->FindMaterial( "debug/showz", TEXTURE_GROUP_OTHER, true ); pMaterial->IncrementReferenceCount(); IMaterialVar *BaseTextureVar = pMaterial->FindVar( "$basetexture", NULL, false ); IMaterialVar *pDepthInAlpha = NULL; if( IsPC() ) { pDepthInAlpha = pMaterial->FindVar( "$ALPHADEPTH", NULL, false ); pDepthInAlpha->SetIntValue( 1 ); } BaseTextureVar->SetTextureValue( pDepthTex ); pRenderContext->OverrideDepthEnable( true, false ); //don't write to depth, or else we'll never see translucents pRenderContext->DrawScreenSpaceQuad( pMaterial ); pRenderContext->OverrideDepthEnable( false, true ); pMaterial->DecrementReferenceCount(); } }
35
157
0.61337
tingtom
33e545f539c638f2cb465f4dc3b0e170baba2fb6
1,745
cpp
C++
samples/CoreAPI_PointSpriteTest/PointSpriteTestApp.cpp
odayibasi/swengine
ef07b7c9125d01596837a423a9f3dcbced1f5aa7
[ "Zlib", "MIT" ]
3
2021-03-01T20:41:13.000Z
2021-07-10T13:45:47.000Z
samples/CoreAPI_PointSpriteTest/PointSpriteTestApp.cpp
odayibasi/swengine
ef07b7c9125d01596837a423a9f3dcbced1f5aa7
[ "Zlib", "MIT" ]
null
null
null
samples/CoreAPI_PointSpriteTest/PointSpriteTestApp.cpp
odayibasi/swengine
ef07b7c9125d01596837a423a9f3dcbced1f5aa7
[ "Zlib", "MIT" ]
null
null
null
//SWEngine #include "../../include/SWEngine.h" #pragma comment (lib,"../../lib/SWUtil.lib") #pragma comment (lib,"../../lib/SWTypes.lib") #pragma comment (lib,"../../lib/SWCore.lib") #pragma comment (lib,"../../lib/SWEngine.lib") swApplication pointSpriteApp; int pointSpriteID=-1; swPoint pointS[3]; swColor colorS[3]; //------------------------------------------------------------------------------------------- void GameLoop(){ swGraphicsBeginScene(); swGraphicsSetBlendingMode(SW_BLENDING_MODE_ADDITIVE_ACCORDING2_ALPHA); swGraphicsRenderPointSprite0(pointSpriteID,60,3,colorS,pointS); swGraphicsEndScene(); } //------------------------------------------------------------------------------------------- void GameInit(){ pointSpriteID=swGraphicsCreatePointSprite("particleX.tga"); pointS[0].x=100; pointS[0].y=100; colorS[0].r=0.2; colorS[0].g=0.8; colorS[0].b=0.8; colorS[0].a=0.5; pointS[1].x=300; pointS[1].y=300; colorS[1].r=0.8; colorS[1].g=0.8; colorS[1].b=0.8; colorS[1].a=1; pointS[2].x=500; pointS[2].y=500; colorS[2].r=1.0; colorS[2].g=0.1; colorS[2].b=0.1; colorS[2].a=1; } //------------------------------------------------------------------------------------------- int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) { //Application Settings pointSpriteApp.hInstance=hInstance; pointSpriteApp.fullScreen=false; pointSpriteApp.cursor=true; pointSpriteApp.width=800; pointSpriteApp.height=600; pointSpriteApp.title="Point Sprite"; pointSpriteApp.path="\\rsc\\PointSprites\\"; pointSpriteApp.appRun=GameLoop; //Application Execution swEngineInit(&pointSpriteApp); GameInit(); swEngineRun(); swEngineExit(); return 0; }
25.661765
93
0.598281
odayibasi
33e679a0092df6b9234ed6c8c7998b3f46b7c54b
72,215
cpp
C++
benchmarks/Stencil/2PE/tapa_result/cpp/compute.cpp
Blaok/AutoBridge
e296a6d5ffe96ddf7ee35bd239ce1cd4a41f3670
[ "MIT" ]
76
2020-12-30T05:47:35.000Z
2022-02-21T20:05:20.000Z
benchmarks/Stencil/2PE/tapa_result/cpp/compute.cpp
Blaok/AutoBridge
e296a6d5ffe96ddf7ee35bd239ce1cd4a41f3670
[ "MIT" ]
16
2021-01-08T23:49:08.000Z
2022-03-28T22:08:31.000Z
benchmarks/Stencil/2PE/tapa_result/cpp/compute.cpp
Blaok/AutoBridge
e296a6d5ffe96ddf7ee35bd239ce1cd4a41f3670
[ "MIT" ]
15
2021-03-02T05:56:58.000Z
2021-12-23T01:28:25.000Z
#include<float.h> #include<math.h> #include<stdbool.h> #include<stddef.h> #include<stdint.h> #include<stdio.h> #include<string.h> #include "ap_int.h" #include "tlp.h" #define BURST_WIDTH 512 #define UNROLL_FACTOR 64 #define TILE_SIZE_DIM_0 8000 #ifndef BURST_WIDTH #define BURST_WIDTH 512 #endif//BURST_WIDTH #if UNROLL_FACTOR != 64 #error UNROLL_FACTOR != 64 #endif//UNROLL_FACTOR != 64 #if TILE_SIZE_DIM_0 != 8000 #error TILE_SIZE_DIM_0 != 8000 #endif//TILE_SIZE_DIM_0 != 8000 #if BURST_WIDTH != 512 #error BURST_WIDTH != 512 #endif//BURST_WIDTH != 512 void compute( tlp::ostream<ap_uint<BURST_WIDTH> >& to_chan_0_bank_0, tlp::ostream<ap_uint<BURST_WIDTH> >& to_chan_0_bank_1, tlp::ostream<ap_uint<BURST_WIDTH> >& to_chan_0_bank_2, tlp::ostream<ap_uint<BURST_WIDTH> >& to_chan_0_bank_3, tlp::istream<ap_uint<BURST_WIDTH> >& from_chan_0_bank_0, tlp::istream<ap_uint<BURST_WIDTH> >& from_chan_0_bank_1, tlp::istream<ap_uint<BURST_WIDTH> >& from_chan_0_bank_2, tlp::istream<ap_uint<BURST_WIDTH> >& from_chan_0_bank_3, int64_t coalesced_data_num, int64_t tile_data_num, int32_t tile_num_dim_0, int32_t input_size_dim_0, int32_t input_size_dim_1) { #pragma HLS data_pack variable = to_chan_0_bank_0.fifo #pragma HLS data_pack variable = to_chan_0_bank_1.fifo #pragma HLS data_pack variable = to_chan_0_bank_2.fifo #pragma HLS data_pack variable = to_chan_0_bank_3.fifo #pragma HLS data_pack variable = from_chan_0_bank_0.fifo #pragma HLS data_pack variable = from_chan_0_bank_0.peek_val #pragma HLS data_pack variable = from_chan_0_bank_1.fifo #pragma HLS data_pack variable = from_chan_0_bank_1.peek_val #pragma HLS data_pack variable = from_chan_0_bank_2.fifo #pragma HLS data_pack variable = from_chan_0_bank_2.peek_val #pragma HLS data_pack variable = from_chan_0_bank_3.fifo #pragma HLS data_pack variable = from_chan_0_bank_3.peek_val int32_t tile_index_dim_0 = 0; // reuse chains for t1 float FF_t1_chan_0[2]; float FIFO_125_t1_chan_0[126][125]; float FIFO_124_t1_chan_0[2][124]; #pragma HLS array_partition variable=FF_t1_chan_0 complete #pragma HLS resource variable=FF_t1_chan_0 latency=1 #pragma HLS array_partition variable=FIFO_125_t1_chan_0 complete dim=1 #pragma HLS array_partition variable=FIFO_124_t1_chan_0 complete dim=1 uint8_t FIFO_125_t1_ptr = 0; uint8_t FIFO_124_t1_ptr = 0; // points aliases for t1 float points_from_t1_to_t0_chan_0[UNROLL_FACTOR][5]; // points_from_t1_to_t0_chan_x[UNROLL_FACTOR][0] <=> t1[x](1, 0) // points_from_t1_to_t0_chan_x[UNROLL_FACTOR][1] <=> t1[x](0, 1) // points_from_t1_to_t0_chan_x[UNROLL_FACTOR][2] <=> t1[x](1, 1) // points_from_t1_to_t0_chan_x[UNROLL_FACTOR][3] <=> t1[x](2, 1) // points_from_t1_to_t0_chan_x[UNROLL_FACTOR][4] <=> t1[x](1, 2) #pragma HLS array_partition variable=points_from_t1_to_t0_chan_0 complete dim=0 // input buffer float buffer_t1_chan_0[UNROLL_FACTOR]; #pragma HLS array_partition variable=buffer_t1_chan_0 complete dim=0 #pragma HLS resource variable=buffer_t1_chan_0 latency=1 // intermediate buffer for t1 // output buffer float buffer_t0_chan_0[UNROLL_FACTOR]; #pragma HLS array_partition variable=buffer_t0_chan_0 complete dim=0 #pragma HLS resource variable=buffer_t0_chan_0 latency=1 // produce output compute_epoch: for(int32_t epoch = 0; epoch < coalesced_data_num*1; ++epoch) { #pragma HLS dependence variable=FF_t1_chan_0 inter false #pragma HLS dependence variable=FIFO_125_t1_chan_0 inter false #pragma HLS dependence variable=FIFO_124_t1_chan_0 inter false #pragma HLS pipeline II=1 { ap_uint<BURST_WIDTH> tmp_chan_0_bank_0, tmp_chan_0_bank_1, tmp_chan_0_bank_2, tmp_chan_0_bank_3; tmp_chan_0_bank_0 = from_chan_0_bank_0.read(); tmp_chan_0_bank_1 = from_chan_0_bank_1.read(); tmp_chan_0_bank_2 = from_chan_0_bank_2.read(); tmp_chan_0_bank_3 = from_chan_0_bank_3.read(); load_coalesced: for(int j = 0; j < BURST_WIDTH/32; ++j) { #pragma HLS unroll uint32_t raw_bits_chan_0_bank_0 = tmp_chan_0_bank_0((j+1)*32-1, j*32); buffer_t1_chan_0[BURST_WIDTH/32*4*0+j*4+0] = *(float*)(&raw_bits_chan_0_bank_0); uint32_t raw_bits_chan_0_bank_1 = tmp_chan_0_bank_1((j+1)*32-1, j*32); buffer_t1_chan_0[BURST_WIDTH/32*4*0+j*4+1] = *(float*)(&raw_bits_chan_0_bank_1); uint32_t raw_bits_chan_0_bank_2 = tmp_chan_0_bank_2((j+1)*32-1, j*32); buffer_t1_chan_0[BURST_WIDTH/32*4*0+j*4+2] = *(float*)(&raw_bits_chan_0_bank_2); uint32_t raw_bits_chan_0_bank_3 = tmp_chan_0_bank_3((j+1)*32-1, j*32); buffer_t1_chan_0[BURST_WIDTH/32*4*0+j*4+3] = *(float*)(&raw_bits_chan_0_bank_3); } } float& FIFO_125_t1_chan_0_fifo_0 = FIFO_125_t1_chan_0[0][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_1 = FIFO_125_t1_chan_0[1][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_2 = FIFO_125_t1_chan_0[2][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_3 = FIFO_125_t1_chan_0[3][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_4 = FIFO_125_t1_chan_0[4][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_5 = FIFO_125_t1_chan_0[5][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_6 = FIFO_125_t1_chan_0[6][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_7 = FIFO_125_t1_chan_0[7][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_8 = FIFO_125_t1_chan_0[8][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_9 = FIFO_125_t1_chan_0[9][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_10 = FIFO_125_t1_chan_0[10][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_11 = FIFO_125_t1_chan_0[11][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_12 = FIFO_125_t1_chan_0[12][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_13 = FIFO_125_t1_chan_0[13][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_14 = FIFO_125_t1_chan_0[14][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_15 = FIFO_125_t1_chan_0[15][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_16 = FIFO_125_t1_chan_0[16][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_17 = FIFO_125_t1_chan_0[17][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_18 = FIFO_125_t1_chan_0[18][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_19 = FIFO_125_t1_chan_0[19][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_20 = FIFO_125_t1_chan_0[20][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_21 = FIFO_125_t1_chan_0[21][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_22 = FIFO_125_t1_chan_0[22][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_23 = FIFO_125_t1_chan_0[23][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_24 = FIFO_125_t1_chan_0[24][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_25 = FIFO_125_t1_chan_0[25][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_26 = FIFO_125_t1_chan_0[26][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_27 = FIFO_125_t1_chan_0[27][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_28 = FIFO_125_t1_chan_0[28][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_29 = FIFO_125_t1_chan_0[29][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_30 = FIFO_125_t1_chan_0[30][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_31 = FIFO_125_t1_chan_0[31][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_32 = FIFO_125_t1_chan_0[32][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_33 = FIFO_125_t1_chan_0[33][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_34 = FIFO_125_t1_chan_0[34][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_35 = FIFO_125_t1_chan_0[35][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_36 = FIFO_125_t1_chan_0[36][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_37 = FIFO_125_t1_chan_0[37][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_38 = FIFO_125_t1_chan_0[38][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_39 = FIFO_125_t1_chan_0[39][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_40 = FIFO_125_t1_chan_0[40][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_41 = FIFO_125_t1_chan_0[41][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_42 = FIFO_125_t1_chan_0[42][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_43 = FIFO_125_t1_chan_0[43][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_44 = FIFO_125_t1_chan_0[44][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_45 = FIFO_125_t1_chan_0[45][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_46 = FIFO_125_t1_chan_0[46][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_47 = FIFO_125_t1_chan_0[47][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_48 = FIFO_125_t1_chan_0[48][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_49 = FIFO_125_t1_chan_0[49][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_50 = FIFO_125_t1_chan_0[50][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_51 = FIFO_125_t1_chan_0[51][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_52 = FIFO_125_t1_chan_0[52][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_53 = FIFO_125_t1_chan_0[53][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_54 = FIFO_125_t1_chan_0[54][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_55 = FIFO_125_t1_chan_0[55][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_56 = FIFO_125_t1_chan_0[56][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_57 = FIFO_125_t1_chan_0[57][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_58 = FIFO_125_t1_chan_0[58][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_59 = FIFO_125_t1_chan_0[59][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_60 = FIFO_125_t1_chan_0[60][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_61 = FIFO_125_t1_chan_0[61][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_62 = FIFO_125_t1_chan_0[62][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_63 = FIFO_125_t1_chan_0[63][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_64 = FIFO_125_t1_chan_0[64][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_65 = FIFO_125_t1_chan_0[65][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_66 = FIFO_125_t1_chan_0[66][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_67 = FIFO_125_t1_chan_0[67][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_68 = FIFO_125_t1_chan_0[68][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_69 = FIFO_125_t1_chan_0[69][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_70 = FIFO_125_t1_chan_0[70][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_71 = FIFO_125_t1_chan_0[71][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_72 = FIFO_125_t1_chan_0[72][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_73 = FIFO_125_t1_chan_0[73][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_74 = FIFO_125_t1_chan_0[74][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_75 = FIFO_125_t1_chan_0[75][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_76 = FIFO_125_t1_chan_0[76][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_77 = FIFO_125_t1_chan_0[77][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_78 = FIFO_125_t1_chan_0[78][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_79 = FIFO_125_t1_chan_0[79][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_80 = FIFO_125_t1_chan_0[80][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_81 = FIFO_125_t1_chan_0[81][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_82 = FIFO_125_t1_chan_0[82][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_83 = FIFO_125_t1_chan_0[83][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_84 = FIFO_125_t1_chan_0[84][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_85 = FIFO_125_t1_chan_0[85][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_86 = FIFO_125_t1_chan_0[86][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_87 = FIFO_125_t1_chan_0[87][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_88 = FIFO_125_t1_chan_0[88][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_89 = FIFO_125_t1_chan_0[89][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_90 = FIFO_125_t1_chan_0[90][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_91 = FIFO_125_t1_chan_0[91][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_92 = FIFO_125_t1_chan_0[92][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_93 = FIFO_125_t1_chan_0[93][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_94 = FIFO_125_t1_chan_0[94][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_95 = FIFO_125_t1_chan_0[95][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_96 = FIFO_125_t1_chan_0[96][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_97 = FIFO_125_t1_chan_0[97][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_98 = FIFO_125_t1_chan_0[98][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_99 = FIFO_125_t1_chan_0[99][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_100 = FIFO_125_t1_chan_0[100][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_101 = FIFO_125_t1_chan_0[101][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_102 = FIFO_125_t1_chan_0[102][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_103 = FIFO_125_t1_chan_0[103][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_104 = FIFO_125_t1_chan_0[104][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_105 = FIFO_125_t1_chan_0[105][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_106 = FIFO_125_t1_chan_0[106][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_107 = FIFO_125_t1_chan_0[107][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_108 = FIFO_125_t1_chan_0[108][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_109 = FIFO_125_t1_chan_0[109][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_110 = FIFO_125_t1_chan_0[110][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_111 = FIFO_125_t1_chan_0[111][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_112 = FIFO_125_t1_chan_0[112][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_113 = FIFO_125_t1_chan_0[113][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_114 = FIFO_125_t1_chan_0[114][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_115 = FIFO_125_t1_chan_0[115][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_116 = FIFO_125_t1_chan_0[116][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_117 = FIFO_125_t1_chan_0[117][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_118 = FIFO_125_t1_chan_0[118][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_119 = FIFO_125_t1_chan_0[119][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_120 = FIFO_125_t1_chan_0[120][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_121 = FIFO_125_t1_chan_0[121][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_122 = FIFO_125_t1_chan_0[122][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_123 = FIFO_125_t1_chan_0[123][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_124 = FIFO_125_t1_chan_0[124][FIFO_125_t1_ptr]; float& FIFO_125_t1_chan_0_fifo_125 = FIFO_125_t1_chan_0[125][FIFO_125_t1_ptr]; float& FIFO_124_t1_chan_0_fifo_0 = FIFO_124_t1_chan_0[0][FIFO_124_t1_ptr]; float& FIFO_124_t1_chan_0_fifo_1 = FIFO_124_t1_chan_0[1][FIFO_124_t1_ptr]; points_from_t1_to_t0_chan_0[0][4] = buffer_t1_chan_0[0]; // t1[0](1, 2) @ unroll_index=0 points_from_t1_to_t0_chan_0[1][4] = buffer_t1_chan_0[1]; // t1[0](1, 2) @ unroll_index=1 points_from_t1_to_t0_chan_0[2][4] = buffer_t1_chan_0[2]; // t1[0](1, 2) @ unroll_index=2 points_from_t1_to_t0_chan_0[3][4] = buffer_t1_chan_0[3]; // t1[0](1, 2) @ unroll_index=3 points_from_t1_to_t0_chan_0[4][4] = buffer_t1_chan_0[4]; // t1[0](1, 2) @ unroll_index=4 points_from_t1_to_t0_chan_0[5][4] = buffer_t1_chan_0[5]; // t1[0](1, 2) @ unroll_index=5 points_from_t1_to_t0_chan_0[6][4] = buffer_t1_chan_0[6]; // t1[0](1, 2) @ unroll_index=6 points_from_t1_to_t0_chan_0[7][4] = buffer_t1_chan_0[7]; // t1[0](1, 2) @ unroll_index=7 points_from_t1_to_t0_chan_0[8][4] = buffer_t1_chan_0[8]; // t1[0](1, 2) @ unroll_index=8 points_from_t1_to_t0_chan_0[9][4] = buffer_t1_chan_0[9]; // t1[0](1, 2) @ unroll_index=9 points_from_t1_to_t0_chan_0[10][4] = buffer_t1_chan_0[10]; // t1[0](1, 2) @ unroll_index=10 points_from_t1_to_t0_chan_0[11][4] = buffer_t1_chan_0[11]; // t1[0](1, 2) @ unroll_index=11 points_from_t1_to_t0_chan_0[12][4] = buffer_t1_chan_0[12]; // t1[0](1, 2) @ unroll_index=12 points_from_t1_to_t0_chan_0[13][4] = buffer_t1_chan_0[13]; // t1[0](1, 2) @ unroll_index=13 points_from_t1_to_t0_chan_0[14][4] = buffer_t1_chan_0[14]; // t1[0](1, 2) @ unroll_index=14 points_from_t1_to_t0_chan_0[15][4] = buffer_t1_chan_0[15]; // t1[0](1, 2) @ unroll_index=15 points_from_t1_to_t0_chan_0[16][4] = buffer_t1_chan_0[16]; // t1[0](1, 2) @ unroll_index=16 points_from_t1_to_t0_chan_0[17][4] = buffer_t1_chan_0[17]; // t1[0](1, 2) @ unroll_index=17 points_from_t1_to_t0_chan_0[18][4] = buffer_t1_chan_0[18]; // t1[0](1, 2) @ unroll_index=18 points_from_t1_to_t0_chan_0[19][4] = buffer_t1_chan_0[19]; // t1[0](1, 2) @ unroll_index=19 points_from_t1_to_t0_chan_0[20][4] = buffer_t1_chan_0[20]; // t1[0](1, 2) @ unroll_index=20 points_from_t1_to_t0_chan_0[21][4] = buffer_t1_chan_0[21]; // t1[0](1, 2) @ unroll_index=21 points_from_t1_to_t0_chan_0[22][4] = buffer_t1_chan_0[22]; // t1[0](1, 2) @ unroll_index=22 points_from_t1_to_t0_chan_0[23][4] = buffer_t1_chan_0[23]; // t1[0](1, 2) @ unroll_index=23 points_from_t1_to_t0_chan_0[24][4] = buffer_t1_chan_0[24]; // t1[0](1, 2) @ unroll_index=24 points_from_t1_to_t0_chan_0[25][4] = buffer_t1_chan_0[25]; // t1[0](1, 2) @ unroll_index=25 points_from_t1_to_t0_chan_0[26][4] = buffer_t1_chan_0[26]; // t1[0](1, 2) @ unroll_index=26 points_from_t1_to_t0_chan_0[27][4] = buffer_t1_chan_0[27]; // t1[0](1, 2) @ unroll_index=27 points_from_t1_to_t0_chan_0[28][4] = buffer_t1_chan_0[28]; // t1[0](1, 2) @ unroll_index=28 points_from_t1_to_t0_chan_0[29][4] = buffer_t1_chan_0[29]; // t1[0](1, 2) @ unroll_index=29 points_from_t1_to_t0_chan_0[30][4] = buffer_t1_chan_0[30]; // t1[0](1, 2) @ unroll_index=30 points_from_t1_to_t0_chan_0[31][4] = buffer_t1_chan_0[31]; // t1[0](1, 2) @ unroll_index=31 points_from_t1_to_t0_chan_0[32][4] = buffer_t1_chan_0[32]; // t1[0](1, 2) @ unroll_index=32 points_from_t1_to_t0_chan_0[33][4] = buffer_t1_chan_0[33]; // t1[0](1, 2) @ unroll_index=33 points_from_t1_to_t0_chan_0[34][4] = buffer_t1_chan_0[34]; // t1[0](1, 2) @ unroll_index=34 points_from_t1_to_t0_chan_0[35][4] = buffer_t1_chan_0[35]; // t1[0](1, 2) @ unroll_index=35 points_from_t1_to_t0_chan_0[36][4] = buffer_t1_chan_0[36]; // t1[0](1, 2) @ unroll_index=36 points_from_t1_to_t0_chan_0[37][4] = buffer_t1_chan_0[37]; // t1[0](1, 2) @ unroll_index=37 points_from_t1_to_t0_chan_0[38][4] = buffer_t1_chan_0[38]; // t1[0](1, 2) @ unroll_index=38 points_from_t1_to_t0_chan_0[39][4] = buffer_t1_chan_0[39]; // t1[0](1, 2) @ unroll_index=39 points_from_t1_to_t0_chan_0[40][4] = buffer_t1_chan_0[40]; // t1[0](1, 2) @ unroll_index=40 points_from_t1_to_t0_chan_0[41][4] = buffer_t1_chan_0[41]; // t1[0](1, 2) @ unroll_index=41 points_from_t1_to_t0_chan_0[42][4] = buffer_t1_chan_0[42]; // t1[0](1, 2) @ unroll_index=42 points_from_t1_to_t0_chan_0[43][4] = buffer_t1_chan_0[43]; // t1[0](1, 2) @ unroll_index=43 points_from_t1_to_t0_chan_0[44][4] = buffer_t1_chan_0[44]; // t1[0](1, 2) @ unroll_index=44 points_from_t1_to_t0_chan_0[45][4] = buffer_t1_chan_0[45]; // t1[0](1, 2) @ unroll_index=45 points_from_t1_to_t0_chan_0[46][4] = buffer_t1_chan_0[46]; // t1[0](1, 2) @ unroll_index=46 points_from_t1_to_t0_chan_0[47][4] = buffer_t1_chan_0[47]; // t1[0](1, 2) @ unroll_index=47 points_from_t1_to_t0_chan_0[48][4] = buffer_t1_chan_0[48]; // t1[0](1, 2) @ unroll_index=48 points_from_t1_to_t0_chan_0[49][4] = buffer_t1_chan_0[49]; // t1[0](1, 2) @ unroll_index=49 points_from_t1_to_t0_chan_0[50][4] = buffer_t1_chan_0[50]; // t1[0](1, 2) @ unroll_index=50 points_from_t1_to_t0_chan_0[51][4] = buffer_t1_chan_0[51]; // t1[0](1, 2) @ unroll_index=51 points_from_t1_to_t0_chan_0[52][4] = buffer_t1_chan_0[52]; // t1[0](1, 2) @ unroll_index=52 points_from_t1_to_t0_chan_0[53][4] = buffer_t1_chan_0[53]; // t1[0](1, 2) @ unroll_index=53 points_from_t1_to_t0_chan_0[54][4] = buffer_t1_chan_0[54]; // t1[0](1, 2) @ unroll_index=54 points_from_t1_to_t0_chan_0[55][4] = buffer_t1_chan_0[55]; // t1[0](1, 2) @ unroll_index=55 points_from_t1_to_t0_chan_0[56][4] = buffer_t1_chan_0[56]; // t1[0](1, 2) @ unroll_index=56 points_from_t1_to_t0_chan_0[57][4] = buffer_t1_chan_0[57]; // t1[0](1, 2) @ unroll_index=57 points_from_t1_to_t0_chan_0[58][4] = buffer_t1_chan_0[58]; // t1[0](1, 2) @ unroll_index=58 points_from_t1_to_t0_chan_0[59][4] = buffer_t1_chan_0[59]; // t1[0](1, 2) @ unroll_index=59 points_from_t1_to_t0_chan_0[60][4] = buffer_t1_chan_0[60]; // t1[0](1, 2) @ unroll_index=60 points_from_t1_to_t0_chan_0[61][4] = buffer_t1_chan_0[61]; // t1[0](1, 2) @ unroll_index=61 points_from_t1_to_t0_chan_0[62][4] = buffer_t1_chan_0[62]; // t1[0](1, 2) @ unroll_index=62 points_from_t1_to_t0_chan_0[63][4] = buffer_t1_chan_0[63]; // t1[0](1, 2) @ unroll_index=63 points_from_t1_to_t0_chan_0[0][2] = FF_t1_chan_0[0]; // t1[0](1, 1) @ unroll_index=0 points_from_t1_to_t0_chan_0[1][1] = FF_t1_chan_0[0]; // t1[0](0, 1) @ unroll_index=1 points_from_t1_to_t0_chan_0[0][1] = FF_t1_chan_0[1]; // t1[0](0, 1) @ unroll_index=0 points_from_t1_to_t0_chan_0[62][3] = FIFO_125_t1_chan_0_fifo_0; // t1[0](2, 1) @ unroll_index=62 points_from_t1_to_t0_chan_0[63][2] = FIFO_125_t1_chan_0_fifo_0; // t1[0](1, 1) @ unroll_index=63 points_from_t1_to_t0_chan_0[61][3] = FIFO_125_t1_chan_0_fifo_1; // t1[0](2, 1) @ unroll_index=61 points_from_t1_to_t0_chan_0[62][2] = FIFO_125_t1_chan_0_fifo_1; // t1[0](1, 1) @ unroll_index=62 points_from_t1_to_t0_chan_0[63][1] = FIFO_125_t1_chan_0_fifo_1; // t1[0](0, 1) @ unroll_index=63 points_from_t1_to_t0_chan_0[60][3] = FIFO_125_t1_chan_0_fifo_2; // t1[0](2, 1) @ unroll_index=60 points_from_t1_to_t0_chan_0[61][2] = FIFO_125_t1_chan_0_fifo_2; // t1[0](1, 1) @ unroll_index=61 points_from_t1_to_t0_chan_0[62][1] = FIFO_125_t1_chan_0_fifo_2; // t1[0](0, 1) @ unroll_index=62 points_from_t1_to_t0_chan_0[59][3] = FIFO_125_t1_chan_0_fifo_3; // t1[0](2, 1) @ unroll_index=59 points_from_t1_to_t0_chan_0[60][2] = FIFO_125_t1_chan_0_fifo_3; // t1[0](1, 1) @ unroll_index=60 points_from_t1_to_t0_chan_0[61][1] = FIFO_125_t1_chan_0_fifo_3; // t1[0](0, 1) @ unroll_index=61 points_from_t1_to_t0_chan_0[58][3] = FIFO_125_t1_chan_0_fifo_4; // t1[0](2, 1) @ unroll_index=58 points_from_t1_to_t0_chan_0[59][2] = FIFO_125_t1_chan_0_fifo_4; // t1[0](1, 1) @ unroll_index=59 points_from_t1_to_t0_chan_0[60][1] = FIFO_125_t1_chan_0_fifo_4; // t1[0](0, 1) @ unroll_index=60 points_from_t1_to_t0_chan_0[57][3] = FIFO_125_t1_chan_0_fifo_5; // t1[0](2, 1) @ unroll_index=57 points_from_t1_to_t0_chan_0[58][2] = FIFO_125_t1_chan_0_fifo_5; // t1[0](1, 1) @ unroll_index=58 points_from_t1_to_t0_chan_0[59][1] = FIFO_125_t1_chan_0_fifo_5; // t1[0](0, 1) @ unroll_index=59 points_from_t1_to_t0_chan_0[56][3] = FIFO_125_t1_chan_0_fifo_6; // t1[0](2, 1) @ unroll_index=56 points_from_t1_to_t0_chan_0[57][2] = FIFO_125_t1_chan_0_fifo_6; // t1[0](1, 1) @ unroll_index=57 points_from_t1_to_t0_chan_0[58][1] = FIFO_125_t1_chan_0_fifo_6; // t1[0](0, 1) @ unroll_index=58 points_from_t1_to_t0_chan_0[56][2] = FIFO_125_t1_chan_0_fifo_7; // t1[0](1, 1) @ unroll_index=56 points_from_t1_to_t0_chan_0[57][1] = FIFO_125_t1_chan_0_fifo_7; // t1[0](0, 1) @ unroll_index=57 points_from_t1_to_t0_chan_0[55][3] = FIFO_125_t1_chan_0_fifo_7; // t1[0](2, 1) @ unroll_index=55 points_from_t1_to_t0_chan_0[56][1] = FIFO_125_t1_chan_0_fifo_8; // t1[0](0, 1) @ unroll_index=56 points_from_t1_to_t0_chan_0[54][3] = FIFO_125_t1_chan_0_fifo_8; // t1[0](2, 1) @ unroll_index=54 points_from_t1_to_t0_chan_0[55][2] = FIFO_125_t1_chan_0_fifo_8; // t1[0](1, 1) @ unroll_index=55 points_from_t1_to_t0_chan_0[53][3] = FIFO_125_t1_chan_0_fifo_9; // t1[0](2, 1) @ unroll_index=53 points_from_t1_to_t0_chan_0[54][2] = FIFO_125_t1_chan_0_fifo_9; // t1[0](1, 1) @ unroll_index=54 points_from_t1_to_t0_chan_0[55][1] = FIFO_125_t1_chan_0_fifo_9; // t1[0](0, 1) @ unroll_index=55 points_from_t1_to_t0_chan_0[52][3] = FIFO_125_t1_chan_0_fifo_10; // t1[0](2, 1) @ unroll_index=52 points_from_t1_to_t0_chan_0[53][2] = FIFO_125_t1_chan_0_fifo_10; // t1[0](1, 1) @ unroll_index=53 points_from_t1_to_t0_chan_0[54][1] = FIFO_125_t1_chan_0_fifo_10; // t1[0](0, 1) @ unroll_index=54 points_from_t1_to_t0_chan_0[51][3] = FIFO_125_t1_chan_0_fifo_11; // t1[0](2, 1) @ unroll_index=51 points_from_t1_to_t0_chan_0[52][2] = FIFO_125_t1_chan_0_fifo_11; // t1[0](1, 1) @ unroll_index=52 points_from_t1_to_t0_chan_0[53][1] = FIFO_125_t1_chan_0_fifo_11; // t1[0](0, 1) @ unroll_index=53 points_from_t1_to_t0_chan_0[50][3] = FIFO_125_t1_chan_0_fifo_12; // t1[0](2, 1) @ unroll_index=50 points_from_t1_to_t0_chan_0[51][2] = FIFO_125_t1_chan_0_fifo_12; // t1[0](1, 1) @ unroll_index=51 points_from_t1_to_t0_chan_0[52][1] = FIFO_125_t1_chan_0_fifo_12; // t1[0](0, 1) @ unroll_index=52 points_from_t1_to_t0_chan_0[49][3] = FIFO_125_t1_chan_0_fifo_13; // t1[0](2, 1) @ unroll_index=49 points_from_t1_to_t0_chan_0[50][2] = FIFO_125_t1_chan_0_fifo_13; // t1[0](1, 1) @ unroll_index=50 points_from_t1_to_t0_chan_0[51][1] = FIFO_125_t1_chan_0_fifo_13; // t1[0](0, 1) @ unroll_index=51 points_from_t1_to_t0_chan_0[48][3] = FIFO_125_t1_chan_0_fifo_14; // t1[0](2, 1) @ unroll_index=48 points_from_t1_to_t0_chan_0[49][2] = FIFO_125_t1_chan_0_fifo_14; // t1[0](1, 1) @ unroll_index=49 points_from_t1_to_t0_chan_0[50][1] = FIFO_125_t1_chan_0_fifo_14; // t1[0](0, 1) @ unroll_index=50 points_from_t1_to_t0_chan_0[48][2] = FIFO_125_t1_chan_0_fifo_15; // t1[0](1, 1) @ unroll_index=48 points_from_t1_to_t0_chan_0[49][1] = FIFO_125_t1_chan_0_fifo_15; // t1[0](0, 1) @ unroll_index=49 points_from_t1_to_t0_chan_0[47][3] = FIFO_125_t1_chan_0_fifo_15; // t1[0](2, 1) @ unroll_index=47 points_from_t1_to_t0_chan_0[48][1] = FIFO_125_t1_chan_0_fifo_16; // t1[0](0, 1) @ unroll_index=48 points_from_t1_to_t0_chan_0[46][3] = FIFO_125_t1_chan_0_fifo_16; // t1[0](2, 1) @ unroll_index=46 points_from_t1_to_t0_chan_0[47][2] = FIFO_125_t1_chan_0_fifo_16; // t1[0](1, 1) @ unroll_index=47 points_from_t1_to_t0_chan_0[45][3] = FIFO_125_t1_chan_0_fifo_17; // t1[0](2, 1) @ unroll_index=45 points_from_t1_to_t0_chan_0[46][2] = FIFO_125_t1_chan_0_fifo_17; // t1[0](1, 1) @ unroll_index=46 points_from_t1_to_t0_chan_0[47][1] = FIFO_125_t1_chan_0_fifo_17; // t1[0](0, 1) @ unroll_index=47 points_from_t1_to_t0_chan_0[44][3] = FIFO_125_t1_chan_0_fifo_18; // t1[0](2, 1) @ unroll_index=44 points_from_t1_to_t0_chan_0[45][2] = FIFO_125_t1_chan_0_fifo_18; // t1[0](1, 1) @ unroll_index=45 points_from_t1_to_t0_chan_0[46][1] = FIFO_125_t1_chan_0_fifo_18; // t1[0](0, 1) @ unroll_index=46 points_from_t1_to_t0_chan_0[43][3] = FIFO_125_t1_chan_0_fifo_19; // t1[0](2, 1) @ unroll_index=43 points_from_t1_to_t0_chan_0[44][2] = FIFO_125_t1_chan_0_fifo_19; // t1[0](1, 1) @ unroll_index=44 points_from_t1_to_t0_chan_0[45][1] = FIFO_125_t1_chan_0_fifo_19; // t1[0](0, 1) @ unroll_index=45 points_from_t1_to_t0_chan_0[42][3] = FIFO_125_t1_chan_0_fifo_20; // t1[0](2, 1) @ unroll_index=42 points_from_t1_to_t0_chan_0[43][2] = FIFO_125_t1_chan_0_fifo_20; // t1[0](1, 1) @ unroll_index=43 points_from_t1_to_t0_chan_0[44][1] = FIFO_125_t1_chan_0_fifo_20; // t1[0](0, 1) @ unroll_index=44 points_from_t1_to_t0_chan_0[41][3] = FIFO_125_t1_chan_0_fifo_21; // t1[0](2, 1) @ unroll_index=41 points_from_t1_to_t0_chan_0[42][2] = FIFO_125_t1_chan_0_fifo_21; // t1[0](1, 1) @ unroll_index=42 points_from_t1_to_t0_chan_0[43][1] = FIFO_125_t1_chan_0_fifo_21; // t1[0](0, 1) @ unroll_index=43 points_from_t1_to_t0_chan_0[40][3] = FIFO_125_t1_chan_0_fifo_22; // t1[0](2, 1) @ unroll_index=40 points_from_t1_to_t0_chan_0[41][2] = FIFO_125_t1_chan_0_fifo_22; // t1[0](1, 1) @ unroll_index=41 points_from_t1_to_t0_chan_0[42][1] = FIFO_125_t1_chan_0_fifo_22; // t1[0](0, 1) @ unroll_index=42 points_from_t1_to_t0_chan_0[40][2] = FIFO_125_t1_chan_0_fifo_23; // t1[0](1, 1) @ unroll_index=40 points_from_t1_to_t0_chan_0[41][1] = FIFO_125_t1_chan_0_fifo_23; // t1[0](0, 1) @ unroll_index=41 points_from_t1_to_t0_chan_0[39][3] = FIFO_125_t1_chan_0_fifo_23; // t1[0](2, 1) @ unroll_index=39 points_from_t1_to_t0_chan_0[40][1] = FIFO_125_t1_chan_0_fifo_24; // t1[0](0, 1) @ unroll_index=40 points_from_t1_to_t0_chan_0[38][3] = FIFO_125_t1_chan_0_fifo_24; // t1[0](2, 1) @ unroll_index=38 points_from_t1_to_t0_chan_0[39][2] = FIFO_125_t1_chan_0_fifo_24; // t1[0](1, 1) @ unroll_index=39 points_from_t1_to_t0_chan_0[37][3] = FIFO_125_t1_chan_0_fifo_25; // t1[0](2, 1) @ unroll_index=37 points_from_t1_to_t0_chan_0[38][2] = FIFO_125_t1_chan_0_fifo_25; // t1[0](1, 1) @ unroll_index=38 points_from_t1_to_t0_chan_0[39][1] = FIFO_125_t1_chan_0_fifo_25; // t1[0](0, 1) @ unroll_index=39 points_from_t1_to_t0_chan_0[36][3] = FIFO_125_t1_chan_0_fifo_26; // t1[0](2, 1) @ unroll_index=36 points_from_t1_to_t0_chan_0[37][2] = FIFO_125_t1_chan_0_fifo_26; // t1[0](1, 1) @ unroll_index=37 points_from_t1_to_t0_chan_0[38][1] = FIFO_125_t1_chan_0_fifo_26; // t1[0](0, 1) @ unroll_index=38 points_from_t1_to_t0_chan_0[35][3] = FIFO_125_t1_chan_0_fifo_27; // t1[0](2, 1) @ unroll_index=35 points_from_t1_to_t0_chan_0[36][2] = FIFO_125_t1_chan_0_fifo_27; // t1[0](1, 1) @ unroll_index=36 points_from_t1_to_t0_chan_0[37][1] = FIFO_125_t1_chan_0_fifo_27; // t1[0](0, 1) @ unroll_index=37 points_from_t1_to_t0_chan_0[34][3] = FIFO_125_t1_chan_0_fifo_28; // t1[0](2, 1) @ unroll_index=34 points_from_t1_to_t0_chan_0[35][2] = FIFO_125_t1_chan_0_fifo_28; // t1[0](1, 1) @ unroll_index=35 points_from_t1_to_t0_chan_0[36][1] = FIFO_125_t1_chan_0_fifo_28; // t1[0](0, 1) @ unroll_index=36 points_from_t1_to_t0_chan_0[33][3] = FIFO_125_t1_chan_0_fifo_29; // t1[0](2, 1) @ unroll_index=33 points_from_t1_to_t0_chan_0[34][2] = FIFO_125_t1_chan_0_fifo_29; // t1[0](1, 1) @ unroll_index=34 points_from_t1_to_t0_chan_0[35][1] = FIFO_125_t1_chan_0_fifo_29; // t1[0](0, 1) @ unroll_index=35 points_from_t1_to_t0_chan_0[32][3] = FIFO_125_t1_chan_0_fifo_30; // t1[0](2, 1) @ unroll_index=32 points_from_t1_to_t0_chan_0[33][2] = FIFO_125_t1_chan_0_fifo_30; // t1[0](1, 1) @ unroll_index=33 points_from_t1_to_t0_chan_0[34][1] = FIFO_125_t1_chan_0_fifo_30; // t1[0](0, 1) @ unroll_index=34 points_from_t1_to_t0_chan_0[32][2] = FIFO_125_t1_chan_0_fifo_31; // t1[0](1, 1) @ unroll_index=32 points_from_t1_to_t0_chan_0[33][1] = FIFO_125_t1_chan_0_fifo_31; // t1[0](0, 1) @ unroll_index=33 points_from_t1_to_t0_chan_0[31][3] = FIFO_125_t1_chan_0_fifo_31; // t1[0](2, 1) @ unroll_index=31 points_from_t1_to_t0_chan_0[32][1] = FIFO_125_t1_chan_0_fifo_32; // t1[0](0, 1) @ unroll_index=32 points_from_t1_to_t0_chan_0[30][3] = FIFO_125_t1_chan_0_fifo_32; // t1[0](2, 1) @ unroll_index=30 points_from_t1_to_t0_chan_0[31][2] = FIFO_125_t1_chan_0_fifo_32; // t1[0](1, 1) @ unroll_index=31 points_from_t1_to_t0_chan_0[29][3] = FIFO_125_t1_chan_0_fifo_33; // t1[0](2, 1) @ unroll_index=29 points_from_t1_to_t0_chan_0[30][2] = FIFO_125_t1_chan_0_fifo_33; // t1[0](1, 1) @ unroll_index=30 points_from_t1_to_t0_chan_0[31][1] = FIFO_125_t1_chan_0_fifo_33; // t1[0](0, 1) @ unroll_index=31 points_from_t1_to_t0_chan_0[28][3] = FIFO_125_t1_chan_0_fifo_34; // t1[0](2, 1) @ unroll_index=28 points_from_t1_to_t0_chan_0[29][2] = FIFO_125_t1_chan_0_fifo_34; // t1[0](1, 1) @ unroll_index=29 points_from_t1_to_t0_chan_0[30][1] = FIFO_125_t1_chan_0_fifo_34; // t1[0](0, 1) @ unroll_index=30 points_from_t1_to_t0_chan_0[27][3] = FIFO_125_t1_chan_0_fifo_35; // t1[0](2, 1) @ unroll_index=27 points_from_t1_to_t0_chan_0[28][2] = FIFO_125_t1_chan_0_fifo_35; // t1[0](1, 1) @ unroll_index=28 points_from_t1_to_t0_chan_0[29][1] = FIFO_125_t1_chan_0_fifo_35; // t1[0](0, 1) @ unroll_index=29 points_from_t1_to_t0_chan_0[26][3] = FIFO_125_t1_chan_0_fifo_36; // t1[0](2, 1) @ unroll_index=26 points_from_t1_to_t0_chan_0[27][2] = FIFO_125_t1_chan_0_fifo_36; // t1[0](1, 1) @ unroll_index=27 points_from_t1_to_t0_chan_0[28][1] = FIFO_125_t1_chan_0_fifo_36; // t1[0](0, 1) @ unroll_index=28 points_from_t1_to_t0_chan_0[25][3] = FIFO_125_t1_chan_0_fifo_37; // t1[0](2, 1) @ unroll_index=25 points_from_t1_to_t0_chan_0[26][2] = FIFO_125_t1_chan_0_fifo_37; // t1[0](1, 1) @ unroll_index=26 points_from_t1_to_t0_chan_0[27][1] = FIFO_125_t1_chan_0_fifo_37; // t1[0](0, 1) @ unroll_index=27 points_from_t1_to_t0_chan_0[24][3] = FIFO_125_t1_chan_0_fifo_38; // t1[0](2, 1) @ unroll_index=24 points_from_t1_to_t0_chan_0[25][2] = FIFO_125_t1_chan_0_fifo_38; // t1[0](1, 1) @ unroll_index=25 points_from_t1_to_t0_chan_0[26][1] = FIFO_125_t1_chan_0_fifo_38; // t1[0](0, 1) @ unroll_index=26 points_from_t1_to_t0_chan_0[24][2] = FIFO_125_t1_chan_0_fifo_39; // t1[0](1, 1) @ unroll_index=24 points_from_t1_to_t0_chan_0[25][1] = FIFO_125_t1_chan_0_fifo_39; // t1[0](0, 1) @ unroll_index=25 points_from_t1_to_t0_chan_0[23][3] = FIFO_125_t1_chan_0_fifo_39; // t1[0](2, 1) @ unroll_index=23 points_from_t1_to_t0_chan_0[24][1] = FIFO_125_t1_chan_0_fifo_40; // t1[0](0, 1) @ unroll_index=24 points_from_t1_to_t0_chan_0[22][3] = FIFO_125_t1_chan_0_fifo_40; // t1[0](2, 1) @ unroll_index=22 points_from_t1_to_t0_chan_0[23][2] = FIFO_125_t1_chan_0_fifo_40; // t1[0](1, 1) @ unroll_index=23 points_from_t1_to_t0_chan_0[21][3] = FIFO_125_t1_chan_0_fifo_41; // t1[0](2, 1) @ unroll_index=21 points_from_t1_to_t0_chan_0[22][2] = FIFO_125_t1_chan_0_fifo_41; // t1[0](1, 1) @ unroll_index=22 points_from_t1_to_t0_chan_0[23][1] = FIFO_125_t1_chan_0_fifo_41; // t1[0](0, 1) @ unroll_index=23 points_from_t1_to_t0_chan_0[20][3] = FIFO_125_t1_chan_0_fifo_42; // t1[0](2, 1) @ unroll_index=20 points_from_t1_to_t0_chan_0[21][2] = FIFO_125_t1_chan_0_fifo_42; // t1[0](1, 1) @ unroll_index=21 points_from_t1_to_t0_chan_0[22][1] = FIFO_125_t1_chan_0_fifo_42; // t1[0](0, 1) @ unroll_index=22 points_from_t1_to_t0_chan_0[19][3] = FIFO_125_t1_chan_0_fifo_43; // t1[0](2, 1) @ unroll_index=19 points_from_t1_to_t0_chan_0[20][2] = FIFO_125_t1_chan_0_fifo_43; // t1[0](1, 1) @ unroll_index=20 points_from_t1_to_t0_chan_0[21][1] = FIFO_125_t1_chan_0_fifo_43; // t1[0](0, 1) @ unroll_index=21 points_from_t1_to_t0_chan_0[18][3] = FIFO_125_t1_chan_0_fifo_44; // t1[0](2, 1) @ unroll_index=18 points_from_t1_to_t0_chan_0[19][2] = FIFO_125_t1_chan_0_fifo_44; // t1[0](1, 1) @ unroll_index=19 points_from_t1_to_t0_chan_0[20][1] = FIFO_125_t1_chan_0_fifo_44; // t1[0](0, 1) @ unroll_index=20 points_from_t1_to_t0_chan_0[17][3] = FIFO_125_t1_chan_0_fifo_45; // t1[0](2, 1) @ unroll_index=17 points_from_t1_to_t0_chan_0[18][2] = FIFO_125_t1_chan_0_fifo_45; // t1[0](1, 1) @ unroll_index=18 points_from_t1_to_t0_chan_0[19][1] = FIFO_125_t1_chan_0_fifo_45; // t1[0](0, 1) @ unroll_index=19 points_from_t1_to_t0_chan_0[16][3] = FIFO_125_t1_chan_0_fifo_46; // t1[0](2, 1) @ unroll_index=16 points_from_t1_to_t0_chan_0[17][2] = FIFO_125_t1_chan_0_fifo_46; // t1[0](1, 1) @ unroll_index=17 points_from_t1_to_t0_chan_0[18][1] = FIFO_125_t1_chan_0_fifo_46; // t1[0](0, 1) @ unroll_index=18 points_from_t1_to_t0_chan_0[16][2] = FIFO_125_t1_chan_0_fifo_47; // t1[0](1, 1) @ unroll_index=16 points_from_t1_to_t0_chan_0[17][1] = FIFO_125_t1_chan_0_fifo_47; // t1[0](0, 1) @ unroll_index=17 points_from_t1_to_t0_chan_0[15][3] = FIFO_125_t1_chan_0_fifo_47; // t1[0](2, 1) @ unroll_index=15 points_from_t1_to_t0_chan_0[16][1] = FIFO_125_t1_chan_0_fifo_48; // t1[0](0, 1) @ unroll_index=16 points_from_t1_to_t0_chan_0[14][3] = FIFO_125_t1_chan_0_fifo_48; // t1[0](2, 1) @ unroll_index=14 points_from_t1_to_t0_chan_0[15][2] = FIFO_125_t1_chan_0_fifo_48; // t1[0](1, 1) @ unroll_index=15 points_from_t1_to_t0_chan_0[13][3] = FIFO_125_t1_chan_0_fifo_49; // t1[0](2, 1) @ unroll_index=13 points_from_t1_to_t0_chan_0[14][2] = FIFO_125_t1_chan_0_fifo_49; // t1[0](1, 1) @ unroll_index=14 points_from_t1_to_t0_chan_0[15][1] = FIFO_125_t1_chan_0_fifo_49; // t1[0](0, 1) @ unroll_index=15 points_from_t1_to_t0_chan_0[12][3] = FIFO_125_t1_chan_0_fifo_50; // t1[0](2, 1) @ unroll_index=12 points_from_t1_to_t0_chan_0[13][2] = FIFO_125_t1_chan_0_fifo_50; // t1[0](1, 1) @ unroll_index=13 points_from_t1_to_t0_chan_0[14][1] = FIFO_125_t1_chan_0_fifo_50; // t1[0](0, 1) @ unroll_index=14 points_from_t1_to_t0_chan_0[11][3] = FIFO_125_t1_chan_0_fifo_51; // t1[0](2, 1) @ unroll_index=11 points_from_t1_to_t0_chan_0[12][2] = FIFO_125_t1_chan_0_fifo_51; // t1[0](1, 1) @ unroll_index=12 points_from_t1_to_t0_chan_0[13][1] = FIFO_125_t1_chan_0_fifo_51; // t1[0](0, 1) @ unroll_index=13 points_from_t1_to_t0_chan_0[10][3] = FIFO_125_t1_chan_0_fifo_52; // t1[0](2, 1) @ unroll_index=10 points_from_t1_to_t0_chan_0[11][2] = FIFO_125_t1_chan_0_fifo_52; // t1[0](1, 1) @ unroll_index=11 points_from_t1_to_t0_chan_0[12][1] = FIFO_125_t1_chan_0_fifo_52; // t1[0](0, 1) @ unroll_index=12 points_from_t1_to_t0_chan_0[9][3] = FIFO_125_t1_chan_0_fifo_53; // t1[0](2, 1) @ unroll_index=9 points_from_t1_to_t0_chan_0[10][2] = FIFO_125_t1_chan_0_fifo_53; // t1[0](1, 1) @ unroll_index=10 points_from_t1_to_t0_chan_0[11][1] = FIFO_125_t1_chan_0_fifo_53; // t1[0](0, 1) @ unroll_index=11 points_from_t1_to_t0_chan_0[8][3] = FIFO_125_t1_chan_0_fifo_54; // t1[0](2, 1) @ unroll_index=8 points_from_t1_to_t0_chan_0[9][2] = FIFO_125_t1_chan_0_fifo_54; // t1[0](1, 1) @ unroll_index=9 points_from_t1_to_t0_chan_0[10][1] = FIFO_125_t1_chan_0_fifo_54; // t1[0](0, 1) @ unroll_index=10 points_from_t1_to_t0_chan_0[8][2] = FIFO_125_t1_chan_0_fifo_55; // t1[0](1, 1) @ unroll_index=8 points_from_t1_to_t0_chan_0[9][1] = FIFO_125_t1_chan_0_fifo_55; // t1[0](0, 1) @ unroll_index=9 points_from_t1_to_t0_chan_0[7][3] = FIFO_125_t1_chan_0_fifo_55; // t1[0](2, 1) @ unroll_index=7 points_from_t1_to_t0_chan_0[8][1] = FIFO_125_t1_chan_0_fifo_56; // t1[0](0, 1) @ unroll_index=8 points_from_t1_to_t0_chan_0[6][3] = FIFO_125_t1_chan_0_fifo_56; // t1[0](2, 1) @ unroll_index=6 points_from_t1_to_t0_chan_0[7][2] = FIFO_125_t1_chan_0_fifo_56; // t1[0](1, 1) @ unroll_index=7 points_from_t1_to_t0_chan_0[5][3] = FIFO_125_t1_chan_0_fifo_57; // t1[0](2, 1) @ unroll_index=5 points_from_t1_to_t0_chan_0[6][2] = FIFO_125_t1_chan_0_fifo_57; // t1[0](1, 1) @ unroll_index=6 points_from_t1_to_t0_chan_0[7][1] = FIFO_125_t1_chan_0_fifo_57; // t1[0](0, 1) @ unroll_index=7 points_from_t1_to_t0_chan_0[4][3] = FIFO_125_t1_chan_0_fifo_58; // t1[0](2, 1) @ unroll_index=4 points_from_t1_to_t0_chan_0[5][2] = FIFO_125_t1_chan_0_fifo_58; // t1[0](1, 1) @ unroll_index=5 points_from_t1_to_t0_chan_0[6][1] = FIFO_125_t1_chan_0_fifo_58; // t1[0](0, 1) @ unroll_index=6 points_from_t1_to_t0_chan_0[3][3] = FIFO_125_t1_chan_0_fifo_59; // t1[0](2, 1) @ unroll_index=3 points_from_t1_to_t0_chan_0[4][2] = FIFO_125_t1_chan_0_fifo_59; // t1[0](1, 1) @ unroll_index=4 points_from_t1_to_t0_chan_0[5][1] = FIFO_125_t1_chan_0_fifo_59; // t1[0](0, 1) @ unroll_index=5 points_from_t1_to_t0_chan_0[2][3] = FIFO_125_t1_chan_0_fifo_60; // t1[0](2, 1) @ unroll_index=2 points_from_t1_to_t0_chan_0[3][2] = FIFO_125_t1_chan_0_fifo_60; // t1[0](1, 1) @ unroll_index=3 points_from_t1_to_t0_chan_0[4][1] = FIFO_125_t1_chan_0_fifo_60; // t1[0](0, 1) @ unroll_index=4 points_from_t1_to_t0_chan_0[1][3] = FIFO_125_t1_chan_0_fifo_61; // t1[0](2, 1) @ unroll_index=1 points_from_t1_to_t0_chan_0[2][2] = FIFO_125_t1_chan_0_fifo_61; // t1[0](1, 1) @ unroll_index=2 points_from_t1_to_t0_chan_0[3][1] = FIFO_125_t1_chan_0_fifo_61; // t1[0](0, 1) @ unroll_index=3 points_from_t1_to_t0_chan_0[0][3] = FIFO_125_t1_chan_0_fifo_62; // t1[0](2, 1) @ unroll_index=0 points_from_t1_to_t0_chan_0[1][2] = FIFO_125_t1_chan_0_fifo_62; // t1[0](1, 1) @ unroll_index=1 points_from_t1_to_t0_chan_0[2][1] = FIFO_125_t1_chan_0_fifo_62; // t1[0](0, 1) @ unroll_index=2 points_from_t1_to_t0_chan_0[62][0] = FIFO_125_t1_chan_0_fifo_63; // t1[0](1, 0) @ unroll_index=62 points_from_t1_to_t0_chan_0[61][0] = FIFO_125_t1_chan_0_fifo_64; // t1[0](1, 0) @ unroll_index=61 points_from_t1_to_t0_chan_0[60][0] = FIFO_125_t1_chan_0_fifo_65; // t1[0](1, 0) @ unroll_index=60 points_from_t1_to_t0_chan_0[59][0] = FIFO_125_t1_chan_0_fifo_66; // t1[0](1, 0) @ unroll_index=59 points_from_t1_to_t0_chan_0[58][0] = FIFO_125_t1_chan_0_fifo_67; // t1[0](1, 0) @ unroll_index=58 points_from_t1_to_t0_chan_0[57][0] = FIFO_125_t1_chan_0_fifo_68; // t1[0](1, 0) @ unroll_index=57 points_from_t1_to_t0_chan_0[56][0] = FIFO_125_t1_chan_0_fifo_69; // t1[0](1, 0) @ unroll_index=56 points_from_t1_to_t0_chan_0[55][0] = FIFO_125_t1_chan_0_fifo_70; // t1[0](1, 0) @ unroll_index=55 points_from_t1_to_t0_chan_0[54][0] = FIFO_125_t1_chan_0_fifo_71; // t1[0](1, 0) @ unroll_index=54 points_from_t1_to_t0_chan_0[53][0] = FIFO_125_t1_chan_0_fifo_72; // t1[0](1, 0) @ unroll_index=53 points_from_t1_to_t0_chan_0[52][0] = FIFO_125_t1_chan_0_fifo_73; // t1[0](1, 0) @ unroll_index=52 points_from_t1_to_t0_chan_0[51][0] = FIFO_125_t1_chan_0_fifo_74; // t1[0](1, 0) @ unroll_index=51 points_from_t1_to_t0_chan_0[50][0] = FIFO_125_t1_chan_0_fifo_75; // t1[0](1, 0) @ unroll_index=50 points_from_t1_to_t0_chan_0[49][0] = FIFO_125_t1_chan_0_fifo_76; // t1[0](1, 0) @ unroll_index=49 points_from_t1_to_t0_chan_0[48][0] = FIFO_125_t1_chan_0_fifo_77; // t1[0](1, 0) @ unroll_index=48 points_from_t1_to_t0_chan_0[47][0] = FIFO_125_t1_chan_0_fifo_78; // t1[0](1, 0) @ unroll_index=47 points_from_t1_to_t0_chan_0[46][0] = FIFO_125_t1_chan_0_fifo_79; // t1[0](1, 0) @ unroll_index=46 points_from_t1_to_t0_chan_0[45][0] = FIFO_125_t1_chan_0_fifo_80; // t1[0](1, 0) @ unroll_index=45 points_from_t1_to_t0_chan_0[44][0] = FIFO_125_t1_chan_0_fifo_81; // t1[0](1, 0) @ unroll_index=44 points_from_t1_to_t0_chan_0[43][0] = FIFO_125_t1_chan_0_fifo_82; // t1[0](1, 0) @ unroll_index=43 points_from_t1_to_t0_chan_0[42][0] = FIFO_125_t1_chan_0_fifo_83; // t1[0](1, 0) @ unroll_index=42 points_from_t1_to_t0_chan_0[41][0] = FIFO_125_t1_chan_0_fifo_84; // t1[0](1, 0) @ unroll_index=41 points_from_t1_to_t0_chan_0[40][0] = FIFO_125_t1_chan_0_fifo_85; // t1[0](1, 0) @ unroll_index=40 points_from_t1_to_t0_chan_0[39][0] = FIFO_125_t1_chan_0_fifo_86; // t1[0](1, 0) @ unroll_index=39 points_from_t1_to_t0_chan_0[38][0] = FIFO_125_t1_chan_0_fifo_87; // t1[0](1, 0) @ unroll_index=38 points_from_t1_to_t0_chan_0[37][0] = FIFO_125_t1_chan_0_fifo_88; // t1[0](1, 0) @ unroll_index=37 points_from_t1_to_t0_chan_0[36][0] = FIFO_125_t1_chan_0_fifo_89; // t1[0](1, 0) @ unroll_index=36 points_from_t1_to_t0_chan_0[35][0] = FIFO_125_t1_chan_0_fifo_90; // t1[0](1, 0) @ unroll_index=35 points_from_t1_to_t0_chan_0[34][0] = FIFO_125_t1_chan_0_fifo_91; // t1[0](1, 0) @ unroll_index=34 points_from_t1_to_t0_chan_0[33][0] = FIFO_125_t1_chan_0_fifo_92; // t1[0](1, 0) @ unroll_index=33 points_from_t1_to_t0_chan_0[32][0] = FIFO_125_t1_chan_0_fifo_93; // t1[0](1, 0) @ unroll_index=32 points_from_t1_to_t0_chan_0[31][0] = FIFO_125_t1_chan_0_fifo_94; // t1[0](1, 0) @ unroll_index=31 points_from_t1_to_t0_chan_0[30][0] = FIFO_125_t1_chan_0_fifo_95; // t1[0](1, 0) @ unroll_index=30 points_from_t1_to_t0_chan_0[29][0] = FIFO_125_t1_chan_0_fifo_96; // t1[0](1, 0) @ unroll_index=29 points_from_t1_to_t0_chan_0[28][0] = FIFO_125_t1_chan_0_fifo_97; // t1[0](1, 0) @ unroll_index=28 points_from_t1_to_t0_chan_0[27][0] = FIFO_125_t1_chan_0_fifo_98; // t1[0](1, 0) @ unroll_index=27 points_from_t1_to_t0_chan_0[26][0] = FIFO_125_t1_chan_0_fifo_99; // t1[0](1, 0) @ unroll_index=26 points_from_t1_to_t0_chan_0[25][0] = FIFO_125_t1_chan_0_fifo_100; // t1[0](1, 0) @ unroll_index=25 points_from_t1_to_t0_chan_0[24][0] = FIFO_125_t1_chan_0_fifo_101; // t1[0](1, 0) @ unroll_index=24 points_from_t1_to_t0_chan_0[23][0] = FIFO_125_t1_chan_0_fifo_102; // t1[0](1, 0) @ unroll_index=23 points_from_t1_to_t0_chan_0[22][0] = FIFO_125_t1_chan_0_fifo_103; // t1[0](1, 0) @ unroll_index=22 points_from_t1_to_t0_chan_0[21][0] = FIFO_125_t1_chan_0_fifo_104; // t1[0](1, 0) @ unroll_index=21 points_from_t1_to_t0_chan_0[20][0] = FIFO_125_t1_chan_0_fifo_105; // t1[0](1, 0) @ unroll_index=20 points_from_t1_to_t0_chan_0[19][0] = FIFO_125_t1_chan_0_fifo_106; // t1[0](1, 0) @ unroll_index=19 points_from_t1_to_t0_chan_0[18][0] = FIFO_125_t1_chan_0_fifo_107; // t1[0](1, 0) @ unroll_index=18 points_from_t1_to_t0_chan_0[17][0] = FIFO_125_t1_chan_0_fifo_108; // t1[0](1, 0) @ unroll_index=17 points_from_t1_to_t0_chan_0[16][0] = FIFO_125_t1_chan_0_fifo_109; // t1[0](1, 0) @ unroll_index=16 points_from_t1_to_t0_chan_0[15][0] = FIFO_125_t1_chan_0_fifo_110; // t1[0](1, 0) @ unroll_index=15 points_from_t1_to_t0_chan_0[14][0] = FIFO_125_t1_chan_0_fifo_111; // t1[0](1, 0) @ unroll_index=14 points_from_t1_to_t0_chan_0[13][0] = FIFO_125_t1_chan_0_fifo_112; // t1[0](1, 0) @ unroll_index=13 points_from_t1_to_t0_chan_0[12][0] = FIFO_125_t1_chan_0_fifo_113; // t1[0](1, 0) @ unroll_index=12 points_from_t1_to_t0_chan_0[11][0] = FIFO_125_t1_chan_0_fifo_114; // t1[0](1, 0) @ unroll_index=11 points_from_t1_to_t0_chan_0[10][0] = FIFO_125_t1_chan_0_fifo_115; // t1[0](1, 0) @ unroll_index=10 points_from_t1_to_t0_chan_0[9][0] = FIFO_125_t1_chan_0_fifo_116; // t1[0](1, 0) @ unroll_index=9 points_from_t1_to_t0_chan_0[8][0] = FIFO_125_t1_chan_0_fifo_117; // t1[0](1, 0) @ unroll_index=8 points_from_t1_to_t0_chan_0[7][0] = FIFO_125_t1_chan_0_fifo_118; // t1[0](1, 0) @ unroll_index=7 points_from_t1_to_t0_chan_0[6][0] = FIFO_125_t1_chan_0_fifo_119; // t1[0](1, 0) @ unroll_index=6 points_from_t1_to_t0_chan_0[5][0] = FIFO_125_t1_chan_0_fifo_120; // t1[0](1, 0) @ unroll_index=5 points_from_t1_to_t0_chan_0[4][0] = FIFO_125_t1_chan_0_fifo_121; // t1[0](1, 0) @ unroll_index=4 points_from_t1_to_t0_chan_0[3][0] = FIFO_125_t1_chan_0_fifo_122; // t1[0](1, 0) @ unroll_index=3 points_from_t1_to_t0_chan_0[2][0] = FIFO_125_t1_chan_0_fifo_123; // t1[0](1, 0) @ unroll_index=2 points_from_t1_to_t0_chan_0[1][0] = FIFO_125_t1_chan_0_fifo_124; // t1[0](1, 0) @ unroll_index=1 points_from_t1_to_t0_chan_0[0][0] = FIFO_125_t1_chan_0_fifo_125; // t1[0](1, 0) @ unroll_index=0 points_from_t1_to_t0_chan_0[63][3] = FIFO_124_t1_chan_0_fifo_0; // t1[0](2, 1) @ unroll_index=63 points_from_t1_to_t0_chan_0[63][0] = FIFO_124_t1_chan_0_fifo_1; // t1[0](1, 0) @ unroll_index=63 compute_t0_unrolled: for(int32_t unroll_index = 0; unroll_index < UNROLL_FACTOR; ++unroll_index) { #pragma HLS unroll #pragma HLS latency min=1 float& load_t1_for_t0_chan_0_at_1_0 = points_from_t1_to_t0_chan_0[unroll_index][0]; float& load_t1_for_t0_chan_0_at_0_1 = points_from_t1_to_t0_chan_0[unroll_index][1]; float& load_t1_for_t0_chan_0_at_1_1 = points_from_t1_to_t0_chan_0[unroll_index][2]; float& load_t1_for_t0_chan_0_at_2_1 = points_from_t1_to_t0_chan_0[unroll_index][3]; float& load_t1_for_t0_chan_0_at_1_2 = points_from_t1_to_t0_chan_0[unroll_index][4]; float result_chan_0; float assign_0 = load_t1_for_t0_chan_0_at_1_2; float assign_1 = load_t1_for_t0_chan_0_at_2_1; float assign_2[1]; #pragma HLS resource variable=assign_2 latency=1 core=RAM_2P_LUTRAM { #pragma HLS latency min=1 assign_2[0] = assign_0 + assign_1; } float assign_3 = assign_2[0]; float assign_4 = load_t1_for_t0_chan_0_at_1_1; float assign_5[1]; #pragma HLS resource variable=assign_5 latency=1 core=RAM_2P_LUTRAM { #pragma HLS latency min=1 assign_5[0] = assign_3 + assign_4; } float assign_6 = assign_5[0]; float assign_7 = load_t1_for_t0_chan_0_at_1_0; float assign_8[1]; #pragma HLS resource variable=assign_8 latency=1 core=RAM_2P_LUTRAM { #pragma HLS latency min=1 assign_8[0] = assign_6 + assign_7; } float assign_9 = assign_8[0]; float assign_10 = load_t1_for_t0_chan_0_at_0_1; float assign_11[1]; #pragma HLS resource variable=assign_11 latency=1 core=RAM_2P_LUTRAM { #pragma HLS latency min=1 assign_11[0] = assign_9 + assign_10; } float assign_12 = assign_11[0]; float assign_13 = (assign_12); float assign_14 = 0.2f; float assign_15[1]; #pragma HLS resource variable=assign_15 latency=1 core=RAM_2P_LUTRAM { #pragma HLS latency min=10 assign_15[0] = assign_13 * assign_14; } float assign_16 = assign_15[0]; result_chan_0 = assign_16; buffer_t0_chan_0[unroll_index] = result_chan_0; } // unroll_index // move reuse chain 0 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[125][FIFO_125_t1_ptr] = FF_t1_chan_0[0]; } { #pragma HLS latency min=1 FF_t1_chan_0[0] = FIFO_124_t1_chan_0_fifo_0; } { #pragma HLS latency min=1 FIFO_124_t1_chan_0[0][FIFO_124_t1_ptr] = buffer_t1_chan_0[0]; } // move reuse chain 1 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[124][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_62; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[62][FIFO_125_t1_ptr] = buffer_t1_chan_0[1]; } // move reuse chain 2 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[123][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_61; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[61][FIFO_125_t1_ptr] = buffer_t1_chan_0[2]; } // move reuse chain 3 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[122][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_60; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[60][FIFO_125_t1_ptr] = buffer_t1_chan_0[3]; } // move reuse chain 4 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[121][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_59; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[59][FIFO_125_t1_ptr] = buffer_t1_chan_0[4]; } // move reuse chain 5 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[120][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_58; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[58][FIFO_125_t1_ptr] = buffer_t1_chan_0[5]; } // move reuse chain 6 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[119][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_57; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[57][FIFO_125_t1_ptr] = buffer_t1_chan_0[6]; } // move reuse chain 7 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[118][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_56; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[56][FIFO_125_t1_ptr] = buffer_t1_chan_0[7]; } // move reuse chain 8 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[117][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_55; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[55][FIFO_125_t1_ptr] = buffer_t1_chan_0[8]; } // move reuse chain 9 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[116][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_54; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[54][FIFO_125_t1_ptr] = buffer_t1_chan_0[9]; } // move reuse chain 10 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[115][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_53; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[53][FIFO_125_t1_ptr] = buffer_t1_chan_0[10]; } // move reuse chain 11 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[114][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_52; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[52][FIFO_125_t1_ptr] = buffer_t1_chan_0[11]; } // move reuse chain 12 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[113][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_51; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[51][FIFO_125_t1_ptr] = buffer_t1_chan_0[12]; } // move reuse chain 13 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[112][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_50; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[50][FIFO_125_t1_ptr] = buffer_t1_chan_0[13]; } // move reuse chain 14 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[111][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_49; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[49][FIFO_125_t1_ptr] = buffer_t1_chan_0[14]; } // move reuse chain 15 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[110][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_48; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[48][FIFO_125_t1_ptr] = buffer_t1_chan_0[15]; } // move reuse chain 16 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[109][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_47; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[47][FIFO_125_t1_ptr] = buffer_t1_chan_0[16]; } // move reuse chain 17 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[108][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_46; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[46][FIFO_125_t1_ptr] = buffer_t1_chan_0[17]; } // move reuse chain 18 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[107][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_45; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[45][FIFO_125_t1_ptr] = buffer_t1_chan_0[18]; } // move reuse chain 19 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[106][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_44; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[44][FIFO_125_t1_ptr] = buffer_t1_chan_0[19]; } // move reuse chain 20 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[105][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_43; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[43][FIFO_125_t1_ptr] = buffer_t1_chan_0[20]; } // move reuse chain 21 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[104][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_42; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[42][FIFO_125_t1_ptr] = buffer_t1_chan_0[21]; } // move reuse chain 22 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[103][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_41; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[41][FIFO_125_t1_ptr] = buffer_t1_chan_0[22]; } // move reuse chain 23 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[102][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_40; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[40][FIFO_125_t1_ptr] = buffer_t1_chan_0[23]; } // move reuse chain 24 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[101][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_39; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[39][FIFO_125_t1_ptr] = buffer_t1_chan_0[24]; } // move reuse chain 25 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[100][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_38; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[38][FIFO_125_t1_ptr] = buffer_t1_chan_0[25]; } // move reuse chain 26 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[99][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_37; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[37][FIFO_125_t1_ptr] = buffer_t1_chan_0[26]; } // move reuse chain 27 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[98][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_36; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[36][FIFO_125_t1_ptr] = buffer_t1_chan_0[27]; } // move reuse chain 28 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[97][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_35; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[35][FIFO_125_t1_ptr] = buffer_t1_chan_0[28]; } // move reuse chain 29 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[96][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_34; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[34][FIFO_125_t1_ptr] = buffer_t1_chan_0[29]; } // move reuse chain 30 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[95][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_33; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[33][FIFO_125_t1_ptr] = buffer_t1_chan_0[30]; } // move reuse chain 31 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[94][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_32; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[32][FIFO_125_t1_ptr] = buffer_t1_chan_0[31]; } // move reuse chain 32 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[93][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_31; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[31][FIFO_125_t1_ptr] = buffer_t1_chan_0[32]; } // move reuse chain 33 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[92][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_30; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[30][FIFO_125_t1_ptr] = buffer_t1_chan_0[33]; } // move reuse chain 34 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[91][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_29; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[29][FIFO_125_t1_ptr] = buffer_t1_chan_0[34]; } // move reuse chain 35 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[90][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_28; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[28][FIFO_125_t1_ptr] = buffer_t1_chan_0[35]; } // move reuse chain 36 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[89][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_27; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[27][FIFO_125_t1_ptr] = buffer_t1_chan_0[36]; } // move reuse chain 37 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[88][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_26; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[26][FIFO_125_t1_ptr] = buffer_t1_chan_0[37]; } // move reuse chain 38 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[87][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_25; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[25][FIFO_125_t1_ptr] = buffer_t1_chan_0[38]; } // move reuse chain 39 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[86][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_24; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[24][FIFO_125_t1_ptr] = buffer_t1_chan_0[39]; } // move reuse chain 40 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[85][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_23; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[23][FIFO_125_t1_ptr] = buffer_t1_chan_0[40]; } // move reuse chain 41 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[84][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_22; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[22][FIFO_125_t1_ptr] = buffer_t1_chan_0[41]; } // move reuse chain 42 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[83][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_21; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[21][FIFO_125_t1_ptr] = buffer_t1_chan_0[42]; } // move reuse chain 43 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[82][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_20; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[20][FIFO_125_t1_ptr] = buffer_t1_chan_0[43]; } // move reuse chain 44 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[81][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_19; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[19][FIFO_125_t1_ptr] = buffer_t1_chan_0[44]; } // move reuse chain 45 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[80][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_18; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[18][FIFO_125_t1_ptr] = buffer_t1_chan_0[45]; } // move reuse chain 46 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[79][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_17; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[17][FIFO_125_t1_ptr] = buffer_t1_chan_0[46]; } // move reuse chain 47 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[78][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_16; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[16][FIFO_125_t1_ptr] = buffer_t1_chan_0[47]; } // move reuse chain 48 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[77][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_15; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[15][FIFO_125_t1_ptr] = buffer_t1_chan_0[48]; } // move reuse chain 49 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[76][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_14; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[14][FIFO_125_t1_ptr] = buffer_t1_chan_0[49]; } // move reuse chain 50 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[75][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_13; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[13][FIFO_125_t1_ptr] = buffer_t1_chan_0[50]; } // move reuse chain 51 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[74][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_12; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[12][FIFO_125_t1_ptr] = buffer_t1_chan_0[51]; } // move reuse chain 52 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[73][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_11; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[11][FIFO_125_t1_ptr] = buffer_t1_chan_0[52]; } // move reuse chain 53 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[72][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_10; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[10][FIFO_125_t1_ptr] = buffer_t1_chan_0[53]; } // move reuse chain 54 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[71][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_9; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[9][FIFO_125_t1_ptr] = buffer_t1_chan_0[54]; } // move reuse chain 55 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[70][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_8; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[8][FIFO_125_t1_ptr] = buffer_t1_chan_0[55]; } // move reuse chain 56 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[69][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_7; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[7][FIFO_125_t1_ptr] = buffer_t1_chan_0[56]; } // move reuse chain 57 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[68][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_6; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[6][FIFO_125_t1_ptr] = buffer_t1_chan_0[57]; } // move reuse chain 58 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[67][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_5; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[5][FIFO_125_t1_ptr] = buffer_t1_chan_0[58]; } // move reuse chain 59 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[66][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_4; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[4][FIFO_125_t1_ptr] = buffer_t1_chan_0[59]; } // move reuse chain 60 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[65][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_3; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[3][FIFO_125_t1_ptr] = buffer_t1_chan_0[60]; } // move reuse chain 61 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[64][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_2; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[2][FIFO_125_t1_ptr] = buffer_t1_chan_0[61]; } // move reuse chain 62 for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_chan_0[63][FIFO_125_t1_ptr] = FIFO_125_t1_chan_0_fifo_1; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[1][FIFO_125_t1_ptr] = buffer_t1_chan_0[62]; } // move reuse chain 63 for buffer t1 { #pragma HLS latency min=1 FIFO_124_t1_chan_0[1][FIFO_124_t1_ptr] = FF_t1_chan_0[1]; } { #pragma HLS latency min=1 FF_t1_chan_0[1] = FIFO_125_t1_chan_0_fifo_0; } { #pragma HLS latency min=1 FIFO_125_t1_chan_0[0][FIFO_125_t1_ptr] = buffer_t1_chan_0[63]; } // move FIFO ptrs for buffer t1 { #pragma HLS latency min=1 FIFO_125_t1_ptr = FIFO_125_t1_ptr==uint8_t(125-1) ? 0 : FIFO_125_t1_ptr+1; } { #pragma HLS latency min=1 FIFO_124_t1_ptr = FIFO_124_t1_ptr==uint8_t(124-1) ? 0 : FIFO_124_t1_ptr+1; } { ap_uint<BURST_WIDTH> tmp_chan_0_bank_0, tmp_chan_0_bank_1, tmp_chan_0_bank_2, tmp_chan_0_bank_3; store_coalesced: for(int j = 0; j < BURST_WIDTH/32; ++j) { #pragma HLS unroll float raw_bits_chan_0_bank_0 = buffer_t0_chan_0[BURST_WIDTH/32*4*0+j*4+0]; tmp_chan_0_bank_0((j+1)*32-1, j*32) = *(uint32_t*)(&raw_bits_chan_0_bank_0); float raw_bits_chan_0_bank_1 = buffer_t0_chan_0[BURST_WIDTH/32*4*0+j*4+1]; tmp_chan_0_bank_1((j+1)*32-1, j*32) = *(uint32_t*)(&raw_bits_chan_0_bank_1); float raw_bits_chan_0_bank_2 = buffer_t0_chan_0[BURST_WIDTH/32*4*0+j*4+2]; tmp_chan_0_bank_2((j+1)*32-1, j*32) = *(uint32_t*)(&raw_bits_chan_0_bank_2); float raw_bits_chan_0_bank_3 = buffer_t0_chan_0[BURST_WIDTH/32*4*0+j*4+3]; tmp_chan_0_bank_3((j+1)*32-1, j*32) = *(uint32_t*)(&raw_bits_chan_0_bank_3); } to_chan_0_bank_0.write(tmp_chan_0_bank_0); to_chan_0_bank_1.write(tmp_chan_0_bank_1); to_chan_0_bank_2.write(tmp_chan_0_bank_2); to_chan_0_bank_3.write(tmp_chan_0_bank_3); } } }
54.87462
108
0.685481
Blaok
33e6c449f6b19c517cbc22da4bff066717cefd83
3,867
cc
C++
arcane/src/arcane/mesh/DoFFamilyPolicyMng.cc
JeromeDuboisPro/framework
d88925495e3787fdaf640c29728dcac385160188
[ "Apache-2.0" ]
null
null
null
arcane/src/arcane/mesh/DoFFamilyPolicyMng.cc
JeromeDuboisPro/framework
d88925495e3787fdaf640c29728dcac385160188
[ "Apache-2.0" ]
null
null
null
arcane/src/arcane/mesh/DoFFamilyPolicyMng.cc
JeromeDuboisPro/framework
d88925495e3787fdaf640c29728dcac385160188
[ "Apache-2.0" ]
null
null
null
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*- //----------------------------------------------------------------------------- // Copyright 2000-2021 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com) // See the top-level COPYRIGHT file for details. // SPDX-License-Identifier: Apache-2.0 //----------------------------------------------------------------------------- /*---------------------------------------------------------------------------*/ /* DoFFamilyPolicyMng.cc (C) 2000-2016 */ /* */ /* Gestionnaire des politiques d'une famille de DoF. */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ #include "arcane/utils/NotSupportedException.h" #include "arcane/mesh/ItemFamilyPolicyMng.h" #include "arcane/mesh/ItemFamilyCompactPolicy.h" #include "arcane/mesh/ItemFamilySerializer.h" #include "arcane/mesh/IndirectItemFamilySerializer.h" #include "arcane/mesh/DoFFamily.h" #include "arcane/mesh/DynamicMesh.h" #include "arcane/mesh/DynamicMeshIncrementalBuilder.h" /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ ARCANE_BEGIN_NAMESPACE ARCANE_MESH_BEGIN_NAMESPACE /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ class DoFFamilyCompactPolicy : public ItemFamilyCompactPolicy { public: DoFFamilyCompactPolicy(ItemFamily* family) : ItemFamilyCompactPolicy(family){} public: void updateInternalReferences(IMeshCompacter* compacter) override { // Pour l'instant ne fait rien car c'est la famille source qui gère la // mise à jour dans ItemFamily::beginCompactItems(). ARCANE_UNUSED(compacter); } }; /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /*! * \brief Gestionnaire des politiques d'une famille de DoF. */ class ARCANE_MESH_EXPORT DoFFamilyPolicyMng : public ItemFamilyPolicyMng { public: DoFFamilyPolicyMng(DoFFamily* family) : ItemFamilyPolicyMng(family,new DoFFamilyCompactPolicy(family)) , m_family(family){} public: IItemFamilySerializer* createSerializer(bool use_flags) override { if (use_flags) throw NotSupportedException(A_FUNCINFO,"serialisation with 'use_flags==true'"); IMesh* mesh = m_family->mesh(); DynamicMesh* dmesh = ARCANE_CHECK_POINTER(dynamic_cast<DynamicMesh*>(mesh)); return new ItemFamilySerializer(m_family, m_family, dmesh->incrementalBuilder()); //return new IndirectItemFamilySerializer(m_family); } private: DoFFamily* m_family; }; /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ extern "C++" ARCANE_MESH_EXPORT IItemFamilyPolicyMng* createDoFFamilyPolicyMng(ItemFamily* family) { DoFFamily* f = ARCANE_CHECK_POINTER(dynamic_cast<DoFFamily*>(family)); return new DoFFamilyPolicyMng(f); } /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ ARCANE_MESH_END_NAMESPACE ARCANE_END_NAMESPACE /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
40.705263
85
0.44091
JeromeDuboisPro
33e735490ceb6525b2f6f4ea3f1718224fa87bf5
46,010
cc
C++
src/yb/docdb/docdb.cc
icaas/yugabyte-db
fdfb3a5f53892efa69e25729af6e078293f02c0b
[ "Apache-2.0", "CC0-1.0" ]
null
null
null
src/yb/docdb/docdb.cc
icaas/yugabyte-db
fdfb3a5f53892efa69e25729af6e078293f02c0b
[ "Apache-2.0", "CC0-1.0" ]
3
2021-03-26T00:29:52.000Z
2022-02-16T01:14:42.000Z
src/yb/docdb/docdb.cc
icaas/yugabyte-db
fdfb3a5f53892efa69e25729af6e078293f02c0b
[ "Apache-2.0", "CC0-1.0" ]
null
null
null
// Copyright (c) YugaByte, 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 <algorithm> #include <memory> #include <stack> #include <string> #include <unordered_map> #include <vector> #include "yb/common/hybrid_time.h" #include "yb/common/redis_protocol.pb.h" #include "yb/common/transaction.h" #include "yb/docdb/conflict_resolution.h" #include "yb/docdb/docdb-internal.h" #include "yb/docdb/docdb.h" #include "yb/docdb/docdb.pb.h" #include "yb/docdb/docdb_compaction_filter.h" #include "yb/docdb/docdb_rocksdb_util.h" #include "yb/docdb/docdb_util.h" #include "yb/docdb/intent.h" #include "yb/docdb/intent_aware_iterator.h" #include "yb/docdb/shared_lock_manager.h" #include "yb/docdb/subdocument.h" #include "yb/docdb/value.h" #include "yb/docdb/value_type.h" #include "yb/gutil/strings/substitute.h" #include "yb/rocksutil/write_batch_formatter.h" #include "yb/rocksutil/yb_rocksdb.h" #include "yb/server/hybrid_clock.h" #include "yb/util/bytes_formatter.h" #include "yb/util/date_time.h" #include "yb/util/enums.h" #include "yb/util/logging.h" #include "yb/util/status.h" #include "yb/util/metrics.h" using std::endl; using std::list; using std::string; using std::stringstream; using std::unique_ptr; using std::shared_ptr; using std::stack; using std::vector; using std::make_shared; using yb::HybridTime; using yb::util::FormatBytesAsStr; using yb::FormatRocksDBSliceAsStr; using strings::Substitute; namespace yb { namespace docdb { namespace { constexpr size_t kMaxWordsPerEncodedHybridTimeWithValueType = ((kMaxBytesPerEncodedHybridTime + 1) + sizeof(size_t) - 1) / sizeof(size_t); // Main intent data:: // Prefix + DocPath + IntentType + DocHybridTime -> TxnId + value of the intent // Reverse index by txn id: // Prefix + TxnId + DocHybridTime -> Main intent data key // // Expects that last entry of key is DocHybridTime. void AddIntent( const TransactionId& transaction_id, const SliceParts& key, const SliceParts& value, rocksdb::WriteBatch* rocksdb_write_batch) { char reverse_key_prefix[1] = { ValueTypeAsChar::kTransactionId }; size_t doc_ht_buffer[kMaxWordsPerEncodedHybridTimeWithValueType]; auto doc_ht_slice = key.parts[key.num_parts - 1]; memcpy(doc_ht_buffer, doc_ht_slice.data(), doc_ht_slice.size()); for (size_t i = 0; i != kMaxWordsPerEncodedHybridTimeWithValueType; ++i) { doc_ht_buffer[i] = ~doc_ht_buffer[i]; } doc_ht_slice = Slice(pointer_cast<char*>(doc_ht_buffer), doc_ht_slice.size()); std::array<Slice, 3> reverse_key = {{ Slice(reverse_key_prefix, sizeof(reverse_key_prefix)), Slice(transaction_id.data, transaction_id.size()), doc_ht_slice, }}; rocksdb_write_batch->Put(key, value); rocksdb_write_batch->Put(reverse_key, key); } void ApplyIntent(const string& lock_string, const IntentType intent, KeyToIntentTypeMap *keys_locked) { auto itr = keys_locked->find(lock_string); if (itr == keys_locked->end()) { keys_locked->emplace(lock_string, intent); } else { itr->second = SharedLockManager::CombineIntents(itr->second, intent); } } } // namespace const SliceKeyBound& SliceKeyBound::Invalid() { static SliceKeyBound result; return result; } const IndexBound& IndexBound::Empty() { static IndexBound result; return result; } void PrepareDocWriteOperation(const vector<unique_ptr<DocOperation>>& doc_write_ops, const scoped_refptr<Histogram>& write_lock_latency, IsolationLevel isolation_level, SharedLockManager *lock_manager, LockBatch *keys_locked, bool *need_read_snapshot) { KeyToIntentTypeMap key_to_lock_type; *need_read_snapshot = false; for (const unique_ptr<DocOperation>& doc_op : doc_write_ops) { list<DocPath> doc_paths; IsolationLevel level; doc_op->GetDocPathsToLock(&doc_paths, &level); if (isolation_level != IsolationLevel::NON_TRANSACTIONAL) { level = isolation_level; } const IntentTypePair intent_types = GetWriteIntentsForIsolationLevel(level); for (const auto& doc_path : doc_paths) { KeyBytes current_prefix = doc_path.encoded_doc_key(); for (int i = 0; i < doc_path.num_subkeys(); i++) { ApplyIntent(current_prefix.AsStringRef(), intent_types.weak, &key_to_lock_type); doc_path.subkey(i).AppendToKey(&current_prefix); } ApplyIntent(current_prefix.AsStringRef(), intent_types.strong, &key_to_lock_type); } if (doc_op->RequireReadSnapshot()) { *need_read_snapshot = true; } } const MonoTime start_time = (write_lock_latency != nullptr) ? MonoTime::Now() : MonoTime(); *keys_locked = LockBatch(lock_manager, std::move(key_to_lock_type)); if (write_lock_latency != nullptr) { const MonoDelta elapsed_time = MonoTime::Now().GetDeltaSince(start_time); write_lock_latency->Increment(elapsed_time.ToMicroseconds()); } } Status SetDocOpQLErrorResponse(DocOperation* doc_op, std::string err_msg) { switch (doc_op->OpType()) { case DocOperation::Type::QL_WRITE_OPERATION: { const auto &resp = down_cast<QLWriteOperation *>(doc_op)->response(); resp->set_status(QLResponsePB::YQL_STATUS_SQL_ERROR); resp->set_error_message(err_msg); break; } case DocOperation::Type::PGSQL_WRITE_OPERATION: { const auto &resp = down_cast<PgsqlWriteOperation *>(doc_op)->response(); resp->set_status(PgsqlResponsePB::PGSQL_STATUS_USAGE_ERROR); resp->set_error_message(err_msg); break; } default: return STATUS_FORMAT(InternalError, "Invalid status (QLError) for doc operation %d", doc_op->OpType()); } return Status::OK(); } Status ExecuteDocWriteOperation(const vector<unique_ptr<DocOperation>>& doc_write_ops, MonoTime deadline, const ReadHybridTime& read_time, const DocDB& doc_db, KeyValueWriteBatchPB* write_batch, InitMarkerBehavior init_marker_behavior, std::atomic<int64_t>* monotonic_counter, HybridTime* restart_read_ht) { DCHECK_ONLY_NOTNULL(restart_read_ht); DocWriteBatch doc_write_batch(doc_db, init_marker_behavior, monotonic_counter); DocOperationApplyData data = {&doc_write_batch, deadline, read_time, restart_read_ht}; for (const unique_ptr<DocOperation>& doc_op : doc_write_ops) { Status s = doc_op->Apply(data); if (s.IsQLError()) { // Ensure we set appropriate error in the response object for QL errors. SetDocOpQLErrorResponse(doc_op.get(), s.message().ToBuffer()); continue; } RETURN_NOT_OK(s); } doc_write_batch.MoveToWriteBatchPB(write_batch); return Status::OK(); } void PrepareNonTransactionWriteBatch( const KeyValueWriteBatchPB& put_batch, HybridTime hybrid_time, rocksdb::WriteBatch* rocksdb_write_batch) { DocHybridTimeBuffer doc_ht_buffer; for (int write_id = 0; write_id < put_batch.kv_pairs_size(); ++write_id) { const auto& kv_pair = put_batch.kv_pairs(write_id); CHECK(!kv_pair.key().empty()); CHECK(!kv_pair.value().empty()); #ifndef NDEBUG // Debug-only: ensure all keys we get in Raft replication can be decoded. { SubDocKey subdoc_key; Status s = subdoc_key.FullyDecodeFromKeyWithOptionalHybridTime(kv_pair.key()); CHECK(s.ok()) << "Failed decoding key: " << s.ToString() << "; " << "Problematic key: " << BestEffortDocDBKeyToStr(KeyBytes(kv_pair.key())) << "\n" << "value: " << util::FormatBytesAsStr(kv_pair.value()) << "\n" << "put_batch:\n" << put_batch.DebugString(); } #endif // We replicate encoded SubDocKeys without a HybridTime at the end, and only append it here. // The reason for this is that the HybridTime timestamp is only picked at the time of // appending an entry to the tablet's Raft log. Also this is a good way to save network // bandwidth. // // "Write id" is the final component of our HybridTime encoding (or, to be more precise, // DocHybridTime encoding) that helps disambiguate between different updates to the // same key (row/column) within a transaction. We set it based on the position of the write // operation in its write batch. std::array<Slice, 2> key_parts = {{ Slice(kv_pair.key()), doc_ht_buffer.EncodeWithValueType(hybrid_time, write_id), }}; Slice key_value = kv_pair.value(); rocksdb_write_batch->Put(key_parts, { &key_value, 1 }); } } CHECKED_STATUS EnumerateIntents( const google::protobuf::RepeatedPtrField<KeyValuePairPB> &kv_pairs, boost::function<Status(IntentKind, Slice, KeyBytes*)> functor) { KeyBytes encoded_key; for (int index = 0; index < kv_pairs.size(); ++index) { const auto &kv_pair = kv_pairs.Get(index); CHECK(!kv_pair.key().empty()); CHECK(!kv_pair.value().empty()); Slice key = kv_pair.key(); auto key_size = DocKey::EncodedSize(key, DocKeyPart::WHOLE_DOC_KEY); CHECK_OK(key_size); encoded_key.Clear(); encoded_key.AppendRawBytes(key.cdata(), *key_size); key.remove_prefix(*key_size); for (;;) { auto subkey_begin = key.cdata(); auto decode_result = SubDocKey::DecodeSubkey(&key); CHECK_OK(decode_result); if (!decode_result.get()) { break; } RETURN_NOT_OK(functor(IntentKind::kWeak, Slice(), &encoded_key)); encoded_key.AppendRawBytes(subkey_begin, key.cdata() - subkey_begin); } RETURN_NOT_OK(functor(IntentKind::kStrong, kv_pair.value(), &encoded_key)); } return Status::OK(); } class PrepareTransactionWriteBatchHelper { public: PrepareTransactionWriteBatchHelper(const PrepareTransactionWriteBatchHelper&) = delete; void operator=(const PrepareTransactionWriteBatchHelper&) = delete; // `rocksdb_write_batch` - in-out parameter is filled by this prepare. PrepareTransactionWriteBatchHelper(HybridTime hybrid_time, rocksdb::WriteBatch* rocksdb_write_batch, const TransactionId& transaction_id, IsolationLevel isolation_level, IntraTxnWriteId* intra_txn_write_id) : hybrid_time_(hybrid_time), rocksdb_write_batch_(rocksdb_write_batch), transaction_id_(transaction_id), intent_types_(GetWriteIntentsForIsolationLevel(isolation_level)), intra_txn_write_id_(intra_txn_write_id) { } // Using operator() to pass this object conveniently to EnumerateIntents. CHECKED_STATUS operator()(IntentKind intent_kind, Slice value_slice, KeyBytes* key) { if (intent_kind == IntentKind::kWeak) { weak_intents_.insert(key->data()); return Status::OK(); } const auto transaction_value_type = ValueTypeAsChar::kTransactionId; const auto write_id_value_type = ValueTypeAsChar::kWriteId; IntraTxnWriteId big_endian_write_id = BigEndian::FromHost32(*intra_txn_write_id_); std::array<Slice, 5> value = {{ Slice(&transaction_value_type, 1), Slice(transaction_id_.data, transaction_id_.size()), Slice(&write_id_value_type, 1), Slice(pointer_cast<char*>(&big_endian_write_id), sizeof(big_endian_write_id)), value_slice }}; ++*intra_txn_write_id_; char intent_type[2] = { ValueTypeAsChar::kIntentType, static_cast<char>(intent_types_.strong) }; DocHybridTimeBuffer doc_ht_buffer; std::array<Slice, 3> key_parts = {{ key->AsSlice(), Slice(intent_type, 2), doc_ht_buffer.EncodeWithValueType(hybrid_time_, write_id_++), }}; AddIntent(transaction_id_, key_parts, value, rocksdb_write_batch_); return Status::OK(); } void Finish() { char transaction_id_value_type = ValueTypeAsChar::kTransactionId; char intent_type[2] = { ValueTypeAsChar::kIntentType, static_cast<char>(intent_types_.weak) }; DocHybridTimeBuffer doc_ht_buffer; std::array<Slice, 2> value = {{ Slice(&transaction_id_value_type, 1), Slice(transaction_id_.data, transaction_id_.size()), }}; for (const auto& intent : weak_intents_) { std::array<Slice, 3> key = {{ Slice(intent), Slice(intent_type, 2), doc_ht_buffer.EncodeWithValueType(hybrid_time_, write_id_++), }}; AddIntent(transaction_id_, key, value, rocksdb_write_batch_); } } private: // TODO(dtxn) weak & strong intent in one batch. // TODO(dtxn) extract part of code knowning about intents structure to lower level. HybridTime hybrid_time_; rocksdb::WriteBatch* rocksdb_write_batch_; const TransactionId& transaction_id_; IntentTypePair intent_types_; std::unordered_set<std::string> weak_intents_; IntraTxnWriteId write_id_ = 0; IntraTxnWriteId* intra_txn_write_id_; }; // We have the following distinct types of data in this "intent store": // Main intent data: // Prefix + SubDocKey (no HybridTime) + IntentType + HybridTime -> TxnId + value of the intent // Transaction metadata // TxnId -> status tablet id + isolation level // Reverse index by txn id // TxnId + HybridTime -> Main intent data key // // Where prefix is just a single byte prefix. TxnId, IntentType, HybridTime all prefixed with // appropriate value type. void PrepareTransactionWriteBatch( const KeyValueWriteBatchPB& put_batch, HybridTime hybrid_time, rocksdb::WriteBatch* rocksdb_write_batch, const TransactionId& transaction_id, IsolationLevel isolation_level, IntraTxnWriteId* write_id) { VLOG(4) << "PrepareTransactionWriteBatch(), write_id = " << *write_id; PrepareTransactionWriteBatchHelper helper( hybrid_time, rocksdb_write_batch, transaction_id, isolation_level, write_id); // We cannot recover from failures here, because it means that we cannot apply replicated // operation. CHECK_OK(EnumerateIntents(put_batch.kv_pairs(), std::ref(helper))); helper.Finish(); } // ------------------------------------------------------------------------------------------------ // Standalone functions // ------------------------------------------------------------------------------------------------ namespace { void SeekToLowerBound(const SliceKeyBound& lower_bound, IntentAwareIterator* iter) { if (lower_bound.is_exclusive()) { iter->SeekPastSubKey(lower_bound.key()); } else { iter->SeekForward(lower_bound.key()); } } // This function does not assume that object init_markers are present. If no init marker is present, // or if a tombstone is found at some level, it still looks for subkeys inside it if they have // larger timestamps. // // TODO(akashnil): ENG-1152: If object init markers were required, this read path may be optimized. // We look at all rocksdb keys with prefix = subdocument_key, and construct a subdocument out of // them, between the timestamp range high_ts and low_ts. // // The iterator is expected to be placed at the smallest key that is subdocument_key or later, and // after the function returns, the iterator should be placed just completely outside the // subdocument_key prefix. Although if high_subkey is specified, the iterator is only guaranteed // to be positioned after the high_subkey and not necessarily outside the subdocument_key prefix. // num_values_observed is used for queries on indices, and keeps track of the number of primitive // values observed thus far. In a query with lower index bound k, ignore the first k primitive // values before building the subdocument. CHECKED_STATUS BuildSubDocument( IntentAwareIterator* iter, const GetSubDocumentData& data, DocHybridTime low_ts, int64* num_values_observed) { VLOG(3) << "BuildSubDocument data: " << data << " read_time: " << iter->read_time() << " low_ts: " << low_ts; while (iter->valid()) { // Since we modify num_values_observed on recursive calls, we keep a local copy of the value. int64 current_values_observed = *num_values_observed; DocHybridTime write_time; auto key = VERIFY_RESULT(iter->FetchKey(&write_time)); VLOG(4) << "iter: " << SubDocKey::DebugSliceToString(key) << ", key: " << SubDocKey::DebugSliceToString(data.subdocument_key); DCHECK(key.starts_with(data.subdocument_key)) << "iter: " << SubDocKey::DebugSliceToString(key) << ", key: " << SubDocKey::DebugSliceToString(data.subdocument_key); // Key could be invalidated because we could move iterator, so back it up. KeyBytes key_copy(key); key = key_copy.AsSlice(); rocksdb::Slice value = iter->value(); // Checking that IntentAwareIterator returns an entry with correct time. DCHECK_GE(iter->read_time().global_limit, write_time.hybrid_time()) << "Found key: " << SubDocKey::DebugSliceToString(key); if (low_ts > write_time) { VLOG(3) << "SeekPastSubKey: " << SubDocKey::DebugSliceToString(key); iter->SeekPastSubKey(key); continue; } Value doc_value; RETURN_NOT_OK(doc_value.Decode(value)); ValueType value_type = doc_value.value_type(); if (key == data.subdocument_key) { if (write_time == DocHybridTime::kMin) return STATUS(Corruption, "No hybrid timestamp found on entry"); // We may need to update the TTL in individual columns. if (write_time.hybrid_time() >= data.exp.write_ht) { // We want to keep the default TTL otherwise. if (doc_value.ttl() != Value::kMaxTtl) { data.exp.write_ht = write_time.hybrid_time(); data.exp.ttl = doc_value.ttl(); } else if (data.exp.ttl.IsNegative()) { data.exp.ttl = -data.exp.ttl; } } // If the hybrid time is kMin, then we must be using default TTL. if (data.exp.write_ht == HybridTime::kMin) { data.exp.write_ht = write_time.hybrid_time(); } bool has_expired; CHECK_OK(HasExpiredTTL(data.exp.write_ht, data.exp.ttl, iter->read_time().read, &has_expired)); // Treat an expired value as a tombstone written at the same time as the original value. if (has_expired) { doc_value = Value::Tombstone(); value_type = ValueType::kTombstone; } const bool is_collection = IsCollectionType(value_type); // We have found some key that matches our entire subdocument_key, i.e. we didn't skip ahead // to a lower level key (with optional object init markers). if (is_collection || value_type == ValueType::kTombstone) { if (low_ts < write_time) { low_ts = write_time; } if (is_collection) { *data.result = SubDocument(value_type); } // If the subkey lower bound filters out the key we found, we want to skip to the lower // bound. If it does not, we want to seek to the next key. This prevents an infinite loop // where the iterator keeps seeking to itself if the key we found matches the low subkey. // TODO: why are not we doing this for arrays? if (IsObjectType(value_type) && !data.low_subkey->CanInclude(key)) { // Try to seek to the low_subkey for efficiency. SeekToLowerBound(*data.low_subkey, iter); } else { VLOG(3) << "SeekPastSubKey: " << SubDocKey::DebugSliceToString(key); iter->SeekPastSubKey(key); } continue; } else { if (!IsPrimitiveValueType(value_type)) { return STATUS_FORMAT(Corruption, "Expected primitive value type, got $0", value_type); } DCHECK_GE(iter->read_time().global_limit, write_time.hybrid_time()); // TODO: the ttl_seconds in primitive value is currently only in use for CQL. At some // point streamline by refactoring CQL to use the mutable Expiration in GetSubDocumentData. if (data.exp.ttl == Value::kMaxTtl) { doc_value.mutable_primitive_value()->SetTtl(-1); } else { int64_t time_since_write_seconds = ( server::HybridClock::GetPhysicalValueMicros(iter->read_time().read) - server::HybridClock::GetPhysicalValueMicros(write_time.hybrid_time())) / MonoTime::kMicrosecondsPerSecond; int64_t ttl_seconds = std::max(static_cast<int64_t>(0), data.exp.ttl.ToMilliseconds() / MonoTime::kMillisecondsPerSecond - time_since_write_seconds); doc_value.mutable_primitive_value()->SetTtl(ttl_seconds); } // Choose the user supplied timestamp if present. const UserTimeMicros user_timestamp = doc_value.user_timestamp(); doc_value.mutable_primitive_value()->SetWriteTime( user_timestamp == Value::kInvalidUserTimestamp ? write_time.hybrid_time().GetPhysicalValueMicros() : doc_value.user_timestamp()); if (!data.high_index->CanInclude(current_values_observed)) { iter->SeekOutOfSubDoc(&key_copy); return Status::OK(); } if (data.low_index->CanInclude(*num_values_observed)) { *data.result = SubDocument(doc_value.primitive_value()); } (*num_values_observed)++; VLOG(3) << "SeekOutOfSubDoc: " << SubDocKey::DebugSliceToString(key); iter->SeekOutOfSubDoc(&key_copy); return Status::OK(); } } SubDocument descendant{PrimitiveValue(ValueType::kInvalid)}; // TODO: what if the key we found is the same as before? // We'll get into an infinite recursion then. { IntentAwareIteratorPrefixScope prefix_scope(key, iter); RETURN_NOT_OK(BuildSubDocument( iter, data.Adjusted(key, &descendant), low_ts, num_values_observed)); } if (descendant.value_type() == ValueType::kInvalid) { // The document was not found in this level (maybe a tombstone was encountered). continue; } if (!data.low_subkey->CanInclude(key)) { VLOG(3) << "Filtered by low_subkey: " << data.low_subkey->ToString() << ", key: " << SubDocKey::DebugSliceToString(key); // The value provided is lower than what we are looking for, seek to the lower bound. SeekToLowerBound(*data.low_subkey, iter); continue; } // We use num_values_observed as a conservative figure for lower bound and // current_values_observed for upper bound so we don't lose any data we should be including. if (!data.low_index->CanInclude(*num_values_observed)) { continue; } if (!data.high_subkey->CanInclude(key)) { VLOG(3) << "Filtered by high_subkey: " << data.high_subkey->ToString() << ", key: " << SubDocKey::DebugSliceToString(key); // We have encountered a subkey higher than our constraints, we should stop here. return Status::OK(); } if (!data.high_index->CanInclude(current_values_observed)) { return Status::OK(); } if (!IsObjectType(data.result->value_type())) { *data.result = SubDocument(); } SubDocument* current = data.result; size_t num_children; RETURN_NOT_OK(current->NumChildren(&num_children)); if (data.limit != 0 && num_children >= data.limit) { // We have processed enough records. return Status::OK(); } if (data.count_only) { // We need to only count the records that we found. data.record_count++; } else { Slice temp = key; temp.remove_prefix(data.subdocument_key.size()); for (;;) { PrimitiveValue child; RETURN_NOT_OK(child.DecodeFromKey(&temp)); if (temp.empty()) { current->SetChild(child, std::move(descendant)); break; } current = current->GetOrAddChild(child).first; } } } return Status::OK(); } } // namespace yb::Status FindLastWriteTime( IntentAwareIterator* iter, const Slice& key_without_ht, DocHybridTime* max_overwrite_time, Expiration* exp, Value* result_value) { Slice value; DocHybridTime doc_ht = *max_overwrite_time; RETURN_NOT_OK(iter->FindLatestRecord(key_without_ht, &doc_ht, &value)); if (!iter->valid()) { return Status::OK(); } uint64_t merge_flags = 0; MonoDelta ttl; ValueType value_type; RETURN_NOT_OK(Value::DecodePrimitiveValueType(value, &value_type, &merge_flags, &ttl)); if (value_type == ValueType::kInvalid) { return Status::OK(); } // We update the expiration if and only if the write time is later than the write time // currently stored in expiration, and the record is not a regular record with default TTL. // This is done independently of whether the row is a TTL row. // In the case that the always_override flag is true, default TTL will not be preserved. Expiration new_exp = *exp; if (doc_ht.hybrid_time() >= exp->write_ht) { // We want to keep the default TTL otherwise. if (ttl != Value::kMaxTtl || merge_flags == Value::kTtlFlag || exp->always_override) { new_exp.write_ht = doc_ht.hybrid_time(); new_exp.ttl = ttl; } else if (exp->ttl.IsNegative()) { new_exp.ttl = -new_exp.ttl; } } // If we encounter a TTL row, we assign max_overwrite_time to be the write time of the // original value/init marker. if (merge_flags == Value::kTtlFlag) { DocHybridTime new_ht; RETURN_NOT_OK(iter->NextFullValue(&new_ht, &value)); // There could be a case where the TTL row exists, but the value has been // compacted away. Then, it is treated as a Tombstone written at the time // of the TTL row. if (!iter->valid() && !new_exp.ttl.IsNegative()) { new_exp.ttl = -new_exp.ttl; } else { ValueType value_type; RETURN_NOT_OK(Value::DecodePrimitiveValueType(value, &value_type)); // Because we still do not know whether we are seeking something expired, // we must take the max_overwrite_time as if the value were not expired. doc_ht = new_ht; } } if ((value_type == ValueType::kTombstone || value_type == ValueType::kInvalid) && !new_exp.ttl.IsNegative()) { new_exp.ttl = -new_exp.ttl; } *exp = new_exp; if (doc_ht > *max_overwrite_time) { *max_overwrite_time = doc_ht; VLOG(4) << "Max overwritten time for " << key_without_ht.ToDebugHexString() << ": " << *max_overwrite_time; } if (result_value) RETURN_NOT_OK(result_value->Decode(value)); return Status::OK(); } yb::Status GetSubDocument( const DocDB& doc_db, const GetSubDocumentData& data, const rocksdb::QueryId query_id, const TransactionOperationContextOpt& txn_op_context, MonoTime deadline, const ReadHybridTime& read_time) { auto iter = CreateIntentAwareIterator( doc_db, BloomFilterMode::USE_BLOOM_FILTER, data.subdocument_key, query_id, txn_op_context, deadline, read_time); return GetSubDocument(iter.get(), data, nullptr /* projection */, SeekFwdSuffices::kFalse); } yb::Status GetSubDocument( IntentAwareIterator *db_iter, const GetSubDocumentData& data, const std::vector<PrimitiveValue>* projection, const SeekFwdSuffices seek_fwd_suffices) { // TODO(dtxn) scan through all involved first transactions to cache statuses in a batch, // so during building subdocument we don't need to request them one by one. // TODO(dtxn) we need to restart read with scan_ht = commit_ht if some transaction was committed // at time commit_ht within [scan_ht; read_request_time + max_clock_skew). Also we need // to wait until time scan_ht = commit_ht passed. // TODO(dtxn) for each scanned key (and its subkeys) we need to avoid new values commits at // ht <= scan_ht (or just ht < scan_ht?) // Question: what will break if we allow later commit at ht <= scan_ht ? Need to write down // detailed example. *data.doc_found = false; DOCDB_DEBUG_LOG("GetSubDocument for key $0 @ $1", data.subdocument_key.ToDebugHexString(), db_iter->read_time().ToString()); // The latest time at which any prefix of the given key was overwritten. DocHybridTime max_overwrite_ht(DocHybridTime::kMin); VLOG(4) << "GetSubDocument(" << data << ")"; SubDocKey found_subdoc_key; auto dockey_size = VERIFY_RESULT(DocKey::EncodedSize(data.subdocument_key, DocKeyPart::WHOLE_DOC_KEY)); Slice key_slice(data.subdocument_key.data(), dockey_size); IntentAwareIteratorPrefixScope prefix_scope(key_slice, db_iter); if (seek_fwd_suffices) { db_iter->SeekForward(key_slice); } else { db_iter->Seek(key_slice); } Value doc_value; // Check ancestors for init markers, tombstones, and expiration, tracking // the expiration and corresponding most recent write time in exp, and the // the general most recent overwrite time in max_overwrite_ht { auto temp_key = data.subdocument_key; temp_key.remove_prefix(dockey_size); for (;;) { auto decode_result = VERIFY_RESULT(SubDocKey::DecodeSubkey(&temp_key)); if (!decode_result) { break; } RETURN_NOT_OK(FindLastWriteTime(db_iter, key_slice, &max_overwrite_ht, &data.exp)); key_slice = Slice(key_slice.data(), temp_key.data() - key_slice.data()); } } // By this point key_bytes is the encoded representation of the DocKey and all the subkeys of // subdocument_key. Check for init-marker / tombstones at the top level, update max_overwrite_ht. doc_value = Value(PrimitiveValue(ValueType::kInvalid)); RETURN_NOT_OK(FindLastWriteTime(db_iter, key_slice, &max_overwrite_ht, &data.exp, &doc_value)); const ValueType value_type = doc_value.value_type(); if (data.return_type_only) { *data.doc_found = value_type != ValueType::kInvalid && !data.exp.ttl.IsNegative(); // Check for expiration. if (*data.doc_found && max_overwrite_ht != DocHybridTime::kMin) { bool has_expired; CHECK_OK(HasExpiredTTL(data.exp.write_ht, data.exp.ttl, db_iter->read_time().read, &has_expired)); *data.doc_found = !has_expired; } if (*data.doc_found) { // Observe that this will have the right type but not necessarily the right value. *data.result = SubDocument(doc_value.primitive_value()); } return Status::OK(); } if (projection == nullptr) { *data.result = SubDocument(ValueType::kInvalid); int64 num_values_observed = 0; IntentAwareIteratorPrefixScope prefix_scope(key_slice, db_iter); RETURN_NOT_OK(BuildSubDocument(db_iter, data, max_overwrite_ht, &num_values_observed)); *data.doc_found = data.result->value_type() != ValueType::kInvalid; if (*data.doc_found) { if (value_type == ValueType::kRedisSet) { RETURN_NOT_OK(data.result->ConvertToRedisSet()); } else if (value_type == ValueType::kRedisTS) { RETURN_NOT_OK(data.result->ConvertToRedisTS()); } else if (value_type == ValueType::kRedisSortedSet) { RETURN_NOT_OK(data.result->ConvertToRedisSortedSet()); } else if (value_type == ValueType::kRedisList) { RETURN_NOT_OK(data.result->ConvertToRedisList()); } } return Status::OK(); } // Seed key_bytes with the subdocument key. For each subkey in the projection, build subdocument // and reuse key_bytes while appending the subkey. *data.result = SubDocument(); KeyBytes key_bytes(data.subdocument_key); const size_t subdocument_key_size = key_bytes.size(); for (const PrimitiveValue& subkey : *projection) { // Append subkey to subdocument key. Reserve extra kMaxBytesPerEncodedHybridTime + 1 bytes in // key_bytes to avoid the internal buffer from getting reallocated and moved by SeekForward() // appending the hybrid time, thereby invalidating the buffer pointer saved by prefix_scope. subkey.AppendToKey(&key_bytes); key_bytes.Reserve(key_bytes.size() + kMaxBytesPerEncodedHybridTime + 1); // This seek is to initialize the iterator for BuildSubDocument call. IntentAwareIteratorPrefixScope prefix_scope(key_bytes, db_iter); db_iter->SeekForward(&key_bytes); SubDocument descendant(ValueType::kInvalid); int64 num_values_observed = 0; RETURN_NOT_OK(BuildSubDocument( db_iter, data.Adjusted(key_bytes, &descendant), max_overwrite_ht, &num_values_observed)); *data.doc_found = descendant.value_type() != ValueType::kInvalid; data.result->SetChild(subkey, std::move(descendant)); // Restore subdocument key by truncating the appended subkey. key_bytes.Truncate(subdocument_key_size); } // Make sure the iterator is placed outside the whole document in the end. key_bytes.Truncate(dockey_size); key_bytes.AppendValueType(ValueType::kMaxByte); db_iter->SeekForward(&key_bytes); return Status::OK(); } // Note: Do not use if also retrieving other value, as some work will be repeated. // Assumes every value has a TTL, and the TTL is stored in the row with this key. // Also observe that tombstone checking only works because we assume the key has // no ancestors. yb::Status GetTtl(const Slice& encoded_subdoc_key, IntentAwareIterator* iter, bool* doc_found, Expiration* exp) { auto dockey_size = VERIFY_RESULT(DocKey::EncodedSize(encoded_subdoc_key, DocKeyPart::WHOLE_DOC_KEY)); Slice key_slice(encoded_subdoc_key.data(), dockey_size); iter->Seek(key_slice); if (!iter->valid()) return Status::OK(); DocHybridTime doc_ht; auto key = VERIFY_RESULT(iter->FetchKey(&doc_ht)); if ((*doc_found = (!key.compare(key_slice)))) { Value doc_value = Value(PrimitiveValue(ValueType::kInvalid)); RETURN_NOT_OK(doc_value.Decode(iter->value())); if (doc_value.value_type() == ValueType::kTombstone) { *doc_found = false; } else { exp->ttl = doc_value.ttl(); exp->write_ht = doc_ht.hybrid_time(); } } return Status::OK(); } // ------------------------------------------------------------------------------------------------ // Debug output // ------------------------------------------------------------------------------------------------ namespace { Result<std::string> DocDBKeyToDebugStr(Slice key_slice, StorageDbType db_type, KeyType* key_type) { *key_type = GetKeyType(key_slice, db_type); SubDocKey subdoc_key; switch (*key_type) { case KeyType::kIntentKey: { Slice intent_prefix; IntentType intent_type; DocHybridTime doc_ht; RETURN_NOT_OK_PREPEND( DecodeIntentKey(key_slice, &intent_prefix, &intent_type, &doc_ht), "Error: failed decoding RocksDB intent key " + FormatRocksDBSliceAsStr(key_slice)); RETURN_NOT_OK(subdoc_key.FullyDecodeFromKeyWithOptionalHybridTime(intent_prefix)); return subdoc_key.ToString() + " " + ToString(intent_type) + " " + doc_ht.ToString(); } case KeyType::kReverseTxnKey: { RETURN_NOT_OK(key_slice.consume_byte(ValueTypeAsChar::kTransactionId)); auto transaction_id = VERIFY_RESULT(DecodeTransactionId(&key_slice)); if (key_slice.empty() || key_slice.size() > kMaxBytesPerEncodedHybridTime + 1) { return STATUS_FORMAT( Corruption, "Invalid doc hybrid time in reverse intent record, transaction id: $0, suffix: $1", transaction_id, key_slice.ToDebugHexString()); } size_t doc_ht_buffer[kMaxWordsPerEncodedHybridTimeWithValueType]; memcpy(doc_ht_buffer, key_slice.data(), key_slice.size()); for (size_t i = 0; i != kMaxWordsPerEncodedHybridTimeWithValueType; ++i) { doc_ht_buffer[i] = ~doc_ht_buffer[i]; } key_slice = Slice(pointer_cast<char*>(doc_ht_buffer), key_slice.size()); if (static_cast<ValueType>(key_slice[0]) != ValueType::kHybridTime) { return STATUS_FORMAT( Corruption, "Invalid prefix of doc hybrid time in reverse intent record, transaction id: $0, " "decoded suffix: $1", transaction_id, key_slice.ToDebugHexString()); } key_slice.consume_byte(); DocHybridTime doc_ht; RETURN_NOT_OK(doc_ht.DecodeFrom(&key_slice)); return Format("TXN REV $0 $1", transaction_id, doc_ht); } case KeyType::kTransactionMetadata: { RETURN_NOT_OK(key_slice.consume_byte(ValueTypeAsChar::kTransactionId)); auto transaction_id = DecodeTransactionId(&key_slice); RETURN_NOT_OK(transaction_id); return Format("TXN META $0", *transaction_id); } case KeyType::kEmpty: FALLTHROUGH_INTENDED; case KeyType::kValueKey: RETURN_NOT_OK_PREPEND( subdoc_key.FullyDecodeFrom(key_slice), "Error: failed decoding RocksDB intent key " + FormatRocksDBSliceAsStr(key_slice)); return subdoc_key.ToString(); } return STATUS_SUBSTITUTE(Corruption, "Corrupted KeyType: $0", yb::ToString(*key_type)); } Result<std::string> DocDBValueToDebugStr(Slice value_slice, const KeyType& key_type) { std::string prefix; if (key_type == KeyType::kIntentKey) { auto txn_id_res = VERIFY_RESULT(DecodeTransactionIdFromIntentValue(&value_slice)); prefix = Format("TransactionId($0) ", txn_id_res); if (!value_slice.empty()) { RETURN_NOT_OK(value_slice.consume_byte(ValueTypeAsChar::kWriteId)); if (value_slice.size() < sizeof(IntraTxnWriteId)) { return STATUS_FORMAT(Corruption, "Not enought bytes for write id: $0", value_slice.size()); } auto write_id = BigEndian::Load32(value_slice.data()); value_slice.remove_prefix(sizeof(write_id)); prefix += Format("WriteId($0) ", write_id); } } // Empty values are allowed for weak intents. if (!value_slice.empty() || key_type != KeyType::kIntentKey) { Value v; RETURN_NOT_OK_PREPEND( v.Decode(value_slice), Substitute("Error: failed to decode value $0", prefix)); return prefix + v.ToString(); } else { return prefix + "none"; } } Result<std::string> DocDBValueToDebugStr( KeyType key_type, const std::string& key_str, Slice value) { switch (key_type) { case KeyType::kTransactionMetadata: { TransactionMetadataPB metadata_pb; if (!metadata_pb.ParseFromArray(value.cdata(), value.size())) { return STATUS_FORMAT(Corruption, "Bad metadata: $0", value.ToDebugHexString()); } auto metadata = TransactionMetadata::FromPB(metadata_pb); RETURN_NOT_OK(metadata); return ToString(*metadata); } case KeyType::kReverseTxnKey: { KeyType ignore_key_type; return DocDBKeyToDebugStr(value, StorageDbType::kIntents, &ignore_key_type); } case KeyType::kEmpty: FALLTHROUGH_INTENDED; case KeyType::kIntentKey: FALLTHROUGH_INTENDED; case KeyType::kValueKey: return DocDBValueToDebugStr(value, key_type); } FATAL_INVALID_ENUM_VALUE(KeyType, key_type); } void ProcessDumpEntry(Slice key, Slice value, IncludeBinary include_binary, StorageDbType db_type, std::ostream* out) { KeyType key_type; Result<std::string> key_str = DocDBKeyToDebugStr(key, db_type, &key_type); if (!key_str.ok()) { *out << key_str.status() << endl; return; } Result<std::string> value_str = DocDBValueToDebugStr(key_type, *key_str, value); if (!value_str.ok()) { *out << value_str.status().CloneAndAppend(Substitute(". Key: $0", *key_str)) << endl; return; } *out << *key_str << " -> " << *value_str << endl; if (include_binary) { *out << FormatRocksDBSliceAsStr(key) << " -> " << FormatRocksDBSliceAsStr(value) << endl << endl; } } std::string EntryToString(const rocksdb::Iterator& iterator, StorageDbType db_type) { std::ostringstream out; ProcessDumpEntry(iterator.key(), iterator.value(), IncludeBinary::kFalse, db_type, &out); return out.str(); } } // namespace void DocDBDebugDump(rocksdb::DB* rocksdb, ostream& out, StorageDbType db_type, IncludeBinary include_binary) { rocksdb::ReadOptions read_opts; read_opts.query_id = rocksdb::kDefaultQueryId; auto iter = unique_ptr<rocksdb::Iterator>(rocksdb->NewIterator(read_opts)); iter->SeekToFirst(); while (iter->Valid()) { ProcessDumpEntry(iter->key(), iter->value(), include_binary, db_type, &out); iter->Next(); } } std::string DocDBDebugDumpToStr(DocDB docdb, IncludeBinary include_binary) { stringstream ss; DocDBDebugDump(docdb.regular, ss, StorageDbType::kRegular, include_binary); if (docdb.intents) { DocDBDebugDump(docdb.intents, ss, StorageDbType::kIntents, include_binary); } return ss.str(); } std::string DocDBDebugDumpToStr(rocksdb::DB* rocksdb, StorageDbType db_type, IncludeBinary include_binary) { stringstream ss; DocDBDebugDump(rocksdb, ss, db_type, include_binary); return ss.str(); } void AppendTransactionKeyPrefix(const TransactionId& transaction_id, KeyBytes* out) { out->AppendValueType(ValueType::kTransactionId); out->AppendRawBytes(Slice(transaction_id.data, transaction_id.size())); } DocHybridTimeBuffer::DocHybridTimeBuffer() { buffer_[0] = ValueTypeAsChar::kHybridTime; } Slice DocHybridTimeBuffer::EncodeWithValueType(const DocHybridTime& doc_ht) { auto end = doc_ht.EncodedInDocDbFormat(buffer_.data() + 1); return Slice(buffer_.data(), end); } CHECKED_STATUS IntentToWriteRequest( const Slice& transaction_id_slice, HybridTime commit_ht, rocksdb::Iterator* reverse_index_iter, rocksdb::Iterator* intent_iter, rocksdb::WriteBatch* regular_batch, IntraTxnWriteId* write_id) { DocHybridTimeBuffer doc_ht_buffer; intent_iter->Seek(reverse_index_iter->value()); if (!intent_iter->Valid() || intent_iter->key() != reverse_index_iter->value()) { LOG(DFATAL) << "Unable to find intent: " << reverse_index_iter->value().ToDebugString() << " for " << reverse_index_iter->key().ToDebugString(); return Status::OK(); } auto intent = VERIFY_RESULT(ParseIntentKey(intent_iter->key(), transaction_id_slice)); if (IsStrongIntent(intent.type)) { IntraTxnWriteId stored_write_id; Slice intent_value; RETURN_NOT_OK(DecodeIntentValue( intent_iter->value(), transaction_id_slice, &stored_write_id, &intent_value)); // Write id should match to one that were calculated during append of intents. // Doing it just for sanity check. DCHECK_EQ(stored_write_id, *write_id) << "Value: " << intent_iter->value().ToDebugHexString(); // After strip of prefix and suffix intent_key contains just SubDocKey w/o a hybrid time. // Time will be added when writing batch to RocksDB. std::array<Slice, 2> key_parts = {{ intent.doc_path, doc_ht_buffer.EncodeWithValueType(commit_ht, *write_id), }}; std::array<Slice, 2> value_parts = {{ intent.doc_ht, intent_value, }}; regular_batch->Put(key_parts, value_parts); ++*write_id; } return Status::OK(); } Status PrepareApplyIntentsBatch( const TransactionId &transaction_id, HybridTime commit_ht, rocksdb::WriteBatch *regular_batch, rocksdb::DB *intents_db, rocksdb::WriteBatch *intents_batch) { Slice reverse_index_upperbound; auto reverse_index_iter = CreateRocksDBIterator( intents_db, BloomFilterMode::DONT_USE_BLOOM_FILTER, boost::none, rocksdb::kDefaultQueryId, nullptr /* read_filter */, &reverse_index_upperbound); std::unique_ptr<rocksdb::Iterator> intent_iter; // If we don't have regular_batch, it means that we just removing intents. // We don't need intent iterator, since reverse index iterator is enough in this case. if (regular_batch) { intent_iter = CreateRocksDBIterator( intents_db, BloomFilterMode::DONT_USE_BLOOM_FILTER, boost::none, rocksdb::kDefaultQueryId); } KeyBytes txn_reverse_index_prefix; Slice transaction_id_slice(transaction_id.data, TransactionId::static_size()); AppendTransactionKeyPrefix(transaction_id, &txn_reverse_index_prefix); KeyBytes txn_reverse_index_upperbound = txn_reverse_index_prefix; txn_reverse_index_upperbound.AppendValueType(ValueType::kMaxByte); reverse_index_upperbound = txn_reverse_index_upperbound.AsSlice(); reverse_index_iter->Seek(txn_reverse_index_prefix.data()); DocHybridTimeBuffer doc_ht_buffer; IntraTxnWriteId write_id = 0; while (reverse_index_iter->Valid()) { rocksdb::Slice key_slice(reverse_index_iter->key()); if (!key_slice.starts_with(txn_reverse_index_prefix.data())) { break; } VLOG(4) << "Apply reverse index record: " << EntryToString(*reverse_index_iter, StorageDbType::kIntents); // If the key ends at the transaction id then it is transaction metadata (status tablet, // isolation level etc.). if (key_slice.size() > txn_reverse_index_prefix.size()) { // Value of reverse index is a key of original intent record, so seek it and check match. if (regular_batch) { RETURN_NOT_OK(IntentToWriteRequest( transaction_id_slice, commit_ht, reverse_index_iter.get(), intent_iter.get(), regular_batch, &write_id)); } intents_batch->Delete(reverse_index_iter->value()); } intents_batch->Delete(reverse_index_iter->key()); reverse_index_iter->Next(); } return Status::OK(); } } // namespace docdb } // namespace yb
39.324786
100
0.683482
icaas
33e7b3fef67d51960183dd80a06465bf4843e744
69,509
cpp
C++
libgpopt/src/engine/CEngine.cpp
ppmht/gporca
7131e3e134e6e608f7e9fef9152a8b5d71e6a59e
[ "ECL-2.0", "Apache-2.0" ]
1
2019-03-05T10:08:56.000Z
2019-03-05T10:08:56.000Z
libgpopt/src/engine/CEngine.cpp
ppmht/gporca
7131e3e134e6e608f7e9fef9152a8b5d71e6a59e
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
libgpopt/src/engine/CEngine.cpp
ppmht/gporca
7131e3e134e6e608f7e9fef9152a8b5d71e6a59e
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
//--------------------------------------------------------------------------- // Greenplum Database // Copyright (C) 2009 - 2011 EMC Corp. // // @filename: // CEngine.cpp // // @doc: // Implementation of optimization engine //--------------------------------------------------------------------------- #include "gpos/base.h" #include "gpos/common/CAutoTimer.h" #include "gpos/io/COstreamString.h" #include "gpos/string/CWStringDynamic.h" #include "gpos/task/CAutoTaskProxy.h" #include "gpos/task/CAutoTraceFlag.h" #include "gpos/memory/CAutoMemoryPool.h" #include "gpopt/exception.h" #include "gpopt/base/CDrvdPropCtxtPlan.h" #include "gpopt/base/CCostContext.h" #include "gpopt/base/COptimizationContext.h" #include "gpopt/base/CReqdPropPlan.h" #include "gpopt/base/CReqdPropRelational.h" #include "gpopt/base/CQueryContext.h" #include "gpopt/base/COptCtxt.h" #include "gpopt/engine/CEngine.h" #include "gpopt/engine/CEnumeratorConfig.h" #include "gpopt/engine/CStatisticsConfig.h" #include "gpopt/minidump/CSerializableStackTrace.h" #include "gpopt/operators/CExpression.h" #include "gpopt/operators/CExpressionHandle.h" #include "gpopt/operators/CLogical.h" #include "gpopt/operators/CPattern.h" #include "gpopt/operators/CPatternLeaf.h" #include "gpopt/operators/CPhysicalMotionGather.h" #include "gpopt/operators/CPhysicalAgg.h" #include "gpopt/operators/CPhysicalSort.h" #include "gpopt/optimizer/COptimizerConfig.h" #include "gpopt/search/CGroup.h" #include "gpopt/search/CGroupExpression.h" #include "gpopt/search/CGroupProxy.h" #include "gpopt/search/CJob.h" #include "gpopt/search/CJobFactory.h" #include "gpopt/search/CMemo.h" #include "gpopt/search/CScheduler.h" #include "gpopt/search/CSchedulerContext.h" #include "gpopt/xforms/CXformFactory.h" #include "naucrates/traceflags/traceflags.h" #define GPOPT_SAMPLING_MAX_ITERS 30 #define GPOPT_JOBS_CAP 5000 // maximum number of initial optimization jobs #define GPOPT_JOBS_PER_GROUP 20 // estimated number of needed optimization jobs per memo group // memory consumption unit in bytes -- currently MB #define GPOPT_MEM_UNIT (1024 * 1024) #define GPOPT_MEM_UNIT_NAME "MB" using namespace gpopt; //--------------------------------------------------------------------------- // @function: // CEngine::CEngine // // @doc: // Ctor // //--------------------------------------------------------------------------- CEngine::CEngine ( IMemoryPool *pmp ) : m_pmp(pmp), m_pqc(NULL), m_pdrgpss(NULL), m_ulCurrSearchStage(0), m_pmemo(NULL), m_pexprEnforcerPattern(NULL), m_pxfs(NULL), m_pdrgpulpXformCalls(NULL), m_pdrgpulpXformTimes(NULL) { m_pmemo = GPOS_NEW(pmp) CMemo(pmp); m_pexprEnforcerPattern = GPOS_NEW(pmp) CExpression(pmp, GPOS_NEW(pmp) CPatternLeaf(pmp)); m_pxfs = GPOS_NEW(pmp) CXformSet(pmp); m_pdrgpulpXformCalls = GPOS_NEW(pmp) DrgPulp(pmp); m_pdrgpulpXformTimes = GPOS_NEW(pmp) DrgPulp(pmp); } //--------------------------------------------------------------------------- // @function: // CEngine::~CEngine // // @doc: // Dtor // //--------------------------------------------------------------------------- CEngine::~CEngine() { #ifdef GPOS_DEBUG // in optimized build, we flush-down memory pools without leak checking, // we can save time in optimized build by skipping all de-allocations here, // we still have all de-llocations enabled in debug-build to detect any possible leaks GPOS_DELETE(m_pmemo); CRefCount::SafeRelease(m_pxfs); m_pdrgpulpXformCalls->Release(); m_pdrgpulpXformTimes->Release(); m_pexprEnforcerPattern->Release(); CRefCount::SafeRelease(m_pdrgpss); #endif // GPOS_DEBUG } //--------------------------------------------------------------------------- // @function: // CEngine::InitLogicalExpression // // @doc: // Initialize engine with a given expression // //--------------------------------------------------------------------------- void CEngine::InitLogicalExpression ( CExpression *pexpr ) { GPOS_ASSERT(NULL == m_pmemo->PgroupRoot() && "Root is already set"); GPOS_ASSERT(pexpr->Pop()->FLogical()); CGroup *pgroupRoot = PgroupInsert(NULL /*pgroupTarget*/, pexpr, CXform::ExfInvalid, NULL /*pgexprOrigin*/, false /*fIntermediate*/); m_pmemo->SetRoot(pgroupRoot); } //--------------------------------------------------------------------------- // @function: // CEngine::Init // // @doc: // Initialize engine using a given query context // //--------------------------------------------------------------------------- void CEngine::Init ( CQueryContext *pqc, DrgPss *pdrgpss ) { GPOS_ASSERT(NULL == m_pqc); GPOS_ASSERT(NULL != pqc); GPOS_ASSERT_IMP ( 0 == CDrvdPropRelational::Pdprel(pqc->Pexpr()->PdpDerive())->PcrsOutput()->CElements(), 0 == pqc->Prpp()->PcrsRequired()->CElements() && "requiring columns from a zero column expression" ); m_pdrgpss = pdrgpss; if (NULL == pdrgpss) { m_pdrgpss = CSearchStage::PdrgpssDefault(m_pmp); } GPOS_ASSERT(0 < m_pdrgpss->UlLength()); if (GPOS_FTRACE(EopttracePrintOptimizationStatistics)) { // initialize per-stage xform calls array const ULONG ulStages = m_pdrgpss->UlLength(); for (ULONG ul = 0; ul < ulStages; ul++) { ULONG_PTR *pulpXformCalls = GPOS_NEW_ARRAY(m_pmp, ULONG_PTR, CXform::ExfSentinel); ULONG_PTR *pulpXformTimes = GPOS_NEW_ARRAY(m_pmp, ULONG_PTR, CXform::ExfSentinel); for (ULONG ulXform = 0; ulXform < CXform::ExfSentinel; ulXform++) { pulpXformCalls[ulXform] = 0; pulpXformTimes[ulXform] = 0; } m_pdrgpulpXformCalls->Append(pulpXformCalls); m_pdrgpulpXformTimes->Append(pulpXformTimes); } } m_pqc = pqc; InitLogicalExpression(m_pqc->Pexpr()); m_pqc->PdrgpcrSystemCols()->AddRef(); COptCtxt::PoctxtFromTLS()->SetReqdSystemCols(m_pqc->PdrgpcrSystemCols()); } //--------------------------------------------------------------------------- // @function: // CEngine::AddEnforcers // // @doc: // Add enforcers to a memo group // //--------------------------------------------------------------------------- void CEngine::AddEnforcers ( CGroupExpression *pgexpr, // belongs to group where we need to add enforcers DrgPexpr *pdrgpexprEnforcers ) { GPOS_ASSERT(NULL != pdrgpexprEnforcers); GPOS_ASSERT(NULL != pgexpr); for (ULONG ul = 0; ul < pdrgpexprEnforcers->UlLength(); ul++) { // assemble an expression rooted by the enforcer operator CExpression *pexprEnforcer = (*pdrgpexprEnforcers)[ul]; #ifdef GPOS_DEBUG CGroup * pgroup = #endif // GPOS_DEBUG PgroupInsert(pgexpr->Pgroup(), pexprEnforcer, CXform::ExfInvalid, NULL /*pgexprOrigin*/, false /*fIntermediate*/); GPOS_ASSERT(pgroup == pgexpr->Pgroup()); } } //--------------------------------------------------------------------------- // @function: // CEngine::InsertExpressionChildren // // @doc: // Insert children of the given expression to memo, and copy the groups // they end up at to the given group array // //--------------------------------------------------------------------------- void CEngine::InsertExpressionChildren ( CExpression *pexpr, DrgPgroup *pdrgpgroupChildren, CXform::EXformId exfidOrigin, CGroupExpression *pgexprOrigin ) { GPOS_ASSERT(NULL != pexpr); GPOS_ASSERT(NULL != pdrgpgroupChildren); ULONG ulArity = pexpr->UlArity(); for (ULONG i = 0; i < ulArity; i++) { CGroup *pgroupChild = NULL; COperator *popChild = (*pexpr)[i]->Pop(); if (popChild->FPattern() && CPattern::PopConvert(popChild)->FLeaf()) { GPOS_ASSERT(NULL != (*pexpr)[i]->Pgexpr()->Pgroup()); // group is already assigned during binding extraction; pgroupChild = (*pexpr)[i]->Pgexpr()->Pgroup(); } else { // insert child expression recursively pgroupChild = PgroupInsert(NULL /*pgroupTarget*/, (*pexpr)[i], exfidOrigin, pgexprOrigin, true /*fIntermediate*/); } pdrgpgroupChildren->Append(pgroupChild); } } //--------------------------------------------------------------------------- // @function: // CEngine::PgroupInsert // // @doc: // Insert an expression tree into the memo, with explicit target group; // the function returns a pointer to the group that contains the given // group expression // //--------------------------------------------------------------------------- CGroup * CEngine::PgroupInsert ( CGroup *pgroupTarget, CExpression *pexpr, CXform::EXformId exfidOrigin, CGroupExpression *pgexprOrigin, BOOL fIntermediate ) { // recursive function - check stack GPOS_CHECK_STACK_SIZE; GPOS_CHECK_ABORT; GPOS_ASSERT_IMP(CXform::ExfInvalid != exfidOrigin, NULL != pgexprOrigin); CGroup *pgroupOrigin = NULL; // check if expression was produced by extracting // a binding from the memo if (NULL != pexpr->Pgexpr()) { pgroupOrigin = pexpr->Pgexpr()->Pgroup(); GPOS_ASSERT(NULL != pgroupOrigin && NULL == pgroupTarget && "A valid group is expected"); // if parent has group pointer, all children must have group pointers; // terminate recursive insertion here return pgroupOrigin; } // if we have a valid origin group, target group must be NULL GPOS_ASSERT_IMP(NULL != pgroupOrigin, NULL == pgroupTarget); // insert expression's children to memo by recursive call DrgPgroup *pdrgpgroupChildren = GPOS_NEW(m_pmp) DrgPgroup(m_pmp, pexpr->UlArity()); InsertExpressionChildren(pexpr, pdrgpgroupChildren, exfidOrigin, pgexprOrigin); COperator *pop = pexpr->Pop(); pop->AddRef(); CGroupExpression *pgexpr = GPOS_NEW(m_pmp) CGroupExpression ( m_pmp, pop, pdrgpgroupChildren, exfidOrigin, pgexprOrigin, fIntermediate ); // find the group that contains created group expression CGroup *pgroupContainer = m_pmemo->PgroupInsert(pgroupTarget, pexpr, pgexpr); if (NULL == pgexpr->Pgroup()) { // insertion failed, release created group expression pgexpr->Release(); } return pgroupContainer; } //--------------------------------------------------------------------------- // @function: // CEngine::InsertXformResult // // @doc: // Insert a set of transformation results to memo // //--------------------------------------------------------------------------- void CEngine::InsertXformResult ( CGroup *pgroupOrigin, CXformResult *pxfres, CXform::EXformId exfidOrigin, CGroupExpression *pgexprOrigin, ULONG ulXformTime // time consumed by transformation in msec ) { GPOS_ASSERT(NULL != pxfres); GPOS_ASSERT(NULL != pgroupOrigin); GPOS_ASSERT(CXform::ExfInvalid != exfidOrigin); GPOS_ASSERT(NULL != pgexprOrigin); if (GPOS_FTRACE(EopttracePrintOptimizationStatistics) && 0 < pxfres->Pdrgpexpr()->UlLength()) { (void) m_pxfs->FExchangeSet(exfidOrigin); (void) UlpExchangeAdd(&(*m_pdrgpulpXformCalls)[m_ulCurrSearchStage][exfidOrigin], 1); { CAutoMutex am(m_mutexOptStats); am.Lock(); (*m_pdrgpulpXformTimes)[m_ulCurrSearchStage][exfidOrigin] += ulXformTime; } } CExpression *pexpr = pxfres->PexprNext(); while (NULL != pexpr) { CGroup *pgroupContainer = PgroupInsert(pgroupOrigin, pexpr, exfidOrigin, pgexprOrigin, false /*fIntermediate*/); if (pgroupContainer != pgroupOrigin && FPossibleDuplicateGroups(pgroupContainer, pgroupOrigin)) { m_pmemo->MarkDuplicates(pgroupOrigin, pgroupContainer); } pexpr = pxfres->PexprNext(); } } //--------------------------------------------------------------------------- // @function: // CEngine::FPossibleDuplicateGroups // // @doc: // Check whether the given memo groups can be marked as duplicates. This is // true only if they have the same logical properties // //--------------------------------------------------------------------------- BOOL CEngine::FPossibleDuplicateGroups ( CGroup *pgroupFst, CGroup *pgroupSnd ) { GPOS_ASSERT(NULL != pgroupFst); GPOS_ASSERT(NULL != pgroupSnd); CDrvdPropRelational *pdprelFst = CDrvdPropRelational::Pdprel(pgroupFst->Pdp()); CDrvdPropRelational *pdprelSnd = CDrvdPropRelational::Pdprel(pgroupSnd->Pdp()); // right now we only check the output columns, but we may possibly need to // check other properties as well return pdprelFst->PcrsOutput()->FEqual(pdprelSnd->PcrsOutput()); } //--------------------------------------------------------------------------- // @function: // CEngine::DeriveStats // // @doc: // Derive statistics on the root group // //--------------------------------------------------------------------------- void CEngine::DeriveStats ( IMemoryPool *pmpLocal ) { CWStringDynamic str(m_pmp); COstreamString oss (&str); oss << "\n[OPT]: Statistics Derivation Time (stage " << m_ulCurrSearchStage <<") "; CHAR *sz = CUtils::SzFromWsz(m_pmp, const_cast<WCHAR *>(str.Wsz())); { CAutoTimer at(sz, GPOS_FTRACE(EopttracePrintOptimizationStatistics)); // derive stats on root group CEngine::DeriveStats(pmpLocal, m_pmp, PgroupRoot(), NULL /*prprel*/); } GPOS_DELETE_ARRAY(sz); } //--------------------------------------------------------------------------- // @function: // CEngine::DeriveStats // // @doc: // Derive statistics on the group // //--------------------------------------------------------------------------- void CEngine::DeriveStats ( IMemoryPool *pmpLocal, IMemoryPool *pmpGlobal, CGroup *pgroup, CReqdPropRelational *prprel ) { CGroupExpression *pgexprFirst = CEngine::PgexprFirst(pgroup); CExpressionHandle exprhdl(pmpGlobal); exprhdl.Attach(pgexprFirst); exprhdl.DeriveStats(pmpLocal, pmpGlobal, prprel, NULL /*pdrgpstatCtxt*/); } //--------------------------------------------------------------------------- // @function: // CEngine::PgexprFirst // // @doc: // Return the first group expression in a given group // //--------------------------------------------------------------------------- CGroupExpression * CEngine::PgexprFirst ( CGroup *pgroup ) { CGroupExpression *pgexprFirst = NULL; { // group proxy scope CGroupProxy gp(pgroup); pgexprFirst = gp.PgexprFirst(); } GPOS_ASSERT(NULL != pgexprFirst); return pgexprFirst; } //--------------------------------------------------------------------------- // @function: // CEngine::EolDamp // // @doc: // Damp optimization level // //--------------------------------------------------------------------------- EOptimizationLevel CEngine::EolDamp ( EOptimizationLevel eol ) { if (EolHigh == eol) { return EolLow; } return EolSentinel; } //--------------------------------------------------------------------------- // @function: // CEngine::FOptimizeChild // // @doc: // Check if parent group expression needs to optimize child group expression. // This method is called right before a group optimization job is about to // schedule a group expression optimization job. // // Relation properties as well the optimizing parent group expression is // available to make the decision. So, operators can reject being optimized // under specific parent operators. For example, a GatherMerge under a Sort // can be prevented here since it destroys the order from a GatherMerge. //--------------------------------------------------------------------------- BOOL CEngine::FOptimizeChild ( CGroupExpression *pgexprParent, CGroupExpression *pgexprChild, COptimizationContext *pocChild, EOptimizationLevel eolCurrent // current optimization level in child group ) { GPOS_ASSERT(NULL != PgroupRoot()); GPOS_ASSERT(PgroupRoot()->FImplemented()); GPOS_ASSERT(NULL != pgexprChild); GPOS_ASSERT_IMP(NULL == pgexprParent, pgexprChild->Pgroup() == PgroupRoot()); if (pgexprParent == pgexprChild) { // a group expression cannot optimize itself return false; } if (pgexprChild->Eol() != eolCurrent) { // child group expression does not match current optimization level return false; } COperator *popChild = pgexprChild->Pop(); if (NULL != pgexprParent && COperator::EopPhysicalSort == pgexprParent->Pop()->Eopid() && COperator::EopPhysicalMotionGather == popChild->Eopid()) { // prevent (Sort --> GatherMerge), since Sort destroys order maintained by GatherMerge return !CPhysicalMotionGather::PopConvert(popChild)->FOrderPreserving(); } return COptimizationContext::FOptimize(m_pmp, pgexprParent, pgexprChild, pocChild, UlSearchStages()); } //--------------------------------------------------------------------------- // @function: // CEngine::FSafeToPruneWithDPEStats // // @doc: // Determine if a plan rooted by given group expression can be safely // pruned during optimization when stats for Dynamic Partition Elimination // are derived // //--------------------------------------------------------------------------- BOOL CEngine::FSafeToPruneWithDPEStats ( CGroupExpression *pgexpr, CReqdPropPlan *, // prpp CCostContext *pccChild, ULONG ulChildIndex ) { GPOS_ASSERT(GPOS_FTRACE(EopttraceDeriveStatsForDPE)); GPOS_ASSERT(GPOS_FTRACE(EopttraceEnableSpacePruning)); if (NULL == pccChild) { // group expression has not been optimized yet CDrvdPropRelational *pdprel = CDrvdPropRelational::Pdprel(pgexpr->Pgroup()->Pdp()); if (0 < pdprel->Ppartinfo()->UlConsumers()) { // we cannot bound cost here because of possible DPE that can happen below the operator return false; } return true; } // first child has been optimized CExpressionHandle exprhdl(m_pmp); exprhdl.Attach(pgexpr); ULONG ulNextChild = exprhdl.UlNextOptimizedChildIndex(ulChildIndex); CDrvdPropRelational *pdprelChild = CDrvdPropRelational::Pdprel((*pgexpr)[ulNextChild]->Pdp()); if (0 < pdprelChild->Ppartinfo()->UlConsumers()) { // we cannot bound cost here because of possible DPE that can happen for the unoptimized child return false; } return true; } //--------------------------------------------------------------------------- // @function: // CEngine::FSafeToPrune // // @doc: // Determine if a plan rooted by given group expression can be safely // pruned during optimization // //--------------------------------------------------------------------------- BOOL CEngine::FSafeToPrune ( CGroupExpression *pgexpr, CReqdPropPlan *prpp, CCostContext *pccChild, ULONG ulChildIndex, CCost *pcostLowerBound // output: a lower bound on plan's cost ) { GPOS_ASSERT(NULL != pcostLowerBound); *pcostLowerBound = GPOPT_INVALID_COST; if (!GPOS_FTRACE(EopttraceEnableSpacePruning)) { // space pruning is disabled return false; } if (GPOS_FTRACE(EopttraceDeriveStatsForDPE) && !FSafeToPruneWithDPEStats(pgexpr, prpp, pccChild, ulChildIndex)) { // stat derivation for Dynamic Partition Elimination may not allow non-trivial cost bounds return false; } // check if container group has a plan for given properties CGroup *pgroup = pgexpr->Pgroup(); COptimizationContext *pocGroup = pgroup->PocLookupBest(m_pmp, UlSearchStages(), prpp); if (NULL != pocGroup && NULL != pocGroup->PccBest()) { // compute a cost lower bound for the equivalent plan rooted by given group expression CCost costLowerBound = pgexpr->CostLowerBound(m_pmp, prpp, pccChild, ulChildIndex); *pcostLowerBound = costLowerBound; if (costLowerBound > pocGroup->PccBest()->Cost()) { // group expression cannot deliver a better plan for given properties and can be safely pruned return true; } } return false; } //--------------------------------------------------------------------------- // @function: // CEngine::Pmemotmap // // @doc: // Build tree map on memo // //--------------------------------------------------------------------------- MemoTreeMap * CEngine::Pmemotmap() { COptimizerConfig *poconf = COptCtxt::PoctxtFromTLS()->Poconf(); if (NULL == m_pmemo->Pmemotmap()) { m_pqc->Prpp()->AddRef(); COptimizationContext *poc = GPOS_NEW(m_pmp) COptimizationContext ( m_pmp, PgroupRoot(), m_pqc->Prpp(), GPOS_NEW(m_pmp) CReqdPropRelational(GPOS_NEW(m_pmp) CColRefSet(m_pmp)), // pass empty required relational properties initially GPOS_NEW(m_pmp) DrgPstat(m_pmp), // pass empty stats context initially 0 // ulSearchStageIndex ); m_pmemo->BuildTreeMap(poc); poconf->Pec()->SetPlanSpaceSize(m_pmemo->Pmemotmap()->UllCount()); poc->Release(); } return m_pmemo->Pmemotmap(); } #ifdef GPOS_DEBUG //--------------------------------------------------------------------------- // @function: // CEngine::ApplyTransformations // // @doc: // Applies given set of xforms to group expression and insert // results to memo // //--------------------------------------------------------------------------- void CEngine::ApplyTransformations ( IMemoryPool *pmpLocal, CXformSet *pxfs, CGroupExpression *pgexpr ) { // iterate over xforms CXformSetIter xsi(*pxfs); while (xsi.FAdvance()) { GPOS_CHECK_ABORT; CXform *pxform = CXformFactory::Pxff()->Pxf(xsi.TBit()); // transform group expression, and insert results to memo CXformResult *pxfres = GPOS_NEW(m_pmp) CXformResult(m_pmp); ULONG ulElapsedTime = 0; pgexpr->Transform(m_pmp, pmpLocal, pxform, pxfres, &ulElapsedTime); InsertXformResult(pgexpr->Pgroup(), pxfres, pxform->Exfid(), pgexpr, ulElapsedTime); pxfres->Release(); if (PssCurrent()->FTimedOut()) { break; } } } //--------------------------------------------------------------------------- // @function: // CEngine::TransitionGroupExpression // // @doc: // Transition group expression to a given target state // //--------------------------------------------------------------------------- void CEngine::TransitionGroupExpression ( IMemoryPool *pmpLocal, CGroupExpression *pgexpr, CGroupExpression::EState estTarget ) { GPOS_ASSERT(CGroupExpression::estExplored == estTarget || CGroupExpression::estImplemented == estTarget); if (PssCurrent()->FTimedOut()) { return; } CGroupExpression::EState estInitial = CGroupExpression::estExploring; CGroup::EState estGroupTargetState = CGroup::estExplored; if (CGroupExpression::estImplemented == estTarget) { estInitial = CGroupExpression::estImplementing; estGroupTargetState = CGroup::estImplemented; } pgexpr->SetState(estInitial); // transition all child groups ULONG ulArity = pgexpr->UlArity(); for (ULONG i = 0; i < ulArity; i++) { TransitionGroup(pmpLocal, (*pgexpr)[i], estGroupTargetState); GPOS_CHECK_ABORT; } // find which set of xforms should be used CXformSet *pxfs = CXformFactory::Pxff()->PxfsExploration(); if (CGroupExpression::estImplemented == estTarget) { pxfs = CXformFactory::Pxff()->PxfsImplementation(); } // get all applicable xforms COperator *pop = pgexpr->Pop(); CXformSet *pxfsCandidates = CLogical::PopConvert(pop)->PxfsCandidates(m_pmp); // intersect them with the required set of xforms, then apply transformations pxfsCandidates->Intersection(pxfs); pxfsCandidates->Intersection(PxfsCurrentStage()); ApplyTransformations(pmpLocal, pxfsCandidates, pgexpr); pxfsCandidates->Release(); pgexpr->SetState(estTarget); } //--------------------------------------------------------------------------- // @function: // CEngine::TransitionGroup // // @doc: // Transition group to a target state // //--------------------------------------------------------------------------- void CEngine::TransitionGroup ( IMemoryPool *pmpLocal, CGroup *pgroup, CGroup::EState estTarget ) { // check stack size GPOS_CHECK_STACK_SIZE; if (PssCurrent()->FTimedOut()) { return; } GPOS_ASSERT(CGroup::estExplored == estTarget || CGroup::estImplemented == estTarget); BOOL fTransitioned = false; { CGroupProxy gp(pgroup); fTransitioned = gp.FTransitioned(estTarget); } // check if we can end recursion early if (!fTransitioned) { CGroup::EState estInitial = CGroup::estExploring; CGroupExpression::EState estGExprTargetState = CGroupExpression::estExplored; if (CGroup::estImplemented == estTarget) { estInitial = CGroup::estImplementing; estGExprTargetState = CGroupExpression::estImplemented; } CGroupExpression *pgexprCurrent = NULL; // transition group's state to initial state { CGroupProxy gp(pgroup); gp.SetState(estInitial); } // get first group expression { CGroupProxy gp(pgroup); pgexprCurrent = gp.PgexprFirst(); } while (NULL != pgexprCurrent) { if (!pgexprCurrent->FTransitioned(estGExprTargetState)) { TransitionGroupExpression ( pmpLocal, pgexprCurrent, estGExprTargetState ); } if (PssCurrent()->FTimedOut()) { break; } // get next group expression { CGroupProxy gp(pgroup); pgexprCurrent = gp.PgexprNext(pgexprCurrent); } GPOS_CHECK_ABORT; } // transition group to target state { CGroupProxy gp(pgroup); gp.SetState(estTarget); } } } //--------------------------------------------------------------------------- // @function: // CEngine::PocChild // // @doc: // Create optimization context for child group // //--------------------------------------------------------------------------- COptimizationContext * CEngine::PocChild ( CGroupExpression *pgexpr, // parent expression COptimizationContext *pocOrigin, // optimization context of parent operator CExpressionHandle &exprhdlPlan, // handle to compute required plan properties CExpressionHandle &exprhdlRel, // handle to compute required relational properties DrgPdp *pdrgpdpChildren, // derived plan properties of optimized children DrgPstat *pdrgpstatCurrentCtxt, ULONG ulChildIndex, ULONG ulOptReq ) { GPOS_ASSERT(exprhdlPlan.Pgexpr() == pgexpr); GPOS_ASSERT(NULL != pocOrigin); GPOS_ASSERT(NULL != pdrgpdpChildren); GPOS_ASSERT(NULL != pdrgpstatCurrentCtxt); CGroup *pgroupChild = (*pgexpr)[ulChildIndex]; // compute required properties of the n-th child exprhdlPlan.ComputeChildReqdProps(ulChildIndex, pdrgpdpChildren, ulOptReq); exprhdlPlan.Prpp(ulChildIndex)->AddRef(); // use current stats for optimizing current child DrgPstat *pdrgpstatCtxt = GPOS_NEW(m_pmp) DrgPstat(m_pmp); CUtils::AddRefAppend<IStatistics, CleanupStats>(pdrgpstatCtxt, pdrgpstatCurrentCtxt); // compute required relational properties CReqdPropRelational *prprel = NULL; if (CPhysical::PopConvert(pgexpr->Pop())->FPassThruStats()) { // copy requirements from origin context prprel = pocOrigin->Prprel(); } else { // retrieve requirements from handle prprel = exprhdlRel.Prprel(ulChildIndex); } GPOS_ASSERT(NULL != prprel); prprel->AddRef(); COptimizationContext *pocChild = GPOS_NEW(m_pmp) COptimizationContext ( m_pmp, pgroupChild, exprhdlPlan.Prpp(ulChildIndex), prprel, pdrgpstatCtxt, m_ulCurrSearchStage ); return pocChild; } //--------------------------------------------------------------------------- // @function: // CEngine::PccOptimizeChild // // @doc: // Optimize child group and return best cost context satisfying // required properties // //--------------------------------------------------------------------------- CCostContext * CEngine::PccOptimizeChild ( CExpressionHandle &exprhdl, // initialized with required properties CExpressionHandle &exprhdlRel, COptimizationContext *pocOrigin, // optimization context of parent operator DrgPdp *pdrgpdp, DrgPstat *pdrgpstatCurrentCtxt, ULONG ulChildIndex, ULONG ulOptReq ) { CGroupExpression *pgexpr = exprhdl.Pgexpr(); CGroup *pgroupChild = (*exprhdl.Pgexpr())[ulChildIndex]; // create optimization context for child group COptimizationContext *pocChild = PocChild(pgexpr, pocOrigin, exprhdl, exprhdlRel, pdrgpdp, pdrgpstatCurrentCtxt, ulChildIndex, ulOptReq); if (pgroupChild == pgexpr->Pgroup() && pocChild->FMatch(pocOrigin)) { // child context is the same as origin context, this is a deadlock pocChild->Release(); return NULL; } // optimize child group CGroupExpression *pgexprChildBest = PgexprOptimize(pgroupChild, pocChild, pgexpr); pocChild->Release(); if (NULL == pgexprChildBest || PssCurrent()->FTimedOut()) { // failed to generate a plan for the child, or search stage is timed-out return NULL; } // derive plan properties of child group optimal implementation COptimizationContext *pocFound = pgroupChild->PocLookupBest(m_pmp, m_pdrgpss->UlLength(), exprhdl.Prpp(ulChildIndex)); GPOS_ASSERT(NULL != pocFound); CCostContext *pccChildBest = pocFound->PccBest(); GPOS_ASSERT(NULL != pccChildBest); // check if optimization can be early terminated after first child has been optimized CCost costLowerBound(GPOPT_INVALID_COST); if (exprhdl.UlFirstOptimizedChildIndex() == ulChildIndex && FSafeToPrune(pgexpr, pocOrigin->Prpp(), pccChildBest, ulChildIndex, &costLowerBound)) { // failed to optimize child due to cost bounding (void) pgexpr->PccComputeCost(m_pmp, pocOrigin, ulOptReq, NULL /*pdrgpoc*/, true /*fPruned*/, costLowerBound); return NULL; } return pccChildBest; } //--------------------------------------------------------------------------- // @function: // CEngine::PdrgpocOptimizeChildren // // @doc: // Optimize child groups of a given group expression; // //--------------------------------------------------------------------------- DrgPoc * CEngine::PdrgpocOptimizeChildren ( CExpressionHandle &exprhdl, // initialized with required properties COptimizationContext *pocOrigin, // optimization context of parent operator ULONG ulOptReq ) { GPOS_ASSERT(NULL != exprhdl.Pgexpr()); CGroupExpression *pgexpr = exprhdl.Pgexpr(); const ULONG ulArity = exprhdl.UlArity(); if (0 == ulArity) { // return empty array if no children return GPOS_NEW(m_pmp) DrgPoc(m_pmp); } // create array of child derived properties DrgPdp *pdrgpdp = GPOS_NEW(m_pmp) DrgPdp(m_pmp); // initialize current stats context with input stats context DrgPstat *pdrgpstatCurrentCtxt = GPOS_NEW(m_pmp) DrgPstat(m_pmp); CUtils::AddRefAppend<IStatistics, CleanupStats>(pdrgpstatCurrentCtxt, pocOrigin->Pdrgpstat()); // initialize required relational properties computation CExpressionHandle exprhdlRel(m_pmp); CGroupExpression *pgexprForStats = pgexpr->Pgroup()->PgexprBestPromise(m_pmp, pgexpr); if (NULL != pgexprForStats) { exprhdlRel.Attach(pgexprForStats); exprhdlRel.DeriveProps(NULL /*pdpctxt*/); exprhdlRel.ComputeReqdProps(pocOrigin->Prprel(), 0 /*ulOptReq*/); } // iterate over child groups and optimize them BOOL fSuccess = true; ULONG ulChildIndex = exprhdl.UlFirstOptimizedChildIndex(); do { CGroup *pgroupChild = (*exprhdl.Pgexpr())[ulChildIndex]; if (pgroupChild->FScalar()) { // skip scalar groups from optimization continue; } CCostContext *pccChildBest = PccOptimizeChild(exprhdl, exprhdlRel, pocOrigin, pdrgpdp, pdrgpstatCurrentCtxt, ulChildIndex, ulOptReq); if (NULL == pccChildBest) { fSuccess = false; break; } CExpressionHandle exprhdlChild(m_pmp); exprhdlChild.Attach(pccChildBest); exprhdlChild.DerivePlanProps(); exprhdlChild.Pdp()->AddRef(); pdrgpdp->Append(exprhdlChild.Pdp()); // copy stats of child's best cost context to current stats context IStatistics *pstat = pccChildBest->Pstats(); pstat->AddRef(); pdrgpstatCurrentCtxt->Append(pstat); GPOS_CHECK_ABORT; } while (exprhdl.FNextChildIndex(&ulChildIndex)); pdrgpdp->Release(); pdrgpstatCurrentCtxt->Release(); if (!fSuccess) { return NULL; } // return child optimization contexts array return PdrgpocChildren(m_pmp, exprhdl); } //--------------------------------------------------------------------------- // @function: // CEngine::OptimizeGroupExpression // // @doc: // Optimize group expression under a given context // //--------------------------------------------------------------------------- void CEngine::OptimizeGroupExpression ( CGroupExpression *pgexpr, COptimizationContext *poc ) { CGroup *pgroup = pgexpr->Pgroup(); const ULONG ulOptRequests = CPhysical::PopConvert(pgexpr->Pop())->UlOptRequests(); for (ULONG ul = 0; ul < ulOptRequests; ul++) { CExpressionHandle exprhdl(m_pmp); exprhdl.Attach(pgexpr); exprhdl.DeriveProps(NULL /*pdpctxt*/); // check if group expression optimization can be early terminated without optimizing any child CCost costLowerBound(GPOPT_INVALID_COST); if (FSafeToPrune(pgexpr, poc->Prpp(), NULL /*pccChild*/, ULONG_MAX /*ulChildIndex*/, &costLowerBound)) { (void) pgexpr->PccComputeCost(m_pmp, poc, ul, NULL /*pdrgpoc*/, true /*fPruned*/, costLowerBound); continue; } if (FCheckReqdProps(exprhdl, poc->Prpp(), ul)) { // load required properties on the handle exprhdl.InitReqdProps(poc->Prpp()); // optimize child groups DrgPoc *pdrgpoc = PdrgpocOptimizeChildren(exprhdl, poc, ul); if (NULL != pdrgpoc && FCheckEnfdProps(m_pmp, pgexpr, poc, ul, pdrgpoc)) { // compute group expression cost under the current optimization context CCostContext *pccComputed = pgexpr->PccComputeCost(m_pmp, poc, ul, pdrgpoc, false /*fPruned*/, CCost(0.0)); if (NULL != pccComputed) { // update best group expression under the current optimization context pgroup->UpdateBestCost(poc, pccComputed); } } CRefCount::SafeRelease(pdrgpoc); } GPOS_CHECK_ABORT; } } //--------------------------------------------------------------------------- // @function: // CEngine::PgexprOptimize // // @doc: // Optimize group under a given context; // //--------------------------------------------------------------------------- CGroupExpression * CEngine::PgexprOptimize ( CGroup *pgroup, COptimizationContext *poc, CGroupExpression *pgexprOrigin ) { // recursive function - check stack GPOS_CHECK_STACK_SIZE; COptimizationContext *pocFound = pgroup->PocInsert(poc); if (poc != pocFound) { GPOS_ASSERT(COptimizationContext::estOptimized == pocFound->Est()); return pocFound->PgexprBest(); } // add-ref context to pin it in hash table poc->AddRef(); poc->SetState(COptimizationContext::estOptimizing); EOptimizationLevel eolCurrent = pgroup->EolMax(); while (EolSentinel != eolCurrent) { CGroupExpression *pgexprCurrent = NULL; { CGroupProxy gp(pgroup); pgexprCurrent = gp.PgexprSkipLogical(NULL /*pgexpr*/); } while (NULL != pgexprCurrent) { if (FOptimizeChild(pgexprOrigin, pgexprCurrent, poc, eolCurrent)) { OptimizeGroupExpression(pgexprCurrent, poc); } if (PssCurrent()->FTimedOut()) { break; } // move to next group expression { CGroupProxy gp(pgroup); pgexprCurrent = gp.PgexprSkipLogical(pgexprCurrent); } } // damp optimization level eolCurrent = EolDamp(eolCurrent); GPOS_CHECK_ABORT; } poc->SetState(COptimizationContext::estOptimized); return poc->PgexprBest(); } //--------------------------------------------------------------------------- // @function: // CEngine::Explore // // @doc: // Apply all exploration xforms // //--------------------------------------------------------------------------- void CEngine::Explore() { GPOS_ASSERT(NULL != m_pqc); GPOS_ASSERT(NULL != PgroupRoot()); // explore root group GPOS_ASSERT(!PgroupRoot()->FExplored()); TransitionGroup(m_pmp, PgroupRoot(), CGroup::estExplored /*estTarget*/); GPOS_ASSERT_IMP ( !PssCurrent()->FTimedOut(), PgroupRoot()->FExplored() ); } //--------------------------------------------------------------------------- // @function: // CEngine::Implement // // @doc: // Apply all implementation xforms // //--------------------------------------------------------------------------- void CEngine::Implement() { GPOS_ASSERT(NULL != m_pqc); GPOS_ASSERT(NULL != PgroupRoot()); // implement root group GPOS_ASSERT(!PgroupRoot()->FImplemented()); TransitionGroup(m_pmp, PgroupRoot(), CGroup::estImplemented /*estTarget*/); GPOS_ASSERT_IMP ( !PssCurrent()->FTimedOut(), PgroupRoot()->FImplemented() ); } //--------------------------------------------------------------------------- // @function: // CEngine::RecursiveOptimize // // @doc: // Recursive optimization // //--------------------------------------------------------------------------- void CEngine::RecursiveOptimize() { COptimizerConfig *poconf = COptCtxt::PoctxtFromTLS()->Poconf(); CAutoTimer at("\n[OPT]: Total Optimization Time", GPOS_FTRACE(EopttracePrintOptimizationStatistics)); const ULONG ulSearchStages = m_pdrgpss->UlLength(); for (ULONG ul = 0; !FSearchTerminated() && ul < ulSearchStages; ul++) { PssCurrent()->RestartTimer(); // apply exploration xforms Explore(); // run exploration completion operations FinalizeExploration(); // apply implementation xforms Implement(); // run implementation completion operations FinalizeImplementation(); // optimize root group m_pqc->Prpp()->AddRef(); COptimizationContext *poc = GPOS_NEW(m_pmp) COptimizationContext ( m_pmp, PgroupRoot(), m_pqc->Prpp(), GPOS_NEW(m_pmp) CReqdPropRelational(GPOS_NEW(m_pmp) CColRefSet(m_pmp)), // pass empty required relational properties initially GPOS_NEW(m_pmp) DrgPstat(m_pmp), // pass an empty stats context initially m_ulCurrSearchStage ); (void) PgexprOptimize(PgroupRoot(), poc, NULL /*pgexprOrigin*/); poc->Release(); // extract best plan found at the end of current search stage CExpression *pexprPlan = m_pmemo->PexprExtractPlan ( m_pmp, m_pmemo->PgroupRoot(), m_pqc->Prpp(), m_pdrgpss->UlLength() ); PssCurrent()->SetBestExpr(pexprPlan); FinalizeSearchStage(); } { CAutoTrace atSearch(m_pmp); atSearch.Os() << "[OPT]: Search terminated at stage " << m_ulCurrSearchStage << "/" << m_pdrgpss->UlLength(); } if (poconf->Pec()->FSample()) { SamplePlans(); } } #endif // GPOS_DEBUG //--------------------------------------------------------------------------- // @function: // CEngine::PdrgpocChildren // // @doc: // Return array of child optimization contexts corresponding // to handle requirements // //--------------------------------------------------------------------------- DrgPoc * CEngine::PdrgpocChildren ( IMemoryPool *pmp, CExpressionHandle &exprhdl ) { GPOS_ASSERT(NULL != exprhdl.Pgexpr()); DrgPoc *pdrgpoc = GPOS_NEW(pmp) DrgPoc(pmp); const ULONG ulArity = exprhdl.UlArity(); for (ULONG ul = 0; ul < ulArity; ul++) { CGroup *pgroupChild = (*exprhdl.Pgexpr())[ul]; if (!pgroupChild->FScalar()) { COptimizationContext *poc = pgroupChild->PocLookupBest(pmp, m_pdrgpss->UlLength(), exprhdl.Prpp(ul)); GPOS_ASSERT(NULL != poc); poc->AddRef(); pdrgpoc->Append(poc); } } return pdrgpoc; } //--------------------------------------------------------------------------- // @function: // CEngine::ScheduleMainJob // // @doc: // Create and schedule the main optimization job // //--------------------------------------------------------------------------- void CEngine::ScheduleMainJob ( CSchedulerContext *psc, COptimizationContext *poc ) { GPOS_ASSERT(NULL != PgroupRoot()); CJobGroupOptimization::ScheduleJob(psc, PgroupRoot(), NULL /*pgexprOrigin*/, poc, NULL /*pjParent*/); } //--------------------------------------------------------------------------- // @function: // CEngine::FinalizeExploration // // @doc: // Execute operations after exploration completes // //--------------------------------------------------------------------------- void CEngine::FinalizeExploration() { GroupMerge(); if (m_pqc->FDeriveStats()) { // derive statistics m_pmemo->ResetStats(); DeriveStats(m_pmp); } if (!GPOS_FTRACE(EopttraceDonotDeriveStatsForAllGroups)) { // derive stats for every group without stats m_pmemo->DeriveStatsIfAbsent(m_pmp); } if (GPOS_FTRACE(EopttracePrintMemoAfterExploration)) { { CAutoTrace at(m_pmp); at.Os() << "MEMO after exploration (stage " << m_ulCurrSearchStage << ")" << std::endl; } { CAutoTrace at(m_pmp); at.Os() << *this; } } if (GPOS_FTRACE(EopttracePrintOptimizationStatistics)) { CAutoTrace at(m_pmp); (void) OsPrintMemoryConsumption(at.Os(), "Memory consumption after exploration "); } } //--------------------------------------------------------------------------- // @function: // CEngine::FinalizeImplementation // // @doc: // Execute operations after implementation completes // //--------------------------------------------------------------------------- void CEngine::FinalizeImplementation() { if (GPOS_FTRACE(EopttracePrintMemoAfterImplementation)) { { CAutoTrace at(m_pmp); at.Os() << "MEMO after implementation (stage " << m_ulCurrSearchStage << ")" << std::endl; } { CAutoTrace at(m_pmp); at.Os() << *this; } } if (GPOS_FTRACE(EopttracePrintOptimizationStatistics)) { CAutoTrace at(m_pmp); (void) OsPrintMemoryConsumption(at.Os(), "Memory consumption after implementation "); } } //--------------------------------------------------------------------------- // @function: // CEngine::FinalizeSearchStage // // @doc: // Execute operations after search stage completes // //--------------------------------------------------------------------------- void CEngine::FinalizeSearchStage() { ProcessTraceFlags(); m_pxfs->Release(); m_pxfs = NULL; m_pxfs = GPOS_NEW(m_pmp) CXformSet(m_pmp); m_ulCurrSearchStage++; m_pmemo->ResetGroupStates(); } //--------------------------------------------------------------------------- // @function: // CEngine::PrintActivatedXforms // // @doc: // Print activated xform // //--------------------------------------------------------------------------- void CEngine::PrintActivatedXforms ( IOstream &os ) const { if (GPOS_FTRACE(EopttracePrintOptimizationStatistics)) { os << std::endl << "[OPT]: <Begin Xforms - stage " << m_ulCurrSearchStage << ">" << std::endl; CXformSetIter xsi(*m_pxfs); while (xsi.FAdvance()) { CXform *pxform = CXformFactory::Pxff()->Pxf(xsi.TBit()); ULONG ulCalls = (ULONG) (*m_pdrgpulpXformCalls)[m_ulCurrSearchStage][pxform->Exfid()]; ULONG ulTime = (ULONG) (*m_pdrgpulpXformTimes)[m_ulCurrSearchStage][pxform->Exfid()]; os << pxform->SzId() << ": " << ulCalls << " calls, " << ulTime << "ms"<< std::endl; } os << "[OPT]: <End Xforms - stage " << m_ulCurrSearchStage << ">" << std::endl; } } //--------------------------------------------------------------------------- // @function: // CEngine::PrintMemoryConsumption // // @doc: // Print current memory consumption // //--------------------------------------------------------------------------- IOstream & CEngine::OsPrintMemoryConsumption ( IOstream &os, const CHAR *szHeader ) const { CMDAccessor *pmda = COptCtxt::PoctxtFromTLS()->Pmda(); CMDAccessor::MDCache *pcache = pmda->Pcache(); os << std::endl << szHeader << "Engine: [" << (DOUBLE) m_pmp->UllTotalAllocatedSize() / GPOPT_MEM_UNIT << "] " << GPOPT_MEM_UNIT_NAME << ", MD Cache: [" << (DOUBLE) (pcache->UllTotalAllocatedSize()) / GPOPT_MEM_UNIT << "] " << GPOPT_MEM_UNIT_NAME << ", Total: [" << (DOUBLE) (CMemoryPoolManager::Pmpm()->UllTotalAllocatedSize()) / GPOPT_MEM_UNIT << "] " << GPOPT_MEM_UNIT_NAME; return os; } //--------------------------------------------------------------------------- // @function: // CEngine::ProcessTraceFlags // // @doc: // Process trace flags after optimization is complete // //--------------------------------------------------------------------------- void CEngine::ProcessTraceFlags() { if (GPOS_FTRACE(EopttracePrintMemoAfterOptimization)) { { CAutoTrace at(m_pmp); at.Os() << "MEMO after optimization (stage "<< m_ulCurrSearchStage << "):" << std::endl; } { CAutoTrace at(m_pmp); at.Os() << *this; } } if (GPOS_FTRACE(EopttracePrintOptimizationStatistics)) { CAutoTrace at(m_pmp); // print optimization stats at.Os() << std::endl << "[OPT]: Memo (stage "<< m_ulCurrSearchStage << "): [" << (ULONG) (m_pmemo->UlpGroups()) << " groups" << ", " << m_pmemo->UlDuplicateGroups() << " duplicate groups" << ", " << m_pmemo->UlGrpExprs() << " group expressions" << ", " << m_pxfs->CElements() << " activated xforms]"; at.Os() << std::endl << "[OPT]: stage "<< m_ulCurrSearchStage << " completed in " << PssCurrent()->UlElapsedTime() << " msec, "; if (NULL == PssCurrent()->PexprBest()) { at.Os() << " no plan was found"; } else { at.Os() << " plan with cost "<< PssCurrent()->CostBest() <<" was found"; } PrintActivatedXforms(at.Os()); (void) OsPrintMemoryConsumption(at.Os(), "Memory consumption after optimization "); } } //--------------------------------------------------------------------------- // @function: // CEngine::Optimize // // @doc: // Main driver of optimization engine // //--------------------------------------------------------------------------- void CEngine::Optimize() { COptimizerConfig *poconf = COptCtxt::PoctxtFromTLS()->Poconf(); CAutoTimer at("\n[OPT]: Total Optimization Time", GPOS_FTRACE(EopttracePrintOptimizationStatistics)); if (GPOS_FTRACE(EopttraceParallel)) { MultiThreadedOptimize(2 /*ulWorkers*/); } else { MainThreadOptimize(); } { if (GPOS_FTRACE(EopttracePrintOptimizationStatistics)) { CAutoTrace atSearch(m_pmp); atSearch.Os() << "[OPT]: Search terminated at stage " << m_ulCurrSearchStage << "/" << m_pdrgpss->UlLength(); } } if (poconf->Pec()->FSample()) { SamplePlans(); } } //--------------------------------------------------------------------------- // @function: // CEngine::MainThreadOptimize // // @doc: // Run optimizer on the main thread // //--------------------------------------------------------------------------- void CEngine::MainThreadOptimize() { GPOS_ASSERT(NULL != PgroupRoot()); GPOS_ASSERT(NULL != COptCtxt::PoctxtFromTLS()); const ULONG ulJobs = std::min((ULONG) GPOPT_JOBS_CAP, (ULONG) (m_pmemo->UlpGroups() * GPOPT_JOBS_PER_GROUP)); CJobFactory jf(m_pmp, ulJobs); CScheduler sched(m_pmp, ulJobs, 1 /*ulWorkers*/); CSchedulerContext sc; sc.Init(m_pmp, &jf, &sched, this); const ULONG ulSearchStages = m_pdrgpss->UlLength(); for (ULONG ul = 0; !FSearchTerminated() && ul < ulSearchStages; ul++) { PssCurrent()->RestartTimer(); // optimize root group m_pqc->Prpp()->AddRef(); COptimizationContext *poc = GPOS_NEW(m_pmp) COptimizationContext ( m_pmp, PgroupRoot(), m_pqc->Prpp(), GPOS_NEW(m_pmp) CReqdPropRelational(GPOS_NEW(m_pmp) CColRefSet(m_pmp)), // pass empty required relational properties initially GPOS_NEW(m_pmp) DrgPstat(m_pmp), // pass empty stats context initially m_ulCurrSearchStage ); // schedule main optimization job ScheduleMainJob(&sc, poc); // run optimization job CScheduler::Run(&sc); poc->Release(); // extract best plan found at the end of current search stage CExpression *pexprPlan = m_pmemo->PexprExtractPlan ( m_pmp, m_pmemo->PgroupRoot(), m_pqc->Prpp(), m_pdrgpss->UlLength() ); PssCurrent()->SetBestExpr(pexprPlan); FinalizeSearchStage(); } } //--------------------------------------------------------------------------- // @function: // CEngine::MultiThreadedOptimize // // @doc: // Multi-threaded optimization // //--------------------------------------------------------------------------- void CEngine::MultiThreadedOptimize ( ULONG ulWorkers ) { GPOS_ASSERT(NULL != PgroupRoot()); GPOS_ASSERT(NULL != COptCtxt::PoctxtFromTLS()); const ULONG ulJobs = std::min((ULONG) GPOPT_JOBS_CAP, (ULONG) (m_pmemo->UlpGroups() * GPOPT_JOBS_PER_GROUP)); CJobFactory jf(m_pmp, ulJobs); CScheduler sched(m_pmp, ulJobs, ulWorkers); CSchedulerContext sc; sc.Init(m_pmp, &jf, &sched, this); const ULONG ulSearchStages = m_pdrgpss->UlLength(); for (ULONG ul = 0; !FSearchTerminated() && ul < ulSearchStages; ul++) { PssCurrent()->RestartTimer(); // optimize root group m_pqc->Prpp()->AddRef(); COptimizationContext *poc = GPOS_NEW(m_pmp) COptimizationContext ( m_pmp, PgroupRoot(), m_pqc->Prpp(), GPOS_NEW(m_pmp) CReqdPropRelational(GPOS_NEW(m_pmp) CColRefSet(m_pmp)), // pass empty required relational properties initially GPOS_NEW(m_pmp) DrgPstat(m_pmp), // pass empty stats context initially m_ulCurrSearchStage ); // schedule main optimization job ScheduleMainJob(&sc, poc); // create task array CAutoRg<CTask*> a_rgptsk; a_rgptsk = GPOS_NEW_ARRAY(m_pmp, CTask*, ulWorkers); // create scheduling contexts CAutoRg<CSchedulerContext> a_rgsc; a_rgsc = GPOS_NEW_ARRAY(m_pmp, CSchedulerContext, ulWorkers); // scope for ATP { CWorkerPoolManager *pwpm = CWorkerPoolManager::Pwpm(); CAutoTaskProxy atp(m_pmp, pwpm); for (ULONG i = 0; i < ulWorkers; i++) { // initialize scheduling context a_rgsc[i].Init(m_pmp, &jf, &sched, this); // create scheduling task a_rgptsk[i] = atp.PtskCreate(CScheduler::Run, &a_rgsc[i]); // store a pointer to optimizer's context in current task local storage a_rgptsk[i]->Tls().Reset(m_pmp); a_rgptsk[i]->Tls().Store(COptCtxt::PoctxtFromTLS()); } // start tasks for (ULONG i = 0; i < ulWorkers; i++) { atp.Schedule(a_rgptsk[i]); } // wait for tasks to complete for (ULONG i = 0; i < ulWorkers; i++) { CTask *ptsk; atp.WaitAny(&ptsk); } } poc->Release(); // extract best plan found at the end of current search stage CExpression *pexprPlan = m_pmemo->PexprExtractPlan ( m_pmp, m_pmemo->PgroupRoot(), m_pqc->Prpp(), m_pdrgpss->UlLength() ); PssCurrent()->SetBestExpr(pexprPlan); FinalizeSearchStage(); } } //--------------------------------------------------------------------------- // @function: // CEngine::CEngine // // @doc: // Ctor // //--------------------------------------------------------------------------- CExpression * CEngine::PexprUnrank ( ULLONG ullPlanId ) { // The CTE map will be updated by the Producer instead of the Sequence operator // because we are doing a DFS traversal of the TreeMap. CDrvdPropCtxtPlan *pdpctxtplan = GPOS_NEW(m_pmp) CDrvdPropCtxtPlan(m_pmp, false /*fUpdateCTEMap*/); CExpression *pexpr = Pmemotmap()->PrUnrank(m_pmp, pdpctxtplan, ullPlanId); pdpctxtplan->Release(); #ifdef GPOS_DEBUG // check plan using configured plan checker, if any COptimizerConfig *poconf = COptCtxt::PoctxtFromTLS()->Poconf(); CEnumeratorConfig *pec = poconf->Pec(); BOOL fCheck = pec->FCheckPlan(pexpr); if (!fCheck) { CAutoTrace at(m_pmp); at.Os() << "\nextracted plan failed PlanChecker function: " << std::endl << *pexpr; } GPOS_ASSERT(fCheck); #endif // GPOS_DEBUG return pexpr; } //--------------------------------------------------------------------------- // @function: // CEngine::PexprExtractPlan // // @doc: // Extract a physical plan from the memo // //--------------------------------------------------------------------------- CExpression * CEngine::PexprExtractPlan() { GPOS_ASSERT(NULL != m_pqc); GPOS_ASSERT(NULL != m_pmemo); GPOS_ASSERT(NULL != m_pmemo->PgroupRoot()); BOOL fGenerateAlt = false; COptimizerConfig *poconf = COptCtxt::PoctxtFromTLS()->Poconf(); CEnumeratorConfig *pec = poconf->Pec(); if (pec->FEnumerate()) { CAutoTrace at(m_pmp); ULLONG ullCount = Pmemotmap()->UllCount(); at.Os() << "[OPT]: Number of plan alternatives: " << ullCount << std::endl; if (0 < pec->UllPlanId()) { if (pec->UllPlanId() > ullCount) { // an invalid plan number is chosen GPOS_RAISE(gpopt::ExmaGPOPT, gpopt::ExmiInvalidPlanAlternative, pec->UllPlanId(), ullCount); } // a valid plan number was chosen fGenerateAlt = true; } } CExpression *pexpr = NULL; if (fGenerateAlt) { pexpr = PexprUnrank(pec->UllPlanId() - 1 /*rank of plan alternative is zero-based*/); CAutoTrace at(m_pmp); at.Os() << "[OPT]: Successfully generated plan: " << pec->UllPlanId() << std::endl; } else { pexpr = m_pmemo->PexprExtractPlan ( m_pmp, m_pmemo->PgroupRoot(), m_pqc->Prpp(), m_pdrgpss->UlLength() ); } if (NULL == pexpr) { GPOS_RAISE(gpopt::ExmaGPOPT, gpopt::ExmiNoPlanFound); } return pexpr; } //--------------------------------------------------------------------------- // @function: // CEngine::UllRandomPlanId // // @doc: // Generate random plan id // //--------------------------------------------------------------------------- ULLONG CEngine::UllRandomPlanId ( ULONG *pulSeed ) { ULLONG ullCount = Pmemotmap()->UllCount(); ULLONG ullPlanId = 0; do { ullPlanId = clib::UlRandR(pulSeed); } while (ullPlanId >= ullCount); return ullPlanId; } //--------------------------------------------------------------------------- // @function: // CEngine::FValidPlanSample // // @doc: // Extract a plan sample and handle exceptions according to enumerator // configurations // //--------------------------------------------------------------------------- BOOL CEngine::FValidPlanSample ( CEnumeratorConfig *pec, ULLONG ullPlanId, CExpression **ppexpr // output: extracted plan ) { GPOS_ASSERT(NULL != pec); GPOS_ASSERT(NULL != ppexpr); BOOL fValidPlan = true; if (pec->FSampleValidPlans()) { // if enumerator is configured to extract valid plans only, // we extract plan and catch invalid plan exception here GPOS_TRY { *ppexpr = PexprUnrank(ullPlanId); } GPOS_CATCH_EX(ex) { if (GPOS_MATCH_EX(ex, gpopt::ExmaGPOPT, gpopt::ExmiUnsatisfiedRequiredProperties)) { GPOS_RESET_EX; fValidPlan = false; } else { // for all other exceptions, we bail out GPOS_RETHROW(ex); } } GPOS_CATCH_END; } else { // otherwise, we extract plan and leave exception handling to the caller *ppexpr = PexprUnrank(ullPlanId); } return fValidPlan; } //--------------------------------------------------------------------------- // @function: // CEngine::SamplePlans // // @doc: // Sample distribution of possible plans uniformly; // //--------------------------------------------------------------------------- void CEngine::SamplePlans() { COptimizerConfig *poconf = COptCtxt::PoctxtFromTLS()->Poconf(); GPOS_ASSERT(NULL != poconf); CEnumeratorConfig *pec = poconf->Pec(); ULLONG ullSamples = pec->UllInputSamples(); GPOS_ASSERT(0 < ullSamples); pec->ClearSamples(); ULLONG ullCount = Pmemotmap()->UllCount(); if (0 == ullCount) { // optimizer generated no plans return; } // generate full plan space when space size is less than or equal to // the required number of samples BOOL fGenerateAll = (ullSamples >= ullCount); ULLONG ullTargetSamples = ullSamples; if (fGenerateAll) { ullTargetSamples = ullCount; } // find cost of best plan CExpression *pexpr = m_pmemo->PexprExtractPlan ( m_pmp, m_pmemo->PgroupRoot(), m_pqc->Prpp(), m_pdrgpss->UlLength() ); CCost costBest = pexpr->Cost(); pec->SetBestCost(costBest); pexpr->Release(); // generate randomized seed using local time TIMEVAL tv; syslib::GetTimeOfDay(&tv, NULL/*timezone*/); ULONG ulSeed = UlCombineHashes((ULONG) tv.tv_sec, (ULONG)tv.tv_usec); // set maximum number of iterations based number of samples // we use maximum iteration to prevent infinite looping below const ULLONG ullMaxIters = ullTargetSamples * GPOPT_SAMPLING_MAX_ITERS; ULLONG ullIters = 0; ULLONG ull = 0; while (ullIters < ullMaxIters && ull < ullTargetSamples) { // generate id of plan to be extracted ULLONG ullPlanId = ull; if (!fGenerateAll) { ullPlanId = UllRandomPlanId(&ulSeed); } pexpr = NULL; BOOL fAccept = false; if (FValidPlanSample(pec, ullPlanId, &pexpr)) { // add plan to the sample if it is below cost threshold CCost cost = pexpr->Cost(); fAccept = pec->FAddSample(ullPlanId, cost); pexpr->Release(); } if (fGenerateAll || fAccept) { ull++; } ullIters++; } pec->PrintPlanSample(); } //--------------------------------------------------------------------------- // @function: // CEngine::FCheckEnfdProps // // @doc: // Check enforceable properties and append enforcers to the current group if // required. // // This check is done in two steps: // // First, it determines if any particular property needs to be enforced at // all. For example, the EopttraceDisableSort traceflag can disable order // enforcement. Also, if there are no partitioned tables referenced in the // subtree, partition propagation enforcement can be skipped. // // Second, EPET methods are called for each property to determine if an // enforcer needs to be added. These methods in turn call into virtual // methods in the different operators. For example, CPhysical::EpetOrder() // is used to determine a Sort node needs to be added to the group. These // methods are passed an expression handle (to access derived properties of // the subtree) and the required properties as a object of a subclass of // CEnfdProp. // // Finally, based on return values of the EPET methods, // CEnfdProp::AppendEnforcers() is called for each of the enforced // properties. // // Returns true if no enforcers were created because they were deemed // unnecessary or optional i.e all enforced properties were satisfied for // the group expression under the current optimization context. Returns // false otherwise. // // NB: This method is only concerned with a certain enforcer needs to be // added into the group. Once added, there is no connection between the // enforcer and the operator that created it. That is although some group // expression X created the enforcer E, later, during costing, E can still // decide to pick some other group expression Y for its child, since // theoretically, all group expressions in a group are equivalent. // //--------------------------------------------------------------------------- BOOL CEngine::FCheckEnfdProps ( IMemoryPool *pmp, CGroupExpression *pgexpr, COptimizationContext *poc, ULONG ulOptReq, DrgPoc *pdrgpoc ) { GPOS_CHECK_ABORT; if (GPOS_FTRACE(EopttracePrintMemoEnforcement)) { CAutoTrace at(m_pmp); at.Os() << "CEngine::FCheckEnfdProps (Group ID: " << pgexpr->Pgroup()->UlId() << " Expression ID: " << pgexpr->UlId() << ")"<< std::endl; m_pmemo->OsPrint(at.Os()); } // check if all children could be successfully optimized if (!FChildrenOptimized(pdrgpoc)) { return false; } // load a handle with derived plan properties poc->AddRef(); pgexpr->AddRef(); pdrgpoc->AddRef(); CCostContext *pcc= GPOS_NEW(pmp) CCostContext(pmp, poc, ulOptReq, pgexpr); pcc->SetChildContexts(pdrgpoc); CExpressionHandle exprhdl(pmp); exprhdl.Attach(pcc); exprhdl.DerivePlanProps(); pcc->Release(); CPhysical *popPhysical = CPhysical::PopConvert(exprhdl.Pop()); CReqdPropPlan *prpp = poc->Prpp(); // check whether the current physical operator satisfies the CTE requirements // and whether it is a motion over unresolved part consumers if (!FValidCTEAndPartitionProperties(pmp, exprhdl, prpp)) { return false; } // Determine if any property enforcement is disable or unnecessary BOOL fOrderReqd = !GPOS_FTRACE(EopttraceDisableSort) && !prpp->Peo()->PosRequired()->FEmpty(); BOOL fDistributionReqd = !GPOS_FTRACE(EopttraceDisableMotions) && (CDistributionSpec::EdtAny != prpp->Ped()->PdsRequired()->Edt()); BOOL fRewindabilityReqd = !GPOS_FTRACE(EopttraceDisableSpool) && (CRewindabilitySpec::ErtNone != prpp->Per()->PrsRequired()->Ert()); BOOL fPartPropagationReqd = !GPOS_FTRACE(EopttraceDisablePartPropagation) && prpp->Pepp()->PppsRequired()->FPartPropagationReqd(); // Determine if adding an enforcer to the group is required, optional, // unnecessary or prohibited over the group expression and given the current // optimization context (required properties) // get order enforcing type CEnfdProp::EPropEnforcingType epetOrder = prpp->Peo()->Epet(exprhdl, popPhysical, fOrderReqd); // get distribution enforcing type CEnfdProp::EPropEnforcingType epetDistribution = prpp->Ped()->Epet(exprhdl, popPhysical, prpp->Pepp()->PppsRequired(), fDistributionReqd); // get rewindability enforcing type CEnfdProp::EPropEnforcingType epetRewindability = prpp->Per()->Epet(exprhdl, popPhysical, fRewindabilityReqd); // get partition propagation enforcing type CEnfdProp::EPropEnforcingType epetPartitionPropagation = prpp->Pepp()->Epet(exprhdl, popPhysical, fPartPropagationReqd); // Skip adding enforcers entirely if any property determines it to be // 'prohibited'. In this way, a property may veto out the creation of an // enforcer for the current group expression and optimization context. // // NB: Even though an enforcer E is not added because of some group // expression G because it was prohibited, some other group expression H may // decide to add it. And if E is added, it is possible for E to consider both // G and H as its child. if (FProhibited(epetOrder, epetDistribution, epetRewindability, epetPartitionPropagation)) { return false; } DrgPexpr *pdrgpexprEnforcers = GPOS_NEW(pmp) DrgPexpr(pmp); // extract a leaf pattern from target group CBinding binding; CExpression *pexpr = binding.PexprExtract(m_pmp, exprhdl.Pgexpr(), m_pexprEnforcerPattern, NULL /* pexprLast */); GPOS_ASSERT(NULL != pexpr); GPOS_ASSERT(pexpr->Pgexpr()->Pgroup() == pgexpr->Pgroup()); prpp->Peo()->AppendEnforcers(pmp, prpp, pdrgpexprEnforcers, pexpr, epetOrder, exprhdl); prpp->Ped()->AppendEnforcers(pmp, prpp, pdrgpexprEnforcers, pexpr, epetDistribution, exprhdl); prpp->Per()->AppendEnforcers(pmp, prpp, pdrgpexprEnforcers, pexpr, epetRewindability, exprhdl); prpp->Pepp()->AppendEnforcers(pmp, prpp, pdrgpexprEnforcers, pexpr, epetPartitionPropagation, exprhdl); if (0 < pdrgpexprEnforcers->UlLength()) { AddEnforcers(exprhdl.Pgexpr(), pdrgpexprEnforcers); } pdrgpexprEnforcers->Release(); pexpr->Release(); return FOptimize(epetOrder, epetDistribution, epetRewindability, epetPartitionPropagation); } //--------------------------------------------------------------------------- // @function: // CEngine::FValidCTEAndPartitionProperties // // @doc: // Check if the given expression has valid cte and partition properties // with respect to the given requirements. This function returns true iff // ALL the following conditions are met: // 1. The expression satisfies the CTE requirements // 2. The root of the expression is not a motion over an unresolved part consumer // 3. The expression does not have an unneeded part propagator // //--------------------------------------------------------------------------- BOOL CEngine::FValidCTEAndPartitionProperties ( IMemoryPool *pmp, CExpressionHandle &exprhdl, CReqdPropPlan *prpp ) { CPhysical *popPhysical = CPhysical::PopConvert(exprhdl.Pop()); CPartIndexMap *ppimDrvd = CDrvdPropPlan::Pdpplan(exprhdl.Pdp())->Ppim(); return popPhysical->FProvidesReqdCTEs(exprhdl, prpp->Pcter()) && !CUtils::FMotionOverUnresolvedPartConsumers(pmp, exprhdl, prpp->Pepp()->PppsRequired()->Ppim()) && !ppimDrvd->FContainsRedundantPartitionSelectors(prpp->Pepp()->PppsRequired()->Ppim()); } //--------------------------------------------------------------------------- // @function: // CEngine::FChildrenOptimized // // @doc: // Check if all children were successfully optimized // //--------------------------------------------------------------------------- BOOL CEngine::FChildrenOptimized ( DrgPoc *pdrgpoc ) { GPOS_ASSERT(NULL != pdrgpoc); const ULONG ulLen = pdrgpoc->UlLength(); for (ULONG ul = 0; ul < ulLen; ul++) { if (NULL == (*pdrgpoc)[ul]->PgexprBest()) { return false; } } return true; } //--------------------------------------------------------------------------- // @function: // CEngine::FOptimize // // @doc: // Check if optimization is possible under the given property enforcing // types // //--------------------------------------------------------------------------- BOOL CEngine::FOptimize ( CEnfdProp::EPropEnforcingType epetOrder, CEnfdProp::EPropEnforcingType epetDistribution, CEnfdProp::EPropEnforcingType epetRewindability, CEnfdProp::EPropEnforcingType epetPropagation ) { return CEnfdProp::FOptimize(epetOrder) && CEnfdProp::FOptimize(epetDistribution) && CEnfdProp::FOptimize(epetRewindability) && CEnfdProp::FOptimize(epetPropagation); } //--------------------------------------------------------------------------- // @function: // CEngine::FProhibited // // @doc: // Check if any of the given property enforcing types prohibits enforcement // //--------------------------------------------------------------------------- BOOL CEngine::FProhibited ( CEnfdProp::EPropEnforcingType epetOrder, CEnfdProp::EPropEnforcingType epetDistribution, CEnfdProp::EPropEnforcingType epetRewindability, CEnfdProp::EPropEnforcingType epetPropagation ) { return (CEnfdProp::EpetProhibited == epetOrder || CEnfdProp::EpetProhibited == epetDistribution || CEnfdProp::EpetProhibited == epetRewindability || CEnfdProp::EpetProhibited == epetPropagation); } //--------------------------------------------------------------------------- // @function: // CEngine::FCheckReqdPartPropagation // // @doc: // Check if partition propagation resolver is passed an empty part propagation // spec // //--------------------------------------------------------------------------- BOOL CEngine::FCheckReqdPartPropagation ( CPhysical *pop, CEnfdPartitionPropagation *pepp ) { BOOL fPartPropagationReqd = (NULL != pepp && pepp->PppsRequired()->Ppim()->FContainsUnresolvedZeroPropagators()); return fPartPropagationReqd || COperator::EopPhysicalPartitionSelector != pop->Eopid(); } //--------------------------------------------------------------------------- // @function: // CEngine::FCheckReqdProps // // @doc: // Determine if checking required properties is needed. // This method is called after a group expression optimization job has // started executing and can be used to cancel the job early. // // This is useful to prevent deadlocks when an enforcer optimizes same // group with the same optimization context. Also, in case the subtree // doesn't provide the required columns we can save optimization time by // skipping this optimization request. // // NB: Only relational properties are available at this stage to make this // decision. //--------------------------------------------------------------------------- BOOL CEngine::FCheckReqdProps ( CExpressionHandle &exprhdl, CReqdPropPlan *prpp, ULONG ulOptReq ) { GPOS_CHECK_ABORT; if (GPOS_FTRACE(EopttracePrintMemoEnforcement)) { CAutoTrace at(m_pmp); at.Os() << "CEngine::FCheckReqdProps (Group ID: " << exprhdl.Pgexpr()->Pgroup()->UlId() << " Expression ID: " << exprhdl.Pgexpr()->UlId() << ")" << std::endl; m_pmemo->OsPrint(at.Os()); } // check if operator provides required columns if (!prpp->FProvidesReqdCols(m_pmp, exprhdl, ulOptReq)) { return false; } CPhysical *popPhysical = CPhysical::PopConvert(exprhdl.Pop()); COperator::EOperatorId eopid = popPhysical->Eopid(); // check if sort operator is passed an empty order spec; // this check is required to avoid self-deadlocks, i.e. // sort optimizing same group with the same optimization context; BOOL fOrderReqd = !prpp->Peo()->PosRequired()->FEmpty(); if (!fOrderReqd && COperator::EopPhysicalSort == eopid) { return false; } // check if motion operator is passed an ANY distribution spec; // this check is required to avoid self-deadlocks, i.e. // motion optimizing same group with the same optimization context; BOOL fDistributionReqd = (CDistributionSpec::EdtAny != prpp->Ped()->PdsRequired()->Edt()); if (!fDistributionReqd && CUtils::FPhysicalMotion(popPhysical)) { return false; } // check if spool operator is passed a non-rewindable spec; // this check is required to avoid self-deadlocks, i.e. // spool optimizing same group with the same optimization context; BOOL fRewindabilityReqd = (CRewindabilitySpec::ErtNone != prpp->Per()->PrsRequired()->Ert()); if (!fRewindabilityReqd && COperator::EopPhysicalSpool == eopid) { return false; } return FCheckReqdPartPropagation(popPhysical, prpp->Pepp()); } #ifdef GPOS_DEBUG //--------------------------------------------------------------------------- // @function: // CEngine::PrintRoot // // @doc: // Print root group // //--------------------------------------------------------------------------- void CEngine::PrintRoot() { CAutoTrace at(m_pmp); at.Os() << "Root Group:" << std::endl; m_pmemo->Pgroup(m_pmemo->PgroupRoot()->UlId())->OsPrint(at.Os()); at.Os() << std::endl; } //--------------------------------------------------------------------------- // @function: // CEngine::PrintOptCtxts // // @doc: // Print main optimization context and optimal cost context // //--------------------------------------------------------------------------- void CEngine::PrintOptCtxts() { CAutoTrace at(m_pmp); COptimizationContext *poc = m_pmemo->PgroupRoot()->PocLookupBest(m_pmp, m_pdrgpss->UlLength(), m_pqc->Prpp()); GPOS_ASSERT(NULL != poc); at.Os() << std::endl << "Main Opt Ctxt:" << std::endl; (void) poc->OsPrint(at.Os(), " "); at.Os() << std::endl; at.Os() << "Optimal Cost Ctxt:" << std::endl; (void) poc->PccBest()->OsPrint(at.Os()); at.Os() << std::endl; } #endif // GPOS_DEBUG //--------------------------------------------------------------------------- // @function: // CEngine::OsPrint // // @doc: // print function // //--------------------------------------------------------------------------- IOstream & CEngine::OsPrint ( IOstream &os ) const { return m_pmemo->OsPrint(os); } // EOF
27.046304
139
0.622725
ppmht
33e826c1feda4be83503d0b7ed8f4efa13cc959e
12,342
cc
C++
android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc
devasia1000/chromium
919a8a666862fb866a6bb7aa7f3ae8c0442b4828
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2019-02-03T05:19:48.000Z
2021-11-15T15:07:21.000Z
android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc
devasia1000/chromium
919a8a666862fb866a6bb7aa7f3ae8c0442b4828
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc
devasia1000/chromium
919a8a666862fb866a6bb7aa7f3ae8c0442b4828
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "android_webview/browser/input_stream.h" #include "android_webview/browser/net/android_stream_reader_url_request_job.h" #include "android_webview/browser/net/aw_url_request_job_factory.h" #include "android_webview/browser/net/input_stream_reader.h" #include "base/format_macros.h" #include "base/message_loop.h" #include "base/run_loop.h" #include "base/stringprintf.h" #include "net/url_request/url_request_job_factory_impl.h" #include "net/url_request/url_request_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" using android_webview::InputStream; using android_webview::InputStreamReader; using net::TestDelegate; using net::TestJobInterceptor; using net::TestNetworkDelegate; using net::TestURLRequestContext; using net::TestURLRequest; using testing::DoAll; using testing::Ge; using testing::Gt; using testing::InSequence; using testing::Invoke; using testing::InvokeWithoutArgs; using testing::NotNull; using testing::Return; using testing::SaveArg; using testing::SetArgPointee; using testing::StrictMock; using testing::Test; using testing::WithArg; using testing::WithArgs; using testing::_; // Some of the classes will DCHECK on a null InputStream (which is desirable). // The workaround is to use this class. None of the methods need to be // implemented as the mock InputStreamReader should never forward calls to the // InputStream. class NotImplInputStream : public InputStream { public: NotImplInputStream() {} virtual ~NotImplInputStream() {} virtual bool BytesAvailable(int* bytes_available) const OVERRIDE { NOTIMPLEMENTED(); return false; } virtual bool Skip(int64_t n, int64_t* bytes_skipped) OVERRIDE { NOTIMPLEMENTED(); return false; } virtual bool Read(net::IOBuffer* dest, int length, int* bytes_read) OVERRIDE { NOTIMPLEMENTED(); return false; } }; // Required in order to create an instance of AndroidStreamReaderURLRequestJob. class StreamReaderDelegate : public AndroidStreamReaderURLRequestJob::Delegate { public: StreamReaderDelegate() {} virtual scoped_ptr<InputStream> OpenInputStream( JNIEnv* env, const GURL& url) OVERRIDE { return make_scoped_ptr<InputStream>(new NotImplInputStream()); } virtual void OnInputStreamOpenFailed(net::URLRequest* request, bool* restart) OVERRIDE { *restart = false; } virtual bool GetMimeType(JNIEnv* env, net::URLRequest* request, android_webview::InputStream* stream, std::string* mime_type) OVERRIDE { return false; } virtual bool GetCharset(JNIEnv* env, net::URLRequest* request, android_webview::InputStream* stream, std::string* charset) OVERRIDE { return false; } }; class NullStreamReaderDelegate : public StreamReaderDelegate { public: NullStreamReaderDelegate() {} virtual scoped_ptr<InputStream> OpenInputStream( JNIEnv* env, const GURL& url) OVERRIDE { return make_scoped_ptr<InputStream>(NULL); } }; class MockInputStreamReader : public InputStreamReader { public: MockInputStreamReader() : InputStreamReader(new NotImplInputStream()) {} ~MockInputStreamReader() {} MOCK_METHOD1(Seek, int(const net::HttpByteRange& byte_range)); MOCK_METHOD2(ReadRawData, int(net::IOBuffer* buffer, int buffer_size)); }; class TestStreamReaderJob : public AndroidStreamReaderURLRequestJob { public: TestStreamReaderJob( net::URLRequest* request, net::NetworkDelegate* network_delegate, scoped_ptr<Delegate> delegate, scoped_ptr<InputStreamReader> stream_reader) : AndroidStreamReaderURLRequestJob(request, network_delegate, delegate.Pass()), stream_reader_(stream_reader.Pass()) { message_loop_proxy_ = base::MessageLoopProxy::current(); } virtual scoped_ptr<InputStreamReader> CreateStreamReader( InputStream* stream) OVERRIDE { return stream_reader_.Pass(); } protected: virtual ~TestStreamReaderJob() {} virtual base::TaskRunner* GetWorkerThreadRunner() OVERRIDE { return message_loop_proxy_.get(); } scoped_ptr<InputStreamReader> stream_reader_; scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; }; class AndroidStreamReaderURLRequestJobTest : public Test { public: AndroidStreamReaderURLRequestJobTest() : loop_(base::MessageLoop::TYPE_IO) {} protected: virtual void SetUp() { context_.set_job_factory(&factory_); context_.set_network_delegate(&network_delegate_); req_.reset( new TestURLRequest(GURL("content://foo"), &url_request_delegate_, &context_, &network_delegate_)); req_->set_method("GET"); } void SetRange(net::URLRequest* req, int first_byte, int last_byte) { net::HttpRequestHeaders headers; headers.SetHeader(net::HttpRequestHeaders::kRange, base::StringPrintf( "bytes=%" PRIuS "-%" PRIuS, first_byte, last_byte)); req->SetExtraRequestHeaders(headers); } void SetUpTestJob(scoped_ptr<InputStreamReader> stream_reader) { SetUpTestJob(stream_reader.Pass(), make_scoped_ptr(new StreamReaderDelegate()) .PassAs<AndroidStreamReaderURLRequestJob::Delegate>()); } void SetUpTestJob(scoped_ptr<InputStreamReader> stream_reader, scoped_ptr<AndroidStreamReaderURLRequestJob::Delegate> stream_reader_delegate) { TestStreamReaderJob* test_stream_reader_job = new TestStreamReaderJob( req_.get(), &network_delegate_, stream_reader_delegate.Pass(), stream_reader.Pass()); // The Interceptor is owned by the |factory_|. TestJobInterceptor* protocol_handler = new TestJobInterceptor; protocol_handler->set_main_intercept_job(test_stream_reader_job); bool set_protocol = factory_.SetProtocolHandler("http", protocol_handler); DCHECK(set_protocol); protocol_handler = new TestJobInterceptor; protocol_handler->set_main_intercept_job(test_stream_reader_job); set_protocol = factory_.SetProtocolHandler("content", protocol_handler); DCHECK(set_protocol); } base::MessageLoop loop_; TestURLRequestContext context_; android_webview::AwURLRequestJobFactory factory_; TestDelegate url_request_delegate_; TestNetworkDelegate network_delegate_; scoped_ptr<TestURLRequest> req_; }; TEST_F(AndroidStreamReaderURLRequestJobTest, ReadEmptyStream) { scoped_ptr<StrictMock<MockInputStreamReader> > stream_reader( new StrictMock<MockInputStreamReader>()); { InSequence s; EXPECT_CALL(*stream_reader, Seek(_)) .WillOnce(Return(0)); EXPECT_CALL(*stream_reader, ReadRawData(NotNull(), Gt(0))) .WillOnce(Return(0)); } SetUpTestJob(stream_reader.PassAs<InputStreamReader>()); req_->Start(); // The TestDelegate will quit the message loop on request completion. base::MessageLoop::current()->Run(); EXPECT_FALSE(url_request_delegate_.request_failed()); EXPECT_EQ(1, network_delegate_.completed_requests()); EXPECT_EQ(0, network_delegate_.error_count()); EXPECT_EQ(200, req_->GetResponseCode()); } TEST_F(AndroidStreamReaderURLRequestJobTest, ReadWithNullStream) { SetUpTestJob(scoped_ptr<InputStreamReader>(), make_scoped_ptr(new NullStreamReaderDelegate()) .PassAs<AndroidStreamReaderURLRequestJob::Delegate>()); req_->Start(); // The TestDelegate will quit the message loop on request completion. base::MessageLoop::current()->Run(); // The request_failed() method is named confusingly but all it checks is // whether the request got as far as calling NotifyHeadersComplete. EXPECT_FALSE(url_request_delegate_.request_failed()); EXPECT_EQ(1, network_delegate_.completed_requests()); // A null input stream shouldn't result in an error. See crbug.com/180950. EXPECT_EQ(0, network_delegate_.error_count()); EXPECT_EQ(404, req_->GetResponseCode()); } TEST_F(AndroidStreamReaderURLRequestJobTest, ReadPartOfStream) { const int bytes_available = 128; const int offset = 32; const int bytes_to_read = bytes_available - offset; scoped_ptr<StrictMock<MockInputStreamReader> > stream_reader( new StrictMock<MockInputStreamReader>()); { InSequence s; EXPECT_CALL(*stream_reader, Seek(_)) .WillOnce(Return(bytes_available)); EXPECT_CALL(*stream_reader, ReadRawData(NotNull(), Ge(bytes_to_read))) .WillOnce(Return(bytes_to_read/2)); EXPECT_CALL(*stream_reader, ReadRawData(NotNull(), Ge(bytes_to_read))) .WillOnce(Return(bytes_to_read/2)); EXPECT_CALL(*stream_reader, ReadRawData(NotNull(), Ge(bytes_to_read))) .WillOnce(Return(0)); } SetUpTestJob(stream_reader.PassAs<InputStreamReader>()); SetRange(req_.get(), offset, bytes_available); req_->Start(); base::MessageLoop::current()->Run(); EXPECT_FALSE(url_request_delegate_.request_failed()); EXPECT_EQ(bytes_to_read, url_request_delegate_.bytes_received()); EXPECT_EQ(1, network_delegate_.completed_requests()); EXPECT_EQ(0, network_delegate_.error_count()); } TEST_F(AndroidStreamReaderURLRequestJobTest, ReadStreamWithMoreAvailableThanActual) { const int bytes_available_reported = 190; const int bytes_available = 128; const int offset = 0; const int bytes_to_read = bytes_available - offset; scoped_ptr<StrictMock<MockInputStreamReader> > stream_reader( new StrictMock<MockInputStreamReader>()); { InSequence s; EXPECT_CALL(*stream_reader, Seek(_)) .WillOnce(Return(bytes_available_reported)); EXPECT_CALL(*stream_reader, ReadRawData(NotNull(), Ge(bytes_to_read))) .WillOnce(Return(bytes_available)); EXPECT_CALL(*stream_reader, ReadRawData(NotNull(), Ge(bytes_to_read))) .WillOnce(Return(0)); } SetUpTestJob(stream_reader.PassAs<InputStreamReader>()); SetRange(req_.get(), offset, bytes_available_reported); req_->Start(); base::MessageLoop::current()->Run(); EXPECT_FALSE(url_request_delegate_.request_failed()); EXPECT_EQ(bytes_to_read, url_request_delegate_.bytes_received()); EXPECT_EQ(1, network_delegate_.completed_requests()); EXPECT_EQ(0, network_delegate_.error_count()); } TEST_F(AndroidStreamReaderURLRequestJobTest, DeleteJobMidWaySeek) { const int offset = 20; const int bytes_available = 128; base::RunLoop loop; scoped_ptr<StrictMock<MockInputStreamReader> > stream_reader( new StrictMock<MockInputStreamReader>()); EXPECT_CALL(*stream_reader, Seek(_)) .WillOnce(DoAll(InvokeWithoutArgs(&loop, &base::RunLoop::Quit), Return(bytes_available))); ON_CALL(*stream_reader, ReadRawData(_, _)) .WillByDefault(Return(0)); SetUpTestJob(stream_reader.PassAs<InputStreamReader>()); SetRange(req_.get(), offset, bytes_available); req_->Start(); loop.Run(); EXPECT_EQ(0, network_delegate_.completed_requests()); req_->Cancel(); EXPECT_EQ(1, network_delegate_.completed_requests()); } TEST_F(AndroidStreamReaderURLRequestJobTest, DeleteJobMidWayRead) { const int offset = 20; const int bytes_available = 128; base::RunLoop loop; scoped_ptr<StrictMock<MockInputStreamReader> > stream_reader( new StrictMock<MockInputStreamReader>()); net::CompletionCallback read_completion_callback; EXPECT_CALL(*stream_reader, Seek(_)) .WillOnce(Return(bytes_available)); EXPECT_CALL(*stream_reader, ReadRawData(_, _)) .WillOnce(DoAll(InvokeWithoutArgs(&loop, &base::RunLoop::Quit), Return(bytes_available))); SetUpTestJob(stream_reader.PassAs<InputStreamReader>()); SetRange(req_.get(), offset, bytes_available); req_->Start(); loop.Run(); EXPECT_EQ(0, network_delegate_.completed_requests()); req_->Cancel(); EXPECT_EQ(1, network_delegate_.completed_requests()); }
34.47486
80
0.719737
devasia1000
33e9b53681b1e0f060293406dca6010ade2c5509
1,310
hpp
C++
ZeroMQ-testing/ZeroMQ-req/TestMessage.hpp
James-Chapman/zeromq-snippets
d09248f7f82d63b5c769dda765b85ebfb76ff01c
[ "BSD-2-Clause" ]
null
null
null
ZeroMQ-testing/ZeroMQ-req/TestMessage.hpp
James-Chapman/zeromq-snippets
d09248f7f82d63b5c769dda765b85ebfb76ff01c
[ "BSD-2-Clause" ]
null
null
null
ZeroMQ-testing/ZeroMQ-req/TestMessage.hpp
James-Chapman/zeromq-snippets
d09248f7f82d63b5c769dda765b85ebfb76ff01c
[ "BSD-2-Clause" ]
null
null
null
#ifndef _TESTMESSAGE_H_ #define _TESTMESSAGE_H_ #include <iostream> #include <sstream> #include <cstdint> #include <vector> /** * Struct representing the data to send down the wire */ struct TestMessage { uint32_t m_MessageSize; uint16_t m_p1Size; uint16_t m_p2Size; std::string m_p1; std::string m_p2; std::ostream& serialize(std::ostream &out) const { out << m_MessageSize; out << ","; out << m_p1Size; out << ","; out << m_p2Size; out << ","; out << m_p1; out << ","; out << m_p2; return out; } std::istream& deserialize(std::istream &in) { if (in) { char comma; in >> m_MessageSize; in >> comma; in >> m_p1Size; in >> comma; in >> m_p2Size; in >> comma; { std::vector<char> tmp(m_p1Size); in.read(&tmp[0], m_p1Size); m_p1.assign(&tmp[0], m_p1Size); } in >> comma; { std::vector<char> tmp(m_p2Size); in.read(&tmp[0], m_p2Size); m_p2.assign(&tmp[0], m_p2Size); } } return in; } }; #endif // _TESTMESSAGE_H_
21.129032
52
0.466412
James-Chapman
33eafe4ed68ddad78c0bc1d941abf87b50f88a78
10,597
cpp
C++
src/misc/object_tracker.cpp
3togo/Anvil
c54059b0972c3261a516d9b6960b45e54ceaea15
[ "MIT" ]
589
2016-05-18T02:39:39.000Z
2020-05-01T18:27:16.000Z
src/misc/object_tracker.cpp
3togo/Anvil
c54059b0972c3261a516d9b6960b45e54ceaea15
[ "MIT" ]
120
2016-06-15T15:18:22.000Z
2020-05-01T02:26:31.000Z
src/misc/object_tracker.cpp
3togo/Anvil
c54059b0972c3261a516d9b6960b45e54ceaea15
[ "MIT" ]
88
2016-06-02T19:27:03.000Z
2020-04-19T06:27:45.000Z
// // Copyright (c) 2017-2018 Advanced Micro Devices, Inc. All rights reserved. // // 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 "misc/debug.h" #include "misc/object_tracker.h" #include <algorithm> static Anvil::ObjectTracker* object_tracker_ptr = nullptr; /** Constructor. */ Anvil::ObjectTracker::ObjectTracker() :CallbacksSupportProvider(OBJECT_TRACKER_CALLBACK_ID_COUNT) { /* Stub */ } /* Please see header for specification */ void Anvil::ObjectTracker::destroy() { delete object_tracker_ptr; object_tracker_ptr = nullptr; } /* Please see header for specification */ Anvil::ObjectTracker* Anvil::ObjectTracker::get() { if (object_tracker_ptr == nullptr) { object_tracker_ptr = new ObjectTracker(); } return object_tracker_ptr; } /* Please see header for specification */ void Anvil::ObjectTracker::check_for_leaks() const { std::unique_lock<std::mutex> lock(m_cs); for (const auto& current_object_type_alloc_data : m_object_allocations) { const uint32_t n_object_allocations = static_cast<uint32_t>(current_object_type_alloc_data.second.size() ); if (n_object_allocations > 0) { fprintf(stdout, "The following %s instances have not been released:\n", get_object_type_name(current_object_type_alloc_data.first) ); for (const auto& current_alloc : current_object_type_alloc_data.second) { fprintf(stdout, "[%d]. %p\n", current_alloc.n_allocation, current_alloc.object_ptr); } fprintf(stdout, "\n"); } } } /** Converts @param object_type enum to a null-terminated string. * * @param object_type Internal wrapper object type to return the string for. * * @return As per description. **/ const char* Anvil::ObjectTracker::get_object_type_name(const Anvil::ObjectType& in_object_type) const { const char* result_ptr = "?!"; switch (in_object_type) { case Anvil::ObjectType::BUFFER: result_ptr = "Buffer"; break; case Anvil::ObjectType::BUFFER_VIEW: result_ptr = "Buffer View"; break; case Anvil::ObjectType::COMMAND_BUFFER: result_ptr = "Command Buffer"; break; case Anvil::ObjectType::COMMAND_POOL: result_ptr = "Command Pool"; break; case Anvil::ObjectType::DESCRIPTOR_POOL: result_ptr = "Descriptor Pool"; break; case Anvil::ObjectType::DESCRIPTOR_SET: result_ptr = "Descriptor Set"; break; case Anvil::ObjectType::DESCRIPTOR_SET_LAYOUT: result_ptr = "Descriptor Set Layout"; break; case Anvil::ObjectType::DESCRIPTOR_UPDATE_TEMPLATE: result_ptr = "Descriptor Update Template"; break; case Anvil::ObjectType::DEVICE: result_ptr = "Device"; break; case Anvil::ObjectType::EVENT: result_ptr = "Event"; break; case Anvil::ObjectType::FENCE: result_ptr = "Fence"; break; case Anvil::ObjectType::FRAMEBUFFER: result_ptr = "Framebuffer"; break; case Anvil::ObjectType::IMAGE: result_ptr = "Image"; break; case Anvil::ObjectType::IMAGE_VIEW: result_ptr = "Image View"; break; case Anvil::ObjectType::INSTANCE: result_ptr = "Instance"; break; case Anvil::ObjectType::PHYSICAL_DEVICE: result_ptr = "Physical Device"; break; case Anvil::ObjectType::PIPELINE_CACHE: result_ptr = "Pipeline Cache"; break; case Anvil::ObjectType::PIPELINE_LAYOUT: result_ptr = "Pipeline Layout"; break; case Anvil::ObjectType::QUERY_POOL: result_ptr = "Query Pool"; break; case Anvil::ObjectType::QUEUE: result_ptr = "Queue"; break; case Anvil::ObjectType::RENDER_PASS: result_ptr = "Render Pass"; break; case Anvil::ObjectType::RENDERING_SURFACE: result_ptr = "Rendering Surface"; break; case Anvil::ObjectType::SAMPLER: result_ptr = "Sampler"; break; case Anvil::ObjectType::SEMAPHORE: result_ptr = "Semaphore"; break; case Anvil::ObjectType::SHADER_MODULE: result_ptr = "Shader Module"; break; case Anvil::ObjectType::SWAPCHAIN: result_ptr = "Swapchain"; break; case Anvil::ObjectType::ANVIL_COMPUTE_PIPELINE_MANAGER: result_ptr = "Anvil Compute Pipeline Manager"; break; case Anvil::ObjectType::ANVIL_DESCRIPTOR_SET_GROUP: result_ptr = "Anvil Descriptor Set Group"; break; case Anvil::ObjectType::ANVIL_DESCRIPTOR_SET_LAYOUT_MANAGER: result_ptr = "Anvil Descriptor Set Layout Manager"; break; case Anvil::ObjectType::ANVIL_GLSL_SHADER_TO_SPIRV_GENERATOR: result_ptr = "Anvil GLSL Shader->SPIRV Generator"; break; case Anvil::ObjectType::ANVIL_GRAPHICS_PIPELINE_MANAGER: result_ptr = "Anvil Graphics Pipeline Manager"; break; case Anvil::ObjectType::ANVIL_MEMORY_BLOCK: result_ptr = "Anvil Memory Block"; break; case Anvil::ObjectType::ANVIL_PIPELINE_LAYOUT_MANAGER: result_ptr = "Anvil Pipeline Layout Manager"; break; default: { anvil_assert_fail(); } } return result_ptr; } /* Please see header for specification */ void* Anvil::ObjectTracker::get_object_at_index(const ObjectType& in_object_type, uint32_t in_alloc_index) const { std::unique_lock<std::mutex> lock (m_cs); void* result(nullptr); if (m_object_allocations[in_object_type].size() > in_alloc_index) { result = m_object_allocations[in_object_type][in_alloc_index].object_ptr; } return result; } /* Please see header for specification */ void Anvil::ObjectTracker::register_object(const ObjectType& in_object_type, void* in_object_ptr) { anvil_assert(in_object_ptr != nullptr); { std::unique_lock<std::mutex> lock(m_cs); m_object_allocations[in_object_type].push_back(ObjectAllocation(m_n_objects_allocated_array[in_object_type]++, in_object_ptr) ); } /* Notify any observers about the new object */ OnObjectRegisteredCallbackArgument callback_arg(in_object_type, in_object_ptr); if (in_object_type == Anvil::ObjectType::ANVIL_GLSL_SHADER_TO_SPIRV_GENERATOR) { callback_safe(OBJECT_TRACKER_CALLBACK_ID_ON_GLSL_SHADER_TO_SPIRV_GENERATOR_OBJECT_REGISTERED, &callback_arg); } else if (in_object_type == Anvil::ObjectType::SHADER_MODULE) { callback_safe(OBJECT_TRACKER_CALLBACK_ID_ON_SHADER_MODULE_OBJECT_REGISTERED, &callback_arg); } } /* Please see header for specification */ void Anvil::ObjectTracker::unregister_object(const ObjectType& in_object_type, void* in_object_ptr) { OnObjectAboutToBeUnregisteredCallbackArgument callback_arg(in_object_type, in_object_ptr); { std::unique_lock<std::mutex> lock (m_cs); auto object_allocation_iterator(std::find(m_object_allocations[in_object_type].begin(), m_object_allocations[in_object_type].end(), in_object_ptr) ); if (object_allocation_iterator == m_object_allocations[in_object_type].end() ) { anvil_assert_fail(); goto end; } m_object_allocations[in_object_type].erase(object_allocation_iterator); } /* Notify any observers about the event. */ if (in_object_type == Anvil::ObjectType::DEVICE) { callback_safe(OBJECT_TRACKER_CALLBACK_ID_ON_DEVICE_OBJECT_ABOUT_TO_BE_UNREGISTERED, &callback_arg); } else if (in_object_type == Anvil::ObjectType::ANVIL_GLSL_SHADER_TO_SPIRV_GENERATOR) { callback_safe(OBJECT_TRACKER_CALLBACK_ID_ON_GLSL_SHADER_TO_SPIRV_GENERATOR_OBJECT_ABOUT_TO_BE_UNREGISTERED, &callback_arg); } else if (in_object_type == Anvil::ObjectType::PIPELINE_LAYOUT) { callback_safe(OBJECT_TRACKER_CALLBACK_ID_ON_PIPELINE_LAYOUT_OBJECT_ABOUT_TO_BE_UNREGISTERED, &callback_arg); } else if (in_object_type == Anvil::ObjectType::SHADER_MODULE) { callback_safe(OBJECT_TRACKER_CALLBACK_ID_ON_SHADER_MODULE_OBJECT_ABOUT_TO_BE_UNREGISTERED, &callback_arg); } end: ; }
44.71308
128
0.606964
3togo
33ed40bb55e7845acd4c00ac251507ba899ec019
13,974
cpp
C++
EchoCanceller.cpp
kebbbnnn/libtgvoip
8d8522a5e89f8bb44119d4d35f94a3f18d61f115
[ "Unlicense" ]
null
null
null
EchoCanceller.cpp
kebbbnnn/libtgvoip
8d8522a5e89f8bb44119d4d35f94a3f18d61f115
[ "Unlicense" ]
null
null
null
EchoCanceller.cpp
kebbbnnn/libtgvoip
8d8522a5e89f8bb44119d4d35f94a3f18d61f115
[ "Unlicense" ]
1
2021-05-03T17:24:04.000Z
2021-05-03T17:24:04.000Z
// // libtgvoip is free and unencumbered public domain software. // For more information, see http://unlicense.org or the UNLICENSE file // you should have received with this source code distribution. // #include "EchoCanceller.h" #include "audio/AudioOutput.h" #include "audio/AudioInput.h" #include "logging.h" #include <string.h> #include <stdio.h> #ifndef TGVOIP_NO_DSP #ifndef TGVOIP_USE_DESKTOP_DSP #include "webrtc/modules/audio_processing/aecm/echo_control_mobile.h" #include "webrtc/modules/audio_processing/ns/noise_suppression_x.h" #else #include "webrtc/modules/audio_processing/aec/echo_cancellation.h" //#include "webrtc/modules/audio_processing/ns/noise_suppression.h" #include "webrtc/modules/audio_processing/ns/noise_suppression_x.h" #endif #include "webrtc/modules/audio_processing/splitting_filter.h" #include "webrtc/common_audio/channel_buffer.h" #include "webrtc/modules/audio_processing/agc/legacy/gain_control.h" #endif #define AEC_FRAME_SIZE 160 #define OFFSET_STEP AEC_FRAME_SIZE*2 //#define CLAMP(x, min, max) (x<max ? (x>min ? x : min) : max) #define CLAMP(x, min, max) x using namespace tgvoip; #ifdef TGVOIP_USE_DESKTOP_DSP namespace webrtc{ void WebRtcAec_enable_delay_agnostic(AecCore* self, int enable); } #endif EchoCanceller::EchoCanceller(bool enableAEC, bool enableNS, bool enableAGC){ #ifndef TGVOIP_NO_DSP this->enableAEC=enableAEC; this->enableAGC=enableAGC; this->enableNS=enableNS; isOn=true; splittingFilter=new webrtc::SplittingFilter(1, 3, 960); splittingFilterFarend=new webrtc::SplittingFilter(1, 3, 960); splittingFilterIn=new webrtc::IFChannelBuffer(960, 1, 1); splittingFilterFarendIn=new webrtc::IFChannelBuffer(960, 1, 1); splittingFilterOut=new webrtc::IFChannelBuffer(960, 1, 3); splittingFilterFarendOut=new webrtc::IFChannelBuffer(960, 1, 3); if(enableAEC){ #ifndef TGVOIP_USE_DESKTOP_DSP aec=WebRtcAecm_Create(); WebRtcAecm_Init(aec, 16000); AecmConfig cfg; cfg.cngMode=AecmFalse; cfg.echoMode=0; WebRtcAecm_set_config(aec, cfg); #else aec=webrtc::WebRtcAec_Create(); webrtc::WebRtcAec_Init(aec, 48000, 48000); webrtc::WebRtcAec_enable_delay_agnostic(webrtc::WebRtcAec_aec_core(aec), 1); webrtc::AecConfig config; config.metricsMode=webrtc::kAecFalse; config.nlpMode=webrtc::kAecNlpAggressive; config.skewMode=webrtc::kAecFalse; config.delay_logging=webrtc::kAecFalse; webrtc::WebRtcAec_set_config(aec, config); #endif farendQueue=new BlockingQueue<int16_t*>(11); farendBufferPool=new BufferPool(960*2, 10); running=true; bufferFarendThread=new Thread(new MethodPointer<EchoCanceller>(&EchoCanceller::RunBufferFarendThread, this), NULL); bufferFarendThread->Start(); }else{ aec=NULL; } if(enableNS){ //#ifndef TGVOIP_USE_DESKTOP_DSP ns=WebRtcNsx_Create(); WebRtcNsx_Init((NsxHandle*)ns, 48000); WebRtcNsx_set_policy((NsxHandle*)ns, 0); /*#else ns=WebRtcNs_Create(); WebRtcNs_Init((NsHandle*)ns, 48000); WebRtcNs_set_policy((NsHandle*)ns, 1); #endif*/ }else{ ns=NULL; } if(enableAGC){ agc=WebRtcAgc_Create(); WebRtcAgcConfig agcConfig; agcConfig.compressionGaindB = 20; agcConfig.limiterEnable = 1; agcConfig.targetLevelDbfs = 9; WebRtcAgc_Init(agc, 0, 255, kAgcModeAdaptiveDigital, 48000); WebRtcAgc_set_config(agc, agcConfig); agcMicLevel=0; }else{ agc=NULL; } #else this->enableAEC=this->enableAGC=enableAGC=this->enableNS=enableNS=false; isOn=true; #endif } EchoCanceller::~EchoCanceller(){ #ifndef TGVOIP_NO_DSP if(enableAEC){ running=false; farendQueue->Put(NULL); bufferFarendThread->Join(); delete bufferFarendThread; delete farendQueue; delete farendBufferPool; #ifndef TGVOIP_USE_DESKTOP_DSP WebRtcAecm_Free(aec); #else webrtc::WebRtcAec_Free(aec); #endif } if(enableNS){ //#ifndef TGVOIP_USE_DESKTOP_DSP WebRtcNsx_Free((NsxHandle*)ns); /*#else WebRtcNs_Free((NsHandle*)ns); #endif*/ } if(enableAGC){ WebRtcAgc_Free(agc); } //webrtc::WebRtcAec_Free(state); delete (webrtc::SplittingFilter*)splittingFilter; delete (webrtc::SplittingFilter*)splittingFilterFarend; delete (webrtc::IFChannelBuffer*)splittingFilterIn; delete (webrtc::IFChannelBuffer*)splittingFilterOut; delete (webrtc::IFChannelBuffer*)splittingFilterFarendIn; delete (webrtc::IFChannelBuffer*)splittingFilterFarendOut; #endif } void EchoCanceller::Start(){ } void EchoCanceller::Stop(){ } void EchoCanceller::SpeakerOutCallback(unsigned char* data, size_t len){ if(len!=960*2 || !enableAEC || !isOn) return; /*size_t offset=0; while(offset<len){ WebRtcAecm_BufferFarend(state, (int16_t*)(data+offset), AEC_FRAME_SIZE); offset+=OFFSET_STEP; }*/ #ifndef TGVOIP_NO_DSP int16_t* buf=(int16_t*)farendBufferPool->Get(); if(buf){ memcpy(buf, data, 960*2); farendQueue->Put(buf); } #endif } #ifndef TGVOIP_NO_DSP void EchoCanceller::RunBufferFarendThread(void* arg){ while(running){ int16_t* samplesIn=farendQueue->GetBlocking(); if(samplesIn){ webrtc::IFChannelBuffer* bufIn=(webrtc::IFChannelBuffer*) splittingFilterFarendIn; webrtc::IFChannelBuffer* bufOut=(webrtc::IFChannelBuffer*) splittingFilterFarendOut; memcpy(bufIn->ibuf()->bands(0)[0], samplesIn, 960*2); farendBufferPool->Reuse((unsigned char *) samplesIn); ((webrtc::SplittingFilter*)splittingFilterFarend)->Analysis(bufIn, bufOut); aecMutex.Lock(); //outstandingFarendFrames++; //LOGV("BufferFarend: %d frames", outstandingFarendFrames); #ifndef TGVOIP_USE_DESKTOP_DSP WebRtcAecm_BufferFarend(aec, bufOut->ibuf_const()->bands(0)[0], 160); WebRtcAecm_BufferFarend(aec, bufOut->ibuf_const()->bands(0)[0]+160, 160); #else webrtc::WebRtcAec_BufferFarend(aec, bufOut->fbuf_const()->bands(0)[0], 160); webrtc::WebRtcAec_BufferFarend(aec, bufOut->fbuf_const()->bands(0)[0]+160, 160); #endif aecMutex.Unlock(); didBufferFarend=true; } } } #endif void EchoCanceller::Enable(bool enabled){ isOn=enabled; } void EchoCanceller::ProcessInput(unsigned char* data, unsigned char* out, size_t len){ int i; if(!isOn || (!enableAEC && !enableAGC && !enableNS)){ memcpy(out, data, len); return; } #ifndef TGVOIP_NO_DSP int16_t* samplesIn=(int16_t*)data; int16_t* samplesOut=(int16_t*)out; webrtc::IFChannelBuffer* bufIn=(webrtc::IFChannelBuffer*) splittingFilterIn; webrtc::IFChannelBuffer* bufOut=(webrtc::IFChannelBuffer*) splittingFilterOut; memcpy(bufIn->ibuf()->bands(0)[0], samplesIn, 960*2); ((webrtc::SplittingFilter*)splittingFilter)->Analysis(bufIn, bufOut); #ifndef TGVOIP_USE_DESKTOP_DSP if(enableAEC && enableNS){ int16_t _nsOut[3][320]; int16_t* nsIn[3]; int16_t* nsOut[3]; for(i=0;i<3;i++){ nsIn[i]=(int16_t*)bufOut->ibuf_const()->bands(0)[i]; nsOut[i]=_nsOut[i]; } WebRtcNsx_Process((NsxHandle*)ns, (const short *const *) nsIn, 3, nsOut); for(i=0;i<3;i++){ nsOut[i]+=160; nsIn[i]+=160; } WebRtcNsx_Process((NsxHandle*)ns, (const short *const *) nsIn, 3, nsOut); memcpy(bufOut->ibuf()->bands(0)[1], _nsOut[1], 320*2*2); aecMutex.Lock(); WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0], _nsOut[0], samplesOut, AEC_FRAME_SIZE, (int16_t) tgvoip::audio::AudioOutput::GetEstimatedDelay()); WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0]+160, _nsOut[0]+160, samplesOut+160, AEC_FRAME_SIZE, (int16_t) (tgvoip::audio::AudioOutput::GetEstimatedDelay()+audio::AudioInput::GetEstimatedDelay())); aecMutex.Unlock(); memcpy(bufOut->ibuf()->bands(0)[0], samplesOut, 320*2); }else if(enableAEC){ aecMutex.Lock(); WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0], NULL, samplesOut, AEC_FRAME_SIZE, (int16_t) tgvoip::audio::AudioOutput::GetEstimatedDelay()); WebRtcAecm_Process(aec, bufOut->ibuf()->bands(0)[0]+160, NULL, samplesOut+160, AEC_FRAME_SIZE, (int16_t) (tgvoip::audio::AudioOutput::GetEstimatedDelay()+audio::AudioInput::GetEstimatedDelay())); aecMutex.Unlock(); memcpy(bufOut->ibuf()->bands(0)[0], samplesOut, 320*2); }else if(enableNS){ int16_t _nsOut[3][320]; int16_t* nsIn[3]; int16_t* nsOut[3]; for(i=0;i<3;i++){ nsIn[i]=(int16_t*)bufOut->ibuf_const()->bands(0)[i]; nsOut[i]=_nsOut[i]; } WebRtcNsx_Process((NsxHandle*)ns, (const short *const *) nsIn, 3, nsOut); for(i=0;i<3;i++){ nsOut[i]+=160; nsIn[i]+=160; } WebRtcNsx_Process((NsxHandle*)ns, (const short *const *) nsIn, 3, nsOut); memcpy(bufOut->ibuf()->bands(0)[0], _nsOut[0], 320*2); memcpy(bufOut->ibuf()->bands(0)[1], _nsOut[1], 320*2); memcpy(bufOut->ibuf()->bands(0)[2], _nsOut[2], 320*2); } #else /*if(enableNS){ float _nsOut[3][320]; const float* nsIn[3]; float* nsOut[3]; for(i=0;i<3;i++){ nsIn[i]=bufOut->fbuf_const()->bands(0)[i]; nsOut[i]=_nsOut[i]; } WebRtcNs_Process((NsHandle*)ns, nsIn, 3, nsOut); for(i=0;i<3;i++){ nsOut[i]+=160; nsIn[i]+=160; } WebRtcNs_Process((NsHandle*)ns, nsIn, 3, nsOut); memcpy(bufOut->fbuf()->bands(0)[0], _nsOut[0], 320*4); memcpy(bufOut->fbuf()->bands(0)[1], _nsOut[1], 320*4); memcpy(bufOut->fbuf()->bands(0)[2], _nsOut[2], 320*4); }*/ if(enableNS){ int16_t _nsOut[3][320]; int16_t* nsIn[3]; int16_t* nsOut[3]; for(i=0;i<3;i++){ nsIn[i]=(int16_t*)bufOut->ibuf_const()->bands(0)[i]; nsOut[i]=_nsOut[i]; } WebRtcNsx_Process((NsxHandle*)ns, (const short *const *)nsIn, 3, nsOut); for(i=0;i<3;i++){ nsOut[i]+=160; nsIn[i]+=160; } WebRtcNsx_Process((NsxHandle*)ns, (const short *const *)nsIn, 3, nsOut); memcpy(bufOut->ibuf()->bands(0)[0], _nsOut[0], 320*2); memcpy(bufOut->ibuf()->bands(0)[1], _nsOut[1], 320*2); memcpy(bufOut->ibuf()->bands(0)[2], _nsOut[2], 320*2); } if(enableAEC){ const float* aecIn[3]; float* aecOut[3]; float _aecOut[3][320]; for(i=0;i<3;i++){ aecIn[i]=bufOut->fbuf_const()->bands(0)[i]; aecOut[i]=_aecOut[i]; } webrtc::WebRtcAec_Process(aec, aecIn, 3, aecOut, AEC_FRAME_SIZE, audio::AudioOutput::GetEstimatedDelay()+audio::AudioInput::GetEstimatedDelay(), 0); for(i=0;i<3;i++){ aecOut[i]+=160; aecIn[i]+=160; } webrtc::WebRtcAec_Process(aec, aecIn, 3, aecOut, AEC_FRAME_SIZE, audio::AudioOutput::GetEstimatedDelay()+audio::AudioInput::GetEstimatedDelay(), 0); //outstandingFarendFrames--; //LOGV("Process: %d frames", outstandingFarendFrames); memcpy(bufOut->fbuf()->bands(0)[0], _aecOut[0], 320*4); memcpy(bufOut->fbuf()->bands(0)[1], _aecOut[1], 320*4); memcpy(bufOut->fbuf()->bands(0)[2], _aecOut[2], 320*4); } #endif if(enableAGC){ int16_t _agcOut[3][320]; int16_t* agcIn[3]; int16_t* agcOut[3]; for(i=0;i<3;i++){ agcIn[i]=(int16_t*)bufOut->ibuf_const()->bands(0)[i]; agcOut[i]=_agcOut[i]; } uint8_t saturation; WebRtcAgc_AddMic(agc, agcIn, 3, 160); WebRtcAgc_Process(agc, (const int16_t *const *) agcIn, 3, 160, agcOut, agcMicLevel, &agcMicLevel, 0, &saturation); for(i=0;i<3;i++){ agcOut[i]+=160; agcIn[i]+=160; } WebRtcAgc_AddMic(agc, agcIn, 3, 160); WebRtcAgc_Process(agc, (const int16_t *const *) agcIn, 3, 160, agcOut, agcMicLevel, &agcMicLevel, 0, &saturation); //LOGV("AGC mic level %d", agcMicLevel); memcpy(bufOut->ibuf()->bands(0)[0], _agcOut[0], 320*2); memcpy(bufOut->ibuf()->bands(0)[1], _agcOut[1], 320*2); memcpy(bufOut->ibuf()->bands(0)[2], _agcOut[2], 320*2); } ((webrtc::SplittingFilter*)splittingFilter)->Synthesis(bufOut, bufIn); memcpy(samplesOut, bufIn->ibuf_const()->bands(0)[0], 960*2); #endif } void EchoCanceller::SetAECStrength(int strength){ #ifndef TGVOIP_NO_DSP if(aec){ #ifndef TGVOIP_USE_DESKTOP_DSP AecmConfig cfg; cfg.cngMode=AecmFalse; cfg.echoMode=(int16_t) strength; WebRtcAecm_set_config(aec, cfg); #endif } #endif } AudioEffect::~AudioEffect(){ } void AudioEffect::SetPassThrough(bool passThrough){ this->passThrough=passThrough; } AutomaticGainControl::AutomaticGainControl(){ #ifndef TGVOIP_NO_DSP splittingFilter=new webrtc::SplittingFilter(1, 3, 960); splittingFilterIn=new webrtc::IFChannelBuffer(960, 1, 1); splittingFilterOut=new webrtc::IFChannelBuffer(960, 1, 3); agc=WebRtcAgc_Create(); WebRtcAgcConfig agcConfig; agcConfig.compressionGaindB = 9; agcConfig.limiterEnable = 1; agcConfig.targetLevelDbfs = 3; WebRtcAgc_Init(agc, 0, 255, kAgcModeAdaptiveDigital, 48000); WebRtcAgc_set_config(agc, agcConfig); agcMicLevel=0; #endif } AutomaticGainControl::~AutomaticGainControl(){ #ifndef TGVOIP_NO_DSP delete (webrtc::SplittingFilter*)splittingFilter; delete (webrtc::IFChannelBuffer*)splittingFilterIn; delete (webrtc::IFChannelBuffer*)splittingFilterOut; WebRtcAgc_Free(agc); #endif } void AutomaticGainControl::Process(int16_t *inOut, size_t numSamples){ #ifndef TGVOIP_NO_DSP if(passThrough) return; if(numSamples!=960){ LOGW("AutomaticGainControl only works on 960-sample buffers (got %u samples)", (unsigned int)numSamples); return; } //LOGV("processing frame through AGC"); webrtc::IFChannelBuffer* bufIn=(webrtc::IFChannelBuffer*) splittingFilterIn; webrtc::IFChannelBuffer* bufOut=(webrtc::IFChannelBuffer*) splittingFilterOut; memcpy(bufIn->ibuf()->bands(0)[0], inOut, 960*2); ((webrtc::SplittingFilter*)splittingFilter)->Analysis(bufIn, bufOut); int i; int16_t _agcOut[3][320]; int16_t* agcIn[3]; int16_t* agcOut[3]; for(i=0;i<3;i++){ agcIn[i]=(int16_t*)bufOut->ibuf_const()->bands(0)[i]; agcOut[i]=_agcOut[i]; } uint8_t saturation; WebRtcAgc_AddMic(agc, agcIn, 3, 160); WebRtcAgc_Process(agc, (const int16_t *const *) agcIn, 3, 160, agcOut, agcMicLevel, &agcMicLevel, 0, &saturation); for(i=0;i<3;i++){ agcOut[i]+=160; agcIn[i]+=160; } WebRtcAgc_AddMic(agc, agcIn, 3, 160); WebRtcAgc_Process(agc, (const int16_t *const *) agcIn, 3, 160, agcOut, agcMicLevel, &agcMicLevel, 0, &saturation); memcpy(bufOut->ibuf()->bands(0)[0], _agcOut[0], 320*2); memcpy(bufOut->ibuf()->bands(0)[1], _agcOut[1], 320*2); memcpy(bufOut->ibuf()->bands(0)[2], _agcOut[2], 320*2); ((webrtc::SplittingFilter*)splittingFilter)->Synthesis(bufOut, bufIn); memcpy(inOut, bufIn->ibuf_const()->bands(0)[0], 960*2); #endif }
30.312364
206
0.714684
kebbbnnn
33ee39f036d47eeca1f02a556144d2ea0632affc
62,240
cpp
C++
cbits/coin/CglTwomir.cpp
amosr/limp-cbc
3d6b9c580c529c0a7151aa7c758305bdf626f0af
[ "MIT" ]
8
2015-05-11T04:18:49.000Z
2020-02-16T00:14:35.000Z
cbits/coin/CglTwomir.cpp
amosr/limp-cbc
3d6b9c580c529c0a7151aa7c758305bdf626f0af
[ "MIT" ]
9
2015-06-06T22:02:28.000Z
2020-02-01T22:03:59.000Z
cbits/coin/CglTwomir.cpp
amosr/limp-cbc
3d6b9c580c529c0a7151aa7c758305bdf626f0af
[ "MIT" ]
4
2015-05-20T22:04:53.000Z
2020-01-29T21:46:25.000Z
// $Id: CglTwomir.cpp 1132 2013-04-25 18:57:12Z stefan $ // Copyright (C) 2002, International Business Machines // Corporation and others. All Rights Reserved. // This code is licensed under the terms of the Eclipse Public License (EPL). #include <cstdlib> #include <cstdio> #include <cmath> #include <cfloat> #include <cassert> #include <iostream> #include "CoinPragma.hpp" #include "CoinHelperFunctions.hpp" #include "CoinPackedVector.hpp" #include "CoinPackedMatrix.hpp" #include "CoinIndexedVector.hpp" #include "OsiRowCutDebugger.hpp" #include "CoinFactorization.hpp" #include "CoinWarmStartBasis.hpp" #include "CoinFinite.hpp" #include "CoinPackedMatrix.hpp" #include "OsiRowCutDebugger.hpp" #include "CoinWarmStartBasis.hpp" #include "CglTwomir.hpp" class CoinWarmStartBasis; #define COIN_HAS_CLP_TWOMIR #ifdef COIN_HAS_CLP_TWOMIR #include "OsiClpSolverInterface.hpp" #endif #undef DGG_DEBUG_DGG //#define DGG_DEBUG_DGG 1 //#define CGL_DEBUG //#define CGL_DEBUG_ZERO #define q_max data->cparams.q_max #define q_min data->cparams.q_min #define t_max data->cparams.t_max #define t_min data->cparams.t_min #define a_max data->cparams.a_max #define max_elements data->cparams.max_elements #ifdef CGL_DEBUG // Declarations and defines for debug build. #define talk true namespace { const OsiSolverInterface *six ; } void write_cut( DGG_constraint_t *cut){ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! printf("2mir_test: cut: !!!!!!!!!!!!!!!!!!!!!!!***********************************\n"); for (int i=0; i<cut->nz; i++) { printf(" %12.10f x[%d] ", cut->coeff[i],cut->index[i]);} printf(" >= %12.10f \n", cut->rhs); } void testus( DGG_constraint_t *cut){ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // const OsiRowCutDebugger debugg(*six, "flugpl.mps"); const OsiRowCutDebugger debugg(*six, "egout.mps"); const OsiRowCutDebugger *debugger = &debugg; if (debugger&&!debugger->onOptimalPath(*six)) return; OsiRowCut rowcut; rowcut.setRow(cut->nz, cut->index, cut->coeff); rowcut.setUb(DBL_MAX); rowcut.setLb(cut->rhs); if(debugger->invalidCut(rowcut)){ write_cut(cut); //assert(0); } } #else // CGL_DEBUG #define talk false #endif // CGL_DEBUG //------------------------------------------------------------------- // Generate cuts //------------------------------------------------------------------- void CglTwomir::generateCuts(const OsiSolverInterface & si, OsiCuts & cs, const CglTreeInfo info ) { # ifdef CGL_DEBUG //!!!!!!!!!!!!!!!!!! six = &si; # endif const double * colUpper = si.getColUpper(); const double * colLower = si.getColLower(); const OsiSolverInterface * useSolver; #ifdef COIN_HAS_CLP_TWOMIR double * objective = NULL; OsiClpSolverInterface * clpSolver = dynamic_cast<OsiClpSolverInterface *>(originalSolver_); int numberOriginalRows; int numberColumns=si.getNumCols(); int twomirType=0; if (!clpSolver) { #endif useSolver=&si; // Temp - check if free variables int ncol = useSolver->getNumCols(); int numberFree=0; for (int i=0;i<ncol;i++) { if (colLower[i]<-1.0e20&&colUpper[i]>1.0e20) numberFree++; } if (numberFree) { #ifdef COIN_DEVELOP if (!info.inTree&&!info.pass) printf("CglTwoMir - %d free variables - returning\n",numberFree); #endif return; } #ifdef COIN_HAS_CLP_TWOMIR } else { useSolver = originalSolver_; assert (twomirType_); // check simplex is plausible if (!clpSolver->getNumRows()||numberColumns!=clpSolver->getNumCols()) { delete originalSolver_; originalSolver_=si.clone(); clpSolver = dynamic_cast<OsiClpSolverInterface *>(originalSolver_); assert (clpSolver); useSolver = originalSolver_; } ClpSimplex * simplex = clpSolver->getModelPtr(); numberOriginalRows = simplex->numberRows(); int numberRows = si.getNumRows(); assert (numberOriginalRows<=numberRows); // only do if different (unless type 2x) twomirType = twomirType_%10; int whenToDo = twomirType_/10; if (whenToDo==2 ||(numberRows>numberOriginalRows && whenToDo==1 && (info.options&512)==0) || ((info.options&1024)!=0 && (info.options&512)==0)) { // bounds const double * solution = si.getColSolution(); memcpy(simplex->columnLower(),colLower,numberColumns*sizeof(double)); memcpy(simplex->columnUpper(),colUpper,numberColumns*sizeof(double)); for (int i=0;i<numberColumns;i++) { if (colLower[i]<-1.0e20&&colUpper[i]>1.0e20) { double lower=-COIN_DBL_MAX; double upper=COIN_DBL_MAX; if (solution[i]>0.0) lower=-1.0e10; else upper=1.0e10; originalSolver_->setColLower(i,lower); originalSolver_->setColUpper(i,upper); } } double * obj = simplex->objective(); objective = CoinCopyOfArray(obj,numberColumns); const double * pi = si.getRowPrice(); const CoinPackedMatrix * rowCopy = si.getMatrixByRow(); const int * column = rowCopy->getIndices(); const CoinBigIndex * rowStart = rowCopy->getVectorStarts(); const int * rowLength = rowCopy->getVectorLengths(); const double * rowElements = rowCopy->getElements(); const double * rowLower = si.getRowLower(); const double * rowUpper = si.getRowUpper(); int numberCopy; int numberAdd; double * rowLower2 = NULL; double * rowUpper2 = NULL; int * column2 = NULL; CoinBigIndex * rowStart2 = NULL; double * rowElements2 = NULL; char * copy = new char [numberRows-numberOriginalRows]; memset(copy,0,numberRows-numberOriginalRows); if (twomirType==2) { numberCopy=0; numberAdd=0; for (int iRow=numberOriginalRows;iRow<numberRows;iRow++) { bool simple = true; for (int k=rowStart[iRow]; k<rowStart[iRow]+rowLength[iRow];k++) { double value = rowElements[k]; if (value!=floor(value+0.5)) { simple=false; break; } } if (simple) { numberCopy++; numberAdd+=rowLength[iRow]; copy[iRow-numberOriginalRows]=1; } } if (numberCopy) { //printf("Using %d rows out of %d\n",numberCopy,numberRows-numberOriginalRows); rowLower2 = new double [numberCopy]; rowUpper2 = new double [numberCopy]; rowStart2 = new CoinBigIndex [numberCopy+1]; rowStart2[0]=0; column2 = new int [numberAdd]; rowElements2 = new double [numberAdd]; } } numberCopy=0; numberAdd=0; const double * rowSolution = si.getRowActivity(); double offset=0.0; for (int iRow=numberOriginalRows;iRow<numberRows;iRow++) { if (!copy[iRow-numberOriginalRows]) { double value = pi[iRow]; offset += rowSolution[iRow]*value; for (int k=rowStart[iRow]; k<rowStart[iRow]+rowLength[iRow];k++) { int iColumn=column[k]; obj[iColumn] -= value*rowElements[k]; } } else { rowLower2[numberCopy]=rowLower[iRow]; rowUpper2[numberCopy]=rowUpper[iRow]; for (int k=rowStart[iRow]; k<rowStart[iRow]+rowLength[iRow];k++) { column2[numberAdd]=column[k]; rowElements2[numberAdd++]=rowElements[k]; } numberCopy++; rowStart2[numberCopy]=numberAdd; } } #if 0 CoinThreadRandom randomNumberGenerator; const double * solution = si.getColSolution(); for (int i=0;i<numberColumns;i++) { if (intVar[i]==1) { double randomNumber = randomNumberGenerator.randomDouble(); //randomNumber = 0.001*floor(randomNumber*1000.0); if (solution[i]>0.5) obj[i] -= randomNumber*0.001*fabs(obj[i]); else obj[i] += randomNumber*0.001*fabs(obj[i]); } } #endif if (numberCopy) { clpSolver->addRows(numberCopy, rowStart2,column2,rowElements2, rowLower2,rowUpper2); delete [] rowLower2 ; delete [] rowUpper2 ; delete [] column2 ; delete [] rowStart2 ; delete [] rowElements2 ; } delete [] copy; memcpy(simplex->primalColumnSolution(),si.getColSolution(), numberColumns*sizeof(double)); CoinWarmStart * warmstart = si.getWarmStart(); CoinWarmStartBasis* warm = dynamic_cast<CoinWarmStartBasis*>(warmstart); warm->resize(simplex->numberRows(),numberColumns); clpSolver->setBasis(*warm); delete warm; simplex->setDualObjectiveLimit(COIN_DBL_MAX); simplex->setLogLevel(0); clpSolver->resolve(); //printf("Trying - %d its status %d objs %g %g - with offset %g\n", // simplex->numberIterations(),simplex->status(), // simplex->objectiveValue(),si.getObjValue(),simplex->objectiveValue()+offset); //simplex->setLogLevel(0); if (simplex->status()) { //printf("BAD status %d\n",simplex->status()); //clpSolver->writeMps("clp"); //si.writeMps("si"); delete [] objective; objective=NULL; useSolver=&si; } } } #endif useSolver->getStrParam(OsiProbName,probname_) ; int numberRowCutsBefore = cs.sizeRowCuts(); DGG_list_t cut_list; DGG_list_init (&cut_list); DGG_data_t* data = DGG_getData(reinterpret_cast<const void *> (useSolver)); // Note that the lhs variables are hash defines to data->cparams.* q_max = q_max_; q_min = q_min_; t_max = t_max_; t_min = t_min_; a_max = a_max_; max_elements = info.inTree ? max_elements_ : max_elements_root_; data->gomory_threshold = info.inTree ? away_ : awayAtRoot_; if (!info.inTree) { //const CoinPackedMatrix * columnCopy = useSolver->getMatrixByCol(); //int numberColumns=columnCopy->getNumCols(); if (!info.pass||(info.options&32)!=0) { max_elements=useSolver->getNumCols(); //} else { //int numberRows=columnCopy.getNumRows(); //int numberElements=columnCopy->getNumElements(); //if (max_elements>500&&numberElements>10*numberColumns) //max_elements=numberColumns; } } if (!do_mir_) t_max = t_min - 1; if (!do_2mir_) q_max = q_min - 1; if (do_tab_ && info.level < 1 && info.pass < 6) DGG_generateTabRowCuts( &cut_list, data, reinterpret_cast<const void *> (useSolver) ); if (do_form_) DGG_generateFormulationCuts( &cut_list, data, reinterpret_cast<const void *> (useSolver), info.formulation_rows, randomNumberGenerator_); #ifdef CGL_DEBUG const OsiRowCutDebugger debugg(si,probname_.c_str()) ; const OsiRowCutDebugger *debugger = &debugg; if (debugger&&!debugger->onOptimalPath(si)) debugger = NULL; else {if(talk) printf ("2mir_test: debug success\n");} #endif int i; for ( i=0; i<cut_list.n; i++){ DGG_constraint_t *cut = cut_list.c[i]; OsiRowCut rowcut; if (cut->nz<max_elements) { // See if any zero coefficients!!!!!!! int nZero=0; for( int i=0; i < cut->nz; i++) { if (!cut->coeff[i]) nZero++; } #ifdef CGL_DEBUG_ZERO if (nZero) { printf("Cut "); for( int i=0; i < cut->nz; i++) { printf("%d %g ",cut->index[i],cut->coeff[i]); } printf("\n"); } #endif if (nZero) { #ifdef CGL_DEBUG_ZERO printf("TwoMir cut had %d zero coefficients!\n",nZero); #endif } else { #ifdef CBC_CHECK_CUT double rhs = cut->rhs; int * cutIndex = cut->index; double * packed = cut->coeff; int i,number2=cut->nz; int number=0; double largest=0.0; double smallest=1.0e30; const double *colUpper = useSolver->getColUpper(); const double *colLower = useSolver->getColLower(); bool goodCut=true; for (i=0;i<number2;i++) { double value=fabs(packed[i]); if (value<1.0e-9) { int iColumn = cutIndex[i]; if (colUpper[iColumn]-colLower[iColumn]<100.0) { // weaken cut if (packed[i]>0.0) rhs -= value*colUpper[iColumn]; else rhs += value*colLower[iColumn]; } else { // throw away goodCut=false; break; } } else { int iColumn = cutIndex[i]; if (colUpper[iColumn]!=colLower[iColumn]) { largest=CoinMax(largest,value); smallest=CoinMin(smallest,value); cutIndex[number]=cutIndex[i]; packed[number++]=packed[i]; } else { // fixed so subtract out rhs -= packed[i]*colLower[iColumn]; } } } if (largest<5.0e9*smallest&&goodCut) { rowcut.setRow(number, cutIndex, packed); rowcut.setUb(COIN_DBL_MAX); rowcut.setLb(rhs); cs.insert(rowcut); } #else rowcut.setRow(cut->nz, cut->index, cut->coeff); rowcut.setUb(DBL_MAX); rowcut.setLb(cut->rhs); cs.insert(rowcut); #endif } #ifdef CGL_DEBUG if (debugger) { if (debugger->invalidCut(rowcut)) { write_cut(cut); printf ("2mir_test: debug failed, mayday, mayday **********************************\n");} //assert(0); } //assert(!debugger->invalidCut(rowcut)); #endif } } for ( i=0; i<cut_list.n; i++) DGG_freeConstraint (cut_list.c[i]); DGG_list_free (&cut_list); DGG_freeData (data); if (!info.inTree&&((info.options&4)==4||((info.options&8)&&!info.pass))) { int numberRowCutsAfter = cs.sizeRowCuts(); for (int i=numberRowCutsBefore;i<numberRowCutsAfter;i++) { int length = cs.rowCutPtr(i)->row().getNumElements(); if (length<=max_elements_) cs.rowCutPtr(i)->setGloballyValid(); } } #ifdef COIN_HAS_CLP_TWOMIR if (objective) { int numberRowCutsAfter = cs.sizeRowCuts(); ClpSimplex * simplex = clpSolver->getModelPtr(); memcpy(simplex->objective(),objective,numberColumns*sizeof(double)); delete [] objective; // take out locally useless cuts const double * solution = si.getColSolution(); double primalTolerance = 1.0e-7; for (int k = numberRowCutsAfter - 1; k >= numberRowCutsBefore; k--) { const OsiRowCut * thisCut = cs.rowCutPtr(k) ; double sum = 0.0; int n = thisCut->row().getNumElements(); const int * column = thisCut->row().getIndices(); const double * element = thisCut->row().getElements(); assert (n); for (int i = 0; i < n; i++) { double value = element[i]; sum += value * solution[column[i]]; } if (sum > thisCut->ub() + primalTolerance) { sum = sum - thisCut->ub(); } else if (sum < thisCut->lb() - primalTolerance) { sum = thisCut->lb() - sum; } else { sum = 0.0; } if (!sum) { // take out cs.eraseRowCut(k); } } #ifdef CLP_INVESTIGATE2 printf("OR %p pass %d inTree %c - %d cuts (but %d deleted)\n", originalSolver_,info.pass,info.inTree?'Y':'N', numberRowCutsAfter-numberRowCutsBefore, numberRowCutsAfter-cs.sizeRowCuts()); #endif } int numberRowCutsAfter = cs.sizeRowCuts(); if (!info.inTree) { for (int i=numberRowCutsBefore;i<numberRowCutsAfter;i++) { cs.rowCutPtr(i)->setGloballyValid(); } } if (twomirType==2) { // back to original int numberRows = clpSolver->getNumRows(); if (numberRows>numberOriginalRows) { int numberDelete = numberRows-numberOriginalRows; int * delRow = new int [numberDelete]; for (int i=0;i<numberDelete;i++) delRow[i]=i+numberOriginalRows; clpSolver->deleteRows(numberDelete,delRow); delete [] delRow; } } #endif } //------------------------------------------------------------------- // Default Constructor //------------------------------------------------------------------- CglTwomir::CglTwomir () : CglCutGenerator(), probname_(), randomNumberGenerator_(987654321),originalSolver_(NULL), away_(0.0005),awayAtRoot_(0.0005),twomirType_(0), do_mir_(true), do_2mir_(true), do_tab_(true), do_form_(true), t_min_(1), t_max_(1), q_min_(1), q_max_(1), a_max_(2),max_elements_(50000), max_elements_root_(50000),form_nrows_(0) {} //------------------------------------------------------------------- // Copy constructor //------------------------------------------------------------------- CglTwomir::CglTwomir (const CglTwomir & source) : CglCutGenerator(source), randomNumberGenerator_(source.randomNumberGenerator_), originalSolver_(NULL), away_(source.away_), awayAtRoot_(source.awayAtRoot_), twomirType_(source.twomirType_), do_mir_(source.do_mir_), do_2mir_(source.do_2mir_), do_tab_(source.do_tab_), do_form_(source.do_form_), t_min_(source.t_min_), t_max_(source.t_max_), q_min_(source.q_min_), q_max_(source.q_max_), a_max_(source.a_max_), max_elements_(source.max_elements_), max_elements_root_(source.max_elements_root_), form_nrows_(source.form_nrows_) { probname_ = source.probname_ ; if (source.originalSolver_) originalSolver_ = source.originalSolver_->clone(); } //------------------------------------------------------------------- // Clone //------------------------------------------------------------------- CglCutGenerator * CglTwomir::clone() const { return new CglTwomir(*this); } //------------------------------------------------------------------- // Destructor //------------------------------------------------------------------- CglTwomir::~CglTwomir () { delete originalSolver_; } //---------------------------------------------------------------- // Assignment operator //------------------------------------------------------------------- CglTwomir & CglTwomir::operator=(const CglTwomir& rhs) { if (this != &rhs) { CglCutGenerator::operator=(rhs); randomNumberGenerator_ = rhs.randomNumberGenerator_; away_=rhs.away_; awayAtRoot_=rhs.awayAtRoot_; twomirType_ = rhs.twomirType_; delete originalSolver_; if (rhs.originalSolver_) originalSolver_ = rhs.originalSolver_->clone(); else originalSolver_=NULL; do_mir_=rhs.do_mir_; do_2mir_=rhs.do_2mir_; do_tab_=rhs.do_tab_; do_form_=rhs.do_form_; t_min_=rhs.t_min_; t_max_=rhs.t_max_; q_min_=rhs.q_min_; q_max_=rhs.q_max_; a_max_=rhs.a_max_; max_elements_=rhs.max_elements_; max_elements_root_ = rhs.max_elements_root_; form_nrows_=rhs.form_nrows_; } return *this; } // Pass in a copy of original solver (clone it) void CglTwomir::passInOriginalSolver(OsiSolverInterface * solver) { delete originalSolver_; if (solver) { if (!twomirType_) twomirType_=1; originalSolver_ = solver->clone(); originalSolver_->setHintParam(OsiDoDualInResolve, false, OsiHintDo); // Temp - check if free variables const double *colUpper = originalSolver_->getColUpper(); const double *colLower = originalSolver_->getColLower(); int ncol = originalSolver_->getNumCols(); int numberFree=0; for (int i=0;i<ncol;i++) { if (colLower[i]<-1.0e20&&colUpper[i]>1.0e20) numberFree++; } if (numberFree) printf("CglTwoMir - %d free variables - take care\n",numberFree); } else { twomirType_=0; originalSolver_=NULL; } } int DGG_freeData( DGG_data_t *data ) { free(data->info); free(data->lb); free(data->ub); free(data->x); free(data->rc); free(data); return 0; } DGG_data_t* DGG_getData(const void *osi_ptr ) { DGG_data_t *data = NULL; const OsiSolverInterface *si = reinterpret_cast<const OsiSolverInterface *> (osi_ptr); data = reinterpret_cast<DGG_data_t*> (malloc( sizeof(DGG_data_t)) ); /* retrieve basis information */ CoinWarmStart *startbasis = si->getWarmStart(); const CoinWarmStartBasis *basis = dynamic_cast<const CoinWarmStartBasis*>(startbasis); /* retrieve bounds information */ const double *colUpper = si->getColUpper(); const double *colLower = si->getColLower(); const double *rowUpper = si->getRowUpper(); const double *rowLower = si->getRowLower(); const double *redCost = si->getReducedCost(); const double *dualVal = si->getRowPrice(); /* retrieve current optimal solution */ const double *colSolut = si->getColSolution(); /* retrieve the matrix in row format */ const CoinPackedMatrix *rowMatrixPtr = si->getMatrixByRow(); const int *rowBeg = 0, *rowCnt = 0, *rowInd = 0; const double *rowMat; rowBeg = rowMatrixPtr->getVectorStarts(); rowCnt = rowMatrixPtr->getVectorLengths(); rowMat = rowMatrixPtr->getElements(); rowInd = rowMatrixPtr->getIndices(); /* set number of columns and number of rows */ data->ncol = si->getNumCols(); data->nrow = si->getNumRows(); /* set ninteger */ data->ninteger = 0; /* allocate memory for the arrays in 'data' */ data->info = reinterpret_cast<int*> (malloc( sizeof(int)*(data->ncol+data->nrow)) ); data->lb = reinterpret_cast<double*> (malloc( sizeof(double)*(data->ncol+data->nrow)) ); data->ub = reinterpret_cast<double*> (malloc( sizeof(double)*(data->ncol+data->nrow)) ); data->x = reinterpret_cast<double*> (malloc( sizeof(double)*(data->ncol+data->nrow)) ); data->rc = reinterpret_cast<double*> (malloc( sizeof(double)*(data->ncol+data->nrow)) ); memset(data->info, 0, sizeof(int)*(data->ncol+data->nrow)); /* set parameters for column variables */ data->nbasic_col = 0; for(int i=0; i < data->ncol; i++){ /* is variable basic */ if ( basis->getStructStatus(i) == CoinWarmStartBasis::basic ){ data->nbasic_col++; DGG_setIsBasic(data,i); } #if DGG_DEBUG_DGG { int error = 0; if ( basis->getStructStatus(i) != CoinWarmStartBasis::basic ) if ( fabs(colSolut[i] - colUpper[i]) > DGG_BOUND_THRESH ) if ( fabs(colSolut[i] - colLower[i]) > DGG_BOUND_THRESH ){ fprintf(stdout, "WARNING!!!! : "); fprintf(stdout, "variable %d non-basic, lb = %f, ub = %f, x = %f\n", i, colLower[i], colUpper[i], colSolut[i]); error+=1; } if (error) fprintf(stdout, "\nFOUND %d errors. BYE.\n", error); } #endif /* set variable bounds*/ data->lb[i] = colLower[i]; data->ub[i] = colUpper[i]; /* is variable integer */ if ( si->isInteger(i) ){ data->ninteger++; DGG_setIsInteger(data,i); /* tighten variable bounds*/ data->lb[i] = ceil(colLower[i]); data->ub[i] = floor(colUpper[i]); } /* set x value */ data->x[i] = colSolut[i]; /* WARNING: remember to set rc!! Its not set!! */ data->rc[i] = redCost[i]; } /* set parameters for row variables */ /* slack variables (row variables) work as follows: for a ranged constraint, b_dw < ax < b_up, define a variable s so that 1) if b_up is not infinity: ax + s = b_up, 0 < s < b_up - b_dw 2) if b_up is infinity: ax - s = b_dw, 0 < s < b_up - b_dw */ { int i,j; double activity; data->nbasic_row = 0; for(i=0, j=data->ncol; i < data->nrow; i++, j++){ /* check if the row is an equality constraint */ if ( fabs( rowUpper[i] - rowLower[i] ) <= DGG_BOUND_THRESH ) DGG_setEqualityConstraint(data,j); /* check if the row is bounded above/below and define variable bounds */ if ( rowUpper[i] < COIN_DBL_MAX ) DGG_setIsConstraintBoundedAbove(data,j); if ( rowLower[i] > -1*COIN_DBL_MAX ) DGG_setIsConstraintBoundedBelow(data,j); data->lb[j] = 0.0; if (DGG_isConstraintBoundedAbove(data,j) && DGG_isConstraintBoundedBelow(data,j)) data->ub[j] = rowUpper[i] - rowLower[i]; else data->ub[j] = COIN_DBL_MAX; /* compute row activity. for this we need to go to the row in question, and multiply all the coefficients times their respective variables. For the moment, we will store the inverse of this value in the 'x' field (since it is in fact a partial computation of it) */ { int k; activity = 0.0; for(k=rowBeg[i]; k < rowBeg[i]+rowCnt[i]; k++) activity += rowMat[k]*colSolut[rowInd[k]]; } /* compute x value */ if ( DGG_isConstraintBoundedAbove(data,j) ) data->x[j] = rowUpper[i] - activity; else data->x[j] = activity - rowLower[i]; if ( data->x[j] < -DGG_NULL_SLACK ){ #if DGG_DEBUG_DGG int k; double norm = 0.0, min = DBL_MAX, amin = DBL_MAX, max = DBL_MIN; printf("** warning: row %d has negative slack!\n", i); for(k=rowBeg[i]; k < rowBeg[i]+rowCnt[i]; k++){ norm += rowMat[k]*rowMat[k]; if ( fabs(rowMat[k]) < amin ) amin = fabs(rowMat[k]); if ( rowMat[k] < min ) min = rowMat[k]; if ( rowMat[k] > max ) max = rowMat[k]; } norm = sqrt(norm); printf("min = %f amin = %f max = %f\n", min, amin, max); printf("rlower = %f activity = %f\n", rowLower[i], activity); printf("norm = %f (b-ax) = %f\n", norm, (rowLower[i] - activity)); printf("steepn = %f\n", (rowLower[i] - activity)/norm); #endif } data->rc[j] = dualVal[i]; #if DGG_DEBUG_SOLVER DGG_IF_EXIT( !DGG_isConstraintBoundedAbove(data,j) && !DGG_isConstraintBoundedBelow(data,j), 1, "some row is not bounded above or below"); #endif /* is variable basic */ if ( basis->getArtifStatus(i) == CoinWarmStartBasis::basic ){ data->nbasic_row++; DGG_setIsBasic(data,j); } /* is variable integer. For this we need to go to the row in question, and check that the rhs is integer, and that all of the coefficients and variables participating in the constraint are also integer. */ { int k; if( DGG_isConstraintBoundedAbove(data,j)) { if ( frac_part(rowUpper[i]) > DGG_INTEGRALITY_THRESH ) goto DONE_ROW; } else if ( frac_part(rowLower[i]) > DGG_INTEGRALITY_THRESH ) goto DONE_ROW; for(k=rowBeg[i]; k < rowBeg[i]+rowCnt[i]; k++) if ( frac_part(rowMat[k]) > DGG_INTEGRALITY_THRESH || !DGG_isInteger(data, rowInd[k])) goto DONE_ROW; DGG_setIsInteger(data, j); data->ninteger++; } DONE_ROW:; /* set variable bounds: careful!! Later, remember to adjust the INFINITY to a DGG standard (to deal with neq solvers). */ /* WARNING: remember to set rc!! Its not set!! */ } } /* CLEANUP */ delete basis; return data; } DGG_constraint_t* DGG_getSlackExpression(const void *osi_ptr, DGG_data_t* data, int row_index) { DGG_constraint_t *row = 0; int i,j; /* retrieve the matrix in row format */ const OsiSolverInterface *si = reinterpret_cast<const OsiSolverInterface *> (osi_ptr); const CoinPackedMatrix *rowMatrixPtr = si->getMatrixByRow(); const int *rowBeg = 0, *rowCnt = 0, *rowInd = 0; const double *rowMat; const double *rowUpper; const double *rowLower; row = DGG_newConstraint(data->ncol); rowBeg = rowMatrixPtr->getVectorStarts(); rowCnt = rowMatrixPtr->getVectorLengths(); rowMat = rowMatrixPtr->getElements(); rowInd = rowMatrixPtr->getIndices(); rowUpper = si->getRowUpper(); rowLower = si->getRowLower(); #if DGG_DEBUG_DGG if ( row_index < 0 || row_index > data->nrow ) DGG_THROW(0, "bad row index"); #endif /* copy the information into the row ADT */ row->nz = rowCnt[row_index]; for(j=0, i=rowBeg[row_index]; i < rowBeg[row_index]+rowCnt[row_index]; i++, j++){ row->coeff[j] = rowMat[i]; row->index[j] = rowInd[i]; if (DGG_isConstraintBoundedAbove (data, data->ncol + row_index)) row->coeff[j] = -row->coeff[j]; } row->sense = '?'; if ( DGG_isConstraintBoundedAbove(data, data->ncol + row_index) ) row->rhs = rowUpper[row_index]; else row->rhs = -rowLower[row_index]; return row; } int DGG_getTableauConstraint( int index, const void *osi_ptr, DGG_data_t *data, DGG_constraint_t* tabrow, const int * colIsBasic, const int * /*rowIsBasic*/, CoinFactorization & factorization, int mode ) { #if DGG_DEBUG_DGG /* ensure that the index corresponds to a basic variable */ if ( !DGG_isBasic(data, index) ) DGG_THROW(1, "index is non-basic"); /* ensure that the index corresponds to a column variable */ if ( index < 0 || index > (data->ncol - 1) ) DGG_THROW(1, "index not a column variable"); #endif /* obtain pointer to solver interface */ const OsiSolverInterface *si = reinterpret_cast<const OsiSolverInterface *> (osi_ptr); DGG_TEST(!si, 1, "null OsiSolverInterfave"); /* obtain address of the LP matrix */ const CoinPackedMatrix *colMatrixPtr = si->getMatrixByCol(); const int* colBeg = colMatrixPtr->getVectorStarts(); const int* colCnt = colMatrixPtr->getVectorLengths(); const int* colInd = colMatrixPtr->getIndices(); const double* colMat = colMatrixPtr->getElements(); /* obtain row right-hand-sides */ const double *rowUpper = si->getRowUpper(); const double *rowLower = si->getRowLower(); /* allocate memory for constraint in non-sparse form */ int nz = 0; double *value = NULL, rhs = 0.0; value = reinterpret_cast<double*>(malloc(sizeof(double)*(data->nrow+data->ncol))); memset(value, 0, sizeof(double)*(data->nrow+data->ncol)); /* obtain the tableau row coefficients for all variables */ /* note: we could speed this up by only computing non-basic variables */ { int i, j, cnt = 0; double one = 1.0; CoinIndexedVector work; CoinIndexedVector array; work.reserve(data->nrow); array.reserve(data->nrow); array.setVector(1,&colIsBasic[index],&one); factorization.updateColumnTranspose ( &work, &array ); int * arrayRows = array.getIndices(); double *arrayElements = array.denseVector(); cnt = array.getNumElements(); /* compute column (structural) variable coefficients */ for(j = 0; j < data->ncol; j++) { value[j] = 0.0; for(i=colBeg[j]; i < colBeg[j]+colCnt[j]; i++) value[j] += colMat[i]*arrayElements[ colInd[i] ]; } #if DGG_DEBUG_SOLVER /* check pivot */ if ( fabs(value[index] - 1.0) > DGG_INTEGRALITY_THRESH ) DGG_THROW(1, "pivot is not one"); #endif /* compute row variable (slack/logical) variable coefficients */ for(j = 0; j < cnt; j++){ if ( DGG_isEqualityConstraint(data,data->ncol + arrayRows[j]) && !mode ) value[ data->ncol + arrayRows[j] ] = 0.0; else if ( DGG_isConstraintBoundedAbove(data, data->ncol + arrayRows[j]) ) value[ data->ncol + arrayRows[j] ] = arrayElements[ arrayRows[j] ]; else value[ data->ncol + arrayRows[j] ] = -1*arrayElements[ arrayRows[j] ]; } /* compute rhs */ rhs = 0.0; for(i=0; i < cnt; i++){ if ( DGG_isConstraintBoundedAbove(data,data->ncol + arrayRows[i]) ) rhs += arrayElements[arrayRows[i]]*rowUpper[arrayRows[i]]; else rhs += arrayElements[arrayRows[i]]*rowLower[arrayRows[i]]; } /* free 'work' and 'array' ?? do the empty functions do it?? they are not cleared in CglGomory. Is that due to a mistake? Is it done on purpose? */ /* work.empty(); array.empty(); */ } /* count non-zeroes */ nz = 0; int j; for( j=0; j<data->ncol+data->nrow; j++){ if ( fabs(value[j]) > DGG_MIN_TABLEAU_COEFFICIENT ) nz += 1; } /* put in sparse constraint format */ /* technical issue: should we let max_nz == nz or should we instead set max_nz == (nrow+ncol). The advantage of the latter approach is that later, when we substitute the slacks, the denser column will not require us to re-allocate memory */ tabrow->max_nz = nz; if (tabrow->coeff) free(tabrow->coeff); if (tabrow->index) free(tabrow->index); tabrow->coeff = reinterpret_cast<double*> (malloc(sizeof(double)*nz)); tabrow->index = reinterpret_cast<int*> (malloc(sizeof(int)*nz)); tabrow->nz = 0; for( j = 0; j < data->ncol + data->nrow; j++) if ( fabs(value[j]) > DGG_MIN_TABLEAU_COEFFICIENT ){ tabrow->coeff[tabrow->nz] = value[j]; tabrow->index[tabrow->nz] = j; tabrow->nz += 1; } tabrow->sense = 'E'; tabrow->rhs = rhs; /* CLEANUP */ free(value); return 0; } int DGG_getFormulaConstraint( int da_row, const void *osi_ptr, DGG_data_t *data, DGG_constraint_t* form_row ) { /* ensure that the da_row corresponds to a row */ if ( data->nrow <= da_row || 0> da_row) DGG_THROW(1, "row out of range..."); /* obtain pointer to solver interface */ const OsiSolverInterface *si = reinterpret_cast<const OsiSolverInterface *> (osi_ptr); //DGG_TEST(!si, 1, "null OsiSolverInterfave"); /* obtain address of the LP matrix */ const CoinPackedMatrix *rowMatrixPtr = si->getMatrixByRow(); const int* rowBeg = rowMatrixPtr->getVectorStarts(); const int* rowCnt = rowMatrixPtr->getVectorLengths(); const int* rowInd = rowMatrixPtr->getIndices(); const double* rowMat = rowMatrixPtr->getElements(); /* obtain row right-hand-sides */ const double *rowUpper = si->getRowUpper(); const double *rowLower = si->getRowLower(); int nz = rowCnt[da_row]; form_row->nz = nz; form_row->max_nz = nz+1; int i; for( i=0; i < nz; i++) form_row->coeff[i] = rowMat[rowBeg[da_row]+i]; for( i=0; i < nz; i++) form_row->index[i] = rowInd[rowBeg[da_row]+i]; if ( DGG_isConstraintBoundedAbove(data,data->ncol + da_row) ){ form_row->rhs = rowUpper[da_row]; form_row->sense = 'L'; } else{ form_row->rhs = rowLower[da_row]; form_row->sense = 'G'; } if ( DGG_isEqualityConstraint(data,data->ncol + da_row) ) form_row->sense = 'E'; /* now add slack/surplus if there is one */ if ( DGG_isEqualityConstraint(data,data->ncol + da_row) == 0 ){ form_row->index[nz] = data->ncol + da_row; if ( DGG_isConstraintBoundedAbove(data, data->ncol + da_row) ) form_row->coeff[nz] = 1; else form_row->coeff[nz] = -1; form_row->nz +=1; } return 0; } //--------------------------------------------------------------- //--------------------------------------------------------------- //--------------------------------------------------------------- //--------------------------------------------------------------- //--------------------------------------------------------------- /******************** CONSTRAINT ADTs *****************************************/ DGG_constraint_t* DGG_newConstraint(int max_arrays) { DGG_constraint_t *c = NULL; if (max_arrays <= 0) return NULL; c = reinterpret_cast<DGG_constraint_t*> (malloc(sizeof(DGG_constraint_t))); c->nz = 0; c->max_nz = max_arrays; c->rhs = 0.0; c->sense = '?'; c->coeff = NULL; c->index = NULL; c->coeff = reinterpret_cast<double*>(malloc(sizeof(double)*max_arrays)); c->index = reinterpret_cast<int*>(malloc(sizeof(int)*max_arrays)); return c; } void DGG_freeConstraint(DGG_constraint_t *c) { if (c == NULL) return; if (c->coeff) free(c->coeff); if (c->index) free(c->index); free(c); } DGG_constraint_t *DGG_copyConstraint(DGG_constraint_t* c) { DGG_constraint_t *nc = NULL; if (!c || c->max_nz <= 0) return nc; nc = DGG_newConstraint(c->max_nz); if (nc == NULL) return nc; nc->nz = c->nz; nc->rhs = c->rhs; nc->sense = c->sense; memcpy(nc->coeff, c->coeff, sizeof(double)*nc->nz); memcpy(nc->index, c->index, sizeof(int)*nc->nz); return nc; } void DGG_scaleConstraint(DGG_constraint_t *c, int t) { int i; c->rhs *= t; if (t < 0){ if (c->sense == 'G') c->sense = 'L'; else if (c->sense == 'L') c->sense = 'G'; } for(i=0; i<c->nz; i++) c->coeff[i] *= t; } void DGG_list_init (DGG_list_t *l) { l->n = 0; l->c = NULL; l->ctype = NULL; l->alpha = NULL; } void DGG_list_free(DGG_list_t *l) { if (l->c != NULL) free (l->c); if (l->ctype != NULL) free (l->ctype); if (l->alpha != NULL) free (l->alpha); } int DGG_list_addcut (DGG_list_t *l, DGG_constraint_t *cut, int ctype, double alpha) { l->n ++; l->c = reinterpret_cast<DGG_constraint_t **>(realloc (l->c, l->n * sizeof(DGG_constraint_t *))); l->ctype = reinterpret_cast<int *>(realloc (l->ctype, l->n * sizeof (int))); l->alpha = reinterpret_cast<double *>(realloc (l->alpha, l->n * sizeof (double))); if (l->c == NULL || l->ctype == NULL || l->alpha == NULL){ printf ("No memory, bailing out\n"); return -1; } l->c[l->n - 1] = cut; l->ctype[l->n - 1] = ctype; l->alpha[l->n - 1] = alpha; return 0; } void DGG_list_delcut (DGG_list_t *l, int i) { if (i >= l->n && i < 0) return; DGG_freeConstraint (l->c[i]); l->c[i] = l->c[l->n - 1]; l->ctype[i] = l->ctype[l->n - 1]; l->alpha[i] = l->alpha[l->n - 1]; l->n --; } /******************* CONSTRAINT MANIPULATION **********************************/ /* VARIABLES CLOSE TO UPPER BOUNDS: we will substitute: x' = (u - x); hence the constraint will change from ax ~ b to -ax' ~ b - au note: the new bounds of x' will be, 0 <= x' <= u - l VARIABLES CLOSE TO LOWER BOUNDS: we will substitute: x' = (x - l); hence, the constraint will change from ax ~ b to ax' ~ b - al. note: some variable lower bounds may have changed when doing the complement in the previous stage - this must be taken into account. note: the new bounds of x' will be, 0 <= x' <= u - l */ int DGG_transformConstraint( DGG_data_t *data, double **x_out, double **rc_out, char **isint_out, DGG_constraint_t *constraint ) { double half; double *px = reinterpret_cast<double*> (malloc( sizeof(double)*constraint->max_nz )); double *rc = reinterpret_cast<double*> (malloc( sizeof(double)*constraint->max_nz )); char *pi = reinterpret_cast<char*> (malloc( sizeof(char) *constraint->max_nz )); { int i, idx; for(i=0; i < constraint->nz; i++){ idx = constraint->index[i]; px[i] = data->x[idx]; rc[i] = data->rc[idx]; pi[i] = static_cast<char>(DGG_isInteger(data, idx)); half = (data->ub[idx] - data->lb[idx]) / 2; if ( data->ub[idx] - data->x[idx] < half ){ px[i] = data->ub[idx] - data->x[idx]; if (fabs(px[i]) <= DGG_BOUND_THRESH) px[i] = 0.0; constraint->rhs -= constraint->coeff[i]*data->ub[idx]; constraint->coeff[i] *= -1; } else { px[i] = data->x[idx] - data->lb[idx]; if (fabs(px[i]) <= DGG_BOUND_THRESH) px[i] = 0.0; constraint->rhs -= constraint->coeff[i]*data->lb[idx]; } } } *x_out = px; *rc_out = rc; *isint_out = pi; #if DGG_DEBUG_DGG DGG_TEST(DGG_isConstraintViolated(data, constraint), 1, "bad transformation"); #endif return 0; } int DGG_unTransformConstraint( DGG_data_t *data, DGG_constraint_t *constraint ) { int i, idx; double half; for(i=0; i < constraint->nz; i++){ idx = constraint->index[i]; half = (data->ub[idx] - data->lb[idx]) / 2; if ( data->ub[idx] - data->x[idx] < half ){ constraint->rhs -= constraint->coeff[i]*data->ub[idx]; constraint->coeff[i] *= -1; } else constraint->rhs += constraint->coeff[i]*data->lb[idx]; } return 0; } int DGG_substituteSlacks( const void *solver_ptr, DGG_data_t *data, DGG_constraint_t *cut ) { int i,j, lnz; double *lcut, lrhs; DGG_constraint_t *row=NULL; /* lcut will store all the column coefficients. allocate space and init. */ lcut = reinterpret_cast<double*>(malloc(sizeof(double)*data->ncol)); memset(lcut, 0, sizeof(double)*data->ncol); /* initialize lrhs */ lrhs = cut->rhs; /* set coefficients in lcut */ /* technical: we could speed this up by re-using allocated memory for row->coeff and row->index */ for(i=0; i < cut->nz; i++){ if ( cut->index[i] < data->ncol ) lcut[ cut->index[i] ] += cut->coeff[i]; else{ row = DGG_getSlackExpression(solver_ptr, data, (cut->index[i] - data->ncol)); for(j=0; j < row->nz; j++) lcut[ row->index[j] ] += row->coeff[j]*cut->coeff[i]; lrhs -= row->rhs*cut->coeff[i]; DGG_freeConstraint(row); } } /* count nz in new constraint */ lnz = 0; for(i=0; i < data->ncol; i++) if ( fabs(lcut[i]) > DGG_MIN_TABLEAU_COEFFICIENT ) lnz += 1; /* free row->coeff and row->index, and re-allocate */ free(cut->coeff); cut->coeff = 0; free(cut->index); cut->index = 0; cut->nz = lnz; cut->max_nz = lnz; if (lnz) { cut->coeff = reinterpret_cast<double*> (malloc( sizeof(double)*lnz )); cut->index = reinterpret_cast<int*> (malloc( sizeof(int)*lnz )); } /* set new constraint */ lnz = 0; for(i=0; i < data->ncol; i++){ if ( fabs(lcut[i]) > DGG_MIN_TABLEAU_COEFFICIENT ){ cut->coeff[lnz] = lcut[i]; cut->index[lnz] = i; lnz += 1; } } cut->rhs = lrhs; free(lcut); return 0; } int DGG_nicefyConstraint( const void * /*solver_ptr*/, DGG_data_t *data, DGG_constraint_t *cut) { double min_coef = COIN_DBL_MAX, max_coef = COIN_DBL_MIN; DGG_TEST(cut->sense == 'L', 1, "can't nicefy an L constraint"); int i; for( i=0; i<cut->nz; i++) // first clean out noise if( fabs(cut->coeff[i]) < DGG_NICEFY_MIN_ABSVALUE) cut->coeff[i] = 0; for( i=0; i<cut->nz; i++){ if( DGG_isInteger(data, cut->index[i])){// look at integral vars. double aht = ABOV(cut->coeff[i]); double ub = data->ub[ cut->index[i]]; if(aht < DGG_NICEFY_MIN_FIX){// coefficient = integer + epsylon cut->coeff[i] = floor( cut->coeff[i]); double ahtu = aht * ub; if(ahtu<DGG_NICEFY_MAX_PADDING) cut->rhs -= ahtu;// safely remove the fractional part else cut->coeff[i] += DGG_NICEFY_MIN_FIX; // inflate the fractional part } else if (1-aht < DGG_NICEFY_MIN_FIX) // coefficient = integer - epsylon cut->coeff[i] = ceil( cut->coeff[i]); }// done with integers else // now look at continuous variables if ( cut->coeff[i] < DGG_NICEFY_MIN_ABSVALUE) // delete all negative and noise cut->coeff[i] = 0.0; else if(cut->coeff[i] < DGG_NICEFY_MIN_FIX) {// coefficient = epsylon double au = cut->coeff[i] * data->ub[ cut->index[i]]; if(au<DGG_NICEFY_MAX_PADDING){ // safely remove the variable cut->coeff[i] = 0.0; cut->rhs -= au; } else cut->coeff[i] = DGG_NICEFY_MIN_FIX; // inflate the coefficient }// done with continuous variables too double abs_coef = fabs(cut->coeff[i]); min_coef = DGG_MIN(min_coef, abs_coef); max_coef = DGG_MAX(max_coef, abs_coef); } cut->sense = 'G'; /* if ( max_coef > DGG_NICEFY_MAX_RATIO*min_coef ) // kill the cut if numbers are all over the place cut->nz = 0; */ return 0; } /******************* CUT GENERATION *******************************************/ int DGG_generateTabRowCuts( DGG_list_t *cut_list, DGG_data_t *data, const void *solver_ptr ) { int k, rval = 0; DGG_constraint_t *base = NULL; int nc = cut_list->n; base = DGG_newConstraint(data->ncol + data->nrow); if(talk) printf ("2mir_test: generating tab row cuts\n"); /* allocate memory for basic column/row indicators */ int *rowIsBasic = 0, *colIsBasic = 0; rowIsBasic = reinterpret_cast<int*>(malloc(sizeof(int)*data->nrow)); colIsBasic = reinterpret_cast<int*>(malloc(sizeof(int)*data->ncol)); /* initialize the IsBasic arrays with -1 / 1 values indicating where the basic rows and columns are. NOTE: WE could do this only once and keep it in osi_data at the expense of space!! */ int i; for( i=0; i<data->ncol; i++){ if ( DGG_isBasic(data,i) ) colIsBasic[i] = 1; else colIsBasic[i] = -1; } for( i=0; i<data->nrow; i++){ if ( DGG_isBasic(data,i+data->ncol) ) rowIsBasic[i] = 1; else rowIsBasic[i] = -1; } /* obtain factorization */ CoinFactorization factorization; /* obtain address of the LP matrix */ const OsiSolverInterface *si = reinterpret_cast<const OsiSolverInterface *> (solver_ptr); const CoinPackedMatrix *colMatrixPtr = si->getMatrixByCol(); rval = factorization.factorize(*colMatrixPtr, rowIsBasic, colIsBasic); /* 0 = okay. -1 = singular. -2 = too many in basis. -99 = memory. */ DGG_TEST2(rval, 1, "factorization error = %d", rval); for(k=0; k<data->ncol; k++){ if (!(DGG_isBasic(data, k) && DGG_isInteger(data,k))) continue; double frac = frac_part (data->x[k]); if (frac < data->gomory_threshold || frac > 1-data->gomory_threshold) continue; base->nz = 0; rval = DGG_getTableauConstraint(k, solver_ptr, data, base, colIsBasic,rowIsBasic,factorization,0); DGG_CHECKRVAL(rval, rval); if (base->nz == 0){ printf ("2mir_test: why does constraint not exist ?\n"); continue; } if (base->nz > 500) continue; rval = DGG_generateCutsFromBase(base, cut_list, data, solver_ptr); DGG_CHECKRVAL(rval, rval); } free(rowIsBasic); free(colIsBasic); if(talk) printf ("2mir_test: generated %d tab cuts\n", cut_list->n - nc); fflush (stdout); DGG_freeConstraint(base); return rval; } int DGG_generateFormulationCuts( DGG_list_t *cut_list, DGG_data_t *data, const void *solver_ptr, int nrows, CoinThreadRandom & generator) { int k, rval = 0; DGG_constraint_t *base = NULL; int num_rows = (data->nrow < nrows) ? data->nrow : nrows; int nc = cut_list->n; base = DGG_newConstraint(data->ncol + data->nrow); if(talk) printf ("2mir_test: generating form row cuts %d\n", num_rows); for(k=0; k<num_rows; k++) { base->nz = 0; rval = DGG_getFormulaConstraint(k, solver_ptr, data, base); DGG_CHECKRVAL1(rval, rval); //printf ("generating formulation for row %d\n", k); rval = DGG_generateFormulationCutsFromBase(base, data->x[data->ncol+k], cut_list, data, solver_ptr, generator); DGG_CHECKRVAL1(rval, rval); if (base->nz == 0){ #ifdef COIN_DEVELOP printf ("why does constraint not exist ?\n"); #endif continue; } } CLEANUP: if(talk) printf ("2mir_test: generated %d form cuts\n", cut_list->n - nc); fflush (stdout); DGG_freeConstraint(base); return rval; } int DGG_generateFormulationCutsFromBase( DGG_constraint_t *base, double slack, DGG_list_t *cut_list, DGG_data_t *data, const void *solver_ptr, CoinThreadRandom & generator) { int i, p, rval; int int_skala; double skala; int num_inlist = 0; int* skala_list = reinterpret_cast<int*> (malloc( sizeof(int)*base->nz )); char *isint = NULL; double *xout = NULL, *rcout = NULL; DGG_constraint_t *scaled_base = NULL; int tot_int = 0; double prob_choose = 0.0; rval = DGG_transformConstraint(data, &xout, &rcout, &isint, base); DGG_CHECKRVAL1(rval, rval); for(p = 0; p < base->nz; p++) if(isint[p]) tot_int ++; if (tot_int == 0) goto CLEANUP; prob_choose = 5.0/tot_int; for(p = 0; p < base->nz; p++) { if(isint[p]) if(generator.randomDouble() < prob_choose){ if(xout[p]<0.01) continue; skala =fabs(base->coeff[p]); if(skala<0.01) continue; // check if slack is too large if (fabs(slack/skala) > 0.5) continue; scaled_base = DGG_copyConstraint(base); DGG_CHECKRVAL1((scaled_base == NULL),-1); if(base->sense == 'L') { skala = -skala; scaled_base->sense = 'G'; } int_skala = int(100*skala); for(i = 0; i< num_inlist; i++) if(int_skala == skala_list[i]) goto END_LOOP; skala_list[num_inlist++] = int_skala; scaled_base->rhs = base->rhs/skala; for(i = 0; i<base->nz; i++) scaled_base->coeff[i] = base->coeff[i] / skala; rval = DGG_unTransformConstraint(data, scaled_base); DGG_CHECKRVAL1(rval, rval); rval = DGG_generateCutsFromBase(scaled_base, cut_list, data, solver_ptr); DGG_CHECKRVAL1(rval, rval); END_LOOP: DGG_freeConstraint(scaled_base); scaled_base = NULL; } } CLEANUP: if (isint) free(isint); if (xout) free(xout); if (rcout) free(rcout); if (skala_list) free(skala_list); if (scaled_base != NULL) DGG_freeConstraint (scaled_base); return rval; } int DGG_generateCutsFromBase( DGG_constraint_t *orig_base, DGG_list_t *cut_list, DGG_data_t *data, const void *solver_ptr ) { int rval = 0; int t; double *x = NULL, *rc = NULL; char *isint = NULL; DGG_constraint_t *base = NULL; bool not_nicefied = true; int new_pos = cut_list->n; // DGG_constraint_t *keep_origbase = DGG_copyConstraint(orig_base); //for debug only ------ if (orig_base->sense == 'L') return 0; if (orig_base->nz == 0) return 0; rval = DGG_transformConstraint(data, &x, &rc, &isint, orig_base); double frac = frac_part(orig_base->rhs); //printf ("frac = %.7f, r %.7f, fr %.7f\n", frac, orig_base->rhs, floor(orig_base->rhs)); if (rval || frac < data->gomory_threshold || frac > 1-data->gomory_threshold){ free (x); free (rc); free (isint); return 0; } int min_t = t_min; int min_q = q_min; if (orig_base->sense == 'G' && min_t < 1) min_t = 1; if (orig_base->sense == 'G' && min_q < 1) min_q = 1; if (min_q > 0 && min_t > 0 ) { not_nicefied = false; rval = DGG_nicefyConstraint(solver_ptr, data, orig_base); DGG_CHECKRVAL(rval, rval); if (orig_base->nz == 0){ if(talk) printf ("2mir_test: Nicefy returns empty constraint\n"); rval = 0; goto CLEANUP; } } for(t = min_t; t <= t_max ; t++){ if (t == 0) continue; base = DGG_copyConstraint(orig_base); DGG_TEST(!base, 1, "error making copy of base"); DGG_scaleConstraint (base, t); if(not_nicefied){ rval = DGG_nicefyConstraint(solver_ptr, data, base); DGG_CHECKRVAL(rval, rval); if (base->nz == 0){ if(talk) printf ("2mir_test: Nicefy returns empty constraint\n"); goto MIR_DONE; } } if ( DGG_isBaseTrivial(data, base) ) goto MIR_DONE; rval = DGG_addMirToList(base, isint, x, cut_list, data, orig_base); DGG_CHECKRVAL(rval, rval); MIR_DONE: DGG_freeConstraint(base); } for( t = min_q; t <= q_max; t++ ){ if (t == 0) continue; base = DGG_copyConstraint(orig_base); DGG_TEST(!base, 1, "error making copy of base"); DGG_scaleConstraint (base, t); if(not_nicefied){ rval = DGG_nicefyConstraint(solver_ptr, data, base); DGG_CHECKRVAL(rval, rval); if (base->nz == 0){ if(talk) printf ("2mir_test: Nicefy returns empty constraint\n"); goto TWOMIR_DONE; } } if ( DGG_isBaseTrivial(data, base) ) goto TWOMIR_DONE; rval = DGG_add2stepToList(base, isint, x, rc, cut_list, data, orig_base); DGG_CHECKRVAL(rval, rval); TWOMIR_DONE: DGG_freeConstraint(base); } int i; for ( i = cut_list->n-1; i>=new_pos; i--){ DGG_constraint_t *lcut = cut_list->c[i]; rval = DGG_unTransformConstraint(data, lcut); DGG_CHECKRVAL(rval, rval); rval = DGG_substituteSlacks(solver_ptr, data, lcut); DGG_CHECKRVAL(rval, rval); if ( !DGG_isCutDesirable(lcut, data) ){ DGG_list_delcut (cut_list, i); continue; } //else testus(lcut);//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! /* if ( data->opt_x && DGG_cutsOffPoint(data->opt_x, lcut) ){ //DGG_cutDisplay_sparse(data, data->opt_x, lcut, stdout); DGG_TEST(1,1, "new cut is infeasible for optimal solution\n"); } */ } CLEANUP: if (x) free(x); if (rc) free (rc); if (isint) free(isint); return 0; } int DGG_addMirToList ( DGG_constraint_t *base, char *isint, double * /*x*/, DGG_list_t *list, DGG_data_t * /*data*/, DGG_constraint_t * /*orig_base*/ ) { int rval = 0; DGG_constraint_t *cut = NULL; rval = DGG_buildMir(isint, base, &cut); DGG_CHECKRVAL(rval, rval); DGG_list_addcut(list, cut, DGG_TMIR_CUT, 0.0); return 0; } int DGG_add2stepToList ( DGG_constraint_t *base, char *isint, double * /*x*/, double *rc, DGG_list_t *list, DGG_data_t *data, DGG_constraint_t * /*orig_base*/ ) { int rval; DGG_constraint_t *cut = NULL; int i; double norm_val, best_norm_val, best_norm_alpha=-1.0; double rc_val, best_rc_val, best_rc_alpha=-1.0; double vht, bht, alpha; best_rc_val = best_norm_val = COIN_DBL_MAX; bht = ABOV(base->rhs); double best_rc = 0; for(i=0; i<base->nz; i++) if (isint[i]) best_rc = CoinMax(best_rc, fabs(rc[i])); double rc_cutoff = best_rc / 10; for(i=0; i<base->nz; i++){ if (!isint[i]) continue; if (fabs(rc[i]) <= rc_cutoff) continue; //too unimportant vht = ABOV(base->coeff[i]); if(vht >= bht) continue; // too big if(vht < bht/a_max) continue; // too small alpha = vht; int kk = 1; while ( !DGG_is2stepValid(alpha, bht) && bht/alpha <= a_max) { alpha = vht/kk; kk++; if (kk>1000) break; } if ( !DGG_is2stepValid(alpha, bht) ) continue; rval = DGG_build2step(alpha, isint, base, &cut); DGG_CHECKRVAL(rval, rval); rc_val = COIN_DBL_MAX; // this gives a lower bound on obj. fn. improvement for(i=0; i<cut->nz; i++) if(cut->coeff[i]> 1E-6){ rc_val = CoinMin(rc_val, fabs(rc[i])/cut->coeff[i]); } rc_val *= cut->rhs; norm_val = 0; // this is the square of the L2 norm for(i=0; i<cut->nz; i++) if(cut->coeff[i]> 1E-6){ norm_val += (cut->coeff[i]*cut->coeff[i]); } norm_val /= cut->rhs * cut->rhs; if (rc_val < best_rc_val ) { best_rc_val = rc_val; best_rc_alpha = alpha; } if (norm_val < best_norm_val ) { best_norm_val = norm_val; best_norm_alpha = alpha; } DGG_freeConstraint(cut); } if( best_rc_val> 1E-6 && best_rc_alpha != -1.0){ rval = DGG_build2step(best_rc_alpha, isint, base, &cut); DGG_CHECKRVAL(rval, rval); DGG_list_addcut(list, cut, DGG_2STEP_CUT, best_rc_alpha); } else if (best_norm_alpha != -1.0){ rval = DGG_build2step(best_norm_alpha, isint, base, &cut); DGG_CHECKRVAL(rval, rval); DGG_list_addcut(list, cut, DGG_2STEP_CUT, best_norm_alpha); } return 0; } int DGG_buildMir( char *isint, DGG_constraint_t *base, DGG_constraint_t **cut_out ) { int i, lnz = 0; double b = (base->rhs); double bht = ABOV(b); double bup = ceil(b); DGG_constraint_t *tmir = NULL; DGG_TEST( base->sense == 'L', 1, "this form not valid for L"); DGG_TEST( base->nz == 0, 1, "base must have some coefficients\n"); tmir = DGG_newConstraint( base->nz ); tmir->sense = 'G'; tmir->rhs = bht * bup; for(i=0; i<base->nz; i++){ double v = base->coeff[i]; if (!isint[i]) { if (v > 0.0) tmir->coeff[lnz] = v; else tmir->coeff[lnz] = 0.0; } else { double vht = ABOV(v); DGG_IF_EXIT( vht<0, 1, "negative vht"); tmir->coeff[lnz] = bht * floor(v) + DGG_MIN(bht,vht); } tmir->index[lnz] = base->index[i]; lnz += 1; } tmir->nz = lnz; *cut_out = tmir; return 0; } int DGG_build2step( double alpha, char *isint, DGG_constraint_t *base, DGG_constraint_t **cut_out ) { DGG_constraint_t *tmir = 0; int i, lnz = 0; double vht, bht, bup, rho, tau, k; double b = (base->rhs); DGG_TEST( base->sense == 'L', 1, "this form not valid for L"); DGG_TEST( base->nz == 0, 1, "base must have some coefficients\n"); bht = ABOV(b); bup = ceil(b); tau = ceil(bht/alpha); rho = bht - alpha*floor(bht/alpha); /* ensure bht > alpha > 0 */ DGG_TEST3( (bht <= alpha) || (alpha <= 0.0), 1, "bad alpha (%f) / bht (%f) pair", alpha, bht); /* ensure that we are not in a limiting case */ DGG_TEST( DGG_is_a_multiple_of_b(alpha, bht), 1, "can't generate simple 2mir in limiting case"); /* ensure that rho is not zero */ DGG_TEST2( rho < DGG_MIN_RHO, 1, "rho (%f) too small", rho); /* initialize constraint */ tmir = DGG_newConstraint( base->nz ); tmir->rhs = bup*tau*rho; tmir->sense = 'G'; /* compute cut coefficients */ for(i=0; i<base->nz; i++){ double v = base->coeff[i]; if (!isint[i]) { if (v > 0.0) tmir->coeff[lnz] = v; else tmir->coeff[lnz] = 0.0; } else { vht = v - floor(v); DGG_IF_EXIT( vht < 0.0, 1, "negative vht"); k = DGG_MIN(tau-1,floor(vht/alpha)); tmir->coeff[lnz] = floor(v)*tau*rho + k*rho + DGG_MIN(rho,vht-k*alpha); } tmir->index[lnz] = base->index[i]; lnz += 1; } tmir->nz = lnz; *cut_out = tmir; return 0; } /******************* TEST / DEBUGGING ROUTINES ********************************/ /* DGG_is2stepValid: checks that: bht > alpha > 0 (1/alpha) >= tau > (bht/alpha) */ int DGG_is2stepValid(double alpha, double bht) { /* d */ double tau; /* ensure that alpha is not null or negative */ if ( alpha < DGG_MIN_ALPHA ) return 0; /* compute tau and tau_lim */ tau = ceil( bht / alpha ); /* make sure alpha is not a divisor of bht */ if ( DGG_is_a_multiple_of_b(alpha, bht) ) return 0; /* page 15, definition 12 */ /* check if alpha is admissible for simple-2-step-tmir */ if ( (bht > alpha) && (alpha > 0.0) ) if ( (1/alpha) >= tau ) return 1; /* not admissible */ return 0; } /* checks that its worth doing a 1MIR on the constraint. More precisely, - Is the RHS null? - Are there any integer variables set at fractional values? */ int DGG_isBaseTrivial(DGG_data_t *d, DGG_constraint_t* c) { /* is rhs sufficiently fractional */ if ( frac_part(ABOV(c->rhs)) < d->gomory_threshold ) return 1; if ( (1.0 - frac_part(ABOV(c->rhs))) < d->gomory_threshold ) return 1; return 0; } /* tests lhs vs rhs of a constraint */ int DGG_isConstraintViolated(DGG_data_t *d, DGG_constraint_t *c) { double lhs = DGG_cutLHS(c, d->x); double rhs = c->rhs; /* compare LHS and RHS */ if (c->sense == 'G') if ( lhs > (rhs - DGG_NULL_SLACK) ) return 0; if (c->sense == 'L') if ( lhs < (rhs + DGG_NULL_SLACK) ) return 0; if (c->sense == 'E') if ( fabs(lhs - rhs) < DGG_NULL_SLACK ) return 0; return 0; } double DGG_cutLHS(DGG_constraint_t *c, double *x) { int i; double lhs = 0.0; for(i=0; i < c->nz; i++) lhs += c->coeff[i]*x[c->index[i]]; return lhs; } int DGG_isCutDesirable(DGG_constraint_t *c, DGG_data_t *d) { double lhs, rhs; lhs = DGG_cutLHS(c, d->x); rhs = c->rhs; if (c->nz > 500) return 0; /* if the cut is not violated, return 0 */ if (c->sense == 'G') if ( lhs > (rhs - DGG_NULL_SLACK) ) return 0; if (c->sense == 'L') if ( lhs < (rhs + DGG_NULL_SLACK) ) return 0; if (c->sense == 'E') if ( fabs(lhs - rhs) < DGG_NULL_SLACK ) return 0; return 1; } /******************** SIMPLE MACROS AND FUNCTIONS *****************************/ int DGG_is_even(double vht, double bht, int tau, int q) { double v2 = V2I(bht, tau, q); if ( vht > v2 ) return 1; return 0; } double frac_part(double value) { return value-floor(value); } int DGG_is_a_multiple_of_b(double a, double b) { double c = b/a; if ( (b - a*floor(c)) < DGG_MIN_RHO ) return 1; return 0; } int DGG_cutsOffPoint(double *x, DGG_constraint_t *cut) { int i; double LHS = 0.0; for(i=0; i < cut->nz; i++) LHS += cut->coeff[i]*(x[ cut->index[i] ]); //fprintf(stdout, "LHS = %f, SENSE = %c, RHS = %f\n", LHS, cut->sense, cut->rhs); if ( cut->sense == 'E' ) if ( fabs(LHS - cut->rhs) > DGG_NULL_SLACK ) goto BAD; if (cut->sense == 'G' ) if ( (cut->rhs - LHS) > DGG_NULL_SLACK ) goto BAD; if (cut->sense == 'L' ) if ( (LHS - cut->rhs) > DGG_NULL_SLACK ) goto BAD; return 0; BAD: fprintf(stdout, "LHS = %f, SENSE = %c, RHS = %f\n", LHS, cut->sense, cut->rhs); DGG_TEST(1, 1, "found a bad cut!"); return 0; } // Returns true if needs optimal basis to do cuts bool CglTwomir::needsOptimalBasis() const { return true; } // Away stuff void CglTwomir::setAway(double value) { if (value>0.0&&value<=0.5) away_=value; } double CglTwomir::getAway() const { return away_; } // Away stuff at root void CglTwomir::setAwayAtRoot(double value) { if (value>0.0&&value<=0.5) awayAtRoot_=value; } double CglTwomir::getAwayAtRoot() const { return awayAtRoot_; } // This can be used to refresh any information void CglTwomir::refreshSolver(OsiSolverInterface * solver) { if (originalSolver_) { delete originalSolver_; originalSolver_ = solver->clone(); } } // Create C++ lines to get to current state std::string CglTwomir::generateCpp( FILE * fp) { CglTwomir other; fprintf(fp,"0#include \"CglTwomir.hpp\"\n"); fprintf(fp,"3 CglTwomir twomir;\n"); if (t_min_!=other.t_min_||t_max_!=other.t_max_) fprintf(fp,"3 twomir.setMirScale(%d,%d);\n",t_min_,t_max_); else fprintf(fp,"4 twomir.setMirScale(%d,%d);\n",t_min_,t_max_); if (q_min_!=other.q_min_||q_max_!=other.q_max_) fprintf(fp,"3 twomir.setTwomirScale(%d,%d);\n",q_min_,q_max_); else fprintf(fp,"4 twomir.setTwomirScale(%d,%d);\n",q_min_,q_max_); if (do_mir_!=other.do_mir_||do_2mir_!=other.do_2mir_|| do_tab_!=other.do_tab_||do_form_!=other.do_form_) fprintf(fp,"3 twomir.setCutTypes(%s,%s,%s,%s);\n", do_mir_ ? "true" : "false", do_2mir_ ? "true" : "false", do_tab_ ? "true" : "false", do_form_ ? "true" : "false"); else fprintf(fp,"4 twomir.setCutTypes(%s,%s,%s,%s);\n", do_mir_ ? "true" : "false", do_2mir_ ? "true" : "false", do_tab_ ? "true" : "false", do_form_ ? "true" : "false"); if (a_max_!=other.a_max_) fprintf(fp,"3 twomir.setAMax(%d);\n",a_max_); else fprintf(fp,"4 twomir.setAMax(%d);\n",a_max_); if (max_elements_!=other.max_elements_) fprintf(fp,"3 twomir.setMaxElements(%d);\n",max_elements_); else fprintf(fp,"4 twomir.setMaxElements(%d);\n",max_elements_); if (max_elements_root_!=other.max_elements_root_) fprintf(fp,"3 twomir.setMaxElementsRoot(%d);\n",max_elements_root_); else fprintf(fp,"4 twomir.setMaxElementsRoot(%d);\n",max_elements_root_); if (getAggressiveness()!=other.getAggressiveness()) fprintf(fp,"3 twomir.setAggressiveness(%d);\n",getAggressiveness()); else fprintf(fp,"4 twomir.setAggressiveness(%d);\n",getAggressiveness()); return "twomir"; }
28.881671
105
0.607471
amosr
33ef5d49ba2446e65f25fead5f1cc3e93da72c15
5,989
cc
C++
plugins/experimental/rate_limit/txn_limiter.cc
rob05c/trafficserver
b2004604e00bc7216856ea5e79082b4e53118a76
[ "Apache-2.0" ]
null
null
null
plugins/experimental/rate_limit/txn_limiter.cc
rob05c/trafficserver
b2004604e00bc7216856ea5e79082b4e53118a76
[ "Apache-2.0" ]
null
null
null
plugins/experimental/rate_limit/txn_limiter.cc
rob05c/trafficserver
b2004604e00bc7216856ea5e79082b4e53118a76
[ "Apache-2.0" ]
null
null
null
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <unistd.h> #include <getopt.h> #include <cstdlib> #include "txn_limiter.h" /////////////////////////////////////////////////////////////////////////////// // These continuations are "helpers" to the TXN limiter object. Putting them // outside the class implementation is just cleaner. // static int txn_limit_cont(TSCont cont, TSEvent event, void *edata) { TxnRateLimiter *limiter = static_cast<TxnRateLimiter *>(TSContDataGet(cont)); switch (event) { case TS_EVENT_HTTP_TXN_CLOSE: limiter->release(); TSContDestroy(cont); // We are done with this continuation now TSHttpTxnReenable(static_cast<TSHttpTxn>(edata), TS_EVENT_HTTP_CONTINUE); return TS_EVENT_CONTINUE; break; case TS_EVENT_HTTP_POST_REMAP: limiter->push(static_cast<TSHttpTxn>(edata), cont); return TS_EVENT_NONE; break; case TS_EVENT_HTTP_SEND_RESPONSE_HDR: // This is only applicable when we set an error in remap retryAfter(static_cast<TSHttpTxn>(edata), limiter->retry); TSContDestroy(cont); // We are done with this continuation now TSHttpTxnReenable(static_cast<TSHttpTxn>(edata), TS_EVENT_HTTP_CONTINUE); return TS_EVENT_CONTINUE; break; default: TSDebug(PLUGIN_NAME, "Unknown event %d", static_cast<int>(event)); TSError("Unknown event in %s", PLUGIN_NAME); break; } return TS_EVENT_NONE; } static int txn_queue_cont(TSCont cont, TSEvent event, void *edata) { TxnRateLimiter *limiter = static_cast<TxnRateLimiter *>(TSContDataGet(cont)); QueueTime now = std::chrono::system_clock::now(); // Only do this once per "loop" // Try to enable some queued txns (if any) if there are slots available while (limiter->size() > 0 && limiter->reserve()) { auto [txnp, contp, start_time] = limiter->pop(); std::chrono::milliseconds delay = std::chrono::duration_cast<std::chrono::milliseconds>(now - start_time); delayHeader(txnp, limiter->header, delay); TSDebug(PLUGIN_NAME, "Enabling queued txn after %ldms", static_cast<long>(delay.count())); // Since this was a delayed transaction, we need to add the TXN_CLOSE hook to free the slot when done TSHttpTxnHookAdd(txnp, TS_HTTP_TXN_CLOSE_HOOK, contp); TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); } // Kill any queued txns if they are too old if (limiter->size() > 0 && limiter->max_age > std::chrono::milliseconds::zero()) { now = std::chrono::system_clock::now(); // Update the "now", for some extra accuracy while (limiter->size() > 0 && limiter->hasOldEntity(now)) { // The oldest object on the queue is too old on the queue, so "kill" it. auto [txnp, contp, start_time] = limiter->pop(); std::chrono::milliseconds age = std::chrono::duration_cast<std::chrono::milliseconds>(now - start_time); delayHeader(txnp, limiter->header, age); TSDebug(PLUGIN_NAME, "Queued TXN is too old (%ldms), erroring out", static_cast<long>(age.count())); TSHttpTxnStatusSet(txnp, static_cast<TSHttpStatus>(limiter->error)); TSHttpTxnHookAdd(txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, contp); TSHttpTxnReenable(txnp, TS_EVENT_HTTP_ERROR); } } return TS_EVENT_NONE; } /////////////////////////////////////////////////////////////////////////////// // Parse the configurations for the TXN limiter. // bool TxnRateLimiter::initialize(int argc, const char *argv[]) { static const struct option longopt[] = { {const_cast<char *>("limit"), required_argument, nullptr, 'l'}, {const_cast<char *>("queue"), required_argument, nullptr, 'q'}, {const_cast<char *>("error"), required_argument, nullptr, 'e'}, {const_cast<char *>("retry"), required_argument, nullptr, 'r'}, {const_cast<char *>("header"), required_argument, nullptr, 'h'}, {const_cast<char *>("maxage"), required_argument, nullptr, 'm'}, // EOF {nullptr, no_argument, nullptr, '\0'}, }; while (true) { int opt = getopt_long(argc, (char *const *)argv, "", longopt, nullptr); switch (opt) { case 'l': this->limit = strtol(optarg, nullptr, 10); break; case 'q': this->max_queue = strtol(optarg, nullptr, 10); break; case 'e': this->error = strtol(optarg, nullptr, 10); break; case 'r': this->retry = strtol(optarg, nullptr, 10); break; case 'm': this->max_age = std::chrono::milliseconds(strtol(optarg, nullptr, 10)); break; case 'h': this->header = optarg; break; } if (opt == -1) { break; } } if (this->max_queue > 0) { _queue_cont = TSContCreate(txn_queue_cont, TSMutexCreate()); TSReleaseAssert(_queue_cont); TSContDataSet(_queue_cont, this); _action = TSContScheduleEveryOnPool(_queue_cont, QUEUE_DELAY_TIME.count(), TS_THREAD_POOL_TASK); } return true; } /////////////////////////////////////////////////////////////////////////////// // Sets up a transaction based continuation for this transaction. // void TxnRateLimiter::setupTxnCont(TSHttpTxn txnp, TSHttpHookID hook) { TSCont cont = TSContCreate(txn_limit_cont, nullptr); TSReleaseAssert(cont); TSContDataSet(cont, this); TSHttpTxnHookAdd(txnp, hook, cont); }
36.078313
111
0.667223
rob05c
33f0d6a9434a5f4585b17d460d2d86cf3750fb83
70,564
cpp
C++
test/float/mm-lin.cpp
SaGagnon/gecode-5.5.0-cbs
e871b320a9b2031423bb0fa452b1a5c09641a041
[ "MIT-feh" ]
1
2020-06-26T11:10:55.000Z
2020-06-26T11:10:55.000Z
test/float/mm-lin.cpp
SaGagnon/gecode-5.5.0-cbs
e871b320a9b2031423bb0fa452b1a5c09641a041
[ "MIT-feh" ]
null
null
null
test/float/mm-lin.cpp
SaGagnon/gecode-5.5.0-cbs
e871b320a9b2031423bb0fa452b1a5c09641a041
[ "MIT-feh" ]
1
2020-06-26T11:10:57.000Z
2020-06-26T11:10:57.000Z
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Christian Schulte <schulte@gecode.org> * * Copyright: * Christian Schulte, 2008, 2012 * * Last modified: * $Date: 2016-04-19 17:19:45 +0200 (Tue, 19 Apr 2016) $ by $Author: schulte $ * $Revision: 14967 $ * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * 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 "test/int.hh" #include "test/float.hh" #include <gecode/minimodel.hh> namespace Test { namespace Float { /// %Tests for minimal modeling constraints (linear) namespace MiniModelLin { /// Linear opcode enum LinOpcode { LO_ACE, ///< Add float and expression LO_AEC, ///< Add expression and float LO_AEE, ///< Add expressions LO_SCE, ///< Subtract float and expression LO_SEC, ///< Subtract expression and float LO_SEE, ///< Subtract expressions LO_SE, ///< Unary subtraction LO_MCE, ///< Multiply constant and expression LO_MEC, ///< Multiply constant and expression LO_HLT ///< Stop execution }; /// Type for representing a linear instruction class LinInstr { public: LinOpcode o; ///< Which instruction to execute unsigned char x, y, z; ///< Instruction arguments, \a y is destination (or \a z) int c; ///< Numerical constant }; /// Evaluate linear instructions template<class Expr> Expr eval(const LinInstr* pc, Expr reg[]) { while (true) { switch (pc->o) { case LO_ACE: reg[pc->y] = pc->c + reg[pc->x]; break; case LO_AEC: reg[pc->y] = reg[pc->x] + pc->c; break; case LO_AEE: reg[pc->z] = reg[pc->x] + reg[pc->y]; break; case LO_SCE: reg[pc->y] = pc->c - reg[pc->x]; break; case LO_SEC: reg[pc->y] = reg[pc->x] - pc->c; break; case LO_SEE: reg[pc->z] = reg[pc->x] - reg[pc->y]; break; case LO_SE: reg[pc->y] = -reg[pc->x]; break; case LO_MCE: reg[pc->y] = pc->c * reg[pc->x]; break; case LO_MEC: reg[pc->y] = reg[pc->x] * pc->c; break; case LO_HLT: return reg[pc->x]; default: GECODE_NEVER; } pc++; } GECODE_NEVER; } /** * \defgroup TaskTestFloatMiniModelLin Minimal modeling constraints (linear constraints) * \ingroup TaskTestFloat */ //@{ /// %Test linear expressions over float variables class LinExpr : public Int::Test { protected: /// Linear instruction sequence const LinInstr* lis; public: /// Create and register test LinExpr(const LinInstr* lis0, const std::string& s) : Test("Float::","MiniModel::LinExpr::"+s,4,-3,3), lis(lis0) { testfix = false; } /// %Test whether \a x is solution virtual bool solution(const Int::Assignment& x) const { int reg[3] = {x[0],x[1],x[2]}; return eval(lis, reg) == x[3]; } /// Post constraint on \a x virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) { using namespace Gecode; FloatVarArray y(home,4,dom.min(),dom.max()); channel(home, x[0], y[0]); channel(home, x[1], y[1]); channel(home, x[2], y[2]); channel(home, x[3], y[3]); LinFloatExpr reg[3] = {y[0],y[1],y[2]}; rel(home, y[3], FRT_EQ, expr(home, eval(lis,reg))); } }; /// %Test linear relations over float variables class LinRel : public Int::Test { protected: /// Linear instruction sequence for left hand side const LinInstr* l_lis; /// Linear instruction sequence for right hand side const LinInstr* r_lis; /// Float relation type to propagate Gecode::FloatRelType frt; public: /// Create and register test LinRel(const LinInstr* l_lis0, const LinInstr* r_lis0, Gecode::FloatRelType frt0, const std::string& s) : Test("Float::","MiniModel::LinRel::"+s+"::"+ Float::Test::str(frt0),3,-3,3), l_lis(l_lis0), r_lis(r_lis0), frt(frt0) { testfix = false; } /// %Test whether \a x is solution virtual bool solution(const Int::Assignment& x) const { using namespace Gecode; int l_reg[3] = {x[0],x[1],x[2]}; int l = eval(l_lis,l_reg); int r_reg[3] = {x[0],x[1],x[2]}; int r = eval(r_lis,r_reg); switch (frt) { case FRT_EQ: return l == r; case FRT_NQ: return l != r; case FRT_LE: return l < r; case FRT_GR: return l > r; case FRT_LQ: return l <= r; case FRT_GQ: return l >= r; default: GECODE_NEVER; } return false; } /// Post constraint on \a x virtual void post(Gecode::Space& home, Gecode::IntVarArray& x) { using namespace Gecode; FloatVarArray y(home,3,dom.min(),dom.max()); channel(home, x[0], y[0]); channel(home, x[1], y[1]); channel(home, x[2], y[2]); LinFloatExpr l_reg[3] = {y[0],y[1],y[2]}; LinFloatExpr r_reg[3] = {y[0],y[1],y[2]}; switch (frt) { case FRT_EQ: Gecode::rel(home, eval(l_lis,l_reg) == eval(r_lis,r_reg)); break; case FRT_NQ: Gecode::rel(home, eval(l_lis,l_reg) != eval(r_lis,r_reg)); break; case FRT_LQ: Gecode::rel(home, eval(l_lis,l_reg) <= eval(r_lis,r_reg)); break; case FRT_LE: Gecode::rel(home, eval(l_lis,l_reg) < eval(r_lis,r_reg)); break; case FRT_GQ: Gecode::rel(home, eval(l_lis,l_reg) >= eval(r_lis,r_reg)); break; case FRT_GR: Gecode::rel(home, eval(l_lis,l_reg) > eval(r_lis,r_reg)); break; default: GECODE_NEVER; } } }; const LinInstr li000[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li001[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li002[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li003[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li004[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li005[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li006[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li007[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li008[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li009[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li010[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li011[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li012[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li013[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li014[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li015[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li016[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li017[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li018[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li019[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li020[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li021[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li022[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li023[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li024[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li025[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li026[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li027[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li028[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li029[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li030[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li031[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li032[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li033[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li034[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li035[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li036[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li037[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li038[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li039[] = { {LO_AEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li040[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li041[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li042[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li043[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li044[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li045[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li046[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li047[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li048[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li049[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li050[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li051[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li052[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li053[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li054[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li055[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li056[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li057[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li058[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li059[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li060[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li061[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li062[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li063[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li064[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li065[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li066[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li067[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li068[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li069[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li070[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li071[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li072[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li073[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li074[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li075[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li076[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li077[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li078[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li079[] = { {LO_AEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li080[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li081[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li082[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li083[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li084[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li085[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li086[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li087[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li088[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li089[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li090[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li091[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li092[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li093[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li094[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li095[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li096[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li097[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li098[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li099[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li100[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li101[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li102[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li103[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li104[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li105[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li106[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li107[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li108[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li109[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li110[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li111[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li112[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li113[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li114[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li115[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li116[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li117[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li118[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li119[] = { {LO_AEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li120[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li121[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li122[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li123[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li124[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li125[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li126[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li127[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li128[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li129[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li130[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li131[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li132[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li133[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li134[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li135[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li136[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li137[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li138[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li139[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li140[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li141[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li142[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li143[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li144[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li145[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li146[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li147[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li148[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li149[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li150[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li151[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li152[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li153[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li154[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li155[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li156[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li157[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li158[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li159[] = { {LO_AEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li160[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li161[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li162[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li163[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li164[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li165[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li166[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li167[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li168[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li169[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li170[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li171[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li172[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li173[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li174[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li175[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li176[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li177[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li178[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li179[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li180[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li181[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li182[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li183[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li184[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li185[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li186[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li187[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li188[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li189[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li190[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li191[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li192[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li193[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li194[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li195[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li196[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li197[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li198[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li199[] = { {LO_AEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li200[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li201[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li202[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li203[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li204[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li205[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li206[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li207[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li208[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li209[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li210[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li211[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li212[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li213[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li214[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li215[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li216[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li217[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li218[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li219[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li220[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li221[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li222[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li223[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li224[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li225[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li226[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li227[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li228[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li229[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li230[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li231[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li232[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li233[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li234[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li235[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li236[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li237[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li238[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li239[] = { {LO_SEE,0,1,0, 0},{LO_AEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li240[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li241[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li242[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li243[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li244[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li245[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li246[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li247[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li248[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li249[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li250[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li251[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li252[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li253[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li254[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li255[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li256[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li257[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li258[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li259[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li260[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li261[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li262[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li263[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li264[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li265[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li266[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li267[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li268[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li269[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li270[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li271[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li272[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li273[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li274[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li275[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li276[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li277[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li278[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li279[] = { {LO_SEE,0,1,0, 0},{LO_SCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li280[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li281[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li282[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li283[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li284[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li285[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li286[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li287[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li288[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li289[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li290[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li291[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li292[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li293[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li294[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li295[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li296[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li297[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li298[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li299[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li300[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li301[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li302[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li303[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li304[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li305[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li306[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li307[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li308[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li309[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li310[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li311[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li312[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li313[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li314[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li315[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li316[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li317[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li318[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li319[] = { {LO_SEE,0,1,0, 0},{LO_SEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li320[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li321[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li322[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li323[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li324[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li325[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li326[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li327[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li328[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li329[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li330[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li331[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li332[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li333[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li334[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li335[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li336[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li337[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li338[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li339[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li340[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li341[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li342[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li343[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li344[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li345[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li346[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li347[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li348[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li349[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li350[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li351[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li352[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li353[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li354[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li355[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li356[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li357[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li358[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li359[] = { {LO_SEE,0,1,0, 0},{LO_MCE,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li360[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li361[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li362[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li363[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li364[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li365[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li366[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li367[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li368[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li369[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li370[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li371[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li372[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li373[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li374[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li375[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0,-1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li376[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li377[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li378[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li379[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li380[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li381[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li382[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li383[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 0},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li384[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li385[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li386[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li387[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li388[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li389[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li390[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li391[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 1},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li392[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li393[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li394[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li395[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_AEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li396[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0,-1},{LO_HLT,0,0,0, 0} }; const LinInstr li397[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_ACE,0,0,0, 1},{LO_HLT,0,0,0, 0} }; const LinInstr li398[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr li399[] = { {LO_SEE,0,1,0, 0},{LO_MEC,0,0,0, 2},{LO_SEE,0,2,0, 0}, {LO_SE ,0,0,0, 0},{LO_HLT,0,0,0, 0} }; const LinInstr* li[] = { &li000[0],&li001[0],&li002[0],&li003[0],&li004[0],&li005[0], &li006[0],&li007[0],&li008[0],&li009[0],&li010[0],&li011[0], &li012[0],&li013[0],&li014[0],&li015[0],&li016[0],&li017[0], &li018[0],&li019[0],&li020[0],&li021[0],&li022[0],&li023[0], &li024[0],&li025[0],&li026[0],&li027[0],&li028[0],&li029[0], &li030[0],&li031[0],&li032[0],&li033[0],&li034[0],&li035[0], &li036[0],&li037[0],&li038[0],&li039[0],&li040[0],&li041[0], &li042[0],&li043[0],&li044[0],&li045[0],&li046[0],&li047[0], &li048[0],&li049[0],&li050[0],&li051[0],&li052[0],&li053[0], &li054[0],&li055[0],&li056[0],&li057[0],&li058[0],&li059[0], &li060[0],&li061[0],&li062[0],&li063[0],&li064[0],&li065[0], &li066[0],&li067[0],&li068[0],&li069[0],&li070[0],&li071[0], &li072[0],&li073[0],&li074[0],&li075[0],&li076[0],&li077[0], &li078[0],&li079[0],&li080[0],&li081[0],&li082[0],&li083[0], &li084[0],&li085[0],&li086[0],&li087[0],&li088[0],&li089[0], &li090[0],&li091[0],&li092[0],&li093[0],&li094[0],&li095[0], &li096[0],&li097[0],&li098[0],&li099[0],&li100[0],&li101[0], &li102[0],&li103[0],&li104[0],&li105[0],&li106[0],&li107[0], &li108[0],&li109[0],&li110[0],&li111[0],&li112[0],&li113[0], &li114[0],&li115[0],&li116[0],&li117[0],&li118[0],&li119[0], &li120[0],&li121[0],&li122[0],&li123[0],&li124[0],&li125[0], &li126[0],&li127[0],&li128[0],&li129[0],&li130[0],&li131[0], &li132[0],&li133[0],&li134[0],&li135[0],&li136[0],&li137[0], &li138[0],&li139[0],&li140[0],&li141[0],&li142[0],&li143[0], &li144[0],&li145[0],&li146[0],&li147[0],&li148[0],&li149[0], &li150[0],&li151[0],&li152[0],&li153[0],&li154[0],&li155[0], &li156[0],&li157[0],&li158[0],&li159[0],&li160[0],&li161[0], &li162[0],&li163[0],&li164[0],&li165[0],&li166[0],&li167[0], &li168[0],&li169[0],&li170[0],&li171[0],&li172[0],&li173[0], &li174[0],&li175[0],&li176[0],&li177[0],&li178[0],&li179[0], &li180[0],&li181[0],&li182[0],&li183[0],&li184[0],&li185[0], &li186[0],&li187[0],&li188[0],&li189[0],&li190[0],&li191[0], &li192[0],&li193[0],&li194[0],&li195[0],&li196[0],&li197[0], &li198[0],&li199[0],&li200[0],&li201[0],&li202[0],&li203[0], &li204[0],&li205[0],&li206[0],&li207[0],&li208[0],&li209[0], &li210[0],&li211[0],&li212[0],&li213[0],&li214[0],&li215[0], &li216[0],&li217[0],&li218[0],&li219[0],&li220[0],&li221[0], &li222[0],&li223[0],&li224[0],&li225[0],&li226[0],&li227[0], &li228[0],&li229[0],&li230[0],&li231[0],&li232[0],&li233[0], &li234[0],&li235[0],&li236[0],&li237[0],&li238[0],&li239[0], &li240[0],&li241[0],&li242[0],&li243[0],&li244[0],&li245[0], &li246[0],&li247[0],&li248[0],&li249[0],&li250[0],&li251[0], &li252[0],&li253[0],&li254[0],&li255[0],&li256[0],&li257[0], &li258[0],&li259[0],&li260[0],&li261[0],&li262[0],&li263[0], &li264[0],&li265[0],&li266[0],&li267[0],&li268[0],&li269[0], &li270[0],&li271[0],&li272[0],&li273[0],&li274[0],&li275[0], &li276[0],&li277[0],&li278[0],&li279[0],&li280[0],&li281[0], &li282[0],&li283[0],&li284[0],&li285[0],&li286[0],&li287[0], &li288[0],&li289[0],&li290[0],&li291[0],&li292[0],&li293[0], &li294[0],&li295[0],&li296[0],&li297[0],&li298[0],&li299[0], &li300[0],&li301[0],&li302[0],&li303[0],&li304[0],&li305[0], &li306[0],&li307[0],&li308[0],&li309[0],&li310[0],&li311[0], &li312[0],&li313[0],&li314[0],&li315[0],&li316[0],&li317[0], &li318[0],&li319[0],&li320[0],&li321[0],&li322[0],&li323[0], &li324[0],&li325[0],&li326[0],&li327[0],&li328[0],&li329[0], &li330[0],&li331[0],&li332[0],&li333[0],&li334[0],&li335[0], &li336[0],&li337[0],&li338[0],&li339[0],&li340[0],&li341[0], &li342[0],&li343[0],&li344[0],&li345[0],&li346[0],&li347[0], &li348[0],&li349[0],&li350[0],&li351[0],&li352[0],&li353[0], &li354[0],&li355[0],&li356[0],&li357[0],&li358[0],&li359[0], &li360[0],&li361[0],&li362[0],&li363[0],&li364[0],&li365[0], &li366[0],&li367[0],&li368[0],&li369[0],&li370[0],&li371[0], &li372[0],&li373[0],&li374[0],&li375[0],&li376[0],&li377[0], &li378[0],&li379[0],&li380[0],&li381[0],&li382[0],&li383[0], &li384[0],&li385[0],&li386[0],&li387[0],&li388[0],&li389[0], &li390[0],&li391[0],&li392[0],&li393[0],&li394[0],&li395[0], &li396[0],&li397[0],&li398[0],&li399[0], }; /// Help class to create and register tests class Create { public: /// Perform creation and registration Create(void) { int n = sizeof(li)/sizeof(LinInstr*); for (int i=0; i<n; i++) { std::string s = Test::str(i); if (i < 10) { s = "00" + s; } else if (i < 100) { s = "0" + s; } (void) new LinExpr(li[i],s); } FloatRelTypes frts; for (int i=0; i<n/2; i++) { std::string s = Test::str(i); if (i < 10) { s = "00" + s; } else if (i < 100) { s = "0" + s; } (void) new LinRel(li[2*i],li[2*i+1],frts.frt(),s); ++frts; if (!frts()) frts.reset(); } } }; Create c; //@} } }} // STATISTICS: test-minimodel
37.022036
93
0.47931
SaGagnon
33f0ea2f87ab3ec36f7a8e8c8ad355428d287a2f
5,179
cc
C++
mindspore/lite/src/runtime/kernel/arm/fp16/pad_fp16.cc
mindspore-ai/mindspore
a9fbb25530a2874166ff0045ddcdfc73207bf5eb
[ "Apache-2.0" ]
3,200
2020-02-17T12:45:41.000Z
2022-03-31T20:21:16.000Z
mindspore/lite/src/runtime/kernel/arm/fp16/pad_fp16.cc
mindspore-ai/mindspore
a9fbb25530a2874166ff0045ddcdfc73207bf5eb
[ "Apache-2.0" ]
176
2020-02-12T02:52:11.000Z
2022-03-28T22:15:55.000Z
mindspore/lite/src/runtime/kernel/arm/fp16/pad_fp16.cc
mindspore-ai/mindspore
a9fbb25530a2874166ff0045ddcdfc73207bf5eb
[ "Apache-2.0" ]
621
2020-03-09T01:31:41.000Z
2022-03-30T03:43:19.000Z
/** * Copyright 2020 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "src/runtime/kernel/arm/fp16/pad_fp16.h" #include "src/runtime/kernel/arm/fp16/common_fp16.h" #include "src/kernel_registry.h" using mindspore::kernel::KERNEL_ARCH; using mindspore::lite::KernelRegistrar; using mindspore::lite::RET_ERROR; using mindspore::lite::RET_OK; using mindspore::schema::PrimitiveType_PadFusion; namespace mindspore::kernel { namespace { constexpr size_t kPadCommonInputSize = 2; } // namespace int PadFp16CPUKernel::RunImpl(int task_id) { PadFp16(input_, output_, in_, out_, pad_param_->paddings_, task_id, op_parameter_->thread_num_); return RET_OK; } int PadFp16CPUKernel::RunMirrorPadImpl(int task_id) { auto input = in_tensors_.at(0); CHECK_NULL_RETURN(input); auto output = out_tensors_.at(0); CHECK_NULL_RETURN(output); auto input_data = reinterpret_cast<float16_t *>(input->data()); CHECK_NULL_RETURN(input_data); auto output_data = reinterpret_cast<float16_t *>(output->data()); CHECK_NULL_RETURN(output_data); /* Fast Mirror pad */ if (mirror_pad_block_.size() != 0) { /* copy center part */ PadFp16(input_data, output_data, in_, out_, pad_param_->paddings_, task_id, op_parameter_->thread_num_); /* calculate region part */ for (size_t i = task_id; i < mirror_pad_block_.size(); i += op_parameter_->thread_num_) { auto block = mirror_pad_block_[i]; for (int a = 0; a < block.size_[0]; a++) { int out_a_index = block.out_offset_ + a * block.out_stride_[0]; for (int b = 0; b < block.size_[1]; b++) { int out_b_index = out_a_index + b * block.out_stride_[1]; for (int c = 0; c < block.size_[2]; ++c) { int out_c_index = out_b_index + c * block.out_stride_[2]; for (int d = 0; d < block.size_[3]; ++d) { int out_d_index = out_c_index + d * block.out_stride_[3]; for (int e = 0; e < block.size_[4]; ++e) { int output_index = out_d_index + e * block.out_stride_[4]; MirrorPadFp16(input_data, output_data, in_, pad_param_, output_index, output_index + block.size_[5]); } } } } } } return RET_OK; } MS_CHECK_FALSE(op_parameter_->thread_num_ == 0, RET_ERROR); int unit = UP_DIV(out_tensors_.at(0)->ElementsNum(), op_parameter_->thread_num_); int begin = unit * task_id; int end = MSMIN(begin + unit, out_tensors_.at(0)->ElementsNum()); MirrorPadFp16(input_, output_, in_, pad_param_, begin, end); return RET_OK; } int PadFp16CPUKernel::Run() { if (in_tensors_.size() == kInputSize2) { auto pad_value = in_tensors_.at(2); auto value_num = pad_value->ElementsNum(); if (value_num != 1) { MS_LOG(ERROR) << "The number of padding value should be only one, but got " << value_num; return RET_ERROR; } CHECK_NULL_RETURN(pad_value->data()); pad_param_->constant_value_ = *(reinterpret_cast<float16_t *>(pad_value->data())); } auto input_tensor = in_tensors_.at(0); auto output_tensor = out_tensors_.at(0); input_ = reinterpret_cast<float16_t *>(input_tensor->data()); output_ = reinterpret_cast<float16_t *>(output_tensor->data()); CHECK_NULL_RETURN(input_); CHECK_NULL_RETURN(output_); int ret = 0; if (pad_param_->pad_mode_ == static_cast<int>(schema::PaddingMode_CONSTANT)) { if (in_tensors_.size() >= kPadCommonInputSize) { ret = CopyPaddingFromInput(); if (ret != RET_OK) { MS_LOG(ERROR) << "PadFp16CPUKernel CopyPaddingFromInput failed"; return RET_ERROR; } } if (pad_param_->constant_value_ - 0.0f < 1e-5) { memset(output_, 0, output_tensor->ElementsNum() * sizeof(float16_t)); } else { for (int i = 0; i < output_tensor->ElementsNum(); ++i) { output_[i] = pad_param_->constant_value_; } } ret = ParallelLaunch(this->ms_context_, PadImpl, this, op_parameter_->thread_num_); if (ret != RET_OK) { MS_LOG(ERROR) << "BatchnormRun error error_code[" << ret << "]"; } } else { // mirror pad case ret = HandleMirrorPad(); if (ret != RET_OK) { MS_LOG(ERROR) << "Handle mirror pad failed, error_code[" << ret << "]"; return ret; } ret = ParallelLaunch(this->ms_context_, MirrorPadImpl, this, op_parameter_->thread_num_); if (ret != RET_OK) { MS_LOG(ERROR) << "Pad Reflect or Symmetric mode run error, error_code[" << ret << "]"; } } return ret; } REG_KERNEL(kCPU, kNumberTypeFloat16, PrimitiveType_PadFusion, LiteKernelCreator<PadFp16CPUKernel>) } // namespace mindspore::kernel
37.258993
117
0.666924
mindspore-ai